Commit 0b3842cf authored by 罗林杰's avatar 罗林杰

Merge remote-tracking branch 'origin/master'

parents dae5ad48 2a652abf
......@@ -13,6 +13,7 @@ import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.media.Schema;
import org.rcisoft.business.memInfo.entity.MemFollowDTO;
import org.rcisoft.business.memInfo.entity.MemInfo;
import org.rcisoft.business.memInfo.entity.MemLikeDTO;
import org.rcisoft.business.memInfo.service.MemInfoService;
import org.rcisoft.core.anno.CyEncryptSm4Anno;
import org.rcisoft.core.anno.CyOpeLogAnno;
......@@ -255,7 +256,9 @@ public class AppMemInfoController extends CyPaginationController<MemInfo> {
memInfo);
}
/**
* 会员基础信息页面-修改个人资料
*/
@CyOpeLogAnno(title = "system-会员表管理-修改会员表", businessType = CyLogTypeEnum.UPDATE)
@Operation(summary="修改会员表", description="修改会员表")
@Parameters({@Parameter(name = "businessId", description = "businessId", required = false, schema = @Schema(type = "string"))})
......@@ -269,28 +272,63 @@ public class AppMemInfoController extends CyPaginationController<MemInfo> {
memInfo);
}
/**
* 会员详情页面-关注
*/
@CyOpeLogAnno(title = "system-会员关注-会员关注", businessType = CyLogTypeEnum.INSERT)
@Operation(summary="会员关注", description="会员关注")
@PostMapping(value = "/open/memInfo/follow")
@PostMapping(value = "/memInfo/follow")
@CyEncryptSm4Anno
public Integer follow( @RequestBody MemFollowDTO followDTO) {
return memInfoServiceImpl.addFollow(followDTO);
public CyResult follow( @RequestBody MemFollowDTO 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)
@Operation(summary="查询是否关注", description="查询是否关注")
@GetMapping(value = "/open/memInfo/isFollow")
@GetMapping(value = "/memInfo/isFollow")
@CyEncryptSm4Anno
public MemFollowDTO isFollow(MemFollowDTO followDTO) {
return memInfoServiceImpl.isFollow(followDTO);
public CyResult isFollow(MemFollowDTO 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)
@Operation(summary="会员取消关注", description="会员取消关注")
@PostMapping(value = "/open/memInfo/followDelete")
@PostMapping(value = "/memInfo/followDelete")
@CyEncryptSm4Anno
public Integer followDelete( @RequestBody MemFollowDTO followDTO) {
return memInfoServiceImpl.deleteFollow(followDTO);
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
public CyResult like( @RequestBody MemLikeDTO likeDTO) {
CyPersistModel data = memInfoServiceImpl.addLike(likeDTO);
return CyResultGenUtil.builder(data,
CyMessCons.MESSAGE_ALERT_SUCCESS,
CyMessCons.MESSAGE_ALERT_ERROR,
likeDTO);
}
}
package org.rcisoft.business.memInfo.bean;
/**
* Created with family.
* author: cy
* Date: 2024/5/25
* Time: 8:43 AM
* description:
*/
public class MemberInfoRedisBean {
//总共的点赞key
public static final String MEMBERINFO_USERLIKE_ALL = "memberInfo:userLike:all:";
//对每个人点赞的key
public static final String MEMBERINFO_USERLIKE = "memberInfo:userLike:";
}
......@@ -86,22 +86,36 @@ public interface MemInfoRepository extends CyBaseMapper<MemInfo> {
/**
* 查询加密字段
* @param businessId
* @param userId
* @return
*/
MemInfo getInfoByUserId(String userId);
/**
* 根据openid查询用户信息
* @param businessId
* @param openId
* @return
*/
MemInfo selectByOpenId(String openId);
/**
* 关注
*/
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 addLike(@Param("entity") MemLikeDTO likeDTO);
}
package org.rcisoft.business.memInfo.entity;
import lombok.Data;
@Data
public class MemLikeDTO {
private Integer userId;
private Integer targetId;
private Integer likeCount;
}
......@@ -91,9 +91,11 @@ public interface MemInfoService {
CyPersistModel update(MemInfo memInfo);
Integer addFollow(MemFollowDTO followDTO);
CyPersistModel addFollow(MemFollowDTO followDTO);
MemFollowDTO isFollow(MemFollowDTO followDTO);
Integer deleteFollow(MemFollowDTO followDTO);
CyPersistModel deleteFollow(MemFollowDTO followDTO);
CyPersistModel addLike(MemLikeDTO likeDTO);
}
......@@ -7,6 +7,7 @@ import org.apache.commons.lang3.StringUtils;
import org.rcisoft.alibaba.faceVerify.bean.FaceVerifyAliComp;
import org.rcisoft.alibaba.faceVerify.bean.FaceVerifyRedisBean;
import org.rcisoft.business.memInfo.bean.MemberGenerateBean;
import org.rcisoft.business.memInfo.bean.MemberInfoRedisBean;
import org.rcisoft.business.memInfo.entity.*;
import org.rcisoft.core.constant.CyDelStaCons;
import org.rcisoft.core.constant.CyFlagStaCons;
......@@ -18,6 +19,8 @@ import org.rcisoft.business.memInfo.dao.MemInfoRepository;
import org.rcisoft.business.memInfo.service.MemInfoService;
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.dto.SysUserRbacDTO;
import org.rcisoft.sys.rbac.user.entity.SysUserRbac;
......@@ -64,10 +67,11 @@ public class MemInfoServiceImpl extends ServiceImpl<MemInfoRepository,MemInfo>
private FaceVerifyAliComp faceVerifyAliComp;
@Autowired
private CyRedisService cyRedisServiceImpl;
@Autowired
private DictionaryService dictionaryService;
@Value("${cy.init.password}")
private String password;
/**
* 保存 会员表
* @param memInfo
......@@ -505,8 +509,9 @@ public class MemInfoServiceImpl extends ServiceImpl<MemInfoRepository,MemInfo>
*/
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT)
@Override
public Integer addFollow(MemFollowDTO followDTO){
return baseMapper.addFollow(followDTO);
public CyPersistModel addFollow(MemFollowDTO followDTO){
int line = baseMapper.addFollow(followDTO);
return new CyPersistModel(line);
}
/**
* 查询是否关注
......@@ -517,7 +522,7 @@ public class MemInfoServiceImpl extends ServiceImpl<MemInfoRepository,MemInfo>
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT)
@Override
public MemFollowDTO isFollow(MemFollowDTO followDTO){
return baseMapper.getFollow(followDTO);
return baseMapper.getIsFollow(followDTO);
}
/**
* 取消关注
......@@ -527,7 +532,61 @@ public class MemInfoServiceImpl extends ServiceImpl<MemInfoRepository,MemInfo>
*/
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT)
@Override
public Integer deleteFollow(MemFollowDTO followDTO){
return baseMapper.deleteFollow(followDTO);
public CyPersistModel deleteFollow(MemFollowDTO 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_ALL + userId);
//redis中 该用户对目标用户的点赞次数
Object redisCountToPersonal = cyRedisServiceImpl.hget(MemberInfoRedisBean.MEMBERINFO_USERLIKE + userId, String.valueOf(likeDTO.getTargetId()));
if (redisCountToAll == null && redisCountToPersonal == null){
//用户第一次进行点赞 设置redis缓存 24小时
//对所有用户的点赞次数存储
cyRedisServiceImpl.set(MemberInfoRedisBean.MEMBERINFO_USERLIKE_ALL + userId,1,86400L);
cyRedisServiceImpl.hset(MemberInfoRedisBean.MEMBERINFO_USERLIKE + userId, String.valueOf(likeDTO.getTargetId()),1,86400L);
likeDTO.setUserId(userId);
int line = baseMapper.addLike(likeDTO);
return new CyPersistModel(line);
} else if (redisCountToPersonal == null){
//用户对目标用户是第一次点赞
//判断点赞总数限制
if (((int)redisCountToAll < dicCountToAll)){
//条件限制都满足 点赞次数都+1
cyRedisServiceImpl.incr(MemberInfoRedisBean.MEMBERINFO_USERLIKE_ALL + userId, 1L);
cyRedisServiceImpl.hincr(MemberInfoRedisBean.MEMBERINFO_USERLIKE + userId, String.valueOf(likeDTO.getTargetId()), (double) 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_ALL + userId, 1L);
cyRedisServiceImpl.hincr(MemberInfoRedisBean.MEMBERINFO_USERLIKE + userId, String.valueOf(likeDTO.getTargetId()), (double) 1L);
} else {
throw new CyServiceException("点赞失败,今日对该用户的点赞次数已达上限");
}
} else {
throw new CyServiceException("点赞失败,今日点赞次数已达上限");
}
}
return new CyPersistModel(1);
}
}
......@@ -519,7 +519,7 @@
parameterType="java.lang.String">
select * from mem_info where wx_openid = #{openId} and del_flag = 0
</select>
<select id="getFollow" resultType="org.rcisoft.business.memInfo.entity.MemFollowDTO" parameterType="org.rcisoft.business.memInfo.entity.MemFollowDTO">
<select id="getIsFollow" 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
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>
......@@ -528,7 +528,11 @@
where user_id = #{entity.userId} and target_id = #{entity.targetId}
</delete>
<insert id="addFollow" parameterType="org.rcisoft.business.memInfo.entity.MemFollowDTO">
insert into opm_user_follow (target_id,user_id)
values(#{entity.targetId},#{entity.userId})
insert into opm_user_follow (target_id,user_id,create_date)
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>
</mapper>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment