diff --git a/Tiobon.Core.Api/Controllers/Ghra_GradeController.cs b/Tiobon.Core.Api/Controllers/Ghra_GradeController.cs index 649a282a..2293c02b 100644 --- a/Tiobon.Core.Api/Controllers/Ghra_GradeController.cs +++ b/Tiobon.Core.Api/Controllers/Ghra_GradeController.cs @@ -4,7 +4,7 @@ /// Ghra_Grade /// [Route("api/[controller]")] - [ApiController] + [ApiController, GlobalActionFilter] [Authorize(Permissions.Name), ApiExplorerSettings(GroupName = Grouping.GroupName_Ghra)] public class Ghra_GradeController : ControllerBase { @@ -89,7 +89,7 @@ if (data.success) { data.msg = "更新成功"; - //data.response = request?.Id.ObjToString(); + data.response = request?.Id.ObjToString(); } return data; @@ -112,7 +112,7 @@ if (data.success) { data.msg = "删除成功"; - //data.response = model?.Id.ObjToString(); + data.response = model?.Id.ObjToString(); } return data; diff --git a/Tiobon.Core.Api/Controllers/LoginController.cs b/Tiobon.Core.Api/Controllers/LoginController.cs index 83884c07..45e55436 100644 --- a/Tiobon.Core.Api/Controllers/LoginController.cs +++ b/Tiobon.Core.Api/Controllers/LoginController.cs @@ -155,7 +155,7 @@ namespace Tiobon.Core.Controllers //如果是基于用户的授权策略,这里要添加用户;如果是基于角色的授权策略,这里要添加角色 var claims = new List { - new Claim(ClaimTypes.Name, name), + new Claim(ClaimTypes.Name, user.FirstOrDefault().Id.ToString()), new Claim(JwtRegisteredClaimNames.Jti, user.FirstOrDefault().Id.ToString()), new Claim("TenantId", user.FirstOrDefault().TenantId.ToString()), new Claim(JwtRegisteredClaimNames.Iat, DateTime.Now.DateToTimeStamp()), diff --git a/Tiobon.Core.Api/Filter/GlobalActionFilter.cs b/Tiobon.Core.Api/Filter/GlobalActionFilter.cs new file mode 100644 index 00000000..e94c207f --- /dev/null +++ b/Tiobon.Core.Api/Filter/GlobalActionFilter.cs @@ -0,0 +1,260 @@ +using Microsoft.AspNetCore.Mvc.Filters; +using System.Security.Claims; + +namespace Tiobon.Core.Api.Filter +{ + /// + /// 全局请求验证 + /// + public class GlobalActionFilter : ActionFilterAttribute + { + /// + /// + /// + public string Message { get; set; } + /// + /// + /// + /// + public override void OnActionExecuting(ActionExecutingContext filterContext) + { + //检查实体合法性 + if (!filterContext.ModelState.IsValid) + { + StringBuilder msg = new StringBuilder(); + foreach (var value in filterContext.ModelState.Values) + { + if (value.Errors.Count > 0) + { + foreach (var error in value.Errors) + { + msg.AppendLine(error.ErrorMessage); + } + } + } + filterContext.Result = new JsonResult(MessageModel.OprateFailed($"参数验证失败:{msg}")); + return; + } + + ////检查用户信息 + //var tenantId = filterContext.HttpContext.User?.Claims?.Where(o => o.Type == CustomClaimTypes.TenantId).FirstOrDefault()?.Value; + //var issuer = filterContext.HttpContext.User?.Claims?.Where(o => o.Type == CustomClaimTypes.Issuer).FirstOrDefault()?.Value; + //var userId = filterContext.HttpContext.User?.Claims?.Where(o => o.Type == CustomClaimTypes.UserId).FirstOrDefault()?.Value; + //var userName = filterContext.HttpContext.User?.Claims?.Where(o => o.Type == CustomClaimTypes.UserName).FirstOrDefault()?.Value; + //var sessionId = filterContext.HttpContext.User?.Claims?.Where(o => o.Type == CustomClaimTypes.SessionId).FirstOrDefault()?.Value; + //var sids = RedisHelper.Get>(string.Format(RedisConsts.SYSTEM_LOGIN_USERID, issuer, userId)) ?? new List(); + //if (string.IsNullOrEmpty(sessionId) || !sids.Any(o => o.ToString() == sessionId)) + //{ + // filterContext.Result = new JsonResult(MessageModel.OprateFailed(ResponseText.LOGIN_USER_QUIT, MessageModelCode.LoginFailed)); + // return; + //} + + ////记录ip + //var ip = filterContext.HttpContext.Request.Headers["X-Forwarded-For"].FirstOrDefault(); + //if (string.IsNullOrEmpty(ip)) + //{ + // ip = filterContext.HttpContext.Request.HttpContext.Connection.RemoteIpAddress.ToString(); + //} + //var claims = new Claim[] { + // new Claim(CustomClaimTypes.RequestIp, ip),//添加IP + // }; + //filterContext.HttpContext.User.AddIdentity(new ClaimsIdentity(claims)); + + ////记录日志(GET请求不记录) + //if (filterContext.HttpContext.Request.Method != "GET") + //{ + // LoggerOperator.PushLogger(new Domain.Model.System.SystemLogger(Guid.NewGuid()) + // { + // Module = GetModel(filterContext.HttpContext.Request.Path), + // Type = GetType(filterContext.HttpContext.Request.Method, filterContext.HttpContext.Request.Path), + // Level = $"INFO", + // Content = $"{filterContext.HttpContext.User.Claims.FirstOrDefault(o => o.Type == CustomClaimTypes.Issuer)?.Value} {filterContext.HttpContext.Request.Path} {Dic2String(filterContext.ActionArguments)}", + // Creator = string.IsNullOrEmpty(userName) ? "sys" : userName, + // CreatorId = string.IsNullOrEmpty(userId) ? new Guid?() : Guid.Parse(userId), + // CreationTime = DateTimeHelper.Now(), + // TenantId = string.IsNullOrEmpty(tenantId) ? new Guid?() : Guid.Parse(tenantId) + // }); + // LoggerOperator.PushModelLogger(new Domain.Model.System.SystemModelLogger(Guid.NewGuid()) + // { + // Module = GetModel(filterContext.HttpContext.Request.Path), + // Oprate = filterContext.HttpContext.Request.Method, + // ApiUrl = GetPath(filterContext.HttpContext.Request.Path), + // Creator = string.IsNullOrEmpty(userName) ? "sys" : userName, + // CreatorId = string.IsNullOrEmpty(userId) ? new Guid?() : Guid.Parse(userId), + // CreationTime = DateTimeHelper.Now(), + // TenantId = string.IsNullOrEmpty(tenantId) ? new Guid?() : Guid.Parse(tenantId) + // }); + //} + + //LoggerOperator.PushTerminalLogger(filterContext.HttpContext.User.Claims.FirstOrDefault(o => o.Type == CustomClaimTypes.TerminalId)?.Value); + base.OnActionExecuting(filterContext); + } + private static string GetPath(string rpath) + { + string res = rpath; + try + { + StringBuilder sb = new StringBuilder(); + string[] empties = res.Split(new string[] { "/" }, StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < empties.Length; ++i) + { + //36位长度,并且全为小写是ID + if (empties[i].Length == 36 && empties[i] == empties[i].ToLower()) + { + continue; + } + sb.Append(empties[i]); + if (i != empties.Length - 1) + sb.Append("/"); + if (empties[i].ToLower().StartsWith("by")) + { + i++; + } + } + if (sb.Length > 0) + res = sb.ToString(); + } + catch { } + return res; + } + + private static string Dic2String(IDictionary dic) + { + if (dic == null || dic.Keys.Count <= 0) + return string.Empty; + StringBuilder sb = new StringBuilder(); + try + { + foreach (KeyValuePair item in dic) + { + if (item.Value == null) + continue; + sb.Append($"{item.Key}:{(item.Value.ToString().StartsWith("{") ? item.Value.ToString() : Newtonsoft.Json.JsonConvert.SerializeObject(item.Value))};"); + } + } + catch { } + return sb.ToString(); + } + + //private static string GetModel(string path) + //{ + // string model = SystemSetting.SYS_LOG_MODEL_SYS; + // if (path.StartsWith("/api/Dialysis")) + // { + // model = SystemSetting.SYS_LOG_MODEL_DIALYSIS; + // } + // else if (path.StartsWith("/api/Emr")) + // { + // model = SystemSetting.SYS_LOG_MODEL_PATIENT; + // } + // else if (path.StartsWith("/api/Dept")) + // { + // model = SystemSetting.SYS_LOG_MODEL_DEPT; + // } + // else if (path.StartsWith("/api/System")) + // { + // model = SystemSetting.SYS_LOG_MODEL_SYS; + // } + // else if (path.StartsWith("/api/Authorize")) + // { + // model = SystemSetting.SYS_LOG_MODEL_LOGIN; + // } + // else if (path.StartsWith("/api/Tmpl")) + // { + // model = SystemSetting.SYS_LOG_MODEL_TMPL; + // } + // else if (path.StartsWith("/api/Schedule")) + // { + // model = SystemSetting.SYS_LOG_MODEL_SCHEDULE; + // } + + // return model; + //} + //private static string GetType(string method, string path) + //{ + // string type = SystemSetting.SYS_LOG_TYPE_OTHER; + // switch (method) + // { + // case "GET": + // type = SystemSetting.SYS_LOG_TYPE_QUERY; + // break; + // case "PUT": + // type = SystemSetting.SYS_LOG_TYPE_EDIT; + // break; + // case "POST": + // type = SystemSetting.SYS_LOG_TYPE_INSERTY; + // break; + // case "DELETE": + // type = SystemSetting.SYS_LOG_TYPE_DELETE; + // break; + // default: + // break; + // } + // if (path.StartsWith("/api/Token")) + // { + // type = SystemSetting.SYS_LOG_TYPE_LOGIN; + // } + // return type; + //} + /// + /// + /// + /// + public override void OnActionExecuted(ActionExecutedContext filterContext) + { + base.OnActionExecuted(filterContext); + } + /// + /// + /// + /// + public override void OnResultExecuting(ResultExecutingContext filterContext) + { + //400错误,统一处理 + if (filterContext.Result is BadRequestObjectResult badResult && badResult.StatusCode == 400) + { + var error = $"{filterContext.HttpContext.Request.Method} {filterContext.HttpContext.Request.Path} 请求的数据类型不正确"; + if (badResult.Value is Microsoft.AspNetCore.Mvc.ValidationProblemDetails values) + { + StringBuilder sb = new StringBuilder(); + foreach (var value in values.Errors) + { + if (value.Value is string[] empties && empties.Length > 0) + { + if (empties[0].Contains(". Path")) + { + sb.AppendLine($"{value.Key.ToString()}:{empties[0].Split(". Path")[0]}"); + } + else + { + sb.Append($"{value.Key.ToString()}:{empties[0]}"); + } + } + } + error += $":{sb.ToString()}"; + filterContext.Result = new JsonResult(MessageModel.OprateFailed($"请求的数据类型不正确:{error}")); + } + else + { + filterContext.Result = new JsonResult(MessageModel.OprateFailed(error)); + } + //LoggerHelper.SendLog(error); + return; + } + if (filterContext.Result is ObjectResult objectResult && objectResult.Value == null) + { + filterContext.Result = new JsonResult(MessageModel.OprateSuccess("查询成功")); + } + + base.OnResultExecuting(filterContext); + } + /// + /// + /// + /// + public override void OnResultExecuted(ResultExecutedContext filterContext) + { + base.OnResultExecuted(filterContext); + } + } +} diff --git a/Tiobon.Core.Api/GlobalUsings.cs b/Tiobon.Core.Api/GlobalUsings.cs index bf90ffe8..40d06266 100644 --- a/Tiobon.Core.Api/GlobalUsings.cs +++ b/Tiobon.Core.Api/GlobalUsings.cs @@ -5,6 +5,7 @@ global using AutoMapper; global using Microsoft.AspNetCore.Authorization; global using Microsoft.AspNetCore.Mvc; global using Newtonsoft.Json; +global using Tiobon.Core.Api.Filter; global using Tiobon.Core.Common; global using Tiobon.Core.Common.Helper; global using Tiobon.Core.Common.HttpContextUser; diff --git a/Tiobon.Core.Api/Program.cs b/Tiobon.Core.Api/Program.cs index 48be8e8e..5b70419c 100644 --- a/Tiobon.Core.Api/Program.cs +++ b/Tiobon.Core.Api/Program.cs @@ -169,6 +169,8 @@ if (builder.Configuration.GetValue("AppSettings:UseLoadTest")) { app.UseMiddleware(); } +//配置HttpContext +app.UseStaticHttpContext(); app.UseAuthentication(); app.UseAuthorization(); diff --git a/Tiobon.Core.Api/Tiobon.Core.Model.xml b/Tiobon.Core.Api/Tiobon.Core.Model.xml index da2d9e18..fda06293 100644 --- a/Tiobon.Core.Api/Tiobon.Core.Model.xml +++ b/Tiobon.Core.Api/Tiobon.Core.Model.xml @@ -4,242 +4,184 @@ Tiobon.Core.Model - + - 无任何权限 + 表主键 - + - 自定义权限 + 序号 - + - 本部门 + 1:有效,0:未生效 - + - 本部门及以下 + 是否默认 - + - 仅自己 + 操作日志ID - + - 所有 + 创建人 - + - + 创建时间 - + - Desc: - Default: - Nullable:False + 创建程序 - + - Desc: - Default: - Nullable:True + 创建IP - + - Desc: - Default: - Nullable:True + 最后修改人 - + - Desc: - Default: - Nullable:True + 最后修改时间 - + - Desc: - Default: - Nullable:True + 最后修改程序 - + - Desc: - Default: - Nullable:True + 最后修改IP - + - Desc: - Default:1 - Nullable:False - + 备注 + - + - Desc: - Default:1 - Nullable:False + 无任何权限 - + - Desc: - Default:1 - Nullable:False + 自定义权限 - + - Desc: - Default:0 - Nullable:True + 本部门 - + - Desc: - Default:0 - Nullable:False + 本部门及以下 - + - Desc: - Default:DateTime.Now - Nullable:False + 仅自己 - + - Desc: - Default: - Nullable:True + 所有 - + - Desc: - Default: - Nullable:True + Ghra_Grade - + - Desc: - Default: - Nullable:True + Reverse6 - + - Desc: - Default: - Nullable:True + MKey - + - Desc: - Default: - Nullable:True + Reverse9 - + - Desc: - Default: - Nullable:True + Reverse3 - + - Desc: - Default: - Nullable:True + Reverse4 - + - Desc: - Default: - Nullable:True + ReverseI1 - + - Desc: - Default: - Nullable:True + DataBelongID - + - Desc: - Default: - Nullable:True + Reverse7 - + - Desc: - Default: - Nullable:True + GradeNo - + - Desc: - Default: - Nullable:True + Reverse1 - + - Desc: - Default: - Nullable:True + Reverse2 - + - Desc: - Default: - Nullable:True + Reverse5 - + - Desc: - Default: - Nullable:True + GradeName - + - Desc: - Default: - Nullable:True + Reverse8 - Desc: - Default: - Nullable:True + ReverseI2 @@ -1998,6 +1940,21 @@ 返回数据集合 + + + 操作成功 + + + + + + + 操作失败 + + + + + 部门表 diff --git a/Tiobon.Core.Api/Tiobon.Core.xml b/Tiobon.Core.Api/Tiobon.Core.xml index a8db25c2..a483e5b2 100644 --- a/Tiobon.Core.Api/Tiobon.Core.xml +++ b/Tiobon.Core.Api/Tiobon.Core.xml @@ -1565,6 +1565,40 @@ + + + 全局请求验证 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Summary:全局路由权限公约 diff --git a/Tiobon.Core.Common/Seed/FrameSeed.cs b/Tiobon.Core.Common/Seed/FrameSeed.cs index c5b479e2..acef9a72 100644 --- a/Tiobon.Core.Common/Seed/FrameSeed.cs +++ b/Tiobon.Core.Common/Seed/FrameSeed.cs @@ -1,8 +1,10 @@ +using Microsoft.AspNetCore.Mvc.ModelBinding; using SqlSugar; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; +using Tiobon.Core.Model.Models; namespace Tiobon.Core.Common.Seed { @@ -141,7 +143,7 @@ namespace Tiobon.Core.Common.Seed /// {ClassName} /// [Route(""api/[controller]"")] - [ApiController] + [ApiController, GlobalActionFilter] [Authorize(Permissions.Name), ApiExplorerSettings(GroupName = Grouping.GroupName_" + groupName + @")] public class {ClassName}Controller : ControllerBase { @@ -335,7 +337,160 @@ namespace " + strNameSpace + @" //.SettingConstructorTemplate(p => p = " this._{PropertyName} ={DefaultValue};") .ToClassStringList(strNameSpace); + + StringBuilder build = new StringBuilder(); + var tableName = lstTableNames[0]; + string sql = @"SELECT A.name AS table_name, + B.name AS column_name, + D.data_type, + C.value AS column_description, + D.NUMERIC_PRECISION, D.NUMERIC_SCALE,D.CHARACTER_MAXIMUM_LENGTH + FROM sys.tables A + INNER JOIN sys.columns B ON B.object_id = A.object_id + LEFT JOIN sys.extended_properties C + ON C.major_id = B.object_id AND C.minor_id = B.column_id + LEFT JOIN information_schema.columns D + ON D.column_name = B.name AND D.TABLE_NAME = '{0}' + WHERE A.name = '{0}'"; + sql = string.Format(sql, tableName); + var dtColumn = sqlSugarClient.Ado.GetDataTable(sql); + build.Append("/* 代码由框架生成,任何更改都可能导致被代码生成器覆盖,可自行修改。\r\n"); + build.Append("* " + tableName + ".cs\r\n"); + build.Append("*\r\n"); + build.Append("*功 能: N / A\r\n"); + build.Append("* 类 名: " + tableName + "\r\n"); + build.Append("*\r\n"); + build.Append("* Ver 变更日期 负责人 变更内容\r\n"); + build.Append("* ───────────────────────────────────\r\n"); + build.Append("*V0.01 " + DateTime.Now.ToString() + " SimonHsiao 初版\r\n"); + build.Append("*\r\n"); + build.Append("* Copyright(c) " + DateTime.Now.Year + " Tiobon Corporation. All Rights Reserved.\r\n"); + build.Append("*┌──────────────────────────────────┐\r\n"); + build.Append("*│ 此技术信息为本公司机密信息,未经本公司书面同意禁止向第三方披露. │\r\n"); + build.Append("*│ 作者:SimonHsiao │\r\n"); + build.Append("*└──────────────────────────────────┘\r\n"); + build.Append("*/ \r\n"); + build.Append("using System.ComponentModel;\r\n"); + build.Append("using System.ComponentModel.DataAnnotations;\r\n"); + build.Append("using SqlSugar;\r\n"); + build.Append("\r\n"); + build.Append("namespace Tiobon.Core.Model.Models\r\n"); + build.Append("{\r\n"); + build.Append("\r\n"); + build.Append(" /// \r\n"); + build.Append(" /// " + tableName + "\r\n"); + build.Append(" /// \r\n"); + build.Append(@" [SugarTable(" + "\"" + tableName + "\"" + ", " + "\"" + tableName + "\"" + ")]\r\n"); + build.Append(" public class " + tableName + " : BasePoco\r\n"); + build.Append(" {\r\n"); + + #region 属性 + //build.Append("\r\n"); + + #region 处理表字段 + string columnCode = string.Empty; + string dataType = string.Empty; + string column_description = string.Empty; + string NUMERIC_PRECISION = string.Empty; + string NUMERIC_SCALE = string.Empty; + string CHARACTER_MAXIMUM_LENGTH = string.Empty; + + string[] a = { + "Id", "SortNo", "IsEnable", "IsDefault", "OperateLogID", "CreateBy", "CreateTime", + "CreateProg", "CreateIP", "UpdateBy", "UpdateTime", "UpdateProg","UpdateIP","RemarkSz" + + }; + + for (int i = 0; i < dtColumn.Rows.Count; i++) + { + columnCode = dtColumn.Rows[i]["column_name"].ToString(); + dataType = dtColumn.Rows[i]["data_type"].ToString(); + column_description = dtColumn.Rows[i]["column_description"].ToString(); + NUMERIC_PRECISION = dtColumn.Rows[i]["NUMERIC_PRECISION"].ToString(); + NUMERIC_SCALE = dtColumn.Rows[i]["NUMERIC_SCALE"].ToString(); + CHARACTER_MAXIMUM_LENGTH = dtColumn.Rows[i]["CHARACTER_MAXIMUM_LENGTH"].ToString(); + + if (string.IsNullOrWhiteSpace(column_description)) + column_description = columnCode; + + if (a.Contains(columnCode)) + continue; + + build.Append("\r\n"); + build.Append(" /// \r\n"); + build.Append(" /// " + column_description + "\r\n"); + build.Append(" /// \r\n"); + if (dataType == "decimal") + build.Append($" [Display(Name = \"" + columnCode + "\"), Description(\"" + column_description + "\"), Column(TypeName = \"decimal(" + NUMERIC_PRECISION + "," + NUMERIC_SCALE + ")\")]\r\n"); + else if (dataType == "varchar" || dataType == "nvarchar" || dataType == "char" || dataType == "text") + build.Append(" [Display(Name = \"" + columnCode + "\"), Description(\"" + column_description + "\"), MaxLength(" + CHARACTER_MAXIMUM_LENGTH + ", ErrorMessage = \"" + column_description + " 不能超过 " + CHARACTER_MAXIMUM_LENGTH + " 个字符\")]\r\n"); + else if (dataType == "decimal") + build.Append(" [Display(Name = \"" + columnCode + "\"), Description(\"" + column_description + "\")]\r\n"); + + switch (dataType) + { + #region 字符串 + case "varchar": + case "nvarchar": + case "char": + case "text": + { + build.Append(" public string " + columnCode + " { get; set; }\r\n"); + break; + } + #endregion + + #region 日期 + case "datetime": + case "date": + { + build.Append(" public DateTime? " + columnCode + " { get; set; }\r\n"); + break; + } + #endregion + + #region 数字 + case "decimal": + { + + build.Append(" public decimal? " + columnCode + " { get; set; }\r\n"); + } + break; + case "int": + { + + build.Append(" public int? " + columnCode + " { get; set; }\r\n"); + + break; + } + case "uniqueidentifier": + { + + build.Append(" public Guid? " + columnCode + " { get; set; }\r\n"); + + break; + } + case "bit": + { + + build.Append(" public bool? " + columnCode + " { get; set; }\r\n"); + + break; + } + #endregion + } + } + #endregion + #endregion + + + build.Append("}\r\n"); + build.Append("}\r\n"); + + ls[tableName] = build.ToString(); CreateFilesByClassStringList(ls, strPath, "{0}"); + + } #endregion diff --git a/Tiobon.Core.Model/Base/BasePoco.cs b/Tiobon.Core.Model/Base/BasePoco.cs new file mode 100644 index 00000000..db2a43e9 --- /dev/null +++ b/Tiobon.Core.Model/Base/BasePoco.cs @@ -0,0 +1,96 @@ +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using SqlSugar; + +namespace Tiobon.Core.Model +{ + public class BasePoco + { + + /// + /// 表主键 + /// + //public long Id { get; set; } + [SugarColumn(IsNullable = false, IsPrimaryKey = true, IsIdentity = false), Display(Name = "表主键")] + public long Id { get; set; } + + /// + /// 序号 + /// + [Display(Name = "序号")] + public int SortNo { get; set; } + + /// + /// 1:有效,0:未生效 + /// + [Display(Name = "1:有效,0:未生效")] + public int IsEnable { get; set; } + + /// + /// 是否默认 + /// + [Display(Name = "是否默认")] + public int IsDefault { get; set; } + + /// + /// 操作日志ID + /// + [Display(Name = "操作日志ID")] + public long? OperateLogID { get; set; } + + /// + /// 创建人 + /// + [Display(Name = "创建人")] + public int CreateBy { get; set; } + + /// + /// 创建时间 + /// + [Display(Name = "创建时间")] + public DateTime CreateTime { get; set; } + + /// + /// 创建程序 + /// + [Display(Name = "创建程序")] + public string CreateProg { get; set; } + + /// + /// 创建IP + /// + [Display(Name = "创建IP")] + public string CreateIP { get; set; } + + /// + /// 最后修改人 + /// + [Display(Name = "最后修改人")] + public int? UpdateBy { get; set; } + + /// + /// 最后修改时间 + /// + [Display(Name = "最后修改时间")] + public DateTime? UpdateTime { get; set; } + + /// + /// 最后修改程序 + /// + [Display(Name = "最后修改程序")] + public string UpdateProg { get; set; } + + /// + /// 最后修改IP + /// + [Display(Name = "最后修改IP")] + public string UpdateIP { get; set; } + + /// + /// 备注 + /// + [Display(Name = "备注"), Description("备注"), MaxLength(1000, ErrorMessage = "备注 不能超过 2000 个字符")] + public string RemarkSz { get; set; } + + } +} diff --git a/Tiobon.Core.Model/Ghra_Grade.cs b/Tiobon.Core.Model/Ghra_Grade.cs index b6eef5e9..900592c9 100644 --- a/Tiobon.Core.Model/Ghra_Grade.cs +++ b/Tiobon.Core.Model/Ghra_Grade.cs @@ -1,196 +1,118 @@ -using System; -using System.Linq; -using System.Text; +/* 代码由框架生成,任何更改都可能导致被代码生成器覆盖,可自行修改。 +* Ghra_Grade.cs +* +*功 能: N / A +* 类 名: Ghra_Grade +* +* Ver 变更日期 负责人 变更内容 +* ─────────────────────────────────── +*V0.01 2024/4/12 17:02:53 SimonHsiao 初版 +* +* Copyright(c) 2024 Tiobon Corporation. All Rights Reserved. +*┌──────────────────────────────────┐ +*│ 此技术信息为本公司机密信息,未经本公司书面同意禁止向第三方披露. │ +*│ 作者:SimonHsiao │ +*└──────────────────────────────────┘ +*/ +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; using SqlSugar; - namespace Tiobon.Core.Model.Models { - /// - /// - /// - [SugarTable("Ghra_Grade", "wmtiobon_mssql_main")] - public class Ghra_Grade + + /// + /// Ghra_Grade + /// + [SugarTable("Ghra_Grade", "Ghra_Grade")] + public class Ghra_Grade : BasePoco { - public Ghra_Grade() - { - } - /// - /// Desc: - /// Default: - /// Nullable:False - /// - //[SugarColumn(IsNullable = false, IsPrimaryKey = true, IsIdentity = false)] - //public long Id { get; set; } - [SugarColumn(IsPrimaryKey = true)]//long类型的主键会自动赋值 - public long Id { get; set; } - /// - /// Desc: - /// Default: - /// Nullable:True - /// - public string GradeNo { get; set; } + /// - /// Desc: - /// Default: - /// Nullable:True + /// Reverse6 /// - public string GradeName { get; set; } + [Display(Name = "Reverse6"), Description("Reverse6"), MaxLength(1000, ErrorMessage = "Reverse6 不能超过 1000 个字符")] + public string Reverse6 { get; set; } + /// - /// Desc: - /// Default: - /// Nullable:True + /// MKey /// + [Display(Name = "MKey"), Description("MKey"), MaxLength(200, ErrorMessage = "MKey 不能超过 200 个字符")] public string MKey { get; set; } + /// - /// Desc: - /// Default: - /// Nullable:True - /// - public int? DataBelongID { get; set; } - /// - /// Desc: - /// Default: - /// Nullable:True - /// - public string RemarkSz { get; set; } - /// - /// Desc: - /// Default:1 - /// Nullable:False - /// - public int SortNo { get; set; } - /// - /// Desc: - /// Default:1 - /// Nullable:False - /// - public int IsEnable { get; set; } - /// - /// Desc: - /// Default:1 - /// Nullable:False - /// - public int IsDefault { get; set; } - /// - /// Desc: - /// Default:0 - /// Nullable:True - /// - public long? OperateLogID { get; set; } - /// - /// Desc: - /// Default:0 - /// Nullable:False - /// - public int CreateBy { get; set; } - /// - /// Desc: - /// Default:DateTime.Now - /// Nullable:False + /// Reverse9 /// - public DateTime CreateTime { get; set; } + [Display(Name = "Reverse9"), Description("Reverse9"), MaxLength(1000, ErrorMessage = "Reverse9 不能超过 1000 个字符")] + public string Reverse9 { get; set; } + /// - /// Desc: - /// Default: - /// Nullable:True + /// Reverse3 /// - public string CreateProg { get; set; } + [Display(Name = "Reverse3"), Description("Reverse3"), MaxLength(1000, ErrorMessage = "Reverse3 不能超过 1000 个字符")] + public string Reverse3 { get; set; } + /// - /// Desc: - /// Default: - /// Nullable:True + /// Reverse4 /// - public string CreateIP { get; set; } + [Display(Name = "Reverse4"), Description("Reverse4"), MaxLength(1000, ErrorMessage = "Reverse4 不能超过 1000 个字符")] + public string Reverse4 { get; set; } + /// - /// Desc: - /// Default: - /// Nullable:True + /// ReverseI1 /// - public int? UpdateBy { get; set; } + public int? ReverseI1 { get; set; } + /// - /// Desc: - /// Default: - /// Nullable:True + /// DataBelongID /// - public DateTime? UpdateTime { get; set; } + public int? DataBelongID { get; set; } + /// - /// Desc: - /// Default: - /// Nullable:True + /// Reverse7 /// - public string UpdateProg { get; set; } + [Display(Name = "Reverse7"), Description("Reverse7"), MaxLength(1000, ErrorMessage = "Reverse7 不能超过 1000 个字符")] + public string Reverse7 { get; set; } + /// - /// Desc: - /// Default: - /// Nullable:True + /// GradeNo /// - public string UpdateIP { get; set; } + [Display(Name = "GradeNo"), Description("GradeNo"), MaxLength(100, ErrorMessage = "GradeNo 不能超过 100 个字符")] + public string GradeNo { get; set; } + /// - /// Desc: - /// Default: - /// Nullable:True + /// Reverse1 /// + [Display(Name = "Reverse1"), Description("Reverse1"), MaxLength(1000, ErrorMessage = "Reverse1 不能超过 1000 个字符")] public string Reverse1 { get; set; } + /// - /// Desc: - /// Default: - /// Nullable:True + /// Reverse2 /// + [Display(Name = "Reverse2"), Description("Reverse2"), MaxLength(1000, ErrorMessage = "Reverse2 不能超过 1000 个字符")] public string Reverse2 { get; set; } + /// - /// Desc: - /// Default: - /// Nullable:True - /// - public string Reverse3 { get; set; } - /// - /// Desc: - /// Default: - /// Nullable:True - /// - public string Reverse4 { get; set; } - /// - /// Desc: - /// Default: - /// Nullable:True + /// Reverse5 /// + [Display(Name = "Reverse5"), Description("Reverse5"), MaxLength(1000, ErrorMessage = "Reverse5 不能超过 1000 个字符")] public string Reverse5 { get; set; } + /// - /// Desc: - /// Default: - /// Nullable:True - /// - public string Reverse6 { get; set; } - /// - /// Desc: - /// Default: - /// Nullable:True + /// GradeName /// - public string Reverse7 { get; set; } + [Display(Name = "GradeName"), Description("GradeName"), MaxLength(1000, ErrorMessage = "GradeName 不能超过 1000 个字符")] + public string GradeName { get; set; } + /// - /// Desc: - /// Default: - /// Nullable:True + /// Reverse8 /// + [Display(Name = "Reverse8"), Description("Reverse8"), MaxLength(1000, ErrorMessage = "Reverse8 不能超过 1000 个字符")] public string Reverse8 { get; set; } + /// - /// Desc: - /// Default: - /// Nullable:True - /// - public string Reverse9 { get; set; } - /// - /// Desc: - /// Default: - /// Nullable:True - /// - public int? ReverseI1 { get; set; } - /// - /// Desc: - /// Default: - /// Nullable:True + /// ReverseI2 /// public int? ReverseI2 { get; set; } - } -} \ No newline at end of file +} +} diff --git a/Tiobon.Core.Model/MessageModel.cs b/Tiobon.Core.Model/MessageModel.cs index 28ead746..64e1da07 100644 --- a/Tiobon.Core.Model/MessageModel.cs +++ b/Tiobon.Core.Model/MessageModel.cs @@ -95,5 +95,36 @@ /// 返回数据集合 /// public object response { get; set; } + + /// + /// 操作成功 + /// + /// + /// + public static MessageModel OprateSuccess(string msg = "操作成功") + { + return new MessageModel + { + msg = msg, + success = true, + response = null + }; + } + + /// + /// 操作失败 + /// + /// + /// + /// + public static MessageModel OprateFailed(string msg = "操作失败", int status = 500) + { + return new MessageModel + { + msg = msg, + status = status, + response = null + }; + } } } diff --git a/Tiobon.Core.Services/BASE/BaseServices.cs b/Tiobon.Core.Services/BASE/BaseServices.cs index 7e92ed25..998df50a 100644 --- a/Tiobon.Core.Services/BASE/BaseServices.cs +++ b/Tiobon.Core.Services/BASE/BaseServices.cs @@ -3,6 +3,7 @@ using System.Linq.Expressions; using SqlSugar; using Tiobon.Core.Common; using Tiobon.Core.Common.Helper; +using Tiobon.Core.Common.UserManager; using Tiobon.Core.IRepository.Base; using Tiobon.Core.IServices.BASE; using Tiobon.Core.Model; @@ -54,6 +55,7 @@ namespace Tiobon.Core.Services.BASE /// public async Task Add(TEntity entity) { + var userId = UserContext.Current.User_Id; return await BaseDal.Add(entity); }