Browse Source

接口名称修改,getlatesttentopics改成getlatesttopics,错误信息封装常量

master
wangchao 5 years ago
parent
commit
933df5a0ef
  1. 24
      epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/topic/form/ResiTopicCancelHiddenFormDTO.java
  2. 2
      epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/topic/form/ResiTopicPublishFormDTO.java
  3. 10
      epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/topic/result/ResiTopicDetailResultDTO.java
  4. 2
      epmet-module/resi-group/resi-group-server/pom.xml
  5. 2
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/redis/ResiGroupRedis.java
  6. 2
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/impl/ResiGroupServiceImpl.java
  7. 10
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/controller/ResiTopicController.java
  8. 2
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/ResiTopicService.java
  9. 9
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/impl/ResiTopicCommentServiceImpl.java
  10. 33
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/impl/ResiTopicServiceImpl.java
  11. 40
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/utils/ModuleConstant.java
  12. 1
      epmet-module/resi-group/resi-group-server/src/main/resources/mapper/topic/ResiTopicCommentDao.xml
  13. 80
      epmet-module/resi-group/resi-group-server/src/main/resources/mapper/topic/ResiTopicDao.xml

24
epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/topic/form/ResiTopicCancelHiddenFormDTO.java

@ -0,0 +1,24 @@
package com.epmet.resi.group.dto.topic.form;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
import java.util.List;
/**
* @Description
* @ClassName ResiTopicCancelHiddenFormDTO
* @Author wangc
* @date 2020.04.07 15:10
*/
@Data
public class ResiTopicCancelHiddenFormDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 需要解除屏蔽的话题Id集合
* */
private List<String> topicIds;
}

2
epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/topic/form/ResiTopicPublishFormDTO.java

