From d34317e812e95c1ce131231711cb62b5ebfdf753 Mon Sep 17 00:00:00 2001 From: PoffyZhang <99775271@qq.com> Date: Fri, 5 May 2023 17:37:23 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E5=B7=B2=E5=A4=84=E7=90=86=20=E5=8A=A0task?= =?UTF-8?q?Id?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pmapi/provincial/model/res/SjApiResponse.java | 120 +++++++++++++++++++++ .../IJoinReviewProvincialBureauService.java | 4 +- .../JoinReviewProvincialBureauServiceImpl.java | 7 +- 3 files changed, 126 insertions(+), 5 deletions(-) create mode 100644 pmapi/src/main/java/com/ningdatech/pmapi/provincial/model/res/SjApiResponse.java diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/provincial/model/res/SjApiResponse.java b/pmapi/src/main/java/com/ningdatech/pmapi/provincial/model/res/SjApiResponse.java new file mode 100644 index 0000000..8aaac45 --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/provincial/model/res/SjApiResponse.java @@ -0,0 +1,120 @@ +package com.ningdatech.pmapi.provincial.model.res; + +import com.ningdatech.basic.enumeration.Status; +import com.ningdatech.basic.model.ApiStatus; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + *

+ * ApiResponse - 省局统一的接口返回值封装 + *

