啊鑫
8 天以前 f2b71fe1d3c2b7651d525a5b5bbe66fad602ea06
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
using System.Data;
using System.Dynamic;
using System.Text;
using Gs.Toolbox;
using Gs.Toolbox.ApiCore.Abstract.Mvc;
using Gs.Toolbox.ApiCore.Common.Mvc;
using Gs.Toolbox.ApiCore.Group;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using static Gs.Toolbox.UtilityHelper;
 
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>
    /// <param name="model"></param>
    /// <returns></returns>
    [RequestMethod(RequestMethods.POST)]
    public ReturnDto<int?> SetModel([FromBody] dynamic model)
    {
        string sql = model.sql;
        var rtnInt = (int)ReturnCode.Default;
        try
        {
            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="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
        {
            var 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,
                    "读取成功!");
            }
 
            return ReturnDto<dynamic>.QuickReturn(m, ReturnCode.Default,
                "读取失败!");
        }
        catch (Exception ex)
        {
            LogHelper.Debug(ToString(), "GetModel error:" + ex.Message);
            return ReturnDto<dynamic>.QuickReturn(m, ReturnCode.Default,
                "读取失败!");
        }
    }
}