Commit 83a22ac5 authored by 刘基明's avatar 刘基明

点赞收藏相关

parent c915b558
package com.tanpu.community.api.beans; package com.tanpu.community.api.beans;
import io.swagger.annotations.ApiModelProperty;
import java.time.LocalDateTime;
public class ThemeDTO { public class ThemeDTO {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "id")
private String id;
@ApiModelProperty(value = "标题")
private String title;
@ApiModelProperty(value = "类型")
private Integer themeType;
@ApiModelProperty(value = "文本内容")
private String content;
@ApiModelProperty(value = "附件类型")
private Integer attachType;
@ApiModelProperty(value = "附件内容")
private String attachment;
@ApiModelProperty(value = "作者id")
private String authorId;
@ApiModelProperty(value = "被转发的主题")
private String formerThemeId;
@ApiModelProperty(value = "所属的话题")
private String topicId;
private String createBy;
private LocalDateTime createTime;
private String updateBy;
private LocalDateTime updateTime;
private Integer deleteTag;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public Integer getThemeType() {
return themeType;
}
public void setThemeType(Integer themeType) {
this.themeType = themeType;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public Integer getAttachType() {
return attachType;
}
public void setAttachType(Integer attachType) {
this.attachType = attachType;
}
public String getAttachment() {
return attachment;
}
public void setAttachment(String attachment) {
this.attachment = attachment;
}
public String getAuthorId() {
return authorId;
}
public void setAuthorId(String authorId) {
this.authorId = authorId;
}
public String getFormerThemeId() {
return formerThemeId;
}
public void setFormerThemeId(String formerThemeId) {
this.formerThemeId = formerThemeId;
}
public String getTopicId() {
return topicId;
}
public void setTopicId(String topicId) {
this.topicId = topicId;
}
public String getCreateBy() {
return createBy;
}
public void setCreateBy(String createBy) {
this.createBy = createBy;
}
public LocalDateTime getCreateTime() {
return createTime;
}
public void setCreateTime(LocalDateTime createTime) {
this.createTime = createTime;
}
public String getUpdateBy() {
return updateBy;
}
public void setUpdateBy(String updateBy) {
this.updateBy = updateBy;
}
public LocalDateTime getUpdateTime() {
return updateTime;
}
public void setUpdateTime(LocalDateTime updateTime) {
this.updateTime = updateTime;
}
public Integer getDeleteTag() {
return deleteTag;
}
public void setDeleteTag(Integer deleteTag) {
this.deleteTag = deleteTag;
}
@Override
public String toString() {
return "ThemeEntity{" +
"id=" + id +
", title=" + title +
", themeType=" + themeType +
", content=" + content +
", attachType=" + attachType +
", attachment=" + attachment +
", authorId=" + authorId +
", formerThemeId=" + formerThemeId +
", topicId=" + topicId +
", createBy=" + createBy +
", createTime=" + createTime +
", updateBy=" + updateBy +
", updateTime=" + updateTime +
", deleteTag=" + deleteTag +
"}";
}
} }
...@@ -2,14 +2,17 @@ package com.tanpu.community.controller; ...@@ -2,14 +2,17 @@ package com.tanpu.community.controller;
import com.tanpu.community.api.beans.ThemeDTO; import com.tanpu.community.api.beans.ThemeDTO;
import com.tanpu.community.dao.entity.community.FansRelEntity; import com.tanpu.community.controller.convert.ThemeConvert;
import com.tanpu.community.dao.entity.community.ThemeEntity; import com.tanpu.community.dao.entity.community.ThemeEntity;
import com.tanpu.community.manager.ThemeManager; import com.tanpu.community.manager.ThemeManager;
import com.tanpu.community.service.FansRelService; import com.tanpu.community.service.FansRelService;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import java.util.List; import java.util.List;
...@@ -27,8 +30,11 @@ public class ThemeController { ...@@ -27,8 +30,11 @@ public class ThemeController {
@ApiOperation("新增主题") @ApiOperation("新增主题")
@RequestMapping(value = "/add") @RequestMapping(value = "/add")
@ResponseBody @ResponseBody
public void insertTheme(@RequestBody ThemeDTO themeDTO){ public String insertTheme(@RequestBody ThemeDTO themeDTO){
String userId="liujm";
themeDTO.setAuthorId(userId);
themeManager.insert(ThemeConvert.convertToEntity(themeDTO));
return "success";
} }
@ApiOperation("系统推荐主题列表") @ApiOperation("系统推荐主题列表")
......
package com.tanpu.community.controller.convert;
import com.tanpu.community.api.beans.ThemeDTO;
import com.tanpu.community.dao.entity.community.ThemeEntity;
import java.util.List;
import java.util.stream.Collectors;
public class ThemeConvert {
public static ThemeDTO convertToDTO(ThemeEntity themeEntity){
ThemeDTO themeDTO = new ThemeDTO();
themeDTO.setId(themeEntity.getId());
themeDTO.setContent(themeEntity.getContent());
themeDTO.setThemeType(themeEntity.getThemeType());
themeDTO.setAttachment(themeEntity.getAttachment());
themeDTO.setAttachType(themeEntity.getAttachType());
themeDTO.setFormerThemeId(themeEntity.getFormerThemeId());
themeDTO.setAuthorId(themeEntity.getAuthorId());
themeDTO.setCreateBy(themeEntity.getCreateBy());
themeDTO.setUpdateBy(themeEntity.getUpdateBy());
themeDTO.setCreateTime(themeEntity.getCreateTime());
themeDTO.setUpdateBy(themeEntity.getUpdateBy());
return themeDTO;
}
public static ThemeEntity convertToEntity(ThemeDTO themeDTO){
ThemeEntity themeEntity = new ThemeEntity();
themeEntity.setContent(themeDTO.getContent());
themeEntity.setThemeType(themeDTO.getThemeType());
themeEntity.setAttachment(themeDTO.getAttachment());
themeEntity.setAttachType(themeDTO.getAttachType());
themeEntity.setFormerThemeId(themeDTO.getFormerThemeId());
themeEntity.setAuthorId(themeDTO.getAuthorId());
themeEntity.setCreateBy(themeDTO.getCreateBy());
themeEntity.setUpdateBy(themeDTO.getUpdateBy());
themeEntity.setCreateTime(themeDTO.getCreateTime());
themeEntity.setUpdateBy(themeDTO.getUpdateBy());
return themeEntity;
}
public static List<ThemeDTO> convertToEntitys(List<ThemeEntity> topicEntities){
return topicEntities.stream().map(ThemeConvert::convertToDTO).collect(Collectors.toList());
}
public static List<ThemeDTO> convertToDTOs(List<ThemeEntity> topicEntities){
return topicEntities.stream().map(ThemeConvert::convertToDTO).collect(Collectors.toList());
}
}
...@@ -104,4 +104,8 @@ public class ThemeManager { ...@@ -104,4 +104,8 @@ public class ThemeManager {
blackListEntity.setBlockedType(BlockTypeEnum.CONTENT.getCode()); blackListEntity.setBlockedType(BlockTypeEnum.CONTENT.getCode());
blackListService.insertBlackList(blackListEntity); blackListService.insertBlackList(blackListEntity);
} }
public void insert(ThemeEntity themeEntity) {
themeService.insertTheme(themeEntity);
}
} }
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