2018-10-19 23:09:52 +08:00
|
|
|
|
using Bootstrap.DataAccess;
|
2018-06-07 00:45:47 +08:00
|
|
|
|
using Longbow.Web.Mvc;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
|
|
namespace Bootstrap.Admin.Query
|
|
|
|
|
{
|
2018-10-28 15:08:58 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
2018-06-07 00:45:47 +08:00
|
|
|
|
public class QueryMenuOption : PaginationOption
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string Name { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string ParentName { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string Category { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string IsResource { get; set; }
|
2018-10-28 15:08:58 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="userName"></param>
|
|
|
|
|
/// <returns></returns>
|
2018-10-31 12:08:57 +08:00
|
|
|
|
public QueryData<object> RetrieveData(string userName)
|
2018-06-07 00:45:47 +08:00
|
|
|
|
{
|
2018-10-19 23:09:52 +08:00
|
|
|
|
var data = MenuHelper.RetrieveMenusByUserName(userName);
|
2018-06-07 00:45:47 +08:00
|
|
|
|
if (!string.IsNullOrEmpty(ParentName))
|
|
|
|
|
{
|
|
|
|
|
data = data.Where(t => t.ParentName.Contains(ParentName));
|
|
|
|
|
}
|
|
|
|
|
if (!string.IsNullOrEmpty(Name))
|
|
|
|
|
{
|
|
|
|
|
data = data.Where(t => t.Name.Contains(Name));
|
|
|
|
|
}
|
|
|
|
|
if (!string.IsNullOrEmpty(Category))
|
|
|
|
|
{
|
|
|
|
|
data = data.Where(t => t.Category.Contains(Category));
|
|
|
|
|
}
|
|
|
|
|
if (!string.IsNullOrEmpty(IsResource))
|
|
|
|
|
{
|
|
|
|
|
data = data.Where(t => t.IsResource.ToString() == IsResource);
|
|
|
|
|
}
|
2018-10-31 12:08:57 +08:00
|
|
|
|
var ret = new QueryData<object>();
|
2018-06-07 00:45:47 +08:00
|
|
|
|
ret.total = data.Count();
|
|
|
|
|
switch (Sort)
|
|
|
|
|
{
|
|
|
|
|
case "Name":
|
|
|
|
|
data = Order == "asc" ? data.OrderBy(t => t.Name) : data.OrderByDescending(t => t.Name);
|
|
|
|
|
break;
|
|
|
|
|
case "ParentName":
|
|
|
|
|
data = Order == "asc" ? data.OrderBy(t => t.ParentName) : data.OrderByDescending(t => t.ParentName);
|
|
|
|
|
break;
|
|
|
|
|
case "Order":
|
|
|
|
|
data = Order == "asc" ? data.OrderBy(t => t.Order) : data.OrderByDescending(t => t.Order);
|
|
|
|
|
break;
|
|
|
|
|
case "CategoryName":
|
|
|
|
|
data = Order == "asc" ? data.OrderBy(t => t.CategoryName) : data.OrderByDescending(t => t.CategoryName);
|
|
|
|
|
break;
|
|
|
|
|
case "Target":
|
|
|
|
|
data = Order == "asc" ? data.OrderBy(t => t.Target) : data.OrderByDescending(t => t.Target);
|
|
|
|
|
break;
|
|
|
|
|
case "IsResource":
|
|
|
|
|
data = Order == "asc" ? data.OrderBy(t => t.IsResource) : data.OrderByDescending(t => t.IsResource);
|
|
|
|
|
break;
|
2019-01-11 23:20:28 +08:00
|
|
|
|
case "Application":
|
|
|
|
|
data = Order == "asc" ? data.OrderBy(t => t.Application) : data.OrderByDescending(t => t.Application);
|
2018-06-07 00:45:47 +08:00
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
2018-10-31 12:08:57 +08:00
|
|
|
|
ret.rows = data.Skip(Offset).Take(Limit).Select(p => new
|
|
|
|
|
{
|
|
|
|
|
p.Id,
|
|
|
|
|
p.ParentId,
|
|
|
|
|
p.ParentName,
|
|
|
|
|
p.Name,
|
|
|
|
|
p.Order,
|
|
|
|
|
p.Icon,
|
|
|
|
|
p.Url,
|
|
|
|
|
p.Category,
|
|
|
|
|
p.CategoryName,
|
|
|
|
|
p.Target,
|
|
|
|
|
p.IsResource,
|
2019-01-11 23:20:28 +08:00
|
|
|
|
p.Application
|
2018-10-31 12:08:57 +08:00
|
|
|
|
});
|
2018-06-07 00:45:47 +08:00
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-10-25 18:54:20 +08:00
|
|
|
|
}
|