package com.njzscloud.supervisory.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.tenant.pojo.SysTenantEntity;
import com.njzscloud.supervisory.tenant.service.SysTenantService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

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

    private final SysTenantService sysTenantService;

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

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

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

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

    /**
     * 分页查询
     *
     * @param sysTenantEntity 筛选条件
     * @param pageParam       分页参数
     * @return PageResult&lt;SysTenantEntity&gt; 分页结果
     */
    @GetMapping("/paging")
    public R<PageResult<SysTenantEntity>> paging(PageParam pageParam, SysTenantEntity sysTenantEntity) {
        return R.success(sysTenantService.paging(pageParam, sysTenantEntity));
    }

    @GetMapping("/list")
    public R<List<SysTenantEntity>> list() {
        return R.success(sysTenantService.list());
    }

}
