package com.njcn.device.pq.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.device.pq.pojo.param.TflgployParam;
import com.njcn.device.pq.pojo.po.PqsTflgploy;
import com.njcn.device.pq.service.IPqsTflgployService;
import com.njcn.web.pojo.param.BaseParam;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import com.njcn.web.controller.BaseController;


/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author wr
 * @since 2023-07-19
 */
@Api(tags = "变压器策略")
@RestController
@RequestMapping("/pqsTflgploy")
@RequiredArgsConstructor
public class PqsTflgployController extends BaseController {

    private final IPqsTflgployService iPqsTflgployService;

    @PostMapping("/flgployPage")
    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @ApiOperation("分页查询变压器策略")
    public HttpResult<Page<PqsTflgploy>> flgployPage(@RequestBody BaseParam param) {
        String methodDescribe = getMethodDescribe("flgployPage");
        Page<PqsTflgploy> page = iPqsTflgployService.flgployPage(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, page, methodDescribe);
    }

    @PostMapping("/insertFlgPloy")
    @OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.ADD)
    @ApiOperation("新增变压器策略")
    public HttpResult<Boolean> insertFlgPloy(@RequestBody @Validated TflgployParam param) {
        String methodDescribe = getMethodDescribe("insertFlgPloy");
        Boolean flag = iPqsTflgployService.insertFlgPloy(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, flag, methodDescribe);
    }

    @GetMapping("/getFlgPloyInfo")
    @OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.UPDATE)
    @ApiOperation("变压器策略详情")
    public HttpResult<TflgployParam.TflgployUpdateParam> getFlgPloyInfo( String id) {
        String methodDescribe = getMethodDescribe("getFlgPloyInfo");
        TflgployParam.TflgployUpdateParam flag = iPqsTflgployService.flgPloyInfo(id);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, flag, methodDescribe);
    }

    @PostMapping("/updateFlgPloy")
    @OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.UPDATE)
    @ApiOperation("修改变压器策略")
    public HttpResult<Boolean> updateFlgPloy(@RequestBody @Validated TflgployParam.TflgployUpdateParam param) {
        String methodDescribe = getMethodDescribe("updateFlgPloy");
        Boolean flag = iPqsTflgployService.updateFlgPloy(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, flag, methodDescribe);
    }

    @GetMapping("/delFlgPloy")
    @ApiOperation(value = "删除变压器策略")
    @OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.DELETE)
    public HttpResult<Boolean> delFlgPloy(String ids) {
        String methodDescribe = getMethodDescribe("delFlgPloy");
        Boolean flag = iPqsTflgployService.delFlgPloy(ids);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, flag, methodDescribe);
    }
}

