package com.njcn.process.controller;


import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.constant.OperateType;
import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.process.service.ISupvFileService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import com.njcn.web.controller.BaseController;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author hongawen
 * @since 2023-06-21
 */
@RestController
@RequestMapping("/supv/file")
@Api(tags = "技术监督附件控制器")
@RequiredArgsConstructor
public class SupvFileController extends BaseController {

    private final ISupvFileService iSupvFileService;


    @PostMapping("planUpload")
    @OperateInfo(info = LogEnum.BUSINESS_COMMON,operateType = OperateType.UPLOAD)
    @ApiOperation("监督计划问题附件上传")
    public HttpResult<Object> planUpload(@ApiParam(value = "文件", required = true) @RequestPart("files") MultipartFile file, @RequestParam("planId") String planId, @RequestParam("type") Integer type,@RequestParam("attachmentType")String attachmentType){
        String methodDescribe = getMethodDescribe("planUpload");
        iSupvFileService.planUpload(file,planId,type,attachmentType);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
    }

    @PostMapping("detail")
    @OperateInfo(info = LogEnum.BUSINESS_COMMON,operateType = OperateType.DOWNLOAD)
    @ApiOperation("监督计划问题附件下载")
    public HttpResult<Object> detail(HttpServletResponse response, @RequestParam("busId") String busId, @RequestParam("type") Integer type,@RequestParam("attachmentType") String attachmentType){
        String methodDescribe = getMethodDescribe("detail");
        iSupvFileService.detail(response,busId,type,attachmentType);
        return null;
    }
}

