mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2026-04-07 17:41:28 +08:00
增加分类管理
This commit is contained in:
85
OpenAuth.App/CategoryApp.cs
Normal file
85
OpenAuth.App/CategoryApp.cs
Normal file
@@ -0,0 +1,85 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenAuth.App;
|
||||
using OpenAuth.App.Request;
|
||||
using OpenAuth.App.Response;
|
||||
using OpenAuth.Repository.Domain;
|
||||
|
||||
namespace LwSolution.App
|
||||
{
|
||||
/// <summary>
|
||||
/// 分类管理
|
||||
/// </summary>
|
||||
public class CategoryApp :BaseApp<Category>
|
||||
{
|
||||
|
||||
public IEnumerable<Category> Get(string type)
|
||||
{
|
||||
return UnitWork.Find<Category>(u => u.TypeId == type);
|
||||
}
|
||||
|
||||
public void Add(Category category)
|
||||
{
|
||||
if (string.IsNullOrEmpty(category.Id))
|
||||
{
|
||||
category.Id = Guid.NewGuid().ToString();
|
||||
}
|
||||
UnitWork.Add(category);
|
||||
UnitWork.Save();
|
||||
}
|
||||
|
||||
public void Update(Category category)
|
||||
{
|
||||
UnitWork.Update<Category>(u =>u.Id,category);
|
||||
UnitWork.Save();
|
||||
}
|
||||
|
||||
|
||||
public void Delete(string[] ids)
|
||||
{
|
||||
UnitWork.Delete<Category>(u => ids.Contains(u.Id));
|
||||
}
|
||||
|
||||
|
||||
public TableData All(QueryCategoriesReq request)
|
||||
{
|
||||
var result = new TableData();
|
||||
var categories = UnitWork.Find<Category>(null) ;
|
||||
if (!string.IsNullOrEmpty(request.key))
|
||||
{
|
||||
categories = categories.Where(u => u.Name.Contains(request.key) || u.Id.Contains(request.key));
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(request.TypeId))
|
||||
{
|
||||
categories = categories.Where(u => u.TypeId == request.TypeId);
|
||||
}
|
||||
|
||||
var query = from category in categories
|
||||
join ct in UnitWork.Find<CategoryType>(null) on category.TypeId equals ct.Id
|
||||
into tmp
|
||||
from ct in tmp.DefaultIfEmpty()
|
||||
select new
|
||||
{
|
||||
category.Name,
|
||||
category.Id,
|
||||
category.TypeId,
|
||||
TypeName = ct.Name,
|
||||
category.Description
|
||||
};
|
||||
|
||||
result.data = query.OrderBy(u => u.TypeId)
|
||||
.Skip((request.page - 1) * request.limit)
|
||||
.Take(request.limit).ToList();
|
||||
result.count = categories.Count();
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<CategoryType> AllTypes()
|
||||
{
|
||||
return UnitWork.Find<CategoryType>(null).ToList();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,4 @@
|
||||
using System;
|
||||
|
||||
namespace OpenAuth.App.Extention
|
||||
namespace OpenAuth.App.Extention
|
||||
{
|
||||
|
||||
public class WF_RuntimeInitModel
|
||||
|
||||
@@ -83,13 +83,16 @@
|
||||
<Compile Include="AuthoriseService.cs" />
|
||||
<Compile Include="BaseApp.cs" />
|
||||
<Compile Include="AuthorizeApp.cs" />
|
||||
<Compile Include="CategoryApp.cs" />
|
||||
<Compile Include="Extention\IWF_Runtime.cs" />
|
||||
<Compile Include="Extention\WF_Runtime.cs" />
|
||||
<Compile Include="Extention\WF_RuntimeInitModel.cs" />
|
||||
<Compile Include="Extention\WF_RuntimeModel.cs" />
|
||||
<Compile Include="Request\IdPageReq.cs" />
|
||||
<Compile Include="Request\PageReq.cs" />
|
||||
<Compile Include="Request\QueryCategoriesReq.cs" />
|
||||
<Compile Include="Request\QueryUserListReq.cs" />
|
||||
<Compile Include="Response\TableData.cs" />
|
||||
<Compile Include="RevelanceManagerApp.cs" />
|
||||
<Compile Include="SystemAuthService.cs" />
|
||||
<Compile Include="WFFormService.cs" />
|
||||
@@ -129,9 +132,7 @@
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Response\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
|
||||
16
OpenAuth.App/Request/QueryCategoriesReq.cs
Normal file
16
OpenAuth.App/Request/QueryCategoriesReq.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
namespace OpenAuth.App.Request
|
||||
{
|
||||
public class QueryCategoriesReq : PageReq
|
||||
{
|
||||
/// <summary>
|
||||
/// 是否审核,all:全部; true:已审核;false:未审核
|
||||
/// </summary>
|
||||
public string Checked { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// TypeID
|
||||
/// </summary>
|
||||
public string TypeId { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
41
OpenAuth.App/Response/TableData.cs
Normal file
41
OpenAuth.App/Response/TableData.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
// ***********************************************************************
|
||||
// Assembly : FundationAdmin
|
||||
// Author : yubaolee
|
||||
// Created : 03-09-2016
|
||||
//
|
||||
// Last Modified By : yubaolee
|
||||
// Last Modified On : 03-09-2016
|
||||
// ***********************************************************************
|
||||
// <copyright file="TableData.cs" company="Microsoft">
|
||||
// 版权所有(C) Microsoft 2015
|
||||
// </copyright>
|
||||
// <summary>layui datatable数据返回</summary>
|
||||
// ***********************************************************************
|
||||
|
||||
namespace OpenAuth.App.Response
|
||||
{
|
||||
/// <summary>
|
||||
/// table的返回数据
|
||||
/// </summary>
|
||||
public class TableData
|
||||
{
|
||||
/// <summary>
|
||||
/// 状态码
|
||||
/// </summary>
|
||||
public int code;
|
||||
/// <summary>
|
||||
/// 操作消息
|
||||
/// </summary>
|
||||
public string msg;
|
||||
|
||||
/// <summary>
|
||||
/// 总记录条数
|
||||
/// </summary>
|
||||
public int count;
|
||||
|
||||
/// <summary>
|
||||
/// 数据内容
|
||||
/// </summary>
|
||||
public dynamic data;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using Infrastructure;
|
||||
using Infrastructure.Cache;
|
||||
using OpenAuth.Repository.Domain;
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using Infrastructure;
|
||||
using Infrastructure;
|
||||
using System.Collections.Generic;
|
||||
using OpenAuth.Repository.Domain;
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
// <summary>角色模型视图</summary>
|
||||
// ***********************************************************************
|
||||
|
||||
using System;
|
||||
using Infrastructure;
|
||||
using OpenAuth.Repository.Domain;
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Infrastructure;
|
||||
using OpenAuth.Repository.Domain;
|
||||
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
// ***********************************************************************
|
||||
|
||||
using System.Collections.Generic;
|
||||
using Infrastructure;
|
||||
using OpenAuth.Repository.Domain;
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenAuth.App.ViewModel;
|
||||
using OpenAuth.Repository.Domain;
|
||||
|
||||
Reference in New Issue
Block a user