mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-09-19 18:22:11 +08:00
增加撤销与启动,详见:#I3ILBG
调整工程结构,采用模块化机制
This commit is contained in:
87
OpenAuth.App/Form/FormApp.cs
Normal file
87
OpenAuth.App/Form/FormApp.cs
Normal file
@@ -0,0 +1,87 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Infrastructure;
|
||||
using Microsoft.Extensions.Options;
|
||||
using OpenAuth.App.Interface;
|
||||
using OpenAuth.App.Request;
|
||||
using OpenAuth.App.Response;
|
||||
using OpenAuth.Repository;
|
||||
using OpenAuth.Repository.Domain;
|
||||
using OpenAuth.Repository.Interface;
|
||||
|
||||
|
||||
namespace OpenAuth.App
|
||||
{
|
||||
public class FormApp : BaseStringApp<Form,OpenAuthDBContext>
|
||||
{
|
||||
private IAuth _auth;
|
||||
private IOptions<AppSetting> _appConfiguration;
|
||||
/// <summary>
|
||||
/// 加载列表
|
||||
/// </summary>
|
||||
public async Task<TableData> Load(QueryFormListReq request)
|
||||
{
|
||||
var result = new TableData();
|
||||
var forms = GetDataPrivilege("u");
|
||||
if (!string.IsNullOrEmpty(request.key))
|
||||
{
|
||||
forms = forms.Where(u => u.Name.Contains(request.key) || u.Id.Contains(request.key));
|
||||
}
|
||||
|
||||
result.data = forms.OrderByDescending(u => u.CreateDate)
|
||||
.Skip((request.page - 1) * request.limit)
|
||||
.Take(request.limit).ToList();
|
||||
result.count = forms.Count();
|
||||
return result;
|
||||
}
|
||||
|
||||
public void Add(Form obj)
|
||||
{
|
||||
var user = _auth.GetCurrentUser().User;
|
||||
obj.CreateUserId = user.Id;
|
||||
obj.CreateUserName = user.Name;
|
||||
UnitWork.Add(obj);
|
||||
if (!string.IsNullOrEmpty(obj.DbName))
|
||||
{
|
||||
UnitWork.ExecuteSql(FormUtil.GetSql(obj, _appConfiguration.Value.DbType));
|
||||
}
|
||||
UnitWork.Save();
|
||||
}
|
||||
|
||||
public void Update(Form obj)
|
||||
{
|
||||
Repository.Update(u => u.Id == obj.Id, u => new Form
|
||||
{
|
||||
ContentData = obj.ContentData,
|
||||
Content = obj.Content,
|
||||
ContentParse = obj.ContentParse,
|
||||
Name = obj.Name,
|
||||
Disabled = obj.Disabled,
|
||||
DbName = obj.DbName,
|
||||
SortCode = obj.SortCode,
|
||||
Description = obj.Description,
|
||||
OrgId = obj.OrgId,
|
||||
ModifyDate = DateTime.Now
|
||||
});
|
||||
|
||||
if (!string.IsNullOrEmpty(obj.DbName))
|
||||
{
|
||||
UnitWork.ExecuteSql(FormUtil.GetSql(obj, _appConfiguration.Value.DbType));
|
||||
}
|
||||
}
|
||||
|
||||
public FormResp FindSingle(string id)
|
||||
{
|
||||
var form = Get(id);
|
||||
return form.MapTo<FormResp>();
|
||||
}
|
||||
|
||||
public FormApp(IUnitWork<OpenAuthDBContext> unitWork, IRepository<Form,OpenAuthDBContext> repository,
|
||||
IAuth auth, IOptions<AppSetting> appConfiguration) : base(unitWork, repository, auth)
|
||||
{
|
||||
_auth = auth;
|
||||
_appConfiguration = appConfiguration;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user