From 255354547add82190a03787e59aa1f6cb84d1c41 Mon Sep 17 00:00:00 2001 From: anthonywj Date: Wed, 31 May 2023 16:30:02 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9A=82=E6=97=B6=E5=8E=BB=E6=8E=89=E5=AE=A2?= =?UTF-8?q?=E6=88=B7=E7=AB=AF=E6=8E=A5=E5=8F=A3=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/glxp/api/aspect/AuthorizeAspect.java | 47 +++++++++++-------- .../com/glxp/api/common/enums/ResultEnum.java | 1 + .../controller/trace/TraceTaskController.java | 22 ++++++--- .../api/req/trace/TraceDlTaskRequest.java | 9 ++++ .../api/res/trace/TraceTaskDlResponse.java | 7 ++- 5 files changed, 57 insertions(+), 29 deletions(-) create mode 100644 src/main/java/com/glxp/api/req/trace/TraceDlTaskRequest.java diff --git a/src/main/java/com/glxp/api/aspect/AuthorizeAspect.java b/src/main/java/com/glxp/api/aspect/AuthorizeAspect.java index c4f1b6e..768484d 100644 --- a/src/main/java/com/glxp/api/aspect/AuthorizeAspect.java +++ b/src/main/java/com/glxp/api/aspect/AuthorizeAspect.java @@ -51,17 +51,11 @@ public class AuthorizeAspect { } HttpServletRequest request = attributes.getRequest(); - String id = request.getHeader("ADMIN_ID"); - if (StrUtil.isBlank(id)) { - String apiKey = request.getHeader("api_key"); - String secretKey = request.getHeader("secret_key"); - AuthLicense authLicense = authLicenseDao.get(apiKey); - if (authLicense != null && authLicense.getSecretKey().equals(secretKey)) { - } else { - throw new JsonException(ResultEnum.LOGIN_VERIFY_FALL); - } - } else { + String clientType = request.getHeader("CLIENT_TYPE"); + if (clientType == null || clientType.equals("locWeb")) { + //系统用户登录权限验证 + String id = request.getHeader("ADMIN_ID"); String query = request.getQueryString(); Long adminId = null; try { @@ -69,7 +63,6 @@ public class AuthorizeAspect { } catch (Exception e) { throw new JsonException(ResultEnum.LOGIN_VERIFY_FALL); } - String token = request.getHeader("ADMIN_TOKEN"); if (token == null) { throw new JsonException(ResultEnum.LOGIN_VERIFY_FALL); @@ -84,17 +77,33 @@ public class AuthorizeAspect { if (adminId.compareTo(jwtAdminId) != 0) { throw new JsonException(ResultEnum.LOGIN_VERIFY_FALL); } + } else if (clientType.equals("third")) { + //其他第三方接口权限验证 + String apiKey = request.getHeader("api_key"); + String secretKey = request.getHeader("secret_key"); + AuthLicense authLicense = authLicenseDao.get(apiKey); + if (authLicense != null && authLicense.getSecretKey().equals(secretKey)) { + + } else { + throw new JsonException(ResultEnum.LOGIN_VERIFY_FALL); + } + } else if (clientType.equals("pcClient")) { + //客户端权限验证 todo +// +// MethodSignature signature = (MethodSignature) joinPoint.getSignature(); +// Method method = signature.getMethod(); +// AuthRuleAnnotation action = method.getAnnotation(AuthRuleAnnotation.class); +// comnpanyRuleVerify(action.value(), adminId); + + } else { + throw new JsonException(ResultEnum.UN_SOURCE_CLIENT); } - // 判断是否进行权限验证 - MethodSignature signature = (MethodSignature) joinPoint.getSignature(); - //从切面中获取当前方法 - Method method = signature.getMethod(); - //得到了方,提取出他的注解 - AuthRuleAnnotation action = method.getAnnotation(AuthRuleAnnotation.class); - // 进行权限验证 -// authRuleVerify(action.value(), adminId); + } + // 企业接口授权验证 + public void comnpanyRuleVerify(String valuem, Long companyId) { + } } diff --git a/src/main/java/com/glxp/api/common/enums/ResultEnum.java b/src/main/java/com/glxp/api/common/enums/ResultEnum.java index 7889eef..7d3f6cd 100644 --- a/src/main/java/com/glxp/api/common/enums/ResultEnum.java +++ b/src/main/java/com/glxp/api/common/enums/ResultEnum.java @@ -11,6 +11,7 @@ public enum ResultEnum { SUCCESS(0, "success"), NOT_NETWORK(1, "系统繁忙,请稍后再试。"), LOGIN_VERIFY_FALL(2, "登录失效"), + UN_SOURCE_CLIENT(2, "不明请求来源"), PARAM_VERIFY_FALL(3, "参数验证错误"), AUTH_FAILED(4, "权限验证失败"), DATA_NOT(5, "没有相关数据"), diff --git a/src/main/java/com/glxp/api/controller/trace/TraceTaskController.java b/src/main/java/com/glxp/api/controller/trace/TraceTaskController.java index 88f93f9..28eef81 100644 --- a/src/main/java/com/glxp/api/controller/trace/TraceTaskController.java +++ b/src/main/java/com/glxp/api/controller/trace/TraceTaskController.java @@ -4,11 +4,14 @@ import com.github.pagehelper.PageInfo; import com.glxp.api.annotation.AuthRuleAnnotation; import com.glxp.api.common.res.BaseResponse; import com.glxp.api.common.util.ResultVOUtils; +import com.glxp.api.entity.trace.TraceTaskNoticeEntity; +import com.glxp.api.req.trace.TraceDlTaskRequest; import com.glxp.api.req.trace.TraceTaskDetailRequest; import com.glxp.api.res.PageSimpleResponse; import com.glxp.api.res.trace.TraceTaskDlResponse; import com.glxp.api.service.trace.TraceTaskService; import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.BeanUtils; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; import springfox.documentation.annotations.ApiIgnore; @@ -30,7 +33,7 @@ public class TraceTaskController { TraceTaskService traceTaskService; -//任务列表 + //任务列表 @AuthRuleAnnotation("udi/trace/task/filter") @GetMapping("udi/trace/task/filter") public BaseResponse filterTask(TraceTaskDetailRequest traceTaskDetailRequest) { @@ -44,12 +47,19 @@ public class TraceTaskController { } + //客户端下载追溯任务列表执行下载任务 + @AuthRuleAnnotation("udi/trace/task/search") + @GetMapping("udi/trace/task/search") + public BaseResponse downloadTask(TraceDlTaskRequest taskRequest) { - - - - - + TraceTaskNoticeEntity taskNoticeEntity = traceTaskService.getById(taskRequest.getTaskId()); + if (taskNoticeEntity == null) { + return ResultVOUtils.error(500, "任务已过期或任务不存在!"); + } + TraceTaskDlResponse taskDlResponse = new TraceTaskDlResponse(); + BeanUtils.copyProperties(taskNoticeEntity, taskDlResponse); + return ResultVOUtils.success(taskDlResponse); + } } diff --git a/src/main/java/com/glxp/api/req/trace/TraceDlTaskRequest.java b/src/main/java/com/glxp/api/req/trace/TraceDlTaskRequest.java new file mode 100644 index 0000000..e1b978a --- /dev/null +++ b/src/main/java/com/glxp/api/req/trace/TraceDlTaskRequest.java @@ -0,0 +1,9 @@ +package com.glxp.api.req.trace; + +import lombok.Data; + +@Data +public class TraceDlTaskRequest { + + private Long taskId; +} diff --git a/src/main/java/com/glxp/api/res/trace/TraceTaskDlResponse.java b/src/main/java/com/glxp/api/res/trace/TraceTaskDlResponse.java index d824913..2f9125b 100644 --- a/src/main/java/com/glxp/api/res/trace/TraceTaskDlResponse.java +++ b/src/main/java/com/glxp/api/res/trace/TraceTaskDlResponse.java @@ -10,7 +10,6 @@ import java.util.List; */ @Data public class TraceTaskDlResponse { - private Long id; /** * 按UDI码查询出入库信息 */ @@ -19,7 +18,7 @@ public class TraceTaskDlResponse { /** * 查询记录表ID外键 */ - private Long recordCode; + private Long produdctRecordIdFk; /** * 任务类型 1:关联关系;2:入库;3:出库 @@ -29,10 +28,10 @@ public class TraceTaskDlResponse { * 任务状态(未处理/正在处理(任务被下载)/ * 已处理(任务已提交) */ - private Integer status; + private Integer status; /** * DI标识列表,多级包装会有多个DI - * DI标识数组,逗号隔开 + * DI标识数组,逗号隔开 */ private List diList;