package cn.com.ctop.kuaishou.modules.document.controller;

import cn.com.ctop.kuaishou.modules.document.service.DocumentLibraryService;
import org.jeecg.common.api.vo.Result;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Description: 文档库管理
 * @Author: zzy
 * @Date: 2021-09-06
 * @Version: V1.0
 */
@RestController
@RequestMapping("/document/library")
public class DocumentLibraryController {

    @Resource
    DocumentLibraryService documentLibraryService;

    /**
     * 创建文案
     *
     * @param
     * @return
     */
    @PostMapping("createdocument")
    public Result createdocument(MultipartFile file, @RequestParam("accountIds") List<String> accountIds) {
        return documentLibraryService.createdocument(file, accountIds);

    }
    /**
     * 获取文案库列表
     *
     * @param
     * @return
     */
    @GetMapping("getDocumentList")
    public Result getDocumentList(@RequestParam(value = "accountIds",required = false) List<String> accountIds,@RequestParam(value = "keywords",required = false) String keywords,
                                  @RequestParam(value = "startDate",required = false) String startDate,@RequestParam(value = "endDate",required = false) String endDate,
                                  @RequestParam(value = "status",required = false) String status,@RequestParam("pageNumber") int pageNumber,@RequestParam("pageSize") int pageSize) {
        return documentLibraryService.getDocumentList(accountIds, keywords,startDate,endDate,status,pageNumber,pageSize);

    }

    /**
     * 编辑文案
     *
     * @param
     * @return
     */
    @PostMapping("updateDocument")
    public Result updateDocument(@RequestParam("accountIds") List<String> accountIds,@RequestParam("copyWriterId") String copyWriterId,@RequestParam("copyWriter") String copyWriter) {
        return documentLibraryService.updateDocument(accountIds, copyWriterId,copyWriter);

    }


    /**
     * 文案下架
     *
     * @param
     * @return
     */
    @GetMapping("updateStatus")
    public Result updateStatus(@RequestParam("copyWriterId") String copyWriterId,@RequestParam("status") String status) {
        return documentLibraryService.updateStatus( copyWriterId,status);

    }

    /**
     * 根据文案查询绑定账户
     *
     * @param
     * @return
     */
    @GetMapping("getAcoountId")
    public Result updateStatus(@RequestParam("copyWriterId") String copyWriterId) {
        return documentLibraryService.getAcoountId( copyWriterId);

    }


    /**
     * 获取被拒创意
     *
     * @param
     * @return
     */
    @GetMapping("getRefusedList")
    public Result getRefusedList(@RequestParam("copyWriterId") String copyWriterId,@RequestParam("pageNumber") int pageNumber,@RequestParam("pageSize") int pageSize) {
        return documentLibraryService.getRefusedList(copyWriterId,pageNumber,pageSize);

    }

}
