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.BaiduApiConfig;
import com.yida.data.common.core.entity.system.UnionPayConfig;
import com.yida.data.common.core.utils.Asserts;
import com.yida.data.system.service.BaiduApiConfigService;
import com.yida.data.system.service.UnionPayConfigService;
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.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 百度api配置信息 Controller
 *
 * @author ZYJ
 * @date 2023/6/20
 */
@RestController
@RequiredArgsConstructor
@Api(tags = "百度api配置信息(无鉴权)")
@RequestMapping("/in/baiDuApiConfig")
public class InBaiDuApiConfigController {

    private final BaiduApiConfigService baiduApiConfigService;

    @ApiOperation("根据学校id查询百度api配置")
    @GetMapping("/getBaiDuApiConfigByDept")
    public ResultBean<BaiduApiConfig> getBaiDuApiConfigByDept(@RequestParam Long deptId, @RequestParam String moduleName) {
        Asserts.isNotNull(deptId, "部门不能为空");
        return ResultBean.buildSuccess(baiduApiConfigService.getOne(Wrappers.lambdaQuery(new BaiduApiConfig())
                .eq(BaiduApiConfig::getSchoolId, deptId)
                .eq(BaiduApiConfig::getModuleName, moduleName)
        ));
    }

}
