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 2539e2e..e57d7d6 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 @@ -273,34 +273,12 @@ public class LoginController { */ private ResultDTO handleAfterLogin(UserMain userMain, String tokenType, HttpServletRequest request) { - - Integer yyyfUserId = null; - String yyyfTtoken = request.getHeader(BaseConstant.YYYF_TOKEN_HEADER); - - //如果有token,拿到用户信息,与以渔有方进行绑定 - if (redisTemplate.hasKey(yyyfTtoken)) { - YyyfUserDto yyyfUserDto = (YyyfUserDto) redisTemplate.opsForValue().get(yyyfTtoken); - yyyfUserId = yyyfUserDto.getId(); - String userId =userMain.getId(); - YyyfUser yyyfUser = this.yyyfUserService.selectByYyyfUserIdAndTel(yyyfUserId, userMain.getMobilePhone()); - if (yyyfUser == null) { - this.yyyfUserService.saveUser(yyyfUserId, userId, yyyfUserDto.getName()); - this.redisTemplate.delete(yyyfTtoken); - }else{ - if(!yyyfUser.getUserId().equals(userMain.getId())){ - throw new UserException(UserEnums.USER_NOT_FORBID_OTHER_USER); - } - } - }else{ - throw new UserException(UserEnums.USER_NOT_BIND_YYYF); - } - + String userId=userMain.getId(); long timestamp = System.currentTimeMillis(); - setUserToRedis(userMain.getId(), userMain.getMobilePhone(), timestamp, tokenType, yyyfUserId); + setUserToRedis(userMain.getId(), userMain.getMobilePhone(), timestamp, tokenType, dealBindYyyfAccount(userId,userMain.getMobilePhone(),request)); String token = generateToken(userMain.getMobilePhone(), timestamp, tokenType); UserBaseDTO userBaseDTO = userMainService.selectUserInfoById(userMain.getId()); userBaseDTO.setToken(token); - return ResultDTO.requstSuccess(userBaseDTO); } @@ -338,4 +316,33 @@ public class LoginController { return ResultDTO.requstSuccess(); } + /** + * @description 处理yyyf账号绑定 + * @param [userId, tel, request] + * @return java.lang.String + **/ + private Integer dealBindYyyfAccount(String userId, String tel, HttpServletRequest request){ + + Integer yyyfUserId = null; + String yyyfTtoken = request.getHeader(BaseConstant.YYYF_TOKEN_HEADER); + + //如果有token,拿到用户信息,与以渔有方进行绑定 + if (redisTemplate.hasKey(yyyfTtoken)) { + YyyfUserDto yyyfUserDto = (YyyfUserDto) redisTemplate.opsForValue().get(yyyfTtoken); + yyyfUserId = yyyfUserDto.getId(); + YyyfUser yyyfUser = this.yyyfUserService.selectByYyyfUserIdAndTel(yyyfUserId, tel); + if (yyyfUser == null) { + this.yyyfUserService.saveUser(yyyfUserId, userId, yyyfUserDto.getName()); + this.redisTemplate.delete(yyyfTtoken); + }else{ + if(!yyyfUser.getUserId().equals(userId)){ + throw new UserException(UserEnums.USER_NOT_FORBID_OTHER_USER); + } + } + }else{ + throw new UserException(UserEnums.USER_NOT_BIND_YYYF); + } + + return yyyfUserId; + } } diff --git a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/LoginController.java b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/LoginController.java index 0cf95d0..28c3c76 100644 --- a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/LoginController.java +++ b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/LoginController.java @@ -5,7 +5,6 @@ import com.blockchain.common.base.dto.ResultDTO; import com.blockchain.common.base.dto.TokenDTO; import com.blockchain.common.base.dto.YyyfUserDto; import com.blockchain.common.base.util.RSACoderUtils; -import com.blockchain.server.train.dto.ExamPaperDto; import com.blockchain.server.yyyf.controller.api.LoginApi; import com.blockchain.server.yyyf.dto.*; import com.blockchain.server.yyyf.service.AssessUserService; @@ -52,6 +51,7 @@ public class LoginController { public ResultDTO loginyyyf(@ApiParam(LoginApi.YyyfLogin.METHOD_API_YYYFLOGINREQUESTVO) @Valid YyyfLoginRequestVo yyyfLoginRequestVo) { //存到redis中用于以渔有方用户与智信链用户进行绑定 + YyyfUserDto yyyfUserDto = new YyyfUserDto(); //登录返回的Data YyyfLoginDto yyyfLoginDto = new YyyfLoginDto(); diff --git a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/StudentAnswerController.java b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/StudentAnswerController.java index 3469072..6219415 100644 --- a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/StudentAnswerController.java +++ b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/StudentAnswerController.java @@ -2,10 +2,13 @@ package com.blockchain.server.yyyf.controller; import com.blockchain.common.base.constant.YyyfConstant; import com.blockchain.common.base.dto.ResultDTO; -import com.blockchain.server.train.dto.ExamPaperDto; import com.blockchain.server.yyyf.controller.api.StudentAnswerApi; -import com.blockchain.server.yyyf.dto.StudentAnswerDto; +import com.blockchain.server.yyyf.dto.AssessUserTargetDto; +import com.blockchain.server.yyyf.entity.AssessUserTarget; +import com.blockchain.server.yyyf.enums.UserEnums; +import com.blockchain.server.yyyf.exceprion.UserException; import com.blockchain.server.yyyf.service.AssessUserService; +import com.blockchain.server.yyyf.service.AssessUserTargetService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; @@ -13,78 +16,62 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.core.RedisTemplate; -import org.springframework.data.redis.core.ValueOperations; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -import java.util.HashMap; import java.util.Map; import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicBoolean; /** * @author huangxl * @data 2019/2/21 15:06 - * 用户注册, 登录控制器 + * 学生成绩控制器 */ @RestController @Api(StudentAnswerApi.CONTROLLER_API) -@RequestMapping("/loginFromYyyf") +@RequestMapping("/studentAnswer") public class StudentAnswerController { private static final Logger LOG = LoggerFactory.getLogger(StudentAnswerController.class); @Autowired private AssessUserService assessUserService; + @Autowired + private AssessUserTargetService assessUserTargetService; @Autowired private RedisTemplate redisTemplate; - @PostMapping("/studentAnswer") - @ApiOperation(value = StudentAnswerApi.StudentAnswer.METHOD_NAME, - notes = StudentAnswerApi.StudentAnswer.METHOD_NOTE) - public ResultDTO studentAnswer(@ApiParam(StudentAnswerApi.StudentAnswer.METHOD_YYYF_USER_ID) @RequestParam(name = "yyyfUserId")String yyyfUserId, - @ApiParam(StudentAnswerApi.StudentAnswer.METHOD_STUDENT_TASK_RATE) @RequestParam(name = "taskRate")String taskRate, - @ApiParam(StudentAnswerApi.StudentAnswer.METHOD_STARGE_ID) @RequestParam(name = "targeId")String targeId) { + @PostMapping("/saveAnswer") + @ApiOperation(value = StudentAnswerApi.SaveAnswer.METHOD_NAME, + notes = StudentAnswerApi.SaveAnswer.METHOD_NOTE) + public ResultDTO saveAnswer(@ApiParam(StudentAnswerApi.SaveAnswer.METHOD_YYYF_USER_ID) @RequestParam(name = "yyyfUserId")Integer yyyfUserId, + @ApiParam(StudentAnswerApi.SaveAnswer.METHOD_STUDENT_TASK_RATE) @RequestParam(name = "taskRate")String taskRate, + @ApiParam(StudentAnswerApi.SaveAnswer.METHOD_STARGE_ID) @RequestParam(name = "targeId")String targeId) { String caseKey = YyyfConstant.CASE_KEY + yyyfUserId; String studentAnswerDtoKey = null; - /* if (redisTemplate.hasKey(caseKey)) { + if (redisTemplate.hasKey(caseKey)) { Map map = (Map) redisTemplate.opsForValue().get(caseKey); String caseId=map.get("examPaperId"); + String examId=map.get("examId"); - studentAnswerDtoKey = YyyfConstant.ANSER_KEY +yyyfUserId + caseId; - ValueOperations studentAnsweValueOperations = redisTemplate.opsForValue(); - StudentAnswerDto studentAnswerDto = (StudentAnswerDto) studentAnsweValueOperations.get(studentAnswerDtoKey); + AssessUserTargetDto assessUserTargetDto= assessUserTargetService.selectAssessUserTargetDtoByUserIdAndIssueIdAndCaseId(yyyfUserId,examId,caseId); - if (studentAnswerDto == null || (studentAnswerDto != null && studentAnswerDto.getTotalScore() != null)) { - return; - } - ExamPaperDto examPaperDto = (ExamPaperDto) redisTemplate.opsForHash().get(YyyfConstant.EXAM_PAPER_KEY, studentAnswerDto.getExamPaperId()); - //交易id - String trxId = studentAnswer.value(); - Map result = studentAnswerDto.getResult(); - if (result == null) { - result = new HashMap<>(); - } - AtomicBoolean flag = new AtomicBoolean(false); - examPaperDto.getTradeList().stream().forEach(bd -> { - if (bd.getId().equals(trxId)) { - flag.set(true); - } - }); - if (flag.get()) { - result.put(trxId, 1); - studentAnswerDto.setResult(result); - studentAnsweValueOperations.set(studentAnswerDtoKey, studentAnswerDto); + if(assessUserTargetDto==null){ + } redisTemplate.expire(caseKey, 2, TimeUnit.HOURS); redisTemplate.expire(studentAnswerDtoKey, 2, TimeUnit.HOURS); - }*/ + + + }else{ + throw new UserException(UserEnums.USER_NOT_BIND_YYYF); + } return new ResultDTO(); } diff --git a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/api/StudentAnswerApi.java b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/api/StudentAnswerApi.java index 4e17d93..e1056a8 100644 --- a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/api/StudentAnswerApi.java +++ b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/api/StudentAnswerApi.java @@ -7,7 +7,7 @@ package com.blockchain.server.yyyf.controller.api; public class StudentAnswerApi { public static final String CONTROLLER_API = "案例答题控制器"; - public static class StudentAnswer { + public static class SaveAnswer { public static final String METHOD_NAME = "学生答题"; public static final String METHOD_NOTE = "学生答题统一调用"; public static final String METHOD_YYYF_USER_ID = "以渔有方用户id"; diff --git a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/dto/AssessUserTargetDto.java b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/dto/AssessUserTargetDto.java new file mode 100644 index 0000000..7374cb8 --- /dev/null +++ b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/dto/AssessUserTargetDto.java @@ -0,0 +1,16 @@ +package com.blockchain.server.yyyf.dto; + +import com.blockchain.server.yyyf.entity.AssessUserTarget; +import lombok.Data; + +/** + * @author huan.xu + * @version 1.0 + * @className AssessUserTargetDto + * @description + * @date 2020-05-13 16:52 + */ +@Data +public class AssessUserTargetDto extends AssessUserTarget { + private String assessUserId; +} \ No newline at end of file diff --git a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/entity/AssessUserProject.java b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/entity/AssessUserProject.java deleted file mode 100644 index f3e4230..0000000 --- a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/entity/AssessUserProject.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.blockchain.server.yyyf.entity; - -import lombok.Data; - -import javax.persistence.Column; -import javax.persistence.Id; -import javax.persistence.Table; -import java.io.Serializable; -import java.math.BigDecimal; -@Table(name = "yyyf_server_assess_user_project") -@Data -public class AssessUserProject implements Serializable { - - private static final long serialVersionUID = 1L; - - /** - * uuid - */ - @Id - @Column(name = "id") - private String id; - /** - * 用户考核主表id - */ - @Column(name = "assess_user_id") - private String assessUserId; - /** - * 子系统项目id - */ - @Column(name = "project_id") - private String projectId; - /** - * 子系统项目名称 - */ - @Column(name = "project_name") - private String projectName; - /** - * 项目得分 - */ - @Column(name = "project_score") - private BigDecimal projectScore; - - @Column(name = "project_case_desc") - private BigDecimal projectCaseDesc; - -} \ No newline at end of file diff --git a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/entity/AssessUserTarget.java b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/entity/AssessUserTarget.java new file mode 100644 index 0000000..a6d6a40 --- /dev/null +++ b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/entity/AssessUserTarget.java @@ -0,0 +1,65 @@ +package com.blockchain.server.yyyf.entity; + +import lombok.Data; + +import javax.persistence.Column; +import javax.persistence.Id; +import javax.persistence.Table; +import java.io.Serializable; + +@Table(name = "yyyf_server_assess_user_target") +@Data +public class AssessUserTarget implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * uuid + */ + @Id + @Column(name = "id") + private String id; + /** + * 用户考核主表id + */ + @Column(name = "assess_user_id") + private String assessUserId; + /** + * 指标id + */ + @Column(name = "targe_id") + private String targeId; + + /** + * 指标名称 + */ + @Column(name = "target_name") + private String targetName; + + /** + * 任务目标运算符:1大于2等于3小于 + */ + @Column(name = "task_operate") + private Integer taskOperate; + /** + * 任务目标比率 + */ + @Column(name = "task_rate") + private Double taskRate; + /** + * 任务分数 + */ + @Column(name = "task_score") + private Double taskScore; + /** + * 指标代码 + */ + @Column(name = "code") + private String code; + + /** + * 排序 + */ + @Column(name = "sort") + private Integer sort; +} \ No newline at end of file diff --git a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/enums/UserEnums.java b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/enums/UserEnums.java new file mode 100644 index 0000000..8173370 --- /dev/null +++ b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/enums/UserEnums.java @@ -0,0 +1,95 @@ +package com.blockchain.server.yyyf.enums; + +/** + * @author huangxl + * @data 2019/2/21 20:53 + */ +public enum UserEnums { + USER_NOT_FORBID_OTHER_USER(1098, "禁止登录他人账号", "The user does not allow login other user's accout", "禁止登錄他人賬號"), + USER_NOT_BIND_YYYF(1099, "该用户未绑定以渔有方或者以渔有方登录已失效", "The user does not bind yyyf", "該用戶未綁定以漁有方或者以漁有方登錄已失效"), + USER_EXISTS(1100, "该用户已存在", "The user already exists", "該用戶已存在"), + USER_NOT_EXISTS(1101, "不存在该用户", "The user does not exist", "不存在該用戶"), + LOGIN_PASSWORD_ERROR(1102, "用户名密码错误", "Wrong username and password", "用戶名密碼錯誤"), + LOGIN_FORBIDDEN(1103, "你被列入黑名单,禁止登录", "You are blacklisted from logging in", "你被列入黑名單,禁止登錄"), + SMS_VERIFY_FAIL(1104, "手机号验证码错误", "Wrong verification code for mobile phone number", "手機號驗證碼錯誤"), + SMS_CODE_NOT_EXIST(1105, "请先获取验证码信息", "Please get the captcha information first", "請先獲取驗證碼資訊"), + PHONE_FORMAT_ERROR(1106, "手机号格式不正确", "The phone number format is not correct", "手機號格式不正確"), + FORMAT_ERROR(1106, "手机号或邮箱格式不正确", "The phone number or email format is not correct", "手機號或郵箱格式不正確"), + VERIFY_CODE_TYPE_ERROR(1107, "没有此类型短信", "There is no text message of this type", "沒有此類型短信"), + VERIFY_CODE_OVER_COUNT(1108, "今日获取验证码到达上限", "The upper limit of the captcha is reached today", "今日獲取驗證碼到達上限"), + USER_PHONE_EXISTS(1109, "该手机号或邮箱已存在", "The phone number or email address already exists", "該手機號或郵箱已存在"), + USER_PASSWORD_ERROR_FORMAT(1110, "密码只能是6-16位数字、字母和特殊字符的组合", "Passwords can only be 6-16 digit combinations of Numbers, letters, and special characters", "密碼只能是6-16位數字、字母和特殊字元的組合"), + INVALID_INVITATION_CODE(1111, "无效的邀请码信息", "Invalid invitation code information", "無效的邀請碼資訊"), + INVALID_NICK_NAME(1112, "昵称不能包含特殊字符", "Nicknames cannot contain special characters", "昵稱不能包含特殊字元"), + PHONE_NOT_CHANGE(1113, "手机号码与当前用户一致", "The phone number is the same as the current user", "手機號碼與當前用戶一致"), + GOOGLE_SECRET_KEY_FAIL(1114, "获取谷歌安全码失败", "Failed to get Google security code", "獲取穀歌安全碼失敗"), + GOOGLE_SECRET_KEY_EXIST(1115, "你已绑定谷歌验证器,请勿重复绑定", "You have bound the Google validator. Do not repeat the binding", "你已綁定穀歌驗證器,請勿重複綁定"), + GOOGLE_AUTH_FAIL(1116, "谷歌验证器验证失败", "Google verifier validation failed", "穀歌驗證器驗證失敗"), + FILE_UPLOAD_ERROR(1117, "文件上传失败", "File upload failed", "文檔上傳失敗"), + FILE_UPLOAD_LIMIT(1118, "文件上传失败,上传文件次数过多!", "File upload failed, too many times!", "文檔上傳失敗,上傳檔次數過多!"), + FILE_UPLOAD_FORMAT_ERROR(1119, "文件地址错误", "File address error", "文檔地址錯誤"), + FILE_UPLOAD_DEFICIENCY(1120, "请先上传文件", "Please upload the file first", "請先上傳文檔"), + AUTH_WAIT(1121, "认证审核中,请勿重复申请!", "Please do not repeat the application during the certification audit!", "認證審核中,請勿重複申請!"), + AUTH_YES(1122, "你已完成认证!", "You have completed the certification!", "你已完成認證!"), + AUTH_BASIC_BEFORE(1123, "请先完成初级认证!", "Please complete the primary certification first!", "請先完成初級認證!"), + EMAIL_FORMAT_ERROR(1124, "无效的邮箱格式!", "Invalid mailbox format!", "無效的郵箱格式!"), + EMAIL_VERIFY_FAIL(1125, "邮箱验证失败!", "Mailbox authentication failed!", "郵箱驗證失敗!"), + EMAIL_BIND_REPEAT(1126, "绑定失败,你已绑定邮箱", "Failed to bind. You have bound your mailbox", "綁定失敗,你已綁定郵箱"), + PASSWORD_EXIST(1127, "设置失败,你已经设置过密码了", "Setup failed. You have already set the password", "設置失敗,你已經設置過密碼了"), + EMAIL_EXIST(1128, "绑定失败,该邮箱已被绑定!", "The mailbox has been bound!", "綁定失敗,該郵箱已被綁定!"), + PASSWORD_NOT_MATCH(1129, "密码不匹配", "Password mismatch", "密碼不匹配"), + TRANSACTION_FORBIDDEN(1130, "你被列入黑名单,禁止交易!", "You're blacklisted! No trading!", "你被列入黑名單,禁止交易!"), + CANNOT_FOUND_INTERNATIONAL(1131, "找不到该国家信息", "Country information not available", "找不到該國家信息"), + VERIFY_CODE_DID_NOT_FIND(1034, "验证码已过期或没有获取", "The captcha is expired or not available", "驗證碼已過期或沒有獲取"), + VERIFY_CODE_DID_NOT_MATCH(1035, "您输入的验证码不匹配", "The verification code you entered does not match", "您輸入的驗證碼不匹配"), + WITHDRAW_FORBIDDEN(1136, "你被列入黑名单,禁止提现!", "You are blacklisted and no withdrawal is allowed!", "你被列入黑名單,禁止提現!"), + TRANSACTION_NOT_PASS_HIGH_AUTH(1137, "操作失败,您未通过高级认证!", "Operation failed. You did not pass advanced certification!", "操作失敗,您未通過高級認證!"), + TRANSACTION_NOT_PASS_LOW_AUTH(1137, "操作失败,您未通过初级认证!", "Operation failed. You did not pass primary certification!", "操作失敗,您未通過初級認證!"), + SEND_CODE_ERROR(1138, "验证码发送失败!", "Verification code failed to send!", "驗證碼發送失敗!"), + ; + + + private int code; + private String hkmsg; + private String enMsg; + private String cnmsg; + + UserEnums(int code, String cnmsg, String enMsg, String hkmsg) { + this.code = code; + this.cnmsg = cnmsg; + this.enMsg = enMsg; + this.hkmsg = hkmsg; + } + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public String getHkmsg() { + return hkmsg; + } + + public void setHkmsg(String hkmsg) { + this.hkmsg = hkmsg; + } + + public String getEnMsg() { + return enMsg; + } + + public void setEnMsg(String enMsg) { + this.enMsg = enMsg; + } + + public String getCnmsg() { + return cnmsg; + } + + public void setCnmsg(String cnmsg) { + this.cnmsg = cnmsg; + } +} diff --git a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/exceprion/UserException.java b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/exceprion/UserException.java new file mode 100644 index 0000000..087f59a --- /dev/null +++ b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/exceprion/UserException.java @@ -0,0 +1,52 @@ +package com.blockchain.server.yyyf.exceprion; + +import com.blockchain.common.base.constant.BaseConstant; +import com.blockchain.common.base.exception.BaseException; +import com.blockchain.common.base.util.HttpRequestUtil; +import com.blockchain.server.yyyf.enums.UserEnums; +import lombok.Data; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; + +import javax.servlet.http.HttpServletRequest; + +/** + * @author huangxl + * @data 2019/2/21 20:51 + */ +@Data +public class UserException extends BaseException { + protected int code; + protected String msg; + + public UserException(int code, String msg) { + this.code = code; + this.msg = msg; + } + + public UserException(UserEnums rs) { + ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); + //可能是定时器调用,避免获取request空指针 + if (servletRequestAttributes == null) { + this.code = rs.getCode(); + this.msg = rs.getCnmsg(); + } else { + HttpServletRequest request = servletRequestAttributes.getRequest(); + String userLocale = HttpRequestUtil.getUserLocale(request); + String msg = ""; + switch (userLocale) { + case BaseConstant.USER_LOCALE_EN_US: + msg = rs.getEnMsg(); + break; + case BaseConstant.USER_LOCALE_ZH_HK: + msg = rs.getHkmsg(); + break; + default: + msg = rs.getCnmsg(); + break; + } + this.code = rs.getCode(); + this.msg = msg; + } + } +} 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 9e0a1a9..241e957 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 @@ -5,13 +5,14 @@ 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; +import tk.mybatis.mapper.common.Mapper; import java.util.List; import java.util.Map; @Repository -public interface AssessUserMapper { +public interface AssessUserMapper extends Mapper { void insert(AssessUser assessUser); diff --git a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/mapper/AssessUserProjectMapper.java b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/mapper/AssessUserProjectMapper.java deleted file mode 100644 index 85fabba..0000000 --- a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/mapper/AssessUserProjectMapper.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.blockchain.server.yyyf.mapper; - -import com.blockchain.server.yyyf.entity.AssessUserProject; -import org.springframework.stereotype.Repository; - -import java.util.List; - -@Repository -public interface AssessUserProjectMapper { - - void insert(AssessUserProject assessUserProject); - - void batchInsert(List assessUserProjectList); - -} diff --git a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/mapper/AssessUserTargetMapper.java b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/mapper/AssessUserTargetMapper.java new file mode 100644 index 0000000..9637eea --- /dev/null +++ b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/mapper/AssessUserTargetMapper.java @@ -0,0 +1,16 @@ +package com.blockchain.server.yyyf.mapper; + +import com.blockchain.server.yyyf.dto.AssessUserTargetDto; +import com.blockchain.server.yyyf.entity.AssessUserTarget; +import org.apache.ibatis.annotations.Param; +import org.springframework.stereotype.Repository; +import tk.mybatis.mapper.common.Mapper; + +import java.util.List; + +@Repository +public interface AssessUserTargetMapper extends Mapper { + + + AssessUserTargetDto selectAssessUserTargetDtoByUserIdAndIssueIdAndCaseId(@Param("userId") Integer userId, @Param("issueId") String issueId,@Param("caseId") String caseId); +} diff --git a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/AssessUserProjectService.java b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/AssessUserProjectService.java deleted file mode 100644 index d9ddd17..0000000 --- a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/AssessUserProjectService.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.blockchain.server.yyyf.service; - -public interface AssessUserProjectService{ -} 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 996d7e0..f2a9f30 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 @@ -71,4 +71,5 @@ public interface AssessUserService { * @return void **/ void delAssessUserByIssueId(String examId); + } diff --git a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/AssessUserTargetService.java b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/AssessUserTargetService.java new file mode 100644 index 0000000..939b87b --- /dev/null +++ b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/AssessUserTargetService.java @@ -0,0 +1,13 @@ +package com.blockchain.server.yyyf.service; + +import com.blockchain.server.yyyf.dto.AssessUserTargetDto; +import com.blockchain.server.yyyf.entity.AssessUserTarget; + +public interface AssessUserTargetService{ + /** + * @description 获取指标情况 + * @param [yyyfUserId, examId, caseId] + * @return com.blockchain.server.yyyf.dto.AssessUserTargetDto + **/ + AssessUserTargetDto selectAssessUserTargetDtoByUserIdAndIssueIdAndCaseId(Integer yyyfUserId, String examId, String caseId); +} diff --git a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/impl/AssessUserProjectServiceImpl.java b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/impl/AssessUserProjectServiceImpl.java deleted file mode 100644 index 63631ff..0000000 --- a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/impl/AssessUserProjectServiceImpl.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.blockchain.server.yyyf.service.impl; - -import com.blockchain.server.yyyf.service.AssessUserProjectService; -import org.springframework.stereotype.Service; - -/** - * @author huan.xu - * @version 1.0 - * @className AssessUserProjectServiceImpl - * @description - * @date 2019-10-31 17:40 - */ -@Service -public class AssessUserProjectServiceImpl implements AssessUserProjectService { -} \ No newline at end of file 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 97459df..84f9926 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 @@ -3,7 +3,7 @@ package com.blockchain.server.yyyf.service.impl; import com.blockchain.server.yyyf.dto.PractiseProDto; import com.blockchain.server.yyyf.entity.AssessUser; import com.blockchain.server.yyyf.mapper.AssessUserMapper; -import com.blockchain.server.yyyf.mapper.AssessUserProjectMapper; +import com.blockchain.server.yyyf.mapper.AssessUserTargetMapper; import com.blockchain.server.yyyf.mapper.AssessUserTaskMapper; import com.blockchain.server.yyyf.service.AssessUserService; import org.slf4j.Logger; @@ -29,7 +29,7 @@ public class AssessUserServiceImpl implements AssessUserService { @Autowired private AssessUserMapper assessUserMapper; @Autowired - private AssessUserProjectMapper assessUserProjectMapper; + private AssessUserTargetMapper assessUserTargetMapper; @Autowired private AssessUserTaskMapper assessUserTaskMapper; diff --git a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/impl/AssessUserTargetServiceImpl.java b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/impl/AssessUserTargetServiceImpl.java new file mode 100644 index 0000000..443dbd8 --- /dev/null +++ b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/impl/AssessUserTargetServiceImpl.java @@ -0,0 +1,23 @@ +package com.blockchain.server.yyyf.service.impl; + +import com.blockchain.server.yyyf.dto.AssessUserTargetDto; +import com.blockchain.server.yyyf.entity.AssessUserTarget; +import com.blockchain.server.yyyf.mapper.AssessUserTargetMapper; +import com.blockchain.server.yyyf.service.AssessUserTargetService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +/** + * @version 1.0 + * @className AssessUserProjectServiceImpl + * @description + */ +@Service +public class AssessUserTargetServiceImpl implements AssessUserTargetService { + @Autowired + private AssessUserTargetMapper assessUserTargetMapper; + @Override + public AssessUserTargetDto selectAssessUserTargetDtoByUserIdAndIssueIdAndCaseId(Integer yyyfUserId, String examId, String caseId) { + return this.assessUserTargetMapper.selectAssessUserTargetDtoByUserIdAndIssueIdAndCaseId(yyyfUserId,examId,caseId); + } +} \ No newline at end of file diff --git a/blockchain-server/blockchain-server-yyyf/src/main/resources/mapper/AssessUserProject.xml b/blockchain-server/blockchain-server-yyyf/src/main/resources/mapper/AssessUserTargetMapper.xml similarity index 58% rename from blockchain-server/blockchain-server-yyyf/src/main/resources/mapper/AssessUserProject.xml rename to blockchain-server/blockchain-server-yyyf/src/main/resources/mapper/AssessUserTargetMapper.xml index c556eb4..01c0c20 100644 --- a/blockchain-server/blockchain-server-yyyf/src/main/resources/mapper/AssessUserProject.xml +++ b/blockchain-server/blockchain-server-yyyf/src/main/resources/mapper/AssessUserTargetMapper.xml @@ -1,13 +1,13 @@ - - + + - + @@ -47,36 +47,26 @@ t.duration_unit, t.project_case_desc, + - - insert into yyyf_server_assess_user_project ( id, assess_user_id, project_name, project_id, project_score, project_case_desc) - values - - ( - #{item.id}, - #{item.assessUserId}, - #{item.projectName}, - #{item.projectId}, - #{item.projectScore}, - #{item.projectCaseDesc} - ) - - - - \ No newline at end of file