package com.sifang.modules.setting.dao;

import com.jfinal.plugin.activerecord.Db;
import com.sifang.modules.setting.entity.CrmPlatformEmployeeRole;
import com.sifang.modules.sys.common.persistence.BaseDao;
import org.springframework.stereotype.Repository;


@Repository
public class CrmPlatformEmployeeRoleDao extends BaseDao<CrmPlatformEmployeeRole> {
//判断该角色下有没有员工
    public Boolean checkIfHasRole(String roleId){
        //首先查出该角色下有没有员工
      StringBuffer sf=new StringBuffer();
      sf.append(" SELECT COUNT(r.id) FROM `crm_platform_employee_role_rel` r LEFT JOIN `crm_platform_employee` e ");
      sf.append("  ON  r.employee_id=e.id WHERE r.role_ids LIKE");
      sf.append(" CONCAT('%',?,'%') AND e.status IN ('0','2') ");
       Long count=Db.queryLong(sf.toString(),roleId);
       if(count>0){
          return  false; //该角色下有员工
       }else{
           return  true;
       }
    }


}
