Explorar o código

添加获取会员 0-1接口

小么熊🐻 %!s(int64=2) %!d(string=hai) anos
pai
achega
96cd07870a

+ 99 - 0
jsjp-admin/src/main/java/com/miaxis/app/controller/userInfo/UserVipController.java

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

+ 54 - 0
jsjp-service/src/main/java/com/miaxis/userInfo/vo/UserVipTFVO.java

@@ -0,0 +1,54 @@
+package com.miaxis.userInfo.vo;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * <p>
+ * 视频VIP表
+ * </p>
+ *
+ * @author ${author}
+ * @since 2022-01-27
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+public class UserVipTFVO implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @ApiModelProperty(value = "ID")
+    private Long id;
+
+    @ApiModelProperty(value = "用户ID")
+    private Long userId;
+
+    @ApiModelProperty(value = "用户名")
+    private String userName;
+
+    @ApiModelProperty(value = "科目2  到期时间")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Integer subject1;
+
+    @ApiModelProperty(value = "科目2  到期时间")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Integer subject2;
+
+    @ApiModelProperty(value = "科目2  到期时间")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Integer subject3;
+
+    @ApiModelProperty(value = "科目3  到期时间")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Integer subject4;
+
+    @ApiModelProperty(value = "签名")
+    private String sign;
+
+
+}