|
@@ -11,6 +11,7 @@ import java.util.*;
|
|
|
import com.miaxis.newgzpt.domain.GzptVideoVip;
|
|
|
import com.miaxis.newgzpt.vo.GzptVideoVipVO;
|
|
|
import com.miaxis.userInfo.dto.UserVipDTO;
|
|
|
+import com.miaxis.userInfo.vo.UserVipTFVO;
|
|
|
import com.miaxis.userInfo.vo.UserVipVO;
|
|
|
import io.swagger.annotations.*;
|
|
|
import com.miaxis.common.core.domain.Response;
|
|
@@ -83,6 +84,76 @@ public class UserVipController extends BaseController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取会员信息0-1表示
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @GetMapping(value = "/info/{userId}")
|
|
|
+ @ApiOperation("获取会员信息0-1表示")
|
|
|
+ public Response<UserVipTFVO> getUserVipUserId(
|
|
|
+ @ApiParam(name = "userId", value = "会员信息参数", required = true)
|
|
|
+ @PathVariable("userId") Long userId
|
|
|
+ ) throws Exception {
|
|
|
+ UserVip userVip = userVipService.getUserVipByUserId(userId);
|
|
|
+ UserVipVO vo = new UserVipVO();
|
|
|
+ UserVipTFVO vo2 = new UserVipTFVO();
|
|
|
+ vo2.setId(vo.getId());
|
|
|
+ vo2.setUserId(vo.getUserId());
|
|
|
+ vo2.setUserName(vo.getUserName());
|
|
|
+
|
|
|
+ if (userVip != null) {
|
|
|
+ BeanUtils.copyProperties(userVip, vo);
|
|
|
+ Date now = new Date();
|
|
|
+ //科一
|
|
|
+ if(vo.getSubject1()!=null){
|
|
|
+ if(now.compareTo(vo.getSubject1())>0) { //如果过期
|
|
|
+ vo2.setSubject1(0);
|
|
|
+ } else {
|
|
|
+ vo2.setSubject1(1);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ vo2.setSubject1(0);
|
|
|
+ }
|
|
|
+ //科二
|
|
|
+ if(vo.getSubject2()!=null){
|
|
|
+ if(now.compareTo(vo.getSubject2())>0) { //如果过期
|
|
|
+ vo2.setSubject2(0);
|
|
|
+ } else {
|
|
|
+ vo2.setSubject2(1);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ vo2.setSubject2(0);
|
|
|
+ }
|
|
|
+ //科三
|
|
|
+ if(vo.getSubject3()!=null){
|
|
|
+ if(now.compareTo(vo.getSubject3())>0) { //如果过期
|
|
|
+ vo2.setSubject3(0);
|
|
|
+ } else {
|
|
|
+ vo2.setSubject3(1);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ vo2.setSubject3(0);
|
|
|
+ }
|
|
|
+ //科四
|
|
|
+ if(vo.getSubject4()!=null){
|
|
|
+ if(now.compareTo(vo.getSubject4())>0) { //如果过期
|
|
|
+ vo2.setSubject4(0);
|
|
|
+ } else {
|
|
|
+ vo2.setSubject4(1);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ vo2.setSubject4(0);
|
|
|
+ }
|
|
|
+
|
|
|
+ String sign = getSign(vo.getUserId(),vo2.getSubject1(), vo2.getSubject2(), vo2.getSubject3(),vo2.getSubject4());
|
|
|
+ vo2.setSign(sign);
|
|
|
+ return Response.success(vo2);
|
|
|
+ } else {
|
|
|
+ return Response.success(vo2);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 删除会员信息
|
|
@@ -128,4 +199,32 @@ public class UserVipController extends BaseController {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ private String getSign(Long userId, Integer subject1, Integer subject2, Integer subject3, Integer subject4) throws Exception {
|
|
|
+ String str = userId + "";
|
|
|
+ // System.out.println(userId);
|
|
|
+
|
|
|
+ if (subject1 != null) {
|
|
|
+ str += subject1 + "";
|
|
|
+ }
|
|
|
+ if (subject2 != null) {
|
|
|
+ str += subject2 + "";
|
|
|
+ }
|
|
|
+ if (subject3 != null) {
|
|
|
+ str += subject3 + "";
|
|
|
+ }
|
|
|
+ if (subject4 != null) {
|
|
|
+ str += subject4 + "";
|
|
|
+ }
|
|
|
+ System.out.println("str:" + str);
|
|
|
+ // 进行签名服务
|
|
|
+ Signature signature = Signature.getInstance("SHA256withRSA");
|
|
|
+ KeyFactory kf = KeyFactory.getInstance("RSA");
|
|
|
+ PrivateKey privateKey = kf.generatePrivate(new PKCS8EncodedKeySpec(Base64.getDecoder().decode(rsaPrivateKey)));
|
|
|
+ signature.initSign(privateKey);
|
|
|
+ signature.update(str.getBytes("UTF-8"));
|
|
|
+ byte[] signedData = signature.sign();
|
|
|
+ return Base64.getEncoder().encodeToString(signedData);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
}
|