package com.cf.imes.module.system.dal.mysql.setting;

import com.cf.imes.framework.mybatis.core.mapper.BaseMapperX;
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.cf.imes.module.system.dal.dataobject.setting.PackageConfigDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;


@Mapper
public interface PackageConfigMapper extends BaseMapperX<PackageConfigDO> {



    default PackageConfigDO selectSetting(Integer type, Long id, Long organId) {
        return selectOne( new LambdaQueryWrapperX<PackageConfigDO>()
                .eqIfPresent(PackageConfigDO::getOrganId,organId)
                .eqIfPresent(PackageConfigDO::getUserId,id)
                .eqIfPresent(PackageConfigDO::getType,type));
    }

    default List<PackageConfigDO> selectSettingList(Integer type, Long organId) {
        return selectList( new LambdaQueryWrapperX<PackageConfigDO>()
                .eqIfPresent(PackageConfigDO::getOrganId,organId)
                .eqIfPresent(PackageConfigDO::getType,type));
    }

    default int deleteSetting(Integer type,Long userId, Long organId) {
        return delete(new LambdaQueryWrapperX<PackageConfigDO>()
                .eq(PackageConfigDO::getOrganId, organId)
                .eq(PackageConfigDO::getUserId, userId)
                .eq(PackageConfigDO::getType,type));
    }
}
