lyhzzz 2 年之前
父节点
当前提交
2197e5589d

+ 3 - 5
src/main/java/com/fdkankan/fusion/controller/TmProjectController.java

@@ -55,13 +55,11 @@ public class TmProjectController {
 
     /**
      * 获取临时密码
-     * @param projectId 项目id
-     * @param roteUrl 路由
+     * @param caseId 项目id
      */
     @GetMapping("/getRandCode")
-    public ResultData getRandCode( @RequestParam(required = false) String projectId,
-                                   @RequestParam(required = false) String roteUrl) {
-        return ResultData.ok(tmProjectService.getRandCode(projectId,roteUrl));
+    public ResultData getRandCode( @RequestParam(required = false) String caseId) {
+        return ResultData.ok(tmProjectService.getRandCode(caseId));
     }
 
     @PostMapping(value = "/updateRandomCode")

+ 1 - 1
src/main/java/com/fdkankan/fusion/request/ProjectRandCodeDto.java

@@ -10,7 +10,7 @@ import java.io.Serializable;
 public class ProjectRandCodeDto implements Serializable {
 
     //@ApiModelProperty(value = "火调项目ID")
-    private String projectId;
+    private String caseId;
 
     //@ApiModelProperty(value = "访问密码")
     private String randCode;

+ 1 - 2
src/main/java/com/fdkankan/fusion/request/ProjectRequest.java

@@ -9,7 +9,6 @@ import lombok.Data;
 @Data
 public class ProjectRequest extends RequestBase {
 
-    private String projectId;
+    private String caseId;
     private String randCode;
-    private int type =1;
 }

+ 0 - 1
src/main/java/com/fdkankan/fusion/response/ProjectRandCodeVo.java

@@ -9,5 +9,4 @@ import lombok.NoArgsConstructor;
 @AllArgsConstructor
 public class ProjectRandCodeVo {
     private String randCode;
-    private String roteUrl;
 }

+ 1 - 1
src/main/java/com/fdkankan/fusion/service/ITmProjectService.java

@@ -25,7 +25,7 @@ public interface ITmProjectService extends IService<TmProject> {
 
     Object getDetailWithoutAuth(ProjectRequest param);
 
-    Object getRandCode(String projectId,String roteUrl);
+    Object getRandCode(String caseId);
 
     void updateRandomCode(ProjectRandCodeDto projectRandCodeDto);
 

+ 17 - 35
src/main/java/com/fdkankan/fusion/service/impl/TmProjectServiceImpl.java

@@ -135,66 +135,51 @@ public class TmProjectServiceImpl extends ServiceImpl<ITmProjectMapper, TmProjec
 
     @Override
     public Object getDetailWithoutAuth(ProjectRequest param) {
-        if (ObjectUtil.isNotNull(param.getProjectId()) && StringUtils.isBlank(param.getProjectId())) {
+        if (ObjectUtil.isNotNull(param.getCaseId()) && StringUtils.isBlank(param.getRandCode())) {
             throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
         }
-        String redisKey = String.format(RedisKeyUtil.RAND_CODE_KEY,param.getProjectId());
-        if (param.getType()==1){
-            if(!redisUtil.hasKey(redisKey)){
-                throw new BusinessException(ResultCode.PROJECT_KEY_NOT_EXITS);
-            }
-            if (StringUtils.isBlank(param.getRandCode())) {
-                throw new BusinessException(ResultCode.PROJECT_PASSWORD_NOT_EXITS);
-            }
-            String redisRandCode =  redisUtil.get(redisKey);
-            if(!StringUtils.equals(redisRandCode , param.getRandCode())){
-                throw new BusinessException(ResultCode.PROJECT_PASSWORD_ERROR);
-            }
+        String redisKey = String.format(RedisKeyUtil.RAND_CODE_KEY,param.getCaseId());
+        if(!redisUtil.hasKey(redisKey)){
+            throw new BusinessException(ResultCode.PROJECT_KEY_NOT_EXITS);
         }
-        TmProject tmProject = this.getById(param.getProjectId());
-        if(null == tmProject){
-            throw new BusinessException(ResultCode.PROJECT_NOT_EXITS);
+        if (StringUtils.isBlank(param.getRandCode())) {
+            throw new BusinessException(ResultCode.PROJECT_PASSWORD_NOT_EXITS);
         }
-        CaseEntity caseEntity = caseService.getByTmProjectId(tmProject.getId());
-        if(caseEntity != null){
-            tmProject.setCaseId(caseEntity.getCaseId());
+        String redisRandCode =  redisUtil.get(redisKey);
+        if(!StringUtils.equals(redisRandCode , param.getRandCode())){
+            throw new BusinessException(ResultCode.PROJECT_PASSWORD_ERROR);
         }
-        return tmProject;
+        return true;
     }
 
     @Override
-    public Object getRandCode(String projectId,String roteUrl) {
-        if(StringUtils.isBlank(projectId) || StringUtils.isBlank(roteUrl)){
+    public Object getRandCode(String caseId) {
+        if(StringUtils.isBlank(caseId) ){
             throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
         }
-        try {
-            roteUrl = URLEncoder.encode(roteUrl,"UTF-8");
-        }catch (Exception e){
-            throw new BusinessException(ResultCode.ROTE_ERROR);
-        }
-        String redisKey = String.format(RedisKeyUtil.RAND_CODE_KEY,projectId);
+        String redisKey = String.format(RedisKeyUtil.RAND_CODE_KEY,caseId);
         if(redisUtil.hasKey(redisKey)){
             redisUtil.expire(redisKey,RedisKeyUtil.projectRandCodeKeyTime);
             return redisUtil.get(redisKey);
         }
-        TmProject tmProject = this.getById(projectId);
+        TmProject tmProject = this.getById(caseId);
         if(tmProject ==null){
             throw new BusinessException(ResultCode.PROJECT_NOT_EXITS);
         }
-        ProjectRandCodeVo vo = new ProjectRandCodeVo(RandomUtil.randomString(4),roteUrl);
+        ProjectRandCodeVo vo = new ProjectRandCodeVo(RandomUtil.randomString(4));
         redisUtil.set(redisKey, JSONObject.toJSONString(vo));
         return vo;
     }
 
     @Override
     public void updateRandomCode(ProjectRandCodeDto projectRandCodeDto) {
-        if(StringUtils.isBlank(projectRandCodeDto.getProjectId()) || StringUtils.isBlank(projectRandCodeDto.getRandCode())){
+        if(StringUtils.isBlank(projectRandCodeDto.getCaseId()) || StringUtils.isBlank(projectRandCodeDto.getRandCode())){
             throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
         }
         if(!projectRandCodeDto.getRandCode().matches(PatternEnum.RAND_CODE_PATTERN)){
             throw new BusinessException(ResultCode.RAND_ERROR);
         }
-        String redisKey = String.format(RedisKeyUtil.RAND_CODE_KEY,projectRandCodeDto.getProjectId());
+        String redisKey = String.format(RedisKeyUtil.RAND_CODE_KEY,projectRandCodeDto.getCaseId());
         if(!redisUtil.hasKey(redisKey)){
             throw new BusinessException(ResultCode.RAND_NOT_EXIST);
         }
@@ -202,9 +187,6 @@ public class TmProjectServiceImpl extends ServiceImpl<ITmProjectMapper, TmProjec
         String value = redisUtil.get(redisKey);
         ProjectRandCodeVo projectRandCodeVo = JSONObject.parseObject(value, ProjectRandCodeVo.class);
         projectRandCodeVo.setRandCode(projectRandCodeDto.getRandCode());
-        if(StringUtils.isNotBlank(projectRandCodeDto.getRoteUrl())){
-            projectRandCodeVo.setRoteUrl(projectRandCodeDto.getRoteUrl());
-        }
         redisUtil.set(redisKey,JSONObject.toJSONString(projectRandCodeVo),RedisKeyUtil.projectRandCodeKeyTime);
     }