|
|
|
@ -31,16 +31,19 @@ import com.elink.esua.epdc.dto.enums.GroupStateEnum; |
|
|
|
import com.elink.esua.epdc.dto.enums.GroupUserStateEnum; |
|
|
|
import com.elink.esua.epdc.dto.enums.TopicStateEnum; |
|
|
|
import com.elink.esua.epdc.dto.epdc.form.EpdcInformationFormDTO; |
|
|
|
import com.elink.esua.epdc.dto.events.form.EpdcEventSubmitFormDTO; |
|
|
|
import com.elink.esua.epdc.dto.group.GroupDTO; |
|
|
|
import com.elink.esua.epdc.dto.group.UserGroupDTO; |
|
|
|
import com.elink.esua.epdc.dto.group.result.TopicAuditRecordResultDTO; |
|
|
|
import com.elink.esua.epdc.dto.topic.TopicDTO; |
|
|
|
import com.elink.esua.epdc.dto.topic.TopicListDTO; |
|
|
|
import com.elink.esua.epdc.dto.topic.form.TopicChangeToIssueFormDTO; |
|
|
|
import com.elink.esua.epdc.dto.topic.form.TopicCloseFormDTO; |
|
|
|
import com.elink.esua.epdc.dto.topic.form.TopicSubmitFormDTO; |
|
|
|
import com.elink.esua.epdc.dto.topic.result.TopicDetailResultDTO; |
|
|
|
import com.elink.esua.epdc.dto.topic.result.TopicListResultDTO; |
|
|
|
import com.elink.esua.epdc.modules.async.NewsTask; |
|
|
|
import com.elink.esua.epdc.modules.feign.EventFeignClient; |
|
|
|
import com.elink.esua.epdc.modules.group.service.GroupService; |
|
|
|
import com.elink.esua.epdc.modules.group.service.UserGroupService; |
|
|
|
import com.elink.esua.epdc.modules.topic.dao.TopicDao; |
|
|
|
@ -82,6 +85,9 @@ public class TopicServiceImpl extends BaseServiceImpl<TopicDao, TopicEntity> imp |
|
|
|
@Autowired |
|
|
|
private NewsTask newsTask; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private EventFeignClient eventFeignClient; |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageData<TopicDTO> page(Map<String, Object> params) { |
|
|
|
IPage<TopicEntity> page = baseDao.selectPage( |
|
|
|
@ -153,7 +159,15 @@ public class TopicServiceImpl extends BaseServiceImpl<TopicDao, TopicEntity> imp |
|
|
|
|
|
|
|
@Override |
|
|
|
public TopicDetailResultDTO getTopicDetailById(String id) { |
|
|
|
return baseDao.selectOneOfTopicDetailById(id); |
|
|
|
TopicDetailResultDTO resultDto = baseDao.selectOneOfTopicDetailById(id); |
|
|
|
if (null != resultDto) { |
|
|
|
// 更新浏览次数
|
|
|
|
TopicEntity entity = new TopicEntity(); |
|
|
|
entity.setId(id); |
|
|
|
entity.setBrowseNum(resultDto.getBrowseNum() + 1); |
|
|
|
this.updateById(entity); |
|
|
|
} |
|
|
|
return resultDto; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@ -211,4 +225,60 @@ public class TopicServiceImpl extends BaseServiceImpl<TopicDao, TopicEntity> imp |
|
|
|
public List<TopicListResultDTO> apiList(TopicListDTO topicListDTO) { |
|
|
|
return baseDao.apiList(topicListDTO); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public Result changeToIssue(TopicChangeToIssueFormDTO formDto) { |
|
|
|
TopicDTO topicDto = this.get(formDto.getId()); |
|
|
|
// 校验
|
|
|
|
Result checkResult = this.checkTopicToIssue(topicDto, formDto.getUserId()); |
|
|
|
if (!checkResult.success()) { |
|
|
|
return checkResult; |
|
|
|
} |
|
|
|
// 插入事件表
|
|
|
|
EpdcEventSubmitFormDTO eventSubmitFormDto = baseDao.selectOneOfTopicForChangeToIssue(formDto.getId()); |
|
|
|
Result eventResult = eventFeignClient.submitEvent(eventSubmitFormDto); |
|
|
|
if (!eventResult.success()) { |
|
|
|
return eventResult; |
|
|
|
} |
|
|
|
|
|
|
|
// 更新话题状态
|
|
|
|
TopicEntity entity = new TopicEntity(); |
|
|
|
entity.setId(formDto.getId()); |
|
|
|
entity.setState(TopicStateEnum.TOPIC_STATE_CHANGE_TO_ISSUE_PENDING_REVIEW.getValue()); |
|
|
|
if (updateById(entity)) { |
|
|
|
return new Result(); |
|
|
|
} |
|
|
|
|
|
|
|
return new Result().error(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* |
|
|
|
* 话题转议题校验 |
|
|
|
* |
|
|
|
* @params [topicDto, userId] |
|
|
|
* @return com.elink.esua.epdc.commons.tools.utils.Result |
|
|
|
* @author liuchuang |
|
|
|
* @since 2019/11/8 11:16 |
|
|
|
*/ |
|
|
|
private Result checkTopicToIssue(TopicDTO topicDto, String userId) { |
|
|
|
// 校验社群状态
|
|
|
|
GroupDTO groupDto = groupService.get(topicDto.getGroupId()); |
|
|
|
if (null == groupDto || GroupStateEnum.GROUP_STATE_DISBANDED.getValue().equals(groupDto.getState())) { |
|
|
|
return new Result().error("话题转议题失败,当前社群已解散"); |
|
|
|
} |
|
|
|
// 校验用户身份
|
|
|
|
UserGroupDTO userDto = userGroupService.getGroupUserInfo(topicDto.getGroupId(), userId, GroupUserStateEnum.GROUP_USER_STATE_EXAMINATION_PASSED.getValue()); |
|
|
|
if (null == userDto || !NumConstant.ONE_STR.equals(userDto.getLordFlag())) { |
|
|
|
return new Result().error("您不是群主,不可以转为议题"); |
|
|
|
} |
|
|
|
// 校验话题状态
|
|
|
|
if (!TopicStateEnum.TOPIC_STATE_IN_CONVERSATION.getValue().equals(topicDto.getState())) { |
|
|
|
return new Result().error("当前话题不是讨论中状态,不可以转为议题"); |
|
|
|
} |
|
|
|
|
|
|
|
return new Result(); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|