package com.rongwei.sfcommon.sys.dao;

import com.rongwe.scentity.domian.AspSafetyProductObjective;
import com.rongwe.scentity.vo.RoleIdAndUserIdsVo;
import com.rongwei.rwcommon.base.BaseDao;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface AspSafetyProductObjectiveDao extends BaseDao<AspSafetyProductObjective> {
    @Select("SELECT\n" +
            "\tsr.ID AS 'id',\n" +
            "\tGROUP_CONCAT( sur.USERID ) AS 'userIds' \n" +
            "FROM\n" +
            "\tsys_role sr\n" +
            "\tLEFT JOIN sys_user_role sur ON sr.ID = sur.ROLEID \n" +
            "\tAND sur.DELETED = 0\n" +
            "\tLEFT JOIN sys_user_org suo ON suo.USERID = sur.USERID \n" +
            "\tAND suo.DELETED = 0\n" +
            "\tLEFT JOIN sys_organization so ON suo.ORGID = so.ID \n" +
            "\tAND so.DELETED = 0 \n" +
            "WHERE\n" +
            "\tsr.DELETED = 0 \n" +
            "\tAND sr.ID IN ( '77a13d95b53e42068e6f0c1d60f07df7', 'b104293d47e34df8847d1634c29ab031', '16963f62b94149d9ae16eabc9248999b', '104ac71c72704bbd953da6d7c167ed3a', 'efed8df42bde46c9970c1476e74d6374' ) \n" +
            "\tAND (\n" +
            "\t\tso.ID = #{tenantId} \n" +
            "\tOR so.FULLPID LIKE CONCAT( '%', #{tenantId}, '%' )) \n" +
            "GROUP BY\n" +
            "\tsr.ID")
    List<RoleIdAndUserIdsVo> selectManagerByTenantId(String tenantId);
}