BLL/AchieveBLL/UserRoleBLL.cs
(开头部分) 4KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using AchieveDALFactory;
using AchieveEntity;
using AchieveInterfaceDAL;
using System;
using System.Collections.Generic;
using System.Data;
namespace AchieveBLL
{
/// <summary>
/// 用户角色(BLL)
/// </summary>
public class UserRoleBLL
{
private IUserRoleDAL dal = DALFactory.GetUserRoleDAL();
/// <summary>
/// 设置用户角色(单个用户)
/// </summary>
/// <param name="userId">用户主键</param>
/// <param name="roleIds">角色id,多个逗号隔开</param>
public bool SetRoleSingle(int userId, string roleIds)
{
DataTable dt_user_role_old = new RoleBLL().GetRoleByUserId(userId); //用户之前拥有的角色
List<UserRoleEntity> role_addList = new List<UserRoleEntity>(); //需要插入角色的sql语句集合
List<UserRoleEntity> role_deleteList = new List<UserRoleEntity>(); //需要删除角色的sql语句集合
string[] str_role = roleIds.Trim(',').Split(','); //传过来用户勾选的角色(有去勾的也有新勾选的)
UserRoleEntity userroledelete = null;
UserRoleEntity userroleadd = null;
//用户去掉勾选的角色(要删除本用户的角色)
for (int i = 0; i < dt_user_role_old.Rows.Count; i++)
{
//等于-1说明用户去掉勾选了某个角色 需要删除
if (Array.IndexOf(str_role, dt_user_role_old.Rows[i]["roleid"].ToString()) == -1)
{
userroledelete = new UserRoleEntity();
userroledelete.RoleId = Convert.ToInt32(dt_user_role_old.Rows[i]["roleid"].ToString());
userroledelete.UserId = userId;
role_deleteList.Add(userroledelete);
}
}
//用户新勾选的角色(要添加本用户的角色)
if (!string.IsNullOrEmpty(roleIds))
{
for (int j = 0; j < str_role.Length; j++)
{
//等于0那么原来的角色没有 是用户新勾选的
if (dt_user_role_old.Select("roleid = '" + str_role[j] + "'").Length == 0)
{
userroleadd = new UserRoleEntity();
userroleadd.UserId = userId;
userroleadd.RoleId = Convert.ToInt32(str_role[j]);
role_addList.Add(userroleadd);
}
}
}
if (role_addList.Count == 0 && role_deleteList.Count == 0)
后面还有 42 行代码,购买后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。