package ink.wgink.common.controller.api.access;

import ink.wgink.common.pojo.vos.access.WhiteListVO;
import ink.wgink.common.service.access.IWhiteListService;
import ink.wgink.interfaces.consts.ISystemConstant;
import ink.wgink.pojo.result.ErrorResult;
import ink.wgink.pojo.result.SuccessResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * When you feel like quitting. Think about why you started
 * 当你想要放弃的时候，想想当初你为何开始
 *
 * @ClassName: ConfigController
 * @Description: 系统配置
 * @Author: WangGeng
 * @Date: 2019/11/20 10:28
 * @Version: 1.0
 **/
@Api(tags = ISystemConstant.API_TAGS_SYSTEM_PREFIX + "白名单")
@RestController
@RequestMapping(ISystemConstant.API_PREFIX + "/access/white-list")
public class WhiteListController {

    @Autowired
    private IWhiteListService whiteListService;

    @ApiOperation(value = "保存白名单", notes = "保存白名单接口")
    @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
    @PutMapping("update")
    public SuccessResult update(@RequestBody WhiteListVO whiteListVO) {
        whiteListService.update(whiteListVO);
        return new SuccessResult();
    }

    @ApiOperation(value = "获取白名单列表", notes = "获取白名单列表接口")
    @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
    @GetMapping("list")
    public List<String> list() {
        return whiteListService.list();
    }

}
