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.SupvPlanHisParam;
import com.njcn.process.pojo.po.SupvPlanHis;
import com.njcn.process.service.ISupvPlanHisService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;
import com.njcn.web.controller.BaseController;

import java.util.List;

/**
 * <p>
 * 监督工作计划变更历史数据表 前端控制器
 * </p>
 *
 * @author wr
 * @since 2023-09-01
 */
@RestController
@RequestMapping("/supvPlanHis")
@Api(tags ="计划历史记录")
@RequiredArgsConstructor
public class SupvPlanHisController extends BaseController {

    private final ISupvPlanHisService supvPlanHisService;

    @PostMapping("addPlanHis")
    @OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.ADD)
    @ApiOperation("新增技术监督计划历史记录")
    public HttpResult<Boolean> addPlanHis(@RequestBody @Validated SupvPlanHisParam.insert insert){
        String methodDescribe = getMethodDescribe("addPlanHis");
        Boolean b = supvPlanHisService.addPlanHis(insert);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, b, methodDescribe);
    }

    @PostMapping("updatePlanHis")
    @OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.ADD)
    @ApiOperation("修改技术监督计划历史记录")
    public HttpResult<Boolean> updatePlanHis(@RequestBody @Validated SupvPlanHisParam.update update){
        String methodDescribe = getMethodDescribe("updatePlanHis");
        Boolean b = supvPlanHisService.updatePlanHis(update);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, b, methodDescribe);
    }

    @PostMapping("delPlanHis")
    @OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.ADD)
    @ApiOperation("删除监督计划历史记录")
    @ApiImplicitParam(name = "planIds",value = "监督计划索引集合",required = true)
    public HttpResult<Boolean> delPlanHis(@RequestBody List<String> planIds){
        String methodDescribe = getMethodDescribe("delPlanHis");
        Boolean b = supvPlanHisService.delPlanHis(planIds);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, b, methodDescribe);
    }

    @PostMapping("pagePlanHis")
    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @ApiOperation("分页查询监督计划历史记录")
    @ApiImplicitParam(name = "param",value = "请求体",required = true)
    public HttpResult<Page<SupvPlanHis>> pagePlanHis(@RequestBody SupvPlanHisParam param){
        String methodDescribe = getMethodDescribe("pagePlanHis");
        Page<SupvPlanHis> supvPlanHisPage = supvPlanHisService.pagePlanHis(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, supvPlanHisPage, methodDescribe);
    }
}

