|
@@ -0,0 +1,450 @@
|
|
|
+package com.chelvc.cloud.vehicle.server.service.impl;
|
|
|
+
|
|
|
+import cn.hutool.extra.spring.SpringUtil;
|
|
|
+import com.baomidou.lock.annotation.Lock4j;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.chelvc.cloud.uc.api.dto.UserDTO;
|
|
|
+import com.chelvc.cloud.uc.api.service.UserService;
|
|
|
+import com.chelvc.cloud.vehicle.api.constant.*;
|
|
|
+import com.chelvc.cloud.vehicle.api.dto.DynamicContentDTO;
|
|
|
+import com.chelvc.cloud.vehicle.api.dto.DynamicEvaluateRecordDTO;
|
|
|
+import com.chelvc.cloud.vehicle.api.param.AddDynamicContentParam;
|
|
|
+import com.chelvc.cloud.vehicle.api.param.AddDynamicResourceParam;
|
|
|
+import com.chelvc.cloud.vehicle.api.param.QueryAdminDynamicParam;
|
|
|
+import com.chelvc.cloud.vehicle.api.param.QueryDynamicContentParam;
|
|
|
+import com.chelvc.cloud.vehicle.server.dao.DynamicCommentMapper;
|
|
|
+import com.chelvc.cloud.vehicle.server.dao.DynamicContentMapper;
|
|
|
+import com.chelvc.cloud.vehicle.server.entity.DynamicComment;
|
|
|
+import com.chelvc.cloud.vehicle.server.entity.DynamicContent;
|
|
|
+import com.chelvc.cloud.vehicle.server.entity.DynamicResource;
|
|
|
+import com.chelvc.cloud.vehicle.server.service.DynamicContentService;
|
|
|
+import com.chelvc.cloud.vehicle.server.service.DynamicEvaluateRecordService;
|
|
|
+import com.chelvc.cloud.vehicle.server.service.DynamicResourceService;
|
|
|
+import com.chelvc.framework.base.exception.ResourceUnavailableException;
|
|
|
+import com.chelvc.framework.common.model.PagedVO;
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.apache.dubbo.config.annotation.DubboReference;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.Objects;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @PACKAGE_NAME: net.yeeu.collision.dynamic.service.impl
|
|
|
+ * @NAME: DynamicContentServiceImpl
|
|
|
+ * @USER: igl
|
|
|
+ * @DATE: 2023/8/8 14:25
|
|
|
+ */
|
|
|
+@Service
|
|
|
+@Slf4j
|
|
|
+@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
|
|
+public class DynamicContentServiceImpl implements DynamicContentService, com.chelvc.cloud.vehicle.api.service.DynamicContentService {
|
|
|
+ private final DynamicContentMapper baseMapper;
|
|
|
+ @DubboReference
|
|
|
+ private final UserService userService;
|
|
|
+ DynamicEvaluateRecordService dynamicEvaluateRecordService;
|
|
|
+ private final DynamicResourceService contentDynamicResourceService;
|
|
|
+ private final DynamicCommentMapper dynamicCommentMapper;
|
|
|
+
|
|
|
+ //private final ContentAuditHelper contentAuditHelper;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public DynamicContentDTO queryById(Long id, Long selfUserId) {
|
|
|
+ DynamicContentDTO dynamicContentDTO = baseMapper.queryById(id);
|
|
|
+ if (dynamicContentDTO == null) {
|
|
|
+ throw new ResourceUnavailableException("动态不存在");
|
|
|
+ }
|
|
|
+ Long userId = dynamicContentDTO.getUserId();
|
|
|
+ UserDTO user = userService.getUser(userId);
|
|
|
+ dynamicContentDTO.setUserDTO(user);
|
|
|
+ if(selfUserId == null){
|
|
|
+ return dynamicContentDTO;
|
|
|
+ }
|
|
|
+ DynamicEvaluateRecordService service = getContentEvaluateRecordService();
|
|
|
+ DynamicEvaluateRecordDTO dto = service.queryOperaterType(dynamicContentDTO.getId(),
|
|
|
+ selfUserId, RecordType.DYNAMIC.getValue());
|
|
|
+ if (dto == null) {
|
|
|
+ dynamicContentDTO.setClickStatus(0);
|
|
|
+ } else {
|
|
|
+ dynamicContentDTO.setClickStatus(dto.getOperaterType());
|
|
|
+ }
|
|
|
+ return dynamicContentDTO;
|
|
|
+ }
|
|
|
+
|
|
|
+ //解决循环依赖
|
|
|
+ public DynamicEvaluateRecordService getContentEvaluateRecordService() {
|
|
|
+ this.dynamicEvaluateRecordService = SpringUtil.getBean(DynamicEvaluateRecordService.class);
|
|
|
+ return dynamicEvaluateRecordService;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public IPage<DynamicContentDTO> queryPageList(QueryDynamicContentParam param, Integer pageNum,
|
|
|
+ Integer pageSize) {
|
|
|
+ String keyWord = param.getKeyWord();
|
|
|
+ Integer type = param.getType().getValue();
|
|
|
+ Page<DynamicContentDTO> page = new Page<>(pageNum, pageSize);
|
|
|
+ IPage<DynamicContentDTO> result = null;
|
|
|
+ if (Objects.equals(DynamicType.HOTTEST.getValue(), type)) {
|
|
|
+ result = baseMapper.queryHot(page, queryHotWrapper(keyWord, param.getUserId()));
|
|
|
+ } /*else if (Objects.equals(DynamicType.ATTENTION.getValue(), type)) {
|
|
|
+ result = baseMapper
|
|
|
+ .selectAttention(page, queryAttentionWrapper(keyWord), userId);
|
|
|
+ } */else if (Objects.equals(DynamicType.LATEST.getValue(), type)) {
|
|
|
+ result = baseMapper
|
|
|
+ .queryAll(page, queryAllWrapper(keyWord, param.getUserId()));
|
|
|
+ } else if (Objects.equals(DynamicType.DISCOVER.getValue(), type)) {
|
|
|
+ result = baseMapper
|
|
|
+ .queryRandom(page, queryRandomWrapper(keyWord, param.getUserId()));
|
|
|
+ }
|
|
|
+ return getResult(result, true, param.getUserId());
|
|
|
+ }
|
|
|
+
|
|
|
+ public IPage<DynamicContentDTO> getResult(IPage<DynamicContentDTO> result, boolean b, Long selfUserId) {
|
|
|
+ if (result == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ List<DynamicContentDTO> records = result.getRecords();
|
|
|
+ log.info("动态信息总数:" + records.size());
|
|
|
+ log.info("动态信息:" + records);
|
|
|
+ DynamicEvaluateRecordService service = getContentEvaluateRecordService();
|
|
|
+ if (!records.isEmpty()) {
|
|
|
+ List<Long> userIds = records.stream().map(DynamicContentDTO::getUserId).collect(
|
|
|
+ Collectors.toList());
|
|
|
+ Map<Long, UserDTO> longUserBaseInfoMap = userService.queryUserByIds(
|
|
|
+ userIds);
|
|
|
+ log.info("远程查询用户信息成功:{}", longUserBaseInfoMap);
|
|
|
+ if(selfUserId != null){
|
|
|
+ records.forEach(e -> {
|
|
|
+ e.setUserDTO(longUserBaseInfoMap == null ? new UserDTO() :
|
|
|
+ longUserBaseInfoMap.get(e.getUserId()));
|
|
|
+ if(b){
|
|
|
+ DynamicEvaluateRecordDTO dto = service.queryOperaterType(e.getId(),
|
|
|
+ selfUserId, RecordType.DYNAMIC.getValue());
|
|
|
+ if (dto == null) {
|
|
|
+ e.setClickStatus(0);
|
|
|
+ } else {
|
|
|
+ e.setClickStatus(dto.getOperaterType());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ public QueryWrapper<DynamicContent> queryAllWrapper(String keyWord, Long userId) {
|
|
|
+ QueryWrapper<DynamicContent> lqw = Wrappers.query();
|
|
|
+ return format(lqw, keyWord, userId);
|
|
|
+ }
|
|
|
+
|
|
|
+ public QueryWrapper<DynamicContent> queryAttentionWrapper(String keyWord) {
|
|
|
+ List<String> list = new ArrayList<>();
|
|
|
+ QueryWrapper<DynamicContent> lqw = Wrappers.query();
|
|
|
+ lqw.eq("t1.is_deleted", 0);
|
|
|
+ lqw.eq("t1.platform_status", 0);
|
|
|
+ lqw.like(StringUtils.isNotBlank(keyWord), "t1.text_content", keyWord);
|
|
|
+ lqw.eq("t1.status", 0);
|
|
|
+ lqw.inSql("t1.user_id",
|
|
|
+ "SELECT t2.target FROM collision_user.user_attention t2 WHERE t2.user_id = #{userId}");
|
|
|
+ list.add("t1.create_time");
|
|
|
+ list.add("t1.id");
|
|
|
+ lqw.orderByDesc(list.toString());
|
|
|
+ return lqw;
|
|
|
+ }
|
|
|
+
|
|
|
+ public QueryWrapper<DynamicContent> queryRandomWrapper(String keyWord, Long userId) {
|
|
|
+ QueryWrapper<DynamicContent> lqw = Wrappers.query();
|
|
|
+ lqw.eq("t1.is_deleted", 0);
|
|
|
+ lqw.eq("t1.platform_status", 0);
|
|
|
+ lqw.like(StringUtils.isNotBlank(keyWord), "t1.text_content", keyWord);
|
|
|
+ lqw.and(wq -> wq
|
|
|
+ .eq("t1.status", 0)
|
|
|
+ .or(wq1 -> wq1
|
|
|
+ .eq("t1.status", 1)
|
|
|
+ .eq("t1.user_id", userId)));
|
|
|
+ return lqw;
|
|
|
+ }
|
|
|
+
|
|
|
+ public QueryWrapper<DynamicContent> queryHotWrapper(String keyWord, Long userId) {
|
|
|
+ QueryWrapper<DynamicContent> lqw = Wrappers.query();
|
|
|
+ lqw.ge("t1.good_num", 50);
|
|
|
+ return format(lqw, keyWord, userId);
|
|
|
+ }
|
|
|
+
|
|
|
+ public QueryWrapper<DynamicContent> format(QueryWrapper<DynamicContent> lqw,
|
|
|
+ String keyWord, Long userId) {
|
|
|
+ lqw.eq("t1.is_deleted", 0);
|
|
|
+ lqw.eq("t1.platform_status", 0);
|
|
|
+ lqw.and(wq -> wq
|
|
|
+ .eq("t1.examine_status", 1)
|
|
|
+ .or(wq1 -> wq1
|
|
|
+ .eq("t1.examine_status", 0)
|
|
|
+ .eq("t1.user_id", userId)));
|
|
|
+ lqw.and(wq -> wq
|
|
|
+ .eq("t1.status", 0)
|
|
|
+ .or(wq1 -> wq1
|
|
|
+ .eq("t1.status", 1)
|
|
|
+ .eq("t1.user_id", userId)));
|
|
|
+ lqw.like(StringUtils.isNotBlank(keyWord), "t1.text_content", keyWord);
|
|
|
+ List<String> list = new ArrayList<>();
|
|
|
+ list.add("t1.create_time");
|
|
|
+ list.add("t1.id");
|
|
|
+ lqw.orderByDesc(list.toString());
|
|
|
+ return lqw;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public PagedVO<DynamicContentDTO> queryAdminPageList(QueryAdminDynamicParam param,
|
|
|
+ Long pageNum, Long pageSize) {
|
|
|
+ Page<DynamicContentDTO> page = new Page<>(pageNum, pageSize);
|
|
|
+ IPage<DynamicContentDTO> result = null;
|
|
|
+ if (param == null) {
|
|
|
+ return PagedVO.build(page, DynamicContentDTO.class);
|
|
|
+ }
|
|
|
+ result = baseMapper
|
|
|
+ .queryAll(page, queryManagerWrapper(param));
|
|
|
+ IPage<DynamicContentDTO> resultDto = getResult(result, false, null);
|
|
|
+ PagedVO<DynamicContentDTO> vo = new PagedVO<>();
|
|
|
+ vo.setPageSize(pageSize);
|
|
|
+ vo.setPageNumber(pageNum);
|
|
|
+ vo.setRecords(resultDto.getRecords());
|
|
|
+ vo.setTotalNumber(result.getTotal());
|
|
|
+ return vo;
|
|
|
+ }
|
|
|
+
|
|
|
+ private QueryWrapper<DynamicContent> queryManagerWrapper(
|
|
|
+ QueryAdminDynamicParam param) {
|
|
|
+ QueryWrapper<DynamicContent> lqw = Wrappers.query();
|
|
|
+ lqw.eq("t1.is_deleted", 0);
|
|
|
+ lqw.like(StringUtils.isNotBlank(param.getKeyWord()), "t1.text_content", param.getKeyWord());
|
|
|
+ lqw.ge(StringUtils.isNotBlank(param.getStartTime()), "t1.create_time", param.getStartTime());
|
|
|
+ lqw.le(StringUtils.isNotBlank(param.getEndTime()), "t1.create_time", param.getEndTime());
|
|
|
+ lqw.eq(param.getExamineStatus() != null, "t1.examine_status", param.getExamineStatus());
|
|
|
+ lqw.eq(param.getExamineResult() != null, "t1.examine_result", param.getExamineResult());
|
|
|
+ lqw.eq(param.getPlatformStatus() != null, "t1.platform_status", param.getPlatformStatus());
|
|
|
+ List<String> list = new ArrayList<>();
|
|
|
+ list.add("t1.create_time");
|
|
|
+ list.add("t1.id");
|
|
|
+ lqw.orderByDesc(list.toString());
|
|
|
+ return lqw;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public IPage<DynamicContentDTO> queryUserById(Long selfUserId, Long userId, Integer pageNum, Integer pageSize) {
|
|
|
+ if (userId == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ int flag = 1;
|
|
|
+ if (selfUserId != null && selfUserId.intValue() == userId.intValue()) {
|
|
|
+ flag = 2;
|
|
|
+ }
|
|
|
+ Page<DynamicContentDTO> page = new Page<>(pageNum, pageSize);
|
|
|
+ //flag: 1-查看其他人;2-查看自己
|
|
|
+ IPage<DynamicContentDTO> iPage = baseMapper
|
|
|
+ .queryBySelf(page, querySelfWrapper(flag, userId));
|
|
|
+ return getResult(iPage, true, userId);
|
|
|
+ }
|
|
|
+
|
|
|
+ public QueryWrapper<DynamicContent> querySelfWrapper(int flag, Long userId) {
|
|
|
+ List<String> list = new ArrayList<>();
|
|
|
+ QueryWrapper<DynamicContent> lqw = Wrappers.query();
|
|
|
+ lqw.eq("t1.is_deleted", 0);
|
|
|
+ lqw.eq("t1.user_id", userId);
|
|
|
+ lqw.eq("t1.platform_status", 0);
|
|
|
+ lqw.eq(flag == 1, "t1.status", 0);
|
|
|
+ lqw.eq(flag == 1, "t1.examine_status", 1);
|
|
|
+ list.add("t1.create_time");
|
|
|
+ list.add("t1.id");
|
|
|
+ lqw.orderByDesc(list.toString());
|
|
|
+ return lqw;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public void insertByBo(AddDynamicContentParam param) {
|
|
|
+ addValidEntityBeforeSave(param);
|
|
|
+ String textContent = param.getTextContent();
|
|
|
+ DynamicContentType type = param.getType();
|
|
|
+ DynamicContent contentDynamic = new DynamicContent();
|
|
|
+ Long userId = param.getUserId();
|
|
|
+ contentDynamic.setUserId(userId);
|
|
|
+ contentDynamic.setTextContent(textContent);
|
|
|
+ contentDynamic.setType(type.getValue());
|
|
|
+ contentDynamic.setLocation(param.getLocation());
|
|
|
+ baseMapper.insert(contentDynamic);
|
|
|
+ log.info("用户[{}]:发送动态信息{}", userId, contentDynamic);
|
|
|
+ List<AddDynamicResourceParam> list = param.getList();
|
|
|
+ if (list != null && !list.isEmpty()) {
|
|
|
+ List<DynamicResource> resources = new ArrayList<>();
|
|
|
+ list.forEach(e -> {
|
|
|
+ DynamicResource resource = new DynamicResource();
|
|
|
+ resource.setDynamicId(contentDynamic.getId());
|
|
|
+ resource.setResourceKey(e.getResourceKey());
|
|
|
+ resource.setSort(e.getSort());
|
|
|
+ resource.setResourceFrame(e.getResourceFrame());
|
|
|
+ resources.add(resource);
|
|
|
+ });
|
|
|
+ contentDynamicResourceService.batchInsert(resources);
|
|
|
+ }
|
|
|
+ //异步处理审核
|
|
|
+ //contentAuditHelper.asyncContentHandle(contentDynamic);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存前的数据校验
|
|
|
+ */
|
|
|
+ private void addValidEntityBeforeSave(AddDynamicContentParam param) {
|
|
|
+ Integer type = param.getType().getValue();
|
|
|
+ List<AddDynamicResourceParam> list = param.getList();
|
|
|
+ if (DynamicContentType.PURE_TEXT.getValue().equals(type) &&
|
|
|
+ !StringUtils.isNotBlank(param.getTextContent())) {
|
|
|
+ throw new ResourceUnavailableException("动态不能为空");
|
|
|
+ } else if (DynamicContentType.PHOTO.getValue().equals(type) && list.size() > 9) {
|
|
|
+ throw new ResourceUnavailableException("动态照片不能超过9张");
|
|
|
+ } else if (DynamicContentType.VIDEO.getValue().equals(type) && list.size() != 1) {
|
|
|
+ throw new ResourceUnavailableException("视频只能发布一部");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public void deleteByIds(Long id, Long userId) {
|
|
|
+ DynamicContent DynamicContent = baseMapper.selectById(id);
|
|
|
+ if (DynamicContent == null || userId == null ||
|
|
|
+ !DynamicContent.getUserId().equals(userId)) {
|
|
|
+ throw new ResourceUnavailableException("动态删除失败");
|
|
|
+ }
|
|
|
+ boolean b = baseMapper.deleteById(id) > 0;
|
|
|
+ if (!b) {
|
|
|
+ throw new ResourceUnavailableException("动态删除失败");
|
|
|
+ }
|
|
|
+ LambdaQueryWrapper<DynamicComment> lwq = Wrappers.lambdaQuery();
|
|
|
+ lwq.eq(DynamicComment::getDynamicId, id);
|
|
|
+ //删除评论
|
|
|
+ dynamicCommentMapper.delete(lwq);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Lock4j(keys = {"#dynamicId"})
|
|
|
+ public void addComment(Long dynamicId) {
|
|
|
+ int i = baseMapper.addComment(dynamicId);
|
|
|
+ if (i != 1) {
|
|
|
+ throw new ResourceUnavailableException("新增评论数失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Lock4j(keys = {"#dynamicId"})
|
|
|
+ public void reduceComment(Long dynamicId, int num) {
|
|
|
+ int i = baseMapper.reduceComment(dynamicId, num);
|
|
|
+ if (i != 1) {
|
|
|
+ throw new ResourceUnavailableException("删除评论数失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Lock4j(keys = {"#contentId"})
|
|
|
+ public void addNum(Integer dynamicStatus, Long contentId) {
|
|
|
+ if (Objects.equals(DynamicStatusType.GOOD.getValue(), dynamicStatus)) {
|
|
|
+ int i = baseMapper.addGoodNum(contentId);
|
|
|
+ if(i != 1){
|
|
|
+ throw new ResourceUnavailableException("点赞失败");
|
|
|
+ }
|
|
|
+ } else if (Objects.equals(DynamicStatusType.BAD.getValue(), dynamicStatus)) {
|
|
|
+ int i = baseMapper.addBadNum(contentId);
|
|
|
+ if(i != 1){
|
|
|
+ throw new ResourceUnavailableException("踩一踩失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Lock4j(keys = {"#contentId"})
|
|
|
+ public void reduceNum(Integer dynamicStatus, Long contentId) {
|
|
|
+ if (Objects.equals(DynamicStatusType.GOOD.getValue(), dynamicStatus)) {
|
|
|
+ int i = baseMapper.reduceGoodNum(contentId);
|
|
|
+ if(i != 1){
|
|
|
+ throw new ResourceUnavailableException("取消点赞失败");
|
|
|
+ }
|
|
|
+ } else if (Objects.equals(DynamicStatusType.BAD.getValue(), dynamicStatus)) {
|
|
|
+ int i = baseMapper.reduceBadNum(contentId);
|
|
|
+ if(i != 1){
|
|
|
+ throw new ResourceUnavailableException("取消踩一踩失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void shieldById(Long id, Integer type) {
|
|
|
+ int i = baseMapper.shieldById(id, type);
|
|
|
+ if(i != 1){
|
|
|
+ throw new ResourceUnavailableException("操作失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public void shieldByUserId(Long userId, Integer type) {
|
|
|
+ baseMapper.shieldByUserId(userId, type);
|
|
|
+ dynamicCommentMapper.shieldByUserId(userId, type);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void examine(Long id, ExamineType examine) {
|
|
|
+ LambdaUpdateWrapper<DynamicContent> lwq = Wrappers.lambdaUpdate();
|
|
|
+ lwq.eq(DynamicContent::getId, id);
|
|
|
+ lwq.set(DynamicContent::getExamineStatus, 1);
|
|
|
+ if(ExamineType.REFUSE.equals(examine)){
|
|
|
+ lwq.set(DynamicContent::getPlatformStatus, 1);
|
|
|
+ }
|
|
|
+ int update = baseMapper.update(null, lwq);
|
|
|
+ if(update != 1){
|
|
|
+ throw new ResourceUnavailableException("操作失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void autoAudit(Long id, int platformStatus, int examineResult) {
|
|
|
+ LambdaUpdateWrapper<DynamicContent> lwq = Wrappers.lambdaUpdate();
|
|
|
+ lwq.set(DynamicContent::getPlatformStatus, platformStatus);
|
|
|
+ lwq.set(DynamicContent::getExamineStatus, 1);
|
|
|
+ lwq.set(DynamicContent::getExamineResult, examineResult);
|
|
|
+ lwq.set(DynamicContent::getUpdateTime, LocalDateTime.now());
|
|
|
+ lwq.eq(DynamicContent::getId, id);
|
|
|
+ int update = baseMapper.update(null, lwq);
|
|
|
+ if(update != 1){
|
|
|
+ throw new ResourceUnavailableException("自动审核失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void videoAuditCallback(Map<String, Object> param) {
|
|
|
+ String suggestion = String.valueOf(param.get("Suggestion"));
|
|
|
+ Long dynamicId = Long.valueOf((String)param.get("DataId"));
|
|
|
+ if(suggestion == null){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ int platformStatus = 0;
|
|
|
+ int examineResult = 0;
|
|
|
+ if("Block".equals(suggestion)){
|
|
|
+ platformStatus = 1;
|
|
|
+ examineResult = 2;
|
|
|
+ } else if("Review".equals(suggestion)){
|
|
|
+ examineResult = 1;
|
|
|
+ }
|
|
|
+ autoAudit(dynamicId, platformStatus, examineResult);
|
|
|
+ }
|
|
|
+}
|