From 1b3db8f5683373dd8e179b006e7314783dd1f9db Mon Sep 17 00:00:00 2001 From: cnf <3200815559@qq.com> Date: 星期三, 10 九月 2025 14:42:12 +0800 Subject: [PATCH] 文件补充 --- WebApi/Gs.Sys/Services/MesConfigController.cs | 139 +++++++++++++++++++++++---------------------- 1 files changed, 71 insertions(+), 68 deletions(-) diff --git a/WebApi/Gs.Sys/Services/MesConfigController.cs b/WebApi/Gs.Sys/Services/MesConfigController.cs index 1ccb2ee..c6d0cf3 100644 --- a/WebApi/Gs.Sys/Services/MesConfigController.cs +++ b/WebApi/Gs.Sys/Services/MesConfigController.cs @@ -1,4 +1,5 @@ 锘縰sing System.Data; +using System.Dynamic; using System.Text; using Gs.Toolbox; using Gs.Toolbox.ApiCore.Abstract.Mvc; @@ -8,87 +9,89 @@ using Microsoft.AspNetCore.Mvc; using static Gs.Toolbox.UtilityHelper; -namespace Gs.Sys.Services +namespace Gs.Sys.Services; + +/// <summary> +/// 閰嶇疆绯荤粺鍙傛暟 +/// </summary> +[ApiGroup(ApiGroupNames.Sys)] +public class MesConfigController : IRomteService { + private readonly IHttpContextAccessor _http; + private readonly string _userCode, _userGuid, _orgFids; + + public MesConfigController(IHttpContextAccessor httpContextAccessor) + { + _http = httpContextAccessor; + (_userCode, _userGuid, _orgFids) = + GetUserGuidAndOrgGuid(_http); + } + /// <summary> - /// 閰嶇疆绯荤粺鍙傛暟 /// </summary> - - [ApiGroup(ApiGroupNames.Sys)] - public class MesConfigController : IRomteService + /// <param name="model"></param> + /// <returns></returns> + [RequestMethod(RequestMethods.POST)] + public ReturnDto<int?> SetModel([FromBody] dynamic model) { - - private readonly IHttpContextAccessor _http; - private readonly string _userCode, _userGuid, _orgFids; - - public MesConfigController(IHttpContextAccessor httpContextAccessor) + string sql = model.sql; + var rtnInt = (int)ReturnCode.Default; + try { - _http = httpContextAccessor; - (_userCode, _userGuid, _orgFids) = - GetUserGuidAndOrgGuid(_http); + var strSql = new StringBuilder(); + strSql.Append(sql); + var rows = DbHelperSQL.ExecuteSql(strSql.ToString()); + rtnInt = rows; + } + catch (Exception ex) + { + LogHelper.Debug(ToString(), "SetSql error锛�" + ex.Message); + rtnInt = (int)ReturnCode.Exception; + return ReturnDto<int>.QuickReturn(default(int?), + ReturnCode.Exception, "鍒犻櫎澶辫触锛�" + ex.Message); } + if (rtnInt > 0) + return ReturnDto<int>.QuickReturn(default(int?), ReturnCode.Success, + "鎿嶄綔鎴愬姛锛�"); + return ReturnDto<int>.QuickReturn(default(int?), ReturnCode.Exception, + "鍒犻櫎澶辫触锛岃閲嶈瘯锛�"); + } - /// <summary> - /// - /// </summary> - /// <param name="model"></param> - /// <returns></returns> - [RequestMethod(RequestMethods.POST)] - public ReturnDto<int?> SetModel([FromBody] dynamic model) + /// <summary> + /// 璇诲彇瀹炰綋 + /// </summary> + /// <param name="guid"></param> + /// <returns></returns> + [RequestMethod(RequestMethods.POST)] + public ReturnDto<ExpandoObject> GetModel([FromBody] dynamic model) + { + dynamic m = new ExpandoObject(); + m.list = new List<dynamic>(); + var sbSql = new StringBuilder(); + sbSql.Append(" select * from MES_CONFIG"); + try { - string sql = model.sql; - int rtnInt = (int)ReturnCode.Default; - try + var dset = new DataSet(); + dset = DbHelperSQL.Query(sbSql.ToString()); + if (dset != null && dset.Tables.Count > 0 && + dset.Tables[0].Rows.Count > 0) { - StringBuilder strSql = new StringBuilder(); - strSql.Append(sql); - int rows = DbHelperSQL.ExecuteSql(strSql.ToString()); - rtnInt = rows; + var _tb = dset.Tables[0].TableToDynamicList(); + m.list = _tb; + return ReturnDto<dynamic>.QuickReturn(m, ReturnCode.Success, + "璇诲彇鎴愬姛锛�"); } - catch (Exception ex) - { - LogHelper.Debug(this.ToString(), "SetSql error锛�" + ex.Message); - rtnInt = (int)ReturnCode.Exception; - return ReturnDto<int>.QuickReturn(default(int?), ReturnCode.Exception, "鍒犻櫎澶辫触锛�" + ex.Message); - } - if (rtnInt > 0) - return ReturnDto<int>.QuickReturn(default(int?), ReturnCode.Success, "鎿嶄綔鎴愬姛锛�"); - else - return ReturnDto<int>.QuickReturn(default(int?), ReturnCode.Exception, "鍒犻櫎澶辫触锛岃閲嶈瘯锛�"); + + return ReturnDto<dynamic>.QuickReturn(m, ReturnCode.Default, + "璇诲彇澶辫触锛�"); } - - /// <summary> - /// 璇诲彇瀹炰綋 - /// </summary> - /// <param name="guid"></param> - /// <returns></returns> - [RequestMethod(RequestMethods.POST)] - public ReturnDto<System.Dynamic.ExpandoObject> GetModel([FromBody] dynamic model) + catch (Exception ex) { - dynamic m = new System.Dynamic.ExpandoObject(); - m.list = new List<dynamic>(); - System.Text.StringBuilder sbSql = new StringBuilder(); - sbSql.Append(" select * from MES_CONFIG"); - try - { - DataSet dset = new DataSet(); - dset = DbHelperSQL.Query(sbSql.ToString()); - if (dset != null && dset.Tables.Count > 0 && dset.Tables[0].Rows.Count > 0) - { - var _tb = dset.Tables[0].TableToDynamicList(); - m.list = _tb; - return ReturnDto<dynamic>.QuickReturn(m, ReturnCode.Success, "璇诲彇鎴愬姛锛�"); - } - else - return ReturnDto<dynamic>.QuickReturn(m, ReturnCode.Default, "璇诲彇澶辫触锛�"); - } - catch (Exception ex) - { - LogHelper.Debug(this.ToString(), "GetModel error:" + ex.Message); - return ReturnDto<dynamic>.QuickReturn(m, ReturnCode.Default, "璇诲彇澶辫触锛�"); - } + LogHelper.Debug(ToString(), "GetModel error:" + ex.Message); + return ReturnDto<dynamic>.QuickReturn(m, ReturnCode.Default, + "璇诲彇澶辫触锛�"); } } -} +} \ No newline at end of file -- Gitblit v1.9.3