|
@@ -0,0 +1,50 @@
|
|
|
+using System;
|
|
|
+using System.Collections.Generic;
|
|
|
+using System.Data.SqlClient;
|
|
|
+using System.Linq;
|
|
|
+using System.Text;
|
|
|
+using System.Threading.Tasks;
|
|
|
+
|
|
|
+namespace JLHHJSvr.BLL
|
|
|
+{
|
|
|
+ internal abstract class HelperBase
|
|
|
+ {
|
|
|
+ /// <summary>
|
|
|
+ /// 数据库连接
|
|
|
+ /// </summary>
|
|
|
+ public SqlCommand cmd { get; set; }
|
|
|
+ /// <summary>
|
|
|
+ /// 预留的上下文
|
|
|
+ /// </summary>
|
|
|
+ public Context context { get; set; }
|
|
|
+ public static T GetHelper<T>(SqlCommand cmd) where T : HelperBase, new()
|
|
|
+ {
|
|
|
+ var rslt = new T();
|
|
|
+ rslt.cmd = cmd;
|
|
|
+ return rslt;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static T GetHelper<T>(SqlCommand cmd, Context context) where T : HelperBase, new()
|
|
|
+ {
|
|
|
+ var rslt = new T();
|
|
|
+ rslt.cmd = cmd;
|
|
|
+ rslt.context = context ?? new Context();
|
|
|
+ return rslt;
|
|
|
+ }
|
|
|
+
|
|
|
+ public sealed class Context
|
|
|
+ {
|
|
|
+ private DateTime _opdate = DateTime.Now;
|
|
|
+
|
|
|
+ public DateTime opdate
|
|
|
+ {
|
|
|
+ get { return _opdate; }
|
|
|
+ set { _opdate = value; }
|
|
|
+ }
|
|
|
+ /// <summary>
|
|
|
+ /// 用户登陆信息
|
|
|
+ /// </summary>
|
|
|
+ public TokenData tokendata { get; set; }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|