123
This commit is contained in:
@@ -57,6 +57,8 @@ public class ChatManager {
|
||||
private AccountService accountService;
|
||||
@Autowired
|
||||
private UserForbidManager userForbidManager;
|
||||
@Autowired
|
||||
private UserBlacklistService userBlacklistService;
|
||||
|
||||
private String setWsToken(Long roomId,Long fromUid,Long toUid,Long userId){
|
||||
String token = IdManager.nextIdStr();
|
||||
@@ -116,6 +118,10 @@ public class ChatManager {
|
||||
if(coin < anchor.getPrice()*2){
|
||||
throw new ServiceException("您的余额不足,请充值");
|
||||
}
|
||||
Boolean b = userBlacklistService.checkBlack(toUser.getId(), fromUser.getId());
|
||||
if(b){
|
||||
throw new ServiceException("对方拒绝接听");
|
||||
}
|
||||
Long roomId = null;
|
||||
Room room = webSocketManager.checkOnlineRoom(fromUser.getId(), toUser.getId());
|
||||
if(room == null){
|
||||
|
||||
@@ -32,4 +32,6 @@ public class AnchorAdminVo extends Anchor {
|
||||
|
||||
private Long cityId;
|
||||
private String city;
|
||||
|
||||
private Integer onlineStatus;
|
||||
}
|
||||
|
||||
@@ -7,6 +7,8 @@ import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class UserAdminVo extends User {
|
||||
|
||||
private Integer onlineStatus;
|
||||
/**
|
||||
* 最后登录IP
|
||||
*/
|
||||
|
||||
@@ -6,10 +6,7 @@ import com.ruoyi.cai.manager.SystemConfigManager;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.yunxin.client.ImUserClient;
|
||||
import com.ruoyi.yunxin.client.ImUserRefClient;
|
||||
import com.ruoyi.yunxin.req.BlockReq;
|
||||
import com.ruoyi.yunxin.req.MuteModuleReq;
|
||||
import com.ruoyi.yunxin.req.UnblockReq;
|
||||
import com.ruoyi.yunxin.req.UpdateUinfoReq;
|
||||
import com.ruoyi.yunxin.req.*;
|
||||
import com.ruoyi.yunxin.resp.YxCommonR;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -27,6 +24,24 @@ public class ImManager {
|
||||
@Resource
|
||||
private ImUserClient imUserClient;
|
||||
|
||||
public boolean blockUser(Long userId,Long blackUserId){
|
||||
SetSpecialRelationReq req = new SetSpecialRelationReq();
|
||||
req.setAccid(userId+"");
|
||||
req.setTargetAcc(blackUserId+"");
|
||||
req.setValue(1);
|
||||
YxCommonR res = userRefClient.setSpecialRelation(req);
|
||||
return res != null && res.isSuccess();
|
||||
}
|
||||
|
||||
public boolean unBlockUser(Long userId,Long blackUserId){
|
||||
SetSpecialRelationReq req = new SetSpecialRelationReq();
|
||||
req.setAccid(userId+"");
|
||||
req.setTargetAcc(blackUserId+"");
|
||||
req.setValue(0);
|
||||
YxCommonR res = userRefClient.setSpecialRelation(req);
|
||||
return res != null && res.isSuccess();
|
||||
}
|
||||
|
||||
public boolean enSpeck(Long userId){
|
||||
MuteModuleReq req = new MuteModuleReq();
|
||||
req.setMuteP2P(false);
|
||||
|
||||
@@ -70,6 +70,7 @@ public class HomeManager {
|
||||
AnchorListQuery query = new AnchorListQuery();
|
||||
// 0-默认查询 1-活跃查询 2-新人查询 3-同城查询
|
||||
query.setType(1);
|
||||
query.setOnlineStatus(1);
|
||||
query.setOpenVideoStatus(1);
|
||||
Page<AnchorListVo> app = anchorService.pageApp(pageQuery, query);
|
||||
List<AnchorListVo> records = app.getRecords();
|
||||
@@ -84,6 +85,7 @@ public class HomeManager {
|
||||
AnchorListQuery query = new AnchorListQuery();
|
||||
// 0-默认查询 1-活跃查询 2-新人查询 3-同城查询
|
||||
query.setType(2);
|
||||
query.setOnlineStatus(1);
|
||||
query.setOpenVideoStatus(1);
|
||||
Page<AnchorListVo> app = anchorService.pageApp(pageQuery, query);
|
||||
List<AnchorListVo> records = app.getRecords();
|
||||
@@ -122,6 +124,8 @@ public class HomeManager {
|
||||
List<AnchorListVo> result = vos.subList(startIndex, endIndex);
|
||||
if(anchorListQueryTypeEnum == AnchorListQueryTypeEnum.DEFAULT && pageNum == 1){
|
||||
List<AnchorListVo> list = getAnchorTopList();
|
||||
Collections.shuffle(list);
|
||||
list = list.subList(0,Math.min(4,list.size()));
|
||||
if(CollectionUtils.isNotEmpty(list)){
|
||||
List<Long> topUserIds = list.stream().map(AnchorListVo::getUserId).collect(Collectors.toList());
|
||||
result = result.stream().filter(anchorListVo -> !topUserIds.contains(anchorListVo.getUserId())).collect(Collectors.toList());
|
||||
|
||||
@@ -59,4 +59,6 @@ public interface UserService extends IService<User> {
|
||||
void noSpeckIm(Long userId);
|
||||
|
||||
void enSpeckIm(Long userId);
|
||||
|
||||
void logout(Long id);
|
||||
}
|
||||
|
||||
@@ -89,6 +89,6 @@ public class AnchorTopServiceImpl extends ServiceImpl<AnchorTopMapper,AnchorTop>
|
||||
|
||||
@Override
|
||||
public List<AnchorListVo> anchorTop(int limit) {
|
||||
return baseMapper.anchorTop(limit);
|
||||
return baseMapper.anchorTop(150);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,10 +5,13 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.ruoyi.cai.domain.UserBlacklist;
|
||||
import com.ruoyi.cai.dto.app.vo.user.UserListVo;
|
||||
import com.ruoyi.cai.executor.ExecutorConstant;
|
||||
import com.ruoyi.cai.im.ImManager;
|
||||
import com.ruoyi.cai.mapper.UserBlacklistMapper;
|
||||
import com.ruoyi.cai.service.UserBlacklistService;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
@@ -20,6 +23,8 @@ import org.springframework.stereotype.Service;
|
||||
@Service
|
||||
public class UserBlacklistServiceImpl extends ServiceImpl<UserBlacklistMapper, UserBlacklist> implements UserBlacklistService {
|
||||
|
||||
@Autowired
|
||||
private ImManager imManager;
|
||||
@Override
|
||||
public boolean existsBlack(Long userId,Long blackUserId){
|
||||
return this.exists(Wrappers.lambdaQuery(UserBlacklist.class)
|
||||
@@ -42,10 +47,16 @@ public class UserBlacklistServiceImpl extends ServiceImpl<UserBlacklistMapper, U
|
||||
userBlacklist.setBlackUid(blackUserId);
|
||||
this.save(userBlacklist);
|
||||
}
|
||||
ExecutorConstant.COMMON_EXECUTOR.execute(() -> {
|
||||
imManager.blockUser(userId,blackUserId);
|
||||
});
|
||||
}else { // 取消拉黑
|
||||
this.remove(Wrappers.lambdaQuery(UserBlacklist.class)
|
||||
.eq(UserBlacklist::getUserId,userId)
|
||||
.eq(UserBlacklist::getBlackUid,blackUserId));
|
||||
ExecutorConstant.COMMON_EXECUTOR.execute(() -> {
|
||||
imManager.unBlockUser(userId,blackUserId);
|
||||
});
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -432,4 +432,9 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void logout(Long id) {
|
||||
LoginHelper.logoutApp(id);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user