|
@@ -5,25 +5,27 @@ import com.yonge.cooleshow.auth.api.client.SysUserFeignService;
|
|
|
import com.yonge.cooleshow.auth.api.entity.SysUser;
|
|
|
import com.yonge.cooleshow.bbs.enums.ArticleEnum;
|
|
|
import com.yonge.cooleshow.bbs.valid.AddGroup;
|
|
|
+import com.yonge.cooleshow.bbs.valid.OtherGroup;
|
|
|
+import com.yonge.cooleshow.bbs.valid.UpdateGroup;
|
|
|
import com.yonge.toolset.base.page.PageInfo;
|
|
|
import com.yonge.cooleshow.common.controller.BaseController;
|
|
|
import com.yonge.cooleshow.common.entity.HttpResponseResult;
|
|
|
|
|
|
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;
|
|
|
-
|
|
|
import com.yonge.cooleshow.bbs.vo.BbsArticleVo;
|
|
|
import com.yonge.cooleshow.bbs.dto.search.BbsArticleSearch;
|
|
|
import com.yonge.cooleshow.bbs.entity.BbsArticle;
|
|
|
import com.yonge.cooleshow.bbs.service.BbsArticleService;
|
|
|
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
@RestController
|
|
|
@RequestMapping("/bbsArticle")
|
|
|
@Api(value = "文章", tags = "文章")
|
|
@@ -34,7 +36,7 @@ public class BbsArticleController extends BaseController {
|
|
|
private BbsArticleService bbsArticleService;
|
|
|
|
|
|
@PostMapping("/addArticle")
|
|
|
- @ApiOperation(value = "发布文章")
|
|
|
+ @ApiOperation(value = "详情-发布文章")
|
|
|
public HttpResponseResult addArticle(@Validated(AddGroup.class) @RequestBody BbsArticle bbsArticle) {
|
|
|
SysUser user = sysUserFeignService.queryUserInfo();
|
|
|
if (user == null || null == user.getId()) {
|
|
@@ -45,66 +47,47 @@ public class BbsArticleController extends BaseController {
|
|
|
return succeed();
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 查询单条
|
|
|
- */
|
|
|
- @GetMapping("/detail/{id}")
|
|
|
- @ApiOperation(value = "详情", notes = "传入id")
|
|
|
- public HttpResponseResult<BbsArticleVo> detail(@PathVariable("id") Long 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);
|
|
|
- return succeed(PageUtil.pageInfo(pages));
|
|
|
-
|
|
|
+ @PostMapping("/updateArticle")
|
|
|
+ @ApiOperation(value = "详情-修改文章")
|
|
|
+ public HttpResponseResult updateArticle(@Validated(UpdateGroup.class) @RequestBody BbsArticle bbsArticle) {
|
|
|
+ SysUser user = sysUserFeignService.queryUserInfo();
|
|
|
+ if (user == null || null == user.getId()) {
|
|
|
+ return failed(HttpStatus.FORBIDDEN, "请登录");
|
|
|
+ }
|
|
|
+ bbsArticleService.updateArticle(bbsArticle, user.getId());
|
|
|
+ return succeed();
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 修改
|
|
|
- */
|
|
|
- @PostMapping("/update")
|
|
|
- @ApiOperation(value = "修改", notes = "传入bbsArticle")
|
|
|
- public HttpResponseResult update(@Valid @RequestBody BbsArticle bbsArticle) {
|
|
|
- return status(bbsArticleService.updateById(bbsArticle));
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "ids", dataType = "List", value = "文章id集合"),
|
|
|
+ })
|
|
|
+ @PostMapping("/deleteArticle")
|
|
|
+ @ApiOperation(value = "详情-删除文章")
|
|
|
+ public HttpResponseResult deleteArticle(@RequestBody Map<String, List<Long>> ids) {
|
|
|
+ SysUser user = sysUserFeignService.queryUserInfo();
|
|
|
+ if (user == null || null == user.getId()) {
|
|
|
+ return failed(HttpStatus.FORBIDDEN, "请登录");
|
|
|
+ }
|
|
|
+ bbsArticleService.deleteArticle(ids, user);
|
|
|
+ return succeed();
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 新增或修改
|
|
|
- */
|
|
|
- @PostMapping("/submit")
|
|
|
- @ApiOperation(value = "新增或修改", notes = "传入bbsArticle")
|
|
|
- public HttpResponseResult submit(@Valid @RequestBody BbsArticle bbsArticle) {
|
|
|
- return status(bbsArticleService.saveOrUpdate(bbsArticle));
|
|
|
+ @PostMapping("/top")
|
|
|
+ @ApiOperation(value = "后台管理-置顶文章")
|
|
|
+ public HttpResponseResult articleTop(@Validated(OtherGroup.class) @RequestBody BbsArticle article) {
|
|
|
+ bbsArticleService.articleTop(article);
|
|
|
+ return succeed();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 删除
|
|
|
+ * 首页
|
|
|
*/
|
|
|
- @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)));
|
|
|
+ @PostMapping("/home")
|
|
|
+ @ApiOperation(value = "首页", notes = "传入bbsArticleSearch")
|
|
|
+ public HttpResponseResult<PageInfo<BbsArticleVo>> home(@RequestBody BbsArticleSearch query) {
|
|
|
+ query.setDelFlag(false);
|
|
|
+ query.setStatus(ArticleEnum.PASS);
|
|
|
+ IPage<BbsArticleVo> pages = bbsArticleService.selectPage(PageUtil.getPage(query), query);
|
|
|
+ return succeed(PageUtil.pageInfo(pages));
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 首页
|
|
|
- */
|
|
|
- @PostMapping("/home")
|
|
|
- @ApiOperation(value = "首页", notes = "传入bbsArticleSearch")
|
|
|
- public HttpResponseResult<PageInfo<BbsArticleVo>> home(@RequestBody BbsArticleSearch query) {
|
|
|
- query.setDelFlag(false);
|
|
|
- query.setStatus(ArticleEnum.PASS);
|
|
|
- IPage<BbsArticleVo> pages = bbsArticleService.selectPage(PageUtil.getPage(query), query);
|
|
|
- return succeed(PageUtil.pageInfo(pages));
|
|
|
- }
|
|
|
}
|