package com.yihu.jw.base.service.doctor;

import com.yihu.jw.base.dao.doctor.BaseModuleRoleDao;
import com.yihu.jw.entity.base.doctor.BaseModuleRoleDO;
import com.yihu.mysql.query.BaseJpaService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.xml.ws.Action;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * 
 * 业务模块与业务模块角色关联信息服务service
 * 
 * @version 
 * <pre>
 * Author	Version		Date		Changes
 * litaohong    1.0  2018年10月25日 Created
 *
 * </pre>
 * @since 1.
 */
@Service
public class BaseModuleRoleService extends BaseJpaService<BaseModuleRoleDO, BaseModuleRoleDao> {

    @Autowired
    private BaseModuleRoleDao baseModuleRoleDao;


    /**
     * 根据角色code获取角色对应的模块Id列表
     *
     * @param roleCode
     * @return
     */
    public Set<Object> findModuleIdList(String roleCode) {
        Set<Object> result = new HashSet<>();
        if (null == roleCode) {
            return result;
        }
        return baseModuleRoleDao.findModuleIdList(roleCode);
    }

    /**
     * 根据角色code获取角色对应的模块列表
     *
     * @param roleCode
     * @return
     */
    public List<BaseModuleRoleDO> findModuleListByRoleCode(String roleCode) {
        List<BaseModuleRoleDO> result = new ArrayList<>();
        if (null == roleCode) {
            return result;
        }
        return baseModuleRoleDao.findAllByRoleCode(roleCode);
    }

}
