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
ac09c0c2
Commit
ac09c0c2
authored
Jan 20, 2025
by
liwei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增了用户点赞功能
parent
76b085ab
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
152 additions
and
23 deletions
+152
-23
AppMemInfoController.java
...isoft/app/appMemInfo/controller/AppMemInfoController.java
+35
-9
MemberInfoRedisBean.java
...rg/rcisoft/business/memInfo/bean/MemberInfoRedisBean.java
+14
-0
MemInfoRepository.java
...a/org/rcisoft/business/memInfo/dao/MemInfoRepository.java
+17
-3
MemLikeDTO.java
.../java/org/rcisoft/business/memInfo/entity/MemLikeDTO.java
+13
-0
MemInfoService.java
.../org/rcisoft/business/memInfo/service/MemInfoService.java
+4
-2
MemInfoServiceImpl.java
...oft/business/memInfo/service/impl/MemInfoServiceImpl.java
+62
-6
MemInfoMapper.xml
...esources/mapper/business/memInfo/mapper/MemInfoMapper.xml
+7
-3
No files found.
src/main/java/org/rcisoft/app/appMemInfo/controller/AppMemInfoController.java
View file @
ac09c0c2
...
@@ -13,6 +13,7 @@ import io.swagger.v3.oas.annotations.Parameters;
...
@@ -13,6 +13,7 @@ import io.swagger.v3.oas.annotations.Parameters;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
org.rcisoft.business.memInfo.entity.MemFollowDTO
;
import
org.rcisoft.business.memInfo.entity.MemFollowDTO
;
import
org.rcisoft.business.memInfo.entity.MemInfo
;
import
org.rcisoft.business.memInfo.entity.MemInfo
;
import
org.rcisoft.business.memInfo.entity.MemLikeDTO
;
import
org.rcisoft.business.memInfo.service.MemInfoService
;
import
org.rcisoft.business.memInfo.service.MemInfoService
;
import
org.rcisoft.core.anno.CyEncryptSm4Anno
;
import
org.rcisoft.core.anno.CyEncryptSm4Anno
;
import
org.rcisoft.core.anno.CyOpeLogAnno
;
import
org.rcisoft.core.anno.CyOpeLogAnno
;
...
@@ -272,25 +273,50 @@ public class AppMemInfoController extends CyPaginationController<MemInfo> {
...
@@ -272,25 +273,50 @@ public class AppMemInfoController extends CyPaginationController<MemInfo> {
@CyOpeLogAnno
(
title
=
"system-会员关注-会员关注"
,
businessType
=
CyLogTypeEnum
.
INSERT
)
@CyOpeLogAnno
(
title
=
"system-会员关注-会员关注"
,
businessType
=
CyLogTypeEnum
.
INSERT
)
@Operation
(
summary
=
"会员关注"
,
description
=
"会员关注"
)
@Operation
(
summary
=
"会员关注"
,
description
=
"会员关注"
)
@PostMapping
(
value
=
"/
open/
memInfo/follow"
)
@PostMapping
(
value
=
"/memInfo/follow"
)
@CyEncryptSm4Anno
@CyEncryptSm4Anno
public
Integer
follow
(
@RequestBody
MemFollowDTO
followDTO
)
{
public
CyResult
follow
(
@RequestBody
MemFollowDTO
followDTO
)
{
return
memInfoServiceImpl
.
addFollow
(
followDTO
);
CyPersistModel
data
=
memInfoServiceImpl
.
addFollow
(
followDTO
);
return
CyResultGenUtil
.
builder
(
data
,
CyMessCons
.
MESSAGE_ALERT_SUCCESS
,
CyMessCons
.
MESSAGE_ALERT_ERROR
,
followDTO
);
}
}
@CyOpeLogAnno
(
title
=
"system-会员关注-查询是否关注"
,
businessType
=
CyLogTypeEnum
.
QUERY
)
@CyOpeLogAnno
(
title
=
"system-会员关注-查询是否关注"
,
businessType
=
CyLogTypeEnum
.
QUERY
)
@Operation
(
summary
=
"查询是否关注"
,
description
=
"查询是否关注"
)
@Operation
(
summary
=
"查询是否关注"
,
description
=
"查询是否关注"
)
@GetMapping
(
value
=
"/
open/
memInfo/isFollow"
)
@GetMapping
(
value
=
"/memInfo/isFollow"
)
@CyEncryptSm4Anno
@CyEncryptSm4Anno
public
MemFollowDTO
isFollow
(
MemFollowDTO
followDTO
)
{
public
CyResult
isFollow
(
MemFollowDTO
followDTO
)
{
return
memInfoServiceImpl
.
isFollow
(
followDTO
);
MemFollowDTO
follow
=
memInfoServiceImpl
.
isFollow
(
followDTO
);
return
CyResultGenUtil
.
builder
(
new
CyPersistModel
(
1
),
CyMessCons
.
MESSAGE_ALERT_SUCCESS
,
CyMessCons
.
MESSAGE_ALERT_ERROR
,
follow
);
}
}
@CyOpeLogAnno
(
title
=
"system-会员取消关注-会员取消关注"
,
businessType
=
CyLogTypeEnum
.
INSERT
)
@CyOpeLogAnno
(
title
=
"system-会员取消关注-会员取消关注"
,
businessType
=
CyLogTypeEnum
.
INSERT
)
@Operation
(
summary
=
"会员取消关注"
,
description
=
"会员取消关注"
)
@Operation
(
summary
=
"会员取消关注"
,
description
=
"会员取消关注"
)
@PostMapping
(
value
=
"/open/memInfo/followDelete"
)
@PostMapping
(
value
=
"/memInfo/followDelete"
)
@CyEncryptSm4Anno
public
CyResult
followDelete
(
@RequestBody
MemFollowDTO
followDTO
)
{
CyPersistModel
data
=
memInfoServiceImpl
.
deleteFollow
(
followDTO
);
return
CyResultGenUtil
.
builder
(
data
,
CyMessCons
.
MESSAGE_ALERT_SUCCESS
,
CyMessCons
.
MESSAGE_ALERT_ERROR
,
followDTO
);
}
@CyOpeLogAnno
(
title
=
"system-会员点赞-会员点赞"
,
businessType
=
CyLogTypeEnum
.
INSERT
)
@Operation
(
summary
=
"会员点赞"
,
description
=
"会员点赞"
)
@PostMapping
(
value
=
"/memInfo/like"
)
@CyEncryptSm4Anno
@CyEncryptSm4Anno
public
Integer
followDelete
(
@RequestBody
MemFollowDTO
followDTO
)
{
public
CyResult
like
(
@RequestBody
MemLikeDTO
likeDTO
)
{
return
memInfoServiceImpl
.
deleteFollow
(
followDTO
);
CyPersistModel
data
=
memInfoServiceImpl
.
addLike
(
likeDTO
);
return
CyResultGenUtil
.
builder
(
data
,
CyMessCons
.
MESSAGE_ALERT_SUCCESS
,
CyMessCons
.
MESSAGE_ALERT_ERROR
,
likeDTO
);
}
}
}
}
src/main/java/org/rcisoft/business/memInfo/bean/MemberInfoRedisBean.java
0 → 100644
View file @
ac09c0c2
package
org
.
rcisoft
.
business
.
memInfo
.
bean
;
/**
* Created with family.
* author: cy
* Date: 2024/5/25
* Time: 8:43 AM
* description:
*/
public
class
MemberInfoRedisBean
{
public
static
final
String
MEMBERINFO_USERLIKE
=
"memberInfo:userLike:"
;
}
src/main/java/org/rcisoft/business/memInfo/dao/MemInfoRepository.java
View file @
ac09c0c2
...
@@ -86,22 +86,36 @@ public interface MemInfoRepository extends CyBaseMapper<MemInfo> {
...
@@ -86,22 +86,36 @@ public interface MemInfoRepository extends CyBaseMapper<MemInfo> {
/**
/**
* 查询加密字段
* 查询加密字段
* @param
business
Id
* @param
user
Id
* @return
* @return
*/
*/
MemInfo
getInfoByUserId
(
String
userId
);
MemInfo
getInfoByUserId
(
String
userId
);
/**
/**
* 根据openid查询用户信息
* 根据openid查询用户信息
* @param
business
Id
* @param
open
Id
* @return
* @return
*/
*/
MemInfo
selectByOpenId
(
String
openId
);
MemInfo
selectByOpenId
(
String
openId
);
/**
* 关注
*/
Integer
addFollow
(
@Param
(
"entity"
)
MemFollowDTO
followDTO
);
Integer
addFollow
(
@Param
(
"entity"
)
MemFollowDTO
followDTO
);
MemFollowDTO
getFollow
(
@Param
(
"entity"
)
MemFollowDTO
followDTO
);
/**
* 查看是否已关注
*/
MemFollowDTO
getIsFollow
(
@Param
(
"entity"
)
MemFollowDTO
followDTO
);
/**
* 删除关注
*/
Integer
deleteFollow
(
@Param
(
"entity"
)
MemFollowDTO
followDTO
);
Integer
deleteFollow
(
@Param
(
"entity"
)
MemFollowDTO
followDTO
);
/**
* 点赞
*/
Integer
addLike
(
@Param
(
"entity"
)
MemLikeDTO
likeDTO
);
}
}
src/main/java/org/rcisoft/business/memInfo/entity/MemLikeDTO.java
0 → 100644
View file @
ac09c0c2
package
org
.
rcisoft
.
business
.
memInfo
.
entity
;
import
lombok.Data
;
@Data
public
class
MemLikeDTO
{
private
Integer
userId
;
private
Integer
targetId
;
private
Integer
likeCount
;
}
src/main/java/org/rcisoft/business/memInfo/service/MemInfoService.java
View file @
ac09c0c2
...
@@ -91,9 +91,11 @@ public interface MemInfoService {
...
@@ -91,9 +91,11 @@ public interface MemInfoService {
CyPersistModel
update
(
MemInfo
memInfo
);
CyPersistModel
update
(
MemInfo
memInfo
);
Integer
addFollow
(
MemFollowDTO
followDTO
);
CyPersistModel
addFollow
(
MemFollowDTO
followDTO
);
MemFollowDTO
isFollow
(
MemFollowDTO
followDTO
);
MemFollowDTO
isFollow
(
MemFollowDTO
followDTO
);
Integer
deleteFollow
(
MemFollowDTO
followDTO
);
CyPersistModel
deleteFollow
(
MemFollowDTO
followDTO
);
CyPersistModel
addLike
(
MemLikeDTO
likeDTO
);
}
}
src/main/java/org/rcisoft/business/memInfo/service/impl/MemInfoServiceImpl.java
View file @
ac09c0c2
...
@@ -7,6 +7,7 @@ import org.apache.commons.lang3.StringUtils;
...
@@ -7,6 +7,7 @@ import org.apache.commons.lang3.StringUtils;
import
org.rcisoft.alibaba.faceVerify.bean.FaceVerifyAliComp
;
import
org.rcisoft.alibaba.faceVerify.bean.FaceVerifyAliComp
;
import
org.rcisoft.alibaba.faceVerify.bean.FaceVerifyRedisBean
;
import
org.rcisoft.alibaba.faceVerify.bean.FaceVerifyRedisBean
;
import
org.rcisoft.business.memInfo.bean.MemberGenerateBean
;
import
org.rcisoft.business.memInfo.bean.MemberGenerateBean
;
import
org.rcisoft.business.memInfo.bean.MemberInfoRedisBean
;
import
org.rcisoft.business.memInfo.entity.*
;
import
org.rcisoft.business.memInfo.entity.*
;
import
org.rcisoft.core.constant.CyDelStaCons
;
import
org.rcisoft.core.constant.CyDelStaCons
;
import
org.rcisoft.core.constant.CyFlagStaCons
;
import
org.rcisoft.core.constant.CyFlagStaCons
;
...
@@ -18,6 +19,8 @@ import org.rcisoft.business.memInfo.dao.MemInfoRepository;
...
@@ -18,6 +19,8 @@ import org.rcisoft.business.memInfo.dao.MemInfoRepository;
import
org.rcisoft.business.memInfo.service.MemInfoService
;
import
org.rcisoft.business.memInfo.service.MemInfoService
;
import
org.rcisoft.sys.constant.CyUserCons
;
import
org.rcisoft.sys.constant.CyUserCons
;
import
org.rcisoft.sys.dictionary.entity.DictData
;
import
org.rcisoft.sys.dictionary.service.DictionaryService
;
import
org.rcisoft.sys.rbac.user.dao.SysUserRbacRepository
;
import
org.rcisoft.sys.rbac.user.dao.SysUserRbacRepository
;
import
org.rcisoft.sys.rbac.user.dto.SysUserRbacDTO
;
import
org.rcisoft.sys.rbac.user.dto.SysUserRbacDTO
;
import
org.rcisoft.sys.rbac.user.entity.SysUserRbac
;
import
org.rcisoft.sys.rbac.user.entity.SysUserRbac
;
...
@@ -64,10 +67,11 @@ public class MemInfoServiceImpl extends ServiceImpl<MemInfoRepository,MemInfo>
...
@@ -64,10 +67,11 @@ public class MemInfoServiceImpl extends ServiceImpl<MemInfoRepository,MemInfo>
private
FaceVerifyAliComp
faceVerifyAliComp
;
private
FaceVerifyAliComp
faceVerifyAliComp
;
@Autowired
@Autowired
private
CyRedisService
cyRedisServiceImpl
;
private
CyRedisService
cyRedisServiceImpl
;
@Autowired
private
DictionaryService
dictionaryService
;
@Value
(
"${cy.init.password}"
)
@Value
(
"${cy.init.password}"
)
private
String
password
;
private
String
password
;
/**
/**
* 保存 会员表
* 保存 会员表
* @param memInfo
* @param memInfo
...
@@ -505,8 +509,9 @@ public class MemInfoServiceImpl extends ServiceImpl<MemInfoRepository,MemInfo>
...
@@ -505,8 +509,9 @@ public class MemInfoServiceImpl extends ServiceImpl<MemInfoRepository,MemInfo>
*/
*/
@Transactional
(
propagation
=
Propagation
.
REQUIRED
,
isolation
=
Isolation
.
DEFAULT
)
@Transactional
(
propagation
=
Propagation
.
REQUIRED
,
isolation
=
Isolation
.
DEFAULT
)
@Override
@Override
public
Integer
addFollow
(
MemFollowDTO
followDTO
){
public
CyPersistModel
addFollow
(
MemFollowDTO
followDTO
){
return
baseMapper
.
addFollow
(
followDTO
);
int
line
=
baseMapper
.
addFollow
(
followDTO
);
return
new
CyPersistModel
(
line
);
}
}
/**
/**
* 查询是否关注
* 查询是否关注
...
@@ -517,7 +522,7 @@ public class MemInfoServiceImpl extends ServiceImpl<MemInfoRepository,MemInfo>
...
@@ -517,7 +522,7 @@ public class MemInfoServiceImpl extends ServiceImpl<MemInfoRepository,MemInfo>
@Transactional
(
propagation
=
Propagation
.
REQUIRED
,
isolation
=
Isolation
.
DEFAULT
)
@Transactional
(
propagation
=
Propagation
.
REQUIRED
,
isolation
=
Isolation
.
DEFAULT
)
@Override
@Override
public
MemFollowDTO
isFollow
(
MemFollowDTO
followDTO
){
public
MemFollowDTO
isFollow
(
MemFollowDTO
followDTO
){
return
baseMapper
.
getFollow
(
followDTO
);
return
baseMapper
.
get
Is
Follow
(
followDTO
);
}
}
/**
/**
* 取消关注
* 取消关注
...
@@ -527,7 +532,58 @@ public class MemInfoServiceImpl extends ServiceImpl<MemInfoRepository,MemInfo>
...
@@ -527,7 +532,58 @@ public class MemInfoServiceImpl extends ServiceImpl<MemInfoRepository,MemInfo>
*/
*/
@Transactional
(
propagation
=
Propagation
.
REQUIRED
,
isolation
=
Isolation
.
DEFAULT
)
@Transactional
(
propagation
=
Propagation
.
REQUIRED
,
isolation
=
Isolation
.
DEFAULT
)
@Override
@Override
public
Integer
deleteFollow
(
MemFollowDTO
followDTO
){
public
CyPersistModel
deleteFollow
(
MemFollowDTO
followDTO
){
return
baseMapper
.
deleteFollow
(
followDTO
);
Integer
line
=
baseMapper
.
deleteFollow
(
followDTO
);
return
new
CyPersistModel
(
line
);
}
/***/
@Override
public
CyPersistModel
addLike
(
MemLikeDTO
likeDTO
)
{
Integer
userId
=
Integer
.
valueOf
(
CyUserUtil
.
getAuthenBusinessId
());
//点赞配置 分为两种
List
<
DictData
>
userLikeConfig
=
dictionaryService
.
selectByTypes
(
"user_like_config"
);
//一天最多给所有用户点赞的总次数
Integer
dicCountToAll
=
Integer
.
valueOf
(
userLikeConfig
.
get
(
0
).
getDictValue
());
//一天最多给某个人点赞的总次数
Integer
dicCountToPersonal
=
Integer
.
valueOf
(
userLikeConfig
.
get
(
1
).
getDictValue
());
//redis中 该用户对所有用户的点赞次数
Object
redisCountToAll
=
cyRedisServiceImpl
.
get
(
MemberInfoRedisBean
.
MEMBERINFO_USERLIKE
+
userId
);
//redis中 该用户对目标用户的点赞次数
Object
redisCountToPersonal
=
cyRedisServiceImpl
.
get
(
MemberInfoRedisBean
.
MEMBERINFO_USERLIKE
+
userId
+
":to:"
+
likeDTO
.
getTargetId
());
if
(
redisCountToAll
==
null
&&
redisCountToPersonal
==
null
){
//用户第一次进行点赞 设置redis缓存 24小时
//对所有用户的点赞次数存储
cyRedisServiceImpl
.
set
(
MemberInfoRedisBean
.
MEMBERINFO_USERLIKE
+
userId
,
1
,
86400L
);
cyRedisServiceImpl
.
set
(
MemberInfoRedisBean
.
MEMBERINFO_USERLIKE
+
userId
+
":to:"
+
likeDTO
.
getTargetId
(),
1
,
86400L
);
}
else
if
(
redisCountToPersonal
==
null
){
//用户对目标用户是第一次点赞
//判断点赞总数限制
if
(((
int
)
redisCountToAll
<
dicCountToAll
)){
//条件限制都满足 点赞次数都+1
cyRedisServiceImpl
.
incr
(
MemberInfoRedisBean
.
MEMBERINFO_USERLIKE
+
userId
,
1L
);
cyRedisServiceImpl
.
incr
(
MemberInfoRedisBean
.
MEMBERINFO_USERLIKE
+
userId
+
":to:"
+
likeDTO
.
getTargetId
(),
1L
);
likeDTO
.
setUserId
(
userId
);
int
line
=
baseMapper
.
addLike
(
likeDTO
);
return
new
CyPersistModel
(
line
);
}
else
{
throw
new
CyServiceException
(
"点赞失败,今日点赞次数已达上限"
);
}
}
else
if
(
redisCountToPersonal
!=
null
){
//判断点赞总数限制
if
(((
int
)
redisCountToAll
<
dicCountToAll
)){
//判断个人点赞次数限制
if
((
int
)
redisCountToPersonal
<
dicCountToPersonal
){
//条件限制都满足 点赞次数都+1
cyRedisServiceImpl
.
incr
(
MemberInfoRedisBean
.
MEMBERINFO_USERLIKE
+
userId
,
1L
);
cyRedisServiceImpl
.
incr
(
MemberInfoRedisBean
.
MEMBERINFO_USERLIKE
+
userId
+
":to:"
+
likeDTO
.
getTargetId
(),
1L
);
}
else
{
throw
new
CyServiceException
(
"点赞失败,今日对该用户的点赞次数已达上限"
);
}
}
else
{
throw
new
CyServiceException
(
"点赞失败,今日点赞次数已达上限"
);
}
}
return
new
CyPersistModel
(
1
);
}
}
}
}
src/main/resources/mapper/business/memInfo/mapper/MemInfoMapper.xml
View file @
ac09c0c2
...
@@ -519,7 +519,7 @@
...
@@ -519,7 +519,7 @@
parameterType=
"java.lang.String"
>
parameterType=
"java.lang.String"
>
select * from mem_info where wx_openid = #{openId} and del_flag = 0
select * from mem_info where wx_openid = #{openId} and del_flag = 0
</select>
</select>
<select
id=
"getFollow"
resultType=
"org.rcisoft.business.memInfo.entity.MemFollowDTO"
parameterType=
"org.rcisoft.business.memInfo.entity.MemFollowDTO"
>
<select
id=
"get
Is
Follow"
resultType=
"org.rcisoft.business.memInfo.entity.MemFollowDTO"
parameterType=
"org.rcisoft.business.memInfo.entity.MemFollowDTO"
>
SELECT MAX(CASE WHEN ouf.business_id IS NOT NULL THEN 1 ELSE 0 END) AS isFollowed
SELECT MAX(CASE WHEN ouf.business_id IS NOT NULL THEN 1 ELSE 0 END) AS isFollowed
FROM (SELECT 1 AS dummy) d LEFT JOIN opm_user_follow ouf ON ouf.user_id = #{entity.userId} AND ouf.target_id = #{entity.targetId};
FROM (SELECT 1 AS dummy) d LEFT JOIN opm_user_follow ouf ON ouf.user_id = #{entity.userId} AND ouf.target_id = #{entity.targetId};
</select>
</select>
...
@@ -528,7 +528,11 @@
...
@@ -528,7 +528,11 @@
where user_id = #{entity.userId} and target_id = #{entity.targetId}
where user_id = #{entity.userId} and target_id = #{entity.targetId}
</delete>
</delete>
<insert
id=
"addFollow"
parameterType=
"org.rcisoft.business.memInfo.entity.MemFollowDTO"
>
<insert
id=
"addFollow"
parameterType=
"org.rcisoft.business.memInfo.entity.MemFollowDTO"
>
insert into opm_user_follow (target_id,user_id)
insert into opm_user_follow (target_id,user_id,create_date)
values(#{entity.targetId},#{entity.userId})
values(#{entity.targetId},#{entity.userId},NOW())
</insert>
<insert
id=
"addLike"
parameterType=
"org.rcisoft.business.memInfo.entity.MemLikeDTO"
>
insert into opm_user_like (target_id,user_id,create_date,like_count)
values(#{entity.targetId},#{entity.userId},NOW(),#{entity.likeCount})
</insert>
</insert>
</mapper>
</mapper>
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