/**
* 根据操作员ID获得该操作员的所有角色id所拼成的String,每个ID用“,”分隔
* @param operatorId 操作员ID
* @return roleIds
*/
public String getRoleIdsByOperatorId(long operatorId) {
// 得到操作员和角色列表
List<PmsRoleOperator> rpList = pmsRoleOperatorDao.listByOperatorId(operatorId);
// 构建StringBuffer来拼字符串
StringBuffer roleIdsBuf = new StringBuffer("");
for (PmsRoleOperator rp : rpList) {
roleIdsBuf.append(rp.getRoleId()).append(",");
}
String roleIds = roleIdsBuf.toString();
// 截取字符串
if (StringUtils.isNotBlank(roleIds) && roleIds.length() > 0) {
roleIds = roleIds.substring(0, roleIds.length() - 1);
}
return roleIds;
}
时间: 2024-11-23 07:07:47