Commit a8a2a392 authored by yuwenwen's avatar yuwenwen
parents 32a19360 41b338c0
......@@ -27,6 +27,7 @@ import me.chanjar.weixin.cp.api.WxCpOAuth2Service;
import me.chanjar.weixin.cp.api.WxCpService;
import me.chanjar.weixin.cp.bean.WxCpOauth2UserInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.web.bind.annotation.*;
......@@ -66,6 +67,10 @@ public class SysLoginController {
@Autowired
private ISysUserService userService;
@Value("${wx.cp.redirect-url}")
private String redirectUrl;
/**
* 登录方法
......@@ -131,11 +136,9 @@ public class SysLoginController {
// 企微登录认证链接
String authCode = bo.getCode();
String baseUrl = this.serverConfig.getUrl();
String redirectUrl = baseUrl + "/bbs/h5/pages/login/login/";
WxCpOAuth2Service oauth2Service = this.wxCpService.getOauth2Service();
if (Objects.isNull(loginUser) && StrUtil.isBlank(authCode)) {
String oauth2Url = oauth2Service.buildAuthorizationUrl(redirectUrl, null);
String oauth2Url = oauth2Service.buildAuthorizationUrl(this.redirectUrl, null);
log.info("=> 认证失败,返回Oauth2登录链接:{}", oauth2Url);
return AjaxResult.error(401, "身份认证失败", oauth2Url);
}
......@@ -188,11 +191,9 @@ public class SysLoginController {
SysUser updUser = new SysUser();
updUser.setUserId(loginUser.getUserId());
updUser.setAvatar(user.getAvatar());
updUser.setNickName(user.getNickName());
if (this.userService.updateUserProfile(updUser) > 0) {
SysUser sysUser = loginUser.getUser();
sysUser.setAvatar(user.getAvatar());
sysUser.setNickName(user.getNickName());
tokenService.setLoginUser(loginUser);
return AjaxResult.success();
}
......
......@@ -95,6 +95,7 @@ spring:
# 企业微信配置
wx:
cp:
redirect-url: https://test.tangguo.ren/bbsh5/pages/login/login
corp-id: ww63ca87d5f8647514
app-config:
agent-id: 1000072
......
......@@ -95,6 +95,7 @@ spring:
# 企业微信配置
wx:
cp:
redirect-url: https://wecom.jift.edu.cn/bbsh5/pages/login/login
corp-id: wxd2a84aa7529d3801
app-config:
agent-id: 1000218
......
......@@ -16,7 +16,7 @@ ruoyi:
# 开发环境配置
server:
# 服务器的HTTP端口,默认为8080
port: 8080
port: 8089
servlet:
# 应用的访问路径
context-path: /
......@@ -67,8 +67,8 @@ token:
header: Authorization
# 令牌密钥
secret: abcdefghijklmnopqrstuvwxyz
# 令牌有效期(默认30分钟
expireTime: 300000000
# 令牌有效期(默认3小时
expireTime: 10800000
# MyBatis Plus配置
mybatis-plus:
......
package com.tangguo.framework.config;
import cn.hutool.core.util.StrUtil;
import com.tangguo.common.utils.ServletUtils;
import org.springframework.stereotype.Component;
......
......@@ -11,6 +11,7 @@ import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.cp.api.WxCpOAuth2Service;
import me.chanjar.weixin.cp.api.WxCpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.AuthenticationEntryPoint;
import org.springframework.stereotype.Component;
......@@ -34,8 +35,8 @@ public class AuthenticationEntryPointImpl implements AuthenticationEntryPoint, S
@Autowired
private WxCpService wxCpService;
@Autowired
private ServerConfig serverConfig;
@Value("${wx.cp.redirect-url}")
private String redirectUrl;
@Override
public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException e)
......@@ -46,10 +47,8 @@ public class AuthenticationEntryPointImpl implements AuthenticationEntryPoint, S
log.info("=> 身份认证失败,Token:{}", request.getHeader("Authorization"));
if (uri.startsWith("/bbs/mobile")) {
String baseUrl = this.serverConfig.getUrl();
String redirectUrl = baseUrl + "/bbs/h5/pages/login/login/";
WxCpOAuth2Service oauth2Service = this.wxCpService.getOauth2Service();
String oauth2Url = oauth2Service.buildAuthorizationUrl(redirectUrl, null);
String oauth2Url = oauth2Service.buildAuthorizationUrl(this.redirectUrl, null);
ServletUtils.renderString(response, JSON.toJSONString(AjaxResult.error(401, "身份认证失败", oauth2Url)));
} else {
String msg = StringUtils.format("请求访问:{},认证失败,无法访问系统资源", uri);
......
......@@ -114,13 +114,14 @@ public class BbsMoment extends BaseEntity {
private String nickName;
/** 用户部门 */
@Excel(name = "所在部门", sort = 3)
@Excel(name = "部门(班级)", sort = 3)
@TableField(exist = false)
private String deptName;
@TableField(exist = false)
private String ancestors;
@Excel(name = "上级部门(学院)", sort = 4)
@TableField(exist = false)
private String fullDeptName;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment