|
@@ -2,9 +2,8 @@ package com.miaxis.app.controller.exam;
|
|
|
|
|
|
import com.miaxis.common.constant.Constants;
|
|
|
import com.miaxis.common.core.controller.BaseController;
|
|
|
-import com.miaxis.common.core.domain.entity.UserInfo;
|
|
|
import com.miaxis.common.core.page.ResponsePageInfo;
|
|
|
-import com.miaxis.common.utils.SecurityUtils;
|
|
|
+import com.miaxis.common.utils.PrivateKeyUtil;
|
|
|
import com.miaxis.examvip.domain.VipUserExam;
|
|
|
import com.miaxis.examvip.service.IVipUserExamService;
|
|
|
import io.swagger.annotations.Api;
|
|
@@ -14,6 +13,11 @@ import org.springframework.web.bind.annotation.GetMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
+import java.security.KeyFactory;
|
|
|
+import java.security.PrivateKey;
|
|
|
+import java.security.Signature;
|
|
|
+import java.security.spec.PKCS8EncodedKeySpec;
|
|
|
+import java.util.Base64;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
@@ -23,8 +27,8 @@ import java.util.List;
|
|
|
* @date 2023-03-20
|
|
|
*/
|
|
|
@RestController
|
|
|
-@RequestMapping(Constants.OPEN_PREFIX+"/vip/exam")
|
|
|
-@Api(tags={"【APP-考场会员】"})
|
|
|
+@RequestMapping(Constants.OPEN_PREFIX + "/vip/exam")
|
|
|
+@Api(tags = {"【APP-考场会员】"})
|
|
|
public class VipUserExamController extends BaseController {
|
|
|
@Autowired
|
|
|
private IVipUserExamService vipUserExamService;
|
|
@@ -34,14 +38,38 @@ public class VipUserExamController extends BaseController {
|
|
|
*/
|
|
|
@GetMapping("/list")
|
|
|
@ApiOperation("查询当前用户考试会员列表")
|
|
|
- public ResponsePageInfo<VipUserExam> list(Long userId){
|
|
|
+ public ResponsePageInfo<VipUserExam> list(Long userId,Long examId) throws Exception {
|
|
|
VipUserExam vipUserExam = new VipUserExam();
|
|
|
vipUserExam.setUserId(userId);
|
|
|
+ vipUserExam.setExamId(examId);
|
|
|
List<VipUserExam> list = vipUserExamService.selectVipUserExamList(vipUserExam);
|
|
|
+ this.doSign(list);
|
|
|
return toResponsePageInfo(list);
|
|
|
}
|
|
|
-
|
|
|
|
|
|
|
|
|
+ private void doSign(List<VipUserExam> userExamList) throws Exception {
|
|
|
|
|
|
-}
|
|
|
+ for (VipUserExam userExam : userExamList) {
|
|
|
+ String str = "";
|
|
|
+ if (userExam.getUserId() != null) {
|
|
|
+ str += userExam.getUserId();
|
|
|
+ }
|
|
|
+ if (userExam.getExpirationTime() != null) {
|
|
|
+ str += userExam.getExpirationTime().getTime();
|
|
|
+ }
|
|
|
+ if (userExam.getIsVip() != null) {
|
|
|
+ str += userExam.getIsVip();
|
|
|
+ }
|
|
|
+ // 进行签名服务
|
|
|
+ Signature signature = Signature.getInstance("SHA256withRSA");
|
|
|
+ KeyFactory kf = KeyFactory.getInstance("RSA");
|
|
|
+ PrivateKey privateKey = kf.generatePrivate(new PKCS8EncodedKeySpec(Base64.getDecoder().decode(PrivateKeyUtil.rsaPrivateKey)));
|
|
|
+ signature.initSign(privateKey);
|
|
|
+ signature.update(str.getBytes("UTF-8"));
|
|
|
+ byte[] signedData = signature.sign();
|
|
|
+ String sign = Base64.getEncoder().encodeToString(signedData);
|
|
|
+ userExam.setSign(sign);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|