serviceImpl.ftl 3.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. package ${code.packageName}.service.impl;
  2. import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
  3. import com.inkasso.adapter.service.KafubaoServiceImpl;
  4. import com.inkasso.adapter.util.BeanUtilsProxy;
  5. import ${code.packageName}.dao.${code.className}DAO;
  6. import ${code.packageName}.entity.${code.className}DO;
  7. import ${code.packageName}.model.dto.${code.className}DTO;
  8. import ${code.packageName}.model.request.Add${code.className}Request;
  9. import ${code.packageName}.model.request.Edit${code.className}Request;
  10. import ${code.packageName}.service.${code.className}Service;
  11. import com.inkasso.adapter.exception.ServiceException;
  12. import com.inkasso.adapter.exception.enums.ExceptionEnum;
  13. import org.springframework.stereotype.Service;
  14. /**
  15. * @author ${code.author}
  16. * @date ${.now?string('yyyy-MM-dd')}
  17. */
  18. @Service
  19. <#if code.parentName = "RelationBaseBean">
  20. public class ${code.className}ServiceImpl extends ServiceImpl<${code.className}DAO, ${code.className}DO> implements ${code.className}Service {
  21. @Override
  22. public void add${code.className}(Add${code.className}Request add${code.className}Request) {
  23. ${code.className}DO ${code.className?uncap_first} = BeanUtilsProxy.copyPropertiesIgnoreNull(add${code.className}Request, ${code.className}DO.class);
  24. this.baseMapper.insert(${code.className?uncap_first});
  25. }
  26. @Override
  27. public void edit${code.className}(Edit${code.className}Request edit${code.className}Request) {
  28. ${code.className}DO ${code.className?uncap_first} = super.getById(edit${code.className}Request.getId());
  29. if (${code.className?uncap_first} == null) {
  30. throw new ServiceException(400, ExceptionEnum.SYSTEM_DATE_ERROR);
  31. }
  32. BeanUtilsProxy.copyPropertiesNotIgnoreNull(edit${code.className}Request,${code.className?uncap_first});
  33. this.updateById(${code.className?uncap_first});
  34. }
  35. @Override
  36. public ${code.className}DTO get${code.className}DtoById(Long id) {
  37. ${code.className}DO ${code.className?uncap_first} = super.getById(id);
  38. ${code.className}DTO ${code.className?uncap_first}Dto = BeanUtilsProxy.copyProperties(${code.className?uncap_first},${code.className}DTO.class);
  39. return ${code.className?uncap_first}Dto;
  40. }
  41. @Override
  42. public void delete${code.className}(Long id) {
  43. this.removeById(id);
  44. }
  45. }
  46. </#if>
  47. <#if code.parentName = "BaseBean">
  48. public class ${code.className}ServiceImpl extends KafubaoServiceImpl<${code.className}DAO, ${code.className}DO,${code.className}DTO > implements ${code.className}Service {
  49. @Override
  50. public void add${code.className}(Add${code.className}Request add${code.className}Request) {
  51. ${code.className}DO ${code.className?uncap_first} = BeanUtilsProxy.copyPropertiesIgnoreNull(add${code.className}Request, ${code.className}DO.class);
  52. this.baseMapper.insert(${code.className?uncap_first});
  53. }
  54. @Override
  55. public void edit${code.className}(Edit${code.className}Request edit${code.className}Request) {
  56. ${code.className}DO ${code.className?uncap_first} = super.getById(edit${code.className}Request.getId());
  57. if (${code.className?uncap_first} == null) {
  58. throw new ServiceException(400, ExceptionEnum.SYSTEM_DATE_ERROR);
  59. }
  60. BeanUtilsProxy.copyPropertiesNotIgnoreNull(edit${code.className}Request,${code.className?uncap_first});
  61. this.updateById(${code.className?uncap_first});
  62. }
  63. @Override
  64. public ${code.className}DTO get${code.className}DtoById(Long id) {
  65. ${code.className}DO ${code.className?uncap_first} = super.getById(id);
  66. ${code.className}DTO ${code.className?uncap_first}Dto = BeanUtilsProxy.copyProperties(${code.className?uncap_first},${code.className}DTO.class);
  67. return ${code.className?uncap_first}Dto;
  68. }
  69. @Override
  70. public void delete${code.className}(Long id) {
  71. this.removeById(id);
  72. }
  73. }
  74. </#if>