mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-07-14 02:55:07 +08:00
添加 serviceImpl.vm 的模板
This commit is contained in:
@ -3,7 +3,7 @@ package ${basePackage}.${table.moduleName}.dal.mysql.dataobject.${table.business
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import ${baseDOClassName};
|
||||
import ${BaseDOClassName};
|
||||
|
||||
/**
|
||||
* ${table.classComment} DO
|
||||
|
@ -1,2 +1,2 @@
|
||||
// ========== ${table.classCommet} TODO 补充编号 ==========
|
||||
ErrorCode ${simpleClassName_underlineCase.toUpperCase()}_NOT_FOUND = new ErrorCode(TODO 补充编号, "${table.classComment}不存在}");
|
||||
// ========== ${table.classComment} TODO 补充编号 ==========
|
||||
ErrorCode ${simpleClassName_underlineCase.toUpperCase()}_NOT_EXISTS = new ErrorCode(TODO 补充编号, "${table.classComment}不存在}");
|
||||
|
@ -10,6 +10,12 @@ import ${basePackage}.${table.moduleName}.controller.${table.businessName}.vo.*;
|
||||
import ${basePackage}.${table.moduleName}.dal.mysql.dataobject.${table.businessName}.${table.className}DO;
|
||||
import ${PageResultClassName};
|
||||
|
||||
import ${basePackage}.${table.moduleName}.convert.${table.businessName}.${table.className}Convert;
|
||||
import ${basePackage}.${table.moduleName}.dal.mysql.dao.${table.businessName}.${table.className}Mapper;
|
||||
import ${basePackage}.${table.moduleName}.service.${table.businessName}.${table.className}Service;
|
||||
|
||||
import ${ServiceExceptionUtilClassName};
|
||||
|
||||
import static ${basePackage}.${table.moduleName}.enums.${simpleModuleName.substring(0,1).toUpperCase()}${simpleModuleName.substring(1)}ErrorCodeConstants.*;
|
||||
|
||||
/**
|
||||
@ -17,14 +23,58 @@ import static ${basePackage}.${table.moduleName}.enums.${simpleModuleName.substr
|
||||
*
|
||||
* @author ${table.author}
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class ${table.className}ServiceImpl implements {table.className}Service {
|
||||
public class ${table.className}ServiceImpl implements ${table.className}Service {
|
||||
|
||||
@Resource
|
||||
private ${table.className}Mapper ${classNameVar}Mapper;
|
||||
|
||||
@Override
|
||||
public ${primaryColumn.javaType} create${simpleClassName}(@Valid ${table.className}CreateReqVO createReqVO) {
|
||||
public ${primaryColumn.javaType} create${simpleClassName}(${table.className}CreateReqVO createReqVO) {
|
||||
// 插入
|
||||
${table.className}DO ${classNameVar} = ${table.className}Convert.INSTANCE.convert(createReqVO);
|
||||
${classNameVar}Mapper.insert(${classNameVar});
|
||||
// 返回
|
||||
return ${classNameVar}.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update${simpleClassName}(${table.className}UpdateReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
this.validate${simpleClassName}Exists(updateReqVO.getId());
|
||||
// 更新
|
||||
${table.className}DO updateObj = ${table.className}Convert.INSTANCE.convert(updateReqVO);
|
||||
${classNameVar}Mapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete${simpleClassName}(${primaryColumn.javaType} id) {
|
||||
// 校验存在
|
||||
this.validate${simpleClassName}Exists(id);
|
||||
// 更新
|
||||
${classNameVar}Mapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void validate${simpleClassName}Exists(${primaryColumn.javaType} id) {
|
||||
if (${classNameVar}Mapper.selectById(id) == null) {
|
||||
throw ServiceExceptionUtil.exception(${simpleClassName_underlineCase.toUpperCase()}_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ${table.className}DO get${simpleClassName}(${primaryColumn.javaType} id) {
|
||||
return ${classNameVar}Mapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<${table.className}DO> get${simpleClassName}List(Collection<${primaryColumn.javaType}> ids) {
|
||||
return ${classNameVar}Mapper.selectBatchIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<${table.className}DO> get${simpleClassName}Page(${table.className}PageReqVO pageReqVO) {
|
||||
return ${classNameVar}Mapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user