|
@@ -1,6 +1,9 @@
|
|
|
package com.yonge.cooleshow.bbs.controller;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.yonge.cooleshow.auth.api.client.SysUserFeignService;
|
|
|
+import com.yonge.cooleshow.auth.api.entity.SysUser;
|
|
|
+import com.yonge.cooleshow.bbs.valid.AddGroup;
|
|
|
import com.yonge.toolset.base.page.PageInfo;
|
|
|
import com.yonge.cooleshow.common.controller.BaseController;
|
|
|
import com.yonge.cooleshow.common.entity.HttpResponseResult;
|
|
@@ -9,6 +12,8 @@ import com.yonge.toolset.mybatis.support.PageUtil;
|
|
|
import com.yonge.toolset.utils.string.StringUtil;
|
|
|
import io.swagger.annotations.*;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.http.HttpStatus;
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.validation.Valid;
|
|
@@ -22,65 +27,69 @@ import com.yonge.cooleshow.bbs.service.BbsArticleService;
|
|
|
@RequestMapping("/bbsArticle")
|
|
|
@Api(value = "文章", tags = "文章")
|
|
|
public class BbsArticleController extends BaseController {
|
|
|
-
|
|
|
+ @Autowired
|
|
|
+ private SysUserFeignService sysUserFeignService;
|
|
|
@Autowired
|
|
|
private BbsArticleService bbsArticleService;
|
|
|
|
|
|
- /**
|
|
|
+ @PostMapping("/addArticle")
|
|
|
+ @ApiOperation(value = "发布文章")
|
|
|
+ public HttpResponseResult addArticle(@Validated(AddGroup.class) @RequestBody BbsArticle bbsArticle) {
|
|
|
+ SysUser user = sysUserFeignService.queryUserInfo();
|
|
|
+ if (user == null || null == user.getId()) {
|
|
|
+ return failed(HttpStatus.FORBIDDEN, "请登录");
|
|
|
+ }
|
|
|
+ bbsArticle.setUserId(user.getId());
|
|
|
+ bbsArticleService.addArticle(bbsArticle);
|
|
|
+ return succeed();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 查询单条
|
|
|
*/
|
|
|
@GetMapping("/detail/{id}")
|
|
|
@ApiOperation(value = "详情", notes = "传入id")
|
|
|
public HttpResponseResult<BbsArticleVo> detail(@PathVariable("id") Long id) {
|
|
|
- return succeed(bbsArticleService.detail(id));
|
|
|
- }
|
|
|
-
|
|
|
+ return succeed(bbsArticleService.detail(id));
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 查询分页
|
|
|
*/
|
|
|
@PostMapping("/page")
|
|
|
@ApiOperation(value = "查询分页", notes = "传入bbsArticleSearch")
|
|
|
public HttpResponseResult<PageInfo<BbsArticleVo>> page(@RequestBody BbsArticleSearch query) {
|
|
|
- IPage<BbsArticleVo> pages = bbsArticleService.selectPage(PageUtil.getPage(query), query);
|
|
|
+ IPage<BbsArticleVo> pages = bbsArticleService.selectPage(PageUtil.getPage(query), query);
|
|
|
return succeed(PageUtil.pageInfo(pages));
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 新增
|
|
|
- */
|
|
|
- @PostMapping("/save")
|
|
|
- @ApiOperation(value = "新增", notes = "传入bbsArticle")
|
|
|
- public HttpResponseResult save(@Valid @RequestBody BbsArticle bbsArticle) {
|
|
|
- return status(bbsArticleService.save(bbsArticle));
|
|
|
- }
|
|
|
-
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
- * 修改
|
|
|
- */
|
|
|
- @PostMapping("/update")
|
|
|
- @ApiOperation(value = "修改", notes = "传入bbsArticle")
|
|
|
- public HttpResponseResult update(@Valid @RequestBody BbsArticle bbsArticle) {
|
|
|
+ * 修改
|
|
|
+ */
|
|
|
+ @PostMapping("/update")
|
|
|
+ @ApiOperation(value = "修改", notes = "传入bbsArticle")
|
|
|
+ public HttpResponseResult update(@Valid @RequestBody BbsArticle bbsArticle) {
|
|
|
return status(bbsArticleService.updateById(bbsArticle));
|
|
|
- }
|
|
|
-
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
- * 新增或修改
|
|
|
- */
|
|
|
+ * 新增或修改
|
|
|
+ */
|
|
|
@PostMapping("/submit")
|
|
|
@ApiOperation(value = "新增或修改", notes = "传入bbsArticle")
|
|
|
- public HttpResponseResult submit(@Valid @RequestBody BbsArticle bbsArticle) {
|
|
|
+ public HttpResponseResult submit(@Valid @RequestBody BbsArticle bbsArticle) {
|
|
|
return status(bbsArticleService.saveOrUpdate(bbsArticle));
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 删除
|
|
|
- */
|
|
|
- @PostMapping("/remove")
|
|
|
- @ApiOperation(value = "逻辑删除", notes = "传入ids")
|
|
|
- public HttpResponseResult remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
|
|
|
+ /**
|
|
|
+ * 删除
|
|
|
+ */
|
|
|
+ @PostMapping("/remove")
|
|
|
+ @ApiOperation(value = "逻辑删除", notes = "传入ids")
|
|
|
+ public HttpResponseResult remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
|
|
|
if (StringUtil.isEmpty(ids)) {
|
|
|
- return failed("参数不能为空");
|
|
|
- }
|
|
|
- return status(bbsArticleService.removeByIds(StringUtil.toLongList(ids)));
|
|
|
- }
|
|
|
+ return failed("参数不能为空");
|
|
|
+ }
|
|
|
+ return status(bbsArticleService.removeByIds(StringUtil.toLongList(ids)));
|
|
|
+ }
|
|
|
}
|