diff --git a/src/main/java/cn/lihongjie/coal/coalAnalysis/controller/CoalAnalysisController.java b/src/main/java/cn/lihongjie/coal/coalAnalysis/controller/CoalAnalysisController.java new file mode 100644 index 00000000..6acbc821 --- /dev/null +++ b/src/main/java/cn/lihongjie/coal/coalAnalysis/controller/CoalAnalysisController.java @@ -0,0 +1,60 @@ +package cn.lihongjie.coal.coalAnalysis.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.coalAnalysis.dto.CoalAnalysisDto; +import cn.lihongjie.coal.coalAnalysis.dto.CreateCoalAnalysisDto; +import cn.lihongjie.coal.coalAnalysis.dto.UpdateCoalAnalysisDto; +import cn.lihongjie.coal.coalAnalysis.service.CoalAnalysisService; +import java.lang.Object; +import java.lang.String; +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("/coalAnalysis") +@SysLog( + module = "煤源化验" +) +@Slf4j +@OrgScope +public class CoalAnalysisController { + @Autowired + private CoalAnalysisService service; + + @PostMapping("/create") + public CoalAnalysisDto create(@RequestBody CreateCoalAnalysisDto request) { + return this.service.create(request) + ; + } + + @PostMapping("/update") + public CoalAnalysisDto update(@RequestBody UpdateCoalAnalysisDto request) { + return this.service.update(request) + ; + } + + @PostMapping("/delete") + public Object delete(@RequestBody IdRequest request) { + this.service.delete(request); + return true + ; + } + + public CoalAnalysisDto getById(@RequestBody String request) { + return this.service.getById(request) + ; + } + + public Page list(@RequestBody CommonQuery request) { + return this.service.list(request) + ; + } +} diff --git a/src/main/java/cn/lihongjie/coal/coalAnalysis/dto/CoalAnalysisDto.java b/src/main/java/cn/lihongjie/coal/coalAnalysis/dto/CoalAnalysisDto.java new file mode 100644 index 00000000..cc16e552 --- /dev/null +++ b/src/main/java/cn/lihongjie/coal/coalAnalysis/dto/CoalAnalysisDto.java @@ -0,0 +1,76 @@ +package cn.lihongjie.coal.coalAnalysis.dto; + +import cn.lihongjie.coal.base.dto.OrgCommonDto; +import cn.lihongjie.coal.coalInfo.entity.CoalInfoEntity; +import jakarta.persistence.ManyToOne; +import jakarta.validation.constraints.DecimalMin; +import lombok.Data; +import org.hibernate.annotations.Comment; + +@Data +public class CoalAnalysisDto extends OrgCommonDto { + @Comment("关联的煤源信息") + private CoalInfoEntity coalInfo; + + + @Comment("参数 1 ") + @DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param1; + @Comment("参数 2 ") + @DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param2; + @Comment("参数 3 ") + @DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param3; + @Comment("参数 4 ") + @DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param4; + @Comment("参数 5 ") + @DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param5; + @Comment("参数 6 ") + @DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param6; + @Comment("参数 7 ") + @DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param7; + @Comment("参数 8 ") + @DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param8; + @Comment("参数 9 ") + @DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param9; + @Comment("参数 10 ") + @DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param10; + @Comment("参数 11 ") + @DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param11; + @Comment("参数 12 ") + @DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param12; + @Comment("参数 13 ") + @DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param13; + @Comment("参数 14 ") + @DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param14; + @Comment("参数 15 ") + @DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param15; + @Comment("参数 16 ") + @DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param16; + @Comment("参数 17 ") + @DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param17; + @Comment("参数 18 ") + @DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param18; + @Comment("参数 19 ") + @DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param19; + @Comment("参数 20 ") + @DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param20; +} diff --git a/src/main/java/cn/lihongjie/coal/coalAnalysis/dto/CreateCoalAnalysisDto.java b/src/main/java/cn/lihongjie/coal/coalAnalysis/dto/CreateCoalAnalysisDto.java new file mode 100644 index 00000000..f1d8e58b --- /dev/null +++ b/src/main/java/cn/lihongjie/coal/coalAnalysis/dto/CreateCoalAnalysisDto.java @@ -0,0 +1,74 @@ +package cn.lihongjie.coal.coalAnalysis.dto; + +import cn.lihongjie.coal.base.dto.OrgCommonDto; +import jakarta.validation.constraints.DecimalMin; +import lombok.Data; +import org.hibernate.annotations.Comment; + +@Data +public class CreateCoalAnalysisDto extends OrgCommonDto { + @Comment("关联的煤源信息") + private String coalInfo; + + + @Comment("参数 1 ") + @DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param1; + @Comment("参数 2 ") + @DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param2; + @Comment("参数 3 ") + @DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param3; + @Comment("参数 4 ") + @DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param4; + @Comment("参数 5 ") + @DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param5; + @Comment("参数 6 ") + @DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param6; + @Comment("参数 7 ") + @DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param7; + @Comment("参数 8 ") + @DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param8; + @Comment("参数 9 ") + @DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param9; + @Comment("参数 10 ") + @DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param10; + @Comment("参数 11 ") + @DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param11; + @Comment("参数 12 ") + @DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param12; + @Comment("参数 13 ") + @DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param13; + @Comment("参数 14 ") + @DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param14; + @Comment("参数 15 ") + @DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param15; + @Comment("参数 16 ") + @DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param16; + @Comment("参数 17 ") + @DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param17; + @Comment("参数 18 ") + @DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param18; + @Comment("参数 19 ") + @DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param19; + @Comment("参数 20 ") + @DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param20; +} diff --git a/src/main/java/cn/lihongjie/coal/coalAnalysis/dto/UpdateCoalAnalysisDto.java b/src/main/java/cn/lihongjie/coal/coalAnalysis/dto/UpdateCoalAnalysisDto.java new file mode 100644 index 00000000..4b4d7a8f --- /dev/null +++ b/src/main/java/cn/lihongjie/coal/coalAnalysis/dto/UpdateCoalAnalysisDto.java @@ -0,0 +1,76 @@ +package cn.lihongjie.coal.coalAnalysis.dto; + +import cn.lihongjie.coal.base.dto.OrgCommonDto; +import cn.lihongjie.coal.coalInfo.entity.CoalInfoEntity; +import jakarta.persistence.ManyToOne; +import jakarta.validation.constraints.DecimalMin; +import lombok.Data; +import org.hibernate.annotations.Comment; + +@Data +public class UpdateCoalAnalysisDto extends OrgCommonDto { + @Comment("关联的煤源信息") + private String coalInfo; + + + @Comment("参数 1 ") + @DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param1; + @Comment("参数 2 ") + @DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param2; + @Comment("参数 3 ") + @DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param3; + @Comment("参数 4 ") + @DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param4; + @Comment("参数 5 ") + @DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param5; + @Comment("参数 6 ") + @DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param6; + @Comment("参数 7 ") + @DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param7; + @Comment("参数 8 ") + @DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param8; + @Comment("参数 9 ") + @DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param9; + @Comment("参数 10 ") + @DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param10; + @Comment("参数 11 ") + @DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param11; + @Comment("参数 12 ") + @DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param12; + @Comment("参数 13 ") + @DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param13; + @Comment("参数 14 ") + @DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param14; + @Comment("参数 15 ") + @DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param15; + @Comment("参数 16 ") + @DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param16; + @Comment("参数 17 ") + @DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param17; + @Comment("参数 18 ") + @DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param18; + @Comment("参数 19 ") + @DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param19; + @Comment("参数 20 ") + @DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param20; +} diff --git a/src/main/java/cn/lihongjie/coal/coalAnalysis/entity/CoalAnalysisEntity.java b/src/main/java/cn/lihongjie/coal/coalAnalysis/entity/CoalAnalysisEntity.java new file mode 100644 index 00000000..be2e2920 --- /dev/null +++ b/src/main/java/cn/lihongjie/coal/coalAnalysis/entity/CoalAnalysisEntity.java @@ -0,0 +1,80 @@ +package cn.lihongjie.coal.coalAnalysis.entity; + +import cn.lihongjie.coal.base.entity.OrgCommonEntity; +import cn.lihongjie.coal.coalInfo.entity.CoalInfoEntity; +import jakarta.persistence.Entity; +import jakarta.persistence.ManyToOne; +import jakarta.validation.constraints.DecimalMin; +import lombok.Data; +import org.hibernate.annotations.Comment; + +@Data +@Entity +public class CoalAnalysisEntity extends OrgCommonEntity { + @ManyToOne + @Comment("关联的煤源信息") + private CoalInfoEntity coalInfo; + + + @Comment("参数 1 ") + @DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param1; + @Comment("参数 2 ") + @DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param2; + @Comment("参数 3 ") + @DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param3; + @Comment("参数 4 ") + @DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param4; + @Comment("参数 5 ") + @DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param5; + @Comment("参数 6 ") + @DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param6; + @Comment("参数 7 ") + @DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param7; + @Comment("参数 8 ") + @DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param8; + @Comment("参数 9 ") + @DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param9; + @Comment("参数 10 ") + @DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param10; + @Comment("参数 11 ") + @DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param11; + @Comment("参数 12 ") + @DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param12; + @Comment("参数 13 ") + @DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param13; + @Comment("参数 14 ") + @DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param14; + @Comment("参数 15 ") + @DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param15; + @Comment("参数 16 ") + @DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param16; + @Comment("参数 17 ") + @DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param17; + @Comment("参数 18 ") + @DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param18; + @Comment("参数 19 ") + @DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param19; + @Comment("参数 20 ") + @DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param20; + +} diff --git a/src/main/java/cn/lihongjie/coal/coalAnalysis/mapper/CoalAnalysisMapper.java b/src/main/java/cn/lihongjie/coal/coalAnalysis/mapper/CoalAnalysisMapper.java new file mode 100644 index 00000000..65f74869 --- /dev/null +++ b/src/main/java/cn/lihongjie/coal/coalAnalysis/mapper/CoalAnalysisMapper.java @@ -0,0 +1,18 @@ +package cn.lihongjie.coal.coalAnalysis.mapper; + +import cn.lihongjie.coal.base.mapper.BaseMapper; +import cn.lihongjie.coal.base.mapper.CommonMapper; +import cn.lihongjie.coal.coalAnalysis.dto.CoalAnalysisDto; +import cn.lihongjie.coal.coalAnalysis.dto.CreateCoalAnalysisDto; +import cn.lihongjie.coal.coalAnalysis.dto.UpdateCoalAnalysisDto; +import cn.lihongjie.coal.coalAnalysis.entity.CoalAnalysisEntity; +import org.mapstruct.Mapper; +import org.mapstruct.control.DeepClone; + +@Mapper( + componentModel = org.mapstruct.MappingConstants.ComponentModel.SPRING, + uses = {CommonMapper.class}, + mappingControl = DeepClone.class +) +public interface CoalAnalysisMapper extends BaseMapper { +} diff --git a/src/main/java/cn/lihongjie/coal/coalAnalysis/repository/CoalAnalysisRepository.java b/src/main/java/cn/lihongjie/coal/coalAnalysis/repository/CoalAnalysisRepository.java new file mode 100644 index 00000000..6c7542de --- /dev/null +++ b/src/main/java/cn/lihongjie/coal/coalAnalysis/repository/CoalAnalysisRepository.java @@ -0,0 +1,9 @@ +package cn.lihongjie.coal.coalAnalysis.repository; + +import cn.lihongjie.coal.base.dao.BaseRepository; +import cn.lihongjie.coal.coalAnalysis.entity.CoalAnalysisEntity; +import org.springframework.stereotype.Repository; + +@Repository +public interface CoalAnalysisRepository extends BaseRepository { +} diff --git a/src/main/java/cn/lihongjie/coal/coalAnalysis/service/CoalAnalysisService.java b/src/main/java/cn/lihongjie/coal/coalAnalysis/service/CoalAnalysisService.java new file mode 100644 index 00000000..8913c712 --- /dev/null +++ b/src/main/java/cn/lihongjie/coal/coalAnalysis/service/CoalAnalysisService.java @@ -0,0 +1,72 @@ +package cn.lihongjie.coal.coalAnalysis.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.coalAnalysis.dto.CoalAnalysisDto; +import cn.lihongjie.coal.coalAnalysis.dto.CreateCoalAnalysisDto; +import cn.lihongjie.coal.coalAnalysis.dto.UpdateCoalAnalysisDto; +import cn.lihongjie.coal.coalAnalysis.entity.CoalAnalysisEntity; +import cn.lihongjie.coal.coalAnalysis.mapper.CoalAnalysisMapper; +import cn.lihongjie.coal.coalAnalysis.repository.CoalAnalysisRepository; +import java.lang.String; +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; + +@Service +@Slf4j +public class CoalAnalysisService extends BaseService { + @Autowired + private CoalAnalysisRepository repository; + + @Autowired + private CoalAnalysisMapper mapper; + + @Autowired + private ConversionService conversionService; + + public CoalAnalysisDto create(CreateCoalAnalysisDto request) { + CoalAnalysisEntity entity = mapper.toEntity(request); + + + this.repository.save(entity); + return getById(entity.getId()) + ; + } + + public CoalAnalysisDto update(UpdateCoalAnalysisDto request) { + CoalAnalysisEntity 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 CoalAnalysisDto getById(String id) { + CoalAnalysisEntity 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) + ; + } +}