OpenAuth.Net/OpenAuth.App/FormApp.cs

64 lines
1.7 KiB
C#
Raw Normal View History

2018-03-28 17:35:43 +08:00
using System;
using Infrastructure;
2018-03-24 09:56:32 +08:00
using OpenAuth.App.Request;
2017-12-18 22:37:51 +08:00
using OpenAuth.App.Response;
using OpenAuth.Repository.Domain;
namespace OpenAuth.App
{
2018-02-28 17:34:27 +08:00
public class FormApp : BaseApp<Form>
2017-12-18 22:37:51 +08:00
{
public RevelanceManagerApp ReleManagerApp { get; set; }
/// <summary>
/// 加载列表
/// </summary>
public TableData Load(QueryFormListReq request)
{
2018-03-28 17:35:43 +08:00
2017-12-18 22:37:51 +08:00
return new TableData
{
count = Repository.GetCount(null),
2018-03-28 17:35:43 +08:00
data = Repository.Find(request.page, request.limit, "CreateDate desc")
2017-12-18 22:37:51 +08:00
};
}
2018-02-28 17:34:27 +08:00
public void Add(Form obj)
2017-12-18 22:37:51 +08:00
{
2018-03-15 17:36:41 +08:00
UnitWork.Add(obj);
2018-03-28 17:35:43 +08:00
if (!string.IsNullOrEmpty(obj.DbName))
{
UnitWork.ExecuteSql(FormUtil.GetSql(obj));
}
2018-03-15 17:36:41 +08:00
UnitWork.Save();
2017-12-18 22:37:51 +08:00
}
2018-03-28 17:35:43 +08:00
2018-02-28 17:34:27 +08:00
public void Update(Form obj)
2017-12-18 22:37:51 +08:00
{
2018-03-06 17:43:40 +08:00
Repository.Update(u => u.Id == obj.Id, u => new Form
2017-12-18 22:37:51 +08:00
{
2018-03-28 17:35:43 +08:00
ContentData = obj.ContentData,
Content = obj.Content,
ContentParse = obj.ContentParse,
Name = obj.Name,
DbName = obj.DbName,
SortCode = obj.SortCode,
Description = obj.Description,
ModifyDate = DateTime.Now
2017-12-18 22:37:51 +08:00
});
2018-03-28 17:35:43 +08:00
if (!string.IsNullOrEmpty(obj.DbName))
{
UnitWork.ExecuteSql(FormUtil.GetSql(obj));
}
2017-12-18 22:37:51 +08:00
}
2018-03-24 09:56:32 +08:00
public FormResp FindSingle(string id)
2018-03-02 16:34:38 +08:00
{
2018-03-28 17:35:43 +08:00
var form = Get(id);
2018-03-24 09:56:32 +08:00
return form.MapTo<FormResp>();
2018-03-02 16:34:38 +08:00
}
2017-12-18 22:37:51 +08:00
}
}