Browse Source

Merge branches 'dev' and 'wxz_send_message' of http://git.elinkit.com.cn:7070/r/epmet-cloud into dev

dev_shibei_match
wxz 4 years ago
parent
commit
afae9c4187
  1. 2
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java
  2. 43
      epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/dto/form/ReceiverGroupCommonFormDTO.java
  3. 16
      epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/dto/result/ReceiverGroupCommonResultDTO.java
  4. 79
      epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/controller/InfoController.java
  5. 53
      epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/InfoService.java
  6. 100
      epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/impl/InfoServiceImpl.java
  7. 2
      epmet-module/epmet-message/epmet-message-server/src/main/resources/logback-spring.xml

2
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java

@ -110,6 +110,8 @@ public enum EpmetErrorCode {
PLEASE_CHOOSE_MEMBER(8611,"请选择成员"), PLEASE_CHOOSE_MEMBER(8611,"请选择成员"),
INFO_GROUP_NAME_EXISTS(8612,"名称已存在"), INFO_GROUP_NAME_EXISTS(8612,"名称已存在"),
INFO_REPLY_CONTENT_LENGTH_LIMIT(8613,"回复内容最多输入500字"), INFO_REPLY_CONTENT_LENGTH_LIMIT(8613,"回复内容最多输入500字"),
INFO_GROUP_NOT_EXISTS(8614,"群不存在"),
INFO_GROUP_OPE_PERMISSION_REQUIRED(8615,"无权操作"),
// 爱心互助 居民端 // 爱心互助 居民端
NOT_IN_THE_SIGN_IN_RANGE(8510, "您还未进入指定的签到范围~"), NOT_IN_THE_SIGN_IN_RANGE(8510, "您还未进入指定的签到范围~"),

43
epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/dto/form/ReceiverGroupCommonFormDTO.java

@ -0,0 +1,43 @@
package com.epmet.dto.form;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import java.util.List;
import java.util.Set;
/**
* @Description 通用的ReceiverGroup 入参dto
* @author wxz
* @date 2021.09.11 22:03:02
*/
@Data
public class ReceiverGroupCommonFormDTO {
public interface UpdateGroup {}
public interface RemoveMember {}
public interface AddMember {}
public interface DeleteGroup {}
/** 群id */
@NotBlank(message = "群ID不能为空", groups = { UpdateGroup.class, AddMember.class, RemoveMember.class, DeleteGroup.class })
private String receiverGroupId;
/** 群名字 */
@NotBlank(message = "群名字不能为空", groups = { UpdateGroup.class })
private String name;
/** 成员id */
@NotBlank(message = "组成员ID不能为空", groups = { RemoveMember.class })
private String staffId;
/** 成员ID列表 */
private List<String> staffIdList;
/**
* 按架构选择的组织或者网格或者部门的集合
*/
private Set<OrgCommonDTO> orgList;
}

16
epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/dto/result/ReceiverGroupCommonResultDTO.java

@ -0,0 +1,16 @@
package com.epmet.dto.result;
import lombok.Data;
/**
* @Description 群通用Result dto
* @author wxz
* @date 2021.09.11 22:08:36
*/
@Data
public class ReceiverGroupCommonResultDTO {
private String receiverGroupId;
private String name;
}

79
epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/controller/InfoController.java

@ -33,6 +33,10 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import javax.validation.constraints.NotBlank;
import java.util.List;
import java.util.Set;
/** /**
* 消息主表 * 消息主表
@ -139,10 +143,83 @@ public class InfoController {
return new Result<AddReceiverGroupResultDTO>().ok(infoService.addReceiverGroup(formDTO)); return new Result<AddReceiverGroupResultDTO>().ok(infoService.addReceiverGroup(formDTO));
} }
/**
* @description 发送消息更新群信息
*
* @param form
* @param tokenDto
* @return
* @author wxz
* @date 2021.09.11 22:05:08
*/
@PostMapping("/receivergroup/update")
public Result updateInfoReceiverGroup(@RequestBody ReceiverGroupCommonFormDTO form, @LoginUser TokenDto tokenDto) {
ValidatorUtils.validateEntity(form, ReceiverGroupCommonFormDTO.UpdateGroup.class);
String userId = tokenDto.getUserId();
String receiverGroupId = form.getReceiverGroupId();
String name = form.getName();
infoService.updateReceiverGroup(userId, receiverGroupId, name);
return new Result();
}
/**
* @description 发送消息移除群成员
*
* @param form
* @param tokenDto
* @return
* @author wxz
* @date 2021.09.11 22:26:44
*/
@PostMapping("/receivergroup/member/remove")
public Result removeInfoGroupMember(@RequestBody ReceiverGroupCommonFormDTO form, @LoginUser TokenDto tokenDto) {
ValidatorUtils.validateEntity(form, ReceiverGroupCommonFormDTO.RemoveMember.class);
String userId = tokenDto.getUserId();
String receiverGroupId = form.getReceiverGroupId();
String staffId = form.getStaffId();
infoService.removeGroupMember(receiverGroupId, staffId, userId);
return new Result();
}
/**
* @description 发送消息添加新成员
*
* @param form
* @param tokenDto
* @return
* @author wxz
* @date 2021.09.13 13:54:02
*/
@PostMapping("/receivergroup/member/add")
public Result addInfoGroupMember(@RequestBody ReceiverGroupCommonFormDTO form, @LoginUser TokenDto tokenDto) {
ValidatorUtils.validateEntity(form, ReceiverGroupCommonFormDTO.AddMember.class);
String userId = tokenDto.getUserId();
String receiverGroupId = form.getReceiverGroupId();
Set<OrgCommonDTO> orgList = form.getOrgList();
List<String> staffIdList = form.getStaffIdList();
infoService.addInfoGroupMember(receiverGroupId, userId, orgList, staffIdList);
return new Result();
}
/**
* @description 发送消息删除群组
*
* @param form
* @param tokenDto
* @return
* @author wxz
* @date 2021.09.11 22:35:21
*/
@PostMapping("/receivergroup/remove")
public Result deleteInfoGroup(@RequestBody ReceiverGroupCommonFormDTO form, @LoginUser TokenDto tokenDto) {
ValidatorUtils.validateEntity(form, ReceiverGroupCommonFormDTO.DeleteGroup.class);
String operatorId = tokenDto.getUserId();
String receiverGroupId = form.getReceiverGroupId();
infoService.deleteInfoGroup(receiverGroupId, operatorId);
return new Result();
}

53
epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/InfoService.java

@ -20,10 +20,14 @@ package com.epmet.service;
import com.epmet.commons.mybatis.service.BaseService; import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.dto.form.*; import com.epmet.dto.form.*;
import com.epmet.dto.result.AddReceiverGroupResultDTO; import com.epmet.dto.result.AddReceiverGroupResultDTO;
import com.epmet.dto.result.ReceiverGroupCommonResultDTO;
import com.epmet.dto.result.ReplyInfoResultDTO; import com.epmet.dto.result.ReplyInfoResultDTO;
import com.epmet.dto.result.SendInfoResultDTO; import com.epmet.dto.result.SendInfoResultDTO;
import com.epmet.entity.InfoEntity; import com.epmet.entity.InfoEntity;
import java.util.List;
import java.util.Set;
/** /**
* 消息主表 * 消息主表
* *
@ -81,4 +85,53 @@ public interface InfoService extends BaseService<InfoEntity> {
* @date 2021/8/20 9:58 上午 * @date 2021/8/20 9:58 上午
*/ */
AddReceiverGroupResultDTO addReceiverGroup(AddReceiverGroupFormDTO formDTO); AddReceiverGroupResultDTO addReceiverGroup(AddReceiverGroupFormDTO formDTO);
/**
* @description 更新群信息
*
* @param operatorId
* @param receiverGroupId
* @param name
* @return
* @author wxz
* @date 2021.09.11 22:07:25
*/
void updateReceiverGroup(String operatorId, String receiverGroupId, String name);
/**
* @description 移除群成员
*
* @param receiverGroupId
*
* @param staffId
* @param operatorId
* @return
* @author wxz
* @date 2021.09.11 22:27:16
*/
void removeGroupMember(String receiverGroupId, String staffId, String operatorId);
/**
* @description 删除群
*
* @param receiverGroupId
* @param operatorId
* @return
* @author wxz
* @date 2021.09.11 22:36:27
*/
void deleteInfoGroup(String receiverGroupId, String operatorId);
/**
* @description 发送消息添加新成员
*
* @param receiverGroupId
* @param operatorId
* @param orgList
* @param staffIdList
* @return
* @author wxz
* @date 2021.09.13 13:54:45
*/
void addInfoGroupMember(String receiverGroupId, String operatorId, Set<OrgCommonDTO> orgList, List<String> staffIdList);
} }

