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.SystemConfigProcessDO;
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 SystemConfigProcessMapper extends BaseMapperX<SystemConfigProcessDO> {


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


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

}
