package com.ruoyi.controller;

import com.ruoyi.annotations.UserLoginToken;
import com.ruoyi.common.page.PageResult;
import com.ruoyi.controller.req.BlockPageReq;
import com.ruoyi.controller.req.BlockUserReq;
import com.ruoyi.controller.resp.BlockPageResp;
import com.ruoyi.frequency.block.service.BlockService;
import com.ruoyi.response.ResponseData;
import com.ruoyi.vo.RyController;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * 拉黑用户
 */
@CrossOrigin
@RestController
@RequestMapping("/api/block")
@Api(tags = "拉黑用户")
public class ApiBlockController extends RyController {

    @Autowired
    private BlockService blockService;

    /**
     * 拉黑
     *
     * @return
     */
    @PostMapping("/blockUser")
    @UserLoginToken
    public ResponseData blockUser(@Valid @RequestBody BlockUserReq req) {
        return blockService.blockUser(req, getUserVo());
    }

    /**
     * 拉黑(只用于拉黑)
     *
     * @return
     */
    @PostMapping("/blockUserVersion2")
    @UserLoginToken
    public ResponseData blockUserVersion2(@Valid @RequestBody BlockUserReq req) {
        return blockService.blockUserVersion2(req, getUserVo());
    }

    /**
     * 取消拉黑(只用于取消拉黑)
     *
     * @return
     */
    @PostMapping("/cancelBlockUserVersion2")
    @UserLoginToken
    public ResponseData cancelBlockUserVersion2(@Valid @RequestBody BlockUserReq req) {
        return blockService.cancelBlockUserVersion2(req, getUserVo());
    }

    /**
     * 拉黑列表
     *
     * @param req
     * @return
     */
    @PostMapping("/blockPage")
    public ResponseData<PageResult<BlockPageResp>> blockPage(@RequestBody BlockPageReq req) {
        return blockService.blockPage(req, getUserVo());
    }

    /**
     * 拉黑列表(别人查看)
     *
     * @param req
     * @return
     */
    @PostMapping("/otherBlockPage")
    public ResponseData<PageResult<BlockPageResp>> otherBlockPage(@RequestBody BlockPageReq req) {
        return blockService.otherBlockPage(req,getUserVo());
    }

}