package com.njzscloud.supervisory.sys.tenant.controller;

import com.njzscloud.common.core.utils.R;
import com.njzscloud.common.mp.support.PageParam;
import com.njzscloud.common.mp.support.PageResult;
import com.njzscloud.supervisory.sys.tenant.pojo.SysTenantEntity;
import com.njzscloud.supervisory.sys.tenant.service.SysTenantService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 租户表
 */
@Slf4j
@RestController
@RequestMapping("/tenant")
@RequiredArgsConstructor
public class SysTenantController {

    private final SysTenantService sysTenantService;

    /**
     * 新增
     */
    @PostMapping("/add")
    public R<?> add(@RequestBody SysTenantEntity sysTenantEntity) {
        sysTenantService.add(sysTenantEntity);
        return R.success();
    }

    /**
     * 修改
     */
    @PostMapping("/modify")
    public R<?> modify(@RequestBody SysTenantEntity sysTenantEntity) {
        sysTenantService.modify(sysTenantEntity);
        return R.success();
    }

    /**
     * 删除
     */
    @PostMapping("/del")
    public R<?> del(@RequestBody List<Long> ids) {
        sysTenantService.del(ids);
        return R.success();
    }

    /**
     * 详情
     */
    @GetMapping("/detail")
    public R<SysTenantEntity> detail(@RequestParam Long id) {
        return R.success(sysTenantService.detail(id));
    }

    /**
     * 分页查询
     */
    @GetMapping("/paging")
    public R<PageResult<SysTenantEntity>> paging(PageParam pageParam, SysTenantEntity sysTenantEntity) {
        return R.success(sysTenantService.paging(pageParam, sysTenantEntity));
    }

    /**
     * 查询所有
     */
    @GetMapping("/list_all")
    public R<List<SysTenantEntity>> listAll() {
        return R.success(sysTenantService.listAll());
    }

}
