commit
01b9dd7a1e
|
@ -0,0 +1,39 @@
|
|||
using Bootstrap.Admin.Components;
|
||||
using Bootstrap.DataAccess;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Bootstrap.Pages.Admin.Components
|
||||
{
|
||||
/// <summary>
|
||||
/// 部门维护组件
|
||||
/// </summary>
|
||||
public class RolesBase : QueryPageBase<Role>
|
||||
{
|
||||
/// <summary>
|
||||
/// 查询方法
|
||||
/// </summary>
|
||||
/// <param name="pageIndex">页码</param>
|
||||
/// <param name="pageItems">每页显示数据条目数量</param>
|
||||
protected override QueryData<Role> Query(int pageIndex, int pageItems)
|
||||
{
|
||||
var data = RoleHelper.Retrieves();
|
||||
if (!string.IsNullOrEmpty(QueryModel.RoleName)) data = data.Where(d => d.RoleName.Contains(QueryModel.RoleName, StringComparison.OrdinalIgnoreCase));
|
||||
if (!string.IsNullOrEmpty(QueryModel.Description)) data = data.Where(d => d.Description != null && d.Description.Contains(QueryModel.Description, StringComparison.OrdinalIgnoreCase));
|
||||
var totalCount = data.Count();
|
||||
var items = data.Skip((pageIndex - 1) * pageItems).Take(pageItems);
|
||||
return new QueryData<Role>() { Items = items, TotalCount = totalCount, PageIndex = pageIndex, PageItems = pageItems };
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 保存方法
|
||||
/// </summary>
|
||||
protected override bool Save(Role item) => RoleHelper.Save(item);
|
||||
|
||||
/// <summary>
|
||||
/// 删除方法
|
||||
/// </summary>
|
||||
protected override bool Delete(IEnumerable<Role> items) => RoleHelper.Delete(items.Select(item => item.Id ?? ""));
|
||||
}
|
||||
}
|
|
@ -78,7 +78,7 @@
|
|||
<div class="form-group col-sm-6">
|
||||
<input type="hidden" id="roleID" />
|
||||
<label class="control-label" for="roleDesc">角色描述</label>
|
||||
<input type="text" class="form-control" id="roleDesc" placeholder="描述信息(可为空),50字以内" maxlength="50" />
|
||||
<input type="text" class="form-control" id="roleDesc" placeholder="描述信息(可为空),500字以内" maxlength="500" />
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
|
|
@ -2,12 +2,13 @@
|
|||
using PetaPoco;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
|
||||
namespace Bootstrap.DataAccess
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// 角色实体类
|
||||
/// </summary>
|
||||
[TableName("Roles")]
|
||||
public class Role
|
||||
|
@ -20,11 +21,13 @@ namespace Bootstrap.DataAccess
|
|||
/// <summary>
|
||||
/// 获得/设置 角色名称
|
||||
/// </summary>
|
||||
[DisplayName("角色名称")]
|
||||
public string RoleName { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// 获得/设置 角色描述
|
||||
/// </summary>
|
||||
[DisplayName("角色描述")]
|
||||
public string Description { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
|
@ -213,7 +216,7 @@ namespace Bootstrap.DataAccess
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// 通过指定登录用户名获得角色列表
|
||||
/// </summary>
|
||||
/// <param name="userName"></param>
|
||||
/// <returns></returns>
|
||||
|
|
Loading…
Reference in New Issue