用户列表添加角色信息

usertest
cjy 3 months ago
parent 6ea7de1026
commit b1722e89d9

@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DS.WMS.Core.Code.Entity
{
internal class CodeDataRule
{
}
}

@ -0,0 +1,63 @@
using DS.Module.Core;
using DS.Module.Core.Data;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DS.WMS.Core.Code.Entity
{
/// <summary>
/// 数据权限模板
/// </summary>
[SqlSugar.SugarTable("code_data_rule_template","数据权限模板")]
public class CodeDataRuleTemplate : BaseModel<long>
{
/// <summary>
/// 模板名称
/// </summary>
[SqlSugar.SugarColumn(ColumnDescription = "模板名称", IsNullable = false, Length = 200)]
public string TemplateName { get; set; }
/// <summary>
/// 资源标识权限ID
/// </summary>
[SugarColumn(ColumnDescription = "资源标识权限ID")]
public long PermissionId { get; set; }
/// <summary>
/// 权限实体
/// </summary>
[SqlSugar.SugarColumn(ColumnDescription = "权限实体", IsNullable = false, Length = 100)]
public string PermissionEntity { get; set; }
/// <summary>
/// 中文视图名
/// </summary>
[SqlSugar.SugarColumn(ColumnDescription = "中文视图名", IsNullable = true, Length = 50)]
public string ColumnView { get; set; }
/// <summary>
/// 权限规则
/// </summary>
[SugarColumn(ColumnDescription = "权限规则", IsNullable = true, ColumnDataType = StaticConfig.CodeFirst_BigString)]
public string DataRules { get; set; }
/// <summary>
/// 数据权限描述
/// </summary>
[SqlSugar.SugarColumn(ColumnDescription = "数据权限描述", IsNullable = true, Length = 200)]
public string Description { get; set; }
/// <summary>
/// 状态
/// </summary>
[SqlSugar.SugarColumn(ColumnDescription = "状态")]
public StatusEnum? Status { get; set; } = StatusEnum.Enable;
/// <summary>
/// 排序号
/// </summary>
[SqlSugar.SugarColumn(ColumnDescription = "排序号", IsNullable = true, DefaultValue ="100")]
public int OrderNo { get; set; }
}
}

@ -228,4 +228,9 @@ public class UserViewModel
/// </summary>
[Description("身份证号")]
public string IdCardNo { get; set; }
/// <summary>
/// 用户角色
/// </summary>
public string RoleName { get; set; }
}

@ -50,14 +50,24 @@ public class UserService : IUserService
public DataResult<List<UserViewModel>> GetListByPage(PageRequest request)
{
var query = _commonService.GetDataRuleFilter<SysUser>();
// var number =_commonService.GetSequenceNext<SysUser>();
//序列化查询条件
var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
var data = query
.Where(x => x.UserCode != "admin")
.Where(whereList).Select<UserViewModel>()
.Mapper(it =>
{
var roleStr = string.Empty;
var roleIds = db.Queryable<SysRoleUser>().Where(x => x.UserId == it.Id).Select(x => x.RoleId).ToArray();
if (roleIds.Count()>0)
{
var roles = db.Queryable<SysRole>().Where(x => roleIds.Contains(x.Id)).Select(x => x.RoleName).ToArray();
roleStr = roles.ToJoin(",");
}
it.RoleName = roleStr;
})
.ToQueryPage(request.PageCondition);
return data;
}

Loading…
Cancel
Save