+ * + * @author ZPF + * @since 14:29 2022/9/29 + */ +@Data +@NoArgsConstructor +public class SjApiResponse implements Serializable { + private static final long serialVersionUID = 532384723325394156L; + + public static final int SUCCESS_CODE = 200; + + public static final String SUCCESS_MSG = "success"; + + public static final int ERROR_CODE = 500; + + public static final String ERROR_MSG = "Internal server error"; + + /** + * 状态码 + */ + private Integer code; + + /** + * 返回内容 + */ + private String msg; + + /** + * 返回数据 + */ + private T data; + + /** + * 全参构造函数 + * + * @param code 状态码 + * @param msg 返回内容 + * @param data 返回数据 + */ + private SjApiResponse(Integer code, String msg, T data) { + this.code = code; + this.msg = msg; + this.data = data; + } + + /** + * 构造一个自定义的API返回 + * + * @param code 状态码 + * @param msg 返回内容 + * @param data 返回数据 + * @return ApiResponse + */ + public static SjApiResponse of(Integer code, String msg, T data) { + return new SjApiResponse(code, msg, data); + } + + /** + * 构造一个成功且不带数据的API返回 + * + * @return ApiResponse + */ + public static SjApiResponse ofSuccess() { + return ofSuccess(null); + } + + /** + * 构造一个成功且带数据的API返回 + * + * @param data 返回数据 + * @return ApiResponse + */ + public static SjApiResponse ofSuccess(T data) { + return ofStatus(Status.OK, data); + } + + /** + * 构造一个成功且自定义消息的API返回 + * + * @param msg 返回内容 + * @return ApiResponse + */ + public static SjApiResponse ofMessage(String msg) { + return of(Status.OK.getCode(), msg, null); + } + + /** + * 构造一个有状态的API返回 + * + * @param status 状态 {@link Status} + * @return ApiResponse + */ + public static SjApiResponse ofStatus(ApiStatus status) { + return ofStatus(status, null); + } + + /** + * 构造一个有状态且带数据的API返回 + * + * @param status 状态 {@link Status} + * @param data 返回数据 + * @return ApiResponse + */ + public static SjApiResponse ofStatus(ApiStatus status, T data) { + return of(status.getCode(), status.getReasonPhrase(), data); + } +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/provincial/service/IJoinReviewProvincialBureauService.java b/pmapi/src/main/java/com/ningdatech/pmapi/provincial/service/IJoinReviewProvincialBureauService.java index 32a5999..91732b8 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/provincial/service/IJoinReviewProvincialBureauService.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/provincial/service/IJoinReviewProvincialBureauService.java @@ -1,7 +1,7 @@ package com.ningdatech.pmapi.provincial.service; -import com.ningdatech.basic.model.ApiResponse; import com.ningdatech.pmapi.provincial.model.dto.ProvincialProjectDTO; +import com.ningdatech.pmapi.provincial.model.res.SjApiResponse; /** * @Classname JointReviewProvincialBureauService @@ -22,5 +22,5 @@ public interface IJoinReviewProvincialBureauService { * 查看 本区域 省局联审 的项目审核详情 * @return */ - ApiResponse processInfo(String projectId); + SjApiResponse processInfo(String projectId); } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/provincial/service/impl/JoinReviewProvincialBureauServiceImpl.java b/pmapi/src/main/java/com/ningdatech/pmapi/provincial/service/impl/JoinReviewProvincialBureauServiceImpl.java index d5be163..8a7e762 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/provincial/service/impl/JoinReviewProvincialBureauServiceImpl.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/provincial/service/impl/JoinReviewProvincialBureauServiceImpl.java @@ -8,6 +8,7 @@ import com.ningdatech.basic.model.ApiResponse; import com.ningdatech.pmapi.common.config.ProvincialProperties; import com.ningdatech.pmapi.provincial.model.dto.ProvincialProjectDTO; import com.ningdatech.pmapi.provincial.model.res.ProvincialProjectRes; +import com.ningdatech.pmapi.provincial.model.res.SjApiResponse; import com.ningdatech.pmapi.provincial.service.IJoinReviewProvincialBureauService; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; @@ -80,13 +81,13 @@ public class JoinReviewProvincialBureauServiceImpl implements IJoinReviewProvinc * @return */ @Override - public ApiResponse processInfo(String projectId) { + public SjApiResponse processInfo(String projectId) { Long timeStamp = System.currentTimeMillis()/1000; String url = provincialProperties.getHost() + provincialProperties.getDetailUrl() + "?timestamp=" + timeStamp; log.info("省局获取审核详情 url {}",url); - ResponseEntity responseEntity = null; + ResponseEntity responseEntity = null; String signature = getSha256(timeStamp,provincialProperties.getDetailUrl(), HttpMethod.POST.name()); @@ -104,7 +105,7 @@ public class JoinReviewProvincialBureauServiceImpl implements IJoinReviewProvinc .body(jsonBaby); //也可以是DTO try { - responseEntity = restTemplate.exchange(requestEntity,ApiResponse.class); + responseEntity = restTemplate.exchange(requestEntity,SjApiResponse.class); log.info("获取审批详情 响应 :{}",responseEntity); } catch (Exception e) { log.error("[省局获取审核详情] http request error", e); From 6218f8dc2e2fb24c2ed982ea5583c7e2941f627d Mon Sep 17 00:00:00 2001 From: PoffyZhang <99775271@qq.com> Date: Fri, 5 May 2023 17:38:23 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E5=B7=B2=E5=A4=84=E7=90=86=20=E5=8A=A0task?= =?UTF-8?q?Id?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pmapi/scheduler/task/CheckProvincialReviewResultTask.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/scheduler/task/CheckProvincialReviewResultTask.java b/pmapi/src/main/java/com/ningdatech/pmapi/scheduler/task/CheckProvincialReviewResultTask.java index 6306c20..c6d24de 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/scheduler/task/CheckProvincialReviewResultTask.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/scheduler/task/CheckProvincialReviewResultTask.java @@ -4,14 +4,13 @@ import cn.hutool.core.collection.CollUtil; import cn.hutool.http.HttpStatus; import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import com.ningdatech.basic.model.ApiResponse; import com.ningdatech.pmapi.common.statemachine.util.StateMachineUtils; -import com.ningdatech.pmapi.projectdeclared.manage.PrequalificationDeclaredProjectManage; import com.ningdatech.pmapi.projectlib.enumeration.ProjectStatusEnum; import com.ningdatech.pmapi.projectlib.model.entity.Project; import com.ningdatech.pmapi.projectlib.service.IProjectService; import com.ningdatech.pmapi.provincial.enumeration.ProjectProvincialAuditStatusEnum; import com.ningdatech.pmapi.provincial.model.res.ProvincialProjectRes; +import com.ningdatech.pmapi.provincial.model.res.SjApiResponse; import com.ningdatech.pmapi.provincial.service.IJoinReviewProvincialBureauService; import com.ningdatech.pmapi.scheduler.contants.TaskContant; import lombok.RequiredArgsConstructor; @@ -41,8 +40,6 @@ public class CheckProvincialReviewResultTask { private final IProjectService projectService; private final StateMachineUtils stateMachineUtils; - private final PrequalificationDeclaredProjectManage prequalificationDeclaredProjectManage; - @Scheduled(cron = "0 */2 * * * ?") public void statusFlow() throws UnknownHostException { //测试暂时用自己电脑HOST @@ -62,7 +59,7 @@ public class CheckProvincialReviewResultTask { //遍历 for(Project project: projectList){ try{ - ApiResponse apiResponse = reviewProvincialBureauService.processInfo(project.getProjectCode()); + SjApiResponse apiResponse = reviewProvincialBureauService.processInfo(project.getProjectCode()); log.info("项目 【{}】 去获取省局联审结果 :{}",project.getId(),apiResponse); if(Objects.isNull(apiResponse) || !Integer.valueOf(HttpStatus.HTTP_OK).equals(apiResponse.getCode())){ log.info("项目 【{}】 去获取省局联审结果失败",project.getId()); From dcb76231152dff7f10708e2cd01081e44e7c7539 Mon Sep 17 00:00:00 2001 From: PoffyZhang <99775271@qq.com> Date: Fri, 5 May 2023 17:39:34 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E5=B7=B2=E5=A4=84=E7=90=86=20=E5=8A=A0task?= =?UTF-8?q?Id?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ningdatech/pmapi/provincial/controller/TestController.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/provincial/controller/TestController.java b/pmapi/src/main/java/com/ningdatech/pmapi/provincial/controller/TestController.java index bbac2e2..369412c 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/provincial/controller/TestController.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/provincial/controller/TestController.java @@ -1,15 +1,12 @@ package com.ningdatech.pmapi.provincial.controller; -import cn.hutool.core.io.resource.ResourceUtil; -import com.ningdatech.basic.model.ApiResponse; import com.ningdatech.pmapi.projectdeclared.manage.ReviewByProvincialDeptManage; import com.ningdatech.pmapi.projectlib.model.entity.Project; -import com.ningdatech.pmapi.provincial.model.dto.ProvincialProjectDTO; +import com.ningdatech.pmapi.provincial.model.res.SjApiResponse; import com.ningdatech.pmapi.provincial.service.IJoinReviewProvincialBureauService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import javax.validation.Valid; @@ -43,7 +40,7 @@ public class TestController { @GetMapping("/detail") @ApiOperation("测试获取详情") - private ApiResponse detail(@RequestParam String projectId){ + private SjApiResponse detail(@RequestParam String projectId){ return joinReviewProvincialBureauService.processInfo(projectId); } From d7724781676ab540d01f7128f42d2057c4a228f1 Mon Sep 17 00:00:00 2001 From: WendyYang Date: Fri, 5 May 2023 17:51:58 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pmapi/common/helper/impl/UserInfoHelperImpl.java | 3 ++- .../ningdatech/pmapi/user/service/IUserInfoService.java | 2 ++ .../pmapi/user/service/impl/UserInfoServiceImpl.java | 17 ++++++++++++----- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/common/helper/impl/UserInfoHelperImpl.java b/pmapi/src/main/java/com/ningdatech/pmapi/common/helper/impl/UserInfoHelperImpl.java index 2172558..1551e98 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/common/helper/impl/UserInfoHelperImpl.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/common/helper/impl/UserInfoHelperImpl.java @@ -143,7 +143,8 @@ public class UserInfoHelperImpl implements UserInfoHelper { @Override public UserFullInfoDTO getUserFullInfoByEmployeeCode(String employeeCode) { - return getUserFullInfoByEmployeeCode(employeeCode); + UserInfo userInfo = userInfoService.getUserInfoByEmployeeCode(employeeCode); + return getUserFullInfo(userInfo); } @Override diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/user/service/IUserInfoService.java b/pmapi/src/main/java/com/ningdatech/pmapi/user/service/IUserInfoService.java index a5ef005..c285c2c 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/user/service/IUserInfoService.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/user/service/IUserInfoService.java @@ -15,4 +15,6 @@ public interface IUserInfoService extends IService { UserInfo getUserInfoByPhoneNo(String phoneNo); + UserInfo getUserInfoByEmployeeCode(String employeeCode); + } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/user/service/impl/UserInfoServiceImpl.java b/pmapi/src/main/java/com/ningdatech/pmapi/user/service/impl/UserInfoServiceImpl.java index 929cf3c..ba023a4 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/user/service/impl/UserInfoServiceImpl.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/user/service/impl/UserInfoServiceImpl.java @@ -1,5 +1,6 @@ package com.ningdatech.pmapi.user.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ningdatech.pmapi.user.entity.UserInfo; @@ -20,16 +21,22 @@ import org.springframework.stereotype.Service; @Service @RequiredArgsConstructor public class UserInfoServiceImpl extends ServiceImpl implements IUserInfoService { - private final NdUserInfoMapper userInfoMapper; @Override public UserInfo getUserInfoByPhoneNo(String phoneNo) { if (StringUtils.isEmpty(phoneNo)) { return null; } - UserInfo userInfo = userInfoMapper - .selectOne(Wrappers.lambdaQuery(UserInfo.class) - .eq(UserInfo::getMobile, phoneNo)); - return userInfo; + LambdaQueryWrapper query = Wrappers.lambdaQuery(UserInfo.class) + .eq(UserInfo::getMobile, phoneNo); + return getOne(query); } + + @Override + public UserInfo getUserInfoByEmployeeCode(String employeeCode) { + LambdaQueryWrapper query = Wrappers.lambdaQuery(UserInfo.class) + .eq(UserInfo::getEmployeeCode, employeeCode); + return getOne(query); + } + }