|
|
@ -20,20 +20,36 @@ package com.elink.esua.epdc.modules.group.service.impl; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.elink.esua.epdc.commons.mybatis.service.impl.BaseServiceImpl; |
|
|
|
import com.elink.esua.epdc.commons.tools.constant.NumConstant; |
|
|
|
import com.elink.esua.epdc.commons.tools.page.PageData; |
|
|
|
import com.elink.esua.epdc.commons.tools.utils.ConvertUtils; |
|
|
|
import com.elink.esua.epdc.commons.tools.constant.FieldConstant; |
|
|
|
import com.elink.esua.epdc.commons.tools.utils.Result; |
|
|
|
import com.elink.esua.epdc.dto.constant.GroupNoticeConstant; |
|
|
|
import com.elink.esua.epdc.dto.enums.GroupUserStateEnum; |
|
|
|
import com.elink.esua.epdc.dto.epdc.form.EpdcInformationFormDTO; |
|
|
|
import com.elink.esua.epdc.dto.epdc.form.EpdcUserGroupInviteFormDTO; |
|
|
|
import com.elink.esua.epdc.dto.epdc.result.EpdcUserGroupInviteResultDTO; |
|
|
|
import com.elink.esua.epdc.dto.group.GroupDTO; |
|
|
|
import com.elink.esua.epdc.dto.group.UserGroupDTO; |
|
|
|
import com.elink.esua.epdc.dto.group.UserReviewDto; |
|
|
|
import com.elink.esua.epdc.dto.group.form.GroupAddUserFormDTO; |
|
|
|
import com.elink.esua.epdc.dto.group.form.GroupUserFormDTO; |
|
|
|
import com.elink.esua.epdc.dto.group.form.GroupUserRemoveOrQuitFormDTO; |
|
|
|
import com.elink.esua.epdc.dto.group.form.GroupUserReviewFormDTO; |
|
|
|
import com.elink.esua.epdc.dto.group.result.GroupUserListResultDTO; |
|
|
|
import com.elink.esua.epdc.modules.async.NewsTask; |
|
|
|
import com.elink.esua.epdc.modules.feign.UserFeignClient; |
|
|
|
import com.elink.esua.epdc.modules.group.dao.UserGroupDao; |
|
|
|
import com.elink.esua.epdc.modules.group.entity.UserGroupEntity; |
|
|
|
import com.elink.esua.epdc.modules.group.service.GroupService; |
|
|
|
import com.elink.esua.epdc.modules.group.service.UserGroupService; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
@ -47,6 +63,15 @@ import java.util.Map; |
|
|
|
@Service |
|
|
|
public class UserGroupServiceImpl extends BaseServiceImpl<UserGroupDao, UserGroupEntity> implements UserGroupService { |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private UserFeignClient userFeignClient; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private GroupService groupService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private NewsTask newsTask; |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageData<UserGroupDTO> page(Map<String, Object> params) { |
|
|
|
IPage<UserGroupDTO> page = getPage(params); |
|
|
@ -120,8 +145,102 @@ public class UserGroupServiceImpl extends BaseServiceImpl<UserGroupDao, UserGrou |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<String> listOfGroupUserIdsByState(String groupId, int[] states) { |
|
|
|
return baseDao.selectListOfGroupUserIdsByState(groupId, states); |
|
|
|
public Result<List<EpdcUserGroupInviteResultDTO>> listOfInviteUsers(EpdcUserGroupInviteFormDTO formDto) { |
|
|
|
// 获取社群当前待审核和审核通过的成员ID
|
|
|
|
int[] states = {GroupUserStateEnum.GROUP_USER_STATE_PENDING_REVIEW.getValue(), GroupUserStateEnum.GROUP_USER_STATE_EXAMINATION_PASSED.getValue()}; |
|
|
|
List<String> userIds = baseDao.selectListOfGroupUserIdsByState(formDto.getGroupId(), states); |
|
|
|
formDto.setUserIds(userIds); |
|
|
|
|
|
|
|
return userFeignClient.getInviteUserList(formDto); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public Result saveGroupUsers(GroupAddUserFormDTO formDto) { |
|
|
|
List<UserGroupEntity> userGroupEntities = new ArrayList<>(formDto.getGroupUserFormDtoList().size()); |
|
|
|
UserGroupEntity entity = null; |
|
|
|
for (GroupUserFormDTO userDto: |
|
|
|
formDto.getGroupUserFormDtoList()) { |
|
|
|
entity = new UserGroupEntity(); |
|
|
|
entity.setGroupId(formDto.getGroupId()); |
|
|
|
entity.setUserId(userDto.getUserId()); |
|
|
|
entity.setNickname(userDto.getNickname()); |
|
|
|
entity.setUserAvatar(userDto.getUserAvatar()); |
|
|
|
entity.setMobile(userDto.getMobile()); |
|
|
|
entity.setPartyMember(userDto.getPartyMember()); |
|
|
|
entity.setLordFlag(NumConstant.ZERO_STR); |
|
|
|
entity.setState(GroupUserStateEnum.GROUP_USER_STATE_EXAMINATION_PASSED.getValue()); |
|
|
|
|
|
|
|
userGroupEntities.add(entity); |
|
|
|
} |
|
|
|
|
|
|
|
if (insertBatch(userGroupEntities)) { |
|
|
|
// 获取社群信息
|
|
|
|
GroupDTO groupDto = groupService.get(formDto.getGroupId()); |
|
|
|
// 组装发送消息内容
|
|
|
|
for (UserGroupEntity userGroupEntity: |
|
|
|
userGroupEntities) { |
|
|
|
EpdcInformationFormDTO informationFormDTO = new EpdcInformationFormDTO(); |
|
|
|
informationFormDTO.setContent(GroupNoticeConstant.NOTICE_GROUP_USER_INVITED_CONTENT.replace("groupName", groupDto.getGroupName())); |
|
|
|
informationFormDTO.setType(GroupNoticeConstant.NOTICE_TYPE_GROUP_NOTICE); |
|
|
|
informationFormDTO.setBusinessId(formDto.getGroupId()); |
|
|
|
informationFormDTO.setUserId(userGroupEntity.getUserId()); |
|
|
|
informationFormDTO.setTitle(GroupNoticeConstant.NOTICE_GROUP_USER_INVITED); |
|
|
|
informationFormDTO.setBusinessType(GroupNoticeConstant.NOTICE_BUSINESS_TYPE_GROUP_USER_INVITED); |
|
|
|
|
|
|
|
// 发送通知
|
|
|
|
newsTask.insertUserInformation(informationFormDTO); |
|
|
|
} |
|
|
|
return new Result(); |
|
|
|
} |
|
|
|
|
|
|
|
return new Result().error(); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public Result modifyGroupUsers(GroupUserReviewFormDTO formDto) { |
|
|
|
List<UserGroupEntity> userGroupEntities = new ArrayList<>(formDto.getUserReviewDtoList().size()); |
|
|
|
UserGroupEntity entity = null; |
|
|
|
for (UserReviewDto userReviewDto: |
|
|
|
formDto.getUserReviewDtoList()) { |
|
|
|
entity = new UserGroupEntity(); |
|
|
|
entity.setId(userReviewDto.getId()); |
|
|
|
entity.setState(userReviewDto.getState()); |
|
|
|
entity.setAuditOpinion(userReviewDto.getAuditOpinion()); |
|
|
|
|
|
|
|
userGroupEntities.add(entity); |
|
|
|
} |
|
|
|
if (updateBatchById(userGroupEntities)) { |
|
|
|
// 获取社群信息
|
|
|
|
GroupDTO groupDto = groupService.get(formDto.getGroupId()); |
|
|
|
// 组装发送消息内容
|
|
|
|
for (UserGroupEntity userGroupEntity: |
|
|
|
userGroupEntities) { |
|
|
|
EpdcInformationFormDTO informationFormDTO = new EpdcInformationFormDTO(); |
|
|
|
informationFormDTO.setType(GroupNoticeConstant.NOTICE_TYPE_AUDIT_NOTICE); |
|
|
|
informationFormDTO.setUserId(userGroupEntity.getUserId()); |
|
|
|
if (GroupUserStateEnum.GROUP_USER_STATE_AUDIT_NOT_PASSED.getValue().equals(userGroupEntity.getState())) { |
|
|
|
informationFormDTO.setTitle(GroupNoticeConstant.NOTICE_GROUP_USER_REVIEW_NOT_PASSED); |
|
|
|
informationFormDTO.setContent(GroupNoticeConstant.NOTICE_GROUP_USER_REVIEW_NOT_PASSED_CONTENT |
|
|
|
.replace("groupName", groupDto.getGroupName()) |
|
|
|
.replace("auditOpinion", userGroupEntity.getAuditOpinion())); |
|
|
|
informationFormDTO.setBusinessId(userGroupEntity.getId()); |
|
|
|
informationFormDTO.setBusinessType(GroupNoticeConstant.NOTICE_BUSINESS_TYPE_GROUP_USER_REVIEW_NOT_PASS); |
|
|
|
} else { |
|
|
|
informationFormDTO.setTitle(GroupNoticeConstant.NOTICE_GROUP_USER_REVIEW_PASSED); |
|
|
|
informationFormDTO.setContent(GroupNoticeConstant.NOTICE_GROUP_USER_REVIEW_PASSED_CONTENT |
|
|
|
.replace("groupName", groupDto.getGroupName())); |
|
|
|
informationFormDTO.setBusinessId(formDto.getGroupId()); |
|
|
|
informationFormDTO.setBusinessType(GroupNoticeConstant.NOTICE_BUSINESS_TYPE_GROUP_USER_REVIEW_PASSED); |
|
|
|
} |
|
|
|
// 发送通知
|
|
|
|
newsTask.insertUserInformation(informationFormDTO); |
|
|
|
} |
|
|
|
return new Result(); |
|
|
|
} |
|
|
|
|
|
|
|
return new Result().error(); |
|
|
|
} |
|
|
|
|
|
|
|
} |