feat: 代码生成器生成subject_liked模块基础代码

This commit is contained in:
2024-03-08 13:54:28 +08:00
parent dfe75eec5a
commit f613d757c0
71 changed files with 3293 additions and 0 deletions

View File

@@ -0,0 +1,115 @@
package com.landaiqing.subject.application.controller;
import com.alibaba.fastjson.JSON;
import com.google.common.base.Preconditions;
import com.landaiqing.subject.application.convert.SubjectLikedDTOConverter;
import com.landaiqing.subject.application.dto.SubjectLikedDTO;
import com.landaiqing.subject.common.entity.Result;
import com.landaiqing.subject.domain.entity.SubjectLikedBO;
import com.landaiqing.subject.domain.service.SubjectLikedDomainService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
/**
* 题目点赞表 controller
*
* @author landaiqing
* @since 2024-03-08 13:44:59
*/
@RestController
@RequestMapping("/subjectLiked/")
@Slf4j
public class SubjectLikedController {
@Resource
private SubjectLikedDomainService subjectLikedDomainService;
/**
* 新增题目点赞表
*/
@RequestMapping("add")
public Result<Boolean> add(@RequestBody SubjectLikedDTO subjectLikedDTO) {
try {
if (log.isInfoEnabled()) {
log.info("SubjectLikedController.add.dto:{}", JSON.toJSONString(subjectLikedDTO));
}
Preconditions.checkNotNull(subjectLikedDTO.getId(), "不能为空");
Preconditions.checkNotNull(subjectLikedDTO.getSubjectId(), "不能为空");
Preconditions.checkNotNull(subjectLikedDTO.getLikeUserId(), "不能为空");
Preconditions.checkNotNull(subjectLikedDTO.getStatus(), "不能为空");
Preconditions.checkNotNull(subjectLikedDTO.getCreatedBy(), "创建人不能为空");
Preconditions.checkNotNull(subjectLikedDTO.getCreatedTime(), "创建时间不能为空");
Preconditions.checkNotNull(subjectLikedDTO.getUpdateBy(), "更新人不能为空");
Preconditions.checkNotNull(subjectLikedDTO.getUpdateTime(), "更新时间不能为空");
Preconditions.checkNotNull(subjectLikedDTO.getIsDeleted(), "不能为空");
SubjectLikedBO SubjectLikedBO = SubjectLikedDTOConverter.INSTANCE.convertDTOToBO(subjectLikedDTO);
return Result.ok(subjectLikedDomainService.add(SubjectLikedBO));
} catch (Exception e) {
log.error("SubjectLikedController.register.error:{}", e.getMessage(), e);
return Result.fail("新增题目点赞表失败");
}
}
/**
* 修改题目点赞表
*/
@RequestMapping("update")
public Result<Boolean> update(@RequestBody SubjectLikedDTO subjectLikedDTO) {
try {
if (log.isInfoEnabled()) {
log.info("SubjectLikedController.update.dto:{}", JSON.toJSONString(subjectLikedDTO));
}
Preconditions.checkNotNull(subjectLikedDTO.getId(), "不能为空");
Preconditions.checkNotNull(subjectLikedDTO.getSubjectId(), "不能为空");
Preconditions.checkNotNull(subjectLikedDTO.getLikeUserId(), "不能为空");
Preconditions.checkNotNull(subjectLikedDTO.getStatus(), "不能为空");
Preconditions.checkNotNull(subjectLikedDTO.getCreatedBy(), "创建人不能为空");
Preconditions.checkNotNull(subjectLikedDTO.getCreatedTime(), "创建时间不能为空");
Preconditions.checkNotNull(subjectLikedDTO.getUpdateBy(), "更新人不能为空");
Preconditions.checkNotNull(subjectLikedDTO.getUpdateTime(), "更新时间不能为空");
Preconditions.checkNotNull(subjectLikedDTO.getIsDeleted(), "不能为空");
SubjectLikedBO subjectLikedBO = SubjectLikedDTOConverter.INSTANCE.convertDTOToBO(subjectLikedDTO);
return Result.ok(subjectLikedDomainService.update(subjectLikedBO));
} catch (Exception e) {
log.error("SubjectLikedController.update.error:{}", e.getMessage(), e);
return Result.fail("更新题目点赞表信息失败");
}
}
/**
* 删除题目点赞表
*/
@RequestMapping("delete")
public Result<Boolean> delete(@RequestBody SubjectLikedDTO subjectLikedDTO) {
try {
if (log.isInfoEnabled()) {
log.info("SubjectLikedController.delete.dto:{}", JSON.toJSONString(subjectLikedDTO));
}
Preconditions.checkNotNull(subjectLikedDTO.getId(), "不能为空");
Preconditions.checkNotNull(subjectLikedDTO.getSubjectId(), "不能为空");
Preconditions.checkNotNull(subjectLikedDTO.getLikeUserId(), "不能为空");
Preconditions.checkNotNull(subjectLikedDTO.getStatus(), "不能为空");
Preconditions.checkNotNull(subjectLikedDTO.getCreatedBy(), "创建人不能为空");
Preconditions.checkNotNull(subjectLikedDTO.getCreatedTime(), "创建时间不能为空");
Preconditions.checkNotNull(subjectLikedDTO.getUpdateBy(), "更新人不能为空");
Preconditions.checkNotNull(subjectLikedDTO.getUpdateTime(), "更新时间不能为空");
Preconditions.checkNotNull(subjectLikedDTO.getIsDeleted(), "不能为空");
SubjectLikedBO subjectLikedBO = SubjectLikedDTOConverter.INSTANCE.convertDTOToBO(subjectLikedDTO);
return Result.ok(subjectLikedDomainService.delete(subjectLikedBO));
} catch (Exception e) {
log.error("SubjectLikedController.delete.error:{}", e.getMessage(), e);
return Result.fail("删除题目点赞表信息失败");
}
}
}

View File

@@ -0,0 +1,21 @@
package com.landaiqing.subject.application.convert;
import com.landaiqing.subject.application.dto.SubjectLikedDTO;
import com.landaiqing.subject.domain.entity.SubjectLikedBO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
/**
* 题目点赞表 dto转换器
*
* @author landaiqing
* @since 2024-03-08 13:44:59
*/
@Mapper
public interface SubjectLikedDTOConverter {
SubjectLikedDTOConverter INSTANCE = Mappers.getMapper(SubjectLikedDTOConverter.class);
SubjectLikedBO convertDTOToBO(SubjectLikedDTO subjectLikedDTO);
}

View File

@@ -0,0 +1,63 @@
package com.landaiqing.subject.application.dto;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* 题目点赞表 dto
*
* @author landaiqing
* @since 2024-03-08 13:44:59
*/
@Data
public class SubjectLikedDTO implements Serializable {
/**
*
*/
private Long id;
/**
*
*/
private Long subjectId;
/**
*
*/
private String likeUserId;
/**
*
*/
private Integer status;
/**
* 创建人
*/
private String createdBy;
/**
* 创建时间
*/
private Date createdTime;
/**
* 更新人
*/
private String updateBy;
/**
* 更新时间
*/
private Date updateTime;
/**
*
*/
private Integer isDeleted;
}