2021-02-06 23:52:26 +08:00
|
|
|
package ${basePackage}.${table.moduleName}.service.${table.businessName}.impl;
|
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
|
|
|
import java.util.*;
|
|
|
|
import ${basePackage}.${table.moduleName}.controller.${table.businessName}.vo.*;
|
2021-02-10 13:41:00 +08:00
|
|
|
import ${basePackage}.${table.moduleName}.dal.dataobject.${table.businessName}.${table.className}DO;
|
2021-02-06 23:52:26 +08:00
|
|
|
import ${PageResultClassName};
|
|
|
|
|
2021-02-07 00:34:54 +08:00
|
|
|
import ${basePackage}.${table.moduleName}.convert.${table.businessName}.${table.className}Convert;
|
2021-02-10 13:41:00 +08:00
|
|
|
import ${basePackage}.${table.moduleName}.dal.mysql.${table.businessName}.${table.className}Mapper;
|
2021-02-07 00:34:54 +08:00
|
|
|
import ${basePackage}.${table.moduleName}.service.${table.businessName}.${table.className}Service;
|
|
|
|
|
|
|
|
import ${ServiceExceptionUtilClassName};
|
|
|
|
|
2021-02-10 14:52:28 +08:00
|
|
|
import static ${basePackage}.${table.moduleName}.enums.${simpleModuleName_upperFirst}ErrorCodeConstants.*;
|
2021-02-06 23:52:26 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* ${table.classComment} Service 实现类
|
|
|
|
*
|
|
|
|
* @author ${table.author}
|
|
|
|
*/
|
2021-02-07 00:34:54 +08:00
|
|
|
@Service
|
2021-02-06 23:52:26 +08:00
|
|
|
@Validated
|
2021-02-07 00:34:54 +08:00
|
|
|
public class ${table.className}ServiceImpl implements ${table.className}Service {
|
2021-02-06 23:52:26 +08:00
|
|
|
|
|
|
|
@Resource
|
|
|
|
private ${table.className}Mapper ${classNameVar}Mapper;
|
|
|
|
|
|
|
|
@Override
|
2021-02-07 00:34:54 +08:00
|
|
|
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);
|
2021-02-06 23:52:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|