Jelajahi Sumber

fix 视频记录

he2802 3 tahun lalu
induk
melakukan
53ecf9520d

+ 3 - 1
zhongzheng-api/src/main/java/com/zhongzheng/controller/wx/WxLoginController.java

@@ -53,7 +53,9 @@ public class WxLoginController
     @PostMapping("/testLogin")
     public AjaxResult testLogin(@RequestBody WxLoginBody loginBody)
     {
-        Map<String,String> map = wxLoginService.test_login();
+        wxLoginService.getWxGzhUserList();
+        String token = wxLoginService.getWxGzhUserCgiInfo("o3oVj0cih3KpmFhXV9PEfDNMfHs8");
+        Map<String,String> map = new HashMap<>();
         return AjaxResult.success(map);
     }
 

+ 2 - 2
zhongzheng-api/src/main/resources/application-dev.yml

@@ -102,8 +102,8 @@ wx:
         appid: wxd3c8ae80cf43a305
         appsecret: 193a001ebfd46f227008a21e9d13e750
     gzh:
-        appid: wx6f48f721d18244eb
-        appsecret: 2f8b2b4ff66e2f6adfb9f08ae22d7474
+        appid: wx505d3a592bc28a42
+        appsecret: 1311d2e3036f4ced5acb8269c82c98e3
     wepay:
         mchid: 1342013901
         key: GdXyPxYjZx1234123yJzXgDxYpXyjpx9

+ 6 - 0
zhongzheng-framework/src/main/java/com/zhongzheng/framework/web/service/UserServiceImpl.java

@@ -531,9 +531,15 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
         if(bo.getTel()==null){
             throw new CustomException("手机号不能为空");
         }
+        if(bo.getTel().length()!=11){
+            throw new CustomException("手机号格式错误");
+        }
         if(bo.getIdCard()==null){
             throw new CustomException("身份证不能为空");
         }
+        if(bo.getIdCard().length()!=18){
+            throw new CustomException("身份证格式错误");
+        }
         if(bo.getRealname()==null){
             throw new CustomException("真实姓名不能为空");
         }

+ 48 - 0
zhongzheng-framework/src/main/java/com/zhongzheng/framework/web/service/WxLoginService.java

@@ -75,6 +75,10 @@ public class WxLoginService
     @Value("${wx.gzh.appsecret}")
     private String gzh_appsrcret;
 
+    private String gzh_wxTokenUrl = "https://api.weixin.qq.com/cgi-bin/token";
+
+    private String gzh_wxTokenParam = "grant_type=client_credential&appid=%s&secret=%s";
+
     private String gzh_wxAuthUrl = "https://api.weixin.qq.com/sns/oauth2/access_token";
 
     private String gzh_wxAuthParam = "appid=%s&secret=%s&code=%s&grant_type=authorization_code";
@@ -83,6 +87,14 @@ public class WxLoginService
 
     private String gzh_wxUserInfoParam = "access_token=%s&openid=%s&lang=zh_CN";
 
+    private String gzh_wxUserListUrl = "https://api.weixin.qq.com/cgi-bin/user/get";
+
+    private String gzh_wxUserListParam = "access_token=%s";
+
+    private String gzh_wxUserCgiInfoUrl = "https://api.weixin.qq.com/cgi-bin/user/info";
+
+    private String gzh_wxUserCgiInfoParam = "access_token=%s&openid=%s&lang=zh_CN";
+
     @Autowired
     private IUserService iUserService;
 
@@ -327,6 +339,42 @@ public class WxLoginService
         return user;
     }
 
+    public String getWxGzhAccessToken() {
+        String key = "WX_GZH_ACCESS_TOKEN";
+        String accessToken = redisCache.getCacheObject(key);
+    //    if(Validator.isEmpty(accessToken)){
+            String param = String.format(gzh_wxTokenParam, gzh_appid, gzh_appsrcret);
+            String resultString  = HttpUtils.sendGet(gzh_wxTokenUrl,param);
+            //解析json
+            JSONObject jsonObject = (JSONObject) JSONObject.parse(resultString);
+            accessToken = String.valueOf(jsonObject.get("access_token"));
+            if(Validator.isNotEmpty(accessToken)){
+                redisCache.setCacheObject(key, accessToken,7100, TimeUnit.SECONDS);//7200有效期
+            }
+   //     }
+        return accessToken;
+    }
+
+    public String getWxGzhUserList() {
+        String accessToken = getWxGzhAccessToken();
+        String nextOpenid = null;
+        String param = String.format(gzh_wxUserListParam, accessToken);
+        if(Validator.isNotEmpty(nextOpenid)){
+            param += "&next_openid="+nextOpenid;
+        }
+        String resultString  = HttpUtils.sendGet(gzh_wxUserListUrl,param);
+        System.out.println(resultString);
+        return resultString;
+    }
+
+    public String getWxGzhUserCgiInfo(String openid) {
+        String accessToken = getWxGzhAccessToken();
+        String param = String.format(gzh_wxUserCgiInfoParam, accessToken,openid);
+        String resultString  = HttpUtils.sendGet(gzh_wxUserCgiInfoUrl,param);
+        System.out.println(resultString);
+        return resultString;
+    }
+
     //公众号获取用户信息
     public User getWxGzhUnionIdUser(WxLoginBody loginBody) {
         String param = String.format(gzh_wxAuthParam, gzh_appid, gzh_appsrcret, loginBody.getCode());

+ 12 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/vo/SectionStudyRecordVo.java

@@ -109,4 +109,16 @@ public class SectionStudyRecordVo {
     @Excel(name = "学习时长")
     @ApiModelProperty("学习时长")
     private Long studyDuration;
+    /** 直播开始时间 */
+    @Excel(name = "直播开始时间")
+    @ApiModelProperty("直播开始时间")
+    private Long liveStartTime;
+    /** 直播结束时间 */
+    @Excel(name = "直播结束时间")
+    @ApiModelProperty("直播结束时间")
+    private Long liveEndTime;
+    /** 录播和回放的url地址 */
+    @Excel(name = "录播和回放的url地址")
+    @ApiModelProperty("录播和回放的url地址")
+    private String recordingUrl;
 }

+ 8 - 1
zhongzheng-system/src/main/resources/mapper/modules/user/UserStudyRecordMapper.xml

@@ -91,6 +91,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="realDuration" column="real_duration"/>
         <result property="firstStartTime" column="first_start_time"/>
         <result property="studyDuration" column="study_duration"/>
+        <result property="liveStartTime" column="live_start_time"/>
+        <result property="liveEndTime" column="live_end_time"/>
+        <result property="recordingUrl" column="recording_url"/>
     </resultMap>
 
     <resultMap type="com.zhongzheng.modules.user.vo.ExamStudyRecordVo" id="ExamStudyRecordVoResult">
@@ -1278,7 +1281,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             r.*,
             g.goods_name,
             g.goods_type,
-            r.order_goods_id
+            r.order_goods_id,
+           cs.recording_url,
+           cs.live_url,
+           cs.live_start_time,
+           cs.live_end_time
         FROM
             (
                 SELECT