package com.yonge.cooleshow.bbs.controller;

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;

import com.yonge.toolset.base.util.StringUtil;
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.constraints.NotNull;

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("/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();
    }
}