|
|
@ -22,6 +22,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |
|
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
|
import com.epmet.commons.tools.page.PageData; |
|
|
|
import com.epmet.commons.tools.redis.RedisUtils; |
|
|
|
import com.epmet.commons.tools.security.dto.TokenDto; |
|
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
import com.epmet.commons.tools.constant.FieldConstant; |
|
|
@ -30,7 +31,9 @@ import com.epmet.dto.form.UserResiInfoFormDTO; |
|
|
|
import com.epmet.dto.result.UserResiInfoResultDTO; |
|
|
|
import com.epmet.modules.feign.EpmetUserFeignClient; |
|
|
|
import com.epmet.modules.group.dao.ResiGroupDao; |
|
|
|
import com.epmet.modules.group.dao.ResiGroupStatisticalDao; |
|
|
|
import com.epmet.modules.group.entity.ResiGroupEntity; |
|
|
|
import com.epmet.modules.group.entity.ResiGroupStatisticalEntity; |
|
|
|
import com.epmet.modules.member.dao.ResiGroupMemberDao; |
|
|
|
import com.epmet.modules.member.service.ResiGroupMemberService; |
|
|
|
import com.epmet.modules.topic.dao.ResiTopicAttachmentDao; |
|
|
@ -54,14 +57,14 @@ import com.epmet.resi.group.dto.topic.result.ResiTopicDetailResultDTO; |
|
|
|
import com.epmet.resi.group.dto.topic.result.ResiTopicInfoResultDTO; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory; |
|
|
|
import org.springframework.data.redis.core.RedisTemplate; |
|
|
|
import org.springframework.data.redis.core.ValueOperations; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.*; |
|
|
|
|
|
|
|
/** |
|
|
|
* 话题信息表 |
|
|
@ -93,6 +96,15 @@ public class ResiTopicServiceImpl extends BaseServiceImpl<ResiTopicDao, ResiTopi |
|
|
|
@Autowired |
|
|
|
ResiGroupMemberDao resiGroupMemberDao; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
ResiGroupStatisticalDao resiGroupStatisticalDao; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
RedisUtils redisUtil; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private RedisTemplate<String, Object> redisTemplate; |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageData<ResiTopicDTO> page(Map<String, Object> params) { |
|
|
|
IPage<ResiTopicEntity> page = baseDao.selectPage( |
|
|
@ -169,6 +181,8 @@ public class ResiTopicServiceImpl extends BaseServiceImpl<ResiTopicDao, ResiTopi |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
Date currentTime = new Date(); |
|
|
|
|
|
|
|
//2.创建话题
|
|
|
|
if(resiTopicPublishFormDTO.getTopicContent().length() > TopicConstant.MAX_NUMBER_OF_CONTENT){ |
|
|
|
//内容超过最大限制
|
|
|
@ -184,10 +198,13 @@ public class ResiTopicServiceImpl extends BaseServiceImpl<ResiTopicDao, ResiTopi |
|
|
|
} |
|
|
|
if(null != resiTopicPublishFormDTO.getAttachmentList() && resiTopicPublishFormDTO.getAttachmentList().size() > 0){ |
|
|
|
ResiTopicAttachmentEntity attachment = new ResiTopicAttachmentEntity(); |
|
|
|
Integer sort = 0; |
|
|
|
for(String url : resiTopicPublishFormDTO.getAttachmentList()){ |
|
|
|
attachment.setAttachmentUrl(url); |
|
|
|
attachment.setTopicId(topic.getId()); |
|
|
|
attachment.setCreatedBy(tokenDto.getUserId()); |
|
|
|
attachment.setAttachmentFormat(url.substring(url.lastIndexOf("\\.") + 1).toLowerCase()); |
|
|
|
attachment.setSort(sort++); |
|
|
|
resiTopicAttachmentDao.insertOne(attachment); |
|
|
|
} |
|
|
|
} |
|
|
@ -199,6 +216,32 @@ public class ResiTopicServiceImpl extends BaseServiceImpl<ResiTopicDao, ResiTopi |
|
|
|
operation.setCreatedBy(tokenDto.getUserId()); |
|
|
|
resiTopicOperationDao.insertOne(operation); |
|
|
|
|
|
|
|
|
|
|
|
//4.小组统计信息,话题数+1
|
|
|
|
QueryWrapper<ResiGroupStatisticalEntity> wrapper = new QueryWrapper<>(); |
|
|
|
wrapper.eq(TopicConstant.RESI_GROUP_ID,resiTopicPublishFormDTO.getGroupId()); |
|
|
|
List<ResiGroupStatisticalEntity> statistical = resiGroupStatisticalDao.selectList(wrapper); |
|
|
|
if(null != statistical && statistical.size() >= NumConstant.ONE){ |
|
|
|
if(statistical.size() != NumConstant.ONE){ |
|
|
|
return new Result().error(ModuleConstant.GROUP_STASTICAL_NOT_SINGLE); |
|
|
|
}else{ |
|
|
|
ResiGroupStatisticalEntity statistical2Update = new ResiGroupStatisticalEntity(); |
|
|
|
statistical2Update.setId(statistical.get(NumConstant.ZERO).getId()); |
|
|
|
statistical2Update.setTotalTopics(null == statistical.get(NumConstant.ZERO).getTotalTopics() ? NumConstant.ONE : statistical.get(NumConstant.ZERO).getTotalTopics() + NumConstant.ONE); |
|
|
|
statistical2Update.setUpdatedBy(tokenDto.getUserId()); |
|
|
|
statistical2Update.setUpdatedTime(currentTime); |
|
|
|
resiGroupStatisticalDao.updateById(statistical2Update); |
|
|
|
} |
|
|
|
}else{ |
|
|
|
return new Result().error(ModuleConstant.NO_SUCH_GROUP_STASTICAL_INFO); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//5.群组信息,更新latestTopicPublishDate字段
|
|
|
|
ResiGroupEntity group2Update = new ResiGroupEntity(); |
|
|
|
group2Update.setId(resiTopicPublishFormDTO.getGroupId()); |
|
|
|
group2Update.setLatestTopicPublishDate(currentTime); |
|
|
|
resiGroupDao.updateById(group2Update); |
|
|
|
return new Result(); |
|
|
|
} |
|
|
|
|
|
|
@ -212,6 +255,7 @@ public class ResiTopicServiceImpl extends BaseServiceImpl<ResiTopicDao, ResiTopi |
|
|
|
**/ |
|
|
|
@Override |
|
|
|
public Result<List<ResiTopicInfoResultDTO>> getLatestTopics(TokenDto tokenDto, String groupId) { |
|
|
|
|
|
|
|
if (null == tokenDto) { |
|
|
|
return new Result().error(ModuleConstant.USER_NOT_NULL); |
|
|
|
} |
|
|
@ -409,7 +453,7 @@ public class ResiTopicServiceImpl extends BaseServiceImpl<ResiTopicDao, ResiTopi |
|
|
|
QueryWrapper<ResiTopicAttachmentEntity> wrapper = new QueryWrapper<>(); |
|
|
|
wrapper.eq(TopicConstant.TOPIC_ID,topicId); |
|
|
|
//wrapper.eq(TopicConstant.DEL_FLAG,NumConstant.ZERO_STR);
|
|
|
|
wrapper.orderByDesc(TopicConstant.CREATED_DATE); |
|
|
|
wrapper.orderByAsc(TopicConstant.SORT); |
|
|
|
List<ResiTopicAttachmentEntity> attachments = resiTopicAttachmentDao.selectList(wrapper); |
|
|
|
List<String> attachmentUrls = new ArrayList<>(); |
|
|
|
for(ResiTopicAttachmentEntity attachment : attachments){ |
|
|
|