/**
 * 
 */
package org.springblade.etl.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springblade.etl.entity.Job;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;

/**
 *	任务定义 数据处理
 *
 * @author aokunsang
 * @date   2023-07-28
 */
public interface JobMapper extends BaseMapper<Job>{
	
	@Select({
		"select distinct c.category_id from etl_job c",
		"left join etl_job_permission a on c.id = a.job_id",
		"left join data_permission_user b on a.data_perm_id = b.data_perm_id",
		"where (b.user_id = #{userId} or c.create_user_id = #{userId} or c.public_status = 1)"
	})
	public List<Integer> categoryIdListOfPerm(@Param("userId") Long userId);
	
	@Select({
		"select distinct c.id from etl_job c",
		"left join etl_job_permission a on c.id = a.job_id",
		"left join data_permission_user b on a.data_perm_id = b.data_perm_id",
		"where (b.user_id = #{userId} or c.create_user_id = #{userId} or c.public_status = 1)"
	})
	public List<Integer> jobIdListOfPerm(@Param("userId") Long userId);

}