package com.chushang.system.service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.chushang.common.mybatis.page.CommonParam;
import com.chushang.common.mybatis.utils.PageResult;
import com.chushang.system.entity.po.SysConfig;

import java.util.List;

/**
 * @auther: zhao
 * @date: 2024/5/9 15:53
 */
public interface ISysConfigService extends IService<SysConfig> {
    default PageResult pageConfigList(SysConfig config, CommonParam commonParam){
        return new PageResult(this.page(new Page<>(commonParam.getPage(), commonParam.getLimit()),
                buildWrapper(config, commonParam)
        ));
    }
    LambdaQueryWrapper<SysConfig> buildWrapper(SysConfig sysConfig, CommonParam commonParam);

    default List<SysConfig> allConfigList(SysConfig config, CommonParam commonParam){
        return this.list(this.buildWrapper(config, commonParam));
    }

    default boolean checkConfigKeyUnique(SysConfig config, CommonParam commonParam){
        return this.count(buildWrapper(config, commonParam)) > 0;
    }
}
