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

import com.cf.imes.framework.mybatis.core.mapper.BaseMapperX;
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.cf.imes.framework.organ.core.context.OrganContextHolder;
import com.cf.imes.module.system.dal.dataobject.systemconfig.SystemConfigDO;
import com.cf.imes.module.system.dal.dataobject.systemconfig.SystemConfigFilterDO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * @author 板件分线 Mapper
 */

@Mapper
public interface SystemConfigFilterMapper extends BaseMapperX<SystemConfigFilterDO> {


    default List<SystemConfigFilterDO> selectSystemConfigList(Integer type, Integer status) {
        return selectList(new LambdaQueryWrapperX<SystemConfigFilterDO>()
                .eqIfPresent(SystemConfigFilterDO::getOrganId, OrganContextHolder.getOrganId())
                .eq(SystemConfigFilterDO::getDeleted,false)
                .eq(SystemConfigFilterDO::getType, type)
                .eqIfPresent(SystemConfigFilterDO::getStatus,status)
                .orderByAsc(SystemConfigFilterDO::getSort,SystemConfigDO::getCreateTime));
    }


    @Delete("delete from system_config_filter where  organ_id = #{organId} and id = #{id}")
    void deleteConfig(@Param("id") Long id,@Param("organId") Long organId);

}
