package com.tofly.xrtygis.custom.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tofly.common.core.entity.ResultRespone;
import com.tofly.xrtygis.custom.service.CustomQuestionMarkServicee;
import com.tofly.xrtygis.entity.Questionmark;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * 自定义疑问标识
 *
 * @author 陈浩
 */
@RestController
@AllArgsConstructor
@RequestMapping("/customMark")
@Api(tags = "自定义疑问标识接口")
public class CustomQuestionMarkController {

    private final CustomQuestionMarkServicee customQuestionMarkServicee;

    /**
     * 疑问标识上传
     *
     * @param fileList 文件上传
     * @param mark    标识类
     * @return true
     */
    @ApiOperation(value = "疑问标识上传")
    @PostMapping(value = "/upLoadMark")
    public ResultRespone upLoadMark(@RequestParam(value = "fileList", required = false) List<MultipartFile> fileList, Questionmark mark) {
        return ResultRespone.success(customQuestionMarkServicee.upLoadMark(fileList, mark));
    }

    /**
     * 删除标识
     *
     * @param markId 标识id
     * @return true
     */
    @ApiOperation(value = "疑问标识删除")
    @DeleteMapping("/deleteMark")
    @ApiImplicitParams(
            @ApiImplicitParam(name = "markId", value = "标识ID,多个，分隔", required = true, dataType = "long")
    )
    public ResultRespone deleteMark(String markId) {
        return ResultRespone.success(customQuestionMarkServicee.deleteMark(markId));
    }

    /**
     * 分页获取当前用户创建的标记
     *
     * @param page page
     * @return page
     */
    @GetMapping("/getMeMark")
    @ApiOperation("分页获取当前用户创建的标记")
    public ResultRespone getMeMark(Page page) {
        return ResultRespone.success(customQuestionMarkServicee.getMeMark(page));
    }

    @PutMapping("/handleMark")
    @ApiOperation("处理疑问标识")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "ids",value = "id,多个‘,’分隔",required = true,dataType = "string"),
            @ApiImplicitParam(name = "userId",value = "处理人id",required = true,dataType = "long"),
    })
    public ResultRespone  handleMark(String ids,Long userId){
        return ResultRespone.success(customQuestionMarkServicee.handleMark(ids, userId));
    }
}


