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.setHashValueSerializer(new JsonRedisSerializer<>(Object.class));
redisTemplate.setConnectionFactory(factory);
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";
/**
* 构造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;
/**
* 排序字段解决多张图片的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.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.UserResiInfoDTO;
import com.epmet.dto.form.UserResiInfoFormDTO;
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){

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

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

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

Loading…
Cancel
Save