he2802 před 4 roky
rodič
revize
0e204657db

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

@@ -8,10 +8,7 @@ import com.zhongzheng.common.core.domain.entity.SysUser;
 import com.zhongzheng.common.core.domain.model.LoginBody;
 import com.zhongzheng.common.core.domain.model.LoginUser;
 import com.zhongzheng.common.utils.ServletUtils;
-import com.zhongzheng.framework.web.service.SysLoginService;
-import com.zhongzheng.framework.web.service.SysPermissionService;
-import com.zhongzheng.framework.web.service.TokenService;
-import com.zhongzheng.framework.web.service.WxTokenService;
+import com.zhongzheng.framework.web.service.*;
 import com.zhongzheng.modules.system.service.ISysMenuService;
 import com.zhongzheng.modules.user.entity.ClientLoginUser;
 import com.zhongzheng.modules.user.service.IUserService;
@@ -35,7 +32,7 @@ import java.util.Set;
 public class WxLoginController
 {
     @Autowired
-    private IUserService iUserService;
+    private WxLoginService wxLoginService;
 
     @Autowired
     private WxTokenService wxTokenService;
@@ -51,7 +48,7 @@ public class WxLoginController
     {
         AjaxResult ajax = AjaxResult.success();
         String union = "cba";
-        String token = iUserService.login(union);
+        String token = wxLoginService.login(union);
         ajax.put(Constants.TOKEN, token);
         return ajax;
     }

+ 6 - 1
zhongzheng-api/src/main/resources/application.yml

@@ -112,7 +112,7 @@ token:
     # 令牌密钥
     secret: abcdefghijklmnopqrstuvwxyz
     # 令牌有效期(默认30分钟)
-    expireTime: 120
+    expireTime: 360
 
 # MyBatis配置
 # https://baomidou.com/config/
@@ -236,3 +236,8 @@ feign:
     enabled: true
   hystrix:
     enabled: true
+
+wx:
+  small:
+    appid: 123
+    appsecret: 3434

+ 11 - 0
zhongzheng-common/src/main/java/com/zhongzheng/common/core/bo/WxLoginResultBo.java

@@ -0,0 +1,11 @@
+package com.zhongzheng.common.core.bo;
+
+import lombok.Data;
+
+@Data
+public class WxLoginResultBo {
+    private String openid;
+    private String session_key;
+    private String errcode;
+    private String errmsg;
+}

+ 2 - 2
zhongzheng-common/src/main/java/com/zhongzheng/common/enums/UserStatus.java

@@ -2,12 +2,12 @@ package com.zhongzheng.common.enums;
 
 /**
  * 用户状态
- * 
+ *
  * @author zhongzheng
  */
 public enum UserStatus
 {
-    OK("0", "正常"), DISABLE("1", "停用"), DELETED("2", "删除");
+    OK("1", "正常"), DISABLE("0", "停用"), DELETED("-1", "删除");
 
     private final String code;
     private final String info;

+ 2 - 12
zhongzheng-framework/src/main/java/com/zhongzheng/framework/web/service/UserServiceImpl.java

@@ -33,8 +33,7 @@ import java.util.stream.Collectors;
 @Service
 public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IUserService {
 
-    @Autowired
-    private WxTokenService wxTokenService;
+
 
     @Override
     public UserVo queryById(Long userId){
@@ -53,16 +52,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
         return null;
     }
 
-    @Override
-    public String login(String unionId) {
-        User user = queryByUnionId(unionId);
-        if(user==null){
-            throw new CustomException("unionId不存在");
-        }
-        ClientLoginUser loginUser = new ClientLoginUser();
-        loginUser.setUser(user);
-        return wxTokenService.createToken(loginUser);
-    }
+
 
     @Override
     public List<UserVo> queryList(UserQueryBo bo) {

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

@@ -0,0 +1,57 @@
+package com.zhongzheng.framework.web.service;
+
+
+import com.zhongzheng.common.core.bo.WxLoginResultBo;
+import com.zhongzheng.common.exception.CustomException;
+
+import com.zhongzheng.modules.user.domain.User;
+import com.zhongzheng.modules.user.entity.ClientLoginUser;
+import com.zhongzheng.modules.user.service.IUserService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+import org.springframework.web.client.RestTemplate;
+
+import javax.annotation.Resource;
+
+/**
+ * 登录校验方法
+ *
+ * @author zhongzheng
+ */
+@Component
+public class WxLoginService
+{
+    @Autowired
+    private WxTokenService wxTokenService;
+
+    @Value("${wx.small.appid}")
+    private String appid;
+
+    @Value("${wx.small.appsecret}")
+    private String appsrcret;
+
+    private String wxAuthUrl = "https://api.weixin.qq.com/sns/jscode2session?appid=%s&secret=%s&js_code=%s&grant_type=authorization_code";
+
+    @Autowired
+    private RestTemplate restTemplate;
+
+    @Autowired
+    private IUserService iUserService;
+
+    public String login(String unionId) {
+        User user = iUserService.queryByUnionId(unionId);
+        if(user==null){
+            throw new CustomException("unionId不存在");
+        }
+        ClientLoginUser loginUser = new ClientLoginUser();
+        loginUser.setUser(user);
+        return wxTokenService.createToken(loginUser);
+    }
+
+    public String getWxUnionId(String code) {
+        String url = String.format(wxAuthUrl, appid, appsrcret, code);
+        WxLoginResultBo wxLoginResult = restTemplate.getForObject(url, WxLoginResultBo.class);
+        return null;
+    }
+}

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/domain/CourseSection.java

@@ -54,4 +54,6 @@ private static final long serialVersionUID=1L;
     /** $column.columnComment */
     private Long sort;
 
+    /** 保利威视频ID */
+    private Long polyvId;
 }

+ 0 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/service/IUserService.java

@@ -26,7 +26,6 @@ public interface IUserService extends IService<User> {
 
 	User queryByUnionId(String unionId);
 
-	String login(String unionId);
 
 	/**
 	 * 查询列表

+ 0 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/wx/bo/WxLoginBody.java

@@ -32,7 +32,6 @@ public class WxLoginBody {
     @ApiModelProperty("encryptedData")
     private String encryptedData;
 
-
     private String tel;
 
 }

+ 1 - 0
zhongzheng-system/src/main/resources/mapper/modules/course/CourseSectionMapper.xml

@@ -14,6 +14,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="updateTime" column="update_time"/>
         <result property="status" column="status"/>
         <result property="sort" column="sort"/>
+        <result property="polyvId" column="polyv_id"/>
     </resultMap>