feat:机器人注册接口更新到IM

This commit is contained in:
zuoqinbo 2023-10-16 12:22:15 +08:00
parent 74742609b9
commit 95ddbed103
6 changed files with 33 additions and 12 deletions

View File

@ -14,8 +14,8 @@ import org.apache.commons.lang3.StringUtils;
@Getter
public enum AppTypeEnum {
WORKER("worker", "工人端"),
ENTERPRISE("enterprise", "企业"),
WORKER("cm", "工人端"),
ENTERPRISE("cmp", "企业管理"),
SYSTEM("system", "服务器");

View File

@ -11,7 +11,16 @@ public interface INotifyService {
/**
* 机器人信息变更通知到IM用户系统
* @param robotId
*
* @param robotPrimaryId
*/
void notifyAccountChange(Long robotPrimaryId);
/**
* 普通用户信息变更通知到IM用户系统
*
* @param userId
* @param nickName
*/
void notifyUserAccountChange(String userId, String nickName);
}

View File

@ -29,10 +29,12 @@ public class RobotTagDao extends ServiceImpl<RobotTagMapper, RobotTag> {
*/
public IPage<RobotTag> queryRobotTagOfPage(RobotTagQuery robotTagQuery) {
return lambdaQuery().eq(RobotTag::getIsDelete, 0)
.like(StringUtils.isNoneBlank(robotTagQuery.getTagName()),
.like(StringUtils.isNotBlank(robotTagQuery.getTagName()),
RobotTag::getTagName,
robotTagQuery.getTagName())
.eq(RobotTag::getStatus, robotTagQuery.getStatus())
.eq(robotTagQuery.getStatus() != null,
RobotTag::getStatus,
robotTagQuery.getStatus())
.orderByDesc(RobotTag::getWeight)
.page(robotTagQuery.toPage());
}

View File

@ -3,6 +3,7 @@ package cn.axzo.im.service;
import cn.axzo.im.center.api.vo.resp.RobotInfoResp;
import cn.axzo.im.center.api.vo.resp.RobotMsgTemplateResp;
import cn.axzo.im.center.api.vo.resp.RobotTagResp;
import cn.axzo.im.center.common.enums.AccountTypeEnum;
import cn.axzo.im.channel.IMChannelProvider;
import cn.axzo.im.channel.netease.INotifyService;
import cn.axzo.im.channel.netease.dto.RegisterUpdateRequest;
@ -52,6 +53,7 @@ public class NotifyChannelServiceImpl implements INotifyService {
robotInfoResp.setMsgTemplateList(robotMsgTemplate.getMsgTemplateList());
}
HashMap<String, Object> userProfileMap = Maps.newHashMap();
userProfileMap.put("accountType", AccountTypeEnum.ROBOT.getCode());
List<RobotTagResp> robotTags = robotInfoResp.getRobotTagList();
if (CollectionUtils.isNotEmpty(robotTags)) {
robotTags.forEach(robotTagResp -> {
@ -71,4 +73,19 @@ public class NotifyChannelServiceImpl implements INotifyService {
}
@Override
public void notifyUserAccountChange(String userId, String nickName) {
HashMap<String, Object> userProfileMap = Maps.newHashMap();
userProfileMap.put("accountType", AccountTypeEnum.USER.getCode());
String extJson = JSONUtil.toJsonStr(userProfileMap);
RegisterUpdateRequest updateProfile = new RegisterUpdateRequest();
updateProfile.setExtJson(extJson);
updateProfile.setAccid(userId);
updateProfile.setName(nickName);
log.info("更新普通用户:{},网易云信账户信息", JSONUtil.toJsonStr(updateProfile));
channelProvider.updateAccountProfile(updateProfile);
}
}

View File

@ -16,7 +16,6 @@ import cn.axzo.im.dao.repository.RobotTagDao;
import cn.axzo.im.entity.RobotInfo;
import cn.axzo.im.entity.RobotTag;
import cn.axzo.im.utils.BeanConvertUtils;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@ -56,9 +55,6 @@ public class RobotInfoService {
@Resource
private RobotTagService robotTagService;
@Resource
private NotifyChannelService notifyChannelService;
@Transactional(rollbackFor = Exception.class)
public RobotInfoResp saveRobotInfo(@Valid RobotInfoReq robotInfoRequest, INotifyService iNotifyService) {
verifyRobotName(robotInfoRequest.getNickName(), null);

View File

@ -36,9 +36,6 @@ public class RobotMsgTemplateService {
@Resource
private RobotInfoDao robotInfoDao;
@Resource
private NotifyChannelService notifyChannelService;
public RobotMsgTemplateResp queryRobotMsgTemplateList(String robotId) {
RobotMsgTemplate robotMsgTemplate = robotMsgTemplateDao.lambdaQuery().eq(RobotMsgTemplate::getIsDelete, 0)
.eq(RobotMsgTemplate::getRobotId, robotId).one();