门户-数据需求开发
Showing
10 changed files
with
1091 additions
and
0 deletions
1 | package com.csbr.qingcloud.controller; | ||
2 | |||
3 | import com.csbr.cloud.common.response.CommonRes; | ||
4 | import csbr.cloud.entity.annotation.SystemLog; | ||
5 | import csbr.cloud.entity.domain.base.vo.PageListVO; | ||
6 | import com.csbr.qingcloud.domain.vo.DemandQueryVO; | ||
7 | import com.csbr.qingcloud.domain.vo.DemandRQVO; | ||
8 | import com.csbr.qingcloud.domain.vo.DemandRSVO; | ||
9 | import com.csbr.qingcloud.service.DemandService; | ||
10 | import io.swagger.v3.oas.annotations.Operation; | ||
11 | import io.swagger.v3.oas.annotations.Parameter; | ||
12 | import io.swagger.v3.oas.annotations.tags.Tag; | ||
13 | import jakarta.annotation.Resource; | ||
14 | import jakarta.validation.Valid; | ||
15 | import org.springframework.web.bind.annotation.*; | ||
16 | |||
17 | import java.util.List; | ||
18 | |||
19 | /** | ||
20 | * @program: D:/csbr/sjzc/ms-data-circulation-portal-service | ||
21 | * @description: -控制器 | ||
22 | * @author: xushaobo | ||
23 | * @create: 2024-12-30 16:29 | ||
24 | **/ | ||
25 | @RestController | ||
26 | @RequestMapping("/demand") | ||
27 | @Tag(name = "-控制器") | ||
28 | public class DemandController { | ||
29 | |||
30 | @Resource | ||
31 | private DemandService demandService; | ||
32 | |||
33 | //region 基本操作 | ||
34 | |||
35 | @PostMapping("/save") | ||
36 | @SystemLog(value = "-新增") | ||
37 | @Operation(summary = "-新增") | ||
38 | public CommonRes<Boolean> saveDemand(@RequestBody @Valid DemandRQVO vo) { | ||
39 | demandService.saveDemand(vo); | ||
40 | return CommonRes.success(true); | ||
41 | } | ||
42 | |||
43 | @PutMapping("/update") | ||
44 | @SystemLog(value = "-修改") | ||
45 | @Operation(summary = "-修改") | ||
46 | public CommonRes<Boolean> updateDemand(@RequestBody @Valid DemandRQVO vo) { | ||
47 | demandService.updateDemand(vo); | ||
48 | return CommonRes.success(true); | ||
49 | } | ||
50 | |||
51 | @DeleteMapping("/delete") | ||
52 | @SystemLog(value = "-批量删除") | ||
53 | @Operation(summary = "-批量删除") | ||
54 | public CommonRes<Boolean> removeByGuids(@RequestBody List<String> guids) { | ||
55 | demandService.removeByGuids(guids); | ||
56 | return CommonRes.success(true); | ||
57 | } | ||
58 | |||
59 | @PostMapping("/page-list") | ||
60 | @SystemLog(value = "-分页") | ||
61 | @Operation(summary = "-分页") | ||
62 | public CommonRes<PageListVO<DemandRSVO>> pageList(@RequestBody @Valid DemandQueryVO queryVO) { | ||
63 | PageListVO<DemandRSVO> pageVO = demandService.pageList(queryVO); | ||
64 | return CommonRes.success(pageVO); | ||
65 | } | ||
66 | |||
67 | @GetMapping("/detail") | ||
68 | @SystemLog(value = "-详情") | ||
69 | @Operation( | ||
70 | summary = "-详情", | ||
71 | parameters = { | ||
72 | @Parameter(name = "guid", description = "唯一标识", required = true)} | ||
73 | ) | ||
74 | public CommonRes<DemandRSVO> getDemandDetail(@RequestParam String guid) { | ||
75 | DemandRSVO vo = demandService.getDemandDetail(guid); | ||
76 | return CommonRes.success(vo); | ||
77 | } | ||
78 | |||
79 | //endregion | ||
80 | |||
81 | } |
1 | package com.csbr.qingcloud.domain.vo; | ||
2 | |||
3 | import csbr.cloud.entity.domain.base.dto.BasePageDTO; | ||
4 | import io.swagger.v3.oas.annotations.media.Schema; | ||
5 | import lombok.EqualsAndHashCode; | ||
6 | import lombok.Data; | ||
7 | import java.math.BigDecimal; | ||
8 | import java.util.Date; | ||
9 | |||
10 | /** | ||
11 | * @program: D:/csbr/sjzc/ms-data-circulation-portal-service | ||
12 | * @description: 查询参数 | ||
13 | * @author: xushaobo | ||
14 | * @create: 2024-12-30 16:29 | ||
15 | **/ | ||
16 | @EqualsAndHashCode(callSuper = true) | ||
17 | @Data | ||
18 | @Schema(title = "查询参数") | ||
19 | public class DemandQueryVO extends BasePageDTO { | ||
20 | |||
21 | } |
1 | package com.csbr.qingcloud.domain.vo; | ||
2 | |||
3 | import io.swagger.v3.oas.annotations.media.Schema; | ||
4 | import com.fasterxml.jackson.annotation.JsonFormat; | ||
5 | import lombok.Data; | ||
6 | import java.math.BigDecimal; | ||
7 | import java.util.Date; | ||
8 | |||
9 | /** | ||
10 | * @program: D:/csbr/sjzc/ms-data-circulation-portal-service | ||
11 | * @description: 新增、修改参数 | ||
12 | * @author: xushaobo | ||
13 | * @create: 2024-12-30 16:29 | ||
14 | **/ | ||
15 | @Data | ||
16 | @Schema(title = "新增、修改参数") | ||
17 | public class DemandRQVO { | ||
18 | |||
19 | /** | ||
20 | * 系统唯一标识 | ||
21 | */ | ||
22 | @Schema(description = "系统唯一标识") | ||
23 | private String guid; | ||
24 | |||
25 | /** | ||
26 | * 数据需求名称 | ||
27 | */ | ||
28 | @Schema(description = "数据需求名称") | ||
29 | private String dataDemandName; | ||
30 | |||
31 | /** | ||
32 | * 需求类型 (1 产业端;2 科研端;3 临床端) | ||
33 | */ | ||
34 | @Schema(description = "需求类型 (1 产业端;2 科研端;3 临床端)") | ||
35 | private String requirementType; | ||
36 | |||
37 | /** | ||
38 | * 需求开始时间 | ||
39 | */ | ||
40 | @Schema(description = "需求开始时间") | ||
41 | @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") | ||
42 | private Date requirementTermSdate; | ||
43 | |||
44 | /** | ||
45 | * 需求结束时间 | ||
46 | */ | ||
47 | @Schema(description = "需求结束时间") | ||
48 | @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") | ||
49 | private Date requirementTermEdate; | ||
50 | |||
51 | /** | ||
52 | * 需求内容 | ||
53 | */ | ||
54 | @Schema(description = "需求内容") | ||
55 | private String requirementContent; | ||
56 | |||
57 | /** | ||
58 | * 数据需求字段 数据格式:[{"name":"","path":""},{"name":"","path":""}] | ||
59 | */ | ||
60 | @Schema(description = "数据需求字段 数据格式:[{\"name\":\"\",\"path\":\"\"},{\"name\":\"\",\"path\":\"\"}]") | ||
61 | private String dataDemandFieldAttachJson; | ||
62 | |||
63 | /** | ||
64 | * 期望交付时间 | ||
65 | */ | ||
66 | @Schema(description = "期望交付时间") | ||
67 | private BigDecimal deliveryTime; | ||
68 | |||
69 | /** | ||
70 | * 最低预算 | ||
71 | */ | ||
72 | @Schema(description = "最低预算") | ||
73 | private BigDecimal minBudget; | ||
74 | |||
75 | /** | ||
76 | * 最高预算 | ||
77 | */ | ||
78 | @Schema(description = "最高预算") | ||
79 | private BigDecimal maxBudget; | ||
80 | |||
81 | /** | ||
82 | * 费用来源 | ||
83 | */ | ||
84 | @Schema(description = "费用来源") | ||
85 | private String costSource; | ||
86 | |||
87 | /** | ||
88 | * 更新周期 | ||
89 | */ | ||
90 | @Schema(description = "更新周期") | ||
91 | private String updateCycle; | ||
92 | |||
93 | /** | ||
94 | * 获取路径方式 (1 接口调用;2 文件下载) | ||
95 | */ | ||
96 | @Schema(description = "获取路径方式 (1 接口调用;2 文件下载)") | ||
97 | private String requestType; | ||
98 | |||
99 | /** | ||
100 | * 场景名称 | ||
101 | */ | ||
102 | @Schema(description = "场景名称") | ||
103 | private String sceneName; | ||
104 | |||
105 | /** | ||
106 | * 应用场景描述 | ||
107 | */ | ||
108 | @Schema(description = "应用场景描述") | ||
109 | private String sceneDescription; | ||
110 | |||
111 | /** | ||
112 | * 数据质量要求 | ||
113 | */ | ||
114 | @Schema(description = "数据质量要求") | ||
115 | private String qualityDemand; | ||
116 | |||
117 | /** | ||
118 | * 隐私合规要求 | ||
119 | */ | ||
120 | @Schema(description = "隐私合规要求") | ||
121 | private String privacyDemand; | ||
122 | |||
123 | /** | ||
124 | * 其他补充内容 | ||
125 | */ | ||
126 | @Schema(description = "其他补充内容") | ||
127 | private String otherContent; | ||
128 | |||
129 | /** | ||
130 | * 联系人 | ||
131 | */ | ||
132 | @Schema(description = "联系人") | ||
133 | private String contacts; | ||
134 | |||
135 | /** | ||
136 | * 需求单位 | ||
137 | */ | ||
138 | @Schema(description = "需求单位") | ||
139 | private String requirementUnit; | ||
140 | |||
141 | /** | ||
142 | * 联系方式 | ||
143 | */ | ||
144 | @Schema(description = "联系方式") | ||
145 | private String contactInformation; | ||
146 | |||
147 | /******** 库表存储属性 需处理 *****/ | ||
148 | |||
149 | /******** 自定义扩展 *****/ | ||
150 | |||
151 | /******** 子对象 *****/ | ||
152 | |||
153 | } |
1 | package com.csbr.qingcloud.domain.vo; | ||
2 | |||
3 | import io.swagger.v3.oas.annotations.media.Schema; | ||
4 | import com.fasterxml.jackson.annotation.JsonFormat; | ||
5 | import lombok.Data; | ||
6 | import java.math.BigDecimal; | ||
7 | import java.util.Date; | ||
8 | |||
9 | /** | ||
10 | * @program: D:/csbr/sjzc/ms-data-circulation-portal-service | ||
11 | * @description: 返回参数 | ||
12 | * @author: xushaobo | ||
13 | * @create: 2024-12-30 16:29 | ||
14 | **/ | ||
15 | @Data | ||
16 | @Schema(title = "返回参数") | ||
17 | public class DemandRSVO { | ||
18 | |||
19 | /** | ||
20 | * 系统唯一标识 | ||
21 | */ | ||
22 | @Schema(description = "系统唯一标识") | ||
23 | private String guid; | ||
24 | |||
25 | /** | ||
26 | * 数据需求名称 | ||
27 | */ | ||
28 | @Schema(description = "数据需求名称") | ||
29 | private String dataDemandName; | ||
30 | |||
31 | /** | ||
32 | * 需求类型 (1 产业端;2 科研端;3 临床端) | ||
33 | */ | ||
34 | @Schema(description = "需求类型 (1 产业端;2 科研端;3 临床端)") | ||
35 | private String requirementType; | ||
36 | |||
37 | /** | ||
38 | * 需求开始时间 | ||
39 | */ | ||
40 | @Schema(description = "需求开始时间") | ||
41 | @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") | ||
42 | private Date requirementTermSdate; | ||
43 | |||
44 | /** | ||
45 | * 需求结束时间 | ||
46 | */ | ||
47 | @Schema(description = "需求结束时间") | ||
48 | @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") | ||
49 | private Date requirementTermEdate; | ||
50 | |||
51 | /** | ||
52 | * 需求内容 | ||
53 | */ | ||
54 | @Schema(description = "需求内容") | ||
55 | private String requirementContent; | ||
56 | |||
57 | /** | ||
58 | * 数据需求字段 数据格式:[{"name":"","path":""},{"name":"","path":""}] | ||
59 | */ | ||
60 | @Schema(description = "数据需求字段 数据格式:[{\"name\":\"\",\"path\":\"\"},{\"name\":\"\",\"path\":\"\"}]") | ||
61 | private String dataDemandFieldAttachJson; | ||
62 | |||
63 | /** | ||
64 | * 期望交付时间 | ||
65 | */ | ||
66 | @Schema(description = "期望交付时间") | ||
67 | private BigDecimal deliveryTime; | ||
68 | |||
69 | /** | ||
70 | * 最低预算 | ||
71 | */ | ||
72 | @Schema(description = "最低预算") | ||
73 | private BigDecimal minBudget; | ||
74 | |||
75 | /** | ||
76 | * 最高预算 | ||
77 | */ | ||
78 | @Schema(description = "最高预算") | ||
79 | private BigDecimal maxBudget; | ||
80 | |||
81 | /** | ||
82 | * 费用来源 | ||
83 | */ | ||
84 | @Schema(description = "费用来源") | ||
85 | private String costSource; | ||
86 | |||
87 | /** | ||
88 | * 更新周期 | ||
89 | */ | ||
90 | @Schema(description = "更新周期") | ||
91 | private String updateCycle; | ||
92 | |||
93 | /** | ||
94 | * 获取路径方式 (1 接口调用;2 文件下载) | ||
95 | */ | ||
96 | @Schema(description = "获取路径方式 (1 接口调用;2 文件下载)") | ||
97 | private String requestType; | ||
98 | |||
99 | /** | ||
100 | * 场景名称 | ||
101 | */ | ||
102 | @Schema(description = "场景名称") | ||
103 | private String sceneName; | ||
104 | |||
105 | /** | ||
106 | * 应用场景描述 | ||
107 | */ | ||
108 | @Schema(description = "应用场景描述") | ||
109 | private String sceneDescription; | ||
110 | |||
111 | /** | ||
112 | * 数据质量要求 | ||
113 | */ | ||
114 | @Schema(description = "数据质量要求") | ||
115 | private String qualityDemand; | ||
116 | |||
117 | /** | ||
118 | * 隐私合规要求 | ||
119 | */ | ||
120 | @Schema(description = "隐私合规要求") | ||
121 | private String privacyDemand; | ||
122 | |||
123 | /** | ||
124 | * 其他补充内容 | ||
125 | */ | ||
126 | @Schema(description = "其他补充内容") | ||
127 | private String otherContent; | ||
128 | |||
129 | /** | ||
130 | * 联系人 | ||
131 | */ | ||
132 | @Schema(description = "联系人") | ||
133 | private String contacts; | ||
134 | |||
135 | /** | ||
136 | * 需求单位 | ||
137 | */ | ||
138 | @Schema(description = "需求单位") | ||
139 | private String requirementUnit; | ||
140 | |||
141 | /** | ||
142 | * 联系方式 | ||
143 | */ | ||
144 | @Schema(description = "联系方式") | ||
145 | private String contactInformation; | ||
146 | |||
147 | /******** 库表存储属性 需处理 *****/ | ||
148 | |||
149 | /******** 自定义扩展 *****/ | ||
150 | |||
151 | /******** 子对象 *****/ | ||
152 | |||
153 | } |
1 | package com.csbr.qingcloud.mybatis.entity; | ||
2 | |||
3 | import csbr.cloud.entity.domain.base.dao.BaseShardingDO; | ||
4 | import jdk.jfr.Name; | ||
5 | import lombok.Data; | ||
6 | import lombok.EqualsAndHashCode; | ||
7 | import lombok.experimental.Accessors; | ||
8 | import java.math.BigDecimal; | ||
9 | import java.util.Date; | ||
10 | |||
11 | /** | ||
12 | * @program: D:/csbr/sjzc/ms-data-circulation-portal-service | ||
13 | * @description: 实体 | ||
14 | * @author: xushaobo | ||
15 | * @create: 2024-12-30 16:26 | ||
16 | **/ | ||
17 | @Data | ||
18 | @EqualsAndHashCode(callSuper = true) | ||
19 | @Accessors(chain = true) | ||
20 | @Name("") | ||
21 | public class MfDemand extends BaseShardingDO { | ||
22 | |||
23 | /** | ||
24 | * 数据需求名称 | ||
25 | */ | ||
26 | @Name("数据需求名称") | ||
27 | private String dataDemandName; | ||
28 | |||
29 | /** | ||
30 | * 需求类型 (1 产业端;2 科研端;3 临床端) | ||
31 | */ | ||
32 | @Name("需求类型 (1 产业端;2 科研端;3 临床端)") | ||
33 | private String requirementType; | ||
34 | |||
35 | /** | ||
36 | * 需求开始时间 | ||
37 | */ | ||
38 | @Name("需求开始时间") | ||
39 | private Date requirementTermSdate; | ||
40 | |||
41 | /** | ||
42 | * 需求结束时间 | ||
43 | */ | ||
44 | @Name("需求结束时间") | ||
45 | private Date requirementTermEdate; | ||
46 | |||
47 | /** | ||
48 | * 需求内容 | ||
49 | */ | ||
50 | @Name("需求内容") | ||
51 | private String requirementContent; | ||
52 | |||
53 | /** | ||
54 | * 数据需求字段 数据格式:[{"name":"","path":""},{"name":"","path":""}] | ||
55 | */ | ||
56 | @Name("数据需求字段 数据格式:[{\"name\":\"\",\"path\":\"\"},{\"name\":\"\",\"path\":\"\"}]") | ||
57 | private String dataDemandFieldAttachJson; | ||
58 | |||
59 | /** | ||
60 | * 期望交付时间 | ||
61 | */ | ||
62 | @Name("期望交付时间") | ||
63 | private BigDecimal deliveryTime; | ||
64 | |||
65 | /** | ||
66 | * 最低预算 | ||
67 | */ | ||
68 | @Name("最低预算") | ||
69 | private BigDecimal minBudget; | ||
70 | |||
71 | /** | ||
72 | * 最高预算 | ||
73 | */ | ||
74 | @Name("最高预算") | ||
75 | private BigDecimal maxBudget; | ||
76 | |||
77 | /** | ||
78 | * 费用来源 | ||
79 | */ | ||
80 | @Name("费用来源") | ||
81 | private String costSource; | ||
82 | |||
83 | /** | ||
84 | * 更新周期 | ||
85 | */ | ||
86 | @Name("更新周期") | ||
87 | private String updateCycle; | ||
88 | |||
89 | /** | ||
90 | * 获取路径方式 (1 接口调用;2 文件下载) | ||
91 | */ | ||
92 | @Name("获取路径方式 (1 接口调用;2 文件下载)") | ||
93 | private String requestType; | ||
94 | |||
95 | /** | ||
96 | * 场景名称 | ||
97 | */ | ||
98 | @Name("场景名称") | ||
99 | private String sceneName; | ||
100 | |||
101 | /** | ||
102 | * 应用场景描述 | ||
103 | */ | ||
104 | @Name("应用场景描述") | ||
105 | private String sceneDescription; | ||
106 | |||
107 | /** | ||
108 | * 数据质量要求 | ||
109 | */ | ||
110 | @Name("数据质量要求") | ||
111 | private String qualityDemand; | ||
112 | |||
113 | /** | ||
114 | * 隐私合规要求 | ||
115 | */ | ||
116 | @Name("隐私合规要求") | ||
117 | private String privacyDemand; | ||
118 | |||
119 | /** | ||
120 | * 其他补充内容 | ||
121 | */ | ||
122 | @Name("其他补充内容") | ||
123 | private String otherContent; | ||
124 | |||
125 | /** | ||
126 | * 联系人 | ||
127 | */ | ||
128 | @Name("联系人") | ||
129 | private String contacts; | ||
130 | |||
131 | /** | ||
132 | * 需求单位 | ||
133 | */ | ||
134 | @Name("需求单位") | ||
135 | private String requirementUnit; | ||
136 | |||
137 | /** | ||
138 | * 联系方式 | ||
139 | */ | ||
140 | @Name("联系方式") | ||
141 | private String contactInformation; | ||
142 | |||
143 | } |
1 | package com.csbr.qingcloud.mybatis.mapper; | ||
2 | |||
3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; | ||
4 | import org.apache.ibatis.annotations.Mapper; | ||
5 | import com.csbr.qingcloud.mybatis.entity.MfDemand; | ||
6 | |||
7 | /** | ||
8 | * @program: D:/csbr/sjzc/ms-data-circulation-portal-service | ||
9 | * @description: Mapper 接口 | ||
10 | * @author: xushaobo | ||
11 | * @create: 2024-12-30 16:29 | ||
12 | **/ | ||
13 | @Mapper | ||
14 | public interface MfDemandMapper extends BaseMapper<MfDemand> { | ||
15 | |||
16 | } |
1 | package com.csbr.qingcloud.mybatis.service; | ||
2 | |||
3 | import com.csbr.cloud.base.service.CsbrService; | ||
4 | import com.csbr.qingcloud.mybatis.entity.MfDemand; | ||
5 | |||
6 | /** | ||
7 | * @program: D:/csbr/sjzc/ms-data-circulation-portal-service | ||
8 | * @description: 逻辑层接口 | ||
9 | * @author: xushaobo | ||
10 | * @create: 2024-12-30 16:29 | ||
11 | **/ | ||
12 | public interface MfDemandService extends CsbrService<MfDemand> { | ||
13 | |||
14 | } |
1 | package com.csbr.qingcloud.mybatis.service.impl; | ||
2 | |||
3 | import com.csbr.cloud.mybatis.service.impl.CsbrServiceImpl; | ||
4 | import com.csbr.qingcloud.mybatis.mapper.MfDemandMapper; | ||
5 | import com.csbr.qingcloud.mybatis.entity.MfDemand; | ||
6 | import com.csbr.qingcloud.mybatis.service.MfDemandService; | ||
7 | import jakarta.annotation.Resource; | ||
8 | import org.springframework.stereotype.Service; | ||
9 | |||
10 | /** | ||
11 | * @program: D:/csbr/sjzc/ms-data-circulation-portal-service | ||
12 | * @description: 逻辑层接口实现 | ||
13 | * @author: xushaobo | ||
14 | * @create: 2024-12-30 16:29 | ||
15 | **/ | ||
16 | @Service | ||
17 | public class MfDemandServiceImpl extends CsbrServiceImpl<MfDemandMapper, MfDemand> implements MfDemandService { | ||
18 | |||
19 | @Resource | ||
20 | private MfDemandMapper mfDemandMapper; | ||
21 | |||
22 | } |
1 | package com.csbr.qingcloud.service; | ||
2 | |||
3 | import csbr.cloud.entity.domain.base.vo.PageListVO; | ||
4 | import com.csbr.qingcloud.domain.vo.DemandQueryVO; | ||
5 | import com.csbr.qingcloud.domain.vo.DemandRQVO; | ||
6 | import com.csbr.qingcloud.domain.vo.DemandRSVO; | ||
7 | |||
8 | import java.util.List; | ||
9 | |||
10 | /** | ||
11 | * @program: D:/csbr/sjzc/ms-data-circulation-portal-service | ||
12 | * @description: 业务逻辑接口 | ||
13 | * @author: xushaobo | ||
14 | * @create: 2024-12-30 16:31 | ||
15 | **/ | ||
16 | public interface DemandService { | ||
17 | |||
18 | /** | ||
19 | * 分页查询 | ||
20 | * @author xushaobo | ||
21 | * @date 2024-12-30 16:31 | ||
22 | * @param queryVO | ||
23 | * @return com.csbr.cloud.mybatis.entity.PageListVO<com.csbr.qingcloud.domain.vo.DemandRSVO> | ||
24 | */ | ||
25 | PageListVO<DemandRSVO> pageList(DemandQueryVO queryVO); | ||
26 | |||
27 | /** | ||
28 | * 获取详情数据 | ||
29 | * @author xushaobo | ||
30 | * @date 2024-12-30 16:31 | ||
31 | * @param guid | ||
32 | * @return com.csbr.qingcloud.domain.vo.DemandRSVO | ||
33 | */ | ||
34 | DemandRSVO getDemandDetail(String guid); | ||
35 | |||
36 | /** | ||
37 | * 数据新增 | ||
38 | * @author xushaobo | ||
39 | * @date 2024-12-30 16:31 | ||
40 | * @param rqVO | ||
41 | * @return boolean | ||
42 | */ | ||
43 | void saveDemand(DemandRQVO rqVO); | ||
44 | |||
45 | /** | ||
46 | * 数据修改 | ||
47 | * @author xushaobo | ||
48 | * @date 2024-12-30 16:31 | ||
49 | * @param rqVO | ||
50 | * @return boolean | ||
51 | */ | ||
52 | void updateDemand(DemandRQVO rqVO); | ||
53 | |||
54 | /** | ||
55 | * 数据删除 | ||
56 | * @author xushaobo | ||
57 | * @date 2024-12-30 16:31 | ||
58 | * @param guids | ||
59 | * @return void | ||
60 | */ | ||
61 | void removeByGuids(List<String> guids); | ||
62 | |||
63 | /** | ||
64 | * 数据删除、并有相关的处理操作 | ||
65 | * @author xushaobo | ||
66 | * @date 2024-12-30 16:31 | ||
67 | * @param guids | ||
68 | * @return void | ||
69 | */ | ||
70 | void removeHandleByGuids(List<String> guids); | ||
71 | |||
72 | } |
1 | package com.csbr.qingcloud.service.impl; | ||
2 | |||
3 | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | ||
4 | import com.csbr.cloud.common.enums.SystemError; | ||
5 | import com.csbr.cloud.common.exception.CsbrSystemException; | ||
6 | import com.csbr.cloud.common.util.CommonUtil; | ||
7 | import com.csbr.cloud.common.util.CsbrBeanUtil; | ||
8 | import com.csbr.cloud.common.util.MessageSourceUtil; | ||
9 | import csbr.cloud.entity.domain.base.vo.PageListVO; | ||
10 | import com.csbr.qingcloud.domain.vo.DemandQueryVO; | ||
11 | import com.csbr.qingcloud.domain.vo.DemandRQVO; | ||
12 | import com.csbr.qingcloud.domain.vo.DemandRSVO; | ||
13 | import com.csbr.qingcloud.mybatis.entity.MfDemand; | ||
14 | import com.csbr.qingcloud.mybatis.service.MfDemandService; | ||
15 | import com.csbr.qingcloud.service.DemandService; | ||
16 | import jakarta.annotation.Resource; | ||
17 | import lombok.extern.slf4j.Slf4j; | ||
18 | import org.apache.commons.collections.CollectionUtils; | ||
19 | import org.apache.commons.lang3.StringUtils; | ||
20 | import org.springframework.stereotype.Service; | ||
21 | import org.springframework.transaction.annotation.Transactional; | ||
22 | |||
23 | import java.util.ArrayList; | ||
24 | import java.util.Collections; | ||
25 | import java.util.List; | ||
26 | |||
27 | /** | ||
28 | * @program: D:/csbr/sjzc/ms-data-circulation-portal-service | ||
29 | * @description: 业务逻辑实现 | ||
30 | * @author: xushaobo | ||
31 | * @create: 2024-12-30 16:30 | ||
32 | **/ | ||
33 | @Slf4j | ||
34 | @Service | ||
35 | public class DemandServiceImpl implements DemandService { | ||
36 | |||
37 | /** | ||
38 | * 功能名称 | ||
39 | */ | ||
40 | private static final String FUNCTION_NAME = ""; | ||
41 | |||
42 | @Resource | ||
43 | private MfDemandService mfDemandService; | ||
44 | |||
45 | @Resource | ||
46 | private CsbrBeanUtil csbrBeanUtil; | ||
47 | |||
48 | @Resource | ||
49 | private MessageSourceUtil messageSourceUtil; | ||
50 | |||
51 | /** | ||
52 | * 分页查询 | ||
53 | * @author xushaobo | ||
54 | * @date 2024-12-30 16:30 | ||
55 | * @param queryVO | ||
56 | * @return com.csbr.cloud.mybatis.entity.PageListVO<com.csbr.qingcloud.domain.vo.DemandRSVO> | ||
57 | */ | ||
58 | @Override | ||
59 | public PageListVO<DemandRSVO> pageList(DemandQueryVO queryVO) { | ||
60 | beforeQuery(queryVO); | ||
61 | LambdaQueryWrapper<MfDemand> queryWrapper = mfDemandService.csbrQueryWrapper(queryVO, MfDemand.class); | ||
62 | queryWrapper.orderByDesc(MfDemand::getCreateTime); | ||
63 | PageListVO<MfDemand> pageList = mfDemandService.csbrPageList(queryVO, queryWrapper); | ||
64 | PageListVO<DemandRSVO> rsPageList = csbrBeanUtil.convert(pageList, PageListVO.class); | ||
65 | afterQuery(pageList, rsPageList); | ||
66 | return rsPageList; | ||
67 | } | ||
68 | |||
69 | /** | ||
70 | * 获取详情数据 | ||
71 | * @author xushaobo | ||
72 | * @date 2024-12-30 16:30 | ||
73 | * @param guid | ||
74 | * @return com.csbr.qingcloud.domain.vo.DemandRSVO | ||
75 | */ | ||
76 | @Override | ||
77 | public DemandRSVO getDemandDetail(String guid) { | ||
78 | if (StringUtils.isBlank(guid)) { | ||
79 | // W00012 = {0}:参数[{1}]不能为空! | ||
80 | throw new CsbrSystemException(SystemError.DATA_INPUT_ERROR, messageSourceUtil.getMessage("W00010", | ||
81 | String.format("获取%s详情数据", FUNCTION_NAME), "数据唯一标识")); | ||
82 | } | ||
83 | MfDemand entity = mfDemandService.getById(guid); | ||
84 | if (entity == null) { | ||
85 | throw new CsbrSystemException(SystemError.DATA_NOT_EXISTS, messageSourceUtil.notExistsToSelectMessage(String.format("获取%s详情数据", FUNCTION_NAME))); | ||
86 | } | ||
87 | return convertToVO(entity); | ||
88 | } | ||
89 | |||
90 | /** | ||
91 | * 数据新增 | ||
92 | * @author xushaobo | ||
93 | * @date 2024-12-30 16:30 | ||
94 | * @param rqVO | ||
95 | * @return boolean | ||
96 | */ | ||
97 | @Transactional(rollbackFor = Exception.class) | ||
98 | @Override | ||
99 | public void saveDemand(DemandRQVO rqVO) { | ||
100 | beforeSave(rqVO); | ||
101 | MfDemand entity = convertToEntity(rqVO); | ||
102 | boolean flag = mfDemandService.save(entity); | ||
103 | if (!flag) { | ||
104 | throw new CsbrSystemException(SystemError.DATA_ADD_ERROR, messageSourceUtil.addMessage(FUNCTION_NAME)); | ||
105 | } | ||
106 | afterSave(rqVO, entity); | ||
107 | } | ||
108 | |||
109 | /** | ||
110 | * 数据修改 | ||
111 | * @author xushaobo | ||
112 | * @date 2024-12-30 16:30 | ||
113 | * @param rqVO | ||
114 | * @return boolean | ||
115 | */ | ||
116 | @Transactional(rollbackFor = Exception.class) | ||
117 | @Override | ||
118 | public void updateDemand(DemandRQVO rqVO) { | ||
119 | beforeUpdate(rqVO); | ||
120 | // 将修改前数据查出来缓存下来,传入到修改后方法中,用于一些特殊逻辑处理,如某个值变化才进行 | ||
121 | // MfDemand oldEntity = mfDemandService.getById(rqVO.getGuid()); | ||
122 | MfDemand entity = convertToEntity(rqVO); | ||
123 | boolean flag = mfDemandService.updateById(entity); | ||
124 | if (!flag) { | ||
125 | throw new CsbrSystemException(SystemError.DATA_UPDATE_ERROR, messageSourceUtil.updateMessage(FUNCTION_NAME)); | ||
126 | } | ||
127 | afterUpdate(rqVO, entity); | ||
128 | } | ||
129 | |||
130 | /** | ||
131 | * 数据删除 | ||
132 | * @author xushaobo | ||
133 | * @date 2024-12-30 16:30 | ||
134 | * @param guids | ||
135 | * @return void | ||
136 | */ | ||
137 | @Transactional(rollbackFor = Exception.class) | ||
138 | @Override | ||
139 | public void removeByGuids(List<String> guids) { | ||
140 | if (CollectionUtils.isEmpty(guids)) { | ||
141 | // W00012 = {0}:参数[{1}]不能为空! | ||
142 | throw new CsbrSystemException(SystemError.DATA_INPUT_ERROR, messageSourceUtil.getMessage("W00012", | ||
143 | String.format("删除%s数据", FUNCTION_NAME), "数据唯一标识")); | ||
144 | } | ||
145 | if (!mfDemandService.isExistsData(guids, MfDemand.class)) { | ||
146 | throw new CsbrSystemException(SystemError.DATA_DEL_ERROR, messageSourceUtil.notExistsToDelMessage(FUNCTION_NAME)); | ||
147 | } | ||
148 | boolean flag = mfDemandService.csbrDeleteData(guids, MfDemand.class); | ||
149 | if (!flag) { | ||
150 | throw new CsbrSystemException(SystemError.DATA_DEL_ERROR, messageSourceUtil.delMessage(FUNCTION_NAME)); | ||
151 | } | ||
152 | } | ||
153 | |||
154 | /** | ||
155 | * 数据删除、并有相关的处理操作 | ||
156 | * @author xushaobo | ||
157 | * @date 2024-12-30 16:30 | ||
158 | * @param guids | ||
159 | * @return void | ||
160 | */ | ||
161 | @Transactional(rollbackFor = Exception.class) | ||
162 | @Override | ||
163 | public void removeHandleByGuids(List<String> guids) { | ||
164 | if (CollectionUtils.isEmpty(guids)) { | ||
165 | // W00012 = {0}:参数[{1}]不能为空! | ||
166 | throw new CsbrSystemException(SystemError.DATA_INPUT_ERROR, messageSourceUtil.getMessage("W00012", | ||
167 | String.format("删除%s数据", FUNCTION_NAME), "数据唯一标识")); | ||
168 | } | ||
169 | for (String guid : guids) { | ||
170 | MfDemand entity = mfDemandService.getById(guid); | ||
171 | beforeRemove(entity); | ||
172 | boolean flag = mfDemandService.removeById(guid); | ||
173 | if (!flag) { | ||
174 | throw new CsbrSystemException(SystemError.DATA_DEL_ERROR, messageSourceUtil.delMessage(FUNCTION_NAME)); | ||
175 | } | ||
176 | afterRemove(entity); | ||
177 | } | ||
178 | } | ||
179 | |||
180 | /** | ||
181 | * 新新增前置处理 | ||
182 | * @author xushaobo | ||
183 | * @date 2024-12-30 16:30 | ||
184 | * @param rqVO | ||
185 | * @return void | ||
186 | */ | ||
187 | private void beforeSave(DemandRQVO rqVO) { | ||
188 | //region 1.输入基础验证 | ||
189 | //endregion | ||
190 | |||
191 | //region 2.数据验证特殊处理 | ||
192 | //region 2.1.业务合规性验证 | ||
193 | //endregion 2.1.业务合规性验证 | ||
194 | |||
195 | //region 2.2.业务数据验证 | ||
196 | //endregion 2.2.业务数据验证 | ||
197 | |||
198 | //endregion 2.数据验证特殊处理 | ||
199 | |||
200 | //region 3.数据转换处理 | ||
201 | |||
202 | //region 3.1.数据过程转换 | ||
203 | //endregion 3.1.数据过程转换 | ||
204 | |||
205 | //endregion 3.数据转换处理 | ||
206 | |||
207 | //region 4.数据过滤与补充处理 | ||
208 | |||
209 | //endregion 4.数据过滤与补充处理 | ||
210 | |||
211 | //region 5.过程处理 | ||
212 | |||
213 | //region 5.1.计算逻辑处理 | ||
214 | //endregion 5.1.计算逻辑处理 | ||
215 | |||
216 | //region 5.2.业务逻辑处理 | ||
217 | //endregion 5.2.业务逻辑处理 | ||
218 | |||
219 | //endregion 5.过程处理 | ||
220 | } | ||
221 | |||
222 | /** | ||
223 | * 新增后置处理 | ||
224 | * @author xushaobo | ||
225 | * @date 2024-12-30 16:30 | ||
226 | * @param rqVO | ||
227 | * @param entity | ||
228 | * @return void | ||
229 | */ | ||
230 | private void afterSave(DemandRQVO rqVO, MfDemand entity) { | ||
231 | //region 1.输出特殊转换 | ||
232 | |||
233 | //region 1.1.输出过滤与补充处理 | ||
234 | //endregion 1.1.输出过滤与补充处理 | ||
235 | |||
236 | //endregion 1.输出特殊转换 | ||
237 | } | ||
238 | |||
239 | /** | ||
240 | * 修改前置校验、处理 | ||
241 | * @author xushaobo | ||
242 | * @date 2024-12-30 16:30 | ||
243 | * @param rqVO | ||
244 | * @return void | ||
245 | */ | ||
246 | private void beforeUpdate(DemandRQVO rqVO) { | ||
247 | //region 1.输入基础验证 | ||
248 | if (StringUtils.isBlank(rqVO.getGuid())) { | ||
249 | // W00012 = {0}:参数[{1}]不能为空! | ||
250 | throw new CsbrSystemException(SystemError.DATA_INPUT_ERROR, messageSourceUtil.getMessage("W00010", String.format("修改%s数据",FUNCTION_NAME), "数据唯一标识")); | ||
251 | } | ||
252 | //endregion | ||
253 | |||
254 | //region 2.数据验证特殊处理 | ||
255 | //region 2.1.业务合规性验证 | ||
256 | //endregion 2.1.业务合规性验证 | ||
257 | |||
258 | //region 2.2.业务数据验证 | ||
259 | if (!mfDemandService.isExistsData(Collections.singletonList(rqVO.getGuid()), MfDemand.class)) { | ||
260 | throw new CsbrSystemException(SystemError.DATA_DEL_ERROR, messageSourceUtil.notExistsToUpdateMessage(FUNCTION_NAME)); | ||
261 | } | ||
262 | //endregion 2.2.业务数据验证 | ||
263 | |||
264 | //endregion 2.数据验证特殊处理 | ||
265 | |||
266 | //region 3.数据转换处理 | ||
267 | |||
268 | //region 3.1.数据过程转换 | ||
269 | //endregion 3.1.数据过程转换 | ||
270 | |||
271 | //endregion 3.数据转换处理 | ||
272 | |||
273 | //region 4.数据过滤与补充处理 | ||
274 | //endregion 4.数据过滤与补充处理 | ||
275 | |||
276 | //region 5.过程处理 | ||
277 | |||
278 | //region 5.1.计算逻辑处理 | ||
279 | //endregion 5.1.计算逻辑处理 | ||
280 | |||
281 | //region 5.2.业务逻辑处理 | ||
282 | //endregion 5.2.业务逻辑处理 | ||
283 | |||
284 | //endregion 5.过程处理 | ||
285 | } | ||
286 | |||
287 | /** | ||
288 | * 修改后置处理 | ||
289 | * @author xushaobo | ||
290 | * @date 2024-12-30 16:30 | ||
291 | * @param rqVO | ||
292 | * @param entity | ||
293 | * @return void | ||
294 | */ | ||
295 | protected void afterUpdate(DemandRQVO rqVO, MfDemand entity) { | ||
296 | //region 1.输出特殊转换 | ||
297 | |||
298 | //region 1.1.输出过滤与补充处理 | ||
299 | //endregion 1.1.输出过滤与补充处理 | ||
300 | |||
301 | //endregion 1.输出特殊转换 | ||
302 | } | ||
303 | |||
304 | |||
305 | /** | ||
306 | * 删除前置处理 | ||
307 | * @author xushaobo | ||
308 | * @date 2024-12-30 16:30 | ||
309 | * @param entity | ||
310 | * @return void | ||
311 | */ | ||
312 | private void beforeRemove(MfDemand entity) { | ||
313 | if (entity == null) { | ||
314 | throw new CsbrSystemException(SystemError.DATA_DEL_ERROR, messageSourceUtil.notExistsToDelMessage(FUNCTION_NAME)); | ||
315 | } | ||
316 | } | ||
317 | |||
318 | /** | ||
319 | * 删除后置处理 | ||
320 | * @author xushaobo | ||
321 | * @date 2024-12-30 16:30 | ||
322 | * @param entity | ||
323 | * @return void | ||
324 | */ | ||
325 | private void afterRemove(MfDemand entity) { | ||
326 | |||
327 | } | ||
328 | |||
329 | /** | ||
330 | * 查询方法前置验证、处理 | ||
331 | * @author xushaobo | ||
332 | * @date 2024-12-30 16:30 | ||
333 | * @param rqQueryVO | ||
334 | * @return void | ||
335 | */ | ||
336 | private void beforeQuery(DemandQueryVO rqQueryVO) { | ||
337 | |||
338 | } | ||
339 | |||
340 | /** | ||
341 | * 查询方法后置数据转换、处理 | ||
342 | * @author xushaobo | ||
343 | * @date 2024-12-30 16:30 | ||
344 | * @param pageList 数据库查询数据 | ||
345 | * @param rsPageList 返回的最终数据 | ||
346 | * @return void | ||
347 | */ | ||
348 | private void afterQuery(PageListVO<MfDemand> pageList, PageListVO<DemandRSVO> rsPageList) { | ||
349 | if (CollectionUtils.isNotEmpty(pageList.getRecords())) { | ||
350 | rsPageList.setRecords(convertToVO(pageList.getRecords())); | ||
351 | } | ||
352 | // 需要特殊处理数据时使用 | ||
353 | /*if(CollectionUtils.isNotEmpty(pageList.getRecords())){ | ||
354 | List<DemandRSVO> results = new ArrayList<>(); | ||
355 | for (MfDemand item : pageList.getRecords()){ | ||
356 | DemandRSVO vo = convertToVO(item); | ||
357 | results.add(vo); | ||
358 | } | ||
359 | rsPageList.setRecords(results); | ||
360 | }*/ | ||
361 | } | ||
362 | |||
363 | //region 辅助操作 | ||
364 | |||
365 | /** | ||
366 | * 实体数据转换为视图对象数据(多个) | ||
367 | * @author xushaobo | ||
368 | * @date 2024-12-30 16:30 | ||
369 | * @param entityList 实体数据列表 | ||
370 | * @return java.util.List<com.csbr.qingcloud.domain.vo.DemandRSVO> 视图对象列表 | ||
371 | */ | ||
372 | private List<DemandRSVO> convertToVO(List<MfDemand> entityList) { | ||
373 | if (CollectionUtils.isEmpty(entityList)) { | ||
374 | // W00012 = {0}:参数[{1}]不能为空! | ||
375 | throw new CsbrSystemException(SystemError.DATA_INPUT_ERROR, messageSourceUtil.getMessage("W00012", | ||
376 | "实体数据转换为视图对象实体数据", "实体数据")); | ||
377 | } | ||
378 | List<DemandRSVO> voList = new ArrayList<>(entityList.size()); | ||
379 | for (MfDemand item : entityList) { | ||
380 | DemandRSVO vo = convertToVO(item); | ||
381 | voList.add(vo); | ||
382 | } | ||
383 | return voList; | ||
384 | } | ||
385 | |||
386 | /** | ||
387 | * 实体数据转换为视图对象数据 | ||
388 | * @author xushaobo | ||
389 | * @date 2024-12-30 16:30 | ||
390 | * @param entity | ||
391 | * @return com.csbr.qingcloud.domain.vo.DemandRSVO | ||
392 | */ | ||
393 | private DemandRSVO convertToVO(MfDemand entity) { | ||
394 | DemandRSVO vo = csbrBeanUtil.convert(entity, DemandRSVO.class); | ||
395 | return vo; | ||
396 | } | ||
397 | |||
398 | /** | ||
399 | * 新增、修改和其他情况的参数转换为实体 | ||
400 | * @author xushaobo | ||
401 | * @date 2024-12-30 16:30 | ||
402 | * @param vo | ||
403 | * @return com.csbr.qingcloud.mybatis.entity.MfDemand | ||
404 | */ | ||
405 | private MfDemand convertToEntity(DemandRQVO vo) { | ||
406 | MfDemand entity = csbrBeanUtil.convert(vo, MfDemand.class); | ||
407 | // 新增时数据默认guid赋值,转换后该guid可能别使用 | ||
408 | if (StringUtils.isBlank(vo.getGuid())) { | ||
409 | entity.setGuid(CommonUtil.newGuid()); | ||
410 | } | ||
411 | return entity; | ||
412 | } | ||
413 | |||
414 | //endregion | ||
415 | |||
416 | } |
-
Please register or sign in to post a comment