package com.ruoyi.web.controller.system;


import com.ruoyi.common.core.domain.RestResponse;
import com.ruoyi.system.domain.SysTenant;
import com.ruoyi.system.domain.vo.ReqBusinessAddTenant;
import com.ruoyi.system.domain.vo.ReqSearchSysTenant;
import com.ruoyi.system.service.SysTenantService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 租户信息 前端控制器
 * </p>
 *
 * @author zhangby
 * @since 2019-11-06
 */
@RestController
@RequestMapping("/system/tenant")
public class SysTenantController {

    @Autowired
    private SysTenantService sysTenantService;

    /**
     * 列表
     *
     * @param reqSearchSysTenant
     * @return
     */
    @GetMapping("/list/searchList")
    public RestResponse searchList(ReqSearchSysTenant reqSearchSysTenant) {
        return sysTenantService.searchList(reqSearchSysTenant);
    }

    /**
     * 前端select
     *
     * @return
     */
    @GetMapping("/list/treeSelect")
    public RestResponse treeSelect() {
        return sysTenantService.treeSelect();
    }

    /**
     * 详情
     *
     * @param tenantId
     * @return
     */
    @GetMapping("/info/detailById/{tenantId}")
    public RestResponse detailById(@PathVariable("tenantId") Long tenantId) {
        return sysTenantService.detailById(tenantId);
    }

    /**
     * 添加
     *
     * @param reqBusinessAddTenant
     * @return
     */
    @PostMapping("/add/addTenant")
    public RestResponse addSysTenant(@RequestBody ReqBusinessAddTenant reqBusinessAddTenant) {
        return sysTenantService.addTenant(reqBusinessAddTenant);
    }

    /**
     * 修改
     *
     * @param sysTenant
     * @return
     */
    @PutMapping("/update/updateTenant")
    public RestResponse updateTenant(@RequestBody SysTenant sysTenant) {
        return sysTenantService.updateTenant(sysTenant);
    }

    /**
     * 删除
     *
     * @param tenantIds
     * @return
     */
    @DeleteMapping("/delete/deleteById/{tenantIds}")
    public RestResponse deleteById(@PathVariable("tenantIds") String[] tenantIds) {
        return sysTenantService.deleteById(tenantIds);
    }

}
