package com.njcn.product.cnzutai.zutai.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.njcn.common.pojo.annotation.OperateInfo;
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.product.cnzutai.zutai.pojo.param.CsPageParm;
import com.njcn.product.cnzutai.zutai.pojo.vo.CsPageVO;
import com.njcn.product.cnzutai.zutai.service.CsPagePOService;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
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;

/**
* (cs_page)表控制层
*
* @author xxxxx
*/
@RestController
@RequestMapping("/cs-harmonic-boot/cspage")
@Api(tags = "组态项目页面")
@AllArgsConstructor
public class CsPagePOController  extends BaseController {
    private final CsPagePOService csPagePOService;

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/add")
    @ApiOperation("新增组态页面")
//    @ApiImplicitParam(name = "csPageParm", value = "新增组态项目参数", required = true)
    public HttpResult<Boolean> add( @Validated CsPageParm csPageParm){
        String methodDescribe = getMethodDescribe("add");

        boolean flag = csPagePOService.add (csPageParm);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, flag, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/audit")
    @ApiOperation("修改组态页面")
    public HttpResult<Boolean> audit( @Validated CsPageParm.CsPageParmAuditParam auditParm){
        String methodDescribe = getMethodDescribe("audit");

        boolean save = csPagePOService.audit (auditParm);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, save, methodDescribe);
    }



    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/queryPage")
    @ApiOperation("组态页面分页查询")
    @ApiImplicitParam(name = "csPageParam", value = "组态项目查询参数", required = true)
    public HttpResult<IPage<CsPageVO>> queryPage(@RequestBody @Validated CsPageParm.CsPageParmQueryParam csPageParam ){
        String methodDescribe = getMethodDescribe("queryPage");

        IPage<CsPageVO> page  = csPagePOService.queryPage (csPageParam);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, page, methodDescribe);
    }
}
