添加报表配置类

This commit is contained in:
2024-08-18 14:08:42 +08:00
parent 64791a6c23
commit cf4a0d9db1
9 changed files with 237 additions and 0 deletions

View File

@@ -0,0 +1,54 @@
package cn.lihongjie.coal.empSalaryReport.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.empSalaryReport.dto.CreateEmpSalaryReportDto;
import cn.lihongjie.coal.empSalaryReport.dto.EmpSalaryReportDto;
import cn.lihongjie.coal.empSalaryReport.dto.UpdateEmpSalaryReportDto;
import cn.lihongjie.coal.empSalaryReport.service.EmpSalaryReportService;
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("/empSalaryReport")
@SysLog(module = "")
@Slf4j
@OrgScope
public class EmpSalaryReportController {
@Autowired private EmpSalaryReportService service;
@PostMapping("/create")
public EmpSalaryReportDto create(@RequestBody CreateEmpSalaryReportDto request) {
return this.service.create(request);
}
@PostMapping("/update")
public EmpSalaryReportDto update(@RequestBody UpdateEmpSalaryReportDto request) {
return this.service.update(request);
}
@PostMapping("/delete")
public Object delete(@RequestBody IdRequest request) {
this.service.delete(request);
return true;
}
@PostMapping("/getById")
public EmpSalaryReportDto getById(@RequestBody IdRequest request) {
return this.service.getById(request.getId());
}
@PostMapping("/list")
public Page<EmpSalaryReportDto> list(@RequestBody CommonQuery request) {
return this.service.list(request);
}
}

View File

@@ -0,0 +1,11 @@
package cn.lihongjie.coal.empSalaryReport.dto;
import cn.lihongjie.coal.base.dto.OrgCommonDto;
import lombok.Data;
@Data
public class CreateEmpSalaryReportDto extends OrgCommonDto {
private String jsonConfig;
}

View File

@@ -0,0 +1,11 @@
package cn.lihongjie.coal.empSalaryReport.dto;
import cn.lihongjie.coal.base.dto.OrgCommonDto;
import lombok.Data;
@Data
public class EmpSalaryReportDto extends OrgCommonDto {
private String jsonConfig;
}

View File

@@ -0,0 +1,11 @@
package cn.lihongjie.coal.empSalaryReport.dto;
import cn.lihongjie.coal.base.dto.OrgCommonDto;
import lombok.Data;
@Data
public class UpdateEmpSalaryReportDto extends OrgCommonDto {
private String jsonConfig;
}

View File

@@ -0,0 +1,14 @@
package cn.lihongjie.coal.empSalaryReport.entity;
import cn.lihongjie.coal.base.entity.OrgCommonEntity;
import jakarta.persistence.Entity;
import lombok.Data;
@Data
@Entity
public class EmpSalaryReportEntity extends OrgCommonEntity {
private String jsonConfig;
}

View File

@@ -0,0 +1,23 @@
package cn.lihongjie.coal.empSalaryReport.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.empSalaryReport.dto.CreateEmpSalaryReportDto;
import cn.lihongjie.coal.empSalaryReport.dto.EmpSalaryReportDto;
import cn.lihongjie.coal.empSalaryReport.dto.UpdateEmpSalaryReportDto;
import cn.lihongjie.coal.empSalaryReport.entity.EmpSalaryReportEntity;
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 EmpSalaryReportMapper
extends BaseMapper<
EmpSalaryReportEntity,
EmpSalaryReportDto,
CreateEmpSalaryReportDto,
UpdateEmpSalaryReportDto> {}

View File

@@ -0,0 +1,15 @@
package cn.lihongjie.coal.empSalaryReport.repository;
import cn.lihongjie.coal.base.dao.BaseRepository;
import cn.lihongjie.coal.empSalaryReport.entity.EmpSalaryReportEntity;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface EmpSalaryReportRepository extends BaseRepository<EmpSalaryReportEntity> {
@Query("select false")
boolean isLinked(List<String> ids);
}

View File

@@ -0,0 +1,81 @@
package cn.lihongjie.coal.empSalaryReport.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.dbFunctions.DbFunctionService;
import cn.lihongjie.coal.empSalaryReport.dto.CreateEmpSalaryReportDto;
import cn.lihongjie.coal.empSalaryReport.dto.EmpSalaryReportDto;
import cn.lihongjie.coal.empSalaryReport.dto.UpdateEmpSalaryReportDto;
import cn.lihongjie.coal.empSalaryReport.entity.EmpSalaryReportEntity;
import cn.lihongjie.coal.empSalaryReport.mapper.EmpSalaryReportMapper;
import cn.lihongjie.coal.empSalaryReport.repository.EmpSalaryReportRepository;
import cn.lihongjie.coal.exception.BizException;
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 EmpSalaryReportService
extends BaseService<EmpSalaryReportEntity, EmpSalaryReportRepository> {
@Autowired private EmpSalaryReportRepository repository;
@Autowired private EmpSalaryReportMapper mapper;
@Autowired private ConversionService conversionService;
@Autowired private DbFunctionService dbFunctionService;
public EmpSalaryReportDto create(CreateEmpSalaryReportDto request) {
EmpSalaryReportEntity entity = mapper.toEntity(request);
this.repository.save(entity);
return getById(entity.getId());
}
public EmpSalaryReportDto update(UpdateEmpSalaryReportDto request) {
EmpSalaryReportEntity entity = this.repository.get(request.getId());
this.mapper.updateEntity(entity, request);
this.repository.save(entity);
return getById(entity.getId());
}
public void delete(IdRequest request) {
boolean linked = this.repository.isLinked(request.getIds());
if (linked) {
throw new BizException("数据已被关联,无法删除");
}
this.repository.deleteAllById(request.getIds());
}
public EmpSalaryReportDto getById(String id) {
EmpSalaryReportEntity entity = repository.get(id);
return mapper.toDto(entity);
}
public Page<EmpSalaryReportDto> list(CommonQuery query) {
Page<EmpSalaryReportEntity> page =
repository.findAll(
query.specification(conversionService),
PageRequest.of(
query.getPageNo(),
query.getPageSize(),
Sort.by(query.getOrders())));
return page.map(this.mapper::toDto);
}
}

View File

@@ -0,0 +1,17 @@
package scripts.dict
import cn.lihongjie.coal.base.dto.CommonQuery
import cn.lihongjie.coal.empSalaryReport.controller.EmpSalaryReportController
import org.springframework.context.ApplicationContext
ApplicationContext ioc = ioc
def controller = ioc.getBean(EmpSalaryReportController.class)
return controller.list(new CommonQuery())