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