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.po.DataArray;
import com.njcn.energy.pojo.po.DataMould;
import com.njcn.energy.service.IGroupArrayService;
import com.njcn.web.controller.BaseController;
import com.sun.org.apache.xpath.internal.operations.Bool;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 类的介绍：
 *
 * @author xuyang
 * @version 1.0.0
 * @createTime 2022/3/16 11:12
 */
@Slf4j
@RestController
@RequestMapping("/groupArray")
@RequiredArgsConstructor
@Api(tags = "数据组关系管理")
public class GroupArrayController extends BaseController {

    private final IGroupArrayService groupArrayService;

    @PutMapping("/groupArrayRelation")
    @OperateInfo(info = LogEnum.SYSTEM_COMMON)
    @ApiOperation("分配组和数据的关系")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "groupId", value = "groupId", required = true),
            @ApiImplicitParam(name = "arrayId", value = "arrayId", required = true)
    })
    public HttpResult groupArrayRelation(@RequestParam String groupId, @RequestParam String arrayId){
        String methodDescribe = getMethodDescribe("groupArrayRelation");
        LogUtil.njcnDebug(log, "{}，组id,数据id：{}", methodDescribe, groupId,arrayId);
        groupArrayService.groupArrayRelation(groupId,arrayId);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
    }


    @DeleteMapping("/deleteGroupArray")
    @OperateInfo(info = LogEnum.SYSTEM_COMMON,operateType = OperateType.DELETE)
    @ApiOperation("删除组和数据关系")
    @ApiImplicitParam(name = "list", value = "组集合", required = true)
    public HttpResult<Boolean> deleteGroupArray(@RequestParam List<String> list){
        String methodDescribe = getMethodDescribe("deleteGroupArray");
        LogUtil.njcnDebug(log, "{}，组集合：{}", methodDescribe, list);
        boolean result = groupArrayService.deleteGroupArray(list);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
    }





}
