发表文章
发表文章的时候,可以支持添加标签
DTO
package com.xsz.dto;
import java.util.List;
import com.xsz.entity.Blog;
import com.xsz.entity.Tag;
public class ArticleDTO extends Blog {
private List<Tag> tags;
public List<Tag> getTags() {
return tags;
}
public void setTags(List<Tag> tags) {
this.tags = tags;
}
}
Conroller
//发表文章
@ApiOperation(value = "发表文章", notes = "发表文章")
@ApiImplicitParam(name = "adto", value = "发表文章对象", required = true, dataType = "ArticleDTO")
@PostMapping("save")
public Blog add(@RequestBody ArticleDTO adto) {
return blogService.add(adto);
}
标签管理
package com.xsz.controller;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.xsz.entity.Tag;
import com.xsz.service.TagService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
/**
*
* @author Bsea
* 文件管理模块 标签控制类
*/
@RequestMapping("tag")
@RestController
@Api(value = "标签API")
public class TagController {
@Resource
TagService tagService;
//发表标签
@ApiOperation(value = "新建标签", notes = "新建标签")
@PostMapping("save")
public Tag add(@RequestBody Tag tag) {
return tagService.add(tag);
}
//修改标签
@ApiOperation(value = "修改标签", notes = "修改标签")
@PostMapping("modify")
public Tag update(@RequestBody Tag tag) {
return tagService.update(tag);
}
//删除标签
@ApiOperation(value = "删除标签", notes = "删除标签")
@ApiImplicitParam(name = "id", value = "标签的主键Id", required = true, dataType = "String", paramType = "path")
@PostMapping("delete/{id}")
public Map<String, String> delete(@PathVariable("id") String id) {
Map<String, String> result=new HashMap();
tagService.delete(id);
result.put("result", "success");
return result;
}
//查询标签
@ApiOperation(value = "查询所有标签", notes = "查询所有标签")
@GetMapping("showAll")
public List<Tag> selectAll() {
return tagService.selectAll();
}
}
评论管理
package com.xsz.controller;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.xsz.entity.Comment;
import com.xsz.service.CommentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
/**
*
* @author Bsea
* 文件管理模块 评论控制类
*/
@RequestMapping("Comment")
@RestController
@Api(value = "评论API")
public class CommentController {
@Resource
CommentService commentService;
//发表评论
@ApiOperation(value = "新建评论", notes = "新建评论")
@PostMapping("save")
public Comment add(@RequestBody Comment comment) {
return commentService.add(comment);
}
//修改评论
@ApiOperation(value = "修改评论", notes = "修改评论")
@PostMapping("modify")
public Comment update(@RequestBody Comment comment) {
return commentService.update(comment);
}
//删除评论
@ApiOperation(value = "删除评论", notes = "删除评论")
@ApiImplicitParam(name = "id", value = "评论的主键Id", required = true, dataType = "String", paramType = "path")
@PostMapping("delete/{id}")
public Map<String, String> delete(@PathVariable("id") String id) {
Map<String, String> result=new HashMap();
commentService.delete(id);
result.put("result", "success");
return result;
}
//查询评论
@ApiOperation(value = "查询所有评论", notes = "查询所有评论")
@GetMapping("showAll")
public List<Comment> selectAll() {
return commentService.selectAll();
}
//根据blog id查询评论
@ApiOperation(value = "根据博客查询评论", notes = "根据blog id查询评论")
@GetMapping("showByBlog/{bid}")
@ApiImplicitParam(name = "bid", value = "评论的主键Id", required = true, dataType = "String", paramType = "path")
public List<Comment> selectByBlog(@PathVariable("bid") String blogId) {
return commentService.selectByBlogId(blogId);
}
}