package com.njcn.device.pms.controller.ledgerManger;


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.pms.pojo.param.NewEnergyQueryParam;
import com.njcn.device.pms.pojo.po.PmsNewEnergy;
import com.njcn.device.pms.service.gwPush.IPmsNewEnergyService;
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.*;

import com.njcn.web.controller.BaseController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author wr
 * @since 2024-03-26
 */
@RestController
@RequestMapping("/pmsNewEnergy")
@Api(tags = "新能源场站信息管理")
@RequiredArgsConstructor
public class PmsNewEnergyController extends BaseController {

    private final IPmsNewEnergyService newEnergyService;
    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("getNewEnergyList")
    @ApiOperation("分页场站台账所有信息")
    @ApiImplicitParam(name = "baseParam",value = "查询监测终端台账信息",required = true)
    public HttpResult<Page<PmsNewEnergy>> getNewEnergyList(@RequestBody @Validated NewEnergyQueryParam baseParam){
        String methodDescribe = getMethodDescribe("getNewEnergyList");
        Page<PmsNewEnergy> res = newEnergyService.getNewEnergyList(baseParam);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS,res,methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("getNewEnergySelectList")
    @ApiOperation("查询场站台账所有信息")
    public HttpResult<List<PmsNewEnergy>> getNewEnergySelectList(String orgId,String type){
        String methodDescribe = getMethodDescribe("getNewEnergySelectList");
        List<PmsNewEnergy> res = newEnergyService.getNewEnergySelectList(orgId,type);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS,res,methodDescribe);
    }


    /**
     * 新增监测终端台账信息
     * @author hany
     * @date 2022/10/26
     */
    @PostMapping("/addNewEnergy")
    @OperateInfo(info = LogEnum.SYSTEM_COMMON,operateType= OperateType.ADD)
    @ApiOperation("新增监测终端台账信息")
    @ApiImplicitParam(name = "param", value = "新增实体", required = true)
    public HttpResult<Object> add(@RequestBody @Validated NewEnergyQueryParam.Info param){
        String methodDescribe = getMethodDescribe("add");
        boolean result = newEnergyService.add(param);
        if (result) {
            return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
        } else {
            return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
        }
    }

    /**
     * 修改监测终端台账信息
     * @author hany
     * @date 2022/10/27
     */
    @PostMapping("/updateNewEnergy")
    @OperateInfo(info = LogEnum.SYSTEM_COMMON,operateType = OperateType.UPDATE)
    @ApiOperation("修改监测终端台账信息")
    @ApiImplicitParam(name = "updateParam", value = "更新实体", required = true)
    public HttpResult<Object> update(@RequestBody @Validated NewEnergyQueryParam.Info updateParam){
        String methodDescribe = getMethodDescribe("update");
        boolean result = newEnergyService.update(updateParam);
        if (result) {
            return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
        } else {
            return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
        }
    }

    /**
     * 删除监测终端台账信息
     * @param ids id
     * @author hany
     * @date 2022/10/27
     */
    @PostMapping("/deleteNewEnergy")
    @OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.DELETE)
    @ApiOperation("删除监测终端台账信息")
    @ApiImplicitParam(name = "ids", value = "ID索引", required = true)
    public HttpResult<Object> delete(@RequestBody List<String> ids){
        String methodDescribe = getMethodDescribe("delete");
        boolean result = newEnergyService.delete(ids);
        if(result){
            return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
        }else {
            return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
        }
    }
}

