Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
poc-api
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
poc
poc-api
Commits
438781c8
Commit
438781c8
authored
Nov 06, 2024
by
alex yao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 判断知识库是否开启
parent
1395aa5e
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
98 additions
and
93 deletions
+98
-93
AgentApplicationInfoServiceImpl.java
...ation/aggregate/impl/AgentApplicationInfoServiceImpl.java
+98
-93
No files found.
src/main/java/cn/com/poc/agent_application/aggregate/impl/AgentApplicationInfoServiceImpl.java
View file @
438781c8
...
@@ -352,6 +352,100 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ
...
@@ -352,6 +352,100 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ
return
true
;
return
true
;
}
}
@Override
public
void
collectOrCancelAgentInMall
(
Integer
id
,
String
agentId
)
throws
Exception
{
UserBaseEntity
userBaseEntity
=
BlContext
.
getCurrentUserNotException
();
if
(
userBaseEntity
==
null
)
{
throw
new
BusinessException
(
"用户未登录"
);
}
BizAgentApplicationMallEntity
mallEntity
=
bizAgentApplicationMallService
.
get
(
id
);
if
(
mallEntity
==
null
)
{
throw
new
BusinessException
(
"应用不存在"
);
}
// 先判断当前应用被当前用户收藏了吗
BizMemberAgentApplicationCollectEntity
collectEntity
=
new
BizMemberAgentApplicationCollectEntity
();
collectEntity
.
setAgentId
(
agentId
);
collectEntity
.
setMemberId
(
userBaseEntity
.
getUserId
().
intValue
());
List
<
BizMemberAgentApplicationCollectEntity
>
collectEntities
=
bizMemberAgentApplicationCollectService
.
findByExample
(
collectEntity
,
new
PagingInfo
());
if
(
collectEntities
.
isEmpty
()
||
CommonConstant
.
IsDeleted
.
N
.
equals
(
collectEntities
.
get
(
0
).
getIsCollect
()))
{
//如果没被收藏
// 收藏该应用
// 说明从来没收藏过
if
(
collectEntities
.
isEmpty
())
{
// 在用户收藏表中添加数据
BizMemberAgentApplicationCollectEntity
entity
=
new
BizMemberAgentApplicationCollectEntity
();
entity
.
setIsCollect
(
CommonConstant
.
IsDeleted
.
Y
);
entity
.
setMemberId
(
userBaseEntity
.
getUserId
().
intValue
());
entity
.
setAgentId
(
agentId
);
bizMemberAgentApplicationCollectService
.
save
(
entity
);
}
else
{
// 说明之前收藏过,则只需要做个修改
collectEntity
.
setIsCollect
(
CommonConstant
.
IsDeleted
.
Y
);
bizMemberAgentApplicationCollectService
.
update
(
collectEntity
);
}
// 在应用广场的应用中 添加收藏数
mallEntity
.
setCollectNumber
(
mallEntity
.
getCollectNumber
()
+
1
);
}
else
{
// 取消收藏该应用
collectEntities
.
get
(
0
).
setIsCollect
(
CommonConstant
.
IsDeleted
.
N
);
bizMemberAgentApplicationCollectService
.
update
(
collectEntity
);
// 在应用广场的应用中 取消收藏数
mallEntity
.
setCollectNumber
(
mallEntity
.
getCollectNumber
()
-
1
);
}
bizAgentApplicationMallService
.
update
(
mallEntity
);
}
@Override
public
void
collectOrCancelAgentInPerson
(
String
agentId
)
throws
Exception
{
UserBaseEntity
userBaseEntity
=
BlContext
.
getCurrentUserNotException
();
if
(
userBaseEntity
==
null
)
{
throw
new
BusinessException
(
"用户未登录"
);
}
// 先判断当前应用被当前用户收藏了吗
BizMemberAgentApplicationCollectEntity
collectEntity
=
new
BizMemberAgentApplicationCollectEntity
();
collectEntity
.
setAgentId
(
agentId
);
collectEntity
.
setMemberId
(
userBaseEntity
.
getUserId
().
intValue
());
List
<
BizMemberAgentApplicationCollectEntity
>
collectEntities
=
bizMemberAgentApplicationCollectService
.
findByExample
(
collectEntity
,
new
PagingInfo
());
Integer
isCollect
=
0
;
if
(
collectEntities
.
isEmpty
()
||
CommonConstant
.
IsDeleted
.
N
.
equals
(
collectEntities
.
get
(
0
).
getIsCollect
()))
{
//如果没被收藏
// 收藏该应用
// 说明从来没收藏过
if
(
collectEntities
.
isEmpty
())
{
// 在用户收藏表中添加数据
BizMemberAgentApplicationCollectEntity
entity
=
new
BizMemberAgentApplicationCollectEntity
();
entity
.
setIsCollect
(
CommonConstant
.
IsDeleted
.
Y
);
entity
.
setMemberId
(
userBaseEntity
.
getUserId
().
intValue
());
entity
.
setAgentId
(
agentId
);
bizMemberAgentApplicationCollectService
.
save
(
entity
);
}
else
{
// 说明之前收藏过,则只需要做个修改
collectEntities
.
get
(
0
).
setIsCollect
(
CommonConstant
.
IsDeleted
.
Y
);
bizMemberAgentApplicationCollectService
.
update
(
collectEntities
.
get
(
0
));
}
isCollect
=
1
;
}
else
{
// 取消收藏该应用
collectEntities
.
get
(
0
).
setIsCollect
(
CommonConstant
.
IsDeleted
.
N
);
bizMemberAgentApplicationCollectService
.
update
(
collectEntities
.
get
(
0
));
isCollect
=
-
1
;
}
BizAgentApplicationPublishEntity
publishEntity
=
bizAgentApplicationPublishService
.
getByAgentId
(
agentId
);
if
(
publishEntity
==
null
)
{
logger
.
warn
(
"应用尚未发布,agentId:{}"
,
agentId
);
return
;
}
Integer
id
=
publishEntity
.
getId
();
BizAgentApplicationMallEntity
mallEntity
=
bizAgentApplicationMallService
.
getByAgentPublishId
(
id
);
if
(
mallEntity
==
null
||
CommonConstant
.
YOrN
.
N
.
equals
(
mallEntity
.
getIsSale
()))
{
logger
.
warn
(
"应用尚未上架,agentId:{}"
,
agentId
);
return
;
}
mallEntity
.
setCollectNumber
(
mallEntity
.
getCollectNumber
()
+
isCollect
);
bizAgentApplicationMallService
.
update
(
mallEntity
);
}
/**
/**
* 构建应用信息提示词
* 构建应用信息提示词
*
*
...
@@ -394,15 +488,18 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ
...
@@ -394,15 +488,18 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ
// 调用知识库
// 调用知识库
if
(
ArrayUtils
.
isNotEmpty
(
kdIds
))
{
if
(
ArrayUtils
.
isNotEmpty
(
kdIds
))
{
List
<
String
>
knowledgeIds
=
new
ArrayList
<>();
List
<
String
>
knowledgeIds
=
new
ArrayList
<>();
for
(
Integer
kdId
:
kdIds
)
{
for
(
Integer
kdId
:
kdIds
)
{
BizKnowledgeDocumentEntity
knowledgeDocumentEntity
=
bizKnowledgeDocumentService
.
get
(
kdId
);
BizKnowledgeDocumentEntity
knowledgeDocumentEntity
=
bizKnowledgeDocumentService
.
get
(
kdId
);
if
(
null
==
knowledgeDocumentEntity
)
{
if
(
null
==
knowledgeDocumentEntity
||
CommonConstant
.
YOrN
.
N
.
equals
(
knowledgeDocumentEntity
.
getIsEnable
())
)
{
continue
;
continue
;
}
}
knowledgeIds
.
add
(
knowledgeDocumentEntity
.
getKnowledgeId
());
knowledgeIds
.
add
(
knowledgeDocumentEntity
.
getKnowledgeId
());
}
}
Object
content
=
messages
.
get
(
messages
.
size
()
-
1
);
Object
content
=
messages
.
get
(
messages
.
size
()
-
1
);
String
query
=
""
;
String
query
=
""
;
if
(
content
instanceof
List
)
{
if
(
content
instanceof
List
)
{
query
=
((
List
<
MultiContent
>)
content
).
get
(
0
).
getText
();
query
=
((
List
<
MultiContent
>)
content
).
get
(
0
).
getText
();
}
else
{
}
else
{
...
@@ -664,96 +761,4 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ
...
@@ -664,96 +761,4 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ
return
largeModelEntity
.
getModelName
();
return
largeModelEntity
.
getModelName
();
}
}
@Override
public
void
collectOrCancelAgentInMall
(
Integer
id
,
String
agentId
)
throws
Exception
{
UserBaseEntity
userBaseEntity
=
BlContext
.
getCurrentUserNotException
();
if
(
userBaseEntity
==
null
)
{
throw
new
BusinessException
(
"用户未登录"
);
}
BizAgentApplicationMallEntity
mallEntity
=
bizAgentApplicationMallService
.
get
(
id
);
if
(
mallEntity
==
null
)
{
throw
new
BusinessException
(
"应用不存在"
);
}
// 先判断当前应用被当前用户收藏了吗
BizMemberAgentApplicationCollectEntity
collectEntity
=
new
BizMemberAgentApplicationCollectEntity
();
collectEntity
.
setAgentId
(
agentId
);
collectEntity
.
setMemberId
(
userBaseEntity
.
getUserId
().
intValue
());
List
<
BizMemberAgentApplicationCollectEntity
>
collectEntities
=
bizMemberAgentApplicationCollectService
.
findByExample
(
collectEntity
,
new
PagingInfo
());
if
(
collectEntities
.
isEmpty
()
||
CommonConstant
.
IsDeleted
.
N
.
equals
(
collectEntities
.
get
(
0
).
getIsCollect
()))
{
//如果没被收藏
// 收藏该应用
// 说明从来没收藏过
if
(
collectEntities
.
isEmpty
())
{
// 在用户收藏表中添加数据
BizMemberAgentApplicationCollectEntity
entity
=
new
BizMemberAgentApplicationCollectEntity
();
entity
.
setIsCollect
(
CommonConstant
.
IsDeleted
.
Y
);
entity
.
setMemberId
(
userBaseEntity
.
getUserId
().
intValue
());
entity
.
setAgentId
(
agentId
);
bizMemberAgentApplicationCollectService
.
save
(
entity
);
}
else
{
// 说明之前收藏过,则只需要做个修改
collectEntity
.
setIsCollect
(
CommonConstant
.
IsDeleted
.
Y
);
bizMemberAgentApplicationCollectService
.
update
(
collectEntity
);
}
// 在应用广场的应用中 添加收藏数
mallEntity
.
setCollectNumber
(
mallEntity
.
getCollectNumber
()
+
1
);
}
else
{
// 取消收藏该应用
collectEntities
.
get
(
0
).
setIsCollect
(
CommonConstant
.
IsDeleted
.
N
);
bizMemberAgentApplicationCollectService
.
update
(
collectEntity
);
// 在应用广场的应用中 取消收藏数
mallEntity
.
setCollectNumber
(
mallEntity
.
getCollectNumber
()
-
1
);
}
bizAgentApplicationMallService
.
update
(
mallEntity
);
}
@Override
public
void
collectOrCancelAgentInPerson
(
String
agentId
)
throws
Exception
{
UserBaseEntity
userBaseEntity
=
BlContext
.
getCurrentUserNotException
();
if
(
userBaseEntity
==
null
)
{
throw
new
BusinessException
(
"用户未登录"
);
}
// 先判断当前应用被当前用户收藏了吗
BizMemberAgentApplicationCollectEntity
collectEntity
=
new
BizMemberAgentApplicationCollectEntity
();
collectEntity
.
setAgentId
(
agentId
);
collectEntity
.
setMemberId
(
userBaseEntity
.
getUserId
().
intValue
());
List
<
BizMemberAgentApplicationCollectEntity
>
collectEntities
=
bizMemberAgentApplicationCollectService
.
findByExample
(
collectEntity
,
new
PagingInfo
());
Integer
isCollect
=
0
;
if
(
collectEntities
.
isEmpty
()
||
CommonConstant
.
IsDeleted
.
N
.
equals
(
collectEntities
.
get
(
0
).
getIsCollect
()))
{
//如果没被收藏
// 收藏该应用
// 说明从来没收藏过
if
(
collectEntities
.
isEmpty
())
{
// 在用户收藏表中添加数据
BizMemberAgentApplicationCollectEntity
entity
=
new
BizMemberAgentApplicationCollectEntity
();
entity
.
setIsCollect
(
CommonConstant
.
IsDeleted
.
Y
);
entity
.
setMemberId
(
userBaseEntity
.
getUserId
().
intValue
());
entity
.
setAgentId
(
agentId
);
bizMemberAgentApplicationCollectService
.
save
(
entity
);
}
else
{
// 说明之前收藏过,则只需要做个修改
collectEntities
.
get
(
0
).
setIsCollect
(
CommonConstant
.
IsDeleted
.
Y
);
bizMemberAgentApplicationCollectService
.
update
(
collectEntities
.
get
(
0
));
}
isCollect
=
1
;
}
else
{
// 取消收藏该应用
collectEntities
.
get
(
0
).
setIsCollect
(
CommonConstant
.
IsDeleted
.
N
);
bizMemberAgentApplicationCollectService
.
update
(
collectEntities
.
get
(
0
));
isCollect
=
-
1
;
}
BizAgentApplicationPublishEntity
publishEntity
=
bizAgentApplicationPublishService
.
getByAgentId
(
agentId
);
if
(
publishEntity
==
null
)
{
logger
.
warn
(
"应用尚未发布,agentId:{}"
,
agentId
);
return
;
}
Integer
id
=
publishEntity
.
getId
();
BizAgentApplicationMallEntity
mallEntity
=
bizAgentApplicationMallService
.
getByAgentPublishId
(
id
);
if
(
mallEntity
==
null
||
CommonConstant
.
YOrN
.
N
.
equals
(
mallEntity
.
getIsSale
()))
{
logger
.
warn
(
"应用尚未上架,agentId:{}"
,
agentId
);
return
;
}
mallEntity
.
setCollectNumber
(
mallEntity
.
getCollectNumber
()
+
isCollect
);
bizAgentApplicationMallService
.
update
(
mallEntity
);
}
}
}
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