Ver Fonte

Merge remote-tracking branch 'origin/master'

小么熊🐻 há 2 anos atrás
pai
commit
0cb913b6bb

+ 3 - 3
twzd-admin/src/main/java/com/miaxis/app/controller/h5/QuestionWrongController.java

@@ -105,9 +105,9 @@ public class QuestionWrongController extends BaseController {
             questionWrong.setUserId(SecurityUtils.getLoginUser().getStudent().getId());
             qlist.add(questionWrong);
         }
-        if (qlist.isEmpty()) {
-            throw new CustomException("选中的错题都已收藏!");
-        }
+//        if (qlist.isEmpty()) {
+//            throw new CustomException("选中的错题都已收藏!");
+//        }
         return toResponse(questionWrongService.saveBatch(qlist) ? 1 : 0);
     }
 

+ 1 - 1
twzd-admin/src/main/java/com/miaxis/system/controller/system/SysLoginController.java

@@ -139,7 +139,7 @@ public class SysLoginController
         WxUserInfo wxUserInfo = new WxUserInfo();
         wxUserInfo.setOpenid("ovKTX5-FKLF6_sgTtCIXpG_lz3PY");
         wxUserInfo.setUnionid("oqEKX6GxPyBPfRbM-Bk01CGwA0oM");
-        wxUserInfo.setNickname("Sss");
+        wxUserInfo.setNickname("Althars");
         wxUserInfo.setSex("0");
         wxUserInfo.setHeadimgurl("https://thirdwx.qlogo.cn/mmopen/vi_32/DYAIOgq83erGMFzKaOmz6cIaA0J1nicWSlBLdLKY46N5CNCoASiajT7Z3RIfPngPhJsjmqsSjGCFibPU4vCtfz3aw/132");
         String token = loginService.login(wxUserInfo,null, StudentLoginTypeEnum.AUTHORIZATION_CODE_LOGIN.getCode());

+ 1 - 1
twzd-framework/src/main/java/com/miaxis/framework/web/service/UserDetailsServiceImpl.java

@@ -89,7 +89,7 @@ public class UserDetailsServiceImpl implements UserDetailsService
                     userService.saveUserInfo(userInfo);
                 }else {
                     userInfo.setXcxOpenid((String) ServletUtils.getRequest().getAttribute("xcxOpenid"));
-                    userService.updateStudent(userInfo);
+                    userService.updateXcxOpenid(userInfo);
                 }
                 return createLoginUser(identification);
             }

+ 1 - 4
twzd-service/src/main/java/com/miaxis/score/dto/ScoreInfoDTO.java

@@ -1,6 +1,5 @@
 package com.miaxis.score.dto;
 
-import com.miaxis.common.core.domain.BaseBusinessEntity;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
@@ -11,9 +10,7 @@ import lombok.Data;
  * @date 2021-08-23
  */
 @Data