@ -32,13 +32,11 @@ public class ResiTopicPublishFormDTO implements Serializable {
/**
* 经度
* */
@NotBlank(message = "缺失经纬度信息")
private String longitude;
/**
* 纬度
* */
@NotBlank(message = "缺失经纬度信息")
private String dimension;
/**

10
epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/topic/result/ResiTopicDetailResultDTO.java

@ -36,11 +36,21 @@ public class ResiTopicDetailResultDTO implements Serializable {
* */
private String releaseTime;
/**
* 发布地址
* */
private String releaseAddress;
/**
* 话题内容
* */
private String topicContent;
/**
* 话题状态
* */
private String topicStatus;
/**
* 图片访问地址
* */

2
epmet-module/resi-group/resi-group-server/pom.xml

@ -122,7 +122,7 @@
</profile>
<profile>
<id>test</id>
<!-- <activation>
<!-- <activation>
<activeByDefault>true</activeByDefault>
</activation>-->
<properties>

2
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/redis/ResiGroupRedis.java

@ -15,7 +15,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.redis;
package com.epmet.modules.group.redis;
import com.epmet.commons.tools.redis.RedisUtils;
import org.springframework.beans.factory.annotation.Autowired;

2
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/impl/ResiGroupServiceImpl.java

@ -25,7 +25,6 @@ import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.UserResiInfoDTO;
@ -45,7 +44,6 @@ import com.epmet.modules.member.dao.ResiGroupMemberDao;
import com.epmet.modules.member.service.GroupMemeberOperationService;
import com.epmet.modules.member.service.ResiGroupMemberService;
import com.epmet.modules.utils.ModuleConstant;
import com.epmet.redis.ResiGroupRedis;
import com.epmet.resi.group.constant.EnterGroupTypeConstant;
import com.epmet.resi.group.constant.GroupStateConstant;
import com.epmet.resi.group.constant.LeaderFlagConstant;

10
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/controller/ResiTopicController.java

@ -78,10 +78,10 @@ public class ResiTopicController {
* @Author wangc
* @Date 2020.04.02 00:01
**/
@PostMapping("getlatesttentopics")
Result<List<ResiTopicInfoResultDTO>> getLatestTenTopics(@LoginUser TokenDto tokenDto,@RequestBody ResiTopicDefaultPageFormDTO topicDefaultPageFormDTO){
@PostMapping("getlatesttopics")
Result<List<ResiTopicInfoResultDTO>> getLatestTopics(@LoginUser TokenDto tokenDto,@RequestBody ResiTopicDefaultPageFormDTO topicDefaultPageFormDTO){
ValidatorUtils.validateEntity(topicDefaultPageFormDTO);
return topicService.getLatestTenTopics(tokenDto,topicDefaultPageFormDTO.getGroupId());
return topicService.getLatestTopics(tokenDto,topicDefaultPageFormDTO.getGroupId());
}
/**
@ -121,8 +121,8 @@ public class ResiTopicController {
* @Date 2020.04.01 14:17
**/
@PostMapping("cancelhiddentopics")
Result cancelHiddenTopics(@LoginUser TokenDto tokenDto,@RequestBody List<String> topicIds){
return topicService.cancelHiddenTopics(tokenDto,topicIds);
Result cancelHiddenTopics(@LoginUser TokenDto tokenDto,@RequestBody ResiTopicCancelHiddenFormDTO cancelHiddenFormDTO){
return topicService.cancelHiddenTopics(tokenDto,cancelHiddenFormDTO.getTopicIds());
}
/**

2
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/ResiTopicService.java

@ -120,7 +120,7 @@ public interface ResiTopicService extends BaseService<ResiTopicEntity> {
* @Author wangc
* @Date 2020.04.01 08:59
**/
Result<List<ResiTopicInfoResultDTO>> getLatestTenTopics(TokenDto tokenDto,String groupId);
Result<List<ResiTopicInfoResultDTO>> getLatestTopics(TokenDto tokenDto,String groupId);
/**
* @Description 查看历史话题(分页,允许状态筛选)

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

@ -32,6 +32,7 @@ import com.epmet.modules.member.service.ResiGroupMemberService;
import com.epmet.modules.topic.dao.ResiTopicCommentDao;
import com.epmet.modules.topic.service.ResiTopicCommentService;
import com.epmet.modules.topic.service.ResiTopicService;
import com.epmet.modules.utils.ModuleConstant;
import com.epmet.resi.group.constant.MemberStateConstant;
import com.epmet.resi.group.constant.TopicConstant;
import com.epmet.resi.group.dto.comment.form.ResiQueryCommentFormDTO;
@ -139,20 +140,20 @@ public class ResiTopicCommentServiceImpl extends BaseServiceImpl<ResiTopicCommen
if(null != resiGroupMemberDTO){
if(MemberStateConstant.SILENT.equals(resiGroupMemberDTO.getStatus())){
//当前用户被禁言
return new Result().error();
return new Result().error(ModuleConstant.SLIENT_MEMBER);
}else if(MemberStateConstant.REMOVED.equals(resiGroupMemberDTO.getStatus())){
//当前用户已被移出群
return new Result().error();
return new Result().error(ModuleConstant.REMOVED_MEMBER);
}
}else{
//当前用户非组内成员
return new Result().error();
return new Result().error(ModuleConstant.NOT_BELONG_TO_CURRENT_GROUP);
}
if(resiCommentFormDTO.getCommentContent().length() > TopicConstant.MAX_NUMBER_OF_COMMENT){
return new Result().error();
return new Result().error(ModuleConstant.COMMENT_NUMBER_OF_WORDS_EXCEEDED);
}
ResiTopicCommentEntity comment = ConvertUtils.sourceToTarget(resiCommentFormDTO,ResiTopicCommentEntity.class);
comment.setStatus(TopicConstant.PUBLISHMENT);

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

@ -172,7 +172,7 @@ public class ResiTopicServiceImpl extends BaseServiceImpl<ResiTopicDao, ResiTopi
//2.创建话题
if(resiTopicPublishFormDTO.getTopicContent().length() > TopicConstant.MAX_NUMBER_OF_CONTENT){
//内容超过最大限制
return new Result().error();
return new Result().error(ModuleConstant.TOPIC_CONTENT_NUMBER_OF_WORDS_EXCEEDED);
}
ResiTopicEntity topic = ConvertUtils.sourceToTarget(resiTopicPublishFormDTO,ResiTopicEntity.class);
topic.setCreatedBy(tokenDto.getUserId());
@ -180,7 +180,7 @@ public class ResiTopicServiceImpl extends BaseServiceImpl<ResiTopicDao, ResiTopi
baseDao.insertOne(topic);
if(StringUtils.isBlank(topic.getId())){
//没有返回主键
return new Result().error();
return new Result().error(ModuleConstant.NO_PRIMARY_KEY_RETURNED);
}
if(null != resiTopicPublishFormDTO.getAttachmentList() && resiTopicPublishFormDTO.getAttachmentList().size() > 0){
ResiTopicAttachmentEntity attachment = new ResiTopicAttachmentEntity();
@ -211,7 +211,7 @@ public class ResiTopicServiceImpl extends BaseServiceImpl<ResiTopicDao, ResiTopi
* @Date 2020.04.01 08:59
**/
@Override
public Result<List<ResiTopicInfoResultDTO>> getLatestTenTopics(TokenDto tokenDto, String groupId) {
public Result<List<ResiTopicInfoResultDTO>> getLatestTopics(TokenDto tokenDto, String groupId) {
if (null == tokenDto) {
return new Result().error(ModuleConstant.USER_NOT_NULL);
}
@ -314,6 +314,10 @@ public class ResiTopicServiceImpl extends BaseServiceImpl<ResiTopicDao, ResiTopi
@Transactional(rollbackFor = Exception.class)
public Result cancelHiddenTopics(TokenDto tokenDto, List<String> topicIds) {
if(null == topicIds || topicIds.size() <= 0){
return new Result().error(ModuleConstant.TOPIC_ID_LIST_NOT_NULL);
}
//1.1拿到组Id
ResiTopicEntity topic = baseDao.selectById(topicIds.get(0));
@ -393,10 +397,14 @@ public class ResiTopicServiceImpl extends BaseServiceImpl<ResiTopicDao, ResiTopi
//1.获取话题基本信息
ResiTopicEntity topicDetail = baseDao.selectById(topicId);
if(null == topicDetail || !StringUtils.equals(topicDetail.getId(),topicId)){
return new Result().error();
return new Result().error(ModuleConstant.NO_SUCH_TOPIC);
}
ResiTopicDetailResultDTO resultDTO = new ResiTopicDetailResultDTO();
resultDTO.setTopicId(topicId);
resultDTO.setReleaseTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(topicDetail.getCreatedTime()));
resultDTO.setTopicContent(topicDetail.getTopicContent());
resultDTO.setReleaseAddress(topicDetail.getAddress());
resultDTO.setTopicStatus(topicDetail.getStatus());
//2.查询话题附件
QueryWrapper<ResiTopicAttachmentEntity> wrapper = new QueryWrapper<>();
wrapper.eq(TopicConstant.TOPIC_ID,topicId);
@ -409,8 +417,6 @@ public class ResiTopicServiceImpl extends BaseServiceImpl<ResiTopicDao, ResiTopi
}
resultDTO.setTopicImgs(attachmentUrls);
resultDTO.setReleaseTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(topicDetail.getCreatedTime()));
resultDTO.setTopicContent(topicDetail.getTopicContent());
//3.拿取用户信息
ResiTopicDTO topic = get(topicId);
@ -467,16 +473,16 @@ public class ResiTopicServiceImpl extends BaseServiceImpl<ResiTopicDao, ResiTopi
if(null != resiGroupMemberDTO){
if(MemberStateConstant.SILENT.equals(resiGroupMemberDTO.getStatus())){
//当前用户被禁言
return new Result().error();
return new Result().error(ModuleConstant.SLIENT_MEMBER);
}else if(MemberStateConstant.REMOVED.equals(resiGroupMemberDTO.getStatus())){
//当前用户已被移出群
return new Result().error();
return new Result().error(ModuleConstant.REMOVED_MEMBER);
}else{
return new Result();
}
}else{
//当前用户非组内成员
return new Result().error();
return new Result().error(ModuleConstant.NOT_BELONG_TO_CURRENT_GROUP);
}
}
@ -494,15 +500,18 @@ public class ResiTopicServiceImpl extends BaseServiceImpl<ResiTopicDao, ResiTopi
//1.2判断是否是组长
if(!StringUtils.equals(leaderVerify.getCustomerUserId(),userId)){
//非组长,无权限进行操作
return new Result().error();
return new Result().error(ModuleConstant.NO_TEAMLEADER_AUTH);
}else{
//是组长
return new Result();
}
}else{
return new Result().error();
//未找到当前用户的成员信息
return new Result().error(ModuleConstant.NOT_BELONG_TO_CURRENT_GROUP);
}
}else{
return new Result().error();
//未能识别该话题基本信息
return new Result().error(ModuleConstant.NO_SUCH_TOPIC);
}
}

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

