package com.palmnest.dao;

import com.palmnest.application.bean.Pagenation;
import com.palmnest.model.Role;
import com.palmnest.model.RoleFunction;

import java.util.List;
import java.util.Map;


/**
 * Role Data Access Object (DAO) interface.
 *
 * @author <a href="mailto:chasel.java@gmail.com">Chasel Li</a>
 */
public interface RoleDao extends GenericDao<Role, Long> {
	/**
	 * Gets role information based on rolename
	 *
	 * @param rolename the rolename
	 * @return populated role object
	 */
	Role getRoleByName(String rolename);

	/**
	 * Removes a role from the database by name
	 *
	 * @param rolename the role's rolename
	 */
	void removeRole(String rolename);

	/**
	 * 分页查询
	 *
	 * @param pageNo   当前页数
	 * @param pageSize 查询数据条数
	 * @return
	 */
	public Pagenation<Role> queryRole(int pageNo, int pageSize, Map<String, String> criteria);

	/**
	 * 查询角色的功能权限集合
	 *
	 * @param role
	 * @return
	 */
	public List<RoleFunction> queryRoleFunctionSet(Role role);

	/**
	 * 根据角色id删除角色-功能
	 *
	 * @param roleid
	 */
	public void deleteRoleFunctions(long roleid);

	/**
	 * 保存角色-功能 数据
	 *
	 * @param model
	 */
	public void saveRoleFunction(RoleFunction model);

	/**
	 * 根据sysCode和orgId获取角色集合
	 *
	 * @param sysCode
	 * @param OrgId
	 * @return
	 */
	List<Map<String, Object>> getRoleByOrgAndSysCode(String sysCode, Integer OrgId);


	/**
	 * 获取可用的角色集合
	 *
	 * @return List<Role>
	 */
	public List<Role> getRoleList(String type);

	/**
	 * 根据项目获取角色集合
	 *
	 * @return List<Role>
	 */
	public List<Role> getRoleListByOrg(String orgStr);

	/**
	 * @return List<Role>
	 */
	public List<Role> getRoleListBySysCode(String id, String code);

	List<Role> getByOrg(Integer orgId, Integer roleType);

	/**
	 * 根据角色id删除角色-功能
	 *
	 * @param roleId
	 */
	public void deleteRoleFunction(Long roleId, Integer functionId);

	/**
	 * 根据功能id删除角色-功能
	 *
	 * @param functionId
	 */
	public void deleteRoleFunctionByFuncId(Integer functionId);

	/**
	 * 根据功能编码获取角色列表
	 *
	 * @param syscode
	 * @return
	 */
	List<Map<String, Object>> getRoleListByFuncCode(String syscode, String userId);

	Role getVirAccountRole();
	
	List<Map<String,Object>> getRoleByFunc(Integer orgId,String syscode);

}