-public class ScoreInfoDTO extends BaseBusinessEntity {
-    private static final long serialVersionUID = 1L;
-
+public class ScoreInfoDTO {
 
 //    /** 用户ID */
 //    private Long userId;

+ 1 - 2
twzd-service/src/main/java/com/miaxis/user/dto/UserInfoUpdateDto.java

@@ -2,7 +2,6 @@ package com.miaxis.user.dto;
 
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.miaxis.common.annotation.Excel;
-import com.miaxis.common.core.domain.BaseBusinessEntity;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
@@ -12,7 +11,7 @@ import lombok.Data;
  * @Version 1.0
  */
 @Data
-public class UserInfoUpdateDto extends BaseBusinessEntity {
+public class UserInfoUpdateDto  {
     /** 小程序头像地址 */
     @Excel(name = "小程序头像地址")
     @TableField("head_image")

+ 14 - 2
twzd-service/src/main/java/com/miaxis/wx/service/impl/WxGzhServiceImpl.java

@@ -64,6 +64,7 @@ public class WxGzhServiceImpl implements IWxGzhService {
 
     private final WxService wxService;
 
+
     @Value("${app.appid}")
     private String appid;
 
@@ -82,7 +83,7 @@ public class WxGzhServiceImpl implements IWxGzhService {
         if (redisTemplate.hasKey(Constants.GZH_MESSAGE_TOKEN)){
             token = (String)redisTemplate.opsForValue().get(Constants.GZH_MESSAGE_TOKEN);
         }
-        if (StringUtils.isEmpty(token)){
+        if (StringUtils.isEmpty(token)|| notEffect(token)){
             String result = wxSendService.getAccessToken("client_credential",appid,secret);
             JSONObject json = JSONObject.parseObject(result);
             token = json.getString("access_token");
@@ -98,6 +99,13 @@ public class WxGzhServiceImpl implements IWxGzhService {
         return token;
     }
 
+    //判定是否失效
+    private boolean notEffect(String token) {
+        String res = wxSendService.userInfo( token, "ovKTX5-FKLF6_sgTtCIXpG_lz3PY", "zh_CN");
+        JSONObject jsonObject = JSONObject.parseObject(res);
+        return jsonObject.getString("unionid") ==null;
+
+    }
 
 
     /**
@@ -176,9 +184,13 @@ public class WxGzhServiceImpl implements IWxGzhService {
                 String event = jsonObjectData.getStr("Event");
                 if (MessageUtil.MESSAGE_SUBSCRIBE.equals(event)) { // 关注事件 或 扫描二维码关注事件
                     log.info("3.1...");
-                    UserInfo user = userService.getStudentByOpenId(fromUserName);
+                    String res = wxSendService.userInfo( this.getGzhToken(), fromUserName, "zh_CN");
+                    JSONObject jsonObject = JSONObject.parseObject(res);
+                    String unionId = jsonObject.getString("unionid");
+                    UserInfo user = userService.getStudentByUnionid(unionId);
                     UserInfo userInfo = new UserInfo();
                     userInfo.setOpenid(fromUserName);
+                    userInfo.setUnionId(unionId);
 
                     //存在Ticket为扫码关注
                     if (org.apache.commons.lang3.StringUtils.isNotEmpty(jsonObjectData.getStr("Ticket"))){

+ 1 - 0
twzd-service/src/main/resources/mapper/score/ScoreInfoMapper.xml

@@ -40,6 +40,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="kskm != null  and kskm != ''"> and kskm = #{kskm}</if>
             <if test="score != null "> and score = #{score}</if>
         </where>
+        order by create_time desc
     </select>
 
 

+ 2 - 0
twzd-system/src/main/java/com/miaxis/system/mapper/SysUserMapper.java

@@ -125,4 +125,6 @@ public interface SysUserMapper
     void updateSysUserByNickName(@Param("schoolName")String schoolName, @Param("total")Integer total);
 
     UserInfo getStudentByUnionid(String identification);
+
+    void updateXcxOpenid(UserInfo userInfo);
 }

+ 2 - 0
twzd-system/src/main/java/com/miaxis/system/service/ISysUserService.java

@@ -186,4 +186,6 @@ public interface ISysUserService
     void updateSysUserByNickName(String schoolName, Integer total);
 
     UserInfo getStudentByUnionid(String identification);
+
+    void updateXcxOpenid(UserInfo userInfo);
 }

+ 5 - 0
twzd-system/src/main/java/com/miaxis/system/service/impl/SysUserServiceImpl.java

@@ -483,4 +483,9 @@ public class SysUserServiceImpl implements ISysUserService
     public UserInfo getStudentByUnionid(String identification) {
         return userMapper.getStudentByUnionid(identification);
     }
+
+    @Override
+    public void updateXcxOpenid(UserInfo userInfo) {
+        userMapper.updateXcxOpenid(userInfo);
+    }
 }

+ 7 - 12
twzd-system/src/main/resources/mapper/system/SysUserMapper.xml

@@ -92,7 +92,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
 	<select id="getStudentByOpenId" parameterType="String" resultType="com.miaxis.common.core.domain.entity.UserInfo">
 		select * from user_info
-		where union_id = #{unionId}
+		where open_id = #{openId}
 	</select>
 
 	<select id="getStudentByUnionid" parameterType="String" resultType="com.miaxis.common.core.domain.entity.UserInfo">
@@ -109,19 +109,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 	</insert>
 	<insert id="updateStudent" parameterType="com.miaxis.common.core.domain.entity.UserInfo" >
 		update user_info set
-		<if test="headImage != null and headImage != ''">
 			head_image = #{headImage},
-		</if>
-		<if test="nickName != null and nickName != ''">
 			nick_name = #{nickName},
-		</if>
-		<if test="openid != null and openid != ''">
-			openid = #{openid},
-		</if>
-		<if test="xcxOpenid != null and xcxOpenid != ''">
-			xcx_openid = #{xcxOpenid},
-		</if>
-		union_id = #{unionId}
+			openid = #{openid}
+		where union_id = #{unionId}
+	</insert>
+	<insert id="updateXcxOpenid" parameterType="com.miaxis.common.core.domain.entity.UserInfo" >
+		update user_info set
+			xcx_openid = #{xcxOpenid}
 		where union_id = #{unionId}
 	</insert>