mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-04-22 02:32:50 +08:00
combine website examples.
This commit is contained in:
commit
9222de0668
82
Examples/website/FreeSql.Site.DAL/BaseDAL.cs
Normal file
82
Examples/website/FreeSql.Site.DAL/BaseDAL.cs
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
//using FreeSql.Site.Entity;
|
||||||
|
using FreeSql.Site.Entity;
|
||||||
|
using FreeSql.Site.Entity.Common;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace FreeSql.Site.DAL
|
||||||
|
{
|
||||||
|
public class BaseDAL<T> where T : BaseEntity
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 新增方法
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="model"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public virtual long Insert(T model)
|
||||||
|
{
|
||||||
|
var runsql = DataBaseType.MySql.DB().Insert<T>(model);
|
||||||
|
return runsql.ExecuteIdentity();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 修改方法
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="model"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public virtual bool Update(T model)
|
||||||
|
{
|
||||||
|
var runsql = DataBaseType.MySql.DB().Update<T>().SetSource(model);
|
||||||
|
return runsql.ExecuteAffrows() > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 删除方法
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public virtual bool Delete(long id)
|
||||||
|
{
|
||||||
|
return DataBaseType.MySql.DB().Delete<T>(id).ExecuteDeleted().Count > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取一条数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="where"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public virtual T GetByOne(Expression<Func<T, bool>> where)
|
||||||
|
{
|
||||||
|
return DataBaseType.MySql.DB().Select<T>()
|
||||||
|
.Where(where).ToOne();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查询方法
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="where"></param>
|
||||||
|
/// <param name="orderby"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public virtual (List<T> list, long count) Query(Expression<Func<T, bool>> where,
|
||||||
|
Expression<Func<T, T>> orderby = null, PageInfo pageInfo = null)
|
||||||
|
{
|
||||||
|
//设置查询条件
|
||||||
|
var list = DataBaseType.MySql.DB().Select<T>()
|
||||||
|
.Where(where);
|
||||||
|
|
||||||
|
BaseEntity baseEntity = new BaseEntity();
|
||||||
|
//设置排序
|
||||||
|
if (orderby != null) list = list.OrderBy(nameof(baseEntity.CreateDt) + " desc ");
|
||||||
|
|
||||||
|
var count = list.Count();
|
||||||
|
//设置分页操作
|
||||||
|
if (pageInfo != null && pageInfo.IsPaging)
|
||||||
|
list.Skip((pageInfo.PageIndex - 1) * pageInfo.PageSize).Limit(pageInfo.PageSize);
|
||||||
|
|
||||||
|
//执行查询
|
||||||
|
return (list.ToList(), count);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
40
Examples/website/FreeSql.Site.DAL/Db.cs
Normal file
40
Examples/website/FreeSql.Site.DAL/Db.cs
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
using FreeSql.Site.DAL.Helper;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace FreeSql.Site.DAL
|
||||||
|
{
|
||||||
|
public static class Db
|
||||||
|
{
|
||||||
|
public static System.Collections.Generic.Dictionary<string, IFreeSql> ConnectionPool = new System.Collections.Generic.Dictionary<string, IFreeSql>();
|
||||||
|
|
||||||
|
private static string getConnectionString(string sDatabaseType)
|
||||||
|
{
|
||||||
|
return AppSettingsManager.Get($"DbContexts:{sDatabaseType}:ConnectionString");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static IFreeSql SelectDBType(string dbtype)
|
||||||
|
{
|
||||||
|
if (!ConnectionPool.ContainsKey(dbtype))
|
||||||
|
{
|
||||||
|
ConnectionPool.Add(dbtype, new FreeSql.FreeSqlBuilder()
|
||||||
|
.UseConnectionString(FreeSql.DataType.MySql, getConnectionString(dbtype))
|
||||||
|
.Build());
|
||||||
|
}
|
||||||
|
return ConnectionPool[dbtype];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IFreeSql DB(this DataBaseType t)
|
||||||
|
{
|
||||||
|
return SelectDBType(t.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum DataBaseType
|
||||||
|
{
|
||||||
|
MySql,
|
||||||
|
SqlServer,
|
||||||
|
PostgreSQL,
|
||||||
|
Oracle,
|
||||||
|
Sqlite
|
||||||
|
}
|
||||||
|
}
|
14
Examples/website/FreeSql.Site.DAL/DocumentCommentDAL.cs
Normal file
14
Examples/website/FreeSql.Site.DAL/DocumentCommentDAL.cs
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
//using FreeSql.Site.Entity;
|
||||||
|
using FreeSql.Site.Entity;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace FreeSql.Site.DAL
|
||||||
|
{
|
||||||
|
public class DocumentCommentDAL : BaseDAL<DocumentComment>
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
90
Examples/website/FreeSql.Site.DAL/DocumentContentDAL.cs
Normal file
90
Examples/website/FreeSql.Site.DAL/DocumentContentDAL.cs
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
using FreeSql.Site.Entity;
|
||||||
|
using FreeSql.Site.Entity.Common;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
|
||||||
|
namespace FreeSql.Site.DAL
|
||||||
|
{
|
||||||
|
public class DocumentContentDAL : BaseDAL<DocumentContent>
|
||||||
|
{
|
||||||
|
///// <summary>
|
||||||
|
///// 新增
|
||||||
|
///// </summary>
|
||||||
|
///// <param name="model"></param>
|
||||||
|
///// <returns></returns>
|
||||||
|
//public long Insert(DocumentContent model)
|
||||||
|
//{
|
||||||
|
// return DataBaseType.MySql.DB().Insert<DocumentContent>(model).ExecuteIdentity();
|
||||||
|
//}
|
||||||
|
|
||||||
|
///// <summary>
|
||||||
|
///// 修改
|
||||||
|
///// </summary>
|
||||||
|
///// <param name="model"></param>
|
||||||
|
///// <returns></returns>
|
||||||
|
//public bool Update(DocumentContent model)
|
||||||
|
//{
|
||||||
|
// var runsql = DataBaseType.MySql.DB().Update<DocumentContent>().SetSource(model);
|
||||||
|
// return runsql.ExecuteAffrows() > 0;
|
||||||
|
//}
|
||||||
|
|
||||||
|
///// <summary>
|
||||||
|
///// 删除
|
||||||
|
///// </summary>
|
||||||
|
///// <param name="id"></param>
|
||||||
|
///// <returns></returns>
|
||||||
|
//public bool Delete(long id)
|
||||||
|
//{
|
||||||
|
// return DataBaseType.MySql.DB().Delete<DocumentContent>(id).ExecuteDeleted().Count > 0;
|
||||||
|
//}
|
||||||
|
|
||||||
|
///// <summary>
|
||||||
|
///// 获取一条数据
|
||||||
|
///// </summary>
|
||||||
|
///// <param name="where"></param>
|
||||||
|
///// <returns></returns>
|
||||||
|
//public DocumentContent GetByOne(Expression<Func<DocumentContent, bool>> where)
|
||||||
|
//{
|
||||||
|
// return DataBaseType.MySql.DB().Select<DocumentContent>()
|
||||||
|
// .Where(where).ToOne();
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
///// <summary>
|
||||||
|
///// 获取一条数据
|
||||||
|
///// </summary>
|
||||||
|
///// <param name="where"></param>
|
||||||
|
///// <returns></returns>
|
||||||
|
//public long Count(Expression<Func<DocumentContent, bool>> where)
|
||||||
|
//{
|
||||||
|
// return DataBaseType.MySql.DB().Select<DocumentContent>()
|
||||||
|
// .Where(where).Count();
|
||||||
|
//}
|
||||||
|
|
||||||
|
///// <summary>
|
||||||
|
///// 查询功能
|
||||||
|
///// </summary>
|
||||||
|
///// <param name="where"></param>
|
||||||
|
///// <param name="orderby"></param>
|
||||||
|
///// <returns></returns>
|
||||||
|
//public (List<DocumentContent> list, long count) Query(Expression<Func<DocumentContent, bool>> where,
|
||||||
|
// Expression<Func<DocumentContent, DocumentContent>> orderby = null, PageInfo pageInfo = null)
|
||||||
|
//{
|
||||||
|
// //设置查询条件
|
||||||
|
// var list = DataBaseType.MySql.DB().Select<DocumentContent>()
|
||||||
|
// .Where(where);
|
||||||
|
|
||||||
|
// //设置排序
|
||||||
|
// if (orderby != null) list = list.OrderBy(b => b.CreateDt);
|
||||||
|
|
||||||
|
// var count = list.Count();
|
||||||
|
// //设置分页操作
|
||||||
|
// if (pageInfo != null && pageInfo.IsPaging)
|
||||||
|
// list.Skip(pageInfo.PageIndex * pageInfo.PageSize).Limit(pageInfo.PageSize);
|
||||||
|
|
||||||
|
// //执行查询
|
||||||
|
// return (list.ToList(), count);
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
}
|
15
Examples/website/FreeSql.Site.DAL/DocumentTypeDAL.cs
Normal file
15
Examples/website/FreeSql.Site.DAL/DocumentTypeDAL.cs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
//using FreeSql.Site.Entity;
|
||||||
|
using FreeSql.Site.Entity;
|
||||||
|
using FreeSql.Site.Entity.Common;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace FreeSql.Site.DAL
|
||||||
|
{
|
||||||
|
public class DocumentTypeDAL : BaseDAL<DocumentType>
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
18
Examples/website/FreeSql.Site.DAL/FreeSql.Site.DAL.csproj
Normal file
18
Examples/website/FreeSql.Site.DAL/FreeSql.Site.DAL.csproj
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>netcoreapp2.2</TargetFramework>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="2.1.0" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.1.0" />
|
||||||
|
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\..\..\FreeSql\FreeSql.csproj" />
|
||||||
|
<ProjectReference Include="..\FreeSql.Site.Entity\FreeSql.Site.Entity.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
@ -0,0 +1,44 @@
|
|||||||
|
using System.IO;
|
||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace FreeSql.Site.DAL
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 配置管理器
|
||||||
|
/// </summary>
|
||||||
|
public static class AppSettingsManager
|
||||||
|
{
|
||||||
|
private static IConfiguration _configuration;
|
||||||
|
|
||||||
|
static AppSettingsManager()
|
||||||
|
{
|
||||||
|
BuildConfiguration();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void BuildConfiguration()
|
||||||
|
{
|
||||||
|
var builder = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory())
|
||||||
|
.AddJsonFile("appsettings.json", false).AddJsonFile("appsettings.Development.json", true);
|
||||||
|
_configuration = builder.Build();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 读取指定节点信息
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="key">节点名称,多节点以:分隔</param>
|
||||||
|
public static string Get(string key)
|
||||||
|
{
|
||||||
|
return _configuration[key];
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 读取指定节点信息
|
||||||
|
/// </summary>
|
||||||
|
public static T Get<T>(string key)
|
||||||
|
{
|
||||||
|
string json = Get(key);
|
||||||
|
return JsonConvert.DeserializeObject<T>(json);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
37
Examples/website/FreeSql.Site.DAL/Helper/EnumHelper.cs
Normal file
37
Examples/website/FreeSql.Site.DAL/Helper/EnumHelper.cs
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace FreeSql.Site.DAL.Helper
|
||||||
|
{
|
||||||
|
public class EnumHelper
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 枚举类型转换为字符串
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T"></typeparam>
|
||||||
|
/// <param name="en"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string EnumConvertToString<T>(T en)
|
||||||
|
{
|
||||||
|
//方法一
|
||||||
|
//return color.ToString();
|
||||||
|
|
||||||
|
//方法二
|
||||||
|
return Enum.GetName(en.GetType(), en);
|
||||||
|
}
|
||||||
|
public static T StringConvertToEnum<T>(string str)
|
||||||
|
{
|
||||||
|
T result = default(T);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
result = (T)Enum.Parse(typeof(T), str);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
14
Examples/website/FreeSql.Site.DAL/TemplateExampleDAL.cs
Normal file
14
Examples/website/FreeSql.Site.DAL/TemplateExampleDAL.cs
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
//using FreeSql.Site.Entity;
|
||||||
|
using FreeSql.Site.Entity;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace FreeSql.Site.DAL
|
||||||
|
{
|
||||||
|
public class TemplateExampleDAL : BaseDAL<TemplateExample>
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
22
Examples/website/FreeSql.Site.Entity/BaseEntity.cs
Normal file
22
Examples/website/FreeSql.Site.Entity/BaseEntity.cs
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
//using FreeSql.DataAnnotations;
|
||||||
|
using FreeSql.DataAnnotations;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace FreeSql.Site.Entity
|
||||||
|
{
|
||||||
|
public class BaseEntity
|
||||||
|
{
|
||||||
|
[Column(IsIdentity = true, IsPrimary = true)]
|
||||||
|
public int ID { get; set; } = 0;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 状态
|
||||||
|
/// </summary>
|
||||||
|
public int Status { get; set; } = 1;
|
||||||
|
|
||||||
|
public DateTime? CreateDt { get; set; } = DateTime.Now;
|
||||||
|
|
||||||
|
public string CreateBy { get; set; } = "admin";
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
34
Examples/website/FreeSql.Site.Entity/Common/DataPage.cs
Normal file
34
Examples/website/FreeSql.Site.Entity/Common/DataPage.cs
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace FreeSql.Site.Entity.Common
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 列表数据返回对象
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T"></typeparam>
|
||||||
|
public class DataPage<T>
|
||||||
|
where T : class
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 返回成功与否
|
||||||
|
/// </summary>
|
||||||
|
public string code { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 如果返回报错,具体报错内容
|
||||||
|
/// </summary>
|
||||||
|
public string msg { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 总计记录行数
|
||||||
|
/// </summary>
|
||||||
|
public long count { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 返回具体的数据
|
||||||
|
/// </summary>
|
||||||
|
public List<T> data { get; set; }
|
||||||
|
}
|
||||||
|
}
|
43
Examples/website/FreeSql.Site.Entity/Common/PageInfo.cs
Normal file
43
Examples/website/FreeSql.Site.Entity/Common/PageInfo.cs
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace FreeSql.Site.Entity.Common
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 列表数据返回对象
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T"></typeparam>
|
||||||
|
public class PageInfo
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 排序字段
|
||||||
|
/// </summary>
|
||||||
|
public string Order { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 页码
|
||||||
|
/// </summary>
|
||||||
|
public int PageIndex { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 页记录数
|
||||||
|
/// </summary>
|
||||||
|
public int PageSize { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 排序方式
|
||||||
|
/// </summary>
|
||||||
|
public string Sort { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 总计数量
|
||||||
|
/// </summary>
|
||||||
|
public int Total { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否获取总数
|
||||||
|
/// </summary>
|
||||||
|
public bool IsPaging { get; set; }
|
||||||
|
}
|
||||||
|
}
|
16
Examples/website/FreeSql.Site.Entity/Common/TreeNode.cs
Normal file
16
Examples/website/FreeSql.Site.Entity/Common/TreeNode.cs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace FreeSql.Site.Entity.Common
|
||||||
|
{
|
||||||
|
public class TreeNode
|
||||||
|
{
|
||||||
|
public string id { get; set; }
|
||||||
|
|
||||||
|
public string pid { get; set; }
|
||||||
|
|
||||||
|
public string title { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
44
Examples/website/FreeSql.Site.Entity/DocumentComment.cs
Normal file
44
Examples/website/FreeSql.Site.Entity/DocumentComment.cs
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
//using FreeSql.DataAnnotations;
|
||||||
|
using FreeSql.DataAnnotations;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace FreeSql.Site.Entity
|
||||||
|
{
|
||||||
|
public class DocumentComment:BaseEntity
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 功能类型(文章、模板、示例等)
|
||||||
|
/// </summary>
|
||||||
|
public int FunctionType { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 功能ID 文章、模板、示例等
|
||||||
|
/// </summary>
|
||||||
|
public int FunctionID { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否匿名访问
|
||||||
|
/// </summary>
|
||||||
|
public int IsAnonymous { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 评论人
|
||||||
|
/// </summary>
|
||||||
|
public string Commentator { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 评论者IP
|
||||||
|
/// </summary>
|
||||||
|
public string CommentatorIp { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 回复评论编号
|
||||||
|
/// </summary>
|
||||||
|
public int ReplyID { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 评论内容
|
||||||
|
/// </summary>
|
||||||
|
public string CommentContent { get; set; }
|
||||||
|
}
|
||||||
|
}
|
77
Examples/website/FreeSql.Site.Entity/DocumentContent.cs
Normal file
77
Examples/website/FreeSql.Site.Entity/DocumentContent.cs
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
//using FreeSql.DataAnnotations;
|
||||||
|
using FreeSql.DataAnnotations;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace FreeSql.Site.Entity
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 数据库实体
|
||||||
|
/// </summary>
|
||||||
|
public class DocumentContent : BaseEntity
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 类型编号
|
||||||
|
/// </summary>
|
||||||
|
public int TypeID { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 标题
|
||||||
|
/// </summary>
|
||||||
|
public string DocTitle { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 摘要
|
||||||
|
/// </summary>
|
||||||
|
public string DocAbstract { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 内容来源类型(0 当前记录 1=Url地址
|
||||||
|
/// </summary>
|
||||||
|
public int OriginType { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 来源地址
|
||||||
|
/// </summary>
|
||||||
|
public string OriginUrl { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 编辑器模式 (=0 Markdown =1 HTML编辑器 )
|
||||||
|
/// </summary>
|
||||||
|
public int EditorMode { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 文档内容
|
||||||
|
/// </summary>
|
||||||
|
[Column(DbType = "text")]
|
||||||
|
public string DocContent { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查看次数
|
||||||
|
/// </summary>
|
||||||
|
public int WatchCount { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Star统计
|
||||||
|
/// </summary>
|
||||||
|
public int StarCount { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 修改时间
|
||||||
|
/// </summary>
|
||||||
|
public DateTime? UpdateDt { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 修改人
|
||||||
|
/// </summary>
|
||||||
|
public string UpdateBy { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 返回实体内容
|
||||||
|
/// </summary>
|
||||||
|
public class DocumentContentView : DocumentContent
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
45
Examples/website/FreeSql.Site.Entity/DocumentType.cs
Normal file
45
Examples/website/FreeSql.Site.Entity/DocumentType.cs
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
//using FreeSql.DataAnnotations;
|
||||||
|
using FreeSql.DataAnnotations;
|
||||||
|
using FreeSql.Site.Entity.Common;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace FreeSql.Site.Entity
|
||||||
|
{
|
||||||
|
public class DocumentType : BaseEntity
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 类型名称
|
||||||
|
/// </summary>
|
||||||
|
public string TypeName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 上级类型名称
|
||||||
|
/// </summary>
|
||||||
|
public int? UpID { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 标签
|
||||||
|
/// </summary>
|
||||||
|
public string Tag { get; set; }
|
||||||
|
|
||||||
|
public DateTime? UpdateDt { get; set; }
|
||||||
|
|
||||||
|
public string UpdateBy { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 类型树形结构
|
||||||
|
/// </summary>
|
||||||
|
public class DocumentTypeTreeNode : TreeNode
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 标签
|
||||||
|
/// </summary>
|
||||||
|
public string tag { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 创建时间
|
||||||
|
/// </summary>
|
||||||
|
public DateTime? createdt { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>netcoreapp2.2</TargetFramework>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\..\..\FreeSql\FreeSql.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
59
Examples/website/FreeSql.Site.Entity/TemplateExample.cs
Normal file
59
Examples/website/FreeSql.Site.Entity/TemplateExample.cs
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
using FreeSql.DataAnnotations;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace FreeSql.Site.Entity
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 模板示例
|
||||||
|
/// </summary>
|
||||||
|
public class TemplateExample : BaseEntity
|
||||||
|
{
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 模板图片
|
||||||
|
/// </summary>
|
||||||
|
public string TemplateImg { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 模板名称
|
||||||
|
/// </summary>
|
||||||
|
public string TempateName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 描述
|
||||||
|
/// </summary>
|
||||||
|
public string Describe { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 模板路径
|
||||||
|
/// </summary>
|
||||||
|
public string TemplatePath { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查看次数
|
||||||
|
/// </summary>
|
||||||
|
public int WatchCount { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 下载统计
|
||||||
|
/// </summary>
|
||||||
|
public int DownloadCount { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Star统计
|
||||||
|
/// </summary>
|
||||||
|
public int StarCount { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 修改时间
|
||||||
|
/// </summary>
|
||||||
|
public DateTime? UpdateDt { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 修改人
|
||||||
|
/// </summary>
|
||||||
|
public string UpdateBy { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace FreeSql.Site.UI.Admin.Common
|
||||||
|
{
|
||||||
|
public class AdminBaseController : Controller
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using FreeSql.Site.Entity;
|
||||||
|
using FreeSql.Site.UI.Admin.Common;
|
||||||
|
using FreeSql.Site.UI.Areas.BBS.Models;
|
||||||
|
using FreeSql.Site.UI.Controllers;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace FreeSql.Site.UI.Areas.Admin.Controllers
|
||||||
|
{
|
||||||
|
[Area("Admin")]
|
||||||
|
public class BBSController : AdminBaseController
|
||||||
|
{
|
||||||
|
public IActionResult Index()
|
||||||
|
{
|
||||||
|
DocumentContent model = new DocumentContent();
|
||||||
|
return View(model);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,254 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using FreeSql.Site.DAL;
|
||||||
|
using FreeSql.Site.Entity;
|
||||||
|
using FreeSql.Site.Entity.Common;
|
||||||
|
using FreeSql.Site.UI.Admin.Common;
|
||||||
|
using FreeSql.Site.UI.Areas.BBS.Models;
|
||||||
|
using FreeSql.Site.UI.Common;
|
||||||
|
using FreeSql.Site.UI.Controllers;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||||
|
|
||||||
|
namespace FreeSql.Site.UI.Areas.Admin.Controllers
|
||||||
|
{
|
||||||
|
[Area("Admin")]
|
||||||
|
public class DocumentController : AdminBaseController
|
||||||
|
{
|
||||||
|
public DocumentTypeDAL DocumentTypeDAL { get; set; }
|
||||||
|
|
||||||
|
public DocumentContentDAL DocumentContentDAL { get; set; }
|
||||||
|
|
||||||
|
public DocumentController()
|
||||||
|
{
|
||||||
|
this.DocumentTypeDAL = new DocumentTypeDAL();
|
||||||
|
this.DocumentContentDAL = new DocumentContentDAL();
|
||||||
|
}
|
||||||
|
|
||||||
|
public IActionResult Index()
|
||||||
|
{
|
||||||
|
DocumentContent model = new DocumentContent();
|
||||||
|
return View(model);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region 文档内容
|
||||||
|
public IActionResult DocContent()
|
||||||
|
{
|
||||||
|
DocumentContent model = new DocumentContent();
|
||||||
|
return View(model);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public IActionResult DocContentList(string searchContent, string seniorQueryJson, int page = 1, int limit = 10)
|
||||||
|
{
|
||||||
|
DocumentContent model = null;
|
||||||
|
if (!string.IsNullOrWhiteSpace(seniorQueryJson))
|
||||||
|
{
|
||||||
|
model = Newtonsoft.Json.JsonConvert.DeserializeObject<DocumentContent>(seniorQueryJson);
|
||||||
|
}
|
||||||
|
Expression<Func<DocumentContent, bool>> predicate = i => 1 == 0;
|
||||||
|
var searchPredicate = PredicateExtensions.True<DocumentContent>();
|
||||||
|
if (model != null)
|
||||||
|
{
|
||||||
|
if (model.TypeID >= 0)
|
||||||
|
searchPredicate = searchPredicate.And(u => u.TypeID == model.TypeID);
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(model.DocTitle))
|
||||||
|
searchPredicate = searchPredicate.And(u => u.DocTitle.IndexOf(model.DocTitle) != -1);
|
||||||
|
}
|
||||||
|
PageInfo pageinfo = new PageInfo() { IsPaging = true, PageIndex = page, PageSize = limit };
|
||||||
|
var contents = DocumentContentDAL.Query(searchPredicate, null, pageinfo);
|
||||||
|
|
||||||
|
return Json(new DataPage<DocumentContent>
|
||||||
|
{
|
||||||
|
code = "0",
|
||||||
|
msg = "",
|
||||||
|
count = contents.count,
|
||||||
|
data = contents.list
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public ActionResult DocContentEditModule(string id)
|
||||||
|
{
|
||||||
|
ViewBag.DocumentTypeList = DocumentTypeDAL.Query(w => w.Status == 1).list.Select(s => new SelectListItem { Text = s.TypeName, Value = s.ID.ToString() }).ToList();
|
||||||
|
DocumentContent model = new DocumentContent() { OriginType = 0};
|
||||||
|
if (!string.IsNullOrEmpty(id) && id != "0")
|
||||||
|
{
|
||||||
|
int _id = Convert.ToInt32(id);
|
||||||
|
model = DocumentContentDAL.GetByOne(w => w.ID == _id);
|
||||||
|
}
|
||||||
|
return View(model);
|
||||||
|
}
|
||||||
|
|
||||||
|
// POST: Documents/Create
|
||||||
|
[HttpPost]
|
||||||
|
//[ValidateAntiForgeryToken]
|
||||||
|
public ActionResult DocContentCreate([FromBody]DocumentContent model)
|
||||||
|
{
|
||||||
|
var resdata = AutoException.Excute<long>((result) =>
|
||||||
|
{
|
||||||
|
result.Data = DocumentContentDAL.Insert(model);
|
||||||
|
if (result.Data == 0)
|
||||||
|
{
|
||||||
|
throw new Exception("数据新增异常,JSON:" + Newtonsoft.Json.JsonConvert.SerializeObject(model));
|
||||||
|
}
|
||||||
|
}, false);
|
||||||
|
return Json(resdata);
|
||||||
|
}
|
||||||
|
|
||||||
|
// POST: Documents/Create
|
||||||
|
[HttpPost]
|
||||||
|
//[ValidateAntiForgeryToken]
|
||||||
|
public ActionResult DocContentUpdate([FromBody]DocumentContent model)
|
||||||
|
{
|
||||||
|
var resdata = AutoException.Excute<bool>((result) =>
|
||||||
|
{
|
||||||
|
model.UpdateBy = "admin";
|
||||||
|
model.UpdateDt = DateTime.Now;
|
||||||
|
result.Data = DocumentContentDAL.Update(model);
|
||||||
|
if (result.Data == false)
|
||||||
|
{
|
||||||
|
throw new Exception("数据新增异常,JSON:" + Newtonsoft.Json.JsonConvert.SerializeObject(model));
|
||||||
|
}
|
||||||
|
}, false);
|
||||||
|
return Json(resdata);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
//[ValidateAntiForgeryToken]
|
||||||
|
public ActionResult DocContentDelete(int id, IFormCollection collection)
|
||||||
|
{
|
||||||
|
var resdata = AutoException.Excute<long>((result) =>
|
||||||
|
{
|
||||||
|
if (!DocumentContentDAL.Delete(id))
|
||||||
|
{
|
||||||
|
throw new Exception("数据删除异常,ID:" + id);
|
||||||
|
}
|
||||||
|
}, false);
|
||||||
|
return Json(resdata);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 文档分类
|
||||||
|
public IActionResult DocType()
|
||||||
|
{
|
||||||
|
DocumentType model = new DocumentType();
|
||||||
|
|
||||||
|
ViewBag.TypeList = DocumentTypeDAL.Query(w => w.Status == 1).list.Select(s => new DocumentTypeTreeNode
|
||||||
|
{
|
||||||
|
id = s.ID.ToString(),
|
||||||
|
pid = (s.UpID ?? 0).ToString(),
|
||||||
|
title = s.TypeName,
|
||||||
|
tag = s.Tag,
|
||||||
|
createdt = s.CreateDt
|
||||||
|
}).ToList();
|
||||||
|
|
||||||
|
return View(model);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public IActionResult DocTypeList(string searchContent, string seniorQueryJson, int page = 1, int limit = 10)
|
||||||
|
{
|
||||||
|
DocumentType model = null;
|
||||||
|
if (!string.IsNullOrWhiteSpace(seniorQueryJson))
|
||||||
|
{
|
||||||
|
model = Newtonsoft.Json.JsonConvert.DeserializeObject<DocumentType>(seniorQueryJson);
|
||||||
|
}
|
||||||
|
Expression<Func<DocumentType, bool>> predicate = i => 1 == 0;
|
||||||
|
var searchPredicate = PredicateExtensions.True<DocumentType>();
|
||||||
|
if (model != null)
|
||||||
|
{
|
||||||
|
searchPredicate = searchPredicate.And(u => u.Status == 1);
|
||||||
|
}
|
||||||
|
var contents = DocumentTypeDAL.Query(searchPredicate);
|
||||||
|
|
||||||
|
return Json(new DataPage<DocumentType>
|
||||||
|
{
|
||||||
|
code = "0",
|
||||||
|
msg = "",
|
||||||
|
count = contents.count,
|
||||||
|
data = contents.list
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public ActionResult DocTypeEditModule(string id, bool ischildren)
|
||||||
|
{
|
||||||
|
ViewBag.DocumentTypeList = DocumentTypeDAL.Query(w => w.Status == 1).list.Select(s => new SelectListItem { Text = s.TypeName, Value = s.ID.ToString() }).ToList();
|
||||||
|
|
||||||
|
DocumentType model = new DocumentType();
|
||||||
|
if (ischildren)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(id))
|
||||||
|
{
|
||||||
|
model.UpID = Convert.ToInt32(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(id))
|
||||||
|
{
|
||||||
|
int _id = Convert.ToInt32(id);
|
||||||
|
model = DocumentTypeDAL.GetByOne(w => w.ID == _id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return View(model);
|
||||||
|
}
|
||||||
|
|
||||||
|
// POST: Documents/Create
|
||||||
|
[HttpPost]
|
||||||
|
//[ValidateAntiForgeryToken]
|
||||||
|
public ActionResult DocTypeCreate([FromBody]DocumentType model)
|
||||||
|
{
|
||||||
|
var resdata = AutoException.Excute<long>((result) =>
|
||||||
|
{
|
||||||
|
model.CreateBy = "admin";
|
||||||
|
model.CreateDt = DateTime.Now;
|
||||||
|
result.Data = DocumentTypeDAL.Insert(model);
|
||||||
|
if (result.Data == 0)
|
||||||
|
{
|
||||||
|
throw new Exception("数据新增异常,JSON:" + Newtonsoft.Json.JsonConvert.SerializeObject(model));
|
||||||
|
}
|
||||||
|
}, false);
|
||||||
|
return Json(resdata);
|
||||||
|
}
|
||||||
|
|
||||||
|
// POST: Documents/Create
|
||||||
|
[HttpPost]
|
||||||
|
//[ValidateAntiForgeryToken]
|
||||||
|
public ActionResult DocTypeUpdate([FromBody]DocumentType model)
|
||||||
|
{
|
||||||
|
var resdata = AutoException.Excute<bool>((result) =>
|
||||||
|
{
|
||||||
|
model.UpdateBy = "admin";
|
||||||
|
model.UpdateDt = DateTime.Now;
|
||||||
|
result.Data = DocumentTypeDAL.Update(model);
|
||||||
|
if (result.Data == false)
|
||||||
|
{
|
||||||
|
throw new Exception("数据新增异常,JSON:" + Newtonsoft.Json.JsonConvert.SerializeObject(model));
|
||||||
|
}
|
||||||
|
}, false);
|
||||||
|
return Json(resdata);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
//[ValidateAntiForgeryToken]
|
||||||
|
public ActionResult DocTypeDelete(int id, IFormCollection collection)
|
||||||
|
{
|
||||||
|
var resdata = AutoException.Excute<long>((result) =>
|
||||||
|
{
|
||||||
|
if (!DocumentTypeDAL.Delete(id))
|
||||||
|
{
|
||||||
|
throw new Exception("数据删除异常,ID:" + id);
|
||||||
|
}
|
||||||
|
}, false);
|
||||||
|
return Json(resdata);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using FreeSql.Site.Entity;
|
||||||
|
using FreeSql.Site.UI.Admin.Common;
|
||||||
|
using FreeSql.Site.UI.Areas.BBS.Models;
|
||||||
|
using FreeSql.Site.UI.Controllers;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace FreeSql.Site.UI.Areas.Admin.Controllers
|
||||||
|
{
|
||||||
|
[Area("Admin")]
|
||||||
|
public class SystemController : AdminBaseController
|
||||||
|
{
|
||||||
|
public IActionResult Setting()
|
||||||
|
{
|
||||||
|
DocumentContent model = new DocumentContent();
|
||||||
|
return View(model);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using FreeSql.Site.Entity;
|
||||||
|
using FreeSql.Site.UI.Admin.Common;
|
||||||
|
using FreeSql.Site.UI.Areas.BBS.Models;
|
||||||
|
using FreeSql.Site.UI.Controllers;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace FreeSql.Site.UI.Areas.Admin.Controllers
|
||||||
|
{
|
||||||
|
[Area("Admin")]
|
||||||
|
public class TemplateController : AdminBaseController
|
||||||
|
{
|
||||||
|
public IActionResult Index()
|
||||||
|
{
|
||||||
|
DocumentContent model = new DocumentContent();
|
||||||
|
return View(model);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FreeSql.Site.UI.Areas.Admin.Models
|
||||||
|
{
|
||||||
|
public class DocumentContentModel
|
||||||
|
{
|
||||||
|
public int OrderBy { get; set; }
|
||||||
|
|
||||||
|
public int ContentID { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FreeSql.Site.UI.Areas.Admin.Models
|
||||||
|
{
|
||||||
|
public class DocumentTypeModel
|
||||||
|
{
|
||||||
|
public int OrderBy { get; set; }
|
||||||
|
|
||||||
|
public int ContentID { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,95 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
<title>@ViewData["Title"]</title>
|
||||||
|
|
||||||
|
<environment include="Development">
|
||||||
|
<link href="~/layui/css/layui.css" rel="stylesheet" />
|
||||||
|
<link href="~/layui/lay/modules/preview.css" rel="stylesheet" />
|
||||||
|
<link href="~/css/admin.css" rel="stylesheet" />
|
||||||
|
<script src="~/lib/jquery/dist/jquery.js"></script>
|
||||||
|
<script src="~/js/common.js"></script>
|
||||||
|
|
||||||
|
<!-- 页面markdown解析成HTML需要的js -->
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
|
||||||
|
<script src="https://cdn.bootcss.com/highlight.js/9.13.1/highlight.min.js"></script>
|
||||||
|
<script src="~/layui/lay/modules/layer.js"></script>
|
||||||
|
<script src="~/layui/layui.js"></script>
|
||||||
|
</environment>
|
||||||
|
<environment exclude="Development">
|
||||||
|
<link rel="stylesheet" href="https://ajax.aspnetcdn.com/ajax/bootstrap/3.3.7/css/bootstrap.min.css"
|
||||||
|
asp-fallback-href="~/lib/bootstrap/dist/css/bootstrap.min.css"
|
||||||
|
asp-fallback-test-class="sr-only" asp-fallback-test-property="position" asp-fallback-test-value="absolute" />
|
||||||
|
</environment>
|
||||||
|
</head>
|
||||||
|
<body class="layui-layout-body" id="LAY_home" style="background-color: #fff;" data-date="12-27">
|
||||||
|
<div class="layui-layout layui-layout-admin">
|
||||||
|
<div class="layui-header">
|
||||||
|
<div class="layui-logo"><span style="font-size:25px; letter-spacing:1px; color:#fff;">FreeSql</span></div>
|
||||||
|
<!-- 头部区域(可配合layui已有的水平导航) -->
|
||||||
|
<ul class="layui-nav layui-layout-left">
|
||||||
|
<li class="layui-nav-item active"><a href="/Admin/Document" target="_self">文档管理</a></li>
|
||||||
|
<li class="layui-nav-item"><a href="/Admin/BBS" target="_self">论坛管理</a></li>
|
||||||
|
<li class="layui-nav-item"><a href="/Admin/Template" target="_self">模板管理</a></li>
|
||||||
|
</ul>
|
||||||
|
<ul class="layui-nav layui-layout-right">
|
||||||
|
<li class="layui-nav-item">
|
||||||
|
<a href="javascript:;">
|
||||||
|
<img src="#" class="layui-nav-img">
|
||||||
|
FreeSql
|
||||||
|
</a>
|
||||||
|
<dl class="layui-nav-child">
|
||||||
|
<dd><a href="">基本资料</a></dd>
|
||||||
|
<dd><a href="">安全设置</a></dd>
|
||||||
|
</dl>
|
||||||
|
</li>
|
||||||
|
<li class="layui-nav-item"><a href="">退出</a></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<partial name="_CookieConsentPartial" />
|
||||||
|
@RenderBody()
|
||||||
|
|
||||||
|
<div class="layui-footer footer">
|
||||||
|
<!-- 底部固定区域 -->
|
||||||
|
© FreeSql.com - 底部固定区域
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<environment include="Development">
|
||||||
|
@*<script src="~/js/site.js" asp-append-version="true"></script>*@
|
||||||
|
<script>
|
||||||
|
layui.config({
|
||||||
|
base: '/layui/lay/modules/'
|
||||||
|
, version: '31111'
|
||||||
|
}).use('global');
|
||||||
|
|
||||||
|
window.global = {
|
||||||
|
preview: function () {
|
||||||
|
var preview = document.getElementById('LAY_preview');
|
||||||
|
return preview ? preview.innerHTML : '';
|
||||||
|
}()
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
</environment>
|
||||||
|
<environment exclude="Development">
|
||||||
|
<script src="https://ajax.aspnetcdn.com/ajax/jquery/jquery-3.3.1.min.js"
|
||||||
|
asp-fallback-src="~/lib/jquery/dist/jquery.min.js"
|
||||||
|
asp-fallback-test="window.jQuery"
|
||||||
|
crossorigin="anonymous"
|
||||||
|
integrity="sha384-tsQFqpEReu7ZLhBV2VZlAu7zcOV+rXbYlF2cqB8txI/8aZajjp4Bqd+V6D5IgvKT">
|
||||||
|
</script>
|
||||||
|
<script src="https://ajax.aspnetcdn.com/ajax/bootstrap/3.3.7/bootstrap.min.js"
|
||||||
|
asp-fallback-src="~/lib/bootstrap/dist/js/bootstrap.min.js"
|
||||||
|
asp-fallback-test="window.jQuery && window.jQuery.fn && window.jQuery.fn.modal"
|
||||||
|
crossorigin="anonymous"
|
||||||
|
integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa">
|
||||||
|
</script>
|
||||||
|
<script src="~/js/site.min.js" asp-append-version="true"></script>
|
||||||
|
</environment>
|
||||||
|
|
||||||
|
@RenderSection("Scripts", required: false)
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -0,0 +1,61 @@
|
|||||||
|
@{
|
||||||
|
ViewBag.Title = "";
|
||||||
|
Layout = "~/Areas/Admin/Shared/_Layout.cshtml";
|
||||||
|
}
|
||||||
|
<div class="layui-side layui-bg-black">
|
||||||
|
<div class="layui-side-scroll">
|
||||||
|
<!-- 左侧导航区域(可配合layui已有的垂直导航) -->
|
||||||
|
<ul class="layui-nav layui-nav-tree" lay-filter="test">
|
||||||
|
<li class="layui-nav-item layui-nav-itemed">
|
||||||
|
<a class="" href="javascript:;">论坛管理</a>
|
||||||
|
<dl class="layui-nav-child menu-item">
|
||||||
|
<dd><a href="javascript:void(0);" datajson="{}" path="/Admin/BBS/Index">论坛文章</a></dd>
|
||||||
|
<dd><a href="javascript:void(0);" datajson="{}" path="/Admin/BBS/Index">论坛标签</a></dd>
|
||||||
|
<dd><a href="javascript:void(0);" datajson="{}" path="/Admin/BBS/Index">论坛内容分析</a></dd>
|
||||||
|
<dd><a href="/BBS/BBS/Index" target="_blank">查看论坛</a></dd>
|
||||||
|
</dl>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="layui-body">
|
||||||
|
<!-- 内容主体区域 -->
|
||||||
|
<div style="padding: 15px;" id="page_content">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
var showLoading = function (obj) {
|
||||||
|
|
||||||
|
var index = layer.msg(obj.msg, {
|
||||||
|
icon: 16,
|
||||||
|
shade: 0.1,
|
||||||
|
shadeClose: false,
|
||||||
|
});
|
||||||
|
return index;
|
||||||
|
};
|
||||||
|
|
||||||
|
var closeLoading = function (index) {
|
||||||
|
layer.close(index);
|
||||||
|
};
|
||||||
|
|
||||||
|
$(".menu-item>dd>a").click(function () {
|
||||||
|
var path_item = $(this).attr("path");
|
||||||
|
var path_json = $(this).attr("datajson");
|
||||||
|
|
||||||
|
var index = showLoading({ msg: "数据加载中......" });
|
||||||
|
$("#page_content").load(path_item, $.parseJSON(path_json), function () {
|
||||||
|
//初始化绑定页面的时间,例如时间控件
|
||||||
|
closeLoading(index);
|
||||||
|
index = -1;
|
||||||
|
});
|
||||||
|
|
||||||
|
//如果出现长时间未关闭,定时关闭loading
|
||||||
|
setTimeout(function () {
|
||||||
|
if (index >= 0) closeLoading(index);
|
||||||
|
}, 5000);
|
||||||
|
});
|
||||||
|
|
||||||
|
</script>
|
@ -0,0 +1,225 @@
|
|||||||
|
|
||||||
|
@{
|
||||||
|
ViewBag.Title = ".NET文档园 .NET开源ORM - 首页";
|
||||||
|
}
|
||||||
|
@using FreeSql.Site.UI.Areas.BBS.Models;
|
||||||
|
<script>
|
||||||
|
var dialog_Paramters = { height: 660, width: 1100 };
|
||||||
|
</script>
|
||||||
|
<style>
|
||||||
|
.layui-table, .layui-table-view {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<table class="layui-table" id="test" lay-filter="test"></table>
|
||||||
|
|
||||||
|
<script type="text/html" id="docContentEdit">
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script type="text/html" id="toolbarDemo">
|
||||||
|
<div class="layui-btn-container">
|
||||||
|
<button class="layui-btn layui-btn-sm" lay-event="add">添加</button>
|
||||||
|
@*<button class="layui-btn layui-btn-sm" lay-event="delete">删除</button>
|
||||||
|
<button class="layui-btn layui-btn-sm" lay-event="update">编辑</button>*@
|
||||||
|
<div style="float:right;border:0px solid red;">
|
||||||
|
<input type="text" name="search_txt" lay-verify="title" autocomplete="off" placeholder="标题" class="layui-input" style="height: 30px;width:160px;float:left;">
|
||||||
|
<a href="#" style="line-height:30px;margin-left:8px;">高级查询</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script type="text/html" id="barDemo">
|
||||||
|
<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
|
||||||
|
<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
var contentEdit;
|
||||||
|
layui.use(['layer', 'laymd', 'form', 'table'], function () {
|
||||||
|
var table = layui.table;
|
||||||
|
var form = layui.form
|
||||||
|
, layer = layui.layer, laymd = layui.laymd;
|
||||||
|
|
||||||
|
var loadMarkDown = function () {
|
||||||
|
//实例化编辑器,可以多个实例
|
||||||
|
var md = laymd.init('DocContent', {});
|
||||||
|
//内容改变事件
|
||||||
|
md.on('change', function () {
|
||||||
|
//这里借用marked.js解析效率比HyperDown快,用户可自行找解析器
|
||||||
|
this.setPreview(marked(this.getText()));
|
||||||
|
});
|
||||||
|
//初始化数据预览
|
||||||
|
md.do('change');
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
table.render({
|
||||||
|
elem: '#test'
|
||||||
|
, url: '/Admin/Document/DocContentList'
|
||||||
|
, where: { searchContent: '', seniorQueryJson: "" }
|
||||||
|
, toolbar: '#toolbarDemo'
|
||||||
|
, title: '文档列表'
|
||||||
|
, cols: [[
|
||||||
|
{ type: 'checkbox', fixed: 'left' }
|
||||||
|
, { field: 'ID', title: 'ID', width: 80, fixed: 'left', unresize: true, sort: true }
|
||||||
|
, { field: 'DocTitle', title: '标题', edit: 'text' }
|
||||||
|
, { field: 'Status', title: '状态', width: 80, edit: 'text', sort: true }
|
||||||
|
, { field: 'WatchCount', title: '阅读量市', width: 100 }
|
||||||
|
, { field: 'StarCount', title: '获赞数', width: 100 }
|
||||||
|
, { field: 'CreateDt', title: '创建时间', width: 160, sort: true }
|
||||||
|
, { field: 'UpdateDt', title: '修改时间', width: 160 }
|
||||||
|
, { fixed: 'right', title: '操作', toolbar: '#barDemo', width: 150 }
|
||||||
|
]]
|
||||||
|
, page: true
|
||||||
|
, id: 'docContentTable'
|
||||||
|
});
|
||||||
|
|
||||||
|
var reloadTable = function () {
|
||||||
|
//执行重载
|
||||||
|
table.reload('docContentTable', {
|
||||||
|
page: {
|
||||||
|
curr: 1 //重新从第 1 页开始
|
||||||
|
}, where: { searchContent: $("input[type=search_txt]").val(), seniorQueryJson: "" }
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
var deleteObj = function (removeRowDatas) {
|
||||||
|
layer.confirm('确定要删除吗?', function (index) {
|
||||||
|
//调用删除
|
||||||
|
$.ajax({
|
||||||
|
type: "POST",
|
||||||
|
url: "/Admin/Document/DocContentDelete",
|
||||||
|
data: { id: rowid },
|
||||||
|
dataType: "html",
|
||||||
|
success: function (data) {
|
||||||
|
obj.del();
|
||||||
|
layer.close(index);
|
||||||
|
},
|
||||||
|
error: function () {
|
||||||
|
layer.close(index);
|
||||||
|
layer.alert("删除失败!");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
//监听事件
|
||||||
|
table.on('toolbar(test)', function (obj) {
|
||||||
|
var checkStatus = table.checkStatus(obj.config.id);
|
||||||
|
switch (obj.event) {
|
||||||
|
case 'add':
|
||||||
|
var options = {
|
||||||
|
url: "/Admin/Document/DocContentEditModule", paramters: { id: "0" },
|
||||||
|
title: "新增文档",
|
||||||
|
area: ['1100px', '660px'],
|
||||||
|
submit: {
|
||||||
|
url: "/Admin/Document/DocContentCreate",
|
||||||
|
},
|
||||||
|
elmid: "docContentEdit",
|
||||||
|
callback: reloadTable,
|
||||||
|
loadBefore: function () {
|
||||||
|
//监听指定开关
|
||||||
|
form.on('switch(switchTest)', function (data) {
|
||||||
|
if (this.checked) {
|
||||||
|
$("#OriginUrlArea").hide();
|
||||||
|
$("#DocContentArea").show();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$("#OriginUrlArea").show();
|
||||||
|
$("#DocContentArea").hide();
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
//contentEdit = editormd("md_DocContent", {
|
||||||
|
// width: "96%",
|
||||||
|
// height: 640,
|
||||||
|
// syncScrolling: "single",
|
||||||
|
// path: "../../lib/editormd/lib/"
|
||||||
|
//});
|
||||||
|
loadMarkDown();
|
||||||
|
},
|
||||||
|
submitBefore: function (data) {
|
||||||
|
data.field.OriginType = data.field.OriginType == "on" ? 1 : 0;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
freejs.dialogWindow.create(options, form);
|
||||||
|
break;
|
||||||
|
case 'delete':
|
||||||
|
var data = checkStatus.data;
|
||||||
|
deleteObj(data);
|
||||||
|
break;
|
||||||
|
case 'update':
|
||||||
|
layer.msg('编辑');
|
||||||
|
break;
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
//监听行工具事件
|
||||||
|
table.on('tool(test)', function (obj) {
|
||||||
|
var data = obj.data;
|
||||||
|
if (obj.event === 'del') {
|
||||||
|
deleteObj(obj.data);
|
||||||
|
layer.confirm('确定要删除吗?', function (index) {
|
||||||
|
//调用删除
|
||||||
|
$.ajax({
|
||||||
|
type: "POST",
|
||||||
|
url: "/Admin/Document/DocContentDelete",
|
||||||
|
data: { id: data.ID },
|
||||||
|
dataType: "html",
|
||||||
|
success: function (data) {
|
||||||
|
obj.del();
|
||||||
|
layer.close(index);
|
||||||
|
},
|
||||||
|
error: function () {
|
||||||
|
layer.close(index);
|
||||||
|
layer.alert("删除失败!");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
} else if (obj.event === 'edit') {
|
||||||
|
var options = {
|
||||||
|
url: "/Admin/Document/DocContentEditModule", paramters: { id: data.ID },
|
||||||
|
title: "编辑文档",
|
||||||
|
area: ['1100px', '660px'],
|
||||||
|
submit: {
|
||||||
|
url: "/Admin/Document/DocContentUpdate",
|
||||||
|
},
|
||||||
|
elmid: "docContentEdit",
|
||||||
|
callback: reloadTable,
|
||||||
|
loadBefore: function () {
|
||||||
|
//监听指定开关
|
||||||
|
form.on('switch(switchTest)', function (data) {
|
||||||
|
if (this.checked) {
|
||||||
|
$("#OriginUrlArea").hide();
|
||||||
|
$("#DocContentArea").show();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$("#OriginUrlArea").show();
|
||||||
|
$("#DocContentArea").hide();
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
//contentEdit = editormd("md_DocContent", {
|
||||||
|
// width: "96%",
|
||||||
|
// height: 640,
|
||||||
|
// syncScrolling: "single",
|
||||||
|
// path: "../../lib/editormd/lib/"
|
||||||
|
//});
|
||||||
|
loadMarkDown();
|
||||||
|
},
|
||||||
|
submitBefore: function (data) {
|
||||||
|
var _origintype = $(".layui-tab-title").find('.layui-this').attr("origintype");
|
||||||
|
data.field.OriginType = _origintype;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
freejs.dialogWindow.create(options, form);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$(document).on('click', '#btnSubmit', function () {
|
||||||
|
layer.msg('响应点击事件');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
@ -0,0 +1,82 @@
|
|||||||
|
@using FreeSql.Site.Entity;
|
||||||
|
@model FreeSql.Site.Entity.DocumentContent
|
||||||
|
|
||||||
|
<form class="layui-form" action="" id="frm_DocContentEdit">
|
||||||
|
<div class="form-module-content">
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">文章分类 </label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
@Html.HiddenFor(m => m.ID)
|
||||||
|
@Html.HiddenFor(m => m.OriginType)
|
||||||
|
@Html.HiddenFor(m => m.WatchCount)
|
||||||
|
@Html.HiddenFor(m => m.StarCount)
|
||||||
|
@Html.HiddenFor(m => m.CreateBy)
|
||||||
|
@Html.HiddenFor(m => m.CreateDt)
|
||||||
|
@Html.DropDownList("TypeID", ViewBag.DocumentTypeList as List<SelectListItem>, "", new Dictionary<string, object> { { "class", "plate_text" } })
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">文章标题</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
@Html.TextBoxFor(m => m.DocTitle, "", new Dictionary<string, object> { { "autocomplete", "off" }, { "class", "layui-input " }, { "lay-verify", "title" }, { "placeholder", "请输入标题" } })
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">摘要</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
@Html.TextBoxFor(m => m.DocAbstract, "", new Dictionary<string, object> { { "autocomplete", "off" }, { "class", "layui-input " }, { "lay-verify", "title" }, { "placeholder", "请输入摘要" } })
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@*<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">文章分类</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input type="checkbox" name="like[write]" title="写作">
|
||||||
|
<input type="checkbox" name="like[read]" title="阅读">
|
||||||
|
<input type="checkbox" name="like[daze]" title="发呆">
|
||||||
|
</div>
|
||||||
|
</div>*@
|
||||||
|
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">状态</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input type="radio" name="status" value="1" title="启用" checked="">
|
||||||
|
<input type="radio" name="status" value="0" title="关闭">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@*<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">来源类型</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input type="checkbox" id="OriginType" @(Model.OriginType == 1 ? "checked=''" : "") name="OriginType" lay-skin="switch" lay-filter="switchTest" lay-text="当前内容|URL地址">
|
||||||
|
</div>
|
||||||
|
</div>*@
|
||||||
|
|
||||||
|
<div class="layui-tab">
|
||||||
|
<ul class="layui-tab-title">
|
||||||
|
<li class=' @(Model.OriginType == 1 ? "" : "layui-this")' origintype="0">自有内容</li>
|
||||||
|
<li class=' @(Model.OriginType == 1 ? "layui-this" : "")' origintype="1">外部来源</li>
|
||||||
|
</ul>
|
||||||
|
<div class="layui-tab-content">
|
||||||
|
<div class='layui-tab-item @(Model.OriginType == 1 ? "" : "layui-show")'>
|
||||||
|
<div class="layui-form-item layui-form-text" id="DocContentArea">
|
||||||
|
<div id="DocContent">@Model.DocContent</div>
|
||||||
|
@*@Html.TextAreaFor(m => m.DocContent, new Dictionary<string, object> { { "autocomplete", "off" }, { "placeholder", "请输入内容" } })*@
|
||||||
|
@*<textarea style="display:none;" placeholder="请输入内容" name="DocContent"></textarea>*@
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class='layui-tab-item @(Model.OriginType == 1 ? "layui-show" : "")'>
|
||||||
|
<div class="layui-form-item" id="OriginUrlArea">
|
||||||
|
<label class="layui-form-label">外部来源</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
@Html.TextBoxFor(m => m.OriginUrl, "", new Dictionary<string, object> { { "autocomplete", "off" }, { "class", "layui-input " }, { "lay-verify", "title" }, { "placeholder", "请输入标题" } })
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@*<div class="form-module-footer">
|
||||||
|
<button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
|
||||||
|
</div>*@
|
||||||
|
</form>
|
@ -0,0 +1,163 @@
|
|||||||
|
@{
|
||||||
|
ViewBag.Title = "";
|
||||||
|
|
||||||
|
//Layout = "~/Areas/Admin/Shared/_Layout.cshtml";
|
||||||
|
}
|
||||||
|
<style>
|
||||||
|
.hide {
|
||||||
|
display: none
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<script>
|
||||||
|
var dialog_Paramters = { height: 460, width: 600 };
|
||||||
|
</script>
|
||||||
|
<button class="layui-btn layui-btn-sm down-up-all" expandStatus="down">全部收起/展开</button>
|
||||||
|
<button class="layui-btn layui-btn-sm get-checked">获取选中</button>
|
||||||
|
|
||||||
|
<table class="layui-table layui-form" id="doctype-tree-table"></table>
|
||||||
|
|
||||||
|
<script type="text/html" id="docTypeEdit">
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
layui.use(['treetable', 'form'], function () {
|
||||||
|
var data = @Html.Raw(Html.ToJson(ViewBag.TypeList as List<DocumentTypeTreeNode>));
|
||||||
|
|
||||||
|
var o = layui.$, treetable = layui.treetable;
|
||||||
|
var form = layui.form, layer = layui.layer;
|
||||||
|
var loadTreeTable = function () {
|
||||||
|
treetable.render({
|
||||||
|
elem: '#doctype-tree-table',
|
||||||
|
data: data,
|
||||||
|
field: 'title',
|
||||||
|
is_checkbox: true,
|
||||||
|
checked: [1, 2, 3, 4],
|
||||||
|
/*icon_val: {
|
||||||
|
open: "",
|
||||||
|
close: ""
|
||||||
|
},
|
||||||
|
space: 4,*/
|
||||||
|
cols: [
|
||||||
|
{
|
||||||
|
field: 'title',
|
||||||
|
title: '标题',
|
||||||
|
width: '45%',
|
||||||
|
template: function (item) {
|
||||||
|
if (item.level == 1) {
|
||||||
|
return '<span style="color:red;">' + item.title + '</span>';
|
||||||
|
}
|
||||||
|
if (item.level == 2) {
|
||||||
|
return '<span style="color:green;">' + item.title + '</span>';
|
||||||
|
}
|
||||||
|
return item.title;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '标签',
|
||||||
|
width: '10%',
|
||||||
|
template: function (item) {
|
||||||
|
return item.tag || "";//'<input type="checkbox" lay-skin="switch" lay-filter="status" lay-text="开启|关闭">';
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '创建时间',
|
||||||
|
width: '20%',
|
||||||
|
template: function (item) {
|
||||||
|
return (item.createdt || "").replace('T', ' ') || "";//'<input type="checkbox" lay-skin="switch" lay-filter="status" lay-text="开启|关闭">';
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'actions',
|
||||||
|
title: '操作',
|
||||||
|
width: '20%',
|
||||||
|
template: function (item) {
|
||||||
|
var tem = [];
|
||||||
|
tem.push('<button class="layui-btn layui-btn-xs layui-btn-normal" lay-filter="add">添加子级</button>');
|
||||||
|
tem.push('<button class="layui-btn layui-btn-xs" lay-filter="edit">编辑</button>');
|
||||||
|
tem.push('<button class="layui-btn layui-btn-xs" lay-filter="delete">删除</button>');
|
||||||
|
return tem.join(' ')
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
loadTreeTable();
|
||||||
|
|
||||||
|
var reloadTable = function () {
|
||||||
|
//执行重载
|
||||||
|
//loadTreeTable();
|
||||||
|
//layer.msg('树的刷新功能暂未实现');
|
||||||
|
var options = {
|
||||||
|
url: "/Admin/Document/DocType", paramters: {}
|
||||||
|
};
|
||||||
|
freejs.loadHtml(options);
|
||||||
|
};
|
||||||
|
|
||||||
|
treetable.on('treetable(add)', function (data) {
|
||||||
|
var options = {
|
||||||
|
url: "/Admin/Document/DocTypeEditModule", paramters: { id: data.item.id, ischildren: true },
|
||||||
|
title: "新增分类",
|
||||||
|
area: ['600px', '460px'],
|
||||||
|
submit: {
|
||||||
|
url: "/Admin/Document/DocTypeCreate",
|
||||||
|
},
|
||||||
|
elmid:"docTypeEdit",
|
||||||
|
callback: reloadTable
|
||||||
|
};
|
||||||
|
freejs.dialogWindow.create(options, form);
|
||||||
|
console.log(data);
|
||||||
|
})
|
||||||
|
|
||||||
|
treetable.on('treetable(edit)', function (data) {
|
||||||
|
layer.msg('编辑操作');
|
||||||
|
var options = {
|
||||||
|
url: "/Admin/Document/DocTypeEditModule", paramters: { id: data.item.id, ischildren: false },
|
||||||
|
title: "编辑分类",
|
||||||
|
area: ['600px', '460px'],
|
||||||
|
submit: {
|
||||||
|
url: "/Admin/Document/DocTypeUpdate",
|
||||||
|
},
|
||||||
|
elmid: "docTypeEdit",
|
||||||
|
callback: reloadTable
|
||||||
|
};
|
||||||
|
freejs.dialogWindow.create(options, form);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
treetable.on('treetable(delete)', function (data) {
|
||||||
|
layer.confirm('确定要删除吗?', function (index) {
|
||||||
|
//调用删除
|
||||||
|
$.ajax({
|
||||||
|
type: "POST",
|
||||||
|
url: "/Admin/Document/DocTypeDelete",
|
||||||
|
data: { id: data.item.id },
|
||||||
|
dataType: "html",
|
||||||
|
success: function (data) {
|
||||||
|
layer.close(index);
|
||||||
|
},
|
||||||
|
error: function () {
|
||||||
|
layer.close(index);
|
||||||
|
layer.alert("删除失败!");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
})
|
||||||
|
|
||||||
|
o('.down-up-all').click(function () {
|
||||||
|
var expandStatus = o(this).attr("expandStatus");
|
||||||
|
expandStatus == "down" ? treetable.all('up') : treetable.all('down');
|
||||||
|
expandStatus == "down" ? o(this).attr('expandStatus', 'up') : o(this).attr('expandStatus', 'down');
|
||||||
|
})
|
||||||
|
|
||||||
|
o('.get-checked').click(function () {
|
||||||
|
layer.alert(JSON.stringify(treetable.all('checked')));
|
||||||
|
})
|
||||||
|
|
||||||
|
form.on('switch(status)', function (data) {
|
||||||
|
layer.msg('监听状态操作');
|
||||||
|
console.log(data);
|
||||||
|
})
|
||||||
|
});
|
||||||
|
</script>
|
@ -0,0 +1,39 @@
|
|||||||
|
@using FreeSql.Site.Entity;
|
||||||
|
@model FreeSql.Site.Entity.DocumentType
|
||||||
|
|
||||||
|
<form class="layui-form" action="" id="frm_DocTypeEdit">
|
||||||
|
@Html.HiddenFor(m => m.ID)
|
||||||
|
@Html.HiddenFor(m => m.CreateBy)
|
||||||
|
@Html.HiddenFor(m => m.CreateDt)
|
||||||
|
<div class="form-module-content">
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">上级分类</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
@Html.DropDownList("UpID", ViewBag.DocumentTypeList as List<SelectListItem>, "", new Dictionary<string, object> { { "class", "plate_text" } })
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">分类名称</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
@Html.TextBoxFor(m => m.TypeName, "", new Dictionary<string, object> { { "autocomplete", "off" }, { "class", "layui-input " }, { "lay-verify", "title" }, { "placeholder", "请输入标题" } })
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">标签</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
@Html.TextBoxFor(m => m.Tag, "", new Dictionary<string, object> { { "autocomplete", "off" }, { "class", "layui-input " }, { "lay-verify", "title" }, { "placeholder", "请输入摘要" } })
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">状态</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input type="radio" name="status" value="1" title="启用" checked="">
|
||||||
|
<input type="radio" name="status" value="0" title="关闭">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@*<div class="form-module-footer">
|
||||||
|
<button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
|
||||||
|
</div>*@
|
||||||
|
</form>
|
@ -0,0 +1,45 @@
|
|||||||
|
@{
|
||||||
|
ViewData["Title"] = ".NETCore最方便的ORM";
|
||||||
|
Layout = "~/Areas/Admin/Shared/_Layout.cshtml";
|
||||||
|
}
|
||||||
|
<div class="layui-side layui-bg-black">
|
||||||
|
<div class="layui-side-scroll">
|
||||||
|
<!-- 左侧导航区域(可配合layui已有的垂直导航) -->
|
||||||
|
<ul class="layui-nav layui-nav-tree" lay-filter="test">
|
||||||
|
<li class="layui-nav-item layui-nav-itemed">
|
||||||
|
<a class="" href="javascript:;">文档管理</a>
|
||||||
|
<dl class="layui-nav-child menu-item">
|
||||||
|
<dd><a href="javascript:void(0);" datajson="{}" path="/Admin/Document/DocContent">文档内容</a></dd>
|
||||||
|
<dd><a href="javascript:void(0);" datajson="{}" path="/Admin/Document/DocType">文档分类</a></dd>
|
||||||
|
<dd><a href="/Doc/Documents/Index" target="_blank">查看文档</a></dd>
|
||||||
|
</dl>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="layui-body">
|
||||||
|
<!-- 内容主体区域 -->
|
||||||
|
<div style="padding: 15px;" id="page_content">
|
||||||
|
文档主页引导
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
$(".menu-item>dd>a").click(function () {
|
||||||
|
var path_item = $(this).attr("path");
|
||||||
|
var path_json = $(this).attr("datajson");
|
||||||
|
|
||||||
|
var index = freejs.showLoading({ msg: "数据加载中......" });
|
||||||
|
var options = {
|
||||||
|
url: path_item, paramters: $.parseJSON(path_json), loadIndex: index, elm: "page_content"
|
||||||
|
};
|
||||||
|
freejs.loadHtml(options);
|
||||||
|
|
||||||
|
//如果出现长时间未关闭,定时关闭loading
|
||||||
|
setTimeout(function () {
|
||||||
|
if (index >= 0) freejs.closeLoading(index);
|
||||||
|
}, 5000);
|
||||||
|
});
|
||||||
|
|
||||||
|
</script>
|
@ -0,0 +1,61 @@
|
|||||||
|
@{
|
||||||
|
ViewBag.Title = "";
|
||||||
|
Layout = "~/Areas/Admin/Shared/_Layout.cshtml";
|
||||||
|
}
|
||||||
|
<div class="layui-side layui-bg-black">
|
||||||
|
<div class="layui-side-scroll">
|
||||||
|
<!-- 左侧导航区域(可配合layui已有的垂直导航) -->
|
||||||
|
<ul class="layui-nav layui-nav-tree" lay-filter="test">
|
||||||
|
<li class="layui-nav-item layui-nav-itemed">
|
||||||
|
<a class="" href="javascript:;">系统设置</a>
|
||||||
|
<dl class="layui-nav-child menu-item">
|
||||||
|
<dd><a href="javascript:void(0);" datajson="{}" path="/Admin/BBS/Index">论坛文章</a></dd>
|
||||||
|
<dd><a href="javascript:void(0);" datajson="{}" path="/Admin/BBS/Index">论坛标签</a></dd>
|
||||||
|
<dd><a href="javascript:void(0);" datajson="{}" path="/Admin/BBS/Index">论坛内容分析</a></dd>
|
||||||
|
<dd><a href="/BBS/BBS/Index" target="_blank">查看论坛</a></dd>
|
||||||
|
</dl>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="layui-body">
|
||||||
|
<!-- 内容主体区域 -->
|
||||||
|
<div style="padding: 15px;" id="page_content">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
var showLoading = function (obj) {
|
||||||
|
|
||||||
|
var index = layer.msg(obj.msg, {
|
||||||
|
icon: 16,
|
||||||
|
shade: 0.1,
|
||||||
|
shadeClose: false,
|
||||||
|
});
|
||||||
|
return index;
|
||||||
|
};
|
||||||
|
|
||||||
|
var closeLoading = function (index) {
|
||||||
|
layer.close(index);
|
||||||
|
};
|
||||||
|
|
||||||
|
$(".menu-item>dd>a").click(function () {
|
||||||
|
var path_item = $(this).attr("path");
|
||||||
|
var path_json = $(this).attr("datajson");
|
||||||
|
|
||||||
|
var index = showLoading({ msg: "数据加载中......" });
|
||||||
|
$("#page_content").load(path_item, $.parseJSON(path_json), function () {
|
||||||
|
//初始化绑定页面的时间,例如时间控件
|
||||||
|
closeLoading(index);
|
||||||
|
index = -1;
|
||||||
|
});
|
||||||
|
|
||||||
|
//如果出现长时间未关闭,定时关闭loading
|
||||||
|
setTimeout(function () {
|
||||||
|
if (index >= 0) closeLoading(index);
|
||||||
|
}, 5000);
|
||||||
|
});
|
||||||
|
|
||||||
|
</script>
|
@ -0,0 +1,4 @@
|
|||||||
|
@{
|
||||||
|
ViewBag.Title = "";
|
||||||
|
}
|
||||||
|
系统参数设置
|
@ -0,0 +1,62 @@
|
|||||||
|
@{
|
||||||
|
ViewBag.Title = "";
|
||||||
|
Layout = "~/Areas/Admin/Shared/_Layout.cshtml";
|
||||||
|
}
|
||||||
|
<div class="layui-side layui-bg-black">
|
||||||
|
<div class="layui-side-scroll">
|
||||||
|
<!-- 左侧导航区域(可配合layui已有的垂直导航) -->
|
||||||
|
<ul class="layui-nav layui-nav-tree" lay-filter="test">
|
||||||
|
<li class="layui-nav-item layui-nav-itemed">
|
||||||
|
<a class="" href="javascript:;">模板管理</a>
|
||||||
|
<dl class="layui-nav-child menu-item">
|
||||||
|
<dd><a href="javascript:void(0);" datajson="{}" path="/Admin/Template/Index">示例模板</a></dd>
|
||||||
|
<dd><a href="javascript:void(0);" datajson="{}" path="/Admin/Template/Index">模板列表</a></dd>
|
||||||
|
<dd><a href="javascript:void(0);" datajson="{}" path="/Admin/Template/Index">模板统计</a></dd>
|
||||||
|
<dd><a href="/Example/Template/Index" target="_blank">查看模板</a></dd>
|
||||||
|
<dd><a href="/Example/Main/Index" target="_blank">查看示例</a></dd>
|
||||||
|
</dl>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="layui-body">
|
||||||
|
<!-- 内容主体区域 -->
|
||||||
|
<div style="padding: 15px;" id="page_content">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
var showLoading = function (obj) {
|
||||||
|
|
||||||
|
var index = layer.msg(obj.msg, {
|
||||||
|
icon: 16,
|
||||||
|
shade: 0.1,
|
||||||
|
shadeClose: false,
|
||||||
|
});
|
||||||
|
return index;
|
||||||
|
};
|
||||||
|
|
||||||
|
var closeLoading = function (index) {
|
||||||
|
layer.close(index);
|
||||||
|
};
|
||||||
|
|
||||||
|
$(".menu-item>dd>a").click(function () {
|
||||||
|
var path_item = $(this).attr("path");
|
||||||
|
var path_json = $(this).attr("datajson");
|
||||||
|
|
||||||
|
var index = showLoading({ msg: "数据加载中......" });
|
||||||
|
$("#page_content").load(path_item, $.parseJSON(path_json), function () {
|
||||||
|
//初始化绑定页面的时间,例如时间控件
|
||||||
|
closeLoading(index);
|
||||||
|
index = -1;
|
||||||
|
});
|
||||||
|
|
||||||
|
//如果出现长时间未关闭,定时关闭loading
|
||||||
|
setTimeout(function () {
|
||||||
|
if (index >= 0) closeLoading(index);
|
||||||
|
}, 5000);
|
||||||
|
});
|
||||||
|
|
||||||
|
</script>
|
@ -0,0 +1,5 @@
|
|||||||
|
@using FreeSql.Site.UI
|
||||||
|
@using FreeSql.Site.UI.Models
|
||||||
|
@using FreeSql.Site.Entity
|
||||||
|
@using FreeSql.Site.UI.Common
|
||||||
|
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
|
@ -0,0 +1,4 @@
|
|||||||
|
@{
|
||||||
|
Layout = null;
|
||||||
|
ViewData["Title"] = ".NETCore最方便的ORM";
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using FreeSql.Site.UI.Areas.BBS.Models;
|
||||||
|
using FreeSql.Site.UI.Controllers;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace FreeSql.Site.UI.Areas.BBS.Controllers
|
||||||
|
{
|
||||||
|
[Area("BBS")]
|
||||||
|
public class BBSContentController : BaseController
|
||||||
|
{
|
||||||
|
public IActionResult Index()
|
||||||
|
{
|
||||||
|
BBSContentModel model = new BBSContentModel();
|
||||||
|
return View(model);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IActionResult Ask() {
|
||||||
|
BBSContentModel model = new BBSContentModel();
|
||||||
|
return View(model);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FreeSql.Site.UI.Areas.BBS.Models
|
||||||
|
{
|
||||||
|
public class BBSContentModel
|
||||||
|
{
|
||||||
|
public int OrderBy { get; set; }
|
||||||
|
|
||||||
|
public int ContentID { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
|
||||||
|
@{
|
||||||
|
ViewBag.Title = ".NET文档园 .NET开源ORM - 首页";
|
||||||
|
}
|
||||||
|
@using FreeSql.Site.UI.Areas.BBS.Models;
|
||||||
|
|
||||||
|
<div style="width:100%; height:430px; text-align:center; padding-top:150px; font-size:20px; font-weight:bold; letter-spacing:6px;" >
|
||||||
|
论坛功能正在开发中......
|
||||||
|
</div>
|
@ -0,0 +1,3 @@
|
|||||||
|
@{
|
||||||
|
Layout = "~/Views/Shared/_Layout.cshtml";
|
||||||
|
}
|
@ -0,0 +1,131 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using FreeSql.Site.DAL;
|
||||||
|
using FreeSql.Site.Entity;
|
||||||
|
using FreeSql.Site.UI.Controllers;
|
||||||
|
using FreeSql.Site.UI.Models;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace FreeSql.Site.UI.Areas.Doc.Controllers
|
||||||
|
{
|
||||||
|
[Area("Doc")]
|
||||||
|
public class DocumentsController : BaseController
|
||||||
|
{
|
||||||
|
public DocumentTypeDAL DocumentTypeDAL { get; set; }
|
||||||
|
|
||||||
|
public DocumentContentDAL DocumentContentDAL { get; set; }
|
||||||
|
|
||||||
|
public DocumentsController()
|
||||||
|
{
|
||||||
|
this.DocumentTypeDAL = new DocumentTypeDAL();
|
||||||
|
this.DocumentContentDAL = new DocumentContentDAL();
|
||||||
|
}
|
||||||
|
|
||||||
|
// GET: Documents
|
||||||
|
public IActionResult Index(int id = 1)
|
||||||
|
{
|
||||||
|
var typeList = DocumentTypeDAL.Query(d => d.ID != 0).list;
|
||||||
|
var contentlist = DocumentContentDAL.Query(d => d.Status == 1).list;
|
||||||
|
|
||||||
|
//适应两层结构即可
|
||||||
|
var query = (from p in typeList
|
||||||
|
where p.UpID == null || p.UpID == 0
|
||||||
|
select new TreeData(p, typeList).AddChildrens(GetContentTreeData(p.ID, contentlist), (tid) => GetContentTreeData(tid, contentlist))).ToList();
|
||||||
|
|
||||||
|
ViewBag.DocumentList = query;
|
||||||
|
ViewBag.DocID = id;
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<TreeData> GetContentTreeData(int id, List<DocumentContent> contentlist)
|
||||||
|
{
|
||||||
|
return contentlist.Where(w => w.TypeID == id).Select(s => new TreeData
|
||||||
|
{
|
||||||
|
id = s.ID,
|
||||||
|
text = s.DocTitle,
|
||||||
|
datatype = 1
|
||||||
|
}).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
// GET: Documents/Details/5
|
||||||
|
public ActionResult Details(int id)
|
||||||
|
{
|
||||||
|
ViewBag.DocumentID = id;
|
||||||
|
var doc = this.DocumentContentDAL.GetByOne(w => w.ID == id);
|
||||||
|
ViewBag.DocumentInfo = doc;
|
||||||
|
return this.PartialView();
|
||||||
|
}
|
||||||
|
|
||||||
|
// GET: Documents/Create
|
||||||
|
public ActionResult Create()
|
||||||
|
{
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
|
||||||
|
// POST: Documents/Create
|
||||||
|
[HttpPost]
|
||||||
|
[ValidateAntiForgeryToken]
|
||||||
|
public ActionResult Create(IFormCollection collection)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// TODO: Add insert logic here
|
||||||
|
|
||||||
|
return RedirectToAction(nameof(Index));
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// GET: Documents/Edit/5
|
||||||
|
public ActionResult Edit(int id)
|
||||||
|
{
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
|
||||||
|
// POST: Documents/Edit/5
|
||||||
|
[HttpPost]
|
||||||
|
[ValidateAntiForgeryToken]
|
||||||
|
public ActionResult Edit(int id, IFormCollection collection)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// TODO: Add update logic here
|
||||||
|
|
||||||
|
return RedirectToAction(nameof(Index));
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// GET: Documents/Delete/5
|
||||||
|
public ActionResult Delete(int id)
|
||||||
|
{
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
|
||||||
|
// POST: Documents/Delete/5
|
||||||
|
[HttpPost]
|
||||||
|
[ValidateAntiForgeryToken]
|
||||||
|
public ActionResult Delete(int id, IFormCollection collection)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// TODO: Add delete logic here
|
||||||
|
|
||||||
|
return RedirectToAction(nameof(Index));
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,6 @@
|
|||||||
|
@*
|
||||||
|
For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
|
||||||
|
*@
|
||||||
|
@{
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,56 @@
|
|||||||
|
@{
|
||||||
|
Layout = null;
|
||||||
|
var documentinfo = (FreeSql.Site.Entity.DocumentContent)ViewBag.DocumentInfo;
|
||||||
|
}
|
||||||
|
@if (ViewBag.DocumentInfo == null)
|
||||||
|
{
|
||||||
|
<span>文章不存在,请选择其它文章查看!</span>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<h1 class="site-h1">@documentinfo.DocTitle</h1>
|
||||||
|
<div id="details_content" style="display:none;">
|
||||||
|
<blockquote>
|
||||||
|
@documentinfo.DocAbstract
|
||||||
|
</blockquote>
|
||||||
|
@documentinfo.DocContent
|
||||||
|
</div>
|
||||||
|
<script>
|
||||||
|
if ('@documentinfo.OriginType' == '1') {
|
||||||
|
var options = {
|
||||||
|
elm: "details_content", url: "@documentinfo.OriginUrl", paramters: "", loadIndex: 1,
|
||||||
|
successCallBack: function () {
|
||||||
|
debugger
|
||||||
|
document.getElementById('details_content').innerHTML =
|
||||||
|
marked($("#details_content").html());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
freejs.loadHtml(options);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if ('@documentinfo.EditorMode' == '0') {
|
||||||
|
marked.setOptions({
|
||||||
|
renderer: new marked.Renderer(),
|
||||||
|
gfm: true,
|
||||||
|
tables: true,
|
||||||
|
breaks: true,
|
||||||
|
pedantic: false,
|
||||||
|
sanitize: false,
|
||||||
|
smartLists: true,
|
||||||
|
smartypants: false,
|
||||||
|
});
|
||||||
|
marked.setOptions({
|
||||||
|
highlight: function (code) {
|
||||||
|
return hljs.highlightAuto(code).value;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
document.getElementById('details_content').innerHTML =
|
||||||
|
marked($("#details_content").html());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
//直接里面的内容就是HTML
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$("#details_content").show();
|
||||||
|
</script>
|
||||||
|
}
|
@ -0,0 +1,62 @@
|
|||||||
|
@{
|
||||||
|
|
||||||
|
}
|
||||||
|
<div class="layui-main site-inline">
|
||||||
|
<div class="site-tree">
|
||||||
|
<ul class="layui-tree">
|
||||||
|
@foreach (var item in (List<FreeSql.Site.UI.Models.TreeData>)ViewBag.DocumentList)
|
||||||
|
{
|
||||||
|
<li><h2>@item.text</h2></li>
|
||||||
|
foreach (var children in item.children)
|
||||||
|
{
|
||||||
|
if (children.datatype == 1)
|
||||||
|
{
|
||||||
|
<li class="site-tree-noicon">
|
||||||
|
<a href="?id=@(children.id)"><cite>@children.text</cite></a>
|
||||||
|
</li>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<li class="site-tree-noicon">
|
||||||
|
<a href="#@(children.id)"><cite>> @children.text</cite></a>
|
||||||
|
</li>
|
||||||
|
foreach (var children2 in children.children)
|
||||||
|
{
|
||||||
|
<li class="site-tree-noicon">
|
||||||
|
<a href="?id=@(children2.id)"><cite> @children2.text</cite></a>
|
||||||
|
</li>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<div class="site-content">
|
||||||
|
@Html.Action("Details", new RouteValueDictionary { { "id", ViewBag.DocID } })
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="site-tree-mobile layui-hide">
|
||||||
|
<i class="layui-icon"></i>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
//window.onhashchange = function () {
|
||||||
|
// var hash = location.hash;
|
||||||
|
// if (hash.search(/^#C\d+$/g) == 0) {
|
||||||
|
// var docid = hash.replace('C', '');
|
||||||
|
|
||||||
|
// $(".site-content").load("/Doc/Documents/Details", { id: docid }, function () {
|
||||||
|
// alert(1);
|
||||||
|
// });
|
||||||
|
// //$.ajax({
|
||||||
|
// // type: "GET",
|
||||||
|
// // url: "/Doc/Documents/Details",
|
||||||
|
// // data: { id: docid },
|
||||||
|
// // dataType: "html",
|
||||||
|
// // success: function (data) {
|
||||||
|
// // $(".site-content").html(data);
|
||||||
|
// // }
|
||||||
|
// //});
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
</script>
|
@ -0,0 +1,7 @@
|
|||||||
|
@using FreeSql.Site.UI;
|
||||||
|
@using FreeSql.Site.UI.Models;
|
||||||
|
@using FreeSql.Site.UI.Common;
|
||||||
|
@using Microsoft.AspNetCore.Routing;
|
||||||
|
@using Microsoft.AspNetCore.Mvc;
|
||||||
|
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
|
||||||
|
@addTagHelper "FreeSql.Site.UI.Common.TagHelpers.MarkdownTagHelper, FreeSql.Site.UI"
|
@ -0,0 +1,3 @@
|
|||||||
|
@{
|
||||||
|
Layout = "~/Views/Shared/_Layout.cshtml";
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace FreeSql.Site.UI.Areas.Example.Controllers
|
||||||
|
{
|
||||||
|
[Area("example")]
|
||||||
|
public class MainController : Controller
|
||||||
|
{
|
||||||
|
public IActionResult Index()
|
||||||
|
{
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace FreeSql.Site.UI.Areas.Example.Controllers
|
||||||
|
{
|
||||||
|
[Area("Example")]
|
||||||
|
public class TemplateController : Controller
|
||||||
|
{
|
||||||
|
public IActionResult Index()
|
||||||
|
{
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,6 @@
|
|||||||
|
@{
|
||||||
|
ViewBag.Title = ".NET文档园 .NET开源ORM - 首页";
|
||||||
|
}
|
||||||
|
<div style="width:100%; height:430px; text-align:center; padding-top:150px; font-size:20px; font-weight:bold; letter-spacing:6px;">
|
||||||
|
示例功能正在开发中......
|
||||||
|
</div>
|
@ -0,0 +1,137 @@
|
|||||||
|
@*
|
||||||
|
For more information on enabling MVC for empty projects, visit http://go.microsoft.com/fwlink/?LinkID=397860
|
||||||
|
*@
|
||||||
|
<div style="width:100%; height:430px; text-align:center; padding-top:150px; font-size:20px; font-weight:bold; letter-spacing:6px;">
|
||||||
|
示例功能正在开发中......
|
||||||
|
</div>
|
||||||
|
<h2>计划如下效果,通过模板生成项目页面</h2>
|
||||||
|
<div style="padding: 20px; background-color: #F2F2F2;">
|
||||||
|
<div class="layui-row layui-col-space15">
|
||||||
|
<div class="layui-col-md6">
|
||||||
|
<div class="layui-card">
|
||||||
|
<div class="layui-card-header">模板一</div>
|
||||||
|
<div class="layui-card-body">
|
||||||
|
卡片式面板面板通常用于非白色背景色的主体内<br>
|
||||||
|
从而映衬出边框投影
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-col-md6">
|
||||||
|
<div class="layui-card">
|
||||||
|
<div class="layui-card-header">模板二</div>
|
||||||
|
<div class="layui-card-body">
|
||||||
|
结合 layui 的栅格系统<br>
|
||||||
|
轻松实现响应式布局
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-col-md6">
|
||||||
|
<div class="layui-card">
|
||||||
|
<div class="layui-card-header">模板三</div>
|
||||||
|
<div class="layui-card-body">
|
||||||
|
结合 layui 的栅格系统<br>
|
||||||
|
轻松实现响应式布局
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-col-md6">
|
||||||
|
<div class="layui-card">
|
||||||
|
<div class="layui-card-header">模板四</div>
|
||||||
|
<div class="layui-card-body">
|
||||||
|
结合 layui 的栅格系统<br>
|
||||||
|
轻松实现响应式布局
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-col-md6">
|
||||||
|
<div class="layui-card">
|
||||||
|
<div class="layui-card-header">模板五</div>
|
||||||
|
<div class="layui-card-body">
|
||||||
|
结合 layui 的栅格系统<br>
|
||||||
|
轻松实现响应式布局
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-col-md6">
|
||||||
|
<div class="layui-card">
|
||||||
|
<div class="layui-card-header">模板6</div>
|
||||||
|
<div class="layui-card-body">
|
||||||
|
结合 layui 的栅格系统<br>
|
||||||
|
轻松实现响应式布局
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-col-md6">
|
||||||
|
<div class="layui-card">
|
||||||
|
<div class="layui-card-header">模板6</div>
|
||||||
|
<div class="layui-card-body">
|
||||||
|
结合 layui 的栅格系统<br>
|
||||||
|
轻松实现响应式布局
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-col-md6">
|
||||||
|
<div class="layui-card">
|
||||||
|
<div class="layui-card-header">模板6</div>
|
||||||
|
<div class="layui-card-body">
|
||||||
|
结合 layui 的栅格系统<br>
|
||||||
|
轻松实现响应式布局
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-col-md6">
|
||||||
|
<div class="layui-card">
|
||||||
|
<div class="layui-card-header">模板6</div>
|
||||||
|
<div class="layui-card-body">
|
||||||
|
结合 layui 的栅格系统<br>
|
||||||
|
轻松实现响应式布局
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-col-md6">
|
||||||
|
<div class="layui-card">
|
||||||
|
<div class="layui-card-header">模板6</div>
|
||||||
|
<div class="layui-card-body">
|
||||||
|
结合 layui 的栅格系统<br>
|
||||||
|
轻松实现响应式布局
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-col-md6">
|
||||||
|
<div class="layui-card">
|
||||||
|
<div class="layui-card-header">模板6</div>
|
||||||
|
<div class="layui-card-body">
|
||||||
|
结合 layui 的栅格系统<br>
|
||||||
|
轻松实现响应式布局
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-col-md6">
|
||||||
|
<div class="layui-card">
|
||||||
|
<div class="layui-card-header">模板6</div>
|
||||||
|
<div class="layui-card-body">
|
||||||
|
结合 layui 的栅格系统<br>
|
||||||
|
轻松实现响应式布局
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-col-md6">
|
||||||
|
<div class="layui-card">
|
||||||
|
<div class="layui-card-header">模板6</div>
|
||||||
|
<div class="layui-card-body">
|
||||||
|
结合 layui 的栅格系统<br>
|
||||||
|
轻松实现响应式布局
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-col-md6">
|
||||||
|
<div class="layui-card">
|
||||||
|
<div class="layui-card-header">模板6</div>
|
||||||
|
<div class="layui-card-body">
|
||||||
|
结合 layui 的栅格系统<br>
|
||||||
|
轻松实现响应式布局
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
@ -0,0 +1,3 @@
|
|||||||
|
@{
|
||||||
|
Layout = "~/Views/Shared/_Layout.cshtml";
|
||||||
|
}
|
73
Examples/website/FreeSql.Site.UI/Common/AutoException.cs
Normal file
73
Examples/website/FreeSql.Site.UI/Common/AutoException.cs
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Transactions;
|
||||||
|
|
||||||
|
namespace FreeSql.Site.UI.Common
|
||||||
|
{
|
||||||
|
public class AutoException
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 执行方法外壳,包括异常抓取,固定格式返回
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T"></typeparam>
|
||||||
|
/// <param name="action"></param>
|
||||||
|
/// <param name="isTransaction"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static ServiceResult<T> Excute<T>(
|
||||||
|
Action<ServiceResult<T>> action, bool isTransaction = false)
|
||||||
|
{
|
||||||
|
TransactionScope ts = null;
|
||||||
|
if (isTransaction) ts = new TransactionScope();
|
||||||
|
ServiceResult<T> result = new ServiceResult<T>() { Status = EnumServiceResult.Success.GetHashCode() };
|
||||||
|
try
|
||||||
|
{
|
||||||
|
action.Invoke(result);
|
||||||
|
if (isTransaction) ts.Complete();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
result.Msg = ex.Message;
|
||||||
|
result.Status = EnumServiceResult.Failure.GetHashCode();
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (isTransaction) ts.Dispose();
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 规范接口调用方法
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T">返回值参数 </typeparam>
|
||||||
|
/// <param name="action">执行方法内容</param>
|
||||||
|
/// <param name="isTransaction">是否启用事务</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static ServiceResult Execute(Action<ServiceResult> action, bool isTransaction = false)
|
||||||
|
{
|
||||||
|
TransactionScope ts = null;
|
||||||
|
if (isTransaction) ts = new TransactionScope();
|
||||||
|
ServiceResult result = new ServiceResult() { Status = EnumServiceResult.Success.GetHashCode(), Msg = "保存成功" };
|
||||||
|
try
|
||||||
|
{
|
||||||
|
action.Invoke(result);
|
||||||
|
if (result.Status == EnumServiceResult.Success.GetHashCode())
|
||||||
|
{
|
||||||
|
if (isTransaction) ts.Complete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
result.Msg = ex.Message;
|
||||||
|
result.Status = EnumServiceResult.Failure.GetHashCode();
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (isTransaction) ts.Dispose();
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,110 @@
|
|||||||
|
using Microsoft.AspNetCore.Html;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using System;
|
||||||
|
using Microsoft.AspNetCore.Routing;
|
||||||
|
using System.IO;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.AspNetCore.Mvc.Infrastructure;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||||
|
|
||||||
|
namespace FreeSql.Site.UI.Common
|
||||||
|
{
|
||||||
|
public static class HtmlHelperViewExtensions
|
||||||
|
{
|
||||||
|
public static string ToJson(this IHtmlHelper htmlHeler, object val)
|
||||||
|
{
|
||||||
|
if (val != null)
|
||||||
|
{
|
||||||
|
return Newtonsoft.Json.JsonConvert.SerializeObject(val);
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IHtmlContent Action(this IHtmlHelper helper, string action, object parameters = null)
|
||||||
|
{
|
||||||
|
var controller = (string)helper.ViewContext.RouteData.Values["controller"];
|
||||||
|
|
||||||
|
return Action(helper, action, controller, parameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IHtmlContent Action(this IHtmlHelper helper, string action, string controller, object parameters = null)
|
||||||
|
{
|
||||||
|
var area = (string)helper.ViewContext.RouteData.Values["area"];
|
||||||
|
|
||||||
|
return Action(helper, action, controller, area, parameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IHtmlContent Action(this IHtmlHelper helper, string action, string controller, string area, object parameters = null)
|
||||||
|
{
|
||||||
|
if (action == null)
|
||||||
|
throw new ArgumentNullException("action");
|
||||||
|
|
||||||
|
if (controller == null)
|
||||||
|
throw new ArgumentNullException("controller");
|
||||||
|
|
||||||
|
|
||||||
|
var task = RenderActionAsync(helper, action, controller, area, parameters);
|
||||||
|
|
||||||
|
return task.Result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static async Task<IHtmlContent> RenderActionAsync(this IHtmlHelper helper, string action, string controller, string area, object parameters = null)
|
||||||
|
{
|
||||||
|
// fetching required services for invocation
|
||||||
|
var serviceProvider = helper.ViewContext.HttpContext.RequestServices;
|
||||||
|
var actionContextAccessor = helper.ViewContext.HttpContext.RequestServices.GetRequiredService<IActionContextAccessor>();
|
||||||
|
var httpContextAccessor = helper.ViewContext.HttpContext.RequestServices.GetRequiredService<IHttpContextAccessor>();
|
||||||
|
var actionSelector = serviceProvider.GetRequiredService<IActionSelector>();
|
||||||
|
|
||||||
|
// creating new action invocation context
|
||||||
|
var routeData = new RouteData();
|
||||||
|
foreach (var router in helper.ViewContext.RouteData.Routers)
|
||||||
|
{
|
||||||
|
routeData.PushState(router, null, null);
|
||||||
|
}
|
||||||
|
routeData.PushState(null, new RouteValueDictionary(new { controller = controller, action = action, area = area }), null);
|
||||||
|
routeData.PushState(null, new RouteValueDictionary(parameters ?? new { }), null);
|
||||||
|
|
||||||
|
//get the actiondescriptor
|
||||||
|
RouteContext routeContext = new RouteContext(helper.ViewContext.HttpContext) { RouteData = routeData };
|
||||||
|
var candidates = actionSelector.SelectCandidates(routeContext);
|
||||||
|
var actionDescriptor = actionSelector.SelectBestCandidate(routeContext, candidates);
|
||||||
|
|
||||||
|
var originalActionContext = actionContextAccessor.ActionContext;
|
||||||
|
var originalhttpContext = httpContextAccessor.HttpContext;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var newHttpContext = serviceProvider.GetRequiredService<IHttpContextFactory>().Create(helper.ViewContext.HttpContext.Features);
|
||||||
|
if (newHttpContext.Items.ContainsKey(typeof(IUrlHelper)))
|
||||||
|
{
|
||||||
|
newHttpContext.Items.Remove(typeof(IUrlHelper));
|
||||||
|
}
|
||||||
|
newHttpContext.Response.Body = new MemoryStream();
|
||||||
|
var actionContext = new ActionContext(newHttpContext, routeData, actionDescriptor);
|
||||||
|
actionContextAccessor.ActionContext = actionContext;
|
||||||
|
var invoker = serviceProvider.GetRequiredService<IActionInvokerFactory>().CreateInvoker(actionContext);
|
||||||
|
await invoker.InvokeAsync();
|
||||||
|
newHttpContext.Response.Body.Position = 0;
|
||||||
|
using (var reader = new StreamReader(newHttpContext.Response.Body))
|
||||||
|
{
|
||||||
|
return new HtmlString(reader.ReadToEnd());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return new HtmlString(ex.Message);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
actionContextAccessor.ActionContext = originalActionContext;
|
||||||
|
httpContextAccessor.HttpContext = originalhttpContext;
|
||||||
|
if (helper.ViewContext.HttpContext.Items.ContainsKey(typeof(IUrlHelper)))
|
||||||
|
{
|
||||||
|
helper.ViewContext.HttpContext.Items.Remove(typeof(IUrlHelper));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
40
Examples/website/FreeSql.Site.UI/Common/MarkdownTagHelper.cs
Normal file
40
Examples/website/FreeSql.Site.UI/Common/MarkdownTagHelper.cs
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
using CommonMark;
|
||||||
|
using Microsoft.AspNetCore.Mvc.ViewFeatures;
|
||||||
|
using Microsoft.AspNetCore.Razor.TagHelpers;
|
||||||
|
using System.Net;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FreeSql.Site.UI.Common.TagHelpers
|
||||||
|
{
|
||||||
|
[HtmlTargetElement("markdown", TagStructure = TagStructure.NormalOrSelfClosing)]
|
||||||
|
[HtmlTargetElement(Attributes = "markdown")]
|
||||||
|
public class MarkdownTagHelper : TagHelper
|
||||||
|
{
|
||||||
|
public MarkdownTagHelper()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public ModelExpression Content { get; set; }
|
||||||
|
|
||||||
|
public async override Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
|
||||||
|
{
|
||||||
|
if (output.TagName == "markdown")
|
||||||
|
{
|
||||||
|
output.TagName = null;
|
||||||
|
}
|
||||||
|
output.Attributes.RemoveAll("markdown");
|
||||||
|
var content = await GetContent(output);
|
||||||
|
var markdown = WebUtility.HtmlEncode(WebUtility.HtmlDecode(content));
|
||||||
|
var html = CommonMarkConverter.Convert(markdown);
|
||||||
|
output.Content.SetHtmlContent(html ?? "");
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task<string> GetContent(TagHelperOutput output)
|
||||||
|
{
|
||||||
|
if (Content == null)
|
||||||
|
return (await output.GetChildContentAsync()).GetContent();
|
||||||
|
return Content.Model?.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,35 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FreeSql.Site.UI.Common
|
||||||
|
{
|
||||||
|
public static class PredicateExtensions
|
||||||
|
{
|
||||||
|
public static Expression<Func<T, bool>> True<T>() { return f => true; }
|
||||||
|
|
||||||
|
public static Expression<Func<T, bool>> False<T>() { return f => false; }
|
||||||
|
|
||||||
|
public static Expression<Func<T, bool>> Or<T>(this Expression<Func<T, bool>> expression1,
|
||||||
|
Expression<Func<T, bool>> expression2)
|
||||||
|
{
|
||||||
|
var invokedExpression = Expression.Invoke(expression2, expression1.Parameters
|
||||||
|
.Cast<Expression>());
|
||||||
|
|
||||||
|
return Expression.Lambda<Func<T, bool>>(Expression.Or(expression1.Body, invokedExpression),
|
||||||
|
expression1.Parameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Expression<Func<T, bool>> And<T>(this Expression<Func<T, bool>> expression1,
|
||||||
|
Expression<Func<T, bool>> expression2)
|
||||||
|
{
|
||||||
|
var invokedExpression = Expression.Invoke(expression2, expression1.Parameters
|
||||||
|
.Cast<Expression>());
|
||||||
|
|
||||||
|
return Expression.Lambda<Func<T, bool>>(Expression.And(expression1.Body,
|
||||||
|
invokedExpression), expression1.Parameters);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace FreeSql.Site.UI.Controllers
|
||||||
|
{
|
||||||
|
public class BaseController : Controller
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,43 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using FreeSql.Site.UI.Models;
|
||||||
|
|
||||||
|
namespace FreeSql.Site.UI.Controllers
|
||||||
|
{
|
||||||
|
public class HomeController : Controller
|
||||||
|
{
|
||||||
|
public IActionResult Index()
|
||||||
|
{
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
|
||||||
|
public IActionResult About()
|
||||||
|
{
|
||||||
|
ViewData["Message"] = "Your application description page.";
|
||||||
|
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
|
||||||
|
public IActionResult Contact()
|
||||||
|
{
|
||||||
|
ViewData["Message"] = "Your contact page.";
|
||||||
|
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
|
||||||
|
public IActionResult Privacy()
|
||||||
|
{
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
|
||||||
|
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||||
|
public IActionResult Error()
|
||||||
|
{
|
||||||
|
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
50
Examples/website/FreeSql.Site.UI/FreeSql.Site.UI.csproj
Normal file
50
Examples/website/FreeSql.Site.UI/FreeSql.Site.UI.csproj
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>netcoreapp2.2</TargetFramework>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="CommonMark.NET" Version="0.15.1" />
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.App" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="Areas\Admin\Data\" />
|
||||||
|
<Folder Include="Areas\BBS\Data\" />
|
||||||
|
<Folder Include="Areas\Doc\Data\" />
|
||||||
|
<Folder Include="Areas\Doc\Models\" />
|
||||||
|
<Folder Include="Areas\Example\Data\" />
|
||||||
|
<Folder Include="Areas\Example\Models\" />
|
||||||
|
<Folder Include="wwwroot\laymd\" />
|
||||||
|
<Folder Include="wwwroot\layui\ext\treetable\js\" />
|
||||||
|
<Folder Include="wwwroot\file\" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\FreeSql.Site.DAL\FreeSql.Site.DAL.csproj" />
|
||||||
|
<ProjectReference Include="..\FreeSql.Site.Entity\FreeSql.Site.Entity.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Content Update="Areas\Admin\Views\Document\DocType.cshtml">
|
||||||
|
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
||||||
|
</Content>
|
||||||
|
<Content Update="Areas\Admin\_ViewStart.cshtml">
|
||||||
|
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
||||||
|
<Pack>$(IncludeRazorContentInPack)</Pack>
|
||||||
|
</Content>
|
||||||
|
<Content Update="Areas\BBS\_ViewStart.cshtml">
|
||||||
|
<Pack>$(IncludeRazorContentInPack)</Pack>
|
||||||
|
</Content>
|
||||||
|
<Content Update="Areas\Doc\_ViewStart.cshtml">
|
||||||
|
<Pack>$(IncludeRazorContentInPack)</Pack>
|
||||||
|
</Content>
|
||||||
|
<Content Update="Areas\Example\_ViewStart.cshtml">
|
||||||
|
<Pack>$(IncludeRazorContentInPack)</Pack>
|
||||||
|
</Content>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ProjectExtensions><VisualStudio><UserProperties appsettings_1json__JSONSchema="" /></VisualStudio></ProjectExtensions>
|
||||||
|
|
||||||
|
</Project>
|
11
Examples/website/FreeSql.Site.UI/Models/ErrorViewModel.cs
Normal file
11
Examples/website/FreeSql.Site.UI/Models/ErrorViewModel.cs
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace FreeSql.Site.UI.Models
|
||||||
|
{
|
||||||
|
public class ErrorViewModel
|
||||||
|
{
|
||||||
|
public string RequestId { get; set; }
|
||||||
|
|
||||||
|
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
|
||||||
|
}
|
||||||
|
}
|
49
Examples/website/FreeSql.Site.UI/Models/ServiceResult.cs
Normal file
49
Examples/website/FreeSql.Site.UI/Models/ServiceResult.cs
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FreeSql.Site.UI
|
||||||
|
{
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ServiceResult操作结果
|
||||||
|
/// </summary>
|
||||||
|
public enum EnumServiceResult
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 操作成功
|
||||||
|
/// </summary>
|
||||||
|
Success = 1,
|
||||||
|
/// <summary>
|
||||||
|
/// 操作失败
|
||||||
|
/// </summary>
|
||||||
|
Failure = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 方法错误结果
|
||||||
|
/// </summary>
|
||||||
|
[Serializable]
|
||||||
|
public class ServiceResult
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 返回结果 =1 表示成功 否则失败
|
||||||
|
/// </summary>
|
||||||
|
public int Status { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 返回结果信息
|
||||||
|
/// </summary>
|
||||||
|
public string Msg { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
[Serializable]
|
||||||
|
public class ServiceResult<T> : ServiceResult
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 数据返回
|
||||||
|
/// </summary>
|
||||||
|
public T Data { get; set; }
|
||||||
|
}
|
||||||
|
}
|
56
Examples/website/FreeSql.Site.UI/Models/TreeDataConvert.cs
Normal file
56
Examples/website/FreeSql.Site.UI/Models/TreeDataConvert.cs
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using FreeSql.Site.Entity;
|
||||||
|
|
||||||
|
namespace FreeSql.Site.UI.Models
|
||||||
|
{
|
||||||
|
public class TreeData
|
||||||
|
{
|
||||||
|
public TreeData() { }
|
||||||
|
|
||||||
|
public TreeData(DocumentType type)
|
||||||
|
{
|
||||||
|
this.id = type.ID;
|
||||||
|
this.text = type.TypeName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TreeData(DocumentType type, List<DocumentType> list)
|
||||||
|
{
|
||||||
|
this.id = type.ID;
|
||||||
|
this.text = type.TypeName;
|
||||||
|
this.children = (from l in list where l.UpID == type.ID select new TreeData(l, list)).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 唯一编号
|
||||||
|
/// </summary>
|
||||||
|
public int id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 标题
|
||||||
|
/// </summary>
|
||||||
|
public string text { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 类型 =0 表示类型 =1 表示内容
|
||||||
|
/// </summary>
|
||||||
|
public int datatype { get; set; } = 0;
|
||||||
|
|
||||||
|
public List<TreeData> children { get; set; }
|
||||||
|
|
||||||
|
public TreeData AddChildrens(List<TreeData> list, Func<int, List<TreeData>> bind = null)
|
||||||
|
{
|
||||||
|
if (this.children != null && bind != null)
|
||||||
|
{
|
||||||
|
this.children.ForEach(f =>
|
||||||
|
{
|
||||||
|
f.children = bind(f.id);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
this.children?.AddRange(list);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
24
Examples/website/FreeSql.Site.UI/Program.cs
Normal file
24
Examples/website/FreeSql.Site.UI/Program.cs
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.AspNetCore;
|
||||||
|
using Microsoft.AspNetCore.Hosting;
|
||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
|
namespace FreeSql.Site.UI
|
||||||
|
{
|
||||||
|
public class Program
|
||||||
|
{
|
||||||
|
public static void Main(string[] args)
|
||||||
|
{
|
||||||
|
CreateWebHostBuilder(args).Build().Run();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
|
||||||
|
WebHost.CreateDefaultBuilder(args)
|
||||||
|
.UseStartup<Startup>();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
{
|
||||||
|
"iisSettings": {
|
||||||
|
"windowsAuthentication": false,
|
||||||
|
"anonymousAuthentication": true,
|
||||||
|
"iisExpress": {
|
||||||
|
"applicationUrl": "http://localhost:59757",
|
||||||
|
"sslPort": 44395
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"profiles": {
|
||||||
|
"IIS Express": {
|
||||||
|
"commandName": "IISExpress",
|
||||||
|
"launchBrowser": true,
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"FreeSql.Site.UI": {
|
||||||
|
"commandName": "Project",
|
||||||
|
"launchBrowser": true,
|
||||||
|
"applicationUrl": "https://localhost:5001;http://localhost:5000",
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
12
Examples/website/FreeSql.Site.UI/ScaffoldingReadMe.txt
Normal file
12
Examples/website/FreeSql.Site.UI/ScaffoldingReadMe.txt
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
Scaffolding has generated all the files and added the required dependencies.
|
||||||
|
|
||||||
|
However the Application's Startup code may required additional changes for things to work end to end.
|
||||||
|
Add the following code to the Configure method in your Application's Startup class if not already done:
|
||||||
|
|
||||||
|
app.UseMvc(routes =>
|
||||||
|
{
|
||||||
|
routes.MapRoute(
|
||||||
|
name : "areas",
|
||||||
|
template : "{area:exists}/{controller=Home}/{action=Index}/{id?}"
|
||||||
|
);
|
||||||
|
});
|
95
Examples/website/FreeSql.Site.UI/Startup.cs
Normal file
95
Examples/website/FreeSql.Site.UI/Startup.cs
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.AspNetCore.Builder;
|
||||||
|
using Microsoft.AspNetCore.Hosting;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.AspNetCore.HttpsPolicy;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.AspNetCore.Mvc.Infrastructure;
|
||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Newtonsoft.Json.Serialization;
|
||||||
|
|
||||||
|
namespace FreeSql.Site.UI
|
||||||
|
{
|
||||||
|
public class Startup
|
||||||
|
{
|
||||||
|
public Startup(IConfiguration configuration)
|
||||||
|
{
|
||||||
|
Configuration = configuration;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IConfiguration Configuration { get; }
|
||||||
|
|
||||||
|
// This method gets called by the runtime. Use this method to add services to the container.
|
||||||
|
public void ConfigureServices(IServiceCollection services)
|
||||||
|
{
|
||||||
|
services.Configure<CookiePolicyOptions>(options =>
|
||||||
|
{
|
||||||
|
// This lambda determines whether user consent for non-essential cookies is needed for a given request.
|
||||||
|
options.CheckConsentNeeded = context => true;
|
||||||
|
options.MinimumSameSitePolicy = SameSiteMode.None;
|
||||||
|
});
|
||||||
|
|
||||||
|
//设置Action方法
|
||||||
|
services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
|
||||||
|
services.AddSingleton<IActionContextAccessor, ActionContextAccessor>();
|
||||||
|
|
||||||
|
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1)
|
||||||
|
//设置返回内容得大小写格式
|
||||||
|
.AddJsonOptions(options => { options.SerializerSettings.ContractResolver = new DefaultContractResolver(); });
|
||||||
|
|
||||||
|
//Session服务
|
||||||
|
services.AddSession();
|
||||||
|
|
||||||
|
//添加跨域访问
|
||||||
|
services.AddCors(options => options.AddPolicy("AllowAnyOrigin",
|
||||||
|
builder => builder.WithOrigins("*")
|
||||||
|
.AllowAnyMethod()
|
||||||
|
.AllowAnyHeader()
|
||||||
|
.AllowAnyOrigin()
|
||||||
|
.AllowCredentials()));
|
||||||
|
|
||||||
|
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||||
|
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
|
||||||
|
{
|
||||||
|
if (env.IsDevelopment())
|
||||||
|
{
|
||||||
|
app.UseDeveloperExceptionPage();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
app.UseExceptionHandler("/Home/Error");
|
||||||
|
app.UseHsts();
|
||||||
|
}
|
||||||
|
|
||||||
|
app.UseHttpsRedirection();
|
||||||
|
app.UseStaticFiles();
|
||||||
|
app.UseCookiePolicy();
|
||||||
|
|
||||||
|
//app.UseMvc(routes =>
|
||||||
|
//{
|
||||||
|
// routes.MapRoute(
|
||||||
|
// name: "default",
|
||||||
|
// template: "{controller=Home}/{action=Index}/{id?}");
|
||||||
|
//});
|
||||||
|
//使用Session,必须在UseMvc之上
|
||||||
|
app.UseSession();
|
||||||
|
app.UseMvc(routes =>
|
||||||
|
{
|
||||||
|
routes.MapRoute(
|
||||||
|
name: "area",
|
||||||
|
template: "{area:exists}/{controller=Home}/{action=Index}/{id?}");
|
||||||
|
|
||||||
|
routes.MapRoute(
|
||||||
|
name: "default",
|
||||||
|
template: "{controller=Home}/{action=Index}/{id?}");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
4
Examples/website/FreeSql.Site.UI/Views/Home/About.cshtml
Normal file
4
Examples/website/FreeSql.Site.UI/Views/Home/About.cshtml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
@{
|
||||||
|
ViewData["Title"] = "About";
|
||||||
|
}
|
||||||
|
关于
|
@ -0,0 +1,4 @@
|
|||||||
|
@{
|
||||||
|
ViewData["Title"] = "Contact";
|
||||||
|
}
|
||||||
|
联系人
|
66
Examples/website/FreeSql.Site.UI/Views/Home/Index.cshtml
Normal file
66
Examples/website/FreeSql.Site.UI/Views/Home/Index.cshtml
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
@{
|
||||||
|
ViewData["Title"] = ".NETCore最方便的ORM";
|
||||||
|
}
|
||||||
|
|
||||||
|
<div class="site-banner">
|
||||||
|
<div class="site-banner-bg" style="background-image: url(/images/banner_index.jpg?v=0); background-size: cover;">
|
||||||
|
</div>
|
||||||
|
<div class="site-banner-main">
|
||||||
|
<div class="site-zfj site-zfj-anim">
|
||||||
|
<i class="layui-icon" style="color: #fff; color: rgba(255,255,255,.7);"></i>
|
||||||
|
</div>
|
||||||
|
<div class="layui-anim site-desc site-desc-anim">
|
||||||
|
<p class="web-font-desc">.NETCore最方便的ORM</p>
|
||||||
|
<cite>打造.NETCore最方便的ORM,包括dbfirst、codefirst混合使用</cite>
|
||||||
|
</div>
|
||||||
|
<div class="site-download">
|
||||||
|
<a href="https://github.com/2881099/FreeSql" class="layui-inline site-down" target="_blank">
|
||||||
|
<cite class="layui-icon"></cite>
|
||||||
|
立即下载
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="site-version">
|
||||||
|
<span>当前版本:<cite class="site-showv">0.0.1.181227_Beta</cite></span>
|
||||||
|
<span><a href="/doc/base/changelog.html" rel="nofollow" target="_blank">更新日志</a></span>
|
||||||
|
<span>下载量:<em class="site-showdowns">23</em></span>
|
||||||
|
</div>
|
||||||
|
<div class="site-banner-other">
|
||||||
|
<a href="https://github.com/2881099/FreeSql" target="_blank" class="site-star">
|
||||||
|
<i class="layui-icon"></i>
|
||||||
|
Star <cite id="getStars">1</cite>
|
||||||
|
</a>
|
||||||
|
<a href="https://github.com/2881099/FreeSql" target="_blank" rel="nofollow" class="site-fork">
|
||||||
|
<i class="layui-icon">1</i>
|
||||||
|
Fork
|
||||||
|
</a>
|
||||||
|
<a href="https://github.com/2881099/FreeSql" target="_blank" rel="nofollow" class="site-fork">
|
||||||
|
Github
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="layui-main">
|
||||||
|
|
||||||
|
<ul class="site-idea">
|
||||||
|
<li>
|
||||||
|
<fieldset class="layui-elem-field layui-field-title">
|
||||||
|
<legend>返璞归真</legend>
|
||||||
|
<p>身处在前端社区的繁荣之下,我们都在有意或无意地追逐。而 FreeSql 偏偏回望当初,奔赴在返璞归真的漫漫征途,自信并勇敢着,追寻于原生态的书写指令,试图以最简单的方式诠释高效。</p>
|
||||||
|
</fieldset>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<fieldset class="layui-elem-field layui-field-title">
|
||||||
|
<legend>双面体验</legend>
|
||||||
|
<p>拥有双面的不仅是人生,还有 FreeSql。一面极简,一面丰盈。极简是视觉所见的外在,是开发所念的简易。丰盈是倾情雕琢的内在,是信手拈来的承诺。一切本应如此,简而全,双重体验。</p>
|
||||||
|
</fieldset>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<fieldset class="layui-elem-field layui-field-title">
|
||||||
|
<legend>星辰大海</legend>
|
||||||
|
<p>如果眼下还是一团零星之火,那运筹帷幄之后,迎面东风,就是一场烈焰燎原吧,那必定会是一番尽情的燃烧。待,秋风萧瑟时,散作满天星辰,你看那四季轮回<!--海天相接-->,正是 FreeSql 不灭的执念。</p>
|
||||||
|
</fieldset>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</div>
|
@ -0,0 +1,4 @@
|
|||||||
|
@{
|
||||||
|
ViewData["Title"] = "Privacy Policy";
|
||||||
|
}
|
||||||
|
隐私
|
22
Examples/website/FreeSql.Site.UI/Views/Shared/Error.cshtml
Normal file
22
Examples/website/FreeSql.Site.UI/Views/Shared/Error.cshtml
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
@model ErrorViewModel
|
||||||
|
@{
|
||||||
|
ViewData["Title"] = "Error";
|
||||||
|
}
|
||||||
|
|
||||||
|
<h1 class="text-danger">Error.</h1>
|
||||||
|
<h2 class="text-danger">An error occurred while processing your request.</h2>
|
||||||
|
|
||||||
|
@if (Model.ShowRequestId)
|
||||||
|
{
|
||||||
|
<p>
|
||||||
|
<strong>Request ID:</strong> <code>@Model.RequestId</code>
|
||||||
|
</p>
|
||||||
|
}
|
||||||
|
|
||||||
|
<h3>Development Mode</h3>
|
||||||
|
<p>
|
||||||
|
Swapping to <strong>Development</strong> environment will display more detailed information about the error that occurred.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<strong>Development environment should not be enabled in deployed applications</strong>, as it can result in sensitive information from exceptions being displayed to end users. For local debugging, development environment can be enabled by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>, and restarting the application.
|
||||||
|
</p>
|
@ -0,0 +1,41 @@
|
|||||||
|
@using Microsoft.AspNetCore.Http.Features
|
||||||
|
|
||||||
|
@{
|
||||||
|
var consentFeature = Context.Features.Get<ITrackingConsentFeature>();
|
||||||
|
var showBanner = !consentFeature?.CanTrack ?? false;
|
||||||
|
var cookieString = consentFeature?.CreateConsentCookie();
|
||||||
|
}
|
||||||
|
|
||||||
|
@if (showBanner)
|
||||||
|
{
|
||||||
|
<nav id="cookieConsent" class="navbar navbar-default navbar-fixed-top" role="alert">
|
||||||
|
<div class="container">
|
||||||
|
<div class="navbar-header">
|
||||||
|
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#cookieConsent .navbar-collapse">
|
||||||
|
<span class="sr-only">Toggle cookie consent banner</span>
|
||||||
|
<span class="icon-bar"></span>
|
||||||
|
<span class="icon-bar"></span>
|
||||||
|
<span class="icon-bar"></span>
|
||||||
|
</button>
|
||||||
|
<span class="navbar-brand"><span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span></span>
|
||||||
|
</div>
|
||||||
|
<div class="collapse navbar-collapse">
|
||||||
|
<p class="navbar-text">
|
||||||
|
Use this space to summarize your privacy and cookie use policy.
|
||||||
|
</p>
|
||||||
|
<div class="navbar-right">
|
||||||
|
<a asp-controller="Home" asp-action="Privacy" class="btn btn-info navbar-btn">Learn More</a>
|
||||||
|
<button type="button" class="btn btn-default navbar-btn" data-cookie-string="@cookieString">Accept</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
<script>
|
||||||
|
(function () {
|
||||||
|
document.querySelector("#cookieConsent button[data-cookie-string]").addEventListener("click", function (el) {
|
||||||
|
document.cookie = el.target.dataset.cookieString;
|
||||||
|
document.querySelector("#cookieConsent").classList.add("hidden");
|
||||||
|
}, false);
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
|
}
|
201
Examples/website/FreeSql.Site.UI/Views/Shared/_Layout.cshtml
Normal file
201
Examples/website/FreeSql.Site.UI/Views/Shared/_Layout.cshtml
Normal file
@ -0,0 +1,201 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
<title>@ViewData["Title"]</title>
|
||||||
|
|
||||||
|
<environment include="Development">
|
||||||
|
<link href="~/layui/css/layui.css" rel="stylesheet" />
|
||||||
|
<link href="~/layui/lay/modules/preview.css" rel="stylesheet" />
|
||||||
|
<link rel="stylesheet" href="~/css/site.css" />
|
||||||
|
<script src="~/lib/jquery/dist/jquery.js"></script>
|
||||||
|
<script src="~/lib/bootstrap/dist/js/bootstrap.js"></script>
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
|
||||||
|
<script src="https://cdn.bootcss.com/highlight.js/9.13.1/highlight.min.js"></script>
|
||||||
|
<script src="~/layui/layui.js"></script>
|
||||||
|
<script src="~/layui/lay/modules/layer.js"></script>
|
||||||
|
<script src="~/js/common.js"></script>
|
||||||
|
</environment>
|
||||||
|
<environment exclude="Development">
|
||||||
|
<link rel="stylesheet" href="https://ajax.aspnetcdn.com/ajax/bootstrap/3.3.7/css/bootstrap.min.css"
|
||||||
|
asp-fallback-href="~/lib/bootstrap/dist/css/bootstrap.min.css"
|
||||||
|
asp-fallback-test-class="sr-only" asp-fallback-test-property="position" asp-fallback-test-value="absolute" />
|
||||||
|
<link rel="stylesheet" href="~/css/site.min.css" asp-append-version="true" />
|
||||||
|
|
||||||
|
</environment>
|
||||||
|
</head>
|
||||||
|
<body class="site-home" id="LAY_home" style="background-color: #fff;" data-date="12-27">
|
||||||
|
<div class="layui-header header header-index" winter="">
|
||||||
|
<div class="layui-main">
|
||||||
|
<a class="logo" href="/">
|
||||||
|
@*<img src="//res.layui.com/static/images/layui/logo.png" alt="layui">*@
|
||||||
|
<span style="font-size:25px; letter-spacing:1px; color:#fff;">FreeSql</span>
|
||||||
|
</a>
|
||||||
|
<div class="layui-form component">
|
||||||
|
<select lay-search="" lay-filter="component">
|
||||||
|
<option value="">搜索功能</option>
|
||||||
|
<option value="element/layout.html">实体</option>
|
||||||
|
<option value="element/layout.html#admin">查询</option>
|
||||||
|
<option value="element/color.html">联表之一:使用导航属性</option>
|
||||||
|
<option value="element/icon.html">联表之二:无导航属性</option>
|
||||||
|
<option value="element/anim.html">联表之三:b, c 条件怎么设?试试这种!</option>
|
||||||
|
<option value="element/button.html">联表之四:原生SQL联表</option>
|
||||||
|
<option value="element/form.html">分组聚合</option>
|
||||||
|
<option value="element/form.html#input">执行SQL返回数据</option>
|
||||||
|
<option value="element/form.html#select">添加</option>
|
||||||
|
<option value="element/form.html#checkbox">执行命令</option>
|
||||||
|
<option value="element/form.html#switch">修改</option>
|
||||||
|
<option value="element/form.html#radio">更新条件</option>
|
||||||
|
<option value="element/form.html#textarea">自定义SQL</option>
|
||||||
|
<option value="element/nav.html">删除</option>
|
||||||
|
<option value="element/nav.html#breadcrumb">表达式函数</option>
|
||||||
|
</select>
|
||||||
|
<div class="layui-form-select">
|
||||||
|
<div class="layui-select-title">
|
||||||
|
<input type="text" placeholder="搜索组件或模块" value="" class="layui-input"><i class="layui-edge"></i>
|
||||||
|
</div>
|
||||||
|
<dl class="layui-anim layui-anim-upbit" style="">
|
||||||
|
<dd lay-value="" class="layui-select-tips layui-this">搜索组件或模块</dd>
|
||||||
|
<dd lay-value="element/layout.html" class="">grid 栅格布局</dd>
|
||||||
|
<dd lay-value="element/layout.html#admin" class="">admin 后台布局</dd>
|
||||||
|
<dd lay-value="element/color.html" class="">color 颜色</dd>
|
||||||
|
<dd lay-value="element/icon.html" class="">iconfont 字体图标</dd>
|
||||||
|
<dd lay-value="element/anim.html" class="">animation 动画</dd>
|
||||||
|
<dd lay-value="element/button.html" class="">button 按钮</dd>
|
||||||
|
<dd lay-value="element/form.html" class="">form 表单组</dd>
|
||||||
|
<dd lay-value="element/form.html#input" class="">input 输入框</dd>
|
||||||
|
<dd lay-value="element/form.html#select" class="">select 下拉选择框</dd>
|
||||||
|
<dd lay-value="element/form.html#checkbox" class="">checkbox 复选框</dd>
|
||||||
|
<dd lay-value="element/form.html#switch" class="">switch 开关</dd>
|
||||||
|
<dd lay-value="element/form.html#radio" class="">radio 单选框</dd>
|
||||||
|
<dd lay-value="element/form.html#textarea" class="">textarea 文本域</dd>
|
||||||
|
<dd lay-value="element/nav.html" class="">nav 导航菜单</dd>
|
||||||
|
<dd lay-value="element/nav.html#breadcrumb" class="">breadcrumb 面包屑</dd>
|
||||||
|
<dd lay-value="element/tab.html" class="">tabs 选项卡</dd>
|
||||||
|
<dd lay-value="element/progress.html" class="">progress 进度条</dd>
|
||||||
|
<dd lay-value="element/collapse.html" class="">collapse 折叠面板/手风琴</dd>
|
||||||
|
<dd lay-value="element/table.html" class="">table 表格元素</dd>
|
||||||
|
<dd lay-value="element/badge.html" class="">badge 徽章</dd>
|
||||||
|
<dd lay-value="element/timeline.html" class="">timeline 时间线</dd>
|
||||||
|
<dd lay-value="element/auxiliar.html#blockquote" class="">blockquote 引用块</dd>
|
||||||
|
<dd lay-value="element/auxiliar.html#fieldset" class="">fieldset 字段集</dd>
|
||||||
|
<dd lay-value="element/auxiliar.html#hr" class="">hr 分割线</dd>
|
||||||
|
<dd lay-value="modules/layer.html" class="">layer 弹出层/弹窗综合</dd>
|
||||||
|
<dd lay-value="modules/laydate.html" class="">laydate 日期时间选择器</dd>
|
||||||
|
<dd lay-value="modules/layim.html" class="">layim 即时通讯/聊天</dd>
|
||||||
|
<dd lay-value="modules/laypage.html" class="">laypage 分页</dd>
|
||||||
|
<dd lay-value="modules/laytpl.html" class="">laytpl 模板引擎</dd>
|
||||||
|
<dd lay-value="modules/form.html" class="">form 表单模块</dd>
|
||||||
|
<dd lay-value="modules/table.html" class="">table 数据表格</dd>
|
||||||
|
<dd lay-value="modules/upload.html" class="">upload 文件/图片上传</dd>
|
||||||
|
<dd lay-value="modules/element.html" class="">element 常用元素操作</dd>
|
||||||
|
<dd lay-value="modules/rate.html" class="">rate 评分</dd>
|
||||||
|
<dd lay-value="modules/colorpicker.html" class="">colorpicker 颜色选择器</dd>
|
||||||
|
<dd lay-value="modules/slider.html" class="">slider 滑块</dd>
|
||||||
|
<dd lay-value="modules/carousel.html" class="">carousel 轮播/跑马灯</dd>
|
||||||
|
<dd lay-value="modules/layedit.html" class="">layedit 富文本编辑器</dd>
|
||||||
|
<dd lay-value="modules/tree.html" class="">tree 树形菜单</dd>
|
||||||
|
<dd lay-value="modules/flow.html" class="">flow 信息流/图片懒加载</dd>
|
||||||
|
<dd lay-value="modules/util.html" class="">util 工具集</dd>
|
||||||
|
<dd lay-value="modules/code.html" class="">code 代码修饰</dd>
|
||||||
|
</dl>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<ul class="layui-nav">
|
||||||
|
<li class="layui-nav-item ">
|
||||||
|
<a href="/doc/documents/" target="_self">文档<!-- <span class="layui-badge-dot"></span> --></a>
|
||||||
|
</li>
|
||||||
|
<li class="layui-nav-item ">
|
||||||
|
<a href="/example/main/" target="_self">示例<!-- <span class="layui-badge-dot"></span> --></a>
|
||||||
|
</li>
|
||||||
|
<li class="layui-nav-item layui-hide-xs">
|
||||||
|
<a href="/bbs/bbscontent/" target="_self">社区</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
@*<li class="layui-nav-item">
|
||||||
|
<a href="javascript:;"><span class="layui-badge-dot" style="margin: -5px 0 0 -15px;"></span>周边<span class="layui-nav-more"></span></a>
|
||||||
|
<dl class="layui-nav-child layui-anim layui-anim-upbit">
|
||||||
|
<dd lay-unselect="">
|
||||||
|
<a href="//fly.layui.com/extend/" target="_blank">扩展组件</a>
|
||||||
|
</dd>
|
||||||
|
<dd lay-unselect="">
|
||||||
|
<a href="//fly.layui.com/store/" target="_blank">模板市场 <span class="layui-badge-dot"></span></a>
|
||||||
|
<hr>
|
||||||
|
</dd>
|
||||||
|
|
||||||
|
<dd class="layui-hide-sm layui-show-xs" lay-unselect="">
|
||||||
|
<a href="//fly.layui.com/" target="_blank">社区交流</a>
|
||||||
|
<hr>
|
||||||
|
</dd>
|
||||||
|
<dd lay-unselect=""><a href="/admin/" target="_blank">后台模板</a></dd>
|
||||||
|
<dd lay-unselect=""><a href="/layim/" target="_blank">即时聊天</a><hr></dd>
|
||||||
|
|
||||||
|
<dd lay-unselect=""><a href="/alone.html" target="_blank" lay-unselect="">独立组件</a></dd>
|
||||||
|
<dd lay-unselect=""><a href="#" target="_blank">Axure 组件</a></dd>
|
||||||
|
</dl>
|
||||||
|
</li>*@
|
||||||
|
|
||||||
|
<li class="layui-nav-item layui-hide-xs" lay-unselect="">
|
||||||
|
<a href="/Example/Template">模板下载<span class="layui-badge-dot" style="margin-top: -5px;"></span></a>
|
||||||
|
</li>
|
||||||
|
<span class="layui-nav-bar" style="left: 54px; top: 55px; width: 0px; opacity: 0;"></span>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<partial name="_CookieConsentPartial" />
|
||||||
|
|
||||||
|
<div class="container body-content">
|
||||||
|
@RenderBody()
|
||||||
|
<div class="layui-footer footer footer-index">
|
||||||
|
<div class="layui-main">
|
||||||
|
<p>© 2018 <a href="/">FreeSql.com</a> MIT license</p>
|
||||||
|
<p>
|
||||||
|
<a href="#" target="_blank">案例</a>
|
||||||
|
<a href="#" target="_blank">支持</a>
|
||||||
|
<a href="#" target="_blank" rel="nofollow">GitHub</a>
|
||||||
|
<a href="#" target="_blank" rel="nofollow">码云</a>
|
||||||
|
<a href="#" target="_blank">公众号</a>
|
||||||
|
<a href="#" target="_blank" rel="nofollow">赣ICP备xxxxxxx号-2</a>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<environment include="Development">
|
||||||
|
@*<script src="~/js/site.js" asp-append-version="true"></script>*@
|
||||||
|
<script src="~/layui/layui.js"></script>
|
||||||
|
<script>
|
||||||
|
layui.config({
|
||||||
|
base: '/layui/lay/modules/'
|
||||||
|
, version: '31111'
|
||||||
|
}).use('global');
|
||||||
|
|
||||||
|
window.global = {
|
||||||
|
preview: function () {
|
||||||
|
var preview = document.getElementById('LAY_preview');
|
||||||
|
return preview ? preview.innerHTML : '';
|
||||||
|
}()
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
</environment>
|
||||||
|
<environment exclude="Development">
|
||||||
|
<script src="https://ajax.aspnetcdn.com/ajax/jquery/jquery-3.3.1.min.js"
|
||||||
|
asp-fallback-src="~/lib/jquery/dist/jquery.min.js"
|
||||||
|
asp-fallback-test="window.jQuery"
|
||||||
|
crossorigin="anonymous"
|
||||||
|
integrity="sha384-tsQFqpEReu7ZLhBV2VZlAu7zcOV+rXbYlF2cqB8txI/8aZajjp4Bqd+V6D5IgvKT">
|
||||||
|
</script>
|
||||||
|
<script src="https://ajax.aspnetcdn.com/ajax/bootstrap/3.3.7/bootstrap.min.js"
|
||||||
|
asp-fallback-src="~/lib/bootstrap/dist/js/bootstrap.min.js"
|
||||||
|
asp-fallback-test="window.jQuery && window.jQuery.fn && window.jQuery.fn.modal"
|
||||||
|
crossorigin="anonymous"
|
||||||
|
integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa">
|
||||||
|
</script>
|
||||||
|
<script src="~/js/site.min.js" asp-append-version="true"></script>
|
||||||
|
</environment>
|
||||||
|
|
||||||
|
@RenderSection("Scripts", required: false)
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -0,0 +1,18 @@
|
|||||||
|
<environment include="Development">
|
||||||
|
<script src="~/lib/jquery-validation/dist/jquery.validate.js"></script>
|
||||||
|
<script src="~/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.js"></script>
|
||||||
|
</environment>
|
||||||
|
<environment exclude="Development">
|
||||||
|
<script src="https://ajax.aspnetcdn.com/ajax/jquery.validate/1.17.0/jquery.validate.min.js"
|
||||||
|
asp-fallback-src="~/lib/jquery-validation/dist/jquery.validate.min.js"
|
||||||
|
asp-fallback-test="window.jQuery && window.jQuery.validator"
|
||||||
|
crossorigin="anonymous"
|
||||||
|
integrity="sha384-rZfj/ogBloos6wzLGpPkkOr/gpkBNLZ6b6yLy4o+ok+t/SAKlL5mvXLr0OXNi1Hp">
|
||||||
|
</script>
|
||||||
|
<script src="https://ajax.aspnetcdn.com/ajax/jquery.validation.unobtrusive/3.2.9/jquery.validate.unobtrusive.min.js"
|
||||||
|
asp-fallback-src="~/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.min.js"
|
||||||
|
asp-fallback-test="window.jQuery && window.jQuery.validator && window.jQuery.validator.unobtrusive"
|
||||||
|
crossorigin="anonymous"
|
||||||
|
integrity="sha384-ifv0TYDWxBHzvAk2Z0n8R434FL1Rlv/Av18DXE43N/1rvHyOG4izKst0f2iSLdds">
|
||||||
|
</script>
|
||||||
|
</environment>
|
@ -0,0 +1,4 @@
|
|||||||
|
@using FreeSql.Site.UI
|
||||||
|
@using FreeSql.Site.UI.Models
|
||||||
|
@using FreeSql.Site.UI.Common
|
||||||
|
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
|
3
Examples/website/FreeSql.Site.UI/Views/_ViewStart.cshtml
Normal file
3
Examples/website/FreeSql.Site.UI/Views/_ViewStart.cshtml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
@{
|
||||||
|
Layout = "_Layout";
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
{
|
||||||
|
"ConnectionStrings": {
|
||||||
|
"DefaultDbContext": "Data Source=127.0.0.1;Port=3307;User ID=root;Password=abc123456;Database=FreeSqlTest;Charset=utf8;SslMode=none;Max pool size=10"
|
||||||
|
},
|
||||||
|
"DbContexts": {
|
||||||
|
"SqlServer": {
|
||||||
|
"ConnectionString": "Data Source=127.0.0.1;Port=3307;User ID=root;Password=abc123456;Database=FreeSqlTest;Charset=utf8;SslMode=none;Max pool size=10",
|
||||||
|
"IsAutoMigration": true
|
||||||
|
},
|
||||||
|
"MySql": {
|
||||||
|
"ConnectionString": "Data Source=127.0.0.1;Port=3307;User ID=root;Password=abc123456;Database=FreeSqlTest;Charset=utf8;SslMode=none;Max pool size=10",
|
||||||
|
"IsAutoMigration": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Logging": {
|
||||||
|
"LogLevel": {
|
||||||
|
"Default": "Debug",
|
||||||
|
"System": "Information",
|
||||||
|
"Microsoft": "Information"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
8
Examples/website/FreeSql.Site.UI/appsettings.json
Normal file
8
Examples/website/FreeSql.Site.UI/appsettings.json
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"Logging": {
|
||||||
|
"LogLevel": {
|
||||||
|
"Default": "Warning"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"AllowedHosts": "*"
|
||||||
|
}
|
43
Examples/website/FreeSql.Site.UI/wwwroot/css/admin.css
Normal file
43
Examples/website/FreeSql.Site.UI/wwwroot/css/admin.css
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
|
||||||
|
.layui-layer-content {
|
||||||
|
padding: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.layui-form-label {
|
||||||
|
width: 80px;
|
||||||
|
font-weight:bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.layui-input, .layui-textarea {
|
||||||
|
display: block;
|
||||||
|
width: 100%;
|
||||||
|
padding-left: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-module-content {
|
||||||
|
border: 0px solid red;
|
||||||
|
overflow: auto;
|
||||||
|
/*height: 548px;*/
|
||||||
|
height: 80%;
|
||||||
|
padding: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-module-footer {
|
||||||
|
border: 0px solid red;
|
||||||
|
height: 55px;
|
||||||
|
width: 100%;
|
||||||
|
position: absolute;
|
||||||
|
border-top: 5px solid #e8e8e8;
|
||||||
|
/*border-bottom: 5px solid #dedede;*/
|
||||||
|
left: 0;
|
||||||
|
bottom: 0px;
|
||||||
|
width: 100%;
|
||||||
|
text-align: right;
|
||||||
|
z-index: 100;
|
||||||
|
padding: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-module-footer button {
|
||||||
|
margin-right: 10px;
|
||||||
|
margin-top: 10px;
|
||||||
|
}
|
1
Examples/website/FreeSql.Site.UI/wwwroot/css/admin.min.css
vendored
Normal file
1
Examples/website/FreeSql.Site.UI/wwwroot/css/admin.min.css
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
body{padding-top:50px;padding-bottom:20px}.body-content{padding-left:15px;padding-right:15px}.carousel-caption p{font-size:20px;line-height:1.4}.carousel-inner .item img[src$=".svg"]{width:100%}#qrCode{margin:15px}@media screen and (max-width:767px){.carousel-caption{display:none}}
|
1819
Examples/website/FreeSql.Site.UI/wwwroot/css/site.css
Normal file
1819
Examples/website/FreeSql.Site.UI/wwwroot/css/site.css
Normal file
File diff suppressed because it is too large
Load Diff
1
Examples/website/FreeSql.Site.UI/wwwroot/css/site.min.css
vendored
Normal file
1
Examples/website/FreeSql.Site.UI/wwwroot/css/site.min.css
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
body{padding-top:50px;padding-bottom:20px}.body-content{padding-left:15px;padding-right:15px}.carousel-caption p{font-size:20px;line-height:1.4}.carousel-inner .item img[src$=".svg"]{width:100%}#qrCode{margin:15px}@media screen and (max-width:767px){.carousel-caption{display:none}}
|
95
Examples/website/FreeSql.Site.UI/wwwroot/demo1.json
Normal file
95
Examples/website/FreeSql.Site.UI/wwwroot/demo1.json
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
{
|
||||||
|
"code": 0
|
||||||
|
,"msg": ""
|
||||||
|
,"count": 3000000
|
||||||
|
,"data": [{
|
||||||
|
"id": "10001"
|
||||||
|
,"username": "杜甫"
|
||||||
|
,"email": "xianxin@layui.com"
|
||||||
|
,"sex": "男"
|
||||||
|
,"city": "浙江杭州"
|
||||||
|
,"sign": "点击此处,显示更多。当内容超出时,点击单元格会自动显示更多内容。"
|
||||||
|
,"experience": "116"
|
||||||
|
,"ip": "192.168.0.8"
|
||||||
|
,"logins": "108"
|
||||||
|
,"joinTime": "2016-10-14"
|
||||||
|
}, {
|
||||||
|
"id": "10002"
|
||||||
|
,"username": "李白"
|
||||||
|
,"email": "xianxin@layui.com"
|
||||||
|
,"sex": "男"
|
||||||
|
,"city": "浙江杭州"
|
||||||
|
,"sign": "君不见,黄河之水天上来,奔流到海不复回。 君不见,高堂明镜悲白发,朝如青丝暮成雪。 人生得意须尽欢,莫使金樽空对月。 天生我材必有用,千金散尽还复来。 烹羊宰牛且为乐,会须一饮三百杯。 岑夫子,丹丘生,将进酒,杯莫停。 与君歌一曲,请君为我倾耳听。(倾耳听 一作:侧耳听) 钟鼓馔玉不足贵,但愿长醉不复醒。(不足贵 一作:何足贵;不复醒 一作:不愿醒/不用醒) 古来圣贤皆寂寞,惟有饮者留其名。(古来 一作:自古;惟 通:唯) 陈王昔时宴平乐,斗酒十千恣欢谑。 主人何为言少钱,径须沽取对君酌。 五花马,千金裘,呼儿将出换美酒,与尔同销万古愁。"
|
||||||
|
,"experience": "12"
|
||||||
|
,"ip": "192.168.0.8"
|
||||||
|
,"logins": "106"
|
||||||
|
,"joinTime": "2016-10-14"
|
||||||
|
,"LAY_CHECKED": true
|
||||||
|
}, {
|
||||||
|
"id": "10003"
|
||||||
|
,"username": "王勃"
|
||||||
|
,"email": "xianxin@layui.com"
|
||||||
|
,"sex": "男"
|
||||||
|
,"city": "浙江杭州"
|
||||||
|
,"sign": "人生恰似一场修行"
|
||||||
|
,"experience": "65"
|
||||||
|
,"ip": "192.168.0.8"
|
||||||
|
,"logins": "106"
|
||||||
|
,"joinTime": "2016-10-14"
|
||||||
|
}, {
|
||||||
|
"id": "10004"
|
||||||
|
,"username": "李清照"
|
||||||
|
,"email": "xianxin@layui.com"
|
||||||
|
,"sex": "女"
|
||||||
|
,"city": "浙江杭州"
|
||||||
|
,"sign": "人生恰似一场修行"
|
||||||
|
,"experience": "666"
|
||||||
|
,"ip": "192.168.0.8"
|
||||||
|
,"logins": "106"
|
||||||
|
,"joinTime": "2016-10-14"
|
||||||
|
}, {
|
||||||
|
"id": "10005"
|
||||||
|
,"username": "冰心"
|
||||||
|
,"email": "xianxin@layui.com"
|
||||||
|
,"sex": "女"
|
||||||
|
,"city": "浙江杭州"
|
||||||
|
,"sign": "人生恰似一场修行"
|
||||||
|
,"experience": "86"
|
||||||
|
,"ip": "192.168.0.8"
|
||||||
|
,"logins": "106"
|
||||||
|
,"joinTime": "2016-10-14"
|
||||||
|
}, {
|
||||||
|
"id": "10006"
|
||||||
|
,"username": "贤心"
|
||||||
|
,"email": "xianxin@layui.com"
|
||||||
|
,"sex": "男"
|
||||||
|
,"city": "浙江杭州"
|
||||||
|
,"sign": "人生恰似一场修行"
|
||||||
|
,"experience": "12"
|
||||||
|
,"ip": "192.168.0.8"
|
||||||
|
,"logins": "106"
|
||||||
|
,"joinTime": "2016-10-14"
|
||||||
|
}, {
|
||||||
|
"id": "10007"
|
||||||
|
,"username": "贤心"
|
||||||
|
,"email": "xianxin@layui.com"
|
||||||
|
,"sex": "男"
|
||||||
|
,"city": "浙江杭州"
|
||||||
|
,"sign": "人生恰似一场修行"
|
||||||
|
,"experience": "16"
|
||||||
|
,"ip": "192.168.0.8"
|
||||||
|
,"logins": "106"
|
||||||
|
,"joinTime": "2016-10-14"
|
||||||
|
}, {
|
||||||
|
"id": "10008"
|
||||||
|
,"username": "贤心"
|
||||||
|
,"email": "xianxin@layui.com"
|
||||||
|
,"sex": "男"
|
||||||
|
,"city": "浙江杭州"
|
||||||
|
,"sign": "人生恰似一场修行"
|
||||||
|
,"experience": "106"
|
||||||
|
,"ip": "192.168.0.8"
|
||||||
|
,"logins": "106"
|
||||||
|
,"joinTime": "2016-10-14"
|
||||||
|
}]
|
||||||
|
}
|
BIN
Examples/website/FreeSql.Site.UI/wwwroot/favicon.ico
Normal file
BIN
Examples/website/FreeSql.Site.UI/wwwroot/favicon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 31 KiB |
129
Examples/website/FreeSql.Site.UI/wwwroot/file/codefirst.md
Normal file
129
Examples/website/FreeSql.Site.UI/wwwroot/file/codefirst.md
Normal file
@ -0,0 +1,129 @@
|
|||||||
|
# CodeFirst
|
||||||
|
|
||||||
|
| 数据库 | 支持的类型类型 |
|
||||||
|
| - | - |
|
||||||
|
| MySql | bool, sbyte, short, int, long, byte, ushort, uint, ulong, double, float, decimal, Guid, TimeSpan, DateTime<br>bool?, sbyte?, short?, int?, long?, byte?, ushort?, uint?, ulong?, double?, float?, decimal?, Guid?, TimeSpan?, DateTime?<br>byte[], string, Enum & FlagsEnum<br>MygisPoint, MygisLineString, MygisPolygon, MygisMultiPoint, MygisMultiLineString, MygisMultiPolygon |
|
||||||
|
| SqlServer | bool, sbyte, short, int, long, byte, ushort, uint, ulong, double, float, decimal, Guid, TimeSpan, DateTime, DateTimeOffset<br>bool?, sbyte?, short?, int?, long?, byte?, ushort?, uint?, ulong?, double?, float?, decimal?, Guid?, TimeSpan?, DateTime?, DateTimeOffset?<br>byte[], string, Enum & FlagsEnum |
|
||||||
|
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
IFreeSql fsql = new FreeSql.FreeSqlBuilder()
|
||||||
|
.UseConnectionString(FreeSql.DataType.MySql, "Data Source=127.0.0.1;Port=3306;User ID=root;Password=root;Initial Catalog=cccddd;Charset=utf8;SslMode=none;Max pool size=10")
|
||||||
|
.Build();
|
||||||
|
```
|
||||||
|
|
||||||
|
### 自动同步实体结构【开发环境必备】
|
||||||
|
|
||||||
|
自动同步实体结构到数据库,程序运行中检查实体表是否存在,然后创建或修改
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
fsql.CodeFirst.IsAutoSyncDataStructure = true;
|
||||||
|
```
|
||||||
|
|
||||||
|
> 此功能默认为开启状态,发布正式环境后,请修改此设置
|
||||||
|
|
||||||
|
> 虽然【自动同步实体结构】功能开发非常好用,但是有个坏处,就是数据库后面会很乱,没用的字段一大堆
|
||||||
|
|
||||||
|
### 手工同步实体结构
|
||||||
|
|
||||||
|
| 实体&表对比 | 添加 | 改名 | 删除 |
|
||||||
|
| - | - | - | - |
|
||||||
|
| | √ | √ | X |
|
||||||
|
|
||||||
|
| 实体属性&字段对比 | 添加 | 修改可空 | 修改自增 | 修改类型 | 改名 | 删除 |
|
||||||
|
| - | - | - | - | - | - | - |
|
||||||
|
| | √ | √ | √ | √ | √ | X |
|
||||||
|
|
||||||
|
> 为了保证安全,不提供删除字段
|
||||||
|
|
||||||
|
|
||||||
|
1、提供方法对比实体,与数据库中的变化部分
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
var t1 = mysql.CodeFirst.GetComparisonDDLStatements<Topic>();
|
||||||
|
|
||||||
|
class Topic {
|
||||||
|
[Column(IsIdentity = true, IsPrimary = true)]
|
||||||
|
public int Id { get; set; }
|
||||||
|
public int Clicks { get; set; }
|
||||||
|
public TestTypeInfo Type { get; set; }
|
||||||
|
public string Title { get; set; }
|
||||||
|
public DateTime CreateTime { get; set; }
|
||||||
|
public ushort fusho { get; set; }
|
||||||
|
}
|
||||||
|
```
|
||||||
|
```sql
|
||||||
|
CREATE TABLE IF NOT EXISTS `cccddd`.`Topic` (
|
||||||
|
`Id` INT(11) NOT NULL AUTO_INCREMENT,
|
||||||
|
`Clicks` INT(11) NOT NULL,
|
||||||
|
`Title` VARCHAR(255),
|
||||||
|
`CreateTime` DATETIME NOT NULL,
|
||||||
|
`fusho` SMALLINT(5) UNSIGNED NOT NULL,
|
||||||
|
PRIMARY KEY (`Id`)
|
||||||
|
) Engine=InnoDB CHARACTER SET utf8;
|
||||||
|
```
|
||||||
|
|
||||||
|
2、指定实体的表名
|
||||||
|
|
||||||
|
指定 Name 后,实体类名变化不影响数据库对应的表
|
||||||
|
```csharp
|
||||||
|
[Table(Name = "tb_topic111")]
|
||||||
|
class Topic {
|
||||||
|
//...
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
3、无指定实体的表名,修改实体类名
|
||||||
|
|
||||||
|
指定数据库旧的表名,修改实体命名时,同时设置此参数为修改之前的值,CodeFirst才可以正确修改数据库表;否则将视为【创建新表】
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
[Table(OldName = "Topic")]
|
||||||
|
class Topic2 {
|
||||||
|
//...
|
||||||
|
}
|
||||||
|
```
|
||||||
|
```sql
|
||||||
|
ALTER TABLE `cccddd`.`Topic` RENAME TO `cccddd`.`Topic2`;
|
||||||
|
```
|
||||||
|
|
||||||
|
4、修改属性的类型
|
||||||
|
|
||||||
|
把 Id 类型改为 uint 后
|
||||||
|
```sql
|
||||||
|
ALTER TABLE `cccddd`.`Topic2` MODIFY `Id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT;
|
||||||
|
```
|
||||||
|
```csharp
|
||||||
|
[Column(DbType = "varchar(128)")]
|
||||||
|
public string Title { get; set; }
|
||||||
|
```
|
||||||
|
```sql
|
||||||
|
ALTER TABLE `cccddd`.`Topic2` MODIFY `Title2` VARCHAR(128);
|
||||||
|
```
|
||||||
|
|
||||||
|
5、指定属性的字段名
|
||||||
|
|
||||||
|
这样指定后,修改实体的属性名不影响数据库对应的列
|
||||||
|
```csharp
|
||||||
|
[Column(Name = "titl2")]
|
||||||
|
public string Title { get; set; }
|
||||||
|
```
|
||||||
|
|
||||||
|
6、无指定属性的字段名,修改属性名
|
||||||
|
|
||||||
|
指定数据库旧的列名,修改实体属性命名时,同时设置此参数为修改之前的值,CodeFirst才可以正确修改数据库字段;否则将视为【新增字段】
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
[Column(OldName = "Title2")]
|
||||||
|
public string Title { get; set; }
|
||||||
|
```
|
||||||
|
```sql
|
||||||
|
ALTER TABLE `cccddd`.`Topic2` CHANGE COLUMN `Title2` `Title` VARCHAR(255);
|
||||||
|
```
|
||||||
|
|
||||||
|
7、提供方法同步结构
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
var t2 = fsql.CodeFirst.SyncStructure<Topic>();
|
||||||
|
//同步实体类型到数据库
|
||||||
|
```
|
109
Examples/website/FreeSql.Site.UI/wwwroot/file/dbfirst.md
Normal file
109
Examples/website/FreeSql.Site.UI/wwwroot/file/dbfirst.md
Normal file
@ -0,0 +1,109 @@
|
|||||||
|
# DbFirst
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
IFreeSql fsql = new FreeSql.FreeSqlBuilder()
|
||||||
|
.UseConnectionString(FreeSql.DataType.MySql, "Data Source=127.0.0.1;Port=3306;User ID=root;Password=root;Initial Catalog=cccddd;Charset=utf8;SslMode=none;Max pool size=10")
|
||||||
|
.Build();
|
||||||
|
```
|
||||||
|
|
||||||
|
### 获取所有数据库
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
var t1 = fsql.DbFirst.GetDatabases();
|
||||||
|
//返回字符串数组, ["cccddd", "test"]
|
||||||
|
```
|
||||||
|
|
||||||
|
### 获取指定数据库的表信息
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
var t2 = fsql.DbFirst.GetTablesByDatabase(fsql.DbFirst.GetDatabases()[0]);
|
||||||
|
//返回包括表、列详情、主键、唯一键、索引、外键
|
||||||
|
```
|
||||||
|
|
||||||
|
# 生成器
|
||||||
|
|
||||||
|
生成器是基于 dbfirst 开发的辅助工具,适用老项目一键生成实体。生成器采用模板的方式,作者实现了三种生成模板:
|
||||||
|
|
||||||
|
| 模板名称 | 路径 | 类型映射 | 外键导航属性 | 缓存管理 | 失血 | 贫血 | 充血 |
|
||||||
|
| ------------- | - | - |- | - |- | - |- |
|
||||||
|
| simple-entity | ../Templates/MySql/simple-entity | √ | X | X | √ | X | X |
|
||||||
|
| simple-entity-navigation-object | ../Templates/MySql/simple-entity-navigation-object | √ | √ | X | √ | X | X |
|
||||||
|
| rich-entity-navigation-object | ../Templates/MySql/rich-entity-navigation-object | √ | √ | √ | X | √ | X |
|
||||||
|
|
||||||
|
> 更多模板逐步开发中。。。
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
//创建模板生成类现实
|
||||||
|
var gen = new FreeSql.Generator.TemplateGenerator();
|
||||||
|
gen.Build(fsql.DbFirst,
|
||||||
|
@"C:\Users\28810\Desktop\github\FreeSql\Templates\MySql\simple-entity", //模板目录(事先下载)
|
||||||
|
@"C:\Users\28810\Desktop\新建文件夹 (9)", //生成后保存的目录
|
||||||
|
"cccddd" //数据库
|
||||||
|
);
|
||||||
|
```
|
||||||
|
|
||||||
|
## 模板语法
|
||||||
|
|
||||||
|
```html
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>{#title}</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<!--绑定表达式-->
|
||||||
|
{#表达式}
|
||||||
|
{##表达式} 当表达式可能发生runtime错误时使用,性能没有上面的高
|
||||||
|
|
||||||
|
<!--可嵌套使用,同一标签最多支持3个指令-->
|
||||||
|
{include ../header.html}
|
||||||
|
<div @for="i 1, 101">
|
||||||
|
<p @if="i === 50" @for="item,index in data">aaa</p>
|
||||||
|
<p @else="i % 3 === 0">bbb {#i}</p>
|
||||||
|
<p @else="">ccc {#i}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!--定义模块,可以将公共模块定义到一个文件中-->
|
||||||
|
{module module_name1 parms1, 2, 3...}
|
||||||
|
{/module}
|
||||||
|
{module module_name2 parms1, 2, 3...}
|
||||||
|
{/module}
|
||||||
|
|
||||||
|
<!--使用模块-->
|
||||||
|
{import ../module.html as myname}
|
||||||
|
{#myname.module_name(parms1, 2, 3...)}
|
||||||
|
|
||||||
|
<!--继承-->
|
||||||
|
{extends ../inc/layout.html}
|
||||||
|
{block body}{/block}
|
||||||
|
|
||||||
|
<!--嵌入代码块-->
|
||||||
|
{%
|
||||||
|
for (var a = 0; a < 100; a++)
|
||||||
|
print(a);
|
||||||
|
%}
|
||||||
|
|
||||||
|
<!--条件分支-->
|
||||||
|
{if i === 50}
|
||||||
|
{elseif i > 60}
|
||||||
|
{else}
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
<!--三种循环-->
|
||||||
|
{for i 1,101} 可自定义名 {for index2 表达式1 in 表达式2}
|
||||||
|
|
||||||
|
{for item,index in items} 可选参数称 index
|
||||||
|
可自定义名 {for item2, index99 in 数组表达式}
|
||||||
|
|
||||||
|
{for key,item,index on json} 可选参数 item, index,
|
||||||
|
可自定义名 {for key2, item2, index99 in 对象表达式}
|
||||||
|
{/for}
|
||||||
|
|
||||||
|
<!--不被解析-->
|
||||||
|
{miss}
|
||||||
|
此块内容不被bmw.js解析
|
||||||
|
{/miss}
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
```
|
82
Examples/website/FreeSql.Site.UI/wwwroot/file/delete.md
Normal file
82
Examples/website/FreeSql.Site.UI/wwwroot/file/delete.md
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
# 删除数据
|
||||||
|
|
||||||
|
| 方法 | 返回值 | 参数 | 描述 |
|
||||||
|
| - | - | - | - |
|
||||||
|
| Where | \<this\> | Lambda | 表达式条件,仅支持实体基础成员(不包含导航对象) |
|
||||||
|
| Where | \<this\> | string, parms | 原生sql语法条件,Where("id = ?id", new { id = 1 }) |
|
||||||
|
| Where | \<this\> | T1 \| IEnumerable<T1> | 传入实体或集合,将其主键作为条件 |
|
||||||
|
| WhereExists | \<this\> | ISelect | 子查询是否存在 |
|
||||||
|
| ToSql | string | | 返回即将执行的SQL语句 |
|
||||||
|
| ExecuteAffrows | long | | 执行SQL语句,返回影响的行数 |
|
||||||
|
| ExecuteDeleted | List\<T1\> | | 执行SQL语句,返回被删除的记录 |
|
||||||
|
|
||||||
|
### 测试代码
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
IFreeSql fsql = new FreeSql.FreeSqlBuilder()
|
||||||
|
.UseConnectionString(FreeSql.DataType.MySql, "Data Source=127.0.0.1;Port=3306;User ID=root;Password=root;Initial Catalog=cccddd;Charset=utf8;SslMode=none;Max pool size=10")
|
||||||
|
.Build();
|
||||||
|
IDelete<Topic> delete => fsql.Delete<Topic>();
|
||||||
|
|
||||||
|
[Table(Name = "tb_topic")]
|
||||||
|
class Topic {
|
||||||
|
[Column(IsIdentity = true, IsPrimary = true)]
|
||||||
|
public int Id { get; set; }
|
||||||
|
public int Clicks { get; set; }
|
||||||
|
public TestTypeInfo Type { get; set; }
|
||||||
|
public string Title { get; set; }
|
||||||
|
public DateTime CreateTime { get; set; }
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### 动态条件
|
||||||
|
```csharp
|
||||||
|
Delete<Topic>(object dywhere)
|
||||||
|
```
|
||||||
|
dywhere 支持
|
||||||
|
|
||||||
|
* 主键值
|
||||||
|
* new[] { 主键值1, 主键值2 }
|
||||||
|
* Topic对象
|
||||||
|
* new[] { Topic对象1, Topic对象2 }
|
||||||
|
* new { id = 1 }
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
var t1 = fsql.Delete<Topic>(new[] { 1, 2 }).ToSql();
|
||||||
|
//DELETE FROM `tb_topic` WHERE (`Id` = 1 OR `Id` = 2)
|
||||||
|
|
||||||
|
var t2 = fsql.Delete<Topic>(new Topic { Id = 1, Title = "test" }).ToSql();
|
||||||
|
//DELETE FROM `tb_topic` WHERE (`Id` = 1)
|
||||||
|
|
||||||
|
var t3 = fsql.Delete<Topic>(new[] { new Topic { Id = 1, Title = "test" }, new Topic { Id = 2, Title = "test" } }).ToSql();
|
||||||
|
//DELETE FROM `tb_topic` WHERE (`Id` = 1 OR `Id` = 2)
|
||||||
|
|
||||||
|
var t4 = fsql.Delete<Topic>(new { id = 1 }).ToSql();
|
||||||
|
//DELETE FROM `tb_topic` WHERE (`Id` = 1)
|
||||||
|
```
|
||||||
|
|
||||||
|
### 删除条件
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
var t5 = delete.Where(a => a.Id == 1).ToSql().Replace("\r\n", "");
|
||||||
|
//DELETE FROM `tb_topic` WHERE (`Id` = 1)
|
||||||
|
|
||||||
|
var t6 = delete.Where("id = ?id", new { id = 1 }).ToSql().Replace("\r\n", "");
|
||||||
|
//DELETE FROM `tb_topic` WHERE (id = ?id)
|
||||||
|
|
||||||
|
var item = new Topic { Id = 1, Title = "newtitle" };
|
||||||
|
var t7 = delete.Where(item).ToSql().Replace("\r\n", "");
|
||||||
|
//DELETE FROM `tb_topic` WHERE (`Id` = 1)
|
||||||
|
|
||||||
|
var items = new List<Topic>();
|
||||||
|
for (var a = 0; a < 10; a++) items.Add(new Topic { Id = a + 1, Title = $"newtitle{a}", Clicks = a * 100 });
|
||||||
|
var t8 = delete.Where(items).ToSql().Replace("\r\n", "");
|
||||||
|
//DELETE FROM `tb_topic` WHERE (`Id` IN (1,2,3,4,5,6,7,8,9,10))
|
||||||
|
```
|
||||||
|
|
||||||
|
### 执行命令
|
||||||
|
|
||||||
|
| 方法 | 返回值 | 参数 | 描述 |
|
||||||
|
| - | - | - | - |
|
||||||
|
| ExecuteAffrows | long | | 执行SQL语句,返回影响的行数 |
|
||||||
|
| ExecuteDeleted | List\<T1\> | | 执行SQL语句,返回被删除的记录 |
|
94
Examples/website/FreeSql.Site.UI/wwwroot/file/generator.md
Normal file
94
Examples/website/FreeSql.Site.UI/wwwroot/file/generator.md
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
# 生成器
|
||||||
|
|
||||||
|
生成器是基于 dbfirst 开发的辅助工具,适用老项目一键生成实体。生成器采用模板的方式,作者实现了三种生成模板:
|
||||||
|
|
||||||
|
| 模板名称 | 类型映射 | 外键导航属性 | 缓存管理 | 失血 | 贫血 | 充血 |
|
||||||
|
| ------------- | - | - |- | - |- | - |
|
||||||
|
| simple-entity | √ | X | X | √ | X | X |
|
||||||
|
| simple-entity-navigation-object | √ | √ | X | √ | X | X |
|
||||||
|
| rich-entity-navigation-object | √ | √ | √ | X | √ | X |
|
||||||
|
|
||||||
|
模板在项目目录:/Templates/MySql
|
||||||
|
|
||||||
|
> 更多模板逐步开发中。。。
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
//定义 mysql FreeSql
|
||||||
|
var mysql = new FreeSql.FreeSqlBuilder()
|
||||||
|
.UseConnectionString(FreeSql.DataType.MySql, "Data Source=127.0.0.1;Port=3306;User ID=root;Password=root;Initial Catalog=cccddd;Charset=utf8;SslMode=none;Max pool size=10")
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
//创建模板生成类现实
|
||||||
|
var gen = new FreeSql.Generator.TemplateGenerator();
|
||||||
|
gen.Build(mysql.DbFirst,
|
||||||
|
@"C:\Users\28810\Desktop\github\FreeSql\Templates\MySql\simple-entity", //模板目录(事先下载)
|
||||||
|
@"C:\Users\28810\Desktop\新建文件夹 (9)", //生成后保存的目录
|
||||||
|
"cccddd" //数据库
|
||||||
|
);
|
||||||
|
```
|
||||||
|
|
||||||
|
## 模板语法
|
||||||
|
|
||||||
|
```html
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>{#title}</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<!--绑定表达式-->
|
||||||
|
{#表达式}
|
||||||
|
{##表达式} 当表达式可能发生runtime错误时使用,性能没有上面的高
|
||||||
|
|
||||||
|
<!--可嵌套使用,同一标签最多支持3个指令-->
|
||||||
|
{include ../header.html}
|
||||||
|
<div @for="i 1, 101">
|
||||||
|
<p @if="i === 50" @for="item,index in data">aaa</p>
|
||||||
|
<p @else="i % 3 === 0">bbb {#i}</p>
|
||||||
|
<p @else="">ccc {#i}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!--定义模块,可以将公共模块定义到一个文件中-->
|
||||||
|
{module module_name1 parms1, 2, 3...}
|
||||||
|
{/module}
|
||||||
|
{module module_name2 parms1, 2, 3...}
|
||||||
|
{/module}
|
||||||
|
|
||||||
|
<!--使用模块-->
|
||||||
|
{import ../module.html as myname}
|
||||||
|
{#myname.module_name(parms1, 2, 3...)}
|
||||||
|
|
||||||
|
<!--继承-->
|
||||||
|
{extends ../inc/layout.html}
|
||||||
|
{block body}{/block}
|
||||||
|
|
||||||
|
<!--嵌入代码块-->
|
||||||
|
{%
|
||||||
|
for (var a = 0; a < 100; a++)
|
||||||
|
print(a);
|
||||||
|
%}
|
||||||
|
|
||||||
|
<!--条件分支-->
|
||||||
|
{if i === 50}
|
||||||
|
{elseif i > 60}
|
||||||
|
{else}
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
<!--三种循环-->
|
||||||
|
{for i 1,101} 可自定义名 {for index2 表达式1 in 表达式2}
|
||||||
|
|
||||||
|
{for item,index in items} 可选参数称 index
|
||||||
|
可自定义名 {for item2, index99 in 数组表达式}
|
||||||
|
|
||||||
|
{for key,item,index on json} 可选参数 item, index,
|
||||||
|
可自定义名 {for key2, item2, index99 in 对象表达式}
|
||||||
|
{/for}
|
||||||
|
|
||||||
|
<!--不被解析-->
|
||||||
|
{miss}
|
||||||
|
此块内容不被bmw.js解析
|
||||||
|
{/miss}
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
```
|
79
Examples/website/FreeSql.Site.UI/wwwroot/file/insert.md
Normal file
79
Examples/website/FreeSql.Site.UI/wwwroot/file/insert.md
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
# 插入数据
|
||||||
|
|
||||||
|
| 方法 | 返回值 | 参数 | 描述 |
|
||||||
|
| - | - | - | - |
|
||||||
|
| AppendData | \<this\> | T1 \| IEnumerable<T1> | 追加准备插入的实体 |
|
||||||
|
| InsertColumns | \<this\> | Lambda | 只插入的列 |
|
||||||
|
| IgnoreColumns | \<this\> | Lambda | 忽略的列 |
|
||||||
|
| ToSql | string | | 返回即将执行的SQL语句 |
|
||||||
|
| ExecuteAffrows | long | | 执行SQL语句,返回影响的行数 |
|
||||||
|
| ExecuteIdentity | long | | 执行SQL语句,返回自增值 |
|
||||||
|
| ExecuteInserted | List\<T1\> | | 执行SQL语句,返回插入后的记录 |
|
||||||
|
|
||||||
|
### 列优先级
|
||||||
|
|
||||||
|
> 全部列 < 指定列(InsertColumns) < 忽略列(IgnoreColumns)
|
||||||
|
|
||||||
|
### 测试代码
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
IFreeSql fsql = new FreeSql.FreeSqlBuilder()
|
||||||
|
.UseConnectionString(FreeSql.DataType.MySql, "Data Source=127.0.0.1;Port=3306;User ID=root;Password=root;Initial Catalog=cccddd;Charset=utf8;SslMode=none;Max pool size=10")
|
||||||
|
.Build();
|
||||||
|
IInsert<Topic> insert => fsql.Insert<Topic>();
|
||||||
|
|
||||||
|
[Table(Name = "tb_topic")]
|
||||||
|
class Topic {
|
||||||
|
[Column(IsIdentity = true, IsPrimary = true)]
|
||||||
|
public int Id { get; set; }
|
||||||
|
public int Clicks { get; set; }
|
||||||
|
public TestTypeInfo Type { get; set; }
|
||||||
|
public string Title { get; set; }
|
||||||
|
public DateTime CreateTime { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
var items = new List<Topic>();
|
||||||
|
for (var a = 0; a < 10; a++) items.Add(new Topic { Id = a + 1, Title = $"newtitle{a}", Clicks = a * 100 });
|
||||||
|
```
|
||||||
|
|
||||||
|
### 插入
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
var t1 = insert.AppendData(items.First()).ToSql();
|
||||||
|
//INSERT INTO `tb_topic`(`Clicks`, `Title`, `CreateTime`) VALUES(?Clicks0, ?Title0, ?CreateTime0)
|
||||||
|
```
|
||||||
|
|
||||||
|
### 批量插入
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
var t2 = insert.AppendData(items).ToSql();
|
||||||
|
//INSERT INTO `tb_topic`(`Clicks`, `Title`, `CreateTime`) VALUES(?Clicks0, ?Title0, ?CreateTime0), (?Clicks1, ?Title1, ?CreateTime1), (?Clicks2, ?Title2, ?CreateTime2), (?Clicks3, ?Title3, ?CreateTime3), (?Clicks4, ?Title4, ?CreateTime4), (?Clicks5, ?Title5, ?CreateTime5), (?Clicks6, ?Title6, ?CreateTime6), (?Clicks7, ?Title7, ?CreateTime7), (?Clicks8, ?Title8, ?CreateTime8), (?Clicks9, ?Title9, ?CreateTime9)
|
||||||
|
```
|
||||||
|
|
||||||
|
### 只想插入指定的列
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
var t3 = insert.AppendData(items).InsertColumns(a => a.Title).ToSql();
|
||||||
|
//INSERT INTO `tb_topic`(`Title`) VALUES(?Title0), (?Title1), (?Title2), (?Title3), (?Title4), (?Title5), (?Title6), (?Title7), (?Title8), (?Title9)
|
||||||
|
|
||||||
|
var t4 = insert.AppendData(items).InsertColumns(a =>new { a.Title, a.Clicks }).ToSql();
|
||||||
|
//INSERT INTO `tb_topic`(`Clicks`, `Title`) VALUES(?Clicks0, ?Title0), (?Clicks1, ?Title1), (?Clicks2, ?Title2), (?Clicks3, ?Title3), (?Clicks4, ?Title4), (?Clicks5, ?Title5), (?Clicks6, ?Title6), (?Clicks7, ?Title7), (?Clicks8, ?Title8), (?Clicks9, ?Title9)
|
||||||
|
```
|
||||||
|
|
||||||
|
### 忽略列
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
var t5 = insert.AppendData(items).IgnoreColumns(a => a.CreateTime).ToSql();
|
||||||
|
//INSERT INTO `tb_topic`(`Clicks`, `Title`) VALUES(?Clicks0, ?Title0), (?Clicks1, ?Title1), (?Clicks2, ?Title2), (?Clicks3, ?Title3), (?Clicks4, ?Title4), (?Clicks5, ?Title5), (?Clicks6, ?Title6), (?Clicks7, ?Title7), (?Clicks8, ?Title8), (?Clicks9, ?Title9)
|
||||||
|
|
||||||
|
var t6 = insert.AppendData(items).IgnoreColumns(a => new { a.Title, a.CreateTime }).ToSql();
|
||||||
|
///INSERT INTO `tb_topic`(`Clicks`) VALUES(?Clicks0), (?Clicks1), (?Clicks2), (?Clicks3), (?Clicks4), (?Clicks5), (?Clicks6), (?Clicks7), (?Clicks8), (?Clicks9)
|
||||||
|
```
|
||||||
|
|
||||||
|
### 执行命令
|
||||||
|
|
||||||
|
| 方法 | 返回值 | 描述 |
|
||||||
|
| - | - | - |
|
||||||
|
| ExecuteAffrows | long | 执行SQL语句,返回影响的行数 |
|
||||||
|
| ExecuteIdentity | long | 执行SQL语句,返回自增值 |
|
||||||
|
| ExecuteInserted | List\<T1\> | 执行SQL语句,返回插入后的记录 |
|
211
Examples/website/FreeSql.Site.UI/wwwroot/file/select.md
Normal file
211
Examples/website/FreeSql.Site.UI/wwwroot/file/select.md
Normal file
@ -0,0 +1,211 @@
|
|||||||
|
# 查询数据
|
||||||
|
|
||||||
|
## 测试代码
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
IFreeSql fsql = new FreeSql.FreeSqlBuilder()
|
||||||
|
.UseConnectionString(FreeSql.DataType.MySql, "Data Source=127.0.0.1;Port=3306;User ID=root;Password=root;Initial Catalog=cccddd;Charset=utf8;SslMode=none;Max pool size=10")
|
||||||
|
.Build();
|
||||||
|
ISelect<Topic> select => fsql.Select<Topic>();
|
||||||
|
|
||||||
|
[Table(Name = "tb_topic")]
|
||||||
|
class Topic {
|
||||||
|
[Column(IsIdentity = true, IsPrimary = true)]
|
||||||
|
public int Id { get; set; }
|
||||||
|
public int Clicks { get; set; }
|
||||||
|
public int TestTypeInfoGuid { get; set; }
|
||||||
|
public TestTypeInfo Type { get; set; }
|
||||||
|
public string Title { get; set; }
|
||||||
|
public DateTime CreateTime { get; set; }
|
||||||
|
}
|
||||||
|
class TestTypeInfo {
|
||||||
|
public int Guid { get; set; }
|
||||||
|
public int ParentId { get; set; }
|
||||||
|
public TestTypeParentInfo Parent { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
}
|
||||||
|
class TestTypeParentInfo {
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
public List<TestTypeInfo> Types { get; set; }
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
# Where
|
||||||
|
|
||||||
|
### 表达式函数支持
|
||||||
|
|
||||||
|
#### String 对象方法
|
||||||
|
StartsWith, EndsWith, Contains, ToLower, ToUpper, Substring, Length, IndexOf, PadLeft, PadRight, Trim, TrimStart, TrimEnd, Replace, CompareTo
|
||||||
|
|
||||||
|
#### Math 方法
|
||||||
|
...
|
||||||
|
|
||||||
|
### 单表
|
||||||
|
```csharp
|
||||||
|
var sql = select.Where(a => a.Id == 10).ToSql();
|
||||||
|
///SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 FROM `tb_topic` a WHERE (a.`Id` = 10)
|
||||||
|
|
||||||
|
sql = select.Where(a => a.Id == 10 && a.Id > 10 || a.Clicks > 100).ToSql();
|
||||||
|
///SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 FROM `tb_topic` a WHERE (a.`Id` = 10 AND a.`Id` > 10 OR a.`Clicks` > 100)
|
||||||
|
```
|
||||||
|
|
||||||
|
### 多表,使用导航属性
|
||||||
|
```csharp
|
||||||
|
sql = select.Where(a => a.Type.Name == "typeTitle" && a.Type.Guid == a.TestTypeInfoGuid).ToSql();
|
||||||
|
///SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 FROM `tb_topic` a, `TestTypeInfo` a__Type WHERE (a__Type.`Name` = 'typeTitle' AND a__Type.`Guid` = a.`TestTypeInfoGuid`)
|
||||||
|
|
||||||
|
sql = select.Where(a => a.Type.Parent.Name == "tparent").ToSql();
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 FROM `tb_topic` a, `TestTypeInfo` a__Type, `TestTypeParentInfo` a__Type__Parent WHERE (a__Type__Parent.`Name` = 'tparent')
|
||||||
|
```
|
||||||
|
|
||||||
|
### 多表,没有导航属性
|
||||||
|
```csharp
|
||||||
|
sql = select.Where<TestTypeInfo>((a, b) => b.Guid == a.TestTypeInfoGuid && b.Name == "typeTitle").ToSql();
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, b.`Guid` as4, b.`ParentId` as5, b.`Name` as6, a.`Title` as7, a.`CreateTime` as8 FROM `tb_topic` a, `TestTypeInfo` b WHERE (b.`Guid` = a.`TestTypeInfoGuid` AND b.`Name` = 'typeTitle')
|
||||||
|
|
||||||
|
sql = select.Where<TestTypeInfo, TestTypeParentInfo>((a, b, c) => c.Name == "tparent").ToSql();
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 FROM `tb_topic` a, `TestTypeParentInfo` c WHERE (c.`Name` = 'tparent')
|
||||||
|
```
|
||||||
|
|
||||||
|
### 多表,任意查
|
||||||
|
```csharp
|
||||||
|
sql = select.From<TestTypeInfo, TestTypeParentInfo>((s, b, c) => s
|
||||||
|
.Where(a => a.Id == 10 && c.Name == "xxx")
|
||||||
|
.Where(a => b.ParentId == 20)).ToSql();
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, b.`Guid` as4, b.`ParentId` as5, b.`Name` as6, a.`Title` as7, a.`CreateTime` as8 FROM `tb_topic` a, `TestTypeParentInfo` c, `TestTypeInfo` b WHERE (a.`Id` = 10 AND c.`Name` = 'xxx') AND (b.`ParentId` = 20)
|
||||||
|
```
|
||||||
|
|
||||||
|
### 原生SQL
|
||||||
|
```csharp
|
||||||
|
sql = select.Where("a.clicks > 100 && a.id = ?id", new { id = 10 }).ToSql();
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 FROM `tb_topic` a WHERE (a.clicks > 100 && a.id = ?id)
|
||||||
|
```
|
||||||
|
|
||||||
|
> 以上条件查询,支持 WhereIf
|
||||||
|
|
||||||
|
# 联表
|
||||||
|
|
||||||
|
### 使用导航属性联表
|
||||||
|
```csharp
|
||||||
|
sql = select.LeftJoin(a => a.Type.Guid == a.TestTypeInfoGuid).ToSql();
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 FROM `tb_topic` a LEFT JOIN `TestTypeInfo` a__Type ON a__Type.`Guid` = a.`TestTypeInfoGuid`
|
||||||
|
|
||||||
|
sql = select
|
||||||
|
.LeftJoin(a => a.Type.Guid == a.TestTypeInfoGuid)
|
||||||
|
.LeftJoin(a => a.Type.Parent.Id == a.Type.ParentId).ToSql();
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 FROM `tb_topic` a LEFT JOIN `TestTypeInfo` a__Type ON a__Type.`Guid` = a.`TestTypeInfoGuid` LEFT JOIN `TestTypeParentInfo` a__Type__Parent ON a__Type__Parent.`Id` = a__Type.`ParentId`
|
||||||
|
```
|
||||||
|
|
||||||
|
### 没有导航属性联表
|
||||||
|
```csharp
|
||||||
|
sql = select.LeftJoin<TestTypeInfo>((a, b) => b.Guid == a.TestTypeInfoGuid).ToSql();
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, b.`Guid` as4, b.`ParentId` as5, b.`Name` as6, a.`Title` as7, a.`CreateTime` as8 FROM `tb_topic` a LEFT JOIN `TestTypeInfo` b ON b.`Guid` = a.`TestTypeInfoGuid`
|
||||||
|
|
||||||
|
sql = select
|
||||||
|
.LeftJoin<TestTypeInfo>((a, b) => b.Guid == a.TestTypeInfoGuid)
|
||||||
|
.LeftJoin<TestTypeParentInfo>((a, c) => c.Id == a.Type.ParentId).ToSql();
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, b.`Guid` as4, b.`ParentId` as5, b.`Name` as6, a.`Title` as7, a.`CreateTime` as8 FROM `tb_topic` a LEFT JOIN `TestTypeInfo` b ON b.`Guid` = a.`TestTypeInfoGuid` LEFT JOIN `TestTypeParentInfo` c ON c.`Id` = b.`ParentId`
|
||||||
|
```
|
||||||
|
|
||||||
|
### 联表任意查
|
||||||
|
```csharp
|
||||||
|
sql = select.From<TestTypeInfo, TestTypeParentInfo>((s, b, c) => s
|
||||||
|
.LeftJoin(a => a.TestTypeInfoGuid == b.Guid)
|
||||||
|
.LeftJoin(a => b.ParentId == c.Id)).ToSql();
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, b.`Guid` as4, b.`ParentId` as5, b.`Name` as6, a.`Title` as7, a.`CreateTime` as8 FROM `tb_topic` a LEFT JOIN `TestTypeInfo` b ON a.`TestTypeInfoGuid` = b.`Guid` LEFT JOIN `TestTypeParentInfo` c ON b.`ParentId` = c.`Id`
|
||||||
|
```
|
||||||
|
|
||||||
|
### 原生SQL联表
|
||||||
|
```csharp
|
||||||
|
sql = select.LeftJoin("TestTypeInfo b on b.Guid = a.TestTypeInfoGuid and b.Name = ?bname", new { bname = "xxx" }).ToSql();
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 FROM `tb_topic` a LEFT JOIN TestTypeInfo b on b.Guid = a.TestTypeInfoGuid and b.Name = ?bname
|
||||||
|
```
|
||||||
|
|
||||||
|
# 查询数据
|
||||||
|
|
||||||
|
### 返回 List
|
||||||
|
```csharp
|
||||||
|
List<Topic> t1 = select.Where(a => a.Id > 0).Skip(100).Limit(200).ToList();
|
||||||
|
```
|
||||||
|
|
||||||
|
### 返回 List + 导航属性的数据
|
||||||
|
```csharp
|
||||||
|
List<Topic> t2 = select.LeftJoin(a => a.Type.Guid == a.TestTypeInfoGuid).ToList();
|
||||||
|
//此时会返回普通字段 + 导航对象 Type 的数据
|
||||||
|
```
|
||||||
|
|
||||||
|
### 指定字段返回
|
||||||
|
```csharp
|
||||||
|
//返回一个字段
|
||||||
|
List<int> t3 = select.Where(a => a.Id > 0).Skip(100).Limit(200).ToList(a => a.Id);
|
||||||
|
|
||||||
|
//返回匿名类
|
||||||
|
List<匿名类> t4 = select.Where(a => a.Id > 0).Skip(100).Limit(200).ToList(a => new { a.Id, a.Title });
|
||||||
|
|
||||||
|
//返回元组
|
||||||
|
List<(int, string)> t5 = select.Where(a => a.Id > 0).Skip(100).Limit(200).ToList<(int, string)>("id, title");
|
||||||
|
```
|
||||||
|
|
||||||
|
### 执行SQL返回数据
|
||||||
|
```csharp
|
||||||
|
class xxx {
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string Path { get; set; }
|
||||||
|
public string Title2 { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
List<xxx> t6 = fsql.Ado.Query<xxx>("select * from song");
|
||||||
|
List<(int, string ,string)> t7 = fsql.Ado.Query<(int, string, string)>("select * from song");
|
||||||
|
List<dynamic> t8 = fsql.Ado.Query<dynamic>("select * from song");
|
||||||
|
```
|
||||||
|
|
||||||
|
# 更多文档整理中。。。
|
||||||
|
|
||||||
|
| 方法 | 返回值 | 参数 | 描述 |
|
||||||
|
| ------------- | - | - | - |
|
||||||
|
| ToSql | string | | 返回即将执行的SQL语句 |
|
||||||
|
| ToList | List<T1> | | 执行SQL查询,返回 T1 实体所有字段的记录,若存在导航属性则一起查询返回,记录不存在时返回 Count 为 0 的列表 |
|
||||||
|
| ToList\<T\> | List\<T\> | Lambda | 执行SQL查询,返回指定字段的记录,记录不存在时返回 Count 为 0 的列表 |
|
||||||
|
| ToList\<T\> | List\<T\> | string field | 执行SQL查询,返回 field 指定字段的记录,并以元组或基础类型(int,string,long)接收,记录不存在时返回 Count 为 0 的列表 |
|
||||||
|
| ToOne | T1 | | 执行SQL查询,返回 T1 实体所有字段的第一条记录,记录不存在时返回 null |
|
||||||
|
| Any | bool | | 执行SQL查询,是否有记录 |
|
||||||
|
| Sum | T | Lambda | 指定一个列求和 |
|
||||||
|
| Min | T | Lambda | 指定一个列求最小值 |
|
||||||
|
| Max | T | Lambda | 指定一个列求最大值 |
|
||||||
|
| Avg | T | Lambda | 指定一个列求平均值 |
|
||||||
|
| 【分页】 |
|
||||||
|
| Count | long | | 查询的记录数量 |
|
||||||
|
| Count | \<this\> | out long | 查询的记录数量,以参数out形式返回 |
|
||||||
|
| Skip | \<this\> | int offset | 查询向后偏移行数 |
|
||||||
|
| Offset | \<this\> | int offset | 查询向后偏移行数 |
|
||||||
|
| Limit | \<this\> | int limit | 查询多少条数据 |
|
||||||
|
| Take | \<this\> | int limit | 查询多少条数据 |
|
||||||
|
| Page | \<this\> | int pageIndex, int pageSize | 分页 |
|
||||||
|
| 【条件】 |
|
||||||
|
| Where | \<this\> | Lambda | 支持多表查询表达式 |
|
||||||
|
| WhereIf | \<this\> | bool, Lambda | 支持多表查询表达式 |
|
||||||
|
| Where | \<this\> | string, parms | 原生sql语法条件,Where("id = ?id", new { id = 1 }) |
|
||||||
|
| WhereIf | \<this\> | bool, string, parms | 原生sql语法条件,WhereIf(true, "id = ?id", new { id = 1 }) |
|
||||||
|
| WhereLike | \<this\> | Lambda, string, bool | like 查询条件,where title like '%xxx%' or content like '%xxx%' |
|
||||||
|
| 【分组】 |
|
||||||
|
| GroupBy | \<this\> | Lambda | 按选择的列分组,GroupBy(a => a.Name) | GroupBy(a => new{a.Name,a.Time}) | GroupBy(a => new[]{"name","time"}) |
|
||||||
|
| GroupBy | \<this\> | string, parms | 按原生sql语法分组,GroupBy("concat(name, ?cc)", new { cc = 1 }) |
|
||||||
|
| Having | \<this\> | string, parms | 按原生sql语法聚合条件过滤,Having("count(name) = ?cc", new { cc = 1 }) |
|
||||||
|
| 【排序】 |
|
||||||
|
| OrderBy | \<this\> | Lambda | 按列排序,OrderBy(a => a.Time) |
|
||||||
|
| OrderByDescending | \<this\> | Lambda | 按列倒向排序,OrderByDescending(a => a.Time) |
|
||||||
|
| OrderBy | \<this\> | string, parms | 按原生sql语法排序,OrderBy("count(name) + ?cc", new { cc = 1 }) |
|
||||||
|
| 【联表】 |
|
||||||
|
| LeftJoin | \<this\> | Lambda | 左联查询,可使用导航属性,或指定关联的实体类型 |
|
||||||
|
| InnerJoin | \<this\> | Lambda | 联接查询,可使用导航属性,或指定关联的实体类型 |
|
||||||
|
| RightJoin | \<this\> | Lambda | 右联查询,可使用导航属性,或指定关联的实体类型 |
|
||||||
|
| LeftJoin | \<this\> | string, parms | 左联查询,使用原生sql语法,LeftJoin("type b on b.id = a.id and b.clicks > ?clicks", new { clicks = 1 }) |
|
||||||
|
| InnerJoin | \<this\> | string, parms | 联接查询,使用原生sql语法,InnerJoin("type b on b.id = a.id and b.clicks > ?clicks", new { clicks = 1 }) |
|
||||||
|
| RightJoin | \<this\> | string, parms | 右联查询,使用原生sql语法,RightJoin("type b on b.id = a.id and b.clicks > ?clicks", new { clicks = 1 }) |
|
||||||
|
| From | \<this\> | Lambda | 多表查询,3个表以上使用非常方便,目前设计最大支持10个表 |
|
||||||
|
| 【其他】 |
|
||||||
|
| As | \<this\> | string alias = "a" | 指定别名 |
|
||||||
|
| Master | \<this\> | | 指定从主库查询(默认查询从库) |
|
||||||
|
| Caching | \<this\> | int seconds, string key = null | 缓存查询结果 |
|
129
Examples/website/FreeSql.Site.UI/wwwroot/file/update.md
Normal file
129
Examples/website/FreeSql.Site.UI/wwwroot/file/update.md
Normal file
@ -0,0 +1,129 @@
|
|||||||
|
# 更新数据
|
||||||
|
|
||||||
|
| 方法 | 返回值 | 参数 | 描述 |
|
||||||
|
| - | - | - | - |
|
||||||
|
| SetSource | \<this\> | T1 \| IEnumerable<T1> | 更新数据,设置更新的实体 |
|
||||||
|
| IgnoreColumns | \<this\> | Lambda | 忽略的列 |
|
||||||
|
| Set | \<this\> | Lambda, value | 设置列的新值,Set(a => a.Name, "newvalue") |
|
||||||
|
| Set | \<this\> | Lambda | 设置列的的新值为基础上增加,Set(a => a.Clicks + 1),相当于 clicks=clicks+1; |
|
||||||
|
| SetRaw | \<this\> | string, parms | 设置值,自定义SQL语法,SetRaw("title = ?title", new { title = "newtitle" }) |
|
||||||
|
| Where | \<this\> | Lambda | 表达式条件,仅支持实体基础成员(不包含导航对象) |
|
||||||
|
| Where | \<this\> | string, parms | 原生sql语法条件,Where("id = ?id", new { id = 1 }) |
|
||||||
|
| Where | \<this\> | T1 \| IEnumerable<T1> | 传入实体或集合,将其主键作为条件 |
|
||||||
|
| WhereExists | \<this\> | ISelect | 子查询是否存在 |
|
||||||
|
| ToSql | string | | 返回即将执行的SQL语句 |
|
||||||
|
| ExecuteAffrows | long | | 执行SQL语句,返回影响的行数 |
|
||||||
|
| ExecuteUpdated | List\<T1\> | | 执行SQL语句,返回更新后的记录 |
|
||||||
|
|
||||||
|
### 列优先级
|
||||||
|
|
||||||
|
> 全部列 < 指定列(Set/SetRaw) < 忽略列(IgnoreColumns)
|
||||||
|
|
||||||
|
### 测试代码
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
[Table(Name = "tb_topic")]
|
||||||
|
class Topic {
|
||||||
|
[Column(IsIdentity = true, IsPrimary = true)]
|
||||||
|
public int Id { get; set; }
|
||||||
|
public int Clicks { get; set; }
|
||||||
|
public TestTypeInfo Type { get; set; }
|
||||||
|
public string Title { get; set; }
|
||||||
|
public DateTime CreateTime { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
IFreeSql fsql = new FreeSql.FreeSqlBuilder()
|
||||||
|
.UseConnectionString(FreeSql.DataType.MySql, "Data Source=127.0.0.1;Port=3306;User ID=root;Password=root;Initial Catalog=cccddd;Charset=utf8;SslMode=none;Max pool size=10")
|
||||||
|
.Build();
|
||||||
|
IUpdate<Topic> update => fsql.Update<Topic>();
|
||||||
|
```
|
||||||
|
|
||||||
|
### 动态条件
|
||||||
|
```csharp
|
||||||
|
Update<Topic>(object dywhere)
|
||||||
|
```
|
||||||
|
dywhere 支持
|
||||||
|
|
||||||
|
* 主键值
|
||||||
|
* new[] { 主键值1, 主键值2 }
|
||||||
|
* Topic对象
|
||||||
|
* new[] { Topic对象1, Topic对象2 }
|
||||||
|
* new { id = 1 }
|
||||||
|
|
||||||
|
### 更新指定列
|
||||||
|
```csharp
|
||||||
|
var t1 = fsql.Update<Topic>(1).Set(a => a.CreateTime, DateTime.Now).ToSql();
|
||||||
|
//UPDATE `tb_topic` SET `CreateTime` = '2018-12-08 00:04:59' WHERE (`Id` = 1)
|
||||||
|
```
|
||||||
|
|
||||||
|
### 更新指定列,累加
|
||||||
|
```csharp
|
||||||
|
var t2 = fsql.Update<Topic>(1).Set(a => a.Clicks + 1).ToSql();
|
||||||
|
//UPDATE `tb_topic` SET `Clicks` = ifnull(`Clicks`,0) + 1 WHERE (`Id` = 1)
|
||||||
|
```
|
||||||
|
|
||||||
|
### 保存实体
|
||||||
|
```csharp
|
||||||
|
var item = new Topic { Id = 1, Title = "newtitle" };
|
||||||
|
var t3 = update.SetSource(item).ToSql();
|
||||||
|
//UPDATE `tb_topic` SET `Clicks` = ?p_0, `Title` = ?p_1, `CreateTime` = ?p_2 WHERE (`Id` = 1)
|
||||||
|
```
|
||||||
|
|
||||||
|
### 保存实体,忽略一些列
|
||||||
|
```csharp
|
||||||
|
var t4 = update.SetSource(item).IgnoreColumns(a => a.Clicks).ToSql();
|
||||||
|
//UPDATE `tb_topic` SET `Title` = ?p_0, `CreateTime` = ?p_1 WHERE (`Id` = 1)
|
||||||
|
var t5 = update.SetSource(item).IgnoreColumns(a => new { a.Clicks, a.CreateTime }).ToSql();
|
||||||
|
//UPDATE `tb_topic` SET `Title` = ?p_0 WHERE (`Id` = 1)
|
||||||
|
```
|
||||||
|
|
||||||
|
### 批量保存
|
||||||
|
```csharp
|
||||||
|
var items = new List<Topic>();
|
||||||
|
for (var a = 0; a < 10; a++) items.Add(new Topic { Id = a + 1, Title = $"newtitle{a}", Clicks = a * 100 });
|
||||||
|
|
||||||
|
var t6 = update.SetSource(items).ToSql();
|
||||||
|
//UPDATE `tb_topic` SET `Clicks` = CASE `Id` WHEN 1 THEN ?p_0 WHEN 2 THEN ?p_1 WHEN 3 THEN ?p_2 WHEN 4 THEN ?p_3 WHEN 5 THEN ?p_4 WHEN 6 THEN ?p_5 WHEN 7 THEN ?p_6 WHEN 8 THEN ?p_7 WHEN 9 THEN ?p_8 WHEN 10 THEN ?p_9 END, `Title` = CASE `Id` WHEN 1 THEN ?p_10 WHEN 2 THEN ?p_11 WHEN 3 THEN ?p_12 WHEN 4 THEN ?p_13 WHEN 5 THEN ?p_14 WHEN 6 THEN ?p_15 WHEN 7 THEN ?p_16 WHEN 8 THEN ?p_17 WHEN 9 THEN ?p_18 WHEN 10 THEN ?p_19 END, `CreateTime` = CASE `Id` WHEN 1 THEN ?p_20 WHEN 2 THEN ?p_21 WHEN 3 THEN ?p_22 WHEN 4 THEN ?p_23 WHEN 5 THEN ?p_24 WHEN 6 THEN ?p_25 WHEN 7 THEN ?p_26 WHEN 8 THEN ?p_27 WHEN 9 THEN ?p_28 WHEN 10 THEN ?p_29 END WHERE (`Id` IN (1,2,3,4,5,6,7,8,9,10))
|
||||||
|
```
|
||||||
|
|
||||||
|
> 批量保存的场景,先查询20条记录,根据本地很复杂的规则把集合的值改完后
|
||||||
|
|
||||||
|
> 传统做法是循环20次保存,用 case when 只要一次就行
|
||||||
|
|
||||||
|
### 批量保存,忽略一些列
|
||||||
|
```csharp
|
||||||
|
var t7 = update.SetSource(items).IgnoreColumns(a => new { a.Clicks, a.CreateTime }).ToSql();
|
||||||
|
//UPDATE `tb_topic` SET `Title` = CASE `Id` WHEN 1 THEN ?p_0 WHEN 2 THEN ?p_1 WHEN 3 THEN ?p_2 WHEN 4 THEN ?p_3 WHEN 5 THEN ?p_4 WHEN 6 THEN ?p_5 WHEN 7 THEN ?p_6 WHEN 8 THEN ?p_7 WHEN 9 THEN ?p_8 WHEN 10 THEN ?p_9 END WHERE (`Id` IN (1,2,3,4,5,6,7,8,9,10))
|
||||||
|
```
|
||||||
|
|
||||||
|
### 批量更新指定列
|
||||||
|
```csharp
|
||||||
|
var t8 = update.SetSource(items).Set(a => a.CreateTime, DateTime.Now).ToSql();
|
||||||
|
//UPDATE `tb_topic` SET `CreateTime` = ?p_0 WHERE (`Id` IN (1,2,3,4,5,6,7,8,9,10))
|
||||||
|
```
|
||||||
|
|
||||||
|
> 指定列更新后,批量保存将失效
|
||||||
|
|
||||||
|
### 更新条件
|
||||||
|
|
||||||
|
> 除了顶上介绍的 dywhere 构造参数外,还支持 Where lambda/sql 方法
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
var t9 = update.Set(a => a.Title, "新标题").Where(a => a.Id == 1).ToSql();
|
||||||
|
//UPDATE `tb_topic` SET `Title` = '新标题' WHERE (Id = 1)
|
||||||
|
```
|
||||||
|
|
||||||
|
### 自定义SQL
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
var t10 = update.SetRaw("Title = {0}", "新标题").Where("Id = {0}", 1).ToSql();
|
||||||
|
//UPDATE `tb_topic` SET Title = '新标题' WHERE (Id = 1)
|
||||||
|
//sql语法条件,参数使用 {0},与 string.Format 保持一致,无须加单引号,错误的用法:'{0}'
|
||||||
|
```
|
||||||
|
|
||||||
|
### 执行命令
|
||||||
|
|
||||||
|
| 方法 | 返回值 | 参数 | 描述 |
|
||||||
|
| - | - | - | - |
|
||||||
|
| ExecuteAffrows | long | | 执行SQL语句,返回影响的行数 |
|
||||||
|
| ExecuteUpdated | List\<T1\> | | 执行SQL语句,返回更新后的记录 |
|
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 9.5 KiB |
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 8.2 KiB |
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 12 KiB |
BIN
Examples/website/FreeSql.Site.UI/wwwroot/images/banner_index.jpg
Normal file
BIN
Examples/website/FreeSql.Site.UI/wwwroot/images/banner_index.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 33 KiB |
BIN
Examples/website/FreeSql.Site.UI/wwwroot/images/default.jpg
Normal file
BIN
Examples/website/FreeSql.Site.UI/wwwroot/images/default.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 46 KiB |
321
Examples/website/FreeSql.Site.UI/wwwroot/js/common.js
Normal file
321
Examples/website/FreeSql.Site.UI/wwwroot/js/common.js
Normal file
@ -0,0 +1,321 @@
|
|||||||
|
|
||||||
|
(function (window) {
|
||||||
|
|
||||||
|
window.base = function () { };
|
||||||
|
|
||||||
|
base.prototype = {
|
||||||
|
showLoading: function (obj) {
|
||||||
|
var index = layer.msg(obj.msg, {
|
||||||
|
icon: 16,
|
||||||
|
shade: 0.1,
|
||||||
|
shadeClose: false,
|
||||||
|
});
|
||||||
|
return index;
|
||||||
|
},
|
||||||
|
closeLoading: function (index) {
|
||||||
|
layer.close(index);
|
||||||
|
},
|
||||||
|
showMessage: function (options) {
|
||||||
|
if (layer == null) {
|
||||||
|
alert(options.msg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var yes = function (index) {
|
||||||
|
if ($.isFunction(options.yes)) {
|
||||||
|
options.yes();
|
||||||
|
}
|
||||||
|
layer.close(index);
|
||||||
|
};
|
||||||
|
layer.alert(options.msg || "操作成功", {
|
||||||
|
icon: options.type || 1,
|
||||||
|
scrollbar: false,
|
||||||
|
shadeClose: false,
|
||||||
|
closeBtn: 0,
|
||||||
|
skin: 'layui-layer-lan'//'layer-ext-moon'
|
||||||
|
}, yes);
|
||||||
|
},
|
||||||
|
//options={title:"标题",msg:"内容",yes:function,no:function}
|
||||||
|
showConfirm: function (options) {
|
||||||
|
if (options == null || options.msg == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var yes = options.yes;
|
||||||
|
var no = options.no;
|
||||||
|
var defaultAction = function (index) {
|
||||||
|
layer.close(index);
|
||||||
|
};
|
||||||
|
if (yes == null) {
|
||||||
|
yes = defaultAction;
|
||||||
|
}
|
||||||
|
if (no == null) {
|
||||||
|
no = defaultAction
|
||||||
|
}
|
||||||
|
////layer.confirm(options.msg, yes, options.title, no);
|
||||||
|
//layer.confirm(options.msg, { btn: ['确定', '取消'] }, yes, no);
|
||||||
|
layer.confirm(options.msg, {
|
||||||
|
btn: ['确定', '取消'], //按钮
|
||||||
|
icon: 3,
|
||||||
|
shadeClose: false,
|
||||||
|
skin: 'layer-ext-moon'
|
||||||
|
}, yes, no);
|
||||||
|
},
|
||||||
|
markDownEdit: function (id, option) {
|
||||||
|
var _option = $.extend({
|
||||||
|
width: "96%",
|
||||||
|
height: 640,
|
||||||
|
syncScrolling: "single",
|
||||||
|
path: "../../lib/editormd/lib/"
|
||||||
|
}, options);
|
||||||
|
return editormd(id, _option);
|
||||||
|
},
|
||||||
|
ajax: function (url, appendPostData, beforeFn, completeFn, successFn, errorFn, isShowLoading) {
|
||||||
|
jQuery.ajax({
|
||||||
|
type: "POST",
|
||||||
|
url: url,
|
||||||
|
data: appendPostData,
|
||||||
|
global: false,
|
||||||
|
beforeSend: function (XMLHttpRequest) {
|
||||||
|
if (jQuery.isFunction(beforeFn)) {
|
||||||
|
if (beforeFn(XMLHttpRequest)) {
|
||||||
|
if (isShowLoading != false) {
|
||||||
|
freejs.showLoading();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (isShowLoading != false) {
|
||||||
|
freejs.showLoading();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
success: function (data, textStatus) {
|
||||||
|
if (jQuery.isFunction(successFn)) {
|
||||||
|
successFn(data, textStatus);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
complete: function (XMLHttpRequest, textStatus) {
|
||||||
|
var gohome = XMLHttpRequest.getResponseHeader("Timeout");
|
||||||
|
if (gohome) {
|
||||||
|
// window.top.window.location.href = gohome;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (isShowLoading != false) {
|
||||||
|
freejs.hideLoading();
|
||||||
|
}
|
||||||
|
if (jQuery.isFunction(completeFn)) {
|
||||||
|
completeFn();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function (e, d, s, u, b) {
|
||||||
|
if (jQuery.isFunction(errorFn)) {
|
||||||
|
errorFn(e, d, s);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
freejs.showMessage({
|
||||||
|
title: "发生异常",
|
||||||
|
type: 2,
|
||||||
|
msg: s
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
dialogWindow: {
|
||||||
|
/*
|
||||||
|
url: "/Admin/Document/DocContentEditModule", //页面地址
|
||||||
|
paramters: { id: "" }, //参数
|
||||||
|
-------------------------------------------------------
|
||||||
|
title: "新增文档", //标题
|
||||||
|
area: ['1100px', '660px'], //尺寸
|
||||||
|
submit: { //提交参数
|
||||||
|
url: "/Admin/Document/DocContentCreate", // 提交的地址
|
||||||
|
}, //
|
||||||
|
callback: reloadTable //执行完成回调函数
|
||||||
|
*/
|
||||||
|
create: function (options, formpage) {
|
||||||
|
//docContentEdit
|
||||||
|
$("#" + options.elmid).load(options.url, options.paramters, function (responseText, textStatus, jqXHR) {
|
||||||
|
switch (textStatus) {
|
||||||
|
case "success":
|
||||||
|
freejs.dialogWindow.open($.extend({
|
||||||
|
type: 1,
|
||||||
|
maxmin: true,
|
||||||
|
title: "编辑",
|
||||||
|
area: ['1100px', '660px'],
|
||||||
|
shadeClose: false, //点击遮罩关闭
|
||||||
|
content: responseText,
|
||||||
|
submit: {
|
||||||
|
url: "/Admin/Document/DocContentCreate",
|
||||||
|
}
|
||||||
|
}, options), formpage);
|
||||||
|
break;
|
||||||
|
case "error":
|
||||||
|
freejs.showMessage({ title: "提示", msg: "页面加载失败", type: 2 });
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
/*
|
||||||
|
{
|
||||||
|
type: 1,
|
||||||
|
maxmin: true,
|
||||||
|
title: "编辑",
|
||||||
|
area: ['1100px', '660px'],
|
||||||
|
shadeClose: false, //点击遮罩关闭
|
||||||
|
content: responseText,
|
||||||
|
submit: {
|
||||||
|
url: "/Admin/Document/DocContentCreate",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
open: function (options, form) {
|
||||||
|
var currentOpenID = 0;
|
||||||
|
var base_options = {
|
||||||
|
type: 1,
|
||||||
|
maxmin: true,
|
||||||
|
title: "编辑",
|
||||||
|
area: ['1100px', '660px'],
|
||||||
|
btn: ['立即提交', '关闭'],
|
||||||
|
yes: function (index, layero) {
|
||||||
|
form.on('submit(saveSubmit)', function (data) {
|
||||||
|
if ($.isFunction(options.submitBefore)) data = options.submitBefore(data);
|
||||||
|
$.ajax({
|
||||||
|
type: 'POST',
|
||||||
|
url: options.submit.url,//"/Admin/Document/DocContentCreate",
|
||||||
|
data: JSON.stringify(data.field),
|
||||||
|
contentType: "application/json; charset=utf-8",
|
||||||
|
dataType: "json",
|
||||||
|
success: function (e) {
|
||||||
|
if (e.Status == 1) {
|
||||||
|
freejs.showMessage({ title: "提示", msg: e.Msg || "保存成功", type: 1 });
|
||||||
|
if ($.isFunction(new_options.callback)) new_options.callback();
|
||||||
|
layer.close(index);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
freejs.showMessage({ title: "提示", msg: e.Msg, type: 2 });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
btn2: function (index, layero) {
|
||||||
|
layer.confirm('确定要关闭么?', {
|
||||||
|
btn: ['确定', '取消'] //按钮
|
||||||
|
}, function (index, layero) {
|
||||||
|
layer.close(index);
|
||||||
|
layer.close(currentOpenID);
|
||||||
|
}, function () {
|
||||||
|
});
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
//右上角关闭回调
|
||||||
|
cancel: function (index, layero) {
|
||||||
|
layer.confirm('确定要关闭么?', {
|
||||||
|
btn: ['确定', '取消'] //按钮
|
||||||
|
}, function (index, layero) {
|
||||||
|
layer.close(index);
|
||||||
|
layer.close(currentOpenID);
|
||||||
|
}, function () {
|
||||||
|
});
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
shadeClose: false //点击遮罩关闭
|
||||||
|
};
|
||||||
|
var new_options = $.extend(base_options, options);
|
||||||
|
new_options.success = function (layero, index) {
|
||||||
|
if ($.isFunction(options.loadBefore)) options.loadBefore(form);
|
||||||
|
$(".form-module-content").height(dialog_Paramters.height - 110);
|
||||||
|
|
||||||
|
// 解决按enter键重复弹窗问题
|
||||||
|
$(':focus').blur();
|
||||||
|
// 添加form标识
|
||||||
|
layero.addClass('layui-form');
|
||||||
|
// 将保存按钮改变成提交按钮
|
||||||
|
layero.find('.layui-layer-btn0').attr({
|
||||||
|
'lay-filter': 'saveSubmit',
|
||||||
|
'lay-submit': ''
|
||||||
|
});
|
||||||
|
form.render();
|
||||||
|
}
|
||||||
|
currentOpenID = layer.open(new_options);
|
||||||
|
},
|
||||||
|
close: function () {
|
||||||
|
}
|
||||||
|
},
|
||||||
|
loadHtml: function (options) {
|
||||||
|
//options = {
|
||||||
|
// elm:"page_content",url: "/Admin/Document/DocType", paramters: {},loadIndex:1,isform:false
|
||||||
|
//};
|
||||||
|
var _container = options.elm || "page_content";
|
||||||
|
$("#" + _container).load(options.url, options.paramters, function (responseText, textStatus, jqXHR) {
|
||||||
|
freejs.closeLoading(options.loadIndex);
|
||||||
|
alert(textStatus);
|
||||||
|
switch (textStatus) {
|
||||||
|
case "success":
|
||||||
|
debugger
|
||||||
|
if ($.isFunction(options.successCallBack)) options.successCallBack();
|
||||||
|
//初始化绑定页面的时间,例如时间控件
|
||||||
|
index = -1;
|
||||||
|
//if (options.isform) {
|
||||||
|
// layui.use('form', function () {
|
||||||
|
// var form = layui.form;
|
||||||
|
|
||||||
|
// });
|
||||||
|
//}
|
||||||
|
break;
|
||||||
|
//case "notmodified":
|
||||||
|
//case "error":
|
||||||
|
//case "timeout":
|
||||||
|
//case "parsererror":
|
||||||
|
//spf.loadHtml(mcid, "/Service/Error/", function (jElement, responseText) {
|
||||||
|
// loadResultShow(jElement, responseText, spTitle, spHead);
|
||||||
|
//});
|
||||||
|
//break;
|
||||||
|
case "error":
|
||||||
|
if ($.isFunction(options.errorCallBack)) options.errorCallBack(form);
|
||||||
|
$("#page_content").html(responseText);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
//如果出现长时间未关闭,定时关闭loading
|
||||||
|
setTimeout(function () {
|
||||||
|
if (options.loadIndex >= 0) freejs.closeLoading(options.loadIndex);
|
||||||
|
}, 5000);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
window.freejs = new base();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数组扩展
|
||||||
|
* @param {any} func
|
||||||
|
*/
|
||||||
|
Array.prototype.select = function (func) {
|
||||||
|
var retValues = [];
|
||||||
|
if (this.length == 0) {
|
||||||
|
return retValues;
|
||||||
|
}
|
||||||
|
if (func == null) {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
for (var i = 0; i < this.length; i++) {
|
||||||
|
retValues.push(func(this[i]));
|
||||||
|
}
|
||||||
|
return retValues;
|
||||||
|
};
|
||||||
|
Array.prototype.where = function (func) {
|
||||||
|
if (func == null) {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
var retList = [];
|
||||||
|
for (var i = 0; i < this.length; i++) {
|
||||||
|
if (func(this[i]) != false) {
|
||||||
|
retList.push(this[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return retList;
|
||||||
|
}
|
||||||
|
})(window);
|
0
Examples/website/FreeSql.Site.UI/wwwroot/js/common.min.js
vendored
Normal file
0
Examples/website/FreeSql.Site.UI/wwwroot/js/common.min.js
vendored
Normal file
478
Examples/website/FreeSql.Site.UI/wwwroot/js/site.js
Normal file
478
Examples/website/FreeSql.Site.UI/wwwroot/js/site.js
Normal file
@ -0,0 +1,478 @@
|
|||||||
|
/**
|
||||||
|
|
||||||
|
layui官网
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
layui.define(['code', 'element', 'table', 'util'], function (exports) {
|
||||||
|
var $ = layui.jquery
|
||||||
|
, element = layui.element
|
||||||
|
, layer = layui.layer
|
||||||
|
, form = layui.form
|
||||||
|
, util = layui.util
|
||||||
|
, device = layui.device()
|
||||||
|
|
||||||
|
, $win = $(window), $body = $('body');
|
||||||
|
|
||||||
|
|
||||||
|
//阻止IE7以下访问
|
||||||
|
if (device.ie && device.ie < 8) {
|
||||||
|
layer.alert('Layui最低支持ie8,您当前使用的是古老的 IE' + device.ie + ',你丫的肯定不是程序猿!');
|
||||||
|
}
|
||||||
|
|
||||||
|
var home = $('#LAY_home');
|
||||||
|
|
||||||
|
|
||||||
|
layer.ready(function () {
|
||||||
|
var local = layui.data('layui');
|
||||||
|
|
||||||
|
//升级提示
|
||||||
|
if (local.version && local.version !== layui.v) {
|
||||||
|
layer.open({
|
||||||
|
type: 1
|
||||||
|
, title: '更新提示' //不显示标题栏
|
||||||
|
, closeBtn: false
|
||||||
|
, area: '300px;'
|
||||||
|
, shade: false
|
||||||
|
, offset: 'b'
|
||||||
|
, id: 'LAY_updateNotice' //设定一个id,防止重复弹出
|
||||||
|
, btn: ['更新日志', '朕不想升']
|
||||||
|
, btnAlign: 'c'
|
||||||
|
, moveType: 1 //拖拽模式,0或者1
|
||||||
|
, content: ['<div class="layui-text">'
|
||||||
|
, 'layui 已更新到:<strong style="padding-right: 10px; color: #fff;">v' + layui.v + '</strong> <br>请注意升级!'
|
||||||
|
, '</div>'].join('')
|
||||||
|
, skin: 'layui-layer-notice'
|
||||||
|
, yes: function (index) {
|
||||||
|
layer.close(index);
|
||||||
|
setTimeout(function () {
|
||||||
|
location.href = '/doc/base/changelog.html';
|
||||||
|
}, 500);
|
||||||
|
}
|
||||||
|
, end: function () {
|
||||||
|
layui.data('layui', {
|
||||||
|
key: 'version'
|
||||||
|
, value: layui.v
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
layui.data('layui', {
|
||||||
|
key: 'version'
|
||||||
|
, value: layui.v
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
//公告
|
||||||
|
; !function () {
|
||||||
|
return layui.data('layui', {
|
||||||
|
key: 'notice_20180530'
|
||||||
|
, remove: true
|
||||||
|
});
|
||||||
|
|
||||||
|
if (local.notice_20180530 && new Date().getTime() - local.notice_20180530 < 1000 * 60 * 60 * 24 * 5) {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
|
layer.open({
|
||||||
|
type: 1
|
||||||
|
, title: 'layui 官方通用后台管理模板'
|
||||||
|
, closeBtn: false
|
||||||
|
, area: ['300px', '280px']
|
||||||
|
, shade: false
|
||||||
|
//,offset: 'c'
|
||||||
|
, id: 'LAY_Notice' //设定一个id,防止重复弹出
|
||||||
|
, btn: ['前往围观', '朕不想看']
|
||||||
|
, btnAlign: 'b'
|
||||||
|
, moveType: 1 //拖拽模式,0或者1
|
||||||
|
, resize: false
|
||||||
|
, content: ['<div style="padding: 15px; text-align: center; background-color: #e2e2e2;">'
|
||||||
|
, '<a href="/admin/std/dist/views/" target="_blank"><img src="//cdn.layui.com/upload/2018_5/168_1527691799254_76462.jpg" alt="layuiAdmin" style="width: 100%; height:149.78px;"></a>'
|
||||||
|
, '</div>'].join('')
|
||||||
|
, success: function (layero, index) {
|
||||||
|
var btn = layero.find('.layui-layer-btn');
|
||||||
|
btn.find('.layui-layer-btn0').attr({
|
||||||
|
href: '/admin/std/dist/views/'
|
||||||
|
, target: '_blank'
|
||||||
|
});
|
||||||
|
|
||||||
|
layero.find('a').on('click', function () {
|
||||||
|
layer.close(index);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
, end: function () {
|
||||||
|
layui.data('layui', {
|
||||||
|
key: 'notice_20180530'
|
||||||
|
, value: new Date().getTime()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}();
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
; !function () {
|
||||||
|
var elemComponentSelect = $(['<select lay-search lay-filter="component">'
|
||||||
|
, '<option value="">搜索组件或模块</option>'
|
||||||
|
, '<option value="element/layout.html">grid 栅格布局</option>'
|
||||||
|
, '<option value="element/layout.html#admin">admin 后台布局</option>'
|
||||||
|
, '<option value="element/color.html">color 颜色</option>'
|
||||||
|
, '<option value="element/icon.html">iconfont 字体图标</option>'
|
||||||
|
, '<option value="element/anim.html">animation 动画</option>'
|
||||||
|
, '<option value="element/button.html">button 按钮</option>'
|
||||||
|
, '<option value="element/form.html">form 表单组</option>'
|
||||||
|
, '<option value="element/form.html#input">input 输入框</option>'
|
||||||
|
, '<option value="element/form.html#select">select 下拉选择框</option>'
|
||||||
|
, '<option value="element/form.html#checkbox">checkbox 复选框</option>'
|
||||||
|
, '<option value="element/form.html#switch">switch 开关</option>'
|
||||||
|
, '<option value="element/form.html#radio">radio 单选框</option>'
|
||||||
|
, '<option value="element/form.html#textarea">textarea 文本域</option>'
|
||||||
|
, '<option value="element/nav.html">nav 导航菜单</option>'
|
||||||
|
, '<option value="element/nav.html#breadcrumb">breadcrumb 面包屑</option>'
|
||||||
|
, '<option value="element/tab.html">tabs 选项卡</option>'
|
||||||
|
, '<option value="element/progress.html">progress 进度条</option>'
|
||||||
|
, '<option value="element/collapse.html">collapse 折叠面板/手风琴</option>'
|
||||||
|
, '<option value="element/table.html">table 表格元素</option>'
|
||||||
|
, '<option value="element/badge.html">badge 徽章</option>'
|
||||||
|
, '<option value="element/timeline.html">timeline 时间线</option>'
|
||||||
|
, '<option value="element/auxiliar.html#blockquote">blockquote 引用块</option>'
|
||||||
|
, '<option value="element/auxiliar.html#fieldset">fieldset 字段集</option>'
|
||||||
|
, '<option value="element/auxiliar.html#hr">hr 分割线</option>'
|
||||||
|
|
||||||
|
, '<option value="modules/layer.html">layer 弹出层/弹窗综合</option>'
|
||||||
|
, '<option value="modules/laydate.html">laydate 日期时间选择器</option>'
|
||||||
|
, '<option value="modules/layim.html">layim 即时通讯/聊天</option>'
|
||||||
|
, '<option value="modules/laypage.html">laypage 分页</option>'
|
||||||
|
, '<option value="modules/laytpl.html">laytpl 模板引擎</option>'
|
||||||
|
, '<option value="modules/form.html">form 表单模块</option>'
|
||||||
|
, '<option value="modules/table.html">table 数据表格</option>'
|
||||||
|
, '<option value="modules/upload.html">upload 文件/图片上传</option>'
|
||||||
|
, '<option value="modules/element.html">element 常用元素操作</option>'
|
||||||
|
, '<option value="modules/rate.html">rate 评分</option>'
|
||||||
|
, '<option value="modules/colorpicker.html">colorpicker 颜色选择器</option>'
|
||||||
|
, '<option value="modules/slider.html">slider 滑块</option>'
|
||||||
|
, '<option value="modules/carousel.html">carousel 轮播/跑马灯</option>'
|
||||||
|
, '<option value="modules/layedit.html">layedit 富文本编辑器</option>'
|
||||||
|
, '<option value="modules/tree.html">tree 树形菜单</option>'
|
||||||
|
, '<option value="modules/flow.html">flow 信息流/图片懒加载</option>'
|
||||||
|
, '<option value="modules/util.html">util 工具集</option>'
|
||||||
|
, '<option value="modules/code.html">code 代码修饰</option>'
|
||||||
|
, '</select>'].join(''));
|
||||||
|
|
||||||
|
$('.component').append(elemComponentSelect);
|
||||||
|
form.render('select', 'LAY-site-header-component');
|
||||||
|
|
||||||
|
//搜索组件
|
||||||
|
form.on('select(component)', function (data) {
|
||||||
|
var value = data.value;
|
||||||
|
location.href = '/doc/' + value;
|
||||||
|
});
|
||||||
|
}();
|
||||||
|
|
||||||
|
|
||||||
|
//点击事件
|
||||||
|
var events = {
|
||||||
|
//联系方式
|
||||||
|
contactInfo: function () {
|
||||||
|
layer.alert('<div class="layui-text">如有合作意向,可联系:<br>邮箱:xianxin@layui-inc.com</div>', {
|
||||||
|
title: '联系'
|
||||||
|
, btn: false
|
||||||
|
, shadeClose: true
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$body.on('click', '*[site-event]', function () {
|
||||||
|
var othis = $(this)
|
||||||
|
, attrEvent = othis.attr('site-event');
|
||||||
|
events[attrEvent] && events[attrEvent].call(this, othis);
|
||||||
|
});
|
||||||
|
|
||||||
|
//切换版本
|
||||||
|
form.on('select(tabVersion)', function (data) {
|
||||||
|
var value = data.value;
|
||||||
|
location.href = value === 'new' ? '/' : ('/' + value + '/doc/');
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
//首页banner
|
||||||
|
setTimeout(function () {
|
||||||
|
$('.site-zfj').addClass('site-zfj-anim');
|
||||||
|
setTimeout(function () {
|
||||||
|
$('.site-desc').addClass('site-desc-anim')
|
||||||
|
}, 5000)
|
||||||
|
}, 100);
|
||||||
|
|
||||||
|
|
||||||
|
//数字前置补零
|
||||||
|
var digit = function (num, length, end) {
|
||||||
|
var str = '';
|
||||||
|
num = String(num);
|
||||||
|
length = length || 2;
|
||||||
|
for (var i = num.length; i < length; i++) {
|
||||||
|
str += '0';
|
||||||
|
}
|
||||||
|
return num < Math.pow(10, length) ? str + (num | 0) : num;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//下载倒计时
|
||||||
|
var setCountdown = $('#setCountdown');
|
||||||
|
if ($('#setCountdown')[0]) {
|
||||||
|
$.get('/api/getTime', function (res) {
|
||||||
|
util.countdown(new Date(2017, 7, 21, 8, 30, 0), new Date(res.time), function (date, serverTime, timer) {
|
||||||
|
var str = digit(date[1]) + ':' + digit(date[2]) + ':' + digit(date[3]);
|
||||||
|
setCountdown.children('span').html(str);
|
||||||
|
});
|
||||||
|
}, 'jsonp');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
for (var i = 0; i < $('.adsbygoogle').length; i++) {
|
||||||
|
(adsbygoogle = window.adsbygoogle || []).push({});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//展示当前版本
|
||||||
|
$('.site-showv').html(layui.v);
|
||||||
|
|
||||||
|
////获取下载数
|
||||||
|
//$.get('//fly.layui.com/api/handle?id=10&type=find', function (res) {
|
||||||
|
// $('.site-showdowns').html(res.number);
|
||||||
|
//}, 'jsonp');
|
||||||
|
|
||||||
|
////记录下载
|
||||||
|
//$('.site-down').on('click', function () {
|
||||||
|
// $.get('//fly.layui.com/api/handle?id=10', function () { }, 'jsonp');
|
||||||
|
//});
|
||||||
|
|
||||||
|
//获取Github数据
|
||||||
|
var getStars = $('#getStars');
|
||||||
|
if (getStars[0]) {
|
||||||
|
$.get('https://api.github.com/repos/2881099/FreeSql', function (res) {
|
||||||
|
getStars.html(res.stargazers_count);
|
||||||
|
}, 'json');
|
||||||
|
}
|
||||||
|
|
||||||
|
//固定Bar
|
||||||
|
if (global.pageType !== 'demo') {
|
||||||
|
util.fixbar({
|
||||||
|
bar1: true
|
||||||
|
, click: function (type) {
|
||||||
|
if (type === 'bar1') {
|
||||||
|
location.href = '//fly.layui.com/';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
//窗口scroll
|
||||||
|
; !function () {
|
||||||
|
var main = $('.site-tree').parent(), scroll = function () {
|
||||||
|
var stop = $(window).scrollTop();
|
||||||
|
|
||||||
|
if ($(window).width() <= 750) return;
|
||||||
|
var bottom = $('.footer').offset().top - $(window).height();
|
||||||
|
if (stop > 211 && stop < bottom) {
|
||||||
|
if (!main.hasClass('site-fix')) {
|
||||||
|
main.addClass('site-fix');
|
||||||
|
}
|
||||||
|
if (main.hasClass('site-fix-footer')) {
|
||||||
|
main.removeClass('site-fix-footer');
|
||||||
|
}
|
||||||
|
} else if (stop >= bottom) {
|
||||||
|
if (!main.hasClass('site-fix-footer')) {
|
||||||
|
main.addClass('site-fix site-fix-footer');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (main.hasClass('site-fix')) {
|
||||||
|
main.removeClass('site-fix').removeClass('site-fix-footer');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stop = null;
|
||||||
|
};
|
||||||
|
scroll();
|
||||||
|
$(window).on('scroll', scroll);
|
||||||
|
}();
|
||||||
|
|
||||||
|
//示例页面滚动
|
||||||
|
$('.site-demo-body').on('scroll', function () {
|
||||||
|
var elemDate = $('.layui-laydate,.layui-colorpicker-main')
|
||||||
|
, elemTips = $('.layui-table-tips');
|
||||||
|
if (elemDate[0]) {
|
||||||
|
elemDate.each(function () {
|
||||||
|
var othis = $(this);
|
||||||
|
if (!othis.hasClass('layui-laydate-static')) {
|
||||||
|
othis.remove();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$('input').blur();
|
||||||
|
}
|
||||||
|
if (elemTips[0]) elemTips.remove();
|
||||||
|
|
||||||
|
if ($('.layui-layer')[0]) {
|
||||||
|
layer.closeAll('tips');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
//目录
|
||||||
|
var siteDir = $('.site-dir');
|
||||||
|
if (siteDir[0] && $(window).width() > 750) {
|
||||||
|
layer.ready(function () {
|
||||||
|
layer.open({
|
||||||
|
type: 1
|
||||||
|
, content: siteDir
|
||||||
|
, skin: 'layui-layer-dir'
|
||||||
|
, area: 'auto'
|
||||||
|
, maxHeight: $(window).height() - 300
|
||||||
|
, title: '目录'
|
||||||
|
//,closeBtn: false
|
||||||
|
, offset: 'r'
|
||||||
|
, shade: false
|
||||||
|
, success: function (layero, index) {
|
||||||
|
layer.style(index, {
|
||||||
|
marginLeft: -15
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
siteDir.find('li').on('click', function () {
|
||||||
|
var othis = $(this);
|
||||||
|
othis.find('a').addClass('layui-this');
|
||||||
|
othis.siblings().find('a').removeClass('layui-this');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
//在textarea焦点处插入字符
|
||||||
|
var focusInsert = function (str) {
|
||||||
|
var start = this.selectionStart
|
||||||
|
, end = this.selectionEnd
|
||||||
|
, offset = start + str.length
|
||||||
|
|
||||||
|
this.value = this.value.substring(0, start) + str + this.value.substring(end);
|
||||||
|
this.setSelectionRange(offset, offset);
|
||||||
|
};
|
||||||
|
|
||||||
|
//演示页面
|
||||||
|
$('body').on('keydown', '#LAY_editor, .site-demo-text', function (e) {
|
||||||
|
var key = e.keyCode;
|
||||||
|
if (key === 9 && window.getSelection) {
|
||||||
|
e.preventDefault();
|
||||||
|
focusInsert.call(this, ' ');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
var editor = $('#LAY_editor')
|
||||||
|
, iframeElem = $('#LAY_demo')
|
||||||
|
, demoForm = $('#LAY_demoForm')[0]
|
||||||
|
, demoCodes = $('#LAY_demoCodes')[0]
|
||||||
|
, runCodes = function () {
|
||||||
|
if (!iframeElem[0]) return;
|
||||||
|
var html = editor.val();
|
||||||
|
|
||||||
|
html = html.replace(/=/gi, "layequalsign");
|
||||||
|
html = html.replace(/script/gi, "layscrlayipttag");
|
||||||
|
demoCodes.value = html.length > 100 * 1000 ? '<h1>卧槽,你的代码过长</h1>' : html;
|
||||||
|
|
||||||
|
demoForm.action = '/api/runHtml/';
|
||||||
|
demoForm.submit();
|
||||||
|
|
||||||
|
};
|
||||||
|
$('#LAY_demo_run').on('click', runCodes), runCodes();
|
||||||
|
|
||||||
|
//让导航在最佳位置
|
||||||
|
var setScrollTop = function (thisItem, elemScroll) {
|
||||||
|
if (thisItem[0]) {
|
||||||
|
var itemTop = thisItem.offset().top
|
||||||
|
, winHeight = $(window).height();
|
||||||
|
if (itemTop > winHeight - 120) {
|
||||||
|
elemScroll.animate({ 'scrollTop': itemTop / 2 }, 200)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
setScrollTop($('.site-demo-nav').find('dd.layui-this'), $('.layui-side-scroll').eq(0));
|
||||||
|
setScrollTop($('.site-demo-table-nav').find('li.layui-this'), $('.layui-side-scroll').eq(1));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//查看代码
|
||||||
|
$(function () {
|
||||||
|
var DemoCode = $('#LAY_democode');
|
||||||
|
DemoCode.val([
|
||||||
|
DemoCode.val()
|
||||||
|
, '<body>'
|
||||||
|
, global.preview
|
||||||
|
, '\n<script src="//res.layui.com/layui/dist/layui.js" charset="utf-8"></script>'
|
||||||
|
, '\n<!-- 注意:如果你直接复制所有代码到本地,上述js路径需要改成你本地的 -->'
|
||||||
|
, $('#LAY_democodejs').html()
|
||||||
|
, '\n</body>\n</html>'
|
||||||
|
].join(''));
|
||||||
|
});
|
||||||
|
|
||||||
|
//点击查看代码选项
|
||||||
|
element.on('tab(demoTitle)', function (obj) {
|
||||||
|
if (obj.index === 1) {
|
||||||
|
if (device.ie && device.ie < 9) {
|
||||||
|
layer.alert('强烈不推荐你通过ie8/9 查看代码!因为,所有的标签都会被格式成大写,且没有换行符,影响阅读');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
//手机设备的简单适配
|
||||||
|
var treeMobile = $('.site-tree-mobile')
|
||||||
|
, shadeMobile = $('.site-mobile-shade')
|
||||||
|
|
||||||
|
treeMobile.on('click', function () {
|
||||||
|
$('body').addClass('site-mobile');
|
||||||
|
});
|
||||||
|
|
||||||
|
shadeMobile.on('click', function () {
|
||||||
|
$('body').removeClass('site-mobile');
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//愚人节
|
||||||
|
; !function () {
|
||||||
|
if (home.data('date') === '4-1') {
|
||||||
|
|
||||||
|
if (local['20180401']) return;
|
||||||
|
|
||||||
|
home.addClass('site-out-up');
|
||||||
|
setTimeout(function () {
|
||||||
|
layer.photos({
|
||||||
|
photos: {
|
||||||
|
"data": [{
|
||||||
|
"src": "//cdn.layui.com/upload/2018_4/168_1522515820513_397.png",
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
, anim: 2
|
||||||
|
, shade: 1
|
||||||
|
, move: false
|
||||||
|
, end: function () {
|
||||||
|
layer.msg('愚公,快醒醒!', {
|
||||||
|
shade: 1
|
||||||
|
}, function () {
|
||||||
|
layui.data('layui', {
|
||||||
|
key: '20180401'
|
||||||
|
, value: true
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
, success: function (layero, index) {
|
||||||
|
home.removeClass('site-out-up');
|
||||||
|
|
||||||
|
layero.find('#layui-layer-photos').on('click', function () {
|
||||||
|
layer.close(layero.attr('times'));
|
||||||
|
}).find('.layui-layer-imgsee').remove();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}, 1000 * 3);
|
||||||
|
}
|
||||||
|
}();
|
||||||
|
|
||||||
|
|
||||||
|
exports('global', {});
|
||||||
|
});
|
0
Examples/website/FreeSql.Site.UI/wwwroot/js/site.min.js
vendored
Normal file
0
Examples/website/FreeSql.Site.UI/wwwroot/js/site.min.js
vendored
Normal file
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user