cnf
6 天以前 aebd2d642e19ce9ccb253c671b239e7ed9fc91c6
WebApi/Gs.Sys/Services/MesConfigController.cs
@@ -1,5 +1,4 @@
using System.Data;
using System.Dynamic;
using System.Text;
using Gs.Toolbox;
using Gs.Toolbox.ApiCore.Abstract.Mvc;
@@ -9,89 +8,87 @@
using Microsoft.AspNetCore.Mvc;
using static Gs.Toolbox.UtilityHelper;
namespace Gs.Sys.Services;
/// <summary>
///     配置系统参数
/// </summary>
[ApiGroup(ApiGroupNames.Sys)]
public class MesConfigController : IRomteService
namespace Gs.Sys.Services
{
    private readonly IHttpContextAccessor _http;
    private readonly string _userCode, _userGuid, _orgFids;
    public MesConfigController(IHttpContextAccessor httpContextAccessor)
    {
        _http = httpContextAccessor;
        (_userCode, _userGuid, _orgFids) =
            GetUserGuidAndOrgGuid(_http);
    }
    /// <summary>
    /// 配置系统参数
    /// </summary>
    /// <param name="model"></param>
    /// <returns></returns>
    [RequestMethod(RequestMethods.POST)]
    public ReturnDto<int?> SetModel([FromBody] dynamic model)
    [ApiGroup(ApiGroupNames.Sys)]
    public class MesConfigController : IRomteService
    {
        string sql = model.sql;
        var rtnInt = (int)ReturnCode.Default;
        try
        private readonly IHttpContextAccessor _http;
        private readonly string _userCode, _userGuid, _orgFids;
        public MesConfigController(IHttpContextAccessor httpContextAccessor)
        {
            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);
            _http = httpContextAccessor;
            (_userCode, _userGuid, _orgFids) =
                GetUserGuidAndOrgGuid(_http);
        }
        if (rtnInt > 0)
            return ReturnDto<int>.QuickReturn(default(int?), ReturnCode.Success,
                "操作成功!");
        return ReturnDto<int>.QuickReturn(default(int?), ReturnCode.Exception,
            "删除失败,请重试!");
    }
    /// <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
        /// <summary>
        ///
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [RequestMethod(RequestMethods.POST)]
        public ReturnDto<int?> SetModel([FromBody] dynamic model)
        {
            var dset = new DataSet();
            dset = DbHelperSQL.Query(sbSql.ToString());
            if (dset != null && dset.Tables.Count > 0 &&
                dset.Tables[0].Rows.Count > 0)
            string sql = model.sql;
            int rtnInt = (int)ReturnCode.Default;
            try
            {
                var _tb = dset.Tables[0].TableToDynamicList();
                m.list = _tb;
                return ReturnDto<dynamic>.QuickReturn(m, ReturnCode.Success,
                    "读取成功!");
                StringBuilder strSql = new StringBuilder();
                strSql.Append(sql);
                int rows = DbHelperSQL.ExecuteSql(strSql.ToString());
                rtnInt = rows;
            }
            return ReturnDto<dynamic>.QuickReturn(m, ReturnCode.Default,
                "读取失败!");
            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, "删除失败,请重试!");
        }
        catch (Exception ex)
        /// <summary>
        /// 读取实体
        /// </summary>
        /// <param name="guid"></param>
        /// <returns></returns>
        [RequestMethod(RequestMethods.POST)]
        public ReturnDto<System.Dynamic.ExpandoObject> GetModel([FromBody] dynamic model)
        {
            LogHelper.Debug(ToString(), "GetModel error:" + ex.Message);
            return ReturnDto<dynamic>.QuickReturn(m, ReturnCode.Default,
                "读取失败!");
            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, "读取失败!");
            }
        }
    }
}
}