|
@@ -1,7 +1,7 @@
|
|
|
package com.yonge.cooleshow.bbs.controller;
|
|
|
|
|
|
-import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
-import com.yonge.toolset.base.page.PageInfo;
|
|
|
+import com.yonge.cooleshow.auth.api.client.SysUserFeignService;
|
|
|
+import com.yonge.cooleshow.auth.api.entity.SysUser;
|
|
|
import com.yonge.cooleshow.common.controller.BaseController;
|
|
|
import com.yonge.cooleshow.common.entity.HttpResponseResult;
|
|
|
|
|
@@ -10,78 +10,30 @@ import com.yonge.toolset.mybatis.support.PageUtil;
|
|
|
|
|
|
import io.swagger.annotations.*;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.http.HttpStatus;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
-import javax.validation.Valid;
|
|
|
+import javax.validation.constraints.NotNull;
|
|
|
|
|
|
-import com.yonge.cooleshow.bbs.vo.BbsLikeVo;
|
|
|
-import com.yonge.cooleshow.bbs.dto.search.BbsLikeSearch;
|
|
|
-import com.yonge.cooleshow.bbs.entity.BbsLike;
|
|
|
import com.yonge.cooleshow.bbs.service.BbsLikeService;
|
|
|
|
|
|
@RestController
|
|
|
@RequestMapping("/bbsLike")
|
|
|
@Api(value = "点赞", tags = "点赞")
|
|
|
public class BbsLikeController extends BaseController {
|
|
|
-
|
|
|
+ @Autowired
|
|
|
+ private SysUserFeignService sysUserFeignService;
|
|
|
@Autowired
|
|
|
private BbsLikeService bbsLikeService;
|
|
|
|
|
|
- /**
|
|
|
- * 查询单条
|
|
|
- */
|
|
|
- @GetMapping("/detail/{id}")
|
|
|
- @ApiOperation(value = "详情", notes = "传入id")
|
|
|
- public HttpResponseResult<BbsLikeVo> detail(@PathVariable("id") Long id) {
|
|
|
- return succeed(bbsLikeService.detail(id));
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 查询分页
|
|
|
- */
|
|
|
- @PostMapping("/page")
|
|
|
- @ApiOperation(value = "查询分页", notes = "传入bbsLikeSearch")
|
|
|
- public HttpResponseResult<PageInfo<BbsLikeVo>> page(@RequestBody BbsLikeSearch query) {
|
|
|
- IPage<BbsLikeVo> pages = bbsLikeService.selectPage(PageUtil.getPage(query), query);
|
|
|
- return succeed(PageUtil.pageInfo(pages));
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 新增
|
|
|
- */
|
|
|
- @PostMapping("/save")
|
|
|
- @ApiOperation(value = "新增", notes = "传入bbsLike")
|
|
|
- public HttpResponseResult save(@Valid @RequestBody BbsLike bbsLike) {
|
|
|
- return status(bbsLikeService.save(bbsLike));
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 修改
|
|
|
- */
|
|
|
- @PostMapping("/update")
|
|
|
- @ApiOperation(value = "修改", notes = "传入bbsLike")
|
|
|
- public HttpResponseResult update(@Valid @RequestBody BbsLike bbsLike) {
|
|
|
- return status(bbsLikeService.updateById(bbsLike));
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 新增或修改
|
|
|
- */
|
|
|
- @PostMapping("/submit")
|
|
|
- @ApiOperation(value = "新增或修改", notes = "传入bbsLike")
|
|
|
- public HttpResponseResult submit(@Valid @RequestBody BbsLike bbsLike) {
|
|
|
- return status(bbsLikeService.saveOrUpdate(bbsLike));
|
|
|
+ @GetMapping("/like")
|
|
|
+ @ApiOperation(value = "详情-点赞/取消点赞")
|
|
|
+ public HttpResponseResult dolike(@NotNull Long articleId) {
|
|
|
+ SysUser user = sysUserFeignService.queryUserInfo();
|
|
|
+ if (user == null || null == user.getId()) {
|
|
|
+ return failed(HttpStatus.FORBIDDEN, "请登录");
|
|
|
+ }
|
|
|
+ bbsLikeService.dolike(articleId, user.getId());
|
|
|
+ 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(bbsLikeService.removeByIds(StringUtil.toLongList(ids)));
|
|
|
- }
|
|
|
}
|