From 3e5169444feca883b46860efaaf447e05752e339 Mon Sep 17 00:00:00 2001 From: lihongjie0209 Date: Mon, 15 Apr 2024 14:32:23 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=BF=87=E7=A3=85=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=8A=A5=E8=A1=A8=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../WeightDeviceDataReportController.java | 54 ++++++++++++++ .../dto/CreateWeightDeviceDataReportDto.java | 10 +++ .../dto/UpdateWeightDeviceDataReportDto.java | 10 +++ .../dto/WeightDeviceDataReportDto.java | 10 +++ .../entity/WeightDeviceDataReportEntity.java | 14 ++++ .../mapper/WeightDeviceDataReportMapper.java | 23 ++++++ .../WeightDeviceDataReportRepository.java | 10 +++ .../WeightDeviceDataReportService.java | 74 +++++++++++++++++++ .../enum/weightDeviceDataReportDict.groovy | 17 +++++ 9 files changed, 222 insertions(+) create mode 100644 src/main/java/cn/lihongjie/coal/weightDeviceDataReport/controller/WeightDeviceDataReportController.java create mode 100644 src/main/java/cn/lihongjie/coal/weightDeviceDataReport/dto/CreateWeightDeviceDataReportDto.java create mode 100644 src/main/java/cn/lihongjie/coal/weightDeviceDataReport/dto/UpdateWeightDeviceDataReportDto.java create mode 100644 src/main/java/cn/lihongjie/coal/weightDeviceDataReport/dto/WeightDeviceDataReportDto.java create mode 100644 src/main/java/cn/lihongjie/coal/weightDeviceDataReport/entity/WeightDeviceDataReportEntity.java create mode 100644 src/main/java/cn/lihongjie/coal/weightDeviceDataReport/mapper/WeightDeviceDataReportMapper.java create mode 100644 src/main/java/cn/lihongjie/coal/weightDeviceDataReport/repository/WeightDeviceDataReportRepository.java create mode 100644 src/main/java/cn/lihongjie/coal/weightDeviceDataReport/service/WeightDeviceDataReportService.java create mode 100644 src/main/resources/scripts/dict/enum/weightDeviceDataReportDict.groovy diff --git a/src/main/java/cn/lihongjie/coal/weightDeviceDataReport/controller/WeightDeviceDataReportController.java b/src/main/java/cn/lihongjie/coal/weightDeviceDataReport/controller/WeightDeviceDataReportController.java new file mode 100644 index 00000000..2d4d7ecf --- /dev/null +++ b/src/main/java/cn/lihongjie/coal/weightDeviceDataReport/controller/WeightDeviceDataReportController.java @@ -0,0 +1,54 @@ +package cn.lihongjie.coal.weightDeviceDataReport.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.weightDeviceDataReport.dto.CreateWeightDeviceDataReportDto; +import cn.lihongjie.coal.weightDeviceDataReport.dto.UpdateWeightDeviceDataReportDto; +import cn.lihongjie.coal.weightDeviceDataReport.dto.WeightDeviceDataReportDto; +import cn.lihongjie.coal.weightDeviceDataReport.service.WeightDeviceDataReportService; + +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("/weightDeviceDataReport") +@SysLog(module = "过磅数据报表") +@Slf4j +@OrgScope +public class WeightDeviceDataReportController { + @Autowired private WeightDeviceDataReportService service; + + @PostMapping("/create") + public WeightDeviceDataReportDto create(@RequestBody CreateWeightDeviceDataReportDto request) { + return this.service.create(request); + } + + @PostMapping("/update") + public WeightDeviceDataReportDto update(@RequestBody UpdateWeightDeviceDataReportDto request) { + return this.service.update(request); + } + + @PostMapping("/delete") + public Object delete(@RequestBody IdRequest request) { + this.service.delete(request); + return true; + } + + @PostMapping("/getById") + public WeightDeviceDataReportDto 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/weightDeviceDataReport/dto/CreateWeightDeviceDataReportDto.java b/src/main/java/cn/lihongjie/coal/weightDeviceDataReport/dto/CreateWeightDeviceDataReportDto.java new file mode 100644 index 00000000..5e82a738 --- /dev/null +++ b/src/main/java/cn/lihongjie/coal/weightDeviceDataReport/dto/CreateWeightDeviceDataReportDto.java @@ -0,0 +1,10 @@ +package cn.lihongjie.coal.weightDeviceDataReport.dto; + +import cn.lihongjie.coal.base.dto.OrgCommonDto; + +import lombok.Data; + +@Data +public class CreateWeightDeviceDataReportDto extends OrgCommonDto { + private String jsonConfig; +} diff --git a/src/main/java/cn/lihongjie/coal/weightDeviceDataReport/dto/UpdateWeightDeviceDataReportDto.java b/src/main/java/cn/lihongjie/coal/weightDeviceDataReport/dto/UpdateWeightDeviceDataReportDto.java new file mode 100644 index 00000000..6f80fc81 --- /dev/null +++ b/src/main/java/cn/lihongjie/coal/weightDeviceDataReport/dto/UpdateWeightDeviceDataReportDto.java @@ -0,0 +1,10 @@ +package cn.lihongjie.coal.weightDeviceDataReport.dto; + +import cn.lihongjie.coal.base.dto.OrgCommonDto; + +import lombok.Data; + +@Data +public class UpdateWeightDeviceDataReportDto extends OrgCommonDto { + private String jsonConfig; +} diff --git a/src/main/java/cn/lihongjie/coal/weightDeviceDataReport/dto/WeightDeviceDataReportDto.java b/src/main/java/cn/lihongjie/coal/weightDeviceDataReport/dto/WeightDeviceDataReportDto.java new file mode 100644 index 00000000..1a5b6154 --- /dev/null +++ b/src/main/java/cn/lihongjie/coal/weightDeviceDataReport/dto/WeightDeviceDataReportDto.java @@ -0,0 +1,10 @@ +package cn.lihongjie.coal.weightDeviceDataReport.dto; + +import cn.lihongjie.coal.base.dto.OrgCommonDto; + +import lombok.Data; + +@Data +public class WeightDeviceDataReportDto extends OrgCommonDto { + private String jsonConfig; +} diff --git a/src/main/java/cn/lihongjie/coal/weightDeviceDataReport/entity/WeightDeviceDataReportEntity.java b/src/main/java/cn/lihongjie/coal/weightDeviceDataReport/entity/WeightDeviceDataReportEntity.java new file mode 100644 index 00000000..f7dced4f --- /dev/null +++ b/src/main/java/cn/lihongjie/coal/weightDeviceDataReport/entity/WeightDeviceDataReportEntity.java @@ -0,0 +1,14 @@ +package cn.lihongjie.coal.weightDeviceDataReport.entity; + +import cn.lihongjie.coal.base.entity.OrgCommonEntity; + +import jakarta.persistence.Entity; + +import lombok.Data; + +@Data +@Entity +public class WeightDeviceDataReportEntity extends OrgCommonEntity { + + private String jsonConfig; +} diff --git a/src/main/java/cn/lihongjie/coal/weightDeviceDataReport/mapper/WeightDeviceDataReportMapper.java b/src/main/java/cn/lihongjie/coal/weightDeviceDataReport/mapper/WeightDeviceDataReportMapper.java new file mode 100644 index 00000000..952e0fff --- /dev/null +++ b/src/main/java/cn/lihongjie/coal/weightDeviceDataReport/mapper/WeightDeviceDataReportMapper.java @@ -0,0 +1,23 @@ +package cn.lihongjie.coal.weightDeviceDataReport.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.weightDeviceDataReport.dto.CreateWeightDeviceDataReportDto; +import cn.lihongjie.coal.weightDeviceDataReport.dto.UpdateWeightDeviceDataReportDto; +import cn.lihongjie.coal.weightDeviceDataReport.dto.WeightDeviceDataReportDto; +import cn.lihongjie.coal.weightDeviceDataReport.entity.WeightDeviceDataReportEntity; + +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 WeightDeviceDataReportMapper + extends BaseMapper< + WeightDeviceDataReportEntity, + WeightDeviceDataReportDto, + CreateWeightDeviceDataReportDto, + UpdateWeightDeviceDataReportDto> {} diff --git a/src/main/java/cn/lihongjie/coal/weightDeviceDataReport/repository/WeightDeviceDataReportRepository.java b/src/main/java/cn/lihongjie/coal/weightDeviceDataReport/repository/WeightDeviceDataReportRepository.java new file mode 100644 index 00000000..4f146ff9 --- /dev/null +++ b/src/main/java/cn/lihongjie/coal/weightDeviceDataReport/repository/WeightDeviceDataReportRepository.java @@ -0,0 +1,10 @@ +package cn.lihongjie.coal.weightDeviceDataReport.repository; + +import cn.lihongjie.coal.base.dao.BaseRepository; +import cn.lihongjie.coal.weightDeviceDataReport.entity.WeightDeviceDataReportEntity; + +import org.springframework.stereotype.Repository; + +@Repository +public interface WeightDeviceDataReportRepository + extends BaseRepository {} diff --git a/src/main/java/cn/lihongjie/coal/weightDeviceDataReport/service/WeightDeviceDataReportService.java b/src/main/java/cn/lihongjie/coal/weightDeviceDataReport/service/WeightDeviceDataReportService.java new file mode 100644 index 00000000..48bf4990 --- /dev/null +++ b/src/main/java/cn/lihongjie/coal/weightDeviceDataReport/service/WeightDeviceDataReportService.java @@ -0,0 +1,74 @@ +package cn.lihongjie.coal.weightDeviceDataReport.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.weightDeviceDataReport.dto.CreateWeightDeviceDataReportDto; +import cn.lihongjie.coal.weightDeviceDataReport.dto.UpdateWeightDeviceDataReportDto; +import cn.lihongjie.coal.weightDeviceDataReport.dto.WeightDeviceDataReportDto; +import cn.lihongjie.coal.weightDeviceDataReport.entity.WeightDeviceDataReportEntity; +import cn.lihongjie.coal.weightDeviceDataReport.mapper.WeightDeviceDataReportMapper; +import cn.lihongjie.coal.weightDeviceDataReport.repository.WeightDeviceDataReportRepository; + +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 WeightDeviceDataReportService + extends BaseService { + @Autowired private WeightDeviceDataReportRepository repository; + + @Autowired private WeightDeviceDataReportMapper mapper; + + @Autowired private ConversionService conversionService; + + @Autowired private DbFunctionService dbFunctionService; + + public WeightDeviceDataReportDto create(CreateWeightDeviceDataReportDto request) { + WeightDeviceDataReportEntity entity = mapper.toEntity(request); + + this.repository.save(entity); + return getById(entity.getId()); + } + + public WeightDeviceDataReportDto update(UpdateWeightDeviceDataReportDto request) { + WeightDeviceDataReportEntity 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 WeightDeviceDataReportDto getById(String id) { + WeightDeviceDataReportEntity 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/weightDeviceDataReportDict.groovy b/src/main/resources/scripts/dict/enum/weightDeviceDataReportDict.groovy new file mode 100644 index 00000000..1db9b93a --- /dev/null +++ b/src/main/resources/scripts/dict/enum/weightDeviceDataReportDict.groovy @@ -0,0 +1,17 @@ + +package scripts.dict + +import cn.lihongjie.coal.base.dto.CommonQuery +import cn.lihongjie.coal.weightDeviceDataReport.controller.WeightDeviceDataReportController +import org.springframework.context.ApplicationContext + +ApplicationContext ioc = ioc + +def controller = ioc.getBean(WeightDeviceDataReportController.class) + + + + +return controller.list(new CommonQuery()) + +