package com.usky.system.controller.web;

import com.usky.common.core.bean.ApiResult;
import com.usky.system.domain.SysTenantConfig;
import com.usky.system.domain.SysTenantPlatform;
import com.usky.system.service.SysPlatformService;
import com.usky.system.service.SysTenantPlatformService;
import com.usky.system.service.vo.TenantPlatformListVo;
import com.usky.system.service.vo.TenantPlatformVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 租户和应用关联表
 *
 * @author han
 * @since 2024-08-14
 */
@RestController
@RequestMapping("/sysTenantPlatform")
public class SysTenantPlatformController {

    @Autowired
    private SysTenantPlatformService sysTenantPlatformService;

    /**
     * PC租户管理-应用编辑
     *
     * @param tenantPlatformVo
     * @return
     */
//    @Log(title = "平台挂管理", businessType = BusinessType.INSERT)
    @PostMapping("updateTenantPlatform")
    public ApiResult<Void> updateTenantPlatform(@RequestBody TenantPlatformVo tenantPlatformVo) {
        sysTenantPlatformService.updateTenantPlatform(tenantPlatformVo);
        return ApiResult.success();
    }

    /**
     * 租户应用关联查询
     *
     * @param tenantId 租户ID
     * @return
     */
    @GetMapping("/getTenantPlatformList")
    public ApiResult<List<TenantPlatformListVo>> getTenantPlatformList(@RequestParam Integer tenantId) {
        return ApiResult.success(sysTenantPlatformService.getTenantPlatformList(tenantId));
    }

    /**
     * 应用菜单关联查询
     *
     * @param tenantId 租户ID
     * @return
     */
    @GetMapping("/getPlatformMenuList")
    public ApiResult<Map<String, Object>> getPlatformMenuList(@RequestParam Integer tenantId) {
        return ApiResult.success(sysTenantPlatformService.selectTenantPlatform(tenantId));
    }
}
