Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
c291e6f2
authored
Nov 05, 2026
by
renyizhao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
创建newapi账号时 带手机号
parent
c0d5047f
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
10 deletions
+17
-10
computility-module-apihub/computility-module-apihub-biz/src/main/java/com/luhu/computility/module/apihub/controller/app/AppAiTokenController.java
+1
-0
computility-module-apihub/computility-module-apihub-biz/src/main/java/com/luhu/computility/module/apihub/service/newapi/AiTokenService.java
+7
-6
computility-module-apihub/computility-module-apihub-biz/src/main/java/com/luhu/computility/module/apihub/service/newapi/NewApiClient.java
+7
-2
computility-server/src/main/resources/application-prod.yaml
+2
-2
No files found.
computility-module-apihub/computility-module-apihub-biz/src/main/java/com/luhu/computility/module/apihub/controller/app/AppAiTokenController.java
View file @
c291e6f2
...
@@ -52,6 +52,7 @@ public class AppAiTokenController {
...
@@ -52,6 +52,7 @@ public class AppAiTokenController {
AiTokenService
.
AiTokenResult
result
=
aiTokenService
.
getOrCreateToken
(
AiTokenService
.
AiTokenResult
result
=
aiTokenService
.
getOrCreateToken
(
user
.
getId
(),
user
.
getId
(),
user
.
getMobile
(),
user
.
getNewapiUsername
(),
user
.
getNewapiUsername
(),
user
.
getNewapiPassword
(),
user
.
getNewapiPassword
(),
user
.
getNewapiUserId
(),
user
.
getNewapiUserId
(),
...
...
computility-module-apihub/computility-module-apihub-biz/src/main/java/com/luhu/computility/module/apihub/service/newapi/AiTokenService.java
View file @
c291e6f2
...
@@ -46,8 +46,9 @@ public class AiTokenService {
...
@@ -46,8 +46,9 @@ public class AiTokenService {
*/
*/
private
static
final
Pattern
GIFT_PATTERN
=
Pattern
.
compile
(
"^Increased user quota by (\\d+)$"
);
private
static
final
Pattern
GIFT_PATTERN
=
Pattern
.
compile
(
"^Increased user quota by (\\d+)$"
);
public
AiTokenResult
getOrCreateToken
(
Long
userId
,
String
newApiUsername
,
String
newApiPassword
,
public
AiTokenResult
getOrCreateToken
(
Long
userId
,
String
displayName
,
String
newApiUsername
,
Long
newApiUserId
,
String
newApiAccessToken
,
String
newApiKey
)
{
String
newApiPassword
,
Long
newApiUserId
,
String
newApiAccessToken
,
String
newApiKey
)
{
log
.
info
(
"[AiTokenService] userId={}, hasApiKey={}"
,
userId
,
newApiKey
!=
null
&&
!
newApiKey
.
isEmpty
());
log
.
info
(
"[AiTokenService] userId={}, hasApiKey={}"
,
userId
,
newApiKey
!=
null
&&
!
newApiKey
.
isEmpty
());
if
(
newApiKey
!=
null
&&
!
newApiKey
.
isEmpty
())
{
if
(
newApiKey
!=
null
&&
!
newApiKey
.
isEmpty
())
{
...
@@ -70,17 +71,17 @@ public class AiTokenService {
...
@@ -70,17 +71,17 @@ public class AiTokenService {
}
}
log
.
info
(
"[AiTokenService] 无账号密码,从第1步开始"
);
log
.
info
(
"[AiTokenService] 无账号密码,从第1步开始"
);
return
createTokenFull
(
userId
);
return
createTokenFull
(
userId
,
displayName
);
}
}
private
AiTokenResult
createTokenFull
(
Long
userId
)
{
private
AiTokenResult
createTokenFull
(
Long
userId
,
String
displayName
)
{
String
username
=
"puhui_"
+
userId
;
String
username
=
"puhui_"
+
userId
;
String
password
=
RandomUtil
.
randomString
(
12
);
String
password
=
RandomUtil
.
randomString
(
12
);
log
.
info
(
"[AiTokenService.createTokenFull] 准备注册: username={}
"
,
usern
ame
);
log
.
info
(
"[AiTokenService.createTokenFull] 准备注册: username={}
, displayName={}"
,
username
,
displayN
ame
);
try
{
try
{
// 使用管理员接口注册(关闭游客注册后使用)
// 使用管理员接口注册(关闭游客注册后使用)
NewApiResponse
<
Void
>
registerResp
=
newApiClient
.
adminRegister
(
username
,
password
);
NewApiResponse
<
Void
>
registerResp
=
newApiClient
.
adminRegister
(
username
,
password
,
displayName
);
log
.
info
(
"[AiTokenService.createTokenFull] 注册结果: success={}, message={}"
,
registerResp
.
getSuccess
(),
registerResp
.
getMessage
());
log
.
info
(
"[AiTokenService.createTokenFull] 注册结果: success={}, message={}"
,
registerResp
.
getSuccess
(),
registerResp
.
getMessage
());
if
(!
Boolean
.
TRUE
.
equals
(
registerResp
.
getSuccess
()))
{
if
(!
Boolean
.
TRUE
.
equals
(
registerResp
.
getSuccess
()))
{
...
...
computility-module-apihub/computility-module-apihub-biz/src/main/java/com/luhu/computility/module/apihub/service/newapi/NewApiClient.java
View file @
c291e6f2
...
@@ -64,15 +64,20 @@ public class NewApiClient {
...
@@ -64,15 +64,20 @@ public class NewApiClient {
/**
/**
* 管理员注册用户(关闭游客注册后使用此接口)
* 管理员注册用户(关闭游客注册后使用此接口)
* POST /api/user/
* POST /api/user/
*
* @param displayName 显示名称(对应 NewAPI 的 display_name 字段),为空时 NewAPI 会默认取 username
*/
*/
public
NewApiResponse
<
Void
>
adminRegister
(
String
username
,
String
password
)
{
public
NewApiResponse
<
Void
>
adminRegister
(
String
username
,
String
password
,
String
displayName
)
{
String
url
=
newApiProperties
.
getBaseUrl
()
+
"/api/user/"
;
String
url
=
newApiProperties
.
getBaseUrl
()
+
"/api/user/"
;
log
.
info
(
"[NewApiClient.adminRegister] 请求URL: {}"
,
url
);
log
.
info
(
"[NewApiClient.adminRegister] 请求URL: {}"
,
url
);
log
.
info
(
"[NewApiClient.adminRegister] 请求参数: username={}, password={}
"
,
username
,
"***"
);
log
.
info
(
"[NewApiClient.adminRegister] 请求参数: username={}, password={}
, displayName={}"
,
username
,
"***"
,
displayName
);
Map
<
String
,
Object
>
body
=
new
HashMap
<>();
Map
<
String
,
Object
>
body
=
new
HashMap
<>();
body
.
put
(
"username"
,
username
);
body
.
put
(
"username"
,
username
);
body
.
put
(
"password"
,
password
);
body
.
put
(
"password"
,
password
);
if
(
StrUtil
.
isNotBlank
(
displayName
))
{
body
.
put
(
"display_name"
,
displayName
);
}
try
{
try
{
HttpResponse
response
=
HttpRequest
.
post
(
url
)
HttpResponse
response
=
HttpRequest
.
post
(
url
)
...
...
computility-server/src/main/resources/application-prod.yaml
View file @
c291e6f2
...
@@ -166,8 +166,8 @@ wx: # 参见 https://github.com/Wechat-Group/WxJava/blob/develop/spring-boot-sta
...
@@ -166,8 +166,8 @@ wx: # 参见 https://github.com/Wechat-Group/WxJava/blob/develop/spring-boot-sta
# 芋道配置项,设置当前项目所有自定义的配置
# 芋道配置项,设置当前项目所有自定义的配置
computility
:
computility
:
new-api
:
new-api
:
base-url
:
http://10.0.0.207:300
0
base-url
:
http://10.0.0.207:300
2
admin-token
:
V33oMN4fI5H0wKSs0gXipXZ4WvU6DQ==
admin-token
:
HWfIG6YoehIwTC6MKSQYy5vn68FApwA7
admin-user-id
:
1
admin-user-id
:
1
captcha
:
captcha
:
enable
:
false
# 本地环境,暂时关闭图片验证码,方便登录等接口的测试;
enable
:
false
# 本地环境,暂时关闭图片验证码,方便登录等接口的测试;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment