Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
cust-api
Project
Project
Details
Activity
Releases
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
李伟
cust-api
Commits
1b942caf
Commit
1b942caf
authored
Jan 11, 2025
by
liwei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改了点赞接口
parent
76188298
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
47 additions
and
51 deletions
+47
-51
OpmArticleController.java
.../business/opmArticle/controller/OpmArticleController.java
+3
-15
OpmArticleRepository.java
...rcisoft/business/opmArticle/dao/OpmArticleRepository.java
+8
-1
OpmArticleService.java
...cisoft/business/opmArticle/service/OpmArticleService.java
+1
-9
OpmArticleServiceImpl.java
...siness/opmArticle/service/impl/OpmArticleServiceImpl.java
+22
-23
OpmArticleMapper.xml
...es/mapper/business/opmArticle/mapper/OpmArticleMapper.xml
+13
-3
No files found.
src/main/java/org/rcisoft/business/opmArticle/controller/OpmArticleController.java
View file @
1b942caf
...
...
@@ -155,21 +155,9 @@ public class OpmArticleController extends CyPaginationController<OpmArticle> {
/**
* 点赞增加点赞数
*/
@PostMapping
(
"/likeAdd/{articleId:\\w+}"
)
public
CyResult
likeAdd
(
@PathVariable
String
articleId
)
{
CyPersistModel
data
=
opmArticleServiceImpl
.
likeAdd
(
articleId
);
return
CyResultGenUtil
.
builder
(
data
,
CyMessCons
.
MESSAGE_ALERT_SUCCESS
,
CyMessCons
.
MESSAGE_ALERT_ERROR
,
articleId
);
}
/**
* 删除点赞中间表
*/
@PostMapping
(
"/likeDelete/{articleId:\\w+}"
)
public
CyResult
likeDelete
(
@PathVariable
String
articleId
)
{
CyPersistModel
data
=
opmArticleServiceImpl
.
likeDelete
(
articleId
);
@PostMapping
(
"/likeAdd"
)
public
CyResult
likeAdd
(
String
articleId
,
String
praiseType
)
{
CyPersistModel
data
=
opmArticleServiceImpl
.
likeAdd
(
articleId
,
praiseType
);
return
CyResultGenUtil
.
builder
(
data
,
CyMessCons
.
MESSAGE_ALERT_SUCCESS
,
CyMessCons
.
MESSAGE_ALERT_ERROR
,
...
...
src/main/java/org/rcisoft/business/opmArticle/dao/OpmArticleRepository.java
View file @
1b942caf
...
...
@@ -37,9 +37,16 @@ public interface OpmArticleRepository extends CyBaseMapper<OpmArticle> {
List
<
String
>
SelectPathList
(
Integer
businessId
);
//添加点赞记录
int
likeAdd
(
@Param
(
"entity"
)
LikeDTO
likeDTO
);
int
likeDelete
(
@Param
(
"entity"
)
LikeDTO
likeDTO
);
//删除点赞记录
int
likeDelete
(
@Param
(
"userId"
)
String
userId
,
@Param
(
"articleId"
)
String
articleId
);
//点赞数+1
int
addLikeCount
(
String
articleId
);
//点赞数-1
int
reduceLikeCount
(
String
articleId
);
}
src/main/java/org/rcisoft/business/opmArticle/service/OpmArticleService.java
View file @
1b942caf
...
...
@@ -84,14 +84,6 @@ public interface OpmArticleService {
* @param articleId
* @return
*/
CyPersistModel
likeAdd
(
String
articleId
);
/**
* 删除点赞中间表
* @param articleId
* @return
*/
CyPersistModel
likeDelete
(
String
articleId
);
CyPersistModel
likeAdd
(
String
articleId
,
String
praiseType
);
}
src/main/java/org/rcisoft/business/opmArticle/service/impl/OpmArticleServiceImpl.java
View file @
1b942caf
...
...
@@ -9,6 +9,7 @@ import org.rcisoft.business.opmArticle.entity.ArticleCommentDTO;
import
org.rcisoft.business.opmArticle.entity.LikeDTO
;
import
org.rcisoft.business.opmArticle.entity.OpmArticle
;
import
org.rcisoft.business.opmArticle.service.OpmArticleService
;
import
org.rcisoft.core.exception.CyServiceException
;
import
org.rcisoft.core.model.CyPageInfo
;
import
org.rcisoft.core.model.CyPersistModel
;
import
org.rcisoft.core.util.CyUserUtil
;
...
...
@@ -156,29 +157,27 @@ public class OpmArticleServiceImpl extends ServiceImpl<OpmArticleRepository, Opm
*/
@Transactional
(
propagation
=
Propagation
.
REQUIRED
,
isolation
=
Isolation
.
DEFAULT
)
@Override
public
CyPersistModel
likeAdd
(
String
articleId
){
//增加操作
LikeDTO
likeDTO
=
new
LikeDTO
();
likeDTO
.
setUserId
(
CyUserUtil
.
getAuthenBusinessId
());
likeDTO
.
setArticleId
(
articleId
);
int
line
=
baseMapper
.
likeAdd
(
likeDTO
);
return
new
CyPersistModel
(
line
);
}
/**
* 删除点赞中间表
* @param articleId
* @return
*/
@Transactional
(
propagation
=
Propagation
.
REQUIRED
,
isolation
=
Isolation
.
DEFAULT
)
@Override
public
CyPersistModel
likeDelete
(
String
articleId
){
//删除操作
LikeDTO
likeDTO
=
new
LikeDTO
();
likeDTO
.
setUserId
(
CyUserUtil
.
getAuthenBusinessId
());
likeDTO
.
setArticleId
(
articleId
);
int
line
=
baseMapper
.
likeDelete
(
likeDTO
);
public
CyPersistModel
likeAdd
(
String
articleId
,
String
praiseType
){
int
line
=
0
;
if
(
praiseType
.
equals
(
"praise"
)){
//点赞
//向点赞表增加一条数据
LikeDTO
likeDTO
=
new
LikeDTO
();
likeDTO
.
setUserId
(
CyUserUtil
.
getAuthenBusinessId
());
likeDTO
.
setArticleId
(
articleId
);
//增加主表该动态的点赞数
baseMapper
.
addLikeCount
(
articleId
);
line
=
baseMapper
.
likeAdd
(
likeDTO
);
}
else
if
(
praiseType
.
equals
(
"cancel"
)){
//取消点赞
//删除点赞表中的数据
String
userId
=
CyUserUtil
.
getAuthenBusinessId
();
baseMapper
.
likeDelete
(
userId
,
articleId
);
//修改主表中该动态的点赞数
line
=
baseMapper
.
reduceLikeCount
(
articleId
);
}
else
{
throw
new
CyServiceException
(
"点赞失败,请稍后再试"
);
}
return
new
CyPersistModel
(
line
);
}
...
...
src/main/resources/mapper/business/opmArticle/mapper/OpmArticleMapper.xml
View file @
1b942caf
...
...
@@ -17,6 +17,16 @@
<result
column=
"exam_status"
jdbcType=
"VARCHAR"
property=
"examStatus"
/>
<result
column=
"is_article"
jdbcType=
"VARCHAR"
property=
"isArticle"
/>
</resultMap>
<update
id=
"addLikeCount"
>
UPDATE opm_article
SET like_count = like_count + 1
WHERE business_id = #{articleId};
</update>
<update
id=
"reduceLikeCount"
>
UPDATE opm_article
SET like_count = like_count - 1
WHERE business_id = #{articleId};
</update>
<!--<cache type="${corePackag!}.util.RedisCache"/>-->
<select
id=
"queryOpmArticle"
resultMap=
"BaseResultMap"
>
...
...
@@ -109,7 +119,7 @@
opm_article.del_flag = '0'
) AS pic_ids ON opa.business_id = pic_ids.business_id
LEFT JOIN oss_info pic_urls ON pic_ids.picture_id = pic_urls.business_id
left join opm_user_like opl on opl.
business
_id = opa.business_id and opl.user_id = #{entity.userId}
left join opm_user_like opl on opl.
article
_id = opa.business_id and opl.user_id = #{entity.userId}
WHERE
opa.del_flag = '0'
<if
test=
"entity.flag !=null and entity.flag != '' "
>
...
...
@@ -199,8 +209,8 @@
update opm_article_comment set del_flag = '1' where business_id = #{businessId}
and del_flag = '0'
</delete>
<delete
id=
"likeDelete"
parameterType=
"org.rcisoft.business.opmArticle.entity.
LikeDTO
"
>
delete from opm_user_like where user_id = #{
entity.userId} and article_id = #{entity.
articleId}
<delete
id=
"likeDelete"
parameterType=
"org.rcisoft.business.opmArticle.entity.
OpmArticle
"
>
delete from opm_user_like where user_id = #{
userId} and article_id = #{
articleId}
</delete>
<insert
id=
"likeAdd"
parameterType=
"org.rcisoft.business.opmArticle.entity.OpmArticle"
>
insert into opm_user_like (user_id, article_id,create_date)
...
...
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