@ -97,4 +97,44 @@ public interface ModuleConstant extends Constant {
* 生成邀请新成员链接时判断群状态
*/
String CANNOT_SHARED="只有讨论中的群才可以邀请新成员";
/**
* 话题内容超过字数限制
* */
String TOPIC_CONTENT_NUMBER_OF_WORDS_EXCEEDED = "话题内容超过字数限制(3000)";
/**
* 评论内容超过字数限制
* */
String COMMENT_NUMBER_OF_WORDS_EXCEEDED = "评论内容超过字数限制(300)";
/**
* 没有返回主键
*/
String NO_PRIMARY_KEY_RETURNED = "没有返回主键";
/**
* 没有找到所在话题
* */
String NO_SUCH_TOPIC = "没有找到所在话题";
/**
* 当前用户被禁言
* */
String SLIENT_MEMBER = "您已被禁言";
/**
* 当前用户被移出群
* */
String REMOVED_MEMBER = "您已被移除群";
/**
* 当前用户不是组长
* */
String NO_TEAMLEADER_AUTH = "您没有组长权限";
/**
* 话题Id集合不能为空
* */
String TOPIC_ID_LIST_NOT_NULL = "话题Id集合不能为空";
}

1
epmet-module/resi-group/resi-group-server/src/main/resources/mapper/topic/ResiTopicCommentDao.xml

