package com.njzscloud.supervisory.tenant.service;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njzscloud.common.mp.support.PageParam;
import com.njzscloud.common.mp.support.PageResult;
import com.njzscloud.supervisory.tenant.mapper.SysTenantMapper;
import com.njzscloud.supervisory.tenant.pojo.SysTenantEntity;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 租户表
 */
@Slf4j
@Service
public class SysTenantService extends ServiceImpl<SysTenantMapper, SysTenantEntity> implements IService<SysTenantEntity> {

    /**
     * 新增
     *
     * @param sysTenantEntity 数据
     */

    public void add(SysTenantEntity sysTenantEntity) {
        this.save(sysTenantEntity);
    }

    /**
     * 修改
     *
     * @param sysTenantEntity 数据
     */

    public void modify(SysTenantEntity sysTenantEntity) {
        this.updateById(sysTenantEntity);
    }

    /**
     * 删除
     *
     * @param ids Ids
     */

    @Transactional(rollbackFor = Exception.class)
    public void del(List<Long> ids) {
        this.removeBatchByIds(ids);
    }

    /**
     * 详情
     *
     * @param id Id
     * @return SysTenantEntity 结果
     */

    public SysTenantEntity detail(Long id) {
        return this.getById(id);
    }

    /**
     * 分页查询
     *
     * @param sysTenantEntity 筛选条件
     * @param pageParam       分页参数
     * @return PageResult&lt;SysTenantEntity&gt; 分页结果
     */

    public PageResult<SysTenantEntity> paging(PageParam pageParam, SysTenantEntity sysTenantEntity) {
        return PageResult.of(this.page(pageParam.toPage(), Wrappers.<SysTenantEntity>query(sysTenantEntity)));
    }

}
