|
|
@ -22,6 +22,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.elink.esua.epdc.commons.mybatis.service.impl.BaseServiceImpl; |
|
|
|
import com.elink.esua.epdc.commons.tools.constant.FieldConstant; |
|
|
|
import com.elink.esua.epdc.commons.tools.constant.NumConstant; |
|
|
|
import com.elink.esua.epdc.commons.tools.exception.RenException; |
|
|
|
import com.elink.esua.epdc.commons.tools.page.PageData; |
|
|
|
import com.elink.esua.epdc.commons.tools.utils.ConvertUtils; |
|
|
|
import com.elink.esua.epdc.commons.tools.utils.Result; |
|
|
@ -30,6 +31,7 @@ import com.elink.esua.epdc.dto.GroupTopicCloseFormDTO; |
|
|
|
import com.elink.esua.epdc.dto.PartyTopicDTO; |
|
|
|
import com.elink.esua.epdc.dto.PartyTopicUserAttitudeDTO; |
|
|
|
import com.elink.esua.epdc.dto.PartyUserGroupDTO; |
|
|
|
import com.elink.esua.epdc.dto.constant.PartyGroupConstant; |
|
|
|
import com.elink.esua.epdc.dto.form.PartyTopicFormDTO; |
|
|
|
import com.elink.esua.epdc.dto.form.PartyTopicSubmitFormDTO; |
|
|
|
import com.elink.esua.epdc.dto.form.TopicStatementFormDTO; |
|
|
@ -177,30 +179,45 @@ public class PartyTopicServiceImpl extends BaseServiceImpl<PartyTopicDao, PartyT |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void updateCommentNum(String topicId) { |
|
|
|
baseDao.updateCommentNum(topicId); |
|
|
|
public void updateCommentNum(String topicId,Integer num) { |
|
|
|
baseDao.updateCommentNum(topicId,num); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void updateSupportNum(String topicId) { |
|
|
|
baseDao.updateSupportNum(topicId); |
|
|
|
public void updateSupportNum(String topicId,Integer num) { |
|
|
|
baseDao.updateSupportNum(topicId,num); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void statement(TopicStatementFormDTO formDto) { |
|
|
|
//防连击!
|
|
|
|
//先根据用户和话题获取点赞点踩表数据
|
|
|
|
PartyTopicUserAttitudeDTO partyTopicUserAttitudeDTO = partyTopicUserAttitudeService.getPartyTopicUserAttitudeDTO(formDto.getTopicId(),formDto.getUserId()); |
|
|
|
if(partyTopicUserAttitudeDTO!=null){ |
|
|
|
return; |
|
|
|
} |
|
|
|
//插入点赞点踩表
|
|
|
|
PartyTopicUserAttitudeEntity partyTopicUserAttitudeEntity = new PartyTopicUserAttitudeEntity(); |
|
|
|
partyTopicUserAttitudeEntity.setPartyTopicId(formDto.getTopicId()); |
|
|
|
partyTopicUserAttitudeEntity.setAttitudeFlag(formDto.getAttitude()); |
|
|
|
partyTopicUserAttitudeEntity.setUserId(formDto.getUserId()); |
|
|
|
if(partyTopicUserAttitudeService.insert(partyTopicUserAttitudeEntity)){ |
|
|
|
//更新话题点赞数
|
|
|
|
updateSupportNum(formDto.getTopicId()); |
|
|
|
//判断用户操作
|
|
|
|
if(PartyGroupConstant.TOPIC_SUPPORT.equals(formDto.getAttitude())){//点赞
|
|
|
|
if(partyTopicUserAttitudeDTO!=null){ |
|
|
|
throw new RenException("不能重复点赞"); |
|
|
|
} |
|
|
|
PartyTopicUserAttitudeEntity partyTopicUserAttitudeEntity = new PartyTopicUserAttitudeEntity(); |
|
|
|
//插入点赞点踩表
|
|
|
|
partyTopicUserAttitudeEntity.setPartyTopicId(formDto.getTopicId()); |
|
|
|
partyTopicUserAttitudeEntity.setAttitudeFlag(formDto.getAttitude()); |
|
|
|
partyTopicUserAttitudeEntity.setUserId(formDto.getUserId()); |
|
|
|
if(partyTopicUserAttitudeService.insert(partyTopicUserAttitudeEntity)){ |
|
|
|
//更新话题点赞数
|
|
|
|
updateSupportNum(formDto.getTopicId(),1); |
|
|
|
} |
|
|
|
}else if(PartyGroupConstant.TOPIC_CANCEL_SUPPORT.equals(formDto.getAttitude())){ |
|
|
|
if(partyTopicUserAttitudeDTO==null){ |
|
|
|
throw new RenException("已取消点赞"); |
|
|
|
} |
|
|
|
//删除点赞点踩数据
|
|
|
|
PartyTopicUserAttitudeEntity partyTopicUserAttitudeEntity = new PartyTopicUserAttitudeEntity(); |
|
|
|
partyTopicUserAttitudeEntity.setId(partyTopicUserAttitudeDTO.getId()); |
|
|
|
if(partyTopicUserAttitudeService.realDelete(partyTopicUserAttitudeEntity)){ |
|
|
|
//更新话题点赞数
|
|
|
|
updateSupportNum(formDto.getTopicId(),-1); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|