Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Q
qk_backend
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
quanku
qk_backend
Commits
7818e75d
Commit
7818e75d
authored
Oct 26, 2023
by
shiyu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
用户修改头像和昵称同步到IM
parent
3bc0798f
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
44 additions
and
3 deletions
+44
-3
ch-core/src/main/resources/application-dev.yml
ch-core/src/main/resources/application-dev.yml
+2
-1
ch-core/src/main/resources/application-prod.yml
ch-core/src/main/resources/application-prod.yml
+2
-1
ch-wx-api/src/main/java/com/wwdz/ch/wx/api/ChatApi.java
ch-wx-api/src/main/java/com/wwdz/ch/wx/api/ChatApi.java
+16
-0
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/UserServiceImpl.java
...pi/src/main/java/com/wwdz/ch/wx/impl/UserServiceImpl.java
+17
-0
ch-wx-api/src/test/java/com/wwdz/ch/wx/api/ChatApiTest.java
ch-wx-api/src/test/java/com/wwdz/ch/wx/api/ChatApiTest.java
+7
-1
No files found.
ch-core/src/main/resources/application-dev.yml
View file @
7818e75d
...
...
@@ -202,3 +202,4 @@ avatar-url: https://cdn.wanwudezhi.com/static/web-static/image/b888cc6cb9c004dc3
chat
:
model-url
:
https://xiaobai-fastapi.wanwudezhi.com/chat
bing-search-url
:
https://xiaobai-fastapi.wanwudezhi.com/local_doc_qa/bing_search_chat
\ No newline at end of file
ch-core/src/main/resources/application-prod.yml
View file @
7818e75d
...
...
@@ -199,3 +199,4 @@ avatar-url: https://cdn.wanwudezhi.com/static/web-static/image/b888cc6cb9c004dc3
chat
:
model-url
:
https://xiaobai-fastapi.wanwudezhi.com/chat
bing-search-url
:
https://xiaobai-fastapi.wanwudezhi.com/local_doc_qa/bing_search_chat
\ No newline at end of file
ch-wx-api/src/main/java/com/wwdz/ch/wx/api/ChatApi.java
View file @
7818e75d
...
...
@@ -17,6 +17,9 @@ public class ChatApi {
@Value
(
"${chat.model-url}"
)
private
String
chatModelUrl
;
@Value
(
"${chat.bing-search-url}"
)
private
String
bingSearchUrl
;
public
String
chatWithModel
(
String
question
)
{
OkHttpUtil
okHttpUtil
=
OkHttpUtil
.
builder
().
url
(
chatModelUrl
);
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
...
...
@@ -28,4 +31,17 @@ public class ChatApi {
logger
.
info
(
"[chatWithModel] response :{}"
,
responseStr
);
return
responseStr
;
}
public
String
chatWithBingSearch
(
String
question
)
{
OkHttpUtil
okHttpUtil
=
OkHttpUtil
.
builder
().
url
(
bingSearchUrl
);
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"question"
,
question
);
map
.
put
(
"history"
,
null
);
okHttpUtil
.
addParams
(
map
);
okHttpUtil
.
post
(
true
);
String
responseStr
=
okHttpUtil
.
async
();
logger
.
info
(
"[chatWithModel] response :{}"
,
responseStr
);
return
responseStr
;
}
}
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/UserServiceImpl.java
View file @
7818e75d
...
...
@@ -114,6 +114,7 @@ public class UserServiceImpl implements UserService {
AiAssistantDao
aiAssistantDao
;
@Override
public
Result
regCaptcha
(
UserRequestDto
dto
)
{
try
{
...
...
@@ -319,6 +320,14 @@ public class UserServiceImpl implements UserService {
String
userKey
=
MessageFormat
.
format
(
CacheCodeConstants
.
USER_INFO_KEY
,
user
.
getId
());
redisUtil
.
set
(
userKey
,
resultUser
,
2
*
60
*
60
);
logger
.
info
(
"【请求结束】用户修改昵称成功"
);
//修改后的昵称同步到IM
Result
synResult
=
chatUserApi
.
importUser
(
user
);
if
(
synResult
.
getSuccess
())
{
logger
.
info
(
"用户id:{}, 修改后的昵称同步到IM成功"
,
user
.
getId
());
}
else
{
logger
.
error
(
"用户id:{}, 修改后的昵称同步到IM失败 :{}"
,
user
.
getId
(),
synResult
.
getErrmsg
());
}
return
Result
.
success
();
}
catch
(
Exception
e
)
{
logger
.
error
(
"用户修改昵称失败"
,
e
);
...
...
@@ -342,6 +351,14 @@ public class UserServiceImpl implements UserService {
String
userKey
=
MessageFormat
.
format
(
CacheCodeConstants
.
USER_INFO_KEY
,
user
.
getId
());
redisUtil
.
set
(
userKey
,
resultUser
,
2
*
60
*
60
);
logger
.
info
(
"【请求结束】用户修改头像成功"
);
//修改后的头像同步到IM
Result
synResult
=
chatUserApi
.
importUser
(
user
);
if
(
synResult
.
getSuccess
())
{
logger
.
info
(
"用户id:{}, 修改后的头像同步到IM成功"
,
user
.
getId
());
}
else
{
logger
.
error
(
"用户id:{}, 修改后的头像同步到IM失败 :{}"
,
user
.
getId
(),
synResult
.
getErrmsg
());
}
return
Result
.
success
();
}
catch
(
Exception
e
)
{
logger
.
error
(
"用户修改头像失败"
,
e
);
...
...
ch-wx-api/src/test/java/com/wwdz/ch/wx/api/ChatApiTest.java
View file @
7818e75d
...
...
@@ -57,6 +57,12 @@ public class ChatApiTest {
chatApi
.
chatWithModel
(
question
);
}
@Test
public
void
chatWithBingSearch
()
{
String
question
=
"什么是站洋"
;
chatApi
.
chatWithBingSearch
(
question
);
}
@Test
public
void
getUserSig
()
{
tlsSigApi
.
refreshUserSig
(
"cjxc"
);
...
...
@@ -136,7 +142,7 @@ public class ChatApiTest {
@Test
public
void
getChatList
()
{
IMChatRequestDto
imChatRequestDto
=
new
IMChatRequestDto
();
imChatRequestDto
.
setUserId
(
2
69
L
);
imChatRequestDto
.
setUserId
(
2
38
L
);
conversationApi
.
getChatList
(
imChatRequestDto
);
}
...
...
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