diff --git a/blockchain-common/blockchain-common-base/src/main/java/com/blockchain/common/base/constant/BaseConstant.java b/blockchain-common/blockchain-common-base/src/main/java/com/blockchain/common/base/constant/BaseConstant.java index 0b851e6..daaf69d 100644 --- a/blockchain-common/blockchain-common-base/src/main/java/com/blockchain/common/base/constant/BaseConstant.java +++ b/blockchain-common/blockchain-common-base/src/main/java/com/blockchain/common/base/constant/BaseConstant.java @@ -17,5 +17,6 @@ public class BaseConstant { public static final int REQUEST_SUCCESS = 200;// 成功标识 public static final String YYYF_TOKEN_HEADER = "X-Requested-YyyfToken";//yyyfToken - + + public static final String USER_ID_YYYF_USER_KEY= "userIdYyyfUserKey";//通过当前用户id与以渔有方用户关联key } diff --git a/blockchain-common/blockchain-common-base/src/main/java/com/blockchain/common/base/util/SSOHelper.java b/blockchain-common/blockchain-common-base/src/main/java/com/blockchain/common/base/util/SSOHelper.java index 3c1be68..aa19290 100644 --- a/blockchain-common/blockchain-common-base/src/main/java/com/blockchain/common/base/util/SSOHelper.java +++ b/blockchain-common/blockchain-common-base/src/main/java/com/blockchain/common/base/util/SSOHelper.java @@ -113,6 +113,10 @@ public class SSOHelper { } if (redisTemplate.hasKey(key)) { redisTemplate.delete(key); + String userIdYyyfUserKey = BaseConstant.USER_ID_YYYF_USER_KEY.concat(user.getId()); + if (redisTemplate.hasKey(key)) { + redisTemplate.delete(userIdYyyfUserKey); + } } } } diff --git a/blockchain-common/blockchain-common-base/src/main/java/com/blockchain/common/base/util/YyyfUserDtoUtils.java b/blockchain-common/blockchain-common-base/src/main/java/com/blockchain/common/base/util/YyyfUserDtoUtils.java index 6be1326..c70cf07 100644 --- a/blockchain-common/blockchain-common-base/src/main/java/com/blockchain/common/base/util/YyyfUserDtoUtils.java +++ b/blockchain-common/blockchain-common-base/src/main/java/com/blockchain/common/base/util/YyyfUserDtoUtils.java @@ -1,5 +1,6 @@ package com.blockchain.common.base.util; +import com.aliyuncs.utils.StringUtils; import com.blockchain.common.base.constant.BaseConstant; import com.blockchain.common.base.dto.YyyfUserDto; import org.springframework.data.redis.core.RedisTemplate; @@ -31,4 +32,24 @@ public class YyyfUserDtoUtils { } return yyyfUserDto; } + + + /** + * @description 通过userId获取以渔有方用户信息 + * @author huan.xu + * @date 2020-05-20 15:42:47 + * @param [userId, redisTemplate] + * @return com.blockchain.common.base.dto.YyyfUserDto + **/ + public static YyyfUserDto getYyyfUserDtoByUserId(String userId, RedisTemplate redisTemplate) { + YyyfUserDto yyyfUserDto = null; + if(StringUtils.isNotEmpty(userId)) { + //如果有token,拿到用户信息,与以渔有方进行绑定 + String key=BaseConstant.USER_ID_YYYF_USER_KEY.concat(userId); + if (redisTemplate.hasKey(key)) { + yyyfUserDto = (YyyfUserDto) redisTemplate.opsForValue().get(key); + } + } + return yyyfUserDto; + } } \ No newline at end of file diff --git a/blockchain-server/blockchain-server-user/src/main/java/com/blockchain/server/user/controller/LoginController.java b/blockchain-server/blockchain-server-user/src/main/java/com/blockchain/server/user/controller/LoginController.java index 18dceff..31e417c 100644 --- a/blockchain-server/blockchain-server-user/src/main/java/com/blockchain/server/user/controller/LoginController.java +++ b/blockchain-server/blockchain-server-user/src/main/java/com/blockchain/server/user/controller/LoginController.java @@ -324,7 +324,6 @@ public class LoginController { **/ private Integer dealBindYyyfAccount(String userId, String tel, HttpServletRequest request) { Integer yyyfUserId = null; - String yyyfTtoken = request.getHeader(BaseConstant.YYYF_TOKEN_HEADER); YyyfUserDto yyyfUserDto = YyyfUserDtoUtils.getYyyfUserDto(request, redisTemplate); //如果有token,拿到用户信息,与以渔有方进行绑定 if (yyyfUserDto != null) { @@ -332,12 +331,14 @@ public class LoginController { YyyfUser yyyfUser = this.yyyfUserService.selectByYyyfUserIdAndTel(yyyfUserId, tel); if (yyyfUser == null) { this.yyyfUserService.saveUser(yyyfUserId, userId, yyyfUserDto.getUserName()); - this.redisTemplate.delete(yyyfTtoken); + // this.redisTemplate.delete(yyyfTtoken); } else { if (!yyyfUser.getUserId().equals(userId)) { throw new UserException(UserEnums.USER_NOT_FORBID_OTHER_USER); } } + //通过当前用户id与以渔有方用户关联 + redisTemplate.opsForValue().set(BaseConstant.USER_ID_YYYF_USER_KEY.concat(userId),yyyfUserDto); } else { throw new UserException(UserEnums.USER_NOT_BIND_YYYF); } diff --git a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/TeachingGradeController.java b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/TeachingGradeController.java index 5c88bbc..cd12e89 100644 --- a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/TeachingGradeController.java +++ b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/TeachingGradeController.java @@ -284,6 +284,7 @@ public class TeachingGradeController { public ResultDTO getExamDetails(@ApiParam(TeachingGradeApi.GetExamDetails.METHOD_ASSESSUSER_ID)@RequestParam("assessUserId") String assessUserId, @ApiParam(TeachingGradeApi.GetExamDetails.METHOD_IS_FIRST)@RequestParam("isFirst") int isFirst) { ExamDetailsDto examDetailsDto = new ExamDetailsDto(); + examDetailsDto.setIsFirst(isFirst); try { if (isFirst != 0) { AssessUser assessUser = this.assessUserService.selectById(assessUserId); diff --git a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/dto/ExamDetailsDto.java b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/dto/ExamDetailsDto.java index dfdd4bb..c1040d3 100644 --- a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/dto/ExamDetailsDto.java +++ b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/dto/ExamDetailsDto.java @@ -29,4 +29,7 @@ public class ExamDetailsDto implements Serializable { private Double totalScore; @ApiModelProperty("学生答题指标集合") private List assessUserTargetList; + @ApiModelProperty("是否是第一个答题记录") + private Integer isFirst; + } \ No newline at end of file diff --git a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/dto/YyyfLoginDto.java b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/dto/YyyfLoginDto.java index fef5e1b..c398a4a 100644 --- a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/dto/YyyfLoginDto.java +++ b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/dto/YyyfLoginDto.java @@ -17,8 +17,8 @@ public class YyyfLoginDto implements Serializable { @ApiModelProperty("状态:0,失败,1成功,2 考试提交后重复进入,3 练习未提交提醒") private int status; - @ApiModelProperty("练习重新开始参数封装") - private PractiseTipDto practiseTipDto; + /*@ApiModelProperty("练习重新开始参数封装") + private PractiseTipDto practiseTipDto;*/ @ApiModelProperty("以渔有方用户token") private String yyyfUserToken; diff --git a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/mapper/AssessUserMapper.java b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/mapper/AssessUserMapper.java index db0cb65..29b62b4 100644 --- a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/mapper/AssessUserMapper.java +++ b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/mapper/AssessUserMapper.java @@ -2,7 +2,6 @@ package com.blockchain.server.yyyf.mapper; import com.blockchain.server.yyyf.dto.AssessUserDto; -import com.blockchain.server.yyyf.dto.PractiseProDto; import com.blockchain.server.yyyf.entity.AssessUser; import org.apache.ibatis.annotations.Param; import org.springframework.stereotype.Repository; diff --git a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/AssessUserService.java b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/AssessUserService.java index ed6f1a5..974ba1f 100644 --- a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/AssessUserService.java +++ b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/AssessUserService.java @@ -1,12 +1,9 @@ package com.blockchain.server.yyyf.service; - import com.blockchain.server.train.dto.TrainCaseTargetDto; import com.blockchain.server.yyyf.dto.AssessUserDto; -import com.blockchain.server.yyyf.dto.PractiseProDto; import com.blockchain.server.yyyf.entity.AssessUser; -import com.blockchain.server.yyyf.entity.AssessUserTarget; import java.util.List; diff --git a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/impl/AssessUserServiceImpl.java b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/impl/AssessUserServiceImpl.java index 53829ad..ecfa677 100644 --- a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/impl/AssessUserServiceImpl.java +++ b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/impl/AssessUserServiceImpl.java @@ -13,6 +13,7 @@ import com.blockchain.server.yyyf.mapper.AssessUserMapper; import com.blockchain.server.yyyf.mapper.AssessUserTargetMapper; import com.blockchain.server.yyyf.service.AssessUserService; import com.blockchain.server.yyyf.utils.HttpClientUtil; +import com.blockchain.server.yyyf.utils.IdGenerator; import lombok.SneakyThrows; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -100,6 +101,7 @@ public class AssessUserServiceImpl implements AssessUserService { assessUserTarget.setTargetName(trainCaseTargetDto.getName()); assessUserTarget.setSort(j++); assessUserTarget.setAnswer(1); + assessUserTarget.setId(IdGenerator.uuid()); list.add(assessUserTarget); } this.assessUserMapper.insert(assessUser);