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
3fb7c06e
Commit
3fb7c06e
authored
Nov 04, 2024
by
alex yao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 修复 Agent应用收藏计数问题
parent
6e1cc5e4
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
7 deletions
+33
-7
AgentApplicationInfoServiceImpl.java
...ation/aggregate/impl/AgentApplicationInfoServiceImpl.java
+17
-0
AgentApplicationMallServiceImpl.java
...ation/aggregate/impl/AgentApplicationMallServiceImpl.java
+16
-7
No files found.
src/main/java/cn/com/poc/agent_application/aggregate/impl/AgentApplicationInfoServiceImpl.java
View file @
3fb7c06e
...
...
@@ -719,6 +719,7 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ
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
()))
{
//如果没被收藏
// 收藏该应用
// 说明从来没收藏过
...
...
@@ -733,10 +734,26 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ
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
)
{
logger
.
warn
(
"应用尚未上架,agentId:{}"
,
agentId
);
return
;
}
mallEntity
.
setCollectNumber
(
mallEntity
.
getCollectNumber
()
+
isCollect
);
bizAgentApplicationMallService
.
update
(
mallEntity
);
}
}
src/main/java/cn/com/poc/agent_application/aggregate/impl/AgentApplicationMallServiceImpl.java
View file @
3fb7c06e
...
...
@@ -13,11 +13,13 @@ import cn.com.poc.common.constant.CommonConstant;
import
cn.com.poc.common.utils.BlContext
;
import
cn.com.poc.support.security.oauth.entity.UserBaseEntity
;
import
cn.com.yict.framemax.core.exception.BusinessException
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.annotation.Resource
;
import
java.util.List
;
@Service
public
class
AgentApplicationMallServiceImpl
implements
AgentApplicationMallService
{
...
...
@@ -41,33 +43,40 @@ public class AgentApplicationMallServiceImpl implements AgentApplicationMallServ
}
BizAgentApplicationMallEntity
mallEntity
=
bizAgentApplicationMallService
.
get
(
id
);
if
(
mallEntity
==
null
)
{
if
(
mallEntity
==
null
)
{
throw
new
BusinessException
(
"应用不存在"
);
}
BizAgentApplicationPublishEntity
publishEntity
=
bizAgentApplicationPublishService
.
get
(
mallEntity
.
getAgentPublishId
());
if
(
publishEntity
==
null
)
{
if
(
publishEntity
==
null
)
{
throw
new
BusinessException
(
"应用未发布"
);
}
// 先判断当前应用被收藏了吗
BizMemberAgentApplicationCollectEntity
collectEntity
=
bizMemberAgentApplicationCollectService
.
getByAgentId
(
publishEntity
.
getAgentId
());
if
(
collectEntity
==
null
||
CommonConstant
.
IsDeleted
.
N
.
equals
(
collectEntity
.
getIsCollect
())){
//如果没被收藏
BizMemberAgentApplicationCollectEntity
bizMemberAgentApplicationCollectEntity
=
new
BizMemberAgentApplicationCollectEntity
();
bizMemberAgentApplicationCollectEntity
.
setMemberId
(
userBaseEntity
.
getUserId
().
intValue
());
bizMemberAgentApplicationCollectEntity
.
setAgentId
(
publishEntity
.
getAgentId
());
bizMemberAgentApplicationCollectEntity
.
setIsDeleted
(
CommonConstant
.
IsDeleted
.
N
);
List
<
BizMemberAgentApplicationCollectEntity
>
collectEntities
=
bizMemberAgentApplicationCollectService
.
findByExample
(
bizMemberAgentApplicationCollectEntity
,
null
);
if
(
CollectionUtils
.
isEmpty
(
collectEntities
)
||
CommonConstant
.
IsDeleted
.
N
.
equals
(
collectEntities
.
get
(
0
).
getIsCollect
()))
{
//如果没被收藏
// 收藏该应用
// 说明从来没收藏过
if
(
collectEntity
==
null
)
{
if
(
CollectionUtils
.
isEmpty
(
collectEntities
))
{
// 在用户收藏表中添加数据
BizMemberAgentApplicationCollectEntity
entity
=
new
BizMemberAgentApplicationCollectEntity
();
entity
.
setIsCollect
(
CommonConstant
.
IsDeleted
.
Y
);
entity
.
setMemberId
(
userBaseEntity
.
getUserId
().
intValue
());
entity
.
setAgentId
(
publishEntity
.
getAgentId
());
bizMemberAgentApplicationCollectService
.
save
(
entity
);
}
else
{
// 说明之前收藏过,则只需要做个修改
}
else
{
// 说明之前收藏过,则只需要做个修改
BizMemberAgentApplicationCollectEntity
collectEntity
=
collectEntities
.
get
(
0
);
collectEntity
.
setIsCollect
(
CommonConstant
.
IsDeleted
.
Y
);
bizMemberAgentApplicationCollectService
.
update
(
collectEntity
);
}
// 在应用广场的应用中 添加收藏数
mallEntity
.
setCollectNumber
(
mallEntity
.
getCollectNumber
()
+
1
);
}
else
{
}
else
{
BizMemberAgentApplicationCollectEntity
collectEntity
=
collectEntities
.
get
(
0
);
// 取消收藏该应用
collectEntity
.
setIsCollect
(
CommonConstant
.
IsDeleted
.
N
);
bizMemberAgentApplicationCollectService
.
update
(
collectEntity
);
...
...
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