package com.usky.backend.controller;

import com.usky.backend.domain.vo.SysConfigLoginVo;
import com.usky.backend.domain.vo.SysConfigTenantVo;
import com.usky.backend.service.SysTenantService;
import com.usky.common.core.bean.ApiResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;


/**
 * <p>
 * 租户信息表 前端控制器
 * </p>
 *
 * @since 2022-04-29
 */
@RestController
@RequestMapping("/sysTenant")
public class SysTenantController {

    @Autowired
    private SysTenantService sysTenantService;

    /**
     *  登录页面配置
     * @param domain
     * @return
     */
    @GetMapping("/getLoginConfig")
    public ApiResult<SysConfigLoginVo> getLoginConfig(@RequestParam("domain") String domain) {
        SysConfigLoginVo config = sysTenantService.getConfig(domain);
        return ApiResult.success(config);
    }

    /**
     *  通过租户ID获取配置
     */
    @GetMapping("/getTenantConfig")
    public ApiResult<SysConfigTenantVo> getTenantConfig() {
        Integer tenantId = 1; //TODO 通过
        SysConfigTenantVo config = sysTenantService.getSysConfig(tenantId);
        return ApiResult.success(config);
    }


}

