Browse Source

附件增加sort,发布话题修改

master
wangchao 5 years ago
parent
commit
8f39456735
  1. 1
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisConfig.java
  2. 9
      epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/constant/TopicConstant.java
  3. 5
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/entity/ResiTopicAttachmentEntity.java
  4. 54
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/impl/ResiTopicServiceImpl.java
  5. 10
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/utils/ModuleConstant.java
  6. 12
      epmet-module/resi-group/resi-group-server/src/main/resources/mapper/topic/ResiTopicAttachmentDao.xml
  7. 4
      epmet-module/resi-group/resi-group-server/src/main/resources/mapper/topic/ResiTopicDao.xml

1
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisConfig.java

@ -36,7 +36,6 @@ public class RedisConfig {
redisTemplate.setHashKeySerializer(new StringRedisSerializer()); redisTemplate.setHashKeySerializer(new StringRedisSerializer());
redisTemplate.setHashValueSerializer(new JsonRedisSerializer<>(Object.class)); redisTemplate.setHashValueSerializer(new JsonRedisSerializer<>(Object.class));
redisTemplate.setConnectionFactory(factory); redisTemplate.setConnectionFactory(factory);
return redisTemplate; return redisTemplate;
} }
} }

9
epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/constant/TopicConstant.java

@ -59,7 +59,12 @@ public interface TopicConstant {
String CREATED_DATE = "CREATED_TIME"; String CREATED_DATE = "CREATED_TIME";
/** /**
* 构造queryWrapper 逻辑删除标识列名 * 构造queryWrapper 小组Id
* */ * */
String DEL_FLAG = "DEL_FLAG"; String RESI_GROUP_ID = "RESI_GROUP_ID";
/**
* 构造queryWrapper 附件排序
* */
String SORT = "SORT";
} }

5
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/entity/ResiTopicAttachmentEntity.java

@ -63,4 +63,9 @@ public class ResiTopicAttachmentEntity extends BaseEpmetEntity {
*/ */
private String attachmentUrl; private String attachmentUrl;
/**
* 排序字段解决多张图片的createdTime相同时的排序问题
* */
private Integer sort;
} }

54
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/impl/ResiTopicServiceImpl.java

