From 5fd37e3ad54e3d1ac5a15d60da4716a3c03b8c7e Mon Sep 17 00:00:00 2001 From: lihongjie0209 Date: Tue, 12 Mar 2024 14:49:20 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=B7=A5=E8=B5=84=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/EmpSalaryItemController.java | 54 ++++++++++++++ .../dto/CreateEmpSalaryItemDto.java | 58 +++++++++++++++ .../empSalaryItem/dto/EmpSalaryItemDto.java | 58 +++++++++++++++ .../dto/UpdateEmpSalaryItemDto.java | 60 ++++++++++++++++ .../entity/EmpSalaryItemEntity.java | 64 +++++++++++++++++ .../mapper/EmpSalaryItemMapper.java | 23 ++++++ .../repository/EmpSalaryItemRepository.java | 9 +++ .../service/EmpSalaryItemService.java | 71 +++++++++++++++++++ .../dict/enum/empSalaryItemDict.groovy | 17 +++++ 9 files changed, 414 insertions(+) create mode 100644 src/main/java/cn/lihongjie/coal/empSalaryItem/controller/EmpSalaryItemController.java create mode 100644 src/main/java/cn/lihongjie/coal/empSalaryItem/dto/CreateEmpSalaryItemDto.java create mode 100644 src/main/java/cn/lihongjie/coal/empSalaryItem/dto/EmpSalaryItemDto.java create mode 100644 src/main/java/cn/lihongjie/coal/empSalaryItem/dto/UpdateEmpSalaryItemDto.java create mode 100644 src/main/java/cn/lihongjie/coal/empSalaryItem/entity/EmpSalaryItemEntity.java create mode 100644 src/main/java/cn/lihongjie/coal/empSalaryItem/mapper/EmpSalaryItemMapper.java create mode 100644 src/main/java/cn/lihongjie/coal/empSalaryItem/repository/EmpSalaryItemRepository.java create mode 100644 src/main/java/cn/lihongjie/coal/empSalaryItem/service/EmpSalaryItemService.java create mode 100644 src/main/resources/scripts/dict/enum/empSalaryItemDict.groovy diff --git a/src/main/java/cn/lihongjie/coal/empSalaryItem/controller/EmpSalaryItemController.java b/src/main/java/cn/lihongjie/coal/empSalaryItem/controller/EmpSalaryItemController.java new file mode 100644 index 00000000..34451484 --- /dev/null +++ b/src/main/java/cn/lihongjie/coal/empSalaryItem/controller/EmpSalaryItemController.java @@ -0,0 +1,54 @@ +package cn.lihongjie.coal.empSalaryItem.controller; + +import cn.lihongjie.coal.annotation.OrgScope; +import cn.lihongjie.coal.annotation.SysLog; +import cn.lihongjie.coal.base.dto.CommonQuery; +import cn.lihongjie.coal.base.dto.IdRequest; +import cn.lihongjie.coal.empSalaryItem.dto.CreateEmpSalaryItemDto; +import cn.lihongjie.coal.empSalaryItem.dto.EmpSalaryItemDto; +import cn.lihongjie.coal.empSalaryItem.dto.UpdateEmpSalaryItemDto; +import cn.lihongjie.coal.empSalaryItem.service.EmpSalaryItemService; + +import lombok.extern.slf4j.Slf4j; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Page; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("/empSalaryItem") +@SysLog(module = "工资项目配置") +@Slf4j +@OrgScope +public class EmpSalaryItemController { + @Autowired private EmpSalaryItemService service; + + @PostMapping("/create") + public EmpSalaryItemDto create(@RequestBody CreateEmpSalaryItemDto request) { + return this.service.create(request); + } + + @PostMapping("/update") + public EmpSalaryItemDto update(@RequestBody UpdateEmpSalaryItemDto request) { + return this.service.update(request); + } + + @PostMapping("/delete") + public Object delete(@RequestBody IdRequest request) { + this.service.delete(request); + return true; + } + + @PostMapping("/getById") + public EmpSalaryItemDto getById(@RequestBody IdRequest request) { + return this.service.getById(request.getId()); + } + + @PostMapping("/list") + public Page list(@RequestBody CommonQuery request) { + return this.service.list(request); + } +} diff --git a/src/main/java/cn/lihongjie/coal/empSalaryItem/dto/CreateEmpSalaryItemDto.java b/src/main/java/cn/lihongjie/coal/empSalaryItem/dto/CreateEmpSalaryItemDto.java new file mode 100644 index 00000000..4f199ede --- /dev/null +++ b/src/main/java/cn/lihongjie/coal/empSalaryItem/dto/CreateEmpSalaryItemDto.java @@ -0,0 +1,58 @@ +package cn.lihongjie.coal.empSalaryItem.dto; + +import cn.lihongjie.coal.base.dto.OrgCommonDto; + +import lombok.Data; + +import org.hibernate.annotations.Comment; +import org.hibernate.annotations.Formula; + +import java.util.List; + +@Data +public class CreateEmpSalaryItemDto extends OrgCommonDto { + + @Comment("上级名称") + private String parentName; + + @Formula("(CONCAT(parentName,'-' ,name))") + private String fullName; + + @Comment("工资项目类型") + private String itemType; + + @Formula( + "(select i.name\n" + + "from t_dictionary d,\n" + + " t_dictionary_item i\n" + + "where d.id = i.dictionary_id\n" + + " and d.code = 'salaryItem.type'\n" + + " and i.code = item_type)") + // @Comment("工资项目类型-名称") + private String itemTypeName; + + @Comment("工资项目录入方式") + private String inputType; + + @Formula( + "(select i.name\n" + + "from t_dictionary d,\n" + + " t_dictionary_item i\n" + + "where d.id = i.dictionary_id\n" + + " and d.code = 'salaryItem.inputType'\n" + + " and i.code = input_type)") + // @Comment("工资项目录入方式-名称") + private String inputTypeName; + + @Comment("公式-显示") + private String formulaShow; + + @Comment("公式") + private String formula; + + @Comment("依赖项目") + private List dependOn; + + @Comment("优先级") + private Integer priority; +} diff --git a/src/main/java/cn/lihongjie/coal/empSalaryItem/dto/EmpSalaryItemDto.java b/src/main/java/cn/lihongjie/coal/empSalaryItem/dto/EmpSalaryItemDto.java new file mode 100644 index 00000000..755b02aa --- /dev/null +++ b/src/main/java/cn/lihongjie/coal/empSalaryItem/dto/EmpSalaryItemDto.java @@ -0,0 +1,58 @@ +package cn.lihongjie.coal.empSalaryItem.dto; + +import cn.lihongjie.coal.base.dto.OrgCommonDto; + +import lombok.Data; + +import org.hibernate.annotations.Comment; +import org.hibernate.annotations.Formula; + +import java.util.List; + +@Data +public class EmpSalaryItemDto extends OrgCommonDto { + + @Comment("上级名称") + private String parentName; + + @Formula("(CONCAT(parentName,'-' ,name))") + private String fullName; + + @Comment("工资项目类型") + private String itemType; + + @Formula( + "(select i.name\n" + + "from t_dictionary d,\n" + + " t_dictionary_item i\n" + + "where d.id = i.dictionary_id\n" + + " and d.code = 'salaryItem.type'\n" + + " and i.code = item_type)") + // @Comment("工资项目类型-名称") + private String itemTypeName; + + @Comment("工资项目录入方式") + private String inputType; + + @Formula( + "(select i.name\n" + + "from t_dictionary d,\n" + + " t_dictionary_item i\n" + + "where d.id = i.dictionary_id\n" + + " and d.code = 'salaryItem.inputType'\n" + + " and i.code = input_type)") + // @Comment("工资项目录入方式-名称") + private String inputTypeName; + + @Comment("公式-显示") + private String formulaShow; + + @Comment("公式") + private String formula; + + @Comment("依赖项目") + private List dependOn; + + @Comment("优先级") + private Integer priority; +} diff --git a/src/main/java/cn/lihongjie/coal/empSalaryItem/dto/UpdateEmpSalaryItemDto.java b/src/main/java/cn/lihongjie/coal/empSalaryItem/dto/UpdateEmpSalaryItemDto.java new file mode 100644 index 00000000..2783987c --- /dev/null +++ b/src/main/java/cn/lihongjie/coal/empSalaryItem/dto/UpdateEmpSalaryItemDto.java @@ -0,0 +1,60 @@ +package cn.lihongjie.coal.empSalaryItem.dto; + +import cn.lihongjie.coal.base.dto.OrgCommonDto; + +import lombok.Data; + +import org.hibernate.annotations.Comment; +import org.hibernate.annotations.Formula; + +import java.util.List; + +@Data +public class UpdateEmpSalaryItemDto extends OrgCommonDto { + + + @Comment("上级名称") + private String parentName; + + @Formula("(CONCAT(parentName,'-' ,name))") + private String fullName; + + @Comment("工资项目类型") + private String itemType; + + @Formula( + "(select i.name\n" + + "from t_dictionary d,\n" + + " t_dictionary_item i\n" + + "where d.id = i.dictionary_id\n" + + " and d.code = 'salaryItem.type'\n" + + " and i.code = item_type)") + // @Comment("工资项目类型-名称") + private String itemTypeName; + + @Comment("工资项目录入方式") + private String inputType; + + @Formula( + "(select i.name\n" + + "from t_dictionary d,\n" + + " t_dictionary_item i\n" + + "where d.id = i.dictionary_id\n" + + " and d.code = 'salaryItem.inputType'\n" + + " and i.code = input_type)") + // @Comment("工资项目录入方式-名称") + private String inputTypeName; + + @Comment("公式-显示") + private String formulaShow; + + @Comment("公式") + private String formula; + + @Comment("依赖项目") + private List dependOn; + + @Comment("优先级") + private Integer priority; + +} diff --git a/src/main/java/cn/lihongjie/coal/empSalaryItem/entity/EmpSalaryItemEntity.java b/src/main/java/cn/lihongjie/coal/empSalaryItem/entity/EmpSalaryItemEntity.java new file mode 100644 index 00000000..1e158b07 --- /dev/null +++ b/src/main/java/cn/lihongjie/coal/empSalaryItem/entity/EmpSalaryItemEntity.java @@ -0,0 +1,64 @@ +package cn.lihongjie.coal.empSalaryItem.entity; + +import cn.lihongjie.coal.base.entity.OrgCommonEntity; + +import jakarta.persistence.Entity; + +import lombok.Data; + +import org.hibernate.annotations.Comment; +import org.hibernate.annotations.Formula; + +import java.util.List; + +@Data +@Entity +public class EmpSalaryItemEntity extends OrgCommonEntity { + + + @Comment("上级名称") + private String parentName; + + @Formula("(CONCAT(parentName,'-' ,name))") + private String fullName; + + @Comment("工资项目类型") + private String itemType; + + @Formula( + "(select i.name\n" + + "from t_dictionary d,\n" + + " t_dictionary_item i\n" + + "where d.id = i.dictionary_id\n" + + " and d.code = 'salaryItem.type'\n" + + " and i.code = item_type)") + // @Comment("工资项目类型-名称") + private String itemTypeName; + + @Comment("工资项目录入方式") + private String inputType; + + @Formula( + "(select i.name\n" + + "from t_dictionary d,\n" + + " t_dictionary_item i\n" + + "where d.id = i.dictionary_id\n" + + " and d.code = 'salaryItem.inputType'\n" + + " and i.code = input_type)") + // @Comment("工资项目录入方式-名称") + private String inputTypeName; + + @Comment("公式-显示") + private String formulaShow; + + @Comment("公式") + private String formula; + + @Comment("依赖项目") + private List dependOn; + + @Comment("优先级") + private Integer priority; + + +} diff --git a/src/main/java/cn/lihongjie/coal/empSalaryItem/mapper/EmpSalaryItemMapper.java b/src/main/java/cn/lihongjie/coal/empSalaryItem/mapper/EmpSalaryItemMapper.java new file mode 100644 index 00000000..f394ec28 --- /dev/null +++ b/src/main/java/cn/lihongjie/coal/empSalaryItem/mapper/EmpSalaryItemMapper.java @@ -0,0 +1,23 @@ +package cn.lihongjie.coal.empSalaryItem.mapper; + +import cn.lihongjie.coal.base.mapper.BaseMapper; +import cn.lihongjie.coal.base.mapper.CommonEntityMapper; +import cn.lihongjie.coal.base.mapper.CommonMapper; +import cn.lihongjie.coal.empSalaryItem.dto.CreateEmpSalaryItemDto; +import cn.lihongjie.coal.empSalaryItem.dto.EmpSalaryItemDto; +import cn.lihongjie.coal.empSalaryItem.dto.UpdateEmpSalaryItemDto; +import cn.lihongjie.coal.empSalaryItem.entity.EmpSalaryItemEntity; + +import org.mapstruct.Mapper; +import org.mapstruct.control.DeepClone; + +@Mapper( + componentModel = org.mapstruct.MappingConstants.ComponentModel.SPRING, + uses = {CommonMapper.class, CommonEntityMapper.class}, + mappingControl = DeepClone.class) +public interface EmpSalaryItemMapper + extends BaseMapper< + EmpSalaryItemEntity, + EmpSalaryItemDto, + CreateEmpSalaryItemDto, + UpdateEmpSalaryItemDto> {} diff --git a/src/main/java/cn/lihongjie/coal/empSalaryItem/repository/EmpSalaryItemRepository.java b/src/main/java/cn/lihongjie/coal/empSalaryItem/repository/EmpSalaryItemRepository.java new file mode 100644 index 00000000..85bbe479 --- /dev/null +++ b/src/main/java/cn/lihongjie/coal/empSalaryItem/repository/EmpSalaryItemRepository.java @@ -0,0 +1,9 @@ +package cn.lihongjie.coal.empSalaryItem.repository; + +import cn.lihongjie.coal.base.dao.BaseRepository; +import cn.lihongjie.coal.empSalaryItem.entity.EmpSalaryItemEntity; + +import org.springframework.stereotype.Repository; + +@Repository +public interface EmpSalaryItemRepository extends BaseRepository {} diff --git a/src/main/java/cn/lihongjie/coal/empSalaryItem/service/EmpSalaryItemService.java b/src/main/java/cn/lihongjie/coal/empSalaryItem/service/EmpSalaryItemService.java new file mode 100644 index 00000000..0f880adb --- /dev/null +++ b/src/main/java/cn/lihongjie/coal/empSalaryItem/service/EmpSalaryItemService.java @@ -0,0 +1,71 @@ +package cn.lihongjie.coal.empSalaryItem.service; + +import cn.lihongjie.coal.base.dto.CommonQuery; +import cn.lihongjie.coal.base.dto.IdRequest; +import cn.lihongjie.coal.base.service.BaseService; +import cn.lihongjie.coal.empSalaryItem.dto.CreateEmpSalaryItemDto; +import cn.lihongjie.coal.empSalaryItem.dto.EmpSalaryItemDto; +import cn.lihongjie.coal.empSalaryItem.dto.UpdateEmpSalaryItemDto; +import cn.lihongjie.coal.empSalaryItem.entity.EmpSalaryItemEntity; +import cn.lihongjie.coal.empSalaryItem.mapper.EmpSalaryItemMapper; +import cn.lihongjie.coal.empSalaryItem.repository.EmpSalaryItemRepository; + +import lombok.extern.slf4j.Slf4j; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.convert.ConversionService; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Sort; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service +@Slf4j +@Transactional +public class EmpSalaryItemService + extends BaseService { + @Autowired private EmpSalaryItemRepository repository; + + @Autowired private EmpSalaryItemMapper mapper; + + @Autowired private ConversionService conversionService; + + public EmpSalaryItemDto create(CreateEmpSalaryItemDto request) { + EmpSalaryItemEntity entity = mapper.toEntity(request); + + this.repository.save(entity); + return getById(entity.getId()); + } + + public EmpSalaryItemDto update(UpdateEmpSalaryItemDto request) { + EmpSalaryItemEntity entity = this.repository.get(request.getId()); + this.mapper.updateEntity(entity, request); + + this.repository.save(entity); + + return getById(entity.getId()); + } + + public void delete(IdRequest request) { + this.repository.deleteAllById(request.getIds()); + } + + public EmpSalaryItemDto getById(String id) { + EmpSalaryItemEntity entity = repository.get(id); + + return mapper.toDto(entity); + } + + public Page list(CommonQuery query) { + Page page = + repository.findAll( + query.specification(conversionService), + PageRequest.of( + query.getPageNo(), + query.getPageSize(), + Sort.by(query.getOrders()))); + + return page.map(this.mapper::toDto); + } +} diff --git a/src/main/resources/scripts/dict/enum/empSalaryItemDict.groovy b/src/main/resources/scripts/dict/enum/empSalaryItemDict.groovy new file mode 100644 index 00000000..41c65e5c --- /dev/null +++ b/src/main/resources/scripts/dict/enum/empSalaryItemDict.groovy @@ -0,0 +1,17 @@ + +package scripts.dict + +import cn.lihongjie.coal.base.dto.CommonQuery +import cn.lihongjie.coal.empSalaryItem.controller.EmpSalaryItemController +import org.springframework.context.ApplicationContext + +ApplicationContext ioc = ioc + +def controller = ioc.getBean(EmpSalaryItemController.class) + + + + +return controller.list(new CommonQuery()) + +