diff --git a/src/main/java/cn/lihongjie/coal/excelGenerator/controller/ExcelGeneratorController.java b/src/main/java/cn/lihongjie/coal/excelGenerator/controller/ExcelGeneratorController.java deleted file mode 100644 index 0e93a094..00000000 --- a/src/main/java/cn/lihongjie/coal/excelGenerator/controller/ExcelGeneratorController.java +++ /dev/null @@ -1,52 +0,0 @@ -package cn.lihongjie.coal.excelGenerator.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.excelGenerator.dto.CreateExcelGeneratorDto; -import cn.lihongjie.coal.excelGenerator.dto.ExcelGeneratorDto; -import cn.lihongjie.coal.excelGenerator.dto.UpdateExcelGeneratorDto; -import cn.lihongjie.coal.excelGenerator.service.ExcelGeneratorService; - -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("/excelGenerator") -@SysLog(module = "Excel生成器") -@Slf4j -public class ExcelGeneratorController { - @Autowired private ExcelGeneratorService service; - - @PostMapping("/create") - public ExcelGeneratorDto create(@RequestBody CreateExcelGeneratorDto request) { - return this.service.create(request); - } - - @PostMapping("/update") - public ExcelGeneratorDto update(@RequestBody UpdateExcelGeneratorDto request) { - return this.service.update(request); - } - - @PostMapping("/delete") - public Object delete(@RequestBody IdRequest request) { - this.service.delete(request); - return true; - } - - @PostMapping("/getById") - public ExcelGeneratorDto 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/excelGenerator/dto/CreateExcelGeneratorDto.java b/src/main/java/cn/lihongjie/coal/excelGenerator/dto/CreateExcelGeneratorDto.java deleted file mode 100644 index 3d102a8d..00000000 --- a/src/main/java/cn/lihongjie/coal/excelGenerator/dto/CreateExcelGeneratorDto.java +++ /dev/null @@ -1,8 +0,0 @@ -package cn.lihongjie.coal.excelGenerator.dto; - -import cn.lihongjie.coal.base.dto.CommonDto; - -import lombok.Data; - -@Data -public class CreateExcelGeneratorDto extends CommonDto {} diff --git a/src/main/java/cn/lihongjie/coal/excelGenerator/dto/ExcelGeneratorDto.java b/src/main/java/cn/lihongjie/coal/excelGenerator/dto/ExcelGeneratorDto.java deleted file mode 100644 index 9529c8f5..00000000 --- a/src/main/java/cn/lihongjie/coal/excelGenerator/dto/ExcelGeneratorDto.java +++ /dev/null @@ -1,8 +0,0 @@ -package cn.lihongjie.coal.excelGenerator.dto; - -import cn.lihongjie.coal.base.dto.CommonDto; - -import lombok.Data; - -@Data -public class ExcelGeneratorDto extends CommonDto {} diff --git a/src/main/java/cn/lihongjie/coal/excelGenerator/dto/GenerateExcelRequest.java b/src/main/java/cn/lihongjie/coal/excelGenerator/dto/GenerateExcelRequest.java deleted file mode 100644 index 6b4c11bd..00000000 --- a/src/main/java/cn/lihongjie/coal/excelGenerator/dto/GenerateExcelRequest.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.lihongjie.coal.excelGenerator.dto; - -import cn.lihongjie.coal.excelGeneratorSheetInfo.dto.CreateExcelGeneratorSheetInfoDto; - -import lombok.Data; - -import java.util.*; - -@Data -public class GenerateExcelRequest { - - private String templateCode; - - private List sheets; - -} diff --git a/src/main/java/cn/lihongjie/coal/excelGenerator/dto/UpdateExcelGeneratorDto.java b/src/main/java/cn/lihongjie/coal/excelGenerator/dto/UpdateExcelGeneratorDto.java deleted file mode 100644 index 8088fa05..00000000 --- a/src/main/java/cn/lihongjie/coal/excelGenerator/dto/UpdateExcelGeneratorDto.java +++ /dev/null @@ -1,8 +0,0 @@ -package cn.lihongjie.coal.excelGenerator.dto; - -import cn.lihongjie.coal.base.dto.CommonDto; - -import lombok.Data; - -@Data -public class UpdateExcelGeneratorDto extends CommonDto {} diff --git a/src/main/java/cn/lihongjie/coal/excelGenerator/entity/ExcelGeneratorEntity.java b/src/main/java/cn/lihongjie/coal/excelGenerator/entity/ExcelGeneratorEntity.java deleted file mode 100644 index f95e6f10..00000000 --- a/src/main/java/cn/lihongjie/coal/excelGenerator/entity/ExcelGeneratorEntity.java +++ /dev/null @@ -1,44 +0,0 @@ -package cn.lihongjie.coal.excelGenerator.entity; - -import cn.lihongjie.coal.base.entity.CommonEntity; -import cn.lihongjie.coal.excelGeneratorSheetInfo.entity.ExcelGeneratorSheetInfoEntity; -import cn.lihongjie.coal.excelTemplate.entity.ExcelTemplateEntity; - -import jakarta.persistence.CascadeType; -import jakarta.persistence.Entity; -import jakarta.persistence.ManyToOne; -import jakarta.persistence.OneToMany; - -import lombok.Data; - -import org.hibernate.annotations.Comment; - -import java.util.List; - -@Data -@Entity -public class ExcelGeneratorEntity extends CommonEntity { - - - @ManyToOne - private ExcelTemplateEntity template; - - @OneToMany(mappedBy = "generator", cascade = {CascadeType.ALL}) - private List sheets; - - - @Comment("数据源耗时") - private Long dataSourceCostTime; - - @Comment("模板耗时") - private Long templateCostTime; - - @Comment("生成耗时") - private Long generateCostTime; - - - - - - -} diff --git a/src/main/java/cn/lihongjie/coal/excelGenerator/mapper/ExcelGeneratorMapper.java b/src/main/java/cn/lihongjie/coal/excelGenerator/mapper/ExcelGeneratorMapper.java deleted file mode 100644 index becbcbb6..00000000 --- a/src/main/java/cn/lihongjie/coal/excelGenerator/mapper/ExcelGeneratorMapper.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.lihongjie.coal.excelGenerator.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.excelGenerator.dto.CreateExcelGeneratorDto; -import cn.lihongjie.coal.excelGenerator.dto.ExcelGeneratorDto; -import cn.lihongjie.coal.excelGenerator.dto.UpdateExcelGeneratorDto; -import cn.lihongjie.coal.excelGenerator.entity.ExcelGeneratorEntity; - -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 ExcelGeneratorMapper - extends BaseMapper< - ExcelGeneratorEntity, - ExcelGeneratorDto, - CreateExcelGeneratorDto, - UpdateExcelGeneratorDto> {} diff --git a/src/main/java/cn/lihongjie/coal/excelGenerator/repository/ExcelGeneratorRepository.java b/src/main/java/cn/lihongjie/coal/excelGenerator/repository/ExcelGeneratorRepository.java deleted file mode 100644 index cc527a5a..00000000 --- a/src/main/java/cn/lihongjie/coal/excelGenerator/repository/ExcelGeneratorRepository.java +++ /dev/null @@ -1,9 +0,0 @@ -package cn.lihongjie.coal.excelGenerator.repository; - -import cn.lihongjie.coal.base.dao.BaseRepository; -import cn.lihongjie.coal.excelGenerator.entity.ExcelGeneratorEntity; - -import org.springframework.stereotype.Repository; - -@Repository -public interface ExcelGeneratorRepository extends BaseRepository {} diff --git a/src/main/java/cn/lihongjie/coal/excelGenerator/service/ExcelGeneratorService.java b/src/main/java/cn/lihongjie/coal/excelGenerator/service/ExcelGeneratorService.java deleted file mode 100644 index b0f91f4f..00000000 --- a/src/main/java/cn/lihongjie/coal/excelGenerator/service/ExcelGeneratorService.java +++ /dev/null @@ -1,139 +0,0 @@ -package cn.lihongjie.coal.excelGenerator.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.excelGenerator.dto.CreateExcelGeneratorDto; -import cn.lihongjie.coal.excelGenerator.dto.ExcelGeneratorDto; -import cn.lihongjie.coal.excelGenerator.dto.GenerateExcelRequest; -import cn.lihongjie.coal.excelGenerator.dto.UpdateExcelGeneratorDto; -import cn.lihongjie.coal.excelGenerator.entity.ExcelGeneratorEntity; -import cn.lihongjie.coal.excelGenerator.mapper.ExcelGeneratorMapper; -import cn.lihongjie.coal.excelGenerator.repository.ExcelGeneratorRepository; -import cn.lihongjie.coal.excelGeneratorSheetInfo.dto.CreateExcelGeneratorSheetInfoDto; -import cn.lihongjie.coal.excelTemplate.entity.ExcelTemplateEntity; -import cn.lihongjie.coal.excelTemplate.service.ExcelTemplateService; - -import com.fasterxml.jackson.databind.ObjectMapper; - -import lombok.Data; -import lombok.SneakyThrows; -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; -import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping; - -@Service -@Slf4j -@Transactional -public class ExcelGeneratorService - extends BaseService { - @Autowired ExcelTemplateService excelTemplateService; - @Autowired ObjectMapper objectMapper; - @Autowired RequestMappingHandlerMapping requestMappingHandlerMapping; - @Autowired private ExcelGeneratorRepository repository; - @Autowired private ExcelGeneratorMapper mapper; - @Autowired private ConversionService conversionService; - - public ExcelGeneratorDto create(CreateExcelGeneratorDto request) { - ExcelGeneratorEntity entity = mapper.toEntity(request); - - this.repository.save(entity); - return getById(entity.getId()); - } - - public ExcelGeneratorDto update(UpdateExcelGeneratorDto request) { - ExcelGeneratorEntity 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 ExcelGeneratorDto getById(String id) { - ExcelGeneratorEntity 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); - } - - @SneakyThrows - public void generate(GenerateExcelRequest request) { - - // 获取模板 - - ExcelTemplateEntity excelTemplate = - excelTemplateService.getByCode(request.getTemplateCode()); - - if (excelTemplate == null) { - throw new RuntimeException("模板不存在"); - } - - // 获取数据源 - - for (CreateExcelGeneratorSheetInfoDto sheet : request.getSheets()) { - - var sheetData = new SheetData(); - - sheetData.setSheetName(sheet.getName()); - switch (sheet.getDataSourceType()) { - case "0": - sheetData.setData( - sheet.getDataSourceParams() == null - ? null - : objectMapper.readTree(sheet.getDataSourceParams())); - break; - - case "1": - - // requestMappingHandlerMapping.match() - break; - - case "2": - break; - - case "3": - break; - - default: - throw new RuntimeException("不支持的数据源类型 " + sheet.getDataSourceType()); - } - - // 模板 + 数据源 生成xml - - // 生成excel - - // 保存excel - - } - } - - @Data - public static class SheetData { - - private String sheetName; - private Object data; - } -} diff --git a/src/main/java/cn/lihongjie/coal/excelGeneratorSheetInfo/controller/ExcelGeneratorSheetInfoController.java b/src/main/java/cn/lihongjie/coal/excelGeneratorSheetInfo/controller/ExcelGeneratorSheetInfoController.java deleted file mode 100644 index 89a4b899..00000000 --- a/src/main/java/cn/lihongjie/coal/excelGeneratorSheetInfo/controller/ExcelGeneratorSheetInfoController.java +++ /dev/null @@ -1,54 +0,0 @@ -package cn.lihongjie.coal.excelGeneratorSheetInfo.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.excelGeneratorSheetInfo.dto.CreateExcelGeneratorSheetInfoDto; -import cn.lihongjie.coal.excelGeneratorSheetInfo.dto.ExcelGeneratorSheetInfoDto; -import cn.lihongjie.coal.excelGeneratorSheetInfo.dto.UpdateExcelGeneratorSheetInfoDto; -import cn.lihongjie.coal.excelGeneratorSheetInfo.service.ExcelGeneratorSheetInfoService; - -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("/excelGeneratorSheetInfo") -@SysLog(module = "excel生成器sheet信息") -@Slf4j -public class ExcelGeneratorSheetInfoController { - @Autowired private ExcelGeneratorSheetInfoService service; - - @PostMapping("/create") - public ExcelGeneratorSheetInfoDto create( - @RequestBody CreateExcelGeneratorSheetInfoDto request) { - return this.service.create(request); - } - - @PostMapping("/update") - public ExcelGeneratorSheetInfoDto update( - @RequestBody UpdateExcelGeneratorSheetInfoDto request) { - return this.service.update(request); - } - - @PostMapping("/delete") - public Object delete(@RequestBody IdRequest request) { - this.service.delete(request); - return true; - } - - @PostMapping("/getById") - public ExcelGeneratorSheetInfoDto 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/excelGeneratorSheetInfo/dto/CreateExcelGeneratorSheetInfoDto.java b/src/main/java/cn/lihongjie/coal/excelGeneratorSheetInfo/dto/CreateExcelGeneratorSheetInfoDto.java deleted file mode 100644 index 982d3516..00000000 --- a/src/main/java/cn/lihongjie/coal/excelGeneratorSheetInfo/dto/CreateExcelGeneratorSheetInfoDto.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.lihongjie.coal.excelGeneratorSheetInfo.dto; - -import cn.lihongjie.coal.base.dto.CommonDto; - -import lombok.Data; - -import org.hibernate.annotations.Comment; -import org.hibernate.annotations.Formula; - -@Data -public class CreateExcelGeneratorSheetInfoDto extends CommonDto { - - @Comment("数据源类型") - private String dataSourceType; - - @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 = 'excel.generator.datasource.type'\n" - + " and i.code = data_source_type)") - private String dataSourceTypeName; - - - @Comment("数据源-url") - private String dataSourceUrl; - - - @Comment("数据源-请求方式") - private String dataSourceMethod; - - - @Comment("数据源-请求参数") - private String dataSourceParams; - - - @Comment("数据源-额外请求头") - private String dataSourceHeaders; -} diff --git a/src/main/java/cn/lihongjie/coal/excelGeneratorSheetInfo/dto/ExcelGeneratorSheetInfoDto.java b/src/main/java/cn/lihongjie/coal/excelGeneratorSheetInfo/dto/ExcelGeneratorSheetInfoDto.java deleted file mode 100644 index 3401e6d5..00000000 --- a/src/main/java/cn/lihongjie/coal/excelGeneratorSheetInfo/dto/ExcelGeneratorSheetInfoDto.java +++ /dev/null @@ -1,11 +0,0 @@ -package cn.lihongjie.coal.excelGeneratorSheetInfo.dto; - -import cn.lihongjie.coal.base.dto.CommonDto; - -import lombok.Data; - -@Data -public class ExcelGeneratorSheetInfoDto extends CommonDto { - - -} diff --git a/src/main/java/cn/lihongjie/coal/excelGeneratorSheetInfo/dto/UpdateExcelGeneratorSheetInfoDto.java b/src/main/java/cn/lihongjie/coal/excelGeneratorSheetInfo/dto/UpdateExcelGeneratorSheetInfoDto.java deleted file mode 100644 index 3c30d9f9..00000000 --- a/src/main/java/cn/lihongjie/coal/excelGeneratorSheetInfo/dto/UpdateExcelGeneratorSheetInfoDto.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.lihongjie.coal.excelGeneratorSheetInfo.dto; - -import cn.lihongjie.coal.base.dto.CommonDto; - -import lombok.Data; - -import org.hibernate.annotations.Comment; -import org.hibernate.annotations.Formula; - -@Data -public class UpdateExcelGeneratorSheetInfoDto extends CommonDto { - - @Comment("数据源类型") - private String dataSourceType; - - @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 = 'excel.generator.datasource.type'\n" - + " and i.code = data_source_type)") - private String dataSourceTypeName; - - - @Comment("数据源-url") - private String dataSourceUrl; - - - @Comment("数据源-请求方式") - private String dataSourceMethod; - - - @Comment("数据源-请求参数") - private String dataSourceParams; - - - @Comment("数据源-额外请求头") - private String dataSourceHeaders; -} diff --git a/src/main/java/cn/lihongjie/coal/excelGeneratorSheetInfo/entity/ExcelGeneratorSheetInfoEntity.java b/src/main/java/cn/lihongjie/coal/excelGeneratorSheetInfo/entity/ExcelGeneratorSheetInfoEntity.java deleted file mode 100644 index d935ab64..00000000 --- a/src/main/java/cn/lihongjie/coal/excelGeneratorSheetInfo/entity/ExcelGeneratorSheetInfoEntity.java +++ /dev/null @@ -1,73 +0,0 @@ -package cn.lihongjie.coal.excelGeneratorSheetInfo.entity; - -import cn.lihongjie.coal.base.entity.CommonEntity; -import cn.lihongjie.coal.excelGenerator.entity.ExcelGeneratorEntity; - -import jakarta.persistence.Entity; -import jakarta.persistence.ManyToOne; - -import lombok.Data; - -import org.hibernate.annotations.Comment; -import org.hibernate.annotations.Formula; - -@Data -@Entity -public class ExcelGeneratorSheetInfoEntity extends CommonEntity { - - @ManyToOne - private ExcelGeneratorEntity generator; - - - @Comment("数据源类型") - private String dataSourceType; - - @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 = 'excel.generator.datasource.type'\n" - + " and i.code = data_source_type)") - private String dataSourceTypeName; - - - @Comment("数据源-url") - private String dataSourceUrl; - - - @Comment("数据源-请求方式") - private String dataSourceMethod; - - - @Comment("数据源-请求参数") - private String dataSourceParams; - - - @Comment("数据源-额外请求头") - private String dataSourceHeaders; - - - - @Comment("数据源耗时") - private Long dataSourceCostTime; - - @Comment("模板耗时") - private Long templateCostTime; - - @Comment("生成耗时") - private Long generateCostTime; - - - @Comment("生成状态") - private String execStatus; - - @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 = 'common.execStatus'\n" - + " and i.code = exec_status)") - private String execStatusName; -} diff --git a/src/main/java/cn/lihongjie/coal/excelGeneratorSheetInfo/mapper/ExcelGeneratorSheetInfoMapper.java b/src/main/java/cn/lihongjie/coal/excelGeneratorSheetInfo/mapper/ExcelGeneratorSheetInfoMapper.java deleted file mode 100644 index 011a936b..00000000 --- a/src/main/java/cn/lihongjie/coal/excelGeneratorSheetInfo/mapper/ExcelGeneratorSheetInfoMapper.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.lihongjie.coal.excelGeneratorSheetInfo.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.excelGeneratorSheetInfo.dto.CreateExcelGeneratorSheetInfoDto; -import cn.lihongjie.coal.excelGeneratorSheetInfo.dto.ExcelGeneratorSheetInfoDto; -import cn.lihongjie.coal.excelGeneratorSheetInfo.dto.UpdateExcelGeneratorSheetInfoDto; -import cn.lihongjie.coal.excelGeneratorSheetInfo.entity.ExcelGeneratorSheetInfoEntity; - -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 ExcelGeneratorSheetInfoMapper - extends BaseMapper< - ExcelGeneratorSheetInfoEntity, - ExcelGeneratorSheetInfoDto, - CreateExcelGeneratorSheetInfoDto, - UpdateExcelGeneratorSheetInfoDto> {} diff --git a/src/main/java/cn/lihongjie/coal/excelGeneratorSheetInfo/repository/ExcelGeneratorSheetInfoRepository.java b/src/main/java/cn/lihongjie/coal/excelGeneratorSheetInfo/repository/ExcelGeneratorSheetInfoRepository.java deleted file mode 100644 index ec80233f..00000000 --- a/src/main/java/cn/lihongjie/coal/excelGeneratorSheetInfo/repository/ExcelGeneratorSheetInfoRepository.java +++ /dev/null @@ -1,10 +0,0 @@ -package cn.lihongjie.coal.excelGeneratorSheetInfo.repository; - -import cn.lihongjie.coal.base.dao.BaseRepository; -import cn.lihongjie.coal.excelGeneratorSheetInfo.entity.ExcelGeneratorSheetInfoEntity; - -import org.springframework.stereotype.Repository; - -@Repository -public interface ExcelGeneratorSheetInfoRepository - extends BaseRepository {} diff --git a/src/main/java/cn/lihongjie/coal/excelGeneratorSheetInfo/service/ExcelGeneratorSheetInfoService.java b/src/main/java/cn/lihongjie/coal/excelGeneratorSheetInfo/service/ExcelGeneratorSheetInfoService.java deleted file mode 100644 index f9224eb0..00000000 --- a/src/main/java/cn/lihongjie/coal/excelGeneratorSheetInfo/service/ExcelGeneratorSheetInfoService.java +++ /dev/null @@ -1,71 +0,0 @@ -package cn.lihongjie.coal.excelGeneratorSheetInfo.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.excelGeneratorSheetInfo.dto.CreateExcelGeneratorSheetInfoDto; -import cn.lihongjie.coal.excelGeneratorSheetInfo.dto.ExcelGeneratorSheetInfoDto; -import cn.lihongjie.coal.excelGeneratorSheetInfo.dto.UpdateExcelGeneratorSheetInfoDto; -import cn.lihongjie.coal.excelGeneratorSheetInfo.entity.ExcelGeneratorSheetInfoEntity; -import cn.lihongjie.coal.excelGeneratorSheetInfo.mapper.ExcelGeneratorSheetInfoMapper; -import cn.lihongjie.coal.excelGeneratorSheetInfo.repository.ExcelGeneratorSheetInfoRepository; - -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 ExcelGeneratorSheetInfoService - extends BaseService { - @Autowired private ExcelGeneratorSheetInfoRepository repository; - - @Autowired private ExcelGeneratorSheetInfoMapper mapper; - - @Autowired private ConversionService conversionService; - - public ExcelGeneratorSheetInfoDto create(CreateExcelGeneratorSheetInfoDto request) { - ExcelGeneratorSheetInfoEntity entity = mapper.toEntity(request); - - this.repository.save(entity); - return getById(entity.getId()); - } - - public ExcelGeneratorSheetInfoDto update(UpdateExcelGeneratorSheetInfoDto request) { - ExcelGeneratorSheetInfoEntity 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 ExcelGeneratorSheetInfoDto getById(String id) { - ExcelGeneratorSheetInfoEntity 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/java/cn/lihongjie/coal/excelTemplate/controller/ExcelTemplateController.java b/src/main/java/cn/lihongjie/coal/excelTemplate/controller/ExcelTemplateController.java deleted file mode 100644 index c399b5d1..00000000 --- a/src/main/java/cn/lihongjie/coal/excelTemplate/controller/ExcelTemplateController.java +++ /dev/null @@ -1,52 +0,0 @@ -package cn.lihongjie.coal.excelTemplate.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.excelTemplate.dto.CreateExcelTemplateDto; -import cn.lihongjie.coal.excelTemplate.dto.ExcelTemplateDto; -import cn.lihongjie.coal.excelTemplate.dto.UpdateExcelTemplateDto; -import cn.lihongjie.coal.excelTemplate.service.ExcelTemplateService; - -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("/excelTemplate") -@SysLog(module = "Excel模板生成服务") -@Slf4j -public class ExcelTemplateController { - @Autowired private ExcelTemplateService service; - - @PostMapping("/create") - public ExcelTemplateDto create(@RequestBody CreateExcelTemplateDto request) { - return this.service.create(request); - } - - @PostMapping("/update") - public ExcelTemplateDto update(@RequestBody UpdateExcelTemplateDto request) { - return this.service.update(request); - } - - @PostMapping("/delete") - public Object delete(@RequestBody IdRequest request) { - this.service.delete(request); - return true; - } - - @PostMapping("/getById") - public ExcelTemplateDto 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/excelTemplate/dto/CreateExcelTemplateDto.java b/src/main/java/cn/lihongjie/coal/excelTemplate/dto/CreateExcelTemplateDto.java deleted file mode 100644 index 6b62239f..00000000 --- a/src/main/java/cn/lihongjie/coal/excelTemplate/dto/CreateExcelTemplateDto.java +++ /dev/null @@ -1,8 +0,0 @@ -package cn.lihongjie.coal.excelTemplate.dto; - -import cn.lihongjie.coal.base.dto.CommonDto; - -import lombok.Data; - -@Data -public class CreateExcelTemplateDto extends CommonDto {} diff --git a/src/main/java/cn/lihongjie/coal/excelTemplate/dto/ExcelTemplateDto.java b/src/main/java/cn/lihongjie/coal/excelTemplate/dto/ExcelTemplateDto.java deleted file mode 100644 index 21fe2321..00000000 --- a/src/main/java/cn/lihongjie/coal/excelTemplate/dto/ExcelTemplateDto.java +++ /dev/null @@ -1,8 +0,0 @@ -package cn.lihongjie.coal.excelTemplate.dto; - -import cn.lihongjie.coal.base.dto.CommonDto; - -import lombok.Data; - -@Data -public class ExcelTemplateDto extends CommonDto {} diff --git a/src/main/java/cn/lihongjie/coal/excelTemplate/dto/UpdateExcelTemplateDto.java b/src/main/java/cn/lihongjie/coal/excelTemplate/dto/UpdateExcelTemplateDto.java deleted file mode 100644 index 39ac8b57..00000000 --- a/src/main/java/cn/lihongjie/coal/excelTemplate/dto/UpdateExcelTemplateDto.java +++ /dev/null @@ -1,8 +0,0 @@ -package cn.lihongjie.coal.excelTemplate.dto; - -import cn.lihongjie.coal.base.dto.CommonDto; - -import lombok.Data; - -@Data -public class UpdateExcelTemplateDto extends CommonDto {} diff --git a/src/main/java/cn/lihongjie/coal/excelTemplate/entity/ExcelTemplateEntity.java b/src/main/java/cn/lihongjie/coal/excelTemplate/entity/ExcelTemplateEntity.java deleted file mode 100644 index e1db8d25..00000000 --- a/src/main/java/cn/lihongjie/coal/excelTemplate/entity/ExcelTemplateEntity.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.lihongjie.coal.excelTemplate.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 ExcelTemplateEntity extends CommonEntity { - - - - private String content; - - @Comment("模板类型") - private String templateType; - - @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 = 'excel.template.type'\n" - + " and i.code = template_type)") - private String templateTypeName; -} diff --git a/src/main/java/cn/lihongjie/coal/excelTemplate/mapper/ExcelTemplateMapper.java b/src/main/java/cn/lihongjie/coal/excelTemplate/mapper/ExcelTemplateMapper.java deleted file mode 100644 index 5c294e3f..00000000 --- a/src/main/java/cn/lihongjie/coal/excelTemplate/mapper/ExcelTemplateMapper.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.lihongjie.coal.excelTemplate.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.excelTemplate.dto.CreateExcelTemplateDto; -import cn.lihongjie.coal.excelTemplate.dto.ExcelTemplateDto; -import cn.lihongjie.coal.excelTemplate.dto.UpdateExcelTemplateDto; -import cn.lihongjie.coal.excelTemplate.entity.ExcelTemplateEntity; - -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 ExcelTemplateMapper - extends BaseMapper< - ExcelTemplateEntity, - ExcelTemplateDto, - CreateExcelTemplateDto, - UpdateExcelTemplateDto> {} diff --git a/src/main/java/cn/lihongjie/coal/excelTemplate/repository/ExcelTemplateRepository.java b/src/main/java/cn/lihongjie/coal/excelTemplate/repository/ExcelTemplateRepository.java deleted file mode 100644 index 5a08b96a..00000000 --- a/src/main/java/cn/lihongjie/coal/excelTemplate/repository/ExcelTemplateRepository.java +++ /dev/null @@ -1,9 +0,0 @@ -package cn.lihongjie.coal.excelTemplate.repository; - -import cn.lihongjie.coal.base.dao.BaseRepository; -import cn.lihongjie.coal.excelTemplate.entity.ExcelTemplateEntity; - -import org.springframework.stereotype.Repository; - -@Repository -public interface ExcelTemplateRepository extends BaseRepository {} diff --git a/src/main/java/cn/lihongjie/coal/excelTemplate/service/ExcelTemplateService.java b/src/main/java/cn/lihongjie/coal/excelTemplate/service/ExcelTemplateService.java deleted file mode 100644 index 55925aab..00000000 --- a/src/main/java/cn/lihongjie/coal/excelTemplate/service/ExcelTemplateService.java +++ /dev/null @@ -1,87 +0,0 @@ -package cn.lihongjie.coal.excelTemplate.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.excelTemplate.dto.CreateExcelTemplateDto; -import cn.lihongjie.coal.excelTemplate.dto.ExcelTemplateDto; -import cn.lihongjie.coal.excelTemplate.dto.UpdateExcelTemplateDto; -import cn.lihongjie.coal.excelTemplate.entity.ExcelTemplateEntity; -import cn.lihongjie.coal.excelTemplate.mapper.ExcelTemplateMapper; -import cn.lihongjie.coal.excelTemplate.repository.ExcelTemplateRepository; - -import jakarta.persistence.criteria.CriteriaBuilder; -import jakarta.persistence.criteria.CriteriaQuery; -import jakarta.persistence.criteria.Predicate; -import jakarta.persistence.criteria.Root; - -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.data.jpa.domain.Specification; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -@Service -@Slf4j -@Transactional -public class ExcelTemplateService - extends BaseService { - @Autowired private ExcelTemplateRepository repository; - - @Autowired private ExcelTemplateMapper mapper; - - @Autowired private ConversionService conversionService; - - public ExcelTemplateDto create(CreateExcelTemplateDto request) { - ExcelTemplateEntity entity = mapper.toEntity(request); - - this.repository.save(entity); - return getById(entity.getId()); - } - - public ExcelTemplateDto update(UpdateExcelTemplateDto request) { - ExcelTemplateEntity 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 ExcelTemplateDto getById(String id) { - ExcelTemplateEntity 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); - } - - public ExcelTemplateEntity getByCode(String templateCode) { - - return repository.findOne(new Specification() { - @Override - public Predicate toPredicate(Root root, CriteriaQuery query, CriteriaBuilder criteriaBuilder) { - return criteriaBuilder.equal(root.get("code"), templateCode); - } - }).orElse(null); - } -}