package com.sky.ioc.controller.scene;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.sky.ioc.entity.QuartzJob;
import com.sky.ioc.entity.domain.scene.Strategy;
import com.sky.ioc.service.job.IQuartzJobService;
import com.sky.ioc.service.scene.StrategyService;
import com.sky.ioc.tool.ReturnMsg;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.sql.Array;
import java.util.List;

@Api(tags ="智慧场景----智能策略")
@Slf4j
@RestController
@RequestMapping("/strategy")
public class StrategyController {

    @Autowired
    StrategyService strategyService;

    @ApiOperation("创建策略")
    @PostMapping(value = "/add")
    public ReturnMsg addStrategy(@RequestBody Strategy strategy){
      return strategyService.addStrategy(strategy);
    }

    @ApiOperation("删除策略")
    @PostMapping(value = "/delById")
    public ReturnMsg delById(@RequestParam(value = "id")Integer id){
        return strategyService.delStrategyById(id);
    }

    @ApiOperation("修改策略")
    @PostMapping(value = "/update")
    public ReturnMsg updateStrategy(@RequestBody Strategy strategy){
        return strategyService.editStrategy(strategy);
    }

    @ApiOperation("策略列表")
    @PostMapping(value = "/getStrategyList")
    public ReturnMsg getStrategyList(@RequestParam(value = "type", required=false)Integer type,
                                     @RequestParam(value = "status", required=false)Integer status,
                                     @RequestParam(value = "name", required=false)String name){

        return strategyService.getListByNameAndType(type, status,name);
    }

    @ApiOperation("批量删除策略")
    @PostMapping(value = "/batchDelByIds")
    public ReturnMsg batchDelByIds(@RequestBody List<Integer> ids){
        return strategyService.delBatchById(ids);
    }



    public static void main(String[] args){
        int[] arr = new int[2];
        System.out.println(arr.length);
    }




}
