Commit d26f1849 by wish_lf

增加功能:流水自动检测

parent 505f4020
using Bailun.DC.Models.Component.Enum;
using System;
namespace Bailun.DC.Models.Component.Entity
{
/// <summary>
/// 字典组件
/// </summary>
public class dc_component_dictionary
{
/// <summary>
/// ID
/// </summary>
public int id { get; set; }
/// <summary>
/// 名称
/// </summary>
public string name { get; set; }
/// <summary>
/// 编码
/// </summary>
public string code { get; set; }
/// <summary>
/// 分类:1:数据源
/// </summary>
public DictionaryCategoryEnum? category { get; set; }
/// <summary>
/// 类型:1:SQL
/// </summary>
public DictionaryTypeEnum? type { get; set; }
/// <summary>
/// 方法:get;post;
/// </summary>
public string method { get; set; }
/// <summary>
/// 值
/// </summary>
public string value { get; set; }
/// <summary>
/// 数据库:1: 数据中心, 2: 交易流水
/// </summary>
public DBEnum? data_db { get; set; }
/// <summary>
/// 是否删除: 1:是; 0:否
/// </summary>
public bool is_delete { get; set; }
/// <summary>
/// 创建时间
/// </summary>
public DateTime gmt_create { get; set; }
/// <summary>
/// 更新时间
/// </summary>
public DateTime gmt_modified { get; set; }
}
}
......@@ -14,6 +14,11 @@ namespace Bailun.DC.Models.Component.Entity
public int id { get; set; }
/// <summary>
/// 名称
/// </summary>
public string name { get; set; }
/// <summary>
/// 通用查询代码
/// </summary>
public string code { get; set; }
......
......@@ -3,21 +3,26 @@
namespace Bailun.DC.Models.Component.Enum
{
/// <summary>
/// 列名类型:1:API,2:SQL,3:本地配置
/// 字典分类:1: 数据源
/// </summary>
public enum ColumnTypeEnum
public enum DictionaryCategoryEnum
{
[Description("API")]
Api = 1,
/// <summary>
/// SQL
/// 数据源
/// </summary>
[Description("SQL")]
Sql = 2,
[Description("数据源")]
DataSource = 1
}
/// <summary>
/// 字典类型:1: SQL
/// </summary>
public enum DictionaryTypeEnum
{
/// <summary>
/// 本地配置
/// SQL
/// </summary>
[Description("配置")]
Config = 3
[Description("SQL")]
SQL = 1
}
}
......@@ -3,6 +3,25 @@
namespace Bailun.DC.Models.Component.Enum
{
/// <summary>
/// 列名类型:1:API,2:SQL,3:本地配置
/// </summary>
public enum ColumnTypeEnum
{
[Description("API")]
Api = 1,
/// <summary>
/// SQL
/// </summary>
[Description("SQL")]
Sql = 2,
/// <summary>
/// 本地配置
/// </summary>
[Description("配置")]
Config = 3
}
/// <summary>
/// 列名类型:1:Api,2:Sql,3:数据库表或视图,4:动态SQL,5:储存过程
/// </summary>
public enum DataTypeEnum
......
using Bailun.DC.Models.Component.Entity;
using Bailun.DC.Models.Component.Enum;
using Dapper;
using System.Collections.Generic;
using System.Linq;
namespace Bailun.DC.Services.Component
{
/// <summary>
/// 字典组件
/// </summary>
public class DictionaryService : BaseService
{
/// <summary>
/// 获取字典组件
/// </summary>
/// <param name="sqlparam">参数</param>
/// <returns></returns>
public IEnumerable<dynamic> GetList(DynamicParameters sqlparam = null)
{
IEnumerable<dynamic> list = default(IEnumerable<dynamic>);
dc_component_dictionary entity = default(dc_component_dictionary);
if (sqlparam != null && sqlparam.ParameterNames.Contains("code"))
{
using (var db = DB)
{
entity = db.QueryFirstOrDefault<dc_component_dictionary>("select * from dc_component_dictionary where is_delete = 0 and code = @code", sqlparam);
}
if (entity != null)
{
switch (entity.type)
{
case DictionaryTypeEnum.SQL:
//查询
using (var db = (entity.data_db == DBEnum.DataWareHouse ? DW_DB : DB))
{
list = db.Query(entity.value, sqlparam);
}
break;
}
}
}
return list;
}
}
}
using Bailun.DC.Models.Component.DTO;
using Bailun.DC.Services.Component;
using Dapper;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Linq;
namespace Bailun.DC.Web.Areas.Component.Controllers
{
[Area("Component")]
public class DictionaryController : Base.BaseController
{
public JsonResult GetList()
{
ResultDTO result = new ResultDTO();
try
{
DynamicParameters sqlparam = new DynamicParameters();
switch (Request.Method)
{
case "GET":
Request.Query.Keys.ForEach(l => sqlparam.Add(l, Request.Query[l]));
break;
case "POST":
if (Request.ContentType.Contains("multipart/form-data"))
{
Request.Form.Keys.ForEach(l => sqlparam.Add(l, Request.Form[l]));
}
else if (Request.ContentType.Contains("application/json"))
{
using (Stream stream = Request.Body)
{
byte[] buffer = new byte[Request.ContentLength.Value];
stream.Read(buffer, 0, buffer.Length);
string content = Encoding.UTF8.GetString(buffer);
IDictionary<string, object> dic = JsonConvert.DeserializeObject<IDictionary<string, object>>(content);
dic.ForEach(l => sqlparam.Add(l.Key, dic[l.Key]));
}
}
break;
}
result.Data = new DictionaryService().GetList(sqlparam);
result.Result = true;
}
catch (Exception ex)
{
result.Message = ex.Message;
}
return Json(result);
}
}
}
......@@ -98,8 +98,9 @@
emulateJSON: method == "post"
}).then(function (response) {
var result = response.data;
if (response.status == 200 && result && result.length) {
var listOptionValue = response.data.list || (Array.isArray(response.data) && response.data)
if (response.status == 200 && result && (result.length || (result.data && result.data.length))) {
debugger
var listOptionValue = Array.isArray(result) ? result : (Array.isArray(result.data) ? result.data : result.data.list);
if (listOptionValue && listOptionValue.length && (listOptionValue[0].constructor === String || listOptionValue[0].constructor === Number)) {
listOptionValue = listOptionValue.map(function (item, index) {
return { value: item, display: item };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment