package com.fs.app.controller;

import com.fs.common.core.domain.R;
import com.fs.common.core.page.TableDataInfo;
import com.fs.common.utils.StringUtils;
import com.fs.course.domain.FsBlackTalent;
import com.fs.course.param.FsBlackAndReportParam;
import com.fs.course.param.FsBlackTalentParam;
import com.fs.course.param.FsBlackVideoParam;
import com.fs.course.service.IFsBlackTalentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.Map;

@Api("达人或短视频被拉黑举报接口")
@RestController
@RequestMapping("/app/blackTalent")
public class FsBlackTalentController extends AppBaseController{
    @Autowired
    private IFsBlackTalentService blackTalentService;
    @ApiOperation("拉黑达人")
    @PostMapping("/addBlackTalent")
    public R addBlackTalent(@RequestBody FsBlackTalentParam blackTalentParam) {
        String userId = getUserId();
        FsBlackTalent fsBlackTalent = new FsBlackTalent();
        fsBlackTalent.setUserId(Long.parseLong(userId));
        fsBlackTalent.setCreatTime(new Date());
        fsBlackTalent.setTalentId(blackTalentParam.getTalentId());
        fsBlackTalent.setType(blackTalentParam.getType());
        fsBlackTalent.setStyle("1");
        if (blackTalentService.addBlack(fsBlackTalent)>0){
            return R.ok();
        }
        return R.error();
    }

    @ApiOperation("拉黑视频")
    @PostMapping("/addBlackVideo")
    public R addBlackTalent(@RequestBody FsBlackVideoParam blackVideoParam) {
        String userId = getUserId();
        FsBlackTalent fsBlackTalent = new FsBlackTalent();
        fsBlackTalent.setUserId(Long.parseLong(userId));
        fsBlackTalent.setCreatTime(new Date());
        fsBlackTalent.setVideoId(blackVideoParam.getVideoId());
        fsBlackTalent.setType(blackVideoParam.getType());
        fsBlackTalent.setStyle("2");
        if (blackTalentService.addBlack(fsBlackTalent)>0){
            return R.ok();
        }
        return R.error();
    }

    @ApiOperation("举报达人")
    @PostMapping("/addReportTalent")
    public R addReportTalent(@RequestBody FsBlackTalentParam blackTalentParam) {
        String userId = getUserId();
        FsBlackTalent fsBlackTalent = new FsBlackTalent();
        fsBlackTalent.setUserId(Long.parseLong(userId));
        fsBlackTalent.setCreatTime(new Date());
        fsBlackTalent.setTalentId(blackTalentParam.getTalentId());
        fsBlackTalent.setType(blackTalentParam.getType());
        fsBlackTalent.setReportDesc(blackTalentParam.getReportDesc());
        fsBlackTalent.setPhone(blackTalentParam.getPhone());
        fsBlackTalent.setUrls(blackTalentParam.getUrls());
        fsBlackTalent.setTemplateId(blackTalentParam.getTemplateId());
        fsBlackTalent.setTradeImage(blackTalentParam.getTradeImage());
        fsBlackTalent.setStyle("1");
        fsBlackTalent.setIsAudit("0");

        if (blackTalentService.addBlack(fsBlackTalent)>0){
            return R.ok();
        }
        return R.error();
    }

    @ApiOperation("举报视频")
    @PostMapping("/addReportVideo")
    public R addReportVideo(@RequestBody FsBlackVideoParam blackVideoParam) {
        String userId = getUserId();
        FsBlackTalent fsBlackTalent = new FsBlackTalent();
        fsBlackTalent.setUserId(Long.parseLong(userId));
        fsBlackTalent.setCreatTime(new Date());
        fsBlackTalent.setVideoId(blackVideoParam.getVideoId());
        fsBlackTalent.setType(blackVideoParam.getType());
        fsBlackTalent.setReportDesc(blackVideoParam.getReportDesc());
        fsBlackTalent.setPhone(blackVideoParam.getPhone());
        fsBlackTalent.setUrls(blackVideoParam.getUrls());
        fsBlackTalent.setTemplateId(blackVideoParam.getTemplateId());
        fsBlackTalent.setStyle("2");
        fsBlackTalent.setIsAudit("0");

        if (blackTalentService.addBlack(fsBlackTalent)>0){
            return R.ok();
        }
        return R.error();
    }
    @ApiOperation("取消拉黑")
    @PostMapping("/cancelBlack")
    public R cancelBlack(@RequestBody Map<String,String> map){
        String userId = getUserId();
        String videoId = map.get("videoId");
        String talentId = map.get("talentId");
        if (StringUtils.isNotEmpty(videoId)){
            blackTalentService.deleteFsBlackVideo(userId,videoId);
            return R.ok();
        }
        if (StringUtils.isNotEmpty(talentId)){
            blackTalentService.deleteFsBlackTalent(userId,talentId);
            return R.ok();
        }
        return R.error("参数错误");
    }
    @ApiOperation("获取拉黑获取报的达人及视频")
    @GetMapping("/getBlack")
    public TableDataInfo getBlack(FsBlackAndReportParam blackAndReportParam){
        return null;
    }
}
