TemplateConfigService.java 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package com.gitee.gen.service;
  2. import com.gitee.gen.entity.TemplateConfig;
  3. import com.gitee.gen.mapper.TemplateConfigMapper;
  4. import org.springframework.beans.factory.annotation.Autowired;
  5. import org.springframework.stereotype.Service;
  6. import java.util.List;
  7. import java.util.Objects;
  8. /**
  9. * @author tanghc
  10. */
  11. @Service
  12. public class TemplateConfigService {
  13. @Autowired
  14. private TemplateConfigMapper templateConfigMapper;
  15. public TemplateConfig getById(int id) {
  16. return templateConfigMapper.getById(id);
  17. }
  18. public List<TemplateConfig> listAll() {
  19. return templateConfigMapper.listAll();
  20. }
  21. public void insert(TemplateConfig templateConfig) {
  22. // TemplateConfig existObj = templateConfigMapper.getByName(templateConfig.getName());
  23. // if (existObj != null) {
  24. // throw new RuntimeException("模板名称已存在");
  25. // }
  26. templateConfig.setIsDeleted(0);
  27. templateConfigMapper.insert(templateConfig);
  28. }
  29. public void update(TemplateConfig templateConfig) {
  30. TemplateConfig existObj = templateConfigMapper.getByName(templateConfig.getName());
  31. if (existObj != null && !Objects.equals(templateConfig.getId(), existObj.getId())) {
  32. throw new RuntimeException("模板名称已存在");
  33. }
  34. templateConfigMapper.updateIgnoreNull(templateConfig);
  35. }
  36. public void delete(TemplateConfig templateConfig) {
  37. templateConfigMapper.delete(templateConfig);
  38. }
  39. public List<TemplateConfig> listByGroupId(String groupId) {
  40. return templateConfigMapper.listByGroupId(groupId);
  41. }
  42. }