package com.njcn.csdevice.controller.data;


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.csdevice.pojo.param.CsDataEffectiveAddParm;
import com.njcn.csdevice.pojo.param.CsDataEffectiveAuditParm;
import com.njcn.csdevice.pojo.param.CsDataEffectiveQueryParm;
import com.njcn.csdevice.pojo.vo.AppBaseInformationVO;
import com.njcn.csdevice.pojo.vo.CsDataEffectiveVO;
import com.njcn.csdevice.service.CsDataEffectiveService;
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 lombok.extern.slf4j.Slf4j;
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 java.util.List;

/**
 * Description:
 * 接口文档访问地址：http://serverIP:port/swagger-ui.html
 * Date: 2023/4/4  9:02【需求编号】
 *
 * @author clam
 * @version V1.0.0
 */
@Slf4j
@RestController
@RequestMapping("/dataEffective")
@Api(tags = "数据有效性")
@AllArgsConstructor
public class DataEffectiveController extends BaseController {

    private final CsDataEffectiveService csDataEffectiveService;

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/addDataEffective")
    @ApiOperation("新增app数据有效性表")
    @ApiImplicitParam(name = "csDataEffectiveAddParm", value = "新增app数据有效性表参数", required = true)
    public HttpResult<Boolean> addDataEffective(@RequestBody @Validated CsDataEffectiveAddParm csDataEffectiveAddParm){
        String methodDescribe = getMethodDescribe("addDataEffective");

        boolean save = csDataEffectiveService.add (csDataEffectiveAddParm);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, save, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/auditDataEffective")
    @ApiOperation("修改app数据有效性表")
    @ApiImplicitParam(name = "auditParm", value = "修改app数据有效性表参数", required = true)
    public HttpResult<Boolean> auditDataEffective(@RequestBody @Validated CsDataEffectiveAuditParm auditParm){
        String methodDescribe = getMethodDescribe("auditDataEffective");

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



    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/queryDataEffective")
    @ApiOperation("查询app数据有效性表")
    @ApiImplicitParam(name = "csDataEffectiveQueryParm", value = "查询app数据有效性表参数", required = true)
    public HttpResult<List<CsDataEffectiveVO>> queryDataEffective(@RequestBody @Validated CsDataEffectiveQueryParm csDataEffectiveQueryParm ){
        String methodDescribe = getMethodDescribe("queryDataEffective");
        AppBaseInformationVO appBaseInformationVO = new AppBaseInformationVO();
        List<CsDataEffectiveVO> list = csDataEffectiveService.queryDataEffective(csDataEffectiveQueryParm);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
    }
}
