补全交互操作
This commit is contained in:
parent
be76f65252
commit
6022eb4752
@ -25,7 +25,7 @@ public class GlobalConfigController {
|
||||
@ApiOperation("查询WebSocket配置")
|
||||
@GetMapping("/admin/common/getWebSocketConf")
|
||||
public CommonResult<WebSocketConfigVO> getWebSocketConf(
|
||||
@RequestParam("type") @Validated @NotNull @Min(1) @ApiParam(required = true, value = "产品类型:3直播互动;9交易圈") Integer type,
|
||||
@RequestParam("type") @Validated @NotNull @Min(1) @ApiParam(required = true, value = "产品类型:3直播互动;41交易圈") Integer type,
|
||||
@RequestParam("id") @Validated @NotNull @Min(1) @ApiParam(required = true, value = "产品ID") Integer id) {
|
||||
WebSocketConfigVO conf = globalConfigService.getWebSocketConf(type, id);
|
||||
return CommonResult.success(conf);
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package com.upchina.group.controller.admin;
|
||||
|
||||
import com.upchina.common.handler.BizException;
|
||||
import com.upchina.common.query.OnlyIdQuery;
|
||||
import com.upchina.common.result.AppPager;
|
||||
import com.upchina.common.result.CommonResult;
|
||||
import com.upchina.common.result.ResponseStatus;
|
||||
@ -19,6 +20,7 @@ import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
@Api(tags = "交易圈admin消息接口")
|
||||
@RestController
|
||||
@ -45,6 +47,7 @@ public class AdminGroupMessageController {
|
||||
adminGroupMessageService.updateStatus(query, backendUserVO);
|
||||
return CommonResult.success();
|
||||
}
|
||||
|
||||
@ApiOperation("后台获取互动消息")
|
||||
@PostMapping("/admin/group/message/getMessageList")
|
||||
public CommonResult<AppPager<GroupMessageVO>> getMessageList(@Validated @RequestBody @ApiParam(required = true) ListGroupMessageQuery query,
|
||||
@ -53,6 +56,14 @@ public class AdminGroupMessageController {
|
||||
return CommonResult.success(list);
|
||||
}
|
||||
|
||||
@ApiOperation("后台获取私聊列表")
|
||||
@PostMapping("/admin/group/message/getPrivateChatList")
|
||||
public CommonResult<List<GroupMessageVO>> getPrivateChatList(@Validated @RequestBody @ApiParam(required = true) OnlyIdQuery query,
|
||||
@RequestAttribute(value = "backendUser", required = false) BackendUserVO backendUserVO) {
|
||||
List<GroupMessageVO> list = adminGroupMessageService.getPrivateChatList(query, backendUserVO);
|
||||
return CommonResult.success(list);
|
||||
}
|
||||
|
||||
@ApiOperation("后台推荐产品消息")
|
||||
@PostMapping("/admin/group/message/sendProductMessage")
|
||||
public CommonResult<OnlyIdVO> sendProductMessage(@Validated @RequestBody @ApiParam(required = true) GroupMessageProductQuery query,
|
||||
@ -123,6 +134,5 @@ public class AdminGroupMessageController {
|
||||
}
|
||||
adminGroupMessageService.setFirstAudit(query, backendUser);
|
||||
return CommonResult.success();
|
||||
|
||||
}
|
||||
}
|
||||
@ -2,6 +2,10 @@ package com.upchina.group.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.upchina.group.entity.GroupMessage;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@ -13,4 +17,12 @@ import com.upchina.group.entity.GroupMessage;
|
||||
*/
|
||||
public interface GroupMessageMapper extends BaseMapper<GroupMessage> {
|
||||
|
||||
@Select("SELECT id\n" +
|
||||
"FROM (\n" +
|
||||
" SELECT id, ROW_NUMBER() OVER (PARTITION BY private_user_id ORDER BY id DESC) as rn\n" +
|
||||
" FROM group_message\n" +
|
||||
" WHERE group_id = #{groupId} AND interactive_type = 2 and private_user_id is not null\n" +
|
||||
") t\n" +
|
||||
"WHERE rn = 1")
|
||||
List<GroupMessage> selectPrivateChatList(@Param("groupId") Integer groupId);
|
||||
}
|
||||
|
||||
@ -203,7 +203,7 @@ public class GroupInfoService {
|
||||
LambdaQueryWrapper<GroupInfo> wrapper = Wrappers.<GroupInfo>lambdaQuery()
|
||||
.eq(GroupInfo::getAdvisorId, id)
|
||||
.eq(GroupInfo::getStatus, GroupInfoStatus.AUDITED.value)
|
||||
.eq(GroupInfo::getIsDisplay, IsDisplay.YES.value)
|
||||
// .eq(GroupInfo::getIsDisplay, IsDisplay.YES.value)
|
||||
.orderByDesc(GroupInfo::getIsRecommend, GroupInfo::getAuditTime);
|
||||
List<GroupInfo> list = groupInfoMapper.selectList(wrapper);
|
||||
NavigableSet<GroupSortEntity> set = new TreeSet<>();
|
||||
|
||||
@ -4,8 +4,11 @@ import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.upchina.advisor.service.AdvisorInfoService;
|
||||
import com.upchina.advisor.vo.AdvisorBasicVO;
|
||||
import com.upchina.common.constant.IsOrNot;
|
||||
import com.upchina.common.handler.BizException;
|
||||
import com.upchina.common.query.OnlyIdQuery;
|
||||
import com.upchina.common.result.AppPager;
|
||||
import com.upchina.common.result.ResponseStatus;
|
||||
import com.upchina.common.state.StateMachine;
|
||||
@ -20,12 +23,14 @@ import com.upchina.group.query.message.*;
|
||||
import com.upchina.group.service.common.GroupCacheService;
|
||||
import com.upchina.group.service.common.GroupMessageService;
|
||||
import com.upchina.group.vo.message.GroupMessageVO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@ -46,6 +51,9 @@ public class AdminGroupMessageService {
|
||||
@Resource
|
||||
private StateMachine<GroupMessageStatus> groupMessageSM;
|
||||
|
||||
@Resource
|
||||
private AdvisorInfoService advisorInfoService;
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public OnlyIdVO sendAdvisorMessage(SendGroupMessageAdminQuery query, BackendUserVO backendUser) {
|
||||
GroupInfo group = groupInfoMapper.selectById(query.getGroupId());
|
||||
@ -116,11 +124,19 @@ public class AdminGroupMessageService {
|
||||
if (hasNext) {
|
||||
list = list.subList(0, size);
|
||||
}
|
||||
|
||||
List<GroupMessageVO> voList = list.stream().map(GroupMessage::getId).map(groupCacheService::getMessage).collect(Collectors.toList());
|
||||
|
||||
Map<Integer, AdvisorBasicVO> advisorMap = advisorInfoService.getAdvisorVoMap();
|
||||
List<GroupMessageVO> voList = list.stream().map(GroupMessage::getId).map(id -> groupCacheService.getMessage(id, advisorMap)).collect(Collectors.toList());
|
||||
return new AppPager<>(voList, hasNext);
|
||||
}
|
||||
|
||||
public List<GroupMessageVO> getPrivateChatList(OnlyIdQuery query, BackendUserVO backendUserVO) {
|
||||
Integer groupId = query.getId();
|
||||
List<GroupMessage> list = groupMessageMapper.selectPrivateChatList(groupId);
|
||||
Map<Integer, AdvisorBasicVO> advisorMap = advisorInfoService.getAdvisorVoMap();
|
||||
return list.stream().map(GroupMessage::getId).map(id -> groupCacheService.getMessage(id, advisorMap)).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public OnlyIdVO saveProductMessage(GroupMessageProductQuery query, BackendUserVO backendUser) {
|
||||
GroupMessage message = new GroupMessage();
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
package com.upchina.group.service.app;
|
||||
|
||||
import com.upchina.advisor.service.AdvisorInfoService;
|
||||
import com.upchina.advisor.vo.AdvisorBasicVO;
|
||||
import com.upchina.common.constant.IsOrNot;
|
||||
import com.upchina.common.handler.BizException;
|
||||
import com.upchina.common.query.OnlyIdQuery;
|
||||
@ -21,14 +23,12 @@ import com.upchina.group.service.common.GroupCommonService;
|
||||
import com.upchina.group.service.common.GroupMessageService;
|
||||
import com.upchina.group.vo.GroupVO;
|
||||
import com.upchina.group.vo.message.GroupMessageVO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.NavigableSet;
|
||||
import java.util.*;
|
||||
|
||||
@Service
|
||||
public class AppGroupMessageService {
|
||||
@ -51,6 +51,9 @@ public class AppGroupMessageService {
|
||||
@Resource
|
||||
private SensitiveWordService sensitiveWordService;
|
||||
|
||||
@Resource
|
||||
private AdvisorInfoService advisorInfoService;
|
||||
|
||||
public AppPager<GroupMessageVO> getMessageList(ListGroupMessageAppQuery query, FrontUserVO frontUser) {
|
||||
Integer groupId = query.getGroupId();
|
||||
Integer lastId = query.getLastId();
|
||||
@ -72,9 +75,10 @@ public class AppGroupMessageService {
|
||||
}
|
||||
List<GroupMessageVO> list = new ArrayList<>(size);
|
||||
Iterator<Integer> it = sortedSet.iterator();
|
||||
Map<Integer, AdvisorBasicVO> advisorMap = advisorInfoService.getAdvisorVoMap();
|
||||
while (it.hasNext()) {
|
||||
Integer msgId = it.next();
|
||||
GroupMessageVO msg = groupCacheService.getMessage(msgId);
|
||||
GroupMessageVO msg = groupCacheService.getMessage(msgId, advisorMap);
|
||||
if (msg != null) {
|
||||
list.add(msg);
|
||||
if (--size == 0) break;
|
||||
@ -108,7 +112,8 @@ public class AppGroupMessageService {
|
||||
message.setContent(TextUtil.cleanUnsafeHtml(content));
|
||||
groupMessageMapper.insert(message);
|
||||
|
||||
GroupMessageVO vo = new GroupMessageVO(message);
|
||||
Map<Integer, AdvisorBasicVO> advisorMap = advisorInfoService.getAdvisorVoMap();
|
||||
GroupMessageVO vo = new GroupMessageVO(message, advisorMap.get(message.getAdvisorId()));
|
||||
|
||||
if (!IsOrNot.IS.value.equals(groupVO.getFirstAudit())) {
|
||||
groupMessageService.publishGroupMessage(GroupMessageChannel.ALL, GroupMessageType.NORMAL, groupId, vo);
|
||||
|
||||
@ -3,6 +3,7 @@ package com.upchina.group.service.common;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.hazelcast.map.IMap;
|
||||
import com.upchina.advisor.vo.AdvisorBasicVO;
|
||||
import com.upchina.common.config.cache.CacheKey;
|
||||
import com.upchina.common.constant.IsOrNot;
|
||||
import com.upchina.common.handler.BizException;
|
||||
@ -20,10 +21,7 @@ import com.upchina.video.entity.OnlineUser;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.NavigableSet;
|
||||
import java.util.TreeSet;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -129,14 +127,14 @@ public class GroupCacheService {
|
||||
groupCache.put(cacheKey, set);
|
||||
}
|
||||
|
||||
public GroupMessageVO getMessage(Integer messageId) {
|
||||
public GroupMessageVO getMessage(Integer messageId, Map<Integer, AdvisorBasicVO> advisorMap) {
|
||||
return cacheService.get(groupCache,
|
||||
CacheKey.GroupKey.GROUP_MESSAGE_DETAIL + messageId, () -> {
|
||||
GroupMessage message = groupMessageMapper.selectById(messageId);
|
||||
if (message == null) {
|
||||
return null;
|
||||
}
|
||||
return new GroupMessageVO(message);
|
||||
return new GroupMessageVO(message, advisorMap.get(message.getAdvisorId()));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -63,7 +63,7 @@ public class GroupMessageVO implements Serializable {
|
||||
public GroupMessageVO() {
|
||||
}
|
||||
|
||||
public GroupMessageVO(GroupMessage message) {
|
||||
public GroupMessageVO(GroupMessage message, AdvisorBasicVO advisor) {
|
||||
this.id = message.getId();
|
||||
this.msgType = message.getMsgType();
|
||||
this.groupId = message.getGroupId();
|
||||
@ -78,6 +78,7 @@ public class GroupMessageVO implements Serializable {
|
||||
this.status = message.getStatus();
|
||||
this.createTime = message.getCreateTime();
|
||||
this.advisorId = message.getAdvisorId();
|
||||
this.advisor = advisor;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user