123
This commit is contained in:
@@ -144,6 +144,9 @@ public class DynamicController extends BaseController {
|
||||
@DeleteMapping("/{ids}")
|
||||
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||
@PathVariable Long[] ids) {
|
||||
return toAjax(dynamicService.removeBatchByIds(Arrays.asList(ids)));
|
||||
for (Long id : ids) {
|
||||
dynamicService.deleteDynamicAdmin(id);
|
||||
}
|
||||
return R.ok();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,6 @@ public class NoticeTest {
|
||||
System.out.println(JSON.toJSONString(rechargeTotalCache.getToday()));
|
||||
rechargeTotalCache.add(BigDecimal.valueOf(123));
|
||||
System.out.println(JSON.toJSONString(rechargeTotalCache.getToday()));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.ruoyi.test.business;
|
||||
import com.ruoyi.cai.domain.User;
|
||||
import com.ruoyi.cai.domain.UserCount;
|
||||
import com.ruoyi.cai.im.ImManager;
|
||||
import com.ruoyi.cai.service.DynamicService;
|
||||
import com.ruoyi.cai.service.UserCountService;
|
||||
import com.ruoyi.cai.service.UserService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -22,6 +23,14 @@ public class UserTest {
|
||||
private UserService userService;
|
||||
@Autowired
|
||||
private ImManager imManager;
|
||||
@Autowired
|
||||
private DynamicService dynamicService;
|
||||
|
||||
@Test
|
||||
public void clean(){
|
||||
dynamicService.clearDynamic(12);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void test(){
|
||||
@@ -35,7 +44,7 @@ public class UserTest {
|
||||
public void refreshIm(){
|
||||
List<User> list = userService.list();
|
||||
for (User user : list) {
|
||||
imManager.updateImInfo(user.getId(),user.getAvatar(),user.getNickname());
|
||||
imManager.updateImInfo(user.getId(),user.getAvatar(),user.getNickname(),user.getGender());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,11 +20,11 @@ public class ImManager {
|
||||
private SystemConfigManager systemConfigManager;
|
||||
@Resource
|
||||
private ImUserRefClient userRefClient;
|
||||
public void updateImInfo(Long userId, String avatar, String nickname){
|
||||
public void updateImInfo(Long userId, String avatar, String nickname,Integer gender){
|
||||
if(userId == null){
|
||||
return;
|
||||
}
|
||||
if(StringUtils.isBlank(avatar) && StringUtils.isBlank(nickname)){
|
||||
if(StringUtils.isBlank(avatar) && StringUtils.isBlank(nickname) && gender == null){
|
||||
return;
|
||||
}
|
||||
try {
|
||||
@@ -41,6 +41,9 @@ public class ImManager {
|
||||
if(StringUtils.isNotBlank(nickname)){
|
||||
uinfoReq.setName(nickname);
|
||||
}
|
||||
if(gender != null){
|
||||
uinfoReq.setGender(gender+"");
|
||||
}
|
||||
YxCommonR r = userRefClient.updateUinfo(uinfoReq);
|
||||
if(!r.isSuccess()){
|
||||
log.error("云信更新失败,【updateImInfo】需要检查!userId={},avatar={},nickname={} data={}",
|
||||
|
||||
@@ -17,6 +17,7 @@ import com.ruoyi.cai.enums.GenderEnum;
|
||||
import com.ruoyi.cai.enums.SystemConfigEnum;
|
||||
import com.ruoyi.cai.enums.user.UserPictureAuditType;
|
||||
import com.ruoyi.cai.executor.ExecutorConstant;
|
||||
import com.ruoyi.cai.im.ImManager;
|
||||
import com.ruoyi.cai.service.*;
|
||||
import com.ruoyi.cai.util.UserUtil;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
@@ -50,12 +51,16 @@ public class CurrentUserManager {
|
||||
private AccountService accountService;
|
||||
@Autowired
|
||||
private AccountBankcardService accountBankcardService;
|
||||
@Resource
|
||||
private ImUserRefClient userClient;
|
||||
@Autowired
|
||||
private UserPictureAuditService userPictureAuditService;
|
||||
@Autowired
|
||||
private SystemConfigManager systemConfigManager;
|
||||
@Autowired
|
||||
private CitysService citysService;
|
||||
@Autowired
|
||||
private CaiLoginManager loginManager;
|
||||
@Autowired
|
||||
private ImManager imManager;
|
||||
|
||||
public CurrentUserInfoVo currentInfo() {
|
||||
Long userId = LoginHelper.getUserId();
|
||||
@@ -166,6 +171,8 @@ public class CurrentUserManager {
|
||||
updateFlag=true;
|
||||
updateYunxin=true;
|
||||
}
|
||||
String imAvatar = null;
|
||||
Integer imGender = null;
|
||||
if(res.getGender() != null){
|
||||
GenderEnum genderEnum = GenderEnum.getByCode(res.getGender());
|
||||
if(genderEnum == null){
|
||||
@@ -174,11 +181,10 @@ public class CurrentUserManager {
|
||||
if(user.getGender() != 0 && !user.getGender().equals(res.getGender())){
|
||||
throw new ServiceException("性别不可以修改");
|
||||
}
|
||||
String cosDomain = systemConfigManager.getSystemConfig(SystemConfigEnum.COS_DOMAIN);
|
||||
update.set(User::getGender,genderEnum.getCode());
|
||||
update.set(User::getAvatar,genderEnum.getDefaultAvatar());
|
||||
uinfoReq.setGender(genderEnum.getCode()+"");
|
||||
uinfoReq.setIcon(cosDomain + genderEnum.getDefaultAvatar());
|
||||
imAvatar = systemConfigManager.getSystemConfig(SystemConfigEnum.COS_DOMAIN);
|
||||
imGender = genderEnum.getCode();
|
||||
updateFlag=true;
|
||||
updateYunxin=true;
|
||||
}
|
||||
@@ -201,10 +207,7 @@ public class CurrentUserManager {
|
||||
if(flag){
|
||||
userService.checkFinishStatus(res.getUserId());
|
||||
if(updateYunxin){
|
||||
YxCommonR r = userClient.updateUinfo(uinfoReq);
|
||||
if(!r.isSuccess()){
|
||||
log.error("云信更新失败,需要检查!{}", JSON.toJSONString(r));
|
||||
}
|
||||
imManager.updateImInfo(user.getId(), imAvatar,res.getNickname(), imGender);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -234,11 +237,6 @@ public class CurrentUserManager {
|
||||
accountBankcardService.saveOrUpdate(bankcard);
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private UserPictureAuditService userPictureAuditService;
|
||||
@Autowired
|
||||
private SystemConfigManager systemConfigManager;
|
||||
|
||||
public UserAvatarMinVo updateAvatar(UserUpdateAvatarReq res) {
|
||||
UserPictureAudit audit = userPictureAuditService.getOneUserAuditRunningPic(UserPictureAuditType.AVATAR.getCode(), res.getUserId());
|
||||
if(audit != null){
|
||||
@@ -268,7 +266,9 @@ public class CurrentUserManager {
|
||||
.set(User::getAvatar, res.getAvatar())
|
||||
.set(User::getAvatarState, 1));
|
||||
vo.setAuditStatus(AuditStatusEnum.SUCCESS.getCode());
|
||||
imManager.updateImInfo(res.getUserId(),res.getAvatar(),null,null);
|
||||
}
|
||||
return vo;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -13,6 +13,11 @@ public class LockManager {
|
||||
public static final String LOCK_SEND_GIFT_REDIS = RedisHttpConstant.REDIS_P + "lock:sendGift:%s";
|
||||
public static final String LOCK_VIDEO_SETTLE_REDIS = RedisHttpConstant.REDIS_P + "lock:videoSettle:%s";
|
||||
public static final String LOCK_ONLINE_LOGIN_NOTICE_REDIS = RedisHttpConstant.REDIS_P + "lockHand:loginFansNotice:%s";
|
||||
public static final String LOCK_USER_STAR_REDIS = RedisHttpConstant.REDIS_P + "userStar:%s-%s";
|
||||
|
||||
public static String getUserStarRedis(Long userId,Long starUserId){
|
||||
return String.format(LOCK_USER_STAR_REDIS,userId,starUserId);
|
||||
}
|
||||
|
||||
public static String getRegisterLockKey(String mobile){
|
||||
return String.format(LOCK_REGISTER_REDIS,mobile);
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.ruoyi.cai.dto.app.query.DynamicQuery;
|
||||
import com.ruoyi.cai.dto.app.query.IdRes;
|
||||
import com.ruoyi.cai.dto.app.vo.DynamicListVo;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -36,6 +37,9 @@ public interface DynamicService extends IService<Dynamic> {
|
||||
|
||||
void clearDynamic(Integer hours);
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
void deleteDynamicAdmin(Long id);
|
||||
|
||||
boolean auditSuccess(List<Long> ids);
|
||||
|
||||
boolean auditFail(Long id);
|
||||
|
||||
@@ -203,7 +203,7 @@ public class DynamicServiceImpl extends ServiceImpl<DynamicMapper, Dynamic> impl
|
||||
LocalDateTime deleteTimeFlag = LocalDateTime.now().plusHours(-hours);
|
||||
while (true){
|
||||
List<Dynamic> list = this.list(Wrappers.lambdaUpdate(Dynamic.class)
|
||||
.eq(Dynamic::getAuditStatus, AuditStatusEnum.AUDITING.getCode())
|
||||
.ne(Dynamic::getAuditStatus, AuditStatusEnum.AUDITING.getCode())
|
||||
.lt(Dynamic::getCreateTime, deleteTimeFlag)
|
||||
.isNull(Dynamic::getSort)
|
||||
.last("limit 100"));
|
||||
@@ -213,11 +213,18 @@ public class DynamicServiceImpl extends ServiceImpl<DynamicMapper, Dynamic> impl
|
||||
index++;
|
||||
for (Dynamic dynamic : list) {
|
||||
DynamicService dynamicService = SpringUtil.getBean(DynamicService.class);
|
||||
dynamicService.deleteDynamic(dynamic.getId());
|
||||
dynamicService.deleteDynamicAdmin(dynamic.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public void deleteDynamicAdmin(Long id){
|
||||
this.removeById(id);
|
||||
dynamicImagesService.removeByDynamicId(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean auditSuccess(List<Long> ids) {
|
||||
return this.update(Wrappers.lambdaUpdate(Dynamic.class)
|
||||
|
||||
@@ -12,6 +12,7 @@ import com.ruoyi.cai.dto.app.query.star.BatchStarReq;
|
||||
import com.ruoyi.cai.dto.app.vo.user.UserBaseVo;
|
||||
import com.ruoyi.cai.dto.app.vo.user.UserStarOrVisitorList;
|
||||
import com.ruoyi.cai.enums.GenderEnum;
|
||||
import com.ruoyi.cai.manager.LockManager;
|
||||
import com.ruoyi.cai.mapper.UserFollowMapper;
|
||||
import com.ruoyi.cai.notice.YunxinHttpService;
|
||||
import com.ruoyi.cai.service.UserCountService;
|
||||
@@ -23,6 +24,8 @@ import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.helper.LoginHelper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.redisson.api.RLock;
|
||||
import org.redisson.api.RedissonClient;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -51,6 +54,8 @@ public class UserFollowServiceImpl extends ServiceImpl<UserFollowMapper, UserFol
|
||||
private YunxinHttpService yunxinHttpService;
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
@Autowired
|
||||
private RedissonClient redissonClient;
|
||||
|
||||
@Override
|
||||
public Long getFansNumByUserId(Long userId){
|
||||
@@ -119,9 +124,17 @@ public class UserFollowServiceImpl extends ServiceImpl<UserFollowMapper, UserFol
|
||||
if(GenderEnum.MAN.getCode().equals(user.getGender()) && GenderEnum.MAN.getCode().equals(toUser.getGender())){
|
||||
throw new ServiceException("无法不能关注男用户哦");
|
||||
}
|
||||
this.remove(Wrappers.lambdaQuery(UserFollow.class)
|
||||
String userStarRedis = LockManager.getUserStarRedis(fromUserId, toUser.getId());
|
||||
RLock lock = redissonClient.getLock(userStarRedis);
|
||||
try {
|
||||
if(lock.isLocked()){
|
||||
throw new ServiceException("请勿频繁操作哦");
|
||||
}
|
||||
lock.lock();
|
||||
UserFollow one = this.getOne(Wrappers.lambdaQuery(UserFollow.class)
|
||||
.eq(UserFollow::getUserId, fromUserId)
|
||||
.eq(UserFollow::getFollowUser, starOrVisitorReq.getToUserId()));
|
||||
.eq(UserFollow::getFollowUser, toUser.getId()));
|
||||
if(one == null){
|
||||
UserFollow userFollow = new UserFollow();
|
||||
userFollow.setUserId(fromUserId);
|
||||
userFollow.setFollowUser(starOrVisitorReq.getToUserId());
|
||||
@@ -129,16 +142,38 @@ public class UserFollowServiceImpl extends ServiceImpl<UserFollowMapper, UserFol
|
||||
userCountService.star(fromUserId, starOrVisitorReq.getToUserId());
|
||||
// 给你关注的人发消息
|
||||
yunxinHttpService.followedSendMessage(starOrVisitorReq.getToUserId(), user, LocalDateTime.now());
|
||||
}
|
||||
}finally {
|
||||
try {
|
||||
lock.unlock();
|
||||
}catch (Exception e){
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean unStar(StarOrVisitorReq starOrVisitorReq) {
|
||||
Long fromUserId = LoginHelper.getUserId();
|
||||
this.remove(Wrappers.lambdaQuery(UserFollow.class)
|
||||
String userStarRedis = LockManager.getUserStarRedis(fromUserId, starOrVisitorReq.getToUserId());
|
||||
RLock lock = redissonClient.getLock(userStarRedis);
|
||||
try {
|
||||
if(lock.isLocked()){
|
||||
throw new ServiceException("请勿频繁操作哦");
|
||||
}
|
||||
lock.lock();
|
||||
boolean remove = this.remove(Wrappers.lambdaQuery(UserFollow.class)
|
||||
.eq(UserFollow::getUserId, fromUserId)
|
||||
.eq(UserFollow::getFollowUser, starOrVisitorReq.getToUserId()));
|
||||
if(remove){
|
||||
userCountService.unStar(fromUserId, starOrVisitorReq.getToUserId());
|
||||
}
|
||||
}finally {
|
||||
try {
|
||||
lock.unlock();
|
||||
}catch (Exception e){
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ public class UserPictureAuditServiceImpl extends ServiceImpl<UserPictureAuditMap
|
||||
.eq(User::getId, userPictureAudit.getUserId())
|
||||
.set(User::getAvatar, userPictureAudit.getUrl())
|
||||
.set(User::getAvatarState, 1));
|
||||
imManager.updateImInfo(userPictureAudit.getUserId(), userPictureAudit.getUrl(), null);
|
||||
imManager.updateImInfo(userPictureAudit.getUserId(), userPictureAudit.getUrl(), null,null);
|
||||
try {
|
||||
anchorApplyService.checkAnchorAuto(userPictureAudit.getUserId());
|
||||
}catch (Exception e){
|
||||
|
||||
@@ -290,7 +290,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
||||
if(!update){
|
||||
return;
|
||||
}
|
||||
imManager.updateImInfo(user.getId(), null, "用户" + user.getUsercode());
|
||||
imManager.updateImInfo(user.getId(), null, "用户" + user.getUsercode(),user.getGender());
|
||||
yunxinHttpService.nickAuditMessage(id);
|
||||
}
|
||||
|
||||
@@ -309,7 +309,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
||||
.eq(User::getId,user.getId())
|
||||
.set(User::getAvatar,genderEnum.getDefaultAvatar())
|
||||
.set(User::getAvatarState, 0));
|
||||
imManager.updateImInfo(user.getId(), genderEnum.getDefaultAvatar(), null);
|
||||
imManager.updateImInfo(user.getId(), genderEnum.getDefaultAvatar(), null,user.getGender());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user