|
@ -24,9 +24,11 @@ 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.ConvertUtils; |
|
|
import com.elink.esua.epdc.commons.tools.constant.FieldConstant; |
|
|
import com.elink.esua.epdc.commons.tools.constant.FieldConstant; |
|
|
import com.elink.esua.epdc.dto.TopicCommentUserAttitudeDTO; |
|
|
import com.elink.esua.epdc.dto.TopicCommentUserAttitudeDTO; |
|
|
|
|
|
import com.elink.esua.epdc.dto.comment.TopicCommentStatementFormDTO; |
|
|
import com.elink.esua.epdc.modules.comment.dao.TopicCommentUserAttitudeDao; |
|
|
import com.elink.esua.epdc.modules.comment.dao.TopicCommentUserAttitudeDao; |
|
|
import com.elink.esua.epdc.modules.comment.entity.TopicCommentUserAttitudeEntity; |
|
|
import com.elink.esua.epdc.modules.comment.entity.TopicCommentUserAttitudeEntity; |
|
|
import com.elink.esua.epdc.modules.comment.redis.TopicCommentUserAttitudeRedis; |
|
|
import com.elink.esua.epdc.modules.comment.redis.TopicCommentUserAttitudeRedis; |
|
|
|
|
|
import com.elink.esua.epdc.modules.comment.service.TopicCommentService; |
|
|
import com.elink.esua.epdc.modules.comment.service.TopicCommentUserAttitudeService; |
|
|
import com.elink.esua.epdc.modules.comment.service.TopicCommentUserAttitudeService; |
|
|
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; |
|
@ -48,6 +50,8 @@ public class TopicCommentUserAttitudeServiceImpl extends BaseServiceImpl<TopicCo |
|
|
|
|
|
|
|
|
@Autowired |
|
|
@Autowired |
|
|
private TopicCommentUserAttitudeRedis topicCommentUserAttitudeRedis; |
|
|
private TopicCommentUserAttitudeRedis topicCommentUserAttitudeRedis; |
|
|
|
|
|
@Autowired |
|
|
|
|
|
private TopicCommentService topicCommentService; |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public PageData<TopicCommentUserAttitudeDTO> page(Map<String, Object> params) { |
|
|
public PageData<TopicCommentUserAttitudeDTO> page(Map<String, Object> params) { |
|
@ -101,4 +105,63 @@ public class TopicCommentUserAttitudeServiceImpl extends BaseServiceImpl<TopicCo |
|
|
baseDao.deleteBatchIds(Arrays.asList(ids)); |
|
|
baseDao.deleteBatchIds(Arrays.asList(ids)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
|
|
public void statement(TopicCommentStatementFormDTO formDto) { |
|
|
|
|
|
//根据用户id和事件id查询记录
|
|
|
|
|
|
QueryWrapper<TopicCommentUserAttitudeEntity> wrapper = new QueryWrapper<>(); |
|
|
|
|
|
wrapper.eq(StringUtils.isNotBlank(formDto.getUseId()), "USER_ID", formDto.getUseId()); |
|
|
|
|
|
wrapper.eq(StringUtils.isNotBlank(formDto.getCommentId()), "COMMENT_ID", formDto.getCommentId()); |
|
|
|
|
|
TopicCommentUserAttitudeEntity topicCommentUserAttitudeEntity = baseDao.selectOne(wrapper); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ("0".equals(formDto.getAttitude()) || "1".equals(formDto.getAttitude())){ |
|
|
|
|
|
if (topicCommentUserAttitudeEntity == null){ |
|
|
|
|
|
//没有点赞或者点踩,直接插入数据
|
|
|
|
|
|
TopicCommentUserAttitudeDTO topicCommentUserAttitudeDTO = new TopicCommentUserAttitudeDTO(); |
|
|
|
|
|
topicCommentUserAttitudeDTO.setCommentId(formDto.getCommentId()); |
|
|
|
|
|
topicCommentUserAttitudeDTO.setUserId(formDto.getUseId()); |
|
|
|
|
|
topicCommentUserAttitudeDTO.setAttitudeFlag(formDto.getAttitude()); |
|
|
|
|
|
this.save(topicCommentUserAttitudeDTO); |
|
|
|
|
|
|
|
|
|
|
|
if ("0".equals(formDto.getAttitude())){ |
|
|
|
|
|
topicCommentService.updateApproveNumAdd(formDto.getCommentId()); |
|
|
|
|
|
} |
|
|
|
|
|
if ("1".equals(formDto.getAttitude())){ |
|
|
|
|
|
topicCommentService.updateOpposeNumAdd(formDto.getCommentId()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
}else { |
|
|
|
|
|
if (!formDto.getAttitude().equals(topicCommentUserAttitudeEntity.getAttitudeFlag())){ |
|
|
|
|
|
topicCommentUserAttitudeEntity.setAttitudeFlag(formDto.getAttitude()); |
|
|
|
|
|
this.updateById(topicCommentUserAttitudeEntity); |
|
|
|
|
|
|
|
|
|
|
|
if ("0".equals(formDto.getAttitude())){ |
|
|
|
|
|
//赞数加1 踩数减一
|
|
|
|
|
|
topicCommentService.updateApproveNumAdd(formDto.getCommentId()); |
|
|
|
|
|
topicCommentService.updateOpposeNumSubtract(formDto.getCommentId()); |
|
|
|
|
|
}else { |
|
|
|
|
|
//踩数加一 赞数减一
|
|
|
|
|
|
topicCommentService.updateOpposeNumAdd(formDto.getCommentId()); |
|
|
|
|
|
topicCommentService.updateApproveNumSubtract(formDto.getCommentId()); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}else { |
|
|
|
|
|
//删除点赞或踩的记录,如果重新点赞或踩则重新插入
|
|
|
|
|
|
this.deleteById(topicCommentUserAttitudeEntity.getId()); |
|
|
|
|
|
if ("2".equals(formDto.getAttitude())){ |
|
|
|
|
|
//取消赞
|
|
|
|
|
|
topicCommentService.updateApproveNumSubtract(formDto.getCommentId()); |
|
|
|
|
|
} |
|
|
|
|
|
if ("3".equals(formDto.getAttitude())){ |
|
|
|
|
|
//取消踩
|
|
|
|
|
|
topicCommentService.updateOpposeNumSubtract(formDto.getCommentId()); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|