100
epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/impl/InfoServiceImpl.java

@ -17,6 +17,8 @@
package com.epmet.service.impl; package com.epmet.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.AppClientConstant; import com.epmet.commons.tools.constant.AppClientConstant;
import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.constant.NumConstant;
@ -31,6 +33,7 @@ import com.epmet.constant.UserMessageTypeConstant;
import com.epmet.dao.*; import com.epmet.dao.*;
import com.epmet.dto.form.*; import com.epmet.dto.form.*;
import com.epmet.dto.result.AddReceiverGroupResultDTO; import com.epmet.dto.result.AddReceiverGroupResultDTO;
import com.epmet.dto.result.ReceiverGroupCommonResultDTO;
import com.epmet.dto.result.ReplyInfoResultDTO; import com.epmet.dto.result.ReplyInfoResultDTO;
import com.epmet.dto.result.SendInfoResultDTO; import com.epmet.dto.result.SendInfoResultDTO;
import com.epmet.entity.*; import com.epmet.entity.*;
@ -44,9 +47,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.Collections; import java.util.*;
import java.util.LinkedHashSet; import java.util.stream.Collectors;
import java.util.Set;
/** /**
* 消息主表 * 消息主表
@ -428,20 +430,100 @@ public class InfoServiceImpl extends BaseServiceImpl<InfoDao, InfoEntity> implem
} }
@Override
public void updateReceiverGroup(String operatorId, String receiverGroupId, String name) {
InfoReceiverGroupEntity groupEntity = baseValidate(receiverGroupId, operatorId);
// 检查重名
if (infoReceiverGroupDao.selectCountName(name.trim(),groupEntity.getCustomerId(),operatorId) > 1) {
throw new RenException(EpmetErrorCode.INFO_GROUP_NAME_EXISTS.getCode(), EpmetErrorCode.INFO_GROUP_NAME_EXISTS.getMsg());
}
LambdaUpdateWrapper<InfoReceiverGroupEntity> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(InfoReceiverGroupEntity::getId, receiverGroupId);
updateWrapper.set(InfoReceiverGroupEntity::getName, name);
infoReceiverGroupDao.update(null, updateWrapper);
}
@Override
public void removeGroupMember(String receiverGroupId, String staffId, String operatorId) {
baseValidate(receiverGroupId, operatorId);
LambdaQueryWrapper<InfoGroupReceiversEntity> query = new LambdaQueryWrapper<>();
query.eq(InfoGroupReceiversEntity::getStaffId, staffId);
query.eq(InfoGroupReceiversEntity::getInfoReceiverGroupId, receiverGroupId);
infoGroupReceiversDao.delete(query);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void deleteInfoGroup(String receiverGroupId, String operatorId) {
baseValidate(receiverGroupId, operatorId);
// 1.先删除群
infoReceiverGroupDao.deleteById(receiverGroupId);
// 2.再删除成员
LambdaQueryWrapper<InfoGroupReceiversEntity> query = new LambdaQueryWrapper();
query.eq(InfoGroupReceiversEntity::getInfoReceiverGroupId, receiverGroupId);
infoGroupReceiversDao.delete(query);
}
@Override
@Transactional
public void addInfoGroupMember(String receiverGroupId, String operatorId, Set<OrgCommonDTO> orgList, List<String> staffIdList) {
InfoReceiverGroupEntity groupInfo = baseValidate(receiverGroupId, operatorId);
// 1、人员列表和组织列表不能同时为空
if (CollectionUtils.isEmpty(staffIdList) && CollectionUtils.isEmpty(orgList)) {
throw new RenException(EpmetErrorCode.PLEASE_CHOOSE_MEMBER.getCode(), EpmetErrorCode.PLEASE_CHOOSE_MEMBER.getMsg());
}
// 2、如果没有单选人,选择的组织内也没有人,那么给出提示
Set<String> orgStaffIds = queryOrgStaffIds(groupInfo.getCustomerId(), orgList);
if (CollectionUtils.isEmpty(staffIdList) && CollectionUtils.isEmpty(orgStaffIds)) {
throw new RenException(EpmetErrorCode.PLEASE_CHOOSE_MEMBER.getCode(), EpmetErrorCode.PLEASE_CHOOSE_MEMBER.getMsg());
}
// 3、用户合并,去重,如果当前用户也在所选成员中,去掉当前用户,不给自己发消息
Set<String> members = new LinkedHashSet<>(CollectionUtils.size(staffIdList) + orgStaffIds.size());
members.addAll(staffIdList);
members.addAll(orgStaffIds);
if (CollectionUtils.isNotEmpty(members) && members.contains(operatorId)) {
members.remove(operatorId);
}
if (CollectionUtils.isEmpty(members)) {
throw new RenException(EpmetErrorCode.PLEASE_CHOOSE_MEMBER.getCode(), EpmetErrorCode.PLEASE_CHOOSE_MEMBER.getMsg());
}
// 4、现有成员去重
Set<String> existingStaffIds = infoGroupReceiversDao.selectStaffIds(new HashSet<>(Arrays.asList(receiverGroupId)));
members = members.stream().filter(mId -> !existingStaffIds.contains(mId)).collect(Collectors.toSet());
// 5、插入新成员
members.forEach(memStaffId->{
InfoGroupReceiversEntity memberEntity=new InfoGroupReceiversEntity();
memberEntity.setCustomerId(groupInfo.getCustomerId());
memberEntity.setInfoReceiverGroupId(receiverGroupId);
memberEntity.setStaffId(memStaffId);
infoGroupReceiversDao.insert(memberEntity);
});
}
/**
* @description 基础检查并且返回组信息
*
* @param receiverGroupId
* @param operatorId
* @return
* @author wxz
* @date 2021.09.13 13:48:26
*/
private InfoReceiverGroupEntity baseValidate(String receiverGroupId, String operatorId) {
InfoReceiverGroupEntity groupEntity = infoReceiverGroupDao.selectById(receiverGroupId);
if (groupEntity == null) {
throw new RenException(EpmetErrorCode.INFO_GROUP_NOT_EXISTS.getCode(), "群不存在");
}
if (!groupEntity.getCreateStaffId().equals(operatorId)) {
// 不是拥有者 ,不允许删除
throw new RenException(EpmetErrorCode.INFO_GROUP_OPE_PERMISSION_REQUIRED.getCode(), "只有群所有者可以进行此操作");
}
return groupEntity;
}
} }

2
epmet-module/epmet-message/epmet-message-server/src/main/resources/logback-spring.xml

@ -139,7 +139,7 @@
</appender> </appender>
<!-- 开发、测试环境 --> <!-- 开发、测试环境 -->
<springProfile name="dev,test"> <springProfile name="dev,test,local">
<logger name="org.springframework.web" level="INFO"/> <logger name="org.springframework.web" level="INFO"/>
<logger name="org.springboot.sample" level="INFO"/> <logger name="org.springboot.sample" level="INFO"/>
<logger name="com.epmet.dao" level="INFO"/> <logger name="com.epmet.dao" level="INFO"/>

Loading…
Cancel
Save