@ -65,6 +65,7 @@
DEL_FLAG = '0'
AND
TOPIC_ID = #{topicId}
ORDER BY CREATED_TIME DESC
LIMIT
#{pageNo},#{pageSize}
</select>

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

@ -93,56 +93,86 @@
<!-- 查询最近十条话题 -->
<select id="getLatestTenTopics" parameterType="string" resultType="com.epmet.resi.group.dto.topic.result.ResiTopicInfoResultDTO">
SELECT
ID AS topicId,
GROUP_ID,
TOPIC_CONTENT,
STATUS,
CREATED_TIME AS releaseTime,
CREATED_BY AS userId,
topic.ID AS topicId,
topic.GROUP_ID,
topic.TOPIC_CONTENT,
topic.STATUS,
topic.CREATED_TIME AS releaseTime,
topic.CREATED_BY AS userId,
attachement2.firstPhoto,
CASE
WHEN CREATED_BY = #{userId} THEN 'me'
WHEN topic.CREATED_BY = #{userId} THEN 'me'
ELSE 'other'
END AS releaseUserFlag
FROM
RESI_TOPIC
RESI_TOPIC topic
LEFT JOIN
(
SELECT
attachment.TOPIC_ID AS attachmentTopicId,
attachment.ATTACHMENT_URL as firstPhoto,
MIN(attachment.CREATED_TIME) AS ATTACHMENT_CREATED_TIME
FROM
RESI_TOPIC_ATTACHMENT attachment
WHERE
attachment.DEL_FLAG = '0'
GROUP BY attachment.TOPIC_ID
) attachement2
ON
topic.ID = attachement2.attachmentTopicId
WHERE
DEL_FLAG = '0'
AND <![CDATA[ STATUS <> 'hidden' ]]>
AND GROUP_ID = #{groupId}
topic.DEL_FLAG = '0'
AND <![CDATA[ topic.STATUS <> 'hidden' ]]>
AND topic.GROUP_ID = #{groupId}
ORDER BY
CREATED_TIME DESC
topic.CREATED_TIME DESC
LIMIT 10
</select>
<!-- 查询历史话题,分页,参数查询 -->
<select id="getPastTopics" parameterType="com.epmet.resi.group.dto.topic.form.ResiTopicPageFormDTO" resultType="com.epmet.resi.group.dto.topic.result.ResiTopicInfoResultDTO">
SELECT
ID AS topicId,
GROUP_ID,
TOPIC_CONTENT,
STATUS,
CREATED_TIME AS releaseTime,
CREATED_BY AS userId,
topic.ID AS topicId,
topic.GROUP_ID,
topic.TOPIC_CONTENT,
topic.STATUS,
topic.CREATED_TIME AS releaseTime,
topic.CREATED_BY AS userId,
attachement2.firstPhoto,
CASE
WHEN CREATED_BY = #{userId} THEN 'me'
WHEN topic.CREATED_BY = #{userId} THEN 'me'
ELSE 'other'
END AS releaseUserFlag
FROM
RESI_TOPIC
RESI_TOPIC topic
LEFT JOIN
(
SELECT
attachment.TOPIC_ID AS attachmentTopicId,
attachment.ATTACHMENT_URL as firstPhoto,
MIN(attachment.CREATED_TIME) AS ATTACHMENT_CREATED_TIME
FROM
RESI_TOPIC_ATTACHMENT attachment
WHERE
attachment.DEL_FLAG = '0'
GROUP BY attachment.TOPIC_ID
) attachement2
ON
topic.ID = attachement2.attachmentTopicId
<where>
DEL_FLAG = '0'
AND GROUP_ID = #{groupId}
topic.DEL_FLAG = '0'
AND topic.GROUP_ID = #{groupId}
<if test='"hidden" != status'>
AND <![CDATA[ STATUS <> 'hidden' ]]>
AND <![CDATA[ topic.STATUS <> 'hidden' ]]>
</if>
<if test='null != status and "" != status'>
AND STATUS = #{status}
AND topic.STATUS = #{status}
</if>
</where>
ORDER BY
CREATED_TIME DESC
topic.CREATED_TIME DESC
LIMIT #{pageNo},#{pageSize}
</select>

Loading…
Cancel
Save