diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..b1e3f8f --- /dev/null +++ b/pom.xml @@ -0,0 +1,166 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 2.2.7.RELEASE + + + com.xdap + self_development + 1.0-SNAPSHOT + self_development + 自开发后端 + + + + dcloud-public + https://registry.dfy.definesys.cn/repository/maven-public/ + + + + + 1.8 + 2.9.2-01 + 2.4.3-01 + 4.0.7-rc + apaas-1.1.18.4-RELEASE + 1.18.12 + 2.0.0 + + + + + cn.hutool + hutool-all + 5.7.15 + + + com.xdap + runtime + ${papaas.version} + + + com.definesys.mpaas + query-mongodb + + + com.xdap + xdap-plugins-common + + + com.xdap + common + + + + + org.projectlombok + lombok + 1.18.12 + true + + + + com.definesys.mpaas + query-mongodb + ${mpaas.version} + + + com.xdap + xdap-plugins-common + ${plugins.version} + + + + + com.fasterxml.jackson.core + jackson-core + 2.14.0-rc1 + + + com.xdap + common + ${papaas.version} + + + + + single + + + + org.springframework.boot + spring-boot-maven-plugin + + + maven-compiler-plugin + 3.6.0 + + 1.8 + 1.8 + UTF-8 + groovy-eclipse-compiler + true + + + + lombok.launch.Agent + + true + + + + org.codehaus.groovy + groovy-eclipse-compiler + ${groovy.eclipse.compiler.version} + + + + org.codehaus.groovy + groovy-eclipse-batch + ${groovy.eclipse.batch.version} + + + org.codehaus.plexus + plexus-compiler-api + 2.8.1 + + + org.projectlombok + lombok + ${lombok.version} + + + + + + + src/main/resources + + **/application.properties + **/*.yml + + + + + + + lib + + + + src/main/resources + + **/*.properties + **/*.yml + + + + + + + \ No newline at end of file diff --git a/src/main/java/com/xdap/self_development/MainApplication.java b/src/main/java/com/xdap/self_development/MainApplication.java new file mode 100644 index 0000000..0244593 --- /dev/null +++ b/src/main/java/com/xdap/self_development/MainApplication.java @@ -0,0 +1,21 @@ +package com.xdap.self_development; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.autoconfigure.mongo.embedded.EmbeddedMongoAutoConfiguration; +import org.springframework.cloud.openfeign.EnableFeignClients; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.scheduling.annotation.EnableScheduling; +import org.springframework.transaction.annotation.EnableTransactionManagement; + +@SpringBootApplication( + exclude = {EmbeddedMongoAutoConfiguration.class} +) +@EnableTransactionManagement +@EnableScheduling +@ComponentScan(basePackages = {"com.definesys.mpaas", "com.xdap.*"}) +public class MainApplication { + public static void main(String[] args) { + SpringApplication.run(MainApplication.class, args); + } +} diff --git a/src/main/java/com/xdap/self_development/config/BusinessDatabase.java b/src/main/java/com/xdap/self_development/config/BusinessDatabase.java new file mode 100644 index 0000000..863e2e7 --- /dev/null +++ b/src/main/java/com/xdap/self_development/config/BusinessDatabase.java @@ -0,0 +1,19 @@ +package com.xdap.self_development.config; + +import com.definesys.mpaas.query.MpaasQuery; +import com.definesys.mpaas.query.MpaasQueryFactory; +import org.springframework.context.annotation.Bean; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; + +@Component +public class BusinessDatabase { + @Resource + private MpaasQueryFactory queryFactory; + + @Bean + public MpaasQuery getBusinessDatabase() { + return queryFactory.buildFromDatasource("xdap_app_223770822127386625"); + } +} diff --git a/src/main/java/com/xdap/self_development/config/CorsConfig.java b/src/main/java/com/xdap/self_development/config/CorsConfig.java new file mode 100644 index 0000000..f075dfe --- /dev/null +++ b/src/main/java/com/xdap/self_development/config/CorsConfig.java @@ -0,0 +1,16 @@ +package com.xdap.self_development.config; + +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.CorsRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +@Configuration +public class CorsConfig implements WebMvcConfigurer { + @Override + public void addCorsMappings(CorsRegistry registry) { + registry.addMapping("/**") + .allowedOrigins("*") + .allowedMethods("GET", "POST", "PUT", "DELETE") + .allowedHeaders("*"); + } +} diff --git a/src/main/java/com/xdap/self_development/config/CustomAllowUrlConfig.java b/src/main/java/com/xdap/self_development/config/CustomAllowUrlConfig.java new file mode 100644 index 0000000..47a0632 --- /dev/null +++ b/src/main/java/com/xdap/self_development/config/CustomAllowUrlConfig.java @@ -0,0 +1,17 @@ +package com.xdap.self_development.config; + +import com.xdap.api.moudle.custom.AllowUrlManage; +import org.springframework.stereotype.Component; + +import java.util.HashSet; +import java.util.Set; + +@Component +public class CustomAllowUrlConfig implements AllowUrlManage { + @Override + public Set getCustomAllowUrls() { + Set urlSet = new HashSet<>(); + urlSet.add("/custom/*"); + return urlSet; + } +} \ No newline at end of file diff --git a/src/main/java/com/xdap/self_development/controller/BenchmarkingReportController.java b/src/main/java/com/xdap/self_development/controller/BenchmarkingReportController.java new file mode 100644 index 0000000..ff86e5a --- /dev/null +++ b/src/main/java/com/xdap/self_development/controller/BenchmarkingReportController.java @@ -0,0 +1,90 @@ +package com.xdap.self_development.controller; + +import com.definesys.mpaas.common.exception.MpaasBusinessException; +import com.definesys.mpaas.common.http.Response; +import com.xdap.self_development.controller.form.BenchmarkingReportPageForm; +import com.xdap.self_development.controller.form.HandleApprovalRequest; +import com.xdap.self_development.controller.form.SaveBenchmarkingReportForm; +import com.xdap.self_development.pojo.BenchmarkingReport; +import com.xdap.self_development.pojo.view.ApprovalFlowView; +import com.xdap.self_development.pojo.view.TodoAndReportView; +import com.xdap.self_development.service.BenchmarkingReportService; +import org.springframework.validation.BindingResult; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import javax.validation.Valid; +import javax.validation.constraints.NotBlank; +import java.util.List; + +@RestController +@RequestMapping("/custom/benchmark") +public class BenchmarkingReportController { + @Resource + private BenchmarkingReportService benchmarkingReportService; + + // 新增对标报告并发起审批 + @PostMapping("/startReportApproval") + public Response startReportApproval( + @Valid @RequestBody SaveBenchmarkingReportForm form, + BindingResult bindingResult + ) { + if (bindingResult.hasErrors()) { + bindingResult.getFieldErrors().forEach(error -> { + throw new MpaasBusinessException(error.getDefaultMessage()); + }); + } + benchmarkingReportService.saveBenchmarkingReport(form); + return Response.ok().setMessage("保存成功"); + } + + // 筛选对标报告及待办 + @PostMapping("/getReportAndTodoByCondition") + public Response getBenchmarkingReportByCondition( + @Valid @RequestBody BenchmarkingReportPageForm form, + BindingResult bindingResult + ) { + if (bindingResult.hasErrors()) { + bindingResult.getFieldErrors().forEach(error -> { + throw new MpaasBusinessException(error.getDefaultMessage()); + }); + } + List list = benchmarkingReportService + .getBenchmarkingReportByCondition(form); + return Response.ok().data(list); + } + + // 处理审批 + @PostMapping("/handleReportApproval") + public Response handleReportApproval( + @RequestBody @Valid HandleApprovalRequest request, + BindingResult bindingResult + ) { + if (bindingResult.hasErrors()) { + bindingResult.getFieldErrors().forEach(error -> { + throw new MpaasBusinessException(error.getDefaultMessage()); + }); + } + benchmarkingReportService.handleReportApproval(request); + return Response.ok().setMessage("处理成功"); + } + + // 查看对标报告详情 + @GetMapping("/getReportDetail") + public Response getReportDetail( + @NotBlank String reportId + ) { + BenchmarkingReport report = benchmarkingReportService + .getReportDetail(reportId); + return Response.ok().data(report); + } + + // 获取审批流程 + @GetMapping("/getReportProcess") + public Response getReportProcess( + @NotBlank String flowId + ) { + ApprovalFlowView approvalFlowView = benchmarkingReportService.getReportProcess(flowId); + return Response.ok().data(approvalFlowView); + } +} diff --git a/src/main/java/com/xdap/self_development/controller/DeleteController.java b/src/main/java/com/xdap/self_development/controller/DeleteController.java new file mode 100644 index 0000000..6a095b7 --- /dev/null +++ b/src/main/java/com/xdap/self_development/controller/DeleteController.java @@ -0,0 +1,171 @@ +package com.xdap.self_development.controller; + +import com.definesys.mpaas.common.http.Response; +import com.xdap.api.moudle.user.vo.LoginUserVo; +import com.xdap.runtime.service.RuntimeAppContextService; +import com.xdap.runtime.service.RuntimeUserService; +import com.xdap.self_development.config.BusinessDatabase; +import com.xdap.self_development.feign.ApaasMyTokenFeign; +import com.xdap.self_development.feign.dto.AppTokenDTO; +import com.xdap.self_development.pojo.*; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +@RestController +@RequestMapping("/custom/delete") +public class DeleteController { + @Resource + private BusinessDatabase bd; + @Resource + private RuntimeAppContextService runtimeAppContextService; + @Resource + private RuntimeUserService runtimeUserService; + @Autowired + private ApaasMyTokenFeign apaasMyTokenFeign; + + @GetMapping("/loginVo") + public Response loginVo(@RequestParam String userId) { + Map map = new HashMap<>(); + AppTokenDTO token = apaasMyTokenFeign.token( + "client_credentials", + "2b5b3de8-e7fd-406a-a59a-d5568457b1f4", + "94bddc6a-27a4-4204-885b-b075812ec535" + ); + map.put("token", token); + return Response.ok().data(map); + } + + @GetMapping("getAll") + public Response getAll() { + List