mirror of
https://codeup.aliyun.com/64f7d6b8ce01efaafef1e678/coal/coal.git
synced 2026-01-25 15:55:18 +08:00
添加工资项目接口
This commit is contained in:
@@ -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<EmpSalaryItemDto> list(@RequestBody CommonQuery request) {
|
||||
return this.service.list(request);
|
||||
}
|
||||
}
|
||||
@@ -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<String> dependOn;
|
||||
|
||||
@Comment("优先级")
|
||||
private Integer priority;
|
||||
}
|
||||
@@ -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<String> dependOn;
|
||||
|
||||
@Comment("优先级")
|
||||
private Integer priority;
|
||||
}
|
||||
@@ -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<String> dependOn;
|
||||
|
||||
@Comment("优先级")
|
||||
private Integer priority;
|
||||
|
||||
}
|
||||
@@ -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<String> dependOn;
|
||||
|
||||
@Comment("优先级")
|
||||
private Integer priority;
|
||||
|
||||
|
||||
}
|
||||
@@ -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> {}
|
||||
@@ -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<EmpSalaryItemEntity> {}
|
||||
@@ -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<EmpSalaryItemEntity, EmpSalaryItemRepository> {
|
||||
@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<EmpSalaryItemDto> list(CommonQuery query) {
|
||||
Page<EmpSalaryItemEntity> page =
|
||||
repository.findAll(
|
||||
query.specification(conversionService),
|
||||
PageRequest.of(
|
||||
query.getPageNo(),
|
||||
query.getPageSize(),
|
||||
Sort.by(query.getOrders())));
|
||||
|
||||
return page.map(this.mapper::toDto);
|
||||
}
|
||||
}
|
||||
@@ -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())
|
||||
|
||||
|
||||
Reference in New Issue
Block a user