package com.yida.data.system.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.yida.data.common.core.common.ResultBean;
import com.yida.data.common.core.entity.system.WhiteList;
import com.yida.data.system.service.WhiteListService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 白名单 Controller
 *
 * @author ZYJ
 * @date 2023/2/21
 */
@RestController
@RequiredArgsConstructor
@Api(tags = "白名单(无鉴权)")
@RequestMapping("/in/whiteList")
public class InWhiteListController {

    private final WhiteListService whiteListService;

    @ApiOperation("根据功能名称获取对应的白名单信息")
    @GetMapping("/getWhiteList")
    public ResultBean<WhiteList> getWhiteList(String functionName) {
        return ResultBean.buildSuccess(whiteListService.getOne(Wrappers.lambdaQuery(new WhiteList())
                .eq(WhiteList::getFunctionName, functionName)));
    }

}
