package com.njcn.process.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
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.pojo.param.SupvPlanParam;
import com.njcn.process.pojo.po.SupvPlan;
import com.njcn.process.pojo.po.SupvPlanRel;
import com.njcn.process.pojo.vo.SupvPlanVO;
import com.njcn.process.service.ISupvPlanService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import liquibase.pro.packaged.S;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

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

import javax.servlet.http.HttpServletResponse;
import java.util.List;

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

    private final ISupvPlanService iSupvPlanService;


    @PostMapping("addPlan")
    @OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.ADD)
    @ApiOperation("新增技术监督计划")
    @ApiImplicitParam(name = "supvPlanParam",value = "请求体",required = true)
    public HttpResult<Object> addPlan(@RequestBody @Validated SupvPlanParam supvPlanParam){
        String methodDescribe = getMethodDescribe("addPlan");
        iSupvPlanService.addPlan(supvPlanParam);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
    }

    @PostMapping("updatePlan")
    @OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.ADD)
    @ApiOperation("修改技术监督计划")
    @ApiImplicitParam(name = "supvPlanParam",value = "请求体",required = true)
    public HttpResult<Object> updatePlan(@RequestBody @Validated SupvPlanParam.UpdateSupvPlanParam supvPlanParam){
        String methodDescribe = getMethodDescribe("updatePlan");
        iSupvPlanService.updatePlan(supvPlanParam);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
    }

    @PostMapping("delPlan")
    @OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.DELETE)
    @ApiOperation("删除监督计划")
    @ApiImplicitParam(name = "planIds",value = "监督计划索引集合",required = true)
    public HttpResult<Object> delPlan(@RequestBody List<String> planIds){
        String methodDescribe = getMethodDescribe("delPlan");
        iSupvPlanService.delPlan(planIds);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
    }

    @PostMapping("pagePlan")
    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @ApiOperation("分页查询监督计划")
    @ApiImplicitParam(name = "supvPlanParam",value = "请求体",required = true)
    public HttpResult<Page<SupvPlanVO>> pagePlan(@RequestBody SupvPlanParam supvPlanParam){
        String methodDescribe = getMethodDescribe("pagePlan");
        Page<SupvPlanVO> page = iSupvPlanService.pagePlan(supvPlanParam);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, page, methodDescribe);
    }



    @PostMapping("saveOrUpdatePlanRel")
    @OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.ADD)
    @ApiOperation("新增变容器组关联对象")
    @ApiImplicitParam(name = "supvPlanRel",value = "请求体",required = true)
    public HttpResult<Object> saveOrUpdatePlanRel(@RequestBody @Validated SupvPlanRel supvPlanRel){
        String methodDescribe = getMethodDescribe("saveOrUpdatePlanRel");
        iSupvPlanService.saveOrUpdatePlanRel(supvPlanRel);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
    }


    @PostMapping("delPlanRel")
    @OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.DELETE)
    @ApiOperation("删除变容器组关联对象")
    @ApiImplicitParam(name = "planRelIds",value = "监督计划索引集合",required = true)
    public HttpResult<Object> delPlanRel(@RequestBody List<String> planRelIds){
        String methodDescribe = getMethodDescribe("delPlanRel");
        iSupvPlanService.delPlanRel(planRelIds);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
    }

    @PostMapping("planRelList")
    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @ApiOperation("查询变容器组关联对象")
    @ApiImplicitParam(name = "supvPlanRel",value = "请求体",required = true)
    public HttpResult<List<SupvPlanRel>> planRelList(@RequestBody SupvPlanRel supvPlanRel){
        String methodDescribe = getMethodDescribe("planRelList");
        List<SupvPlanRel> result = iSupvPlanService.planList(supvPlanRel);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
    }




}

