mirror of
https://codeup.aliyun.com/64f7d6b8ce01efaafef1e678/coal/coal.git
synced 2026-01-25 07:46:40 +08:00
工资项目公式配置表
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
package cn.lihongjie.coal.empSalaryItemConfig.controller;
|
||||
|
||||
import cn.lihongjie.coal.annotation.SysLog;
|
||||
import cn.lihongjie.coal.base.dto.CommonQuery;
|
||||
import cn.lihongjie.coal.base.dto.IdRequest;
|
||||
import cn.lihongjie.coal.empSalaryItemConfig.dto.CreateEmpSalaryItemConfigDto;
|
||||
import cn.lihongjie.coal.empSalaryItemConfig.dto.EmpSalaryItemConfigDto;
|
||||
import cn.lihongjie.coal.empSalaryItemConfig.dto.UpdateEmpSalaryItemConfigDto;
|
||||
import cn.lihongjie.coal.empSalaryItemConfig.service.EmpSalaryItemConfigService;
|
||||
|
||||
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("/empSalaryItemConfig")
|
||||
@SysLog(module = "工资公式配置")
|
||||
@Slf4j
|
||||
public class EmpSalaryItemConfigController {
|
||||
@Autowired private EmpSalaryItemConfigService service;
|
||||
|
||||
@PostMapping("/create")
|
||||
public EmpSalaryItemConfigDto create(@RequestBody CreateEmpSalaryItemConfigDto request) {
|
||||
return this.service.create(request);
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
public EmpSalaryItemConfigDto update(@RequestBody UpdateEmpSalaryItemConfigDto request) {
|
||||
return this.service.update(request);
|
||||
}
|
||||
|
||||
@PostMapping("/delete")
|
||||
public Object delete(@RequestBody IdRequest request) {
|
||||
this.service.delete(request);
|
||||
return true;
|
||||
}
|
||||
|
||||
@PostMapping("/getById")
|
||||
public EmpSalaryItemConfigDto getById(@RequestBody IdRequest request) {
|
||||
return this.service.getById(request.getId());
|
||||
}
|
||||
|
||||
@PostMapping("/list")
|
||||
public Page<EmpSalaryItemConfigDto> list(@RequestBody CommonQuery request) {
|
||||
return this.service.list(request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package cn.lihongjie.coal.empSalaryItemConfig.dto;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.CommonDto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import org.hibernate.annotations.Comment;
|
||||
import org.hibernate.annotations.Formula;
|
||||
|
||||
@Data
|
||||
public class CreateEmpSalaryItemConfigDto extends CommonDto {
|
||||
@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 = 'emp.salary.item.config.type'\n"
|
||||
+ " and i.code = item_type)")
|
||||
private String itemTypeName;
|
||||
|
||||
|
||||
|
||||
@Comment("表达式")
|
||||
private String expression;
|
||||
|
||||
|
||||
|
||||
@Comment("表达式-展示")
|
||||
private String expressionShow;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package cn.lihongjie.coal.empSalaryItemConfig.dto;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.CommonDto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import org.hibernate.annotations.Comment;
|
||||
import org.hibernate.annotations.Formula;
|
||||
|
||||
@Data
|
||||
public class EmpSalaryItemConfigDto extends CommonDto {
|
||||
|
||||
@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 = 'emp.salary.item.config.type'\n"
|
||||
+ " and i.code = item_type)")
|
||||
private String itemTypeName;
|
||||
|
||||
|
||||
|
||||
@Comment("表达式")
|
||||
private String expression;
|
||||
|
||||
|
||||
|
||||
@Comment("表达式-展示")
|
||||
private String expressionShow;
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package cn.lihongjie.coal.empSalaryItemConfig.dto;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.CommonDto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import org.hibernate.annotations.Comment;
|
||||
import org.hibernate.annotations.Formula;
|
||||
|
||||
@Data
|
||||
public class UpdateEmpSalaryItemConfigDto extends CommonDto {
|
||||
|
||||
@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 = 'emp.salary.item.config.type'\n"
|
||||
+ " and i.code = item_type)")
|
||||
private String itemTypeName;
|
||||
|
||||
|
||||
|
||||
@Comment("表达式")
|
||||
private String expression;
|
||||
|
||||
|
||||
|
||||
@Comment("表达式-展示")
|
||||
private String expressionShow;
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package cn.lihongjie.coal.empSalaryItemConfig.entity;
|
||||
|
||||
import cn.lihongjie.coal.base.entity.CommonEntity;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import org.hibernate.annotations.Comment;
|
||||
import org.hibernate.annotations.Formula;
|
||||
|
||||
@Data
|
||||
@Entity
|
||||
public class EmpSalaryItemConfigEntity extends CommonEntity {
|
||||
|
||||
@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 = 'emp.salary.item.config.type'\n"
|
||||
+ " and i.code = item_type)")
|
||||
private String itemTypeName;
|
||||
|
||||
|
||||
|
||||
@Comment("表达式")
|
||||
private String expression;
|
||||
|
||||
|
||||
|
||||
@Comment("表达式-展示")
|
||||
private String expressionShow;
|
||||
|
||||
|
||||
|
||||
@Comment("字典编码")
|
||||
private String dictCode;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package cn.lihongjie.coal.empSalaryItemConfig.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.empSalaryItemConfig.dto.CreateEmpSalaryItemConfigDto;
|
||||
import cn.lihongjie.coal.empSalaryItemConfig.dto.EmpSalaryItemConfigDto;
|
||||
import cn.lihongjie.coal.empSalaryItemConfig.dto.UpdateEmpSalaryItemConfigDto;
|
||||
import cn.lihongjie.coal.empSalaryItemConfig.entity.EmpSalaryItemConfigEntity;
|
||||
|
||||
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 EmpSalaryItemConfigMapper
|
||||
extends BaseMapper<
|
||||
EmpSalaryItemConfigEntity,
|
||||
EmpSalaryItemConfigDto,
|
||||
CreateEmpSalaryItemConfigDto,
|
||||
UpdateEmpSalaryItemConfigDto> {}
|
||||
@@ -0,0 +1,9 @@
|
||||
package cn.lihongjie.coal.empSalaryItemConfig.repository;
|
||||
|
||||
import cn.lihongjie.coal.base.dao.BaseRepository;
|
||||
import cn.lihongjie.coal.empSalaryItemConfig.entity.EmpSalaryItemConfigEntity;
|
||||
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface EmpSalaryItemConfigRepository extends BaseRepository<EmpSalaryItemConfigEntity> {}
|
||||
@@ -0,0 +1,71 @@
|
||||
package cn.lihongjie.coal.empSalaryItemConfig.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.empSalaryItemConfig.dto.CreateEmpSalaryItemConfigDto;
|
||||
import cn.lihongjie.coal.empSalaryItemConfig.dto.EmpSalaryItemConfigDto;
|
||||
import cn.lihongjie.coal.empSalaryItemConfig.dto.UpdateEmpSalaryItemConfigDto;
|
||||
import cn.lihongjie.coal.empSalaryItemConfig.entity.EmpSalaryItemConfigEntity;
|
||||
import cn.lihongjie.coal.empSalaryItemConfig.mapper.EmpSalaryItemConfigMapper;
|
||||
import cn.lihongjie.coal.empSalaryItemConfig.repository.EmpSalaryItemConfigRepository;
|
||||
|
||||
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 EmpSalaryItemConfigService
|
||||
extends BaseService<EmpSalaryItemConfigEntity, EmpSalaryItemConfigRepository> {
|
||||
@Autowired private EmpSalaryItemConfigRepository repository;
|
||||
|
||||
@Autowired private EmpSalaryItemConfigMapper mapper;
|
||||
|
||||
@Autowired private ConversionService conversionService;
|
||||
|
||||
public EmpSalaryItemConfigDto create(CreateEmpSalaryItemConfigDto request) {
|
||||
EmpSalaryItemConfigEntity entity = mapper.toEntity(request);
|
||||
|
||||
this.repository.save(entity);
|
||||
return getById(entity.getId());
|
||||
}
|
||||
|
||||
public EmpSalaryItemConfigDto update(UpdateEmpSalaryItemConfigDto request) {
|
||||
EmpSalaryItemConfigEntity 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 EmpSalaryItemConfigDto getById(String id) {
|
||||
EmpSalaryItemConfigEntity entity = repository.get(id);
|
||||
|
||||
return mapper.toDto(entity);
|
||||
}
|
||||
|
||||
public Page<EmpSalaryItemConfigDto> list(CommonQuery query) {
|
||||
Page<EmpSalaryItemConfigEntity> 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.empSalaryItemConfig.controller.EmpSalaryItemConfigController
|
||||
import org.springframework.context.ApplicationContext
|
||||
|
||||
ApplicationContext ioc = ioc
|
||||
|
||||
def controller = ioc.getBean(EmpSalaryItemConfigController.class)
|
||||
|
||||
|
||||
|
||||
|
||||
return controller.list(new CommonQuery())
|
||||
|
||||
|
||||
Reference in New Issue
Block a user