package com.njcn.energy.controller;

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.common.utils.LogUtil;
import com.njcn.energy.pojo.param.DataArrayParam;
import com.njcn.energy.pojo.param.DataSetParam;
import com.njcn.energy.pojo.po.DataArray;
import com.njcn.energy.pojo.po.DataMould;
import com.njcn.energy.pojo.po.DataSet;
import com.njcn.energy.service.IDataArrayService;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Objects;

/**
 * 类的介绍：
 *
 * @author xuyang
 * @version 1.0.0
 * @createTime 2022/3/9 15:47
 */
@Slf4j
@RestController
@RequestMapping("/dataArray")
@RequiredArgsConstructor
@Api(tags = "装置详细数据管理")
public class DataArrayController extends BaseController {

    private final IDataArrayService dataArrayService;

    @PostMapping("/add")
    @OperateInfo(info = LogEnum.SYSTEM_COMMON)
    @ApiOperation("新增装置详细模板数据")
    @ApiImplicitParam(name = "dataArrayParam", value = "装置详细模板数据", required = true)
    public HttpResult<DataMould> add(@RequestBody DataArrayParam dataArrayParam){
        String methodDescribe = getMethodDescribe("add");
        LogUtil.njcnDebug(log, "{}，装置详细模板数据为：{}", methodDescribe, dataArrayParam);
        DataArray dataArray = dataArrayService.addDataArray(dataArrayParam);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
    }

    @DeleteMapping("/delete")
    @OperateInfo(info = LogEnum.SYSTEM_COMMON,operateType = OperateType.DELETE)
    @ApiOperation("删除详细数据")
    @ApiImplicitParam(name = "list", value = "数据集id", required = true)
    public HttpResult<Boolean> delete(@RequestParam List<String> list){
        String methodDescribe = getMethodDescribe("delete");
        LogUtil.njcnDebug(log, "{}，数据集id：{}", methodDescribe, list);
        boolean result = dataArrayService.deleteDataArray(list);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
    }

}
