|
@@ -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);
|
|
|
}
|
|
|
|