<#@ template language="c#" HostSpecific="True" #>
<#@ output extension= ".cs" #>
<#
TableHost host = (TableHost)(Host);
host.Fieldlist.Sort(CodeCommon.CompareByintOrder);
#>
using Review.Core.Repositories.Dapper;
using Review.Core.SOA;
using Review.Permissions.Model;
using System;
using System.Collections.Generic;
using System.Text;
namespace Review.Permissions.Repositories
{
/// <summary>
<# if( host.TableDescription.Length > 0) {#>
/// <#= host.TableDescription #>
<# } #>
/// </summary>
public class <#= host.GetModelClass(host.TableName) #>Rep
{
private readonly IDapperExtensionRepository<<#= host.GetModelClass(host.TableName) #>> _<#= host.GetModelClass(host.TableName).ToString().ToLower() #>;
public <#= host.GetModelClass(host.TableName) #>Rep (IDapperExtensionRepository<<#= host.GetModelClass(host.TableName) #>> <#= host.GetModelClass(host.TableName).ToString().ToLower() #>)
{
_<#= host.GetModelClass(host.TableName).ToString().ToLower() #>=<#= host.GetModelClass(host.TableName).ToString().ToLower() #>;
}
/// <summary>
<# if( host.TableDescription.Length > 0) {#>
/// 获取<#= host.TableDescription #>数据
<# } #>
/// </summary>
/// <param name="ID"></param>
/// <returns></returns>
public <#= host.GetModelClass(host.TableName) #> Find(long ID)
{
return _<#= host.GetModelClass(host.TableName).ToString().ToLower() #>.Find(i => i.<#= host.GetModelClass(host.TableName) #>ID == ID);
}
/// <summary>
/// 添加
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public int Add(<#= host.GetModelClass(host.TableName) #> model)
{
return _<#= host.GetModelClass(host.TableName).ToString().ToLower() #>.InsertById(model);
}
/// <summary>
/// 编辑
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public void Update(<#= host.GetModelClass(host.TableName) #> model)
{
_<#= host.GetModelClass(host.TableName).ToString().ToLower() #>.Update(model);
}
/// <summary>
/// 获取列表
/// </summary>
/// <param name="page"></param>
/// <returns></returns>
public PageDataView<<#= host.GetModelClass(host.TableName) #>> Get<#= host.GetModelClass(host.TableName) #>InfoList(<#= host.GetModelClass(host.TableName) #> <#= host.GetModelClass(host.TableName).ToString().ToLower() #>, RequestPageBaseModel page)
{
PageCriteria pageCriteria = new PageCriteria();
pageCriteria.TableName = "";
pageCriteria.CurrentPage = page.CurrentPage;
pageCriteria.PrimaryKey = "";
pageCriteria.Fields = @"*";
pageCriteria.Sort = page.Sorting.Replace(',', ' ').ToString();
pageCriteria.PageSize = page.TotalPageCount;
pageCriteria.Condition = "1=1";
if (!string.IsNullOrEmpty(page.StartDateTime))
{
pageCriteria.Condition += string.Format(" AND a.CreateTime>='{0}'", page.StartDateTime);
}
if (!string.IsNullOrEmpty(page.EndDateTime))
{
pageCriteria.Condition += string.Format(" AND a.CreateTime<='{0}'", page.EndDateTime);
}
return _<#= host.GetModelClass(host.TableName).ToString().ToLower() #>.Page(pageCriteria);
}
}
}