package com.eleadmin.test.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.eleadmin.test.mapper.TenantSettingMapper;
import com.eleadmin.test.service.TenantSettingService;
import com.eleadmin.test.entity.TenantSetting;
import com.eleadmin.test.param.TenantSettingParam;
import com.eleadmin.common.core.web.PageParam;
import com.eleadmin.common.core.web.PageResult;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 系统设置表Service实现
 *
 * @author 科技小王子
 * @since 2022-08-29 09:27:05
 */
@Service
public class TenantSettingServiceImpl extends ServiceImpl<TenantSettingMapper, TenantSetting> implements TenantSettingService {

    @Override
    public PageResult<TenantSetting> pageRel(TenantSettingParam param) {
        PageParam<TenantSetting, TenantSettingParam> page = new PageParam<>(param);
        //page.setDefaultOrder("create_time desc");
        List<TenantSetting> list = baseMapper.selectPageRel(page, param);
        return new PageResult<>(list, page.getTotal());
    }

    @Override
    public List<TenantSetting> listRel(TenantSettingParam param) {
        List<TenantSetting> list = baseMapper.selectListRel(param);
        // 排序
        PageParam<TenantSetting, TenantSettingParam> page = new PageParam<>();
        //page.setDefaultOrder("create_time desc");
        return page.sortRecords(list);
    }

    @Override
    public TenantSetting getByIdRel(Integer id) {
        TenantSettingParam param = new TenantSettingParam();
        param.setId(id);
        return param.getOne(baseMapper.selectListRel(param));
    }

}