@ -22,6 +22,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.page.PageData; 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.security.dto.TokenDto;
import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.constant.FieldConstant; import com.epmet.commons.tools.constant.FieldConstant;
@ -30,7 +31,9 @@ import com.epmet.dto.UserResiInfoDTO;
import com.epmet.dto.form.UserResiInfoFormDTO; import com.epmet.dto.form.UserResiInfoFormDTO;
import com.epmet.modules.feign.EpmetUserFeignClient; import com.epmet.modules.feign.EpmetUserFeignClient;
import com.epmet.modules.group.dao.ResiGroupDao; 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.ResiGroupEntity;
import com.epmet.modules.group.entity.ResiGroupStatisticalEntity;
import com.epmet.modules.member.dao.ResiGroupMemberDao; import com.epmet.modules.member.dao.ResiGroupMemberDao;
import com.epmet.modules.member.service.ResiGroupMemberService; import com.epmet.modules.member.service.ResiGroupMemberService;
import com.epmet.modules.topic.dao.ResiTopicAttachmentDao; 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 com.epmet.resi.group.dto.topic.result.ResiTopicInfoResultDTO;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; 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.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.*;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
/** /**
* 话题信息表 * 话题信息表
@ -93,6 +96,15 @@ public class ResiTopicServiceImpl extends BaseServiceImpl<ResiTopicDao, ResiTopi
@Autowired @Autowired
ResiGroupMemberDao resiGroupMemberDao; ResiGroupMemberDao resiGroupMemberDao;
@Autowired
ResiGroupStatisticalDao resiGroupStatisticalDao;
@Autowired
RedisUtils redisUtil;
@Autowired
private RedisTemplate<String, Object> redisTemplate;
@Override @Override
public PageData<ResiTopicDTO> page(Map<String, Object> params) { public PageData<ResiTopicDTO> page(Map<String, Object> params) {
IPage<ResiTopicEntity> page = baseDao.selectPage( IPage<ResiTopicEntity> page = baseDao.selectPage(
@ -169,6 +181,8 @@ public class ResiTopicServiceImpl extends BaseServiceImpl<ResiTopicDao, ResiTopi
return result; return result;
} }
Date currentTime = new Date();
//2.创建话题 //2.创建话题
if(resiTopicPublishFormDTO.getTopicContent().length() > TopicConstant.MAX_NUMBER_OF_CONTENT){ 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){ if(null != resiTopicPublishFormDTO.getAttachmentList() && resiTopicPublishFormDTO.getAttachmentList().size() > 0){
ResiTopicAttachmentEntity attachment = new ResiTopicAttachmentEntity(); ResiTopicAttachmentEntity attachment = new ResiTopicAttachmentEntity();
Integer sort = 0;
for(String url : resiTopicPublishFormDTO.getAttachmentList()){ for(String url : resiTopicPublishFormDTO.getAttachmentList()){
attachment.setAttachmentUrl(url); attachment.setAttachmentUrl(url);
attachment.setTopicId(topic.getId()); attachment.setTopicId(topic.getId());
attachment.setCreatedBy(tokenDto.getUserId()); attachment.setCreatedBy(tokenDto.getUserId());
attachment.setAttachmentFormat(url.substring(url.lastIndexOf("\\.") + 1).toLowerCase());
attachment.setSort(sort++);
resiTopicAttachmentDao.insertOne(attachment); resiTopicAttachmentDao.insertOne(attachment);
} }
} }
@ -199,6 +216,32 @@ public class ResiTopicServiceImpl extends BaseServiceImpl<ResiTopicDao, ResiTopi
operation.setCreatedBy(tokenDto.getUserId()); operation.setCreatedBy(tokenDto.getUserId());
resiTopicOperationDao.insertOne(operation); 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(); return new Result();
} }
@ -212,6 +255,7 @@ public class ResiTopicServiceImpl extends BaseServiceImpl<ResiTopicDao, ResiTopi
**/ **/
@Override @Override
public Result<List<ResiTopicInfoResultDTO>> getLatestTopics(TokenDto tokenDto, String groupId) { public Result<List<ResiTopicInfoResultDTO>> getLatestTopics(TokenDto tokenDto, String groupId) {
if (null == tokenDto) { if (null == tokenDto) {
return new Result().error(ModuleConstant.USER_NOT_NULL); return new Result().error(ModuleConstant.USER_NOT_NULL);
} }
@ -409,7 +453,7 @@ public class ResiTopicServiceImpl extends BaseServiceImpl<ResiTopicDao, ResiTopi
QueryWrapper<ResiTopicAttachmentEntity> wrapper = new QueryWrapper<>(); QueryWrapper<ResiTopicAttachmentEntity> wrapper = new QueryWrapper<>();
wrapper.eq(TopicConstant.TOPIC_ID,topicId); wrapper.eq(TopicConstant.TOPIC_ID,topicId);
//wrapper.eq(TopicConstant.DEL_FLAG,NumConstant.ZERO_STR); //wrapper.eq(TopicConstant.DEL_FLAG,NumConstant.ZERO_STR);
wrapper.orderByDesc(TopicConstant.CREATED_DATE); wrapper.orderByAsc(TopicConstant.SORT);
List<ResiTopicAttachmentEntity> attachments = resiTopicAttachmentDao.selectList(wrapper); List<ResiTopicAttachmentEntity> attachments = resiTopicAttachmentDao.selectList(wrapper);
List<String> attachmentUrls = new ArrayList<>(); List<String> attachmentUrls = new ArrayList<>();
for(ResiTopicAttachmentEntity attachment : attachments){ for(ResiTopicAttachmentEntity attachment : attachments){

10
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/utils/ModuleConstant.java

@ -137,4 +137,14 @@ public interface ModuleConstant extends Constant {
* 话题Id集合不能为空 * 话题Id集合不能为空
* */ * */
String TOPIC_ID_LIST_NOT_NULL = "话题Id集合不能为空"; String TOPIC_ID_LIST_NOT_NULL = "话题Id集合不能为空";
/**
* 一个组找到多个统计信息
* */
String GROUP_STASTICAL_NOT_SINGLE = "一个组找到多个统计信息";
/**
* 未找到对应的小组统计信息
* */
String NO_SUCH_GROUP_STASTICAL_INFO = "未找到对应的小组统计信息";
} }

12
epmet-module/resi-group/resi-group-server/src/main/resources/mapper/topic/ResiTopicAttachmentDao.xml

@ -27,6 +27,9 @@
<if test ='null != attachmentUrl'> <if test ='null != attachmentUrl'>
attachment_url, attachment_url,
</if> </if>
<if test='null != sort'>
sort,
</if>
<if test ='null != createdBy'> <if test ='null != createdBy'>
created_by, created_by,
</if> </if>
@ -53,6 +56,9 @@
<if test ='null != attachmentUrl'> <if test ='null != attachmentUrl'>
#{attachmentUrl}, #{attachmentUrl},
</if> </if>
<if test='null != sort'>
#{sort},
</if>
<if test ='null != createdBy'> <if test ='null != createdBy'>
#{createdBy}, #{createdBy},
</if> </if>
@ -67,7 +73,7 @@
<!-- 批量插入 --> <!-- 批量插入 -->
<insert id="insertBatch" parameterType="java.util.List"> <insert id="insertBatch" parameterType="java.util.List">
insert into user insert into resi_topic_attachment
( (
id, id,
topic_id, topic_id,
@ -77,6 +83,7 @@
attachment_url, attachment_url,
del_flag, del_flag,
revision, revision,
sort,
created_by, created_by,
created_time, created_time,
updated_by, updated_by,
@ -92,8 +99,9 @@
#{item.attachmentUrl}, #{item.attachmentUrl},
#{item.delFlag}, #{item.delFlag},
#{item.revision}, #{item.revision},
#{item.sort},
#{item.createdBy}, #{item.createdBy},
#{item.createdTime}, now(),
#{item.updatedBy}, #{item.updatedBy},
#{item.updatedTime} #{item.updatedTime}
) )

4
epmet-module/resi-group/resi-group-server/src/main/resources/mapper/topic/ResiTopicDao.xml

@ -112,7 +112,7 @@
SELECT SELECT
attachment.TOPIC_ID AS attachmentTopicId, attachment.TOPIC_ID AS attachmentTopicId,
attachment.ATTACHMENT_URL as firstPhoto, attachment.ATTACHMENT_URL as firstPhoto,
MIN(attachment.CREATED_TIME) AS ATTACHMENT_CREATED_TIME MIN(attachment.SORD)
FROM FROM
RESI_TOPIC_ATTACHMENT attachment RESI_TOPIC_ATTACHMENT attachment
WHERE WHERE
@ -151,7 +151,7 @@
SELECT SELECT
attachment.TOPIC_ID AS attachmentTopicId, attachment.TOPIC_ID AS attachmentTopicId,
attachment.ATTACHMENT_URL as firstPhoto, attachment.ATTACHMENT_URL as firstPhoto,
MIN(attachment.CREATED_TIME) AS ATTACHMENT_CREATED_TIME MIN(attachment.SORT)
FROM FROM
RESI_TOPIC_ATTACHMENT attachment RESI_TOPIC_ATTACHMENT attachment
WHERE WHERE

Loading…
Cancel
Save