package com.usoftchina.bi.server.controller.strategy;

import com.usoftchina.bi.core.base.RepEntity;
import com.usoftchina.bi.server.model.vo.configVo.ObjectInfo;
import com.usoftchina.bi.server.model.vo.configVo.StrategysInfo;
import com.usoftchina.bi.server.service.strategy.StrategysService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@Api(description = "策略相关接口")
public class StrategysController {
    @Autowired
    StrategysService strategysService;
    /*
   添加数据源策略
    */
    @ApiOperation(value = "添加数据源策略", notes = "添加数据源策略", response = RepEntity.class)
    @PostMapping("/addStrategys")
    public RepEntity addStrategys(@RequestBody StrategysInfo body){
        return strategysService.addStrategys(body);
    }

    /*
    删除数据源策略
     */
    @ApiOperation(value = "删除数据源策略", notes = "删除数据源策略", response = RepEntity.class)
    @PostMapping("/delDbStrategys")
    public RepEntity delDbStrategys(@RequestBody Long body){
        return strategysService.delDbStrategys(body);
    }

    /*
    删除图表策略
     */
    @ApiOperation(value = "删除图表策略", notes = "删除图表策略", response = RepEntity.class)
    @PostMapping("/delChartStrategys")
    public RepEntity delChartStrategys(@RequestBody Long body){
        return strategysService.delChartStrategys(body);
    }

    /*
    更新数据源策略
     */
    @ApiOperation(value = "更新数据源策略", notes = "更新数据源策略", response = RepEntity.class)
    @PostMapping("/updateStrategys")
    public RepEntity updateStrategys(@RequestBody StrategysInfo body){
        return strategysService.updateStrategys(body);
    }

    /*
    查询数据源策略
     */
    @ApiOperation(value = "查询数据源策略", notes = "查询数据源策略", response = RepEntity.class)
    @PostMapping("/getDbStrategys")
    public RepEntity getDbStrategys(@RequestBody int body){
        return strategysService.getDbStrategys(body);
    }

    /*
    添加用户或用户组
     */
    @ApiOperation(value = "添加用户或用户组", notes = "添加用户或用户组", response = RepEntity.class)
    @PostMapping("/addObject")
    public RepEntity addObject(@RequestBody ObjectInfo body){
        return strategysService.addObject(body);
    }

    /*
    查询图表策略
     */
    @ApiOperation(value = "查询图表策略", notes = "查询图表策略", response = RepEntity.class)
    @PostMapping("/getChartStrategys")
    public RepEntity getChartStrategys(@RequestBody int body){
        return strategysService.getChartStrategys(body);
    }
}