package com.zjty.inspect.controller;

import com.zjty.inspect.aop.AuthAnnotation;
import com.zjty.inspect.entity.MasterConfig;
import com.zjty.inspect.entity.ServerResponse;
import com.zjty.inspect.service.ConfigService;
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.util.List;

@Slf4j
@RestController
@RequestMapping("/config")
@Api(value = "参数配置接口管理接口",description = "参数配置管理接口,提供页面的增、删、改、查")
public class ConfigController {
    @Autowired
    private ConfigService configService;

    /**
     * 查询所有参数配置
     * @return 参数配置
     */
    @ApiOperation("查询所有参数配置")
    @GetMapping
    public ServerResponse<List<MasterConfig>> getConfigs(){
        return ServerResponse.ok(configService.findAll());
    }

    /**
     * 根据id修改参数
     * @param
     * @param
     * @return
     */
    @PostMapping("/updates")
    @ApiOperation("根据id修改参数,需要传id和value")
    @AuthAnnotation(code = {"0001300"})
    public ServerResponse update(@RequestBody List<MasterConfig> configs){
        configService.updateConfig(configs);
        return ServerResponse.ok(200);
    }
}
