Commit 8c40abcc authored by 刘基明's avatar 刘基明

热点数据

parent a98e8975
......@@ -35,9 +35,6 @@ public class ThemeController {
@ResponseBody
public CommonResp<CreateThemeResp> publishTheme(@Validated @RequestBody CreateThemeReq req) {
String userId = userHolder.getUserId();
if(StringUtils.isEmpty(userId)){
throw new BizException("用户为空");
}
return CommonResp.success(themeManager.publishTheme(req, userId));
}
......
......@@ -73,18 +73,24 @@ public class ThemeManager {
BeanUtils.copyProperties(req, themeEntity);
themeEntity.setAuthorId(userId);
themeEntity.setContent(JsonUtil.toJson(req.getContent()));
//保存附件表
List<ThemeAttachmentEntity> themeAttachments = ConvertUtil.themeReqToAttachmentList(req, themeEntity.getThemeId());
if (StringUtils.isEmpty(req.getEditThemeId())) {
//新建
themeService.insertTheme(themeEntity);
themeAttachmentService.insertList(themeAttachments);
} else {
//修改
themeService.update(themeEntity, req.getEditThemeId());
themeEntity.setThemeId(req.getEditThemeId());
themeAttachmentService.deleteByThemeId(req.getEditThemeId());
themeAttachmentService.insertList(themeAttachments);
}
//保存附件表
List<ThemeAttachmentEntity> themeAttachments = ConvertUtil.themeReqToAttachmentList(req, themeEntity.getThemeId());
themeAttachmentService.insertList(themeAttachments);
return CreateThemeResp.builder().themeId(themeEntity.getThemeId()).build();
}
......@@ -311,15 +317,15 @@ public class ThemeManager {
String formerThemeId = themeQo.getFormerThemeId();
if (StringUtils.isNotEmpty(formerThemeId)) {
ThemeQo formerTheme = ConvertUtil.themeEntityToQo2(themeService.queryByThemeId(formerThemeId));
if (formerTheme == null) {
throw new BizException("转发主题Id错误,id:" + formerThemeId);
}
if (formerTheme != null) {
//单个查询详情
productService.getAttachDetail(formerTheme);
FormerThemeQo f = ConvertUtil.themeQo2FormerThemeQo(formerTheme);
themeQo.setFormerTheme(f);
}
}
}
......
package com.tanpu.community.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.tanpu.community.api.enums.DeleteTagEnum;
import com.tanpu.community.dao.entity.community.ThemeAttachmentEntity;
import com.tanpu.community.dao.mapper.community.ThemeAttachmentMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.List;
......@@ -17,14 +18,21 @@ public class ThemeAttachmentService {
public List<ThemeAttachmentEntity> selectByThemeId(String themeId){
return themeAttachmentMapper.selectList(new LambdaQueryWrapper<ThemeAttachmentEntity>()
.eq(ThemeAttachmentEntity::getThemeId,themeId));
.eq(ThemeAttachmentEntity::getThemeId,themeId)
.eq(ThemeAttachmentEntity::getDeleteTag,DeleteTagEnum.NOT_DELETED));
}
@Transactional
public void insertList(List<ThemeAttachmentEntity> themeAttachments) {
for (ThemeAttachmentEntity themeAttachment : themeAttachments) {
themeAttachmentMapper.insert(themeAttachment);
}
return;
}
public int deleteByThemeId(String themeId) {
ThemeAttachmentEntity target = ThemeAttachmentEntity.builder().deleteTag(DeleteTagEnum.DELETED.getCode()).build();
LambdaUpdateWrapper<ThemeAttachmentEntity> update = new LambdaUpdateWrapper<ThemeAttachmentEntity>().eq(ThemeAttachmentEntity::getThemeId, themeId);
return themeAttachmentMapper.update(target,update);
}
}
......@@ -166,12 +166,26 @@ public class ConvertUtil {
.themeId(themeId)
.build());
}
} else {
} else if ((content.getType().equals(RelTypeEnum.SINGLE_IMG.type))) {
if (StringUtils.isEmpty(content.getValue())){
list.add(ThemeAttachmentEntity.builder()
.attachType(Integer.valueOf(content.getType()))
.attachId(content.getValue())
.themeId(themeId)
.build());
}else {
List<ImagesDTO> imgList = content.getImgList();
for (ImagesDTO imagesDTO : imgList) {
list.add(ThemeAttachmentEntity.builder()
.attachType(Integer.valueOf(RelTypeEnum.SINGLE_IMG.type))
.attachId(imagesDTO.getRelId())
.themeId(themeId)
.build());
}
}
} else {
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment