Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
W
wangxiaolu-sfa-auth
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
sfa
wangxiaolu-sfa-auth
Commits
8413a978
提交
8413a978
authored
12月 04, 2025
作者:
000516
浏览文件
操作
浏览文件
下载
差异文件
修改qa\master配置文件
上级
8193b338
62d22093
隐藏空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
110 行增加
和
101 行删除
+110
-101
SfaAuthApplication.java
src/main/java/com/sfa/auth/SfaAuthApplication.java
+3
-1
FsTokenController.java
src/main/java/com/sfa/auth/controller/FsTokenController.java
+10
-3
FeiShuUtil.java
src/main/java/com/sfa/auth/util/FeiShuUtil.java
+88
-82
bootstrap-dev.yml
src/main/resources/bootstrap-dev.yml
+3
-0
bootstrap-live.yml
src/main/resources/bootstrap-live.yml
+0
-15
bootstrap-master.yml
src/main/resources/bootstrap-master.yml
+2
-0
bootstrap-qa.yml
src/main/resources/bootstrap-qa.yml
+2
-0
logback-spring.xml
src/main/resources/logback-spring.xml
+2
-0
没有找到文件。
src/main/java/com/sfa/auth/SfaAuthApplication.java
浏览文件 @
8413a978
package
com
.
sfa
.
auth
;
import
com.sfa.common.security.annotation.EnableRyFeignClients
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration
;
import
com.sfa.common.security.annotation.EnableRyFeignClients
;
import
org.springframework.context.annotation.ComponentScan
;
/**
* 认证授权中心
*
* @author ruoyi
*/
@ComponentScan
(
basePackages
=
{
"com.sfa.common.core.utils.sdk"
,
"com.sfa.auth"
})
@EnableRyFeignClients
@SpringBootApplication
(
exclude
=
{
DataSourceAutoConfiguration
.
class
})
public
class
SfaAuthApplication
...
...
src/main/java/com/sfa/auth/controller/FsTokenController.java
浏览文件 @
8413a978
...
...
@@ -3,7 +3,8 @@ package com.sfa.auth.controller;
import
com.lark.oapi.service.authen.v1.model.GetUserInfoRespBody
;
import
com.sfa.auth.form.LoginBody
;
import
com.sfa.auth.service.SysLoginService
;
import
com.sfa.auth.util.FeiShuUtil
;
import
com.sfa.common.core.utils.sdk.FeiShuUtil
;
import
com.sfa.common.security.service.TokenService
;
import
com.sfa.system.api.model.LoginUser
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -29,9 +30,15 @@ public class FsTokenController {
@PostMapping
(
"/fs/login"
)
public
Map
<
String
,
Object
>
login
(
@RequestBody
LoginBody
form
){
String
userAccessToken
=
feiShuUtil
.
createUserAccessToken
(
form
.
getCode
());
GetUserInfoRespBody
fsUserInfo
=
feiShuUtil
.
getUserInfo
(
userAccessToken
);
String
userAccessToken
=
feiShuUtil
.
createUserAccessToken
(
form
.
getCode
()
,
FeiShuUtil
.
APP_LUZX
);
GetUserInfoRespBody
fsUserInfo
=
feiShuUtil
.
getUserInfo
(
userAccessToken
,
FeiShuUtil
.
APP_LUZX
);
LoginUser
userInfo
=
sysLoginService
.
fsLogin
(
fsUserInfo
.
getEmployeeNo
());
return
tokenService
.
createToken
(
userInfo
);
}
@PostMapping
(
"/fs/lb_login"
)
public
GetUserInfoRespBody
lbLogin
(
@RequestBody
LoginBody
form
){
String
userAccessToken
=
feiShuUtil
.
createUserAccessToken
(
form
.
getCode
(),
FeiShuUtil
.
APP_LBXY
);
GetUserInfoRespBody
fsUserInfo
=
feiShuUtil
.
getUserInfo
(
userAccessToken
,
FeiShuUtil
.
APP_LBXY
);
return
fsUserInfo
;
}
}
src/main/java/com/sfa/auth/util/FeiShuUtil.java
浏览文件 @
8413a978
package
com
.
sfa
.
auth
.
util
;
import
com.alibaba.fastjson2.JSONObject
;
import
com.google.gson.JsonParser
;
import
com.lark.oapi.Client
;
import
com.lark.oapi.core.request.RequestOptions
;
import
com.lark.oapi.core.utils.Jsons
;
import
com.lark.oapi.okhttp.*
;
import
com.lark.oapi.service.authen.v1.model.GetUserInfoResp
;
import
com.lark.oapi.service.authen.v1.model.GetUserInfoRespBody
;
import
com.sfa.common.core.enums.ECode
;
import
com.sfa.common.core.exception.auth.NotLoginException
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Component
;
import
java.util.HashMap
;
/**
* @author : liqiulin
* @date : 2024-12-06 16
* @describe :
*/
@Slf4j
@Component
public
class
FeiShuUtil
{
//飞书获取用户信息,注意值:最后的斜杆
@Value
(
"${feishu.redirectUri}"
)
private
String
redirectUri
;
/**
* 根据用户的登录临时code获取useraccessToken
*/
public
String
createUserAccessToken
(
String
code
)
{
try
{
HashMap
<
String
,
String
>
bodyMap
=
new
HashMap
<>();
bodyMap
.
put
(
"grant_type"
,
"authorization_code"
);
bodyMap
.
put
(
"client_id"
,
"cli_a7dbe3ec7d9e5013"
);
bodyMap
.
put
(
"client_secret"
,
"WxiT7uIJNDbDpEGfVCXEwNNfN1A3RgUo"
);
bodyMap
.
put
(
"redirect_uri"
,
redirectUri
);
bodyMap
.
put
(
"code"
,
code
);
OkHttpClient
client
=
new
OkHttpClient
();
RequestBody
body
=
RequestBody
.
create
(
MediaType
.
get
(
"application/json"
),
JSONObject
.
toJSONString
(
bodyMap
));
Request
build
=
new
Request
.
Builder
().
url
(
"https://open.feishu.cn/open-apis/authen/v2/oauth/token"
).
addHeader
(
"Content-Type"
,
"application/json; charset=utf-8"
).
post
(
body
).
build
();
Response
execute
=
client
.
newCall
(
build
).
execute
();
JSONObject
rj
=
JSONObject
.
parseObject
(
execute
.
body
().
string
());
if
(!
rj
.
containsKey
(
"access_token"
)){
log
.
error
(
"飞书用户获取失败!"
,
rj
.
toString
());
throw
new
NotLoginException
(
ECode
.
FEISHU_ACCESS_TOKEN_ERROR
);
}
return
rj
.
getString
(
"access_token"
);
}
catch
(
Exception
e
)
{
throw
new
NotLoginException
(
ECode
.
FEISHU_ACCESS_TOKEN_ERROR
);
}
}
/**
* 根据用户的userAccessToken获取用户信息
*/
public
GetUserInfoRespBody
getUserInfo
(
String
userAccessToken
)
{
try
{
Client
client
=
getClient
();
GetUserInfoResp
resp
=
client
.
authen
().
userInfo
().
get
(
RequestOptions
.
newBuilder
()
.
userAccessToken
(
userAccessToken
)
.
build
());
if
(!
resp
.
success
())
{
log
.
error
(
String
.
format
(
"code:%s,msg:%s,reqId:%s, resp:%s"
,
resp
.
getCode
(),
resp
.
getMsg
(),
resp
.
getRequestId
(),
Jsons
.
createGSON
(
true
,
false
).
toJson
(
JsonParser
.
parseString
(
new
String
(
resp
.
getRawResponse
().
getBody
(),
"UTF-8"
)))));
return
null
;
}
return
resp
.
getData
();
}
catch
(
Exception
e
)
{
log
.
error
(
"获取用户信息失败,停止执行!"
);
return
null
;
}
}
private
Client
getClient
()
{
return
Client
.
newBuilder
(
"cli_a7dbe3ec7d9e5013"
,
"WxiT7uIJNDbDpEGfVCXEwNNfN1A3RgUo"
).
build
();
}
}
//package com.sfa.auth.util;
//
//import com.alibaba.fastjson2.JSONObject;
//import com.google.gson.JsonParser;
//import com.lark.oapi.Client;
//import com.lark.oapi.core.request.RequestOptions;
//import com.lark.oapi.core.utils.Jsons;
//import com.lark.oapi.okhttp.*;
//import com.lark.oapi.service.authen.v1.model.GetUserInfoResp;
//import com.lark.oapi.service.authen.v1.model.GetUserInfoRespBody;
//import com.sfa.common.core.enums.ECode;
//import com.sfa.common.core.exception.auth.NotLoginException;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.stereotype.Component;
//
//import java.util.HashMap;
//
///**
// * @author : liqiulin
// * @date : 2024-12-06 16
// * @describe :
// */
//@Slf4j
//@Component
//public class FeiShuUtil {
// //飞书获取用户信息,注意值:最后的斜杆
// @Value("${feishu.redirectUri}")
// private String redirectUri;
//
// /**
// * 根据用户的登录临时code获取useraccessToken
// * 应用:链路中心
// */
// public String createUserAccessToken(String code) {
// try {
// HashMap<String, String> bodyMap = new HashMap<>();
// bodyMap.put("grant_type", "authorization_code");
// bodyMap.put("client_id", "cli_a7dbe3ec7d9e5013");
// bodyMap.put("client_secret", "WxiT7uIJNDbDpEGfVCXEwNNfN1A3RgUo");
// bodyMap.put("redirect_uri", redirectUri);
//
// bodyMap.put("code", code);
//
// OkHttpClient client = new OkHttpClient();
// RequestBody body = RequestBody.create(MediaType.get("application/json"), JSONObject.toJSONString(bodyMap));
// Request build = new Request.Builder().url("https://open.feishu.cn/open-apis/authen/v2/oauth/token").addHeader("Content-Type", "application/json; charset=utf-8").post(body).build();
// Response execute = client.newCall(build).execute();
// JSONObject rj = JSONObject.parseObject(execute.body().string());
// if (!rj.containsKey("access_token")){
// log.error("飞书用户获取失败!",rj.toString());
// throw new NotLoginException(ECode.FEISHU_ACCESS_TOKEN_ERROR);
// }
// return rj.getString("access_token");
// } catch (Exception e) {
// throw new NotLoginException(ECode.FEISHU_ACCESS_TOKEN_ERROR);
// }
// }
//
// /**
// * 根据用户的userAccessToken获取用户信息
// */
// public GetUserInfoRespBody getUserInfo(String userAccessToken) {
// try {
// Client client = getClient();
// GetUserInfoResp resp = client.authen().userInfo().get(RequestOptions.newBuilder()
// .userAccessToken(userAccessToken)
// .build());
// if (!resp.success()) {
// log.error(String.format("code:%s,msg:%s,reqId:%s, resp:%s",
// resp.getCode(), resp.getMsg(), resp.getRequestId(), Jsons.createGSON(true, false).toJson(JsonParser.parseString(new String(resp.getRawResponse().getBody(), "UTF-8")))));
// return null;
// }
// return resp.getData();
// } catch (Exception e) {
// log.error("获取用户信息失败,停止执行!");
// return null;
// }
// }
//
// /**
// * 创建飞书客户端
// * 应用:链路中心
// */
// private Client getClient() {
// return Client.newBuilder("cli_a7dbe3ec7d9e5013", "WxiT7uIJNDbDpEGfVCXEwNNfN1A3RgUo").build();
// }
//}
src/main/resources/bootstrap-dev.yml
浏览文件 @
8413a978
...
...
@@ -13,3 +13,5 @@ spring:
file-extension
:
yaml
group
:
sfa
namespace
:
9fb64726-e415-43e4-9e79-9be8d2666671
shared-configs
:
-
data-id
:
wangxiaolu-sfa-shared.yaml
\ No newline at end of file
src/main/resources/bootstrap-live.yml
deleted
100644 → 0
浏览文件 @
8193b338
spring
:
application
:
name
:
wangxiaolu-sfa-auth
cloud
:
nacos
:
discovery
:
server-addr
:
192.168.100.38:8848
group
:
sfa
namespace
:
5ae12140-31d8-490a-9798-f923cb0e30d4
config
:
server-addr
:
192.168.100.38:8848
file-extension
:
yaml
group
:
sfa
namespace
:
5ae12140-31d8-490a-9798-f923cb0e30d4
src/main/resources/bootstrap-master.yml
浏览文件 @
8413a978
...
...
@@ -13,3 +13,5 @@ spring:
file-extension
:
yaml
group
:
sfa
namespace
:
e2996044-6ddc-4988-8810-602e05d01ccf
shared-configs
:
-
data-id
:
wangxiaolu-sfa-shared.yaml
src/main/resources/bootstrap-qa.yml
浏览文件 @
8413a978
...
...
@@ -13,3 +13,5 @@ spring:
file-extension
:
yaml
group
:
sfa
namespace
:
24aed289-30a5-4e5c-8110-1b96281d1265
shared-configs
:
-
data-id
:
wangxiaolu-sfa-shared.yaml
src/main/resources/logback-spring.xml
浏览文件 @
8413a978
...
...
@@ -40,6 +40,7 @@
class=
"ch.qos.logback.core.rolling.RollingFileAppender"
>
<encoder>
<pattern>
${FILE_LOG_PATTERN}
</pattern>
<charset>
UTF-8
</charset>
</encoder>
<file>
${LOG_PATH}/${MODEL_NAME}-today.log
</file>
<rollingPolicy
class=
"ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"
>
...
...
@@ -56,6 +57,7 @@
class=
"ch.qos.logback.core.rolling.RollingFileAppender"
>
<encoder>
<pattern>
${FILE_LOG_PATTERN}
</pattern>
<charset>
UTF-8
</charset>
</encoder>
<file>
${LOG_PATH}/${MODEL_NAME}-error-today.log
</file>
<rollingPolicy
class=
"ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"
>
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论