Compare commits

..

No commits in common. '84c2e9fccc54052be580308a5db166d2bb38f360' and '7d4acd61c0844a1d020007bc49338cd4e6243509' have entirely different histories.

@ -22,38 +22,14 @@ namespace ZKLT.Hadoop.API.Controllers
private IHadoopService _HadoopService; private IHadoopService _HadoopService;
[HttpGet("getid")] [HttpGet("getid")]
public ActionResult GetId([FromQuery] string? prefix, [FromQuery] int? count) { public ActionResult GetId([FromQuery] string? prefix) {
if (count != null && count > 0) string _result = "";
{ if (!string.IsNullOrEmpty(prefix)) {
List<string> _result = new List<string>(); _result += prefix;
for (int i = 0; i < count; i++) { }
string _temp = ""; var _date = DateTime.Now;
if (!string.IsNullOrEmpty(prefix)) _result += $@"{_date.Year.ToString().PadLeft(4,'0')}{_date.Month.ToString().PadLeft(2, '0')}{_date.Day.ToString().PadLeft(2, '0')}{_date.Hour.ToString().PadLeft(2, '0')}{_date.Minute.ToString().PadLeft(2, '0')}{_date.Second.ToString().PadLeft(2, '0')}{_date.Millisecond.ToString().PadLeft(3, '0')}{new Random().Next(1000).ToString().PadLeft(4,'0')}";
{ return Ok(_result);
_temp += prefix;
}
var _date = DateTime.Now;
_temp += $@"{_date.Year.ToString().PadLeft(4, '0')}{_date.Month.ToString().PadLeft(2, '0')}{_date.Day.ToString().PadLeft(2, '0')}{_date.Hour.ToString().PadLeft(2, '0')}{_date.Minute.ToString().PadLeft(2, '0')}{_date.Second.ToString().PadLeft(2, '0')}{_date.Millisecond.ToString().PadLeft(3, '0')}{new Random().Next(9999).ToString().PadLeft(4, '0')}";
if (_result.Any(v => v == _temp))
{
i--;
}
else {
_result.Add(_temp);
}
}
return Ok(_result);
}
else {
string _result = "";
if (!string.IsNullOrEmpty(prefix))
{
_result += prefix;
}
var _date = DateTime.Now;
_result += $@"{_date.Year.ToString().PadLeft(4, '0')}{_date.Month.ToString().PadLeft(2, '0')}{_date.Day.ToString().PadLeft(2, '0')}{_date.Hour.ToString().PadLeft(2, '0')}{_date.Minute.ToString().PadLeft(2, '0')}{_date.Second.ToString().PadLeft(2, '0')}{_date.Millisecond.ToString().PadLeft(3, '0')}{new Random().Next(9999).ToString().PadLeft(4, '0')}";
return Ok(_result);
}
} }
[HttpGet("getsource")] [HttpGet("getsource")]

@ -40,25 +40,25 @@ namespace ZKLT.Hadoop.API
app.UseCors("all"); app.UseCors("all");
#endregion #endregion
app.UseHadoop((c) =>
{
c.Host = "127.0.0.1";
c.Account = "root";
c.PassWord = "root";
c.Key = "hadoopdb";
c.Port = 3306;
});
//app.UseHadoop((c) => //app.UseHadoop((c) =>
//{ //{
// c.Host = "127.0.0.1"; // c.Host = "172.17.0.1";
// c.Account = "root"; // c.Account = "root";
// c.PassWord = "root"; // c.PassWord = "root";
// c.Key = "hadoopdb"; // c.Key = "testdb";
// c.Port = 3306; // c.Port = 4000;
//}); //});
app.UseHadoop((c) =>
{
c.Host = app.Configuration["ConnectionStrings:Host"];
c.Account = app.Configuration["ConnectionStrings:Account"];
c.PassWord = app.Configuration["ConnectionStrings:PassWord"];
c.Key = app.Configuration["ConnectionStrings:Key"];
c.Port = Convert.ToInt32(app.Configuration["ConnectionStrings:Port"]);
});
//app.UseHadoop((c) => //app.UseHadoop((c) =>
//{ //{
// c.Host = "118.195.165.218"; // c.Host = "118.195.165.218";

@ -8,7 +8,7 @@
"ASPNETCORE_ENVIRONMENT": "Development" "ASPNETCORE_ENVIRONMENT": "Development"
}, },
"dotnetRunMessages": true, "dotnetRunMessages": true,
"applicationUrl": "http://*:5171" "applicationUrl": "http://localhost:5171"
}, },
"IIS Express": { "IIS Express": {
"commandName": "IISExpress", "commandName": "IISExpress",
@ -33,7 +33,7 @@
"windowsAuthentication": false, "windowsAuthentication": false,
"anonymousAuthentication": true, "anonymousAuthentication": true,
"iisExpress": { "iisExpress": {
"applicationUrl": "http://localhost:43666", "applicationUrl": "http://localhost:59844",
"sslPort": 0 "sslPort": 0
} }
} }

@ -4,12 +4,5 @@
"Default": "Information", "Default": "Information",
"Microsoft.AspNetCore": "Warning" "Microsoft.AspNetCore": "Warning"
} }
},
"ConnectionStrings": {
"Host": "1.94.127.210",
"Account": "root",
"PassWord": "Panjiandong1994",
"Key": "erptest",
"Port": "3306"
} }
} }

@ -5,12 +5,5 @@
"Microsoft.AspNetCore": "Warning" "Microsoft.AspNetCore": "Warning"
} }
}, },
"AllowedHosts": "*", "AllowedHosts": "*"
"ConnectionStrings": {
"Host": "1.94.127.210",
"Account": "root",
"PassWord": "Panjiandong1994",
"Key": "erptest",
"Port": "3306"
}
} }

@ -1 +0,0 @@
docker build -f ./Dockerfile -t hadoop:1.0.3 ../../.

@ -1,5 +1,4 @@
using Newtonsoft.Json.Linq; using System;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@ -33,7 +32,7 @@ namespace ZKLT.Hadoop.Interface
/// <param name="table">数据表</param> /// <param name="table">数据表</param>
/// <param name="row">数据</param> /// <param name="row">数据</param>
/// <returns>是否成功</returns> /// <returns>是否成功</returns>
public bool Insert(HDP_Source source, HDP_Table table, JContainer? row); public bool Insert(HDP_Source source, HDP_Table table, Dictionary<string, object> row);
/// <summary> /// <summary>
/// 更新 /// 更新
@ -43,7 +42,7 @@ namespace ZKLT.Hadoop.Interface
/// <param name="where">条件</param> /// <param name="where">条件</param>
/// <param name="row">数据</param> /// <param name="row">数据</param>
/// <returns>是否成功</returns> /// <returns>是否成功</returns>
public bool Update(HDP_Source source, HDP_Table table, JContainer? where, JContainer? row); public bool Update(HDP_Source source, HDP_Table table, Dictionary<string, string> where, Dictionary<string, object> row);
/// <summary> /// <summary>
/// 删除 /// 删除
@ -53,7 +52,7 @@ namespace ZKLT.Hadoop.Interface
/// <param name="where">条件</param> /// <param name="where">条件</param>
/// <param name="row">数据</param> /// <param name="row">数据</param>
/// <returns>是否成功</returns> /// <returns>是否成功</returns>
public bool Delete(HDP_Source source, HDP_Table table, JContainer? where, JContainer? row); public bool Delete(HDP_Source source, HDP_Table table, Dictionary<string, string> where, Dictionary<string, object> row);
/// <summary> /// <summary>
/// 查询单个 /// 查询单个
@ -63,7 +62,7 @@ namespace ZKLT.Hadoop.Interface
/// <param name="where">条件</param> /// <param name="where">条件</param>
/// <param name="row">数据</param> /// <param name="row">数据</param>
/// <returns>结果</returns> /// <returns>结果</returns>
public T? QuerySingle<T>(HDP_Source source, HDP_Table table, JContainer? where, JContainer? row, string[]? col); public T? QuerySingle<T>(HDP_Source source, HDP_Table table, Dictionary<string, string> where, Dictionary<string, object> row, string[]? col);
/// <summary> /// <summary>
/// 查询列表 /// 查询列表
@ -74,8 +73,8 @@ namespace ZKLT.Hadoop.Interface
/// <param name="where">条件</param> /// <param name="where">条件</param>
/// <param name="row">数据</param> /// <param name="row">数据</param>
/// <returns>结果集</returns> /// <returns>结果集</returns>
public T[] Query<T>(HDP_Source source, HDP_Table table, JContainer? where, JContainer? row, public T[] Query<T>(HDP_Source source, HDP_Table table, Dictionary<string, string>? where, Dictionary<string, object>? row,
JContainer? order, string[]? col); Dictionary<string, object>? order, string[]? col);
/// <summary> /// <summary>
/// 查询列表 /// 查询列表
@ -86,7 +85,7 @@ namespace ZKLT.Hadoop.Interface
/// <param name="where">条件</param> /// <param name="where">条件</param>
/// <param name="row">数据</param> /// <param name="row">数据</param>
/// <returns>结果集</returns> /// <returns>结果集</returns>
public HDP_Page<T> QueryPage<T>(HDP_Source source, HDP_Table table, int pageIndex, int pageSize, JContainer? where, JContainer? row, JContainer? order, string[]? col); public HDP_Page<T> QueryPage<T>(HDP_Source source, HDP_Table table, int pageIndex, int pageSize, Dictionary<string, string>? where, Dictionary<string, object>? row, Dictionary<string, object>? order, string[]? col);
/// <summary> /// <summary>

@ -1,5 +1,4 @@
using Newtonsoft.Json.Linq; using System;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@ -24,11 +23,11 @@ namespace ZKLT.Hadoop.Model
private string[]? _Col; private string[]? _Col;
private JContainer? _Where; private Dictionary<string, string>? _Where;
private JContainer? _Data; private Dictionary<string, object>? _Data;
private JContainer? _Order; private Dictionary<string, object>? _Order;
/// <summary> /// <summary>
/// 源 /// 源
@ -43,12 +42,12 @@ namespace ZKLT.Hadoop.Model
/// <summary> /// <summary>
/// 条件 /// 条件
/// </summary> /// </summary>
public JContainer? Where { get => _Where; set => _Where = value; } public Dictionary<string, string>? Where { get => _Where; set => _Where = value; }
/// <summary> /// <summary>
/// 数据 /// 数据
/// </summary> /// </summary>
public JContainer? Data { get => _Data; set => _Data = value; } public Dictionary<string, object>? Data { get => _Data; set => _Data = value; }
/// <summary> /// <summary>
/// 分页下标 /// 分页下标
@ -63,7 +62,7 @@ namespace ZKLT.Hadoop.Model
/// <summary> /// <summary>
/// 排序 /// 排序
/// </summary> /// </summary>
public JContainer? Order { get => _Order; set => _Order = value; } public Dictionary<string, object>? Order { get => _Order; set => _Order = value; }
/// <summary> /// <summary>
/// 命令类型 /// 命令类型

@ -1,10 +1,8 @@
using Newtonsoft.Json.Linq; using System;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Text.RegularExpressions;
namespace ZKLT.Hadoop.Model namespace ZKLT.Hadoop.Model
{ {
@ -29,7 +27,7 @@ namespace ZKLT.Hadoop.Model
/// <param name="action">函数</param> /// <param name="action">函数</param>
/// <param name="param">参数</param> /// <param name="param">参数</param>
/// <returns>命令</returns> /// <returns>命令</returns>
public static object Convert(string action, JContainer param) public static object Convert(string action, Dictionary<string, object> param)
{ {
if (action == DATENOW) if (action == DATENOW)
{ {
@ -43,35 +41,5 @@ namespace ZKLT.Hadoop.Model
return action; return action;
} }
} }
/// <summary>
/// 列转换
/// </summary>
/// <param name="column">列</param>
/// <param name="param">参数</param>
/// <param name="action">公式</param>
/// <returns></returns>
public static string ColConvert(HDP_Column column, Dictionary<string, object> param,object value) {
string _guid;
if (value is string) {
string _action = value.ToString()!;
Regex _regex1 = new Regex(@"(?<=(\+\=))[\d\.]+");
if(_regex1.IsMatch(_action))
{
_guid = Guid.NewGuid().ToString("N");
param.Add(_guid,_regex1.Match(_action).Value);
return @$"`{column.Key}` + @{_guid}";
}
Regex _regex2 = new Regex(@"(?<=(\-\=))[\d\.]+");
if (_regex2.IsMatch(_action))
{
_guid = Guid.NewGuid().ToString("N");
param.Add(_guid, _regex2.Match(_action).Value);
return @$"`{column.Key}` - @{_guid}";
}
}
param.Add(column.Key!, value);
return $@"@{column.Key}";
}
} }
} }

@ -1,6 +1,4 @@
using Newtonsoft.Json; using System;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using System.Linq; using System.Linq;
@ -140,14 +138,5 @@ namespace ZKLT.Hadoop.Model
return _result; return _result;
} }
/// <summary>
/// 类转JObject
/// </summary>
/// <param name="data">数据</param>
/// <returns></returns>
public static JObject Class2JObject(object data) {
return JsonConvert.DeserializeObject<JObject>(JsonConvert.SerializeObject(data)!)!;
}
} }
} }

@ -10,8 +10,4 @@
<None Remove="HDP_Table.cs~RF4db01d6c.TMP" /> <None Remove="HDP_Table.cs~RF4db01d6c.TMP" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>
</Project> </Project>

@ -1,7 +1,6 @@
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using MySqlX.XDevAPI.Relational; using MySqlX.XDevAPI.Relational;
using Newtonsoft.Json.Linq;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -141,11 +140,10 @@ namespace ZKLT.Hadoop
{ {
return _Source; return _Source;
} }
var _result = _TableService.QuerySingle<HDP_Source>(_Source, GetTable("HDP_Source")!, new Dictionary<string, string>
var _result = _TableService.QuerySingle<HDP_Source>(_Source, GetTable("HDP_Source")!, new JObject
{ {
{ "Id","=" } { "Id","=" }
}, new JObject { }, new Dictionary<string, object> {
{ "Id",sourceid} { "Id",sourceid}
}, null); }, null);
return _result; return _result;
@ -188,7 +186,7 @@ namespace ZKLT.Hadoop
throw new ArgumentException("编号已存在"); throw new ArgumentException("编号已存在");
} }
return _TableService.Insert(_Source, GetTable("HDP_Source")!, HDP_Table.Class2JObject(source)); return _TableService.Insert(_Source, GetTable("HDP_Source")!, HDP_Table.Class2Dictionary(source));
} }
/// <summary> /// <summary>
@ -228,9 +226,9 @@ namespace ZKLT.Hadoop
throw new ArgumentException("编号不存在"); throw new ArgumentException("编号不存在");
} }
return _TableService.Update(_Source, GetTable("HDP_Source")!, new JObject { return _TableService.Update(_Source, GetTable("HDP_Source")!, new Dictionary<string, string> {
{"Id","=" } {"Id","=" }
}, HDP_Table.Class2JObject(source)); }, HDP_Table.Class2Dictionary(source));
} }
/// <summary> /// <summary>
@ -250,9 +248,9 @@ namespace ZKLT.Hadoop
throw new ArgumentException("编号不存在"); throw new ArgumentException("编号不存在");
} }
return _TableService.Delete(_Source, GetTable("HDP_Source")!, new JObject{ return _TableService.Delete(_Source, GetTable("HDP_Source")!, new Dictionary<string, string> {
{"Id","=" } {"Id","=" }
}, new JObject{ }, new Dictionary<string, object> {
{"Id",sourceid } {"Id",sourceid }
}); });
} }
@ -284,18 +282,18 @@ namespace ZKLT.Hadoop
return _Tables.First(x => x.Id == tableid); return _Tables.First(x => x.Id == tableid);
} }
var _result = _TableService.QuerySingle<HDP_Table>(_Source, GetTable("HDP_Table")!, new JObject var _result = _TableService.QuerySingle<HDP_Table>(_Source, GetTable("HDP_Table")!, new Dictionary<string, string>
{ {
{ "Id","=" } { "Id","=" }
}, new JObject{ }, new Dictionary<string, object> {
{ "Id",tableid} { "Id",tableid}
}, null); }, null);
if (_result != null) if (_result != null)
{ {
_result.Columns = _TableService.Query<HDP_Column>(_Source, GetTable("HDP_Column")!, new JObject { _result.Columns = _TableService.Query<HDP_Column>(_Source, GetTable("HDP_Column")!, new Dictionary<string, string> {
{ "TableId","="} { "TableId","="}
}, new JObject{ }, new Dictionary<string, object> {
{"TableId",_result.Id! } {"TableId",_result.Id! }
}, null, null); }, null, null);
} }
@ -322,7 +320,7 @@ namespace ZKLT.Hadoop
{ {
using (TransactionScope _scope = new TransactionScope()) using (TransactionScope _scope = new TransactionScope())
{ {
if (!_TableService.Insert(_Source, GetTable("HDP_Table")!, HDP_Table.Class2JObject(table))) if (!_TableService.Insert(_Source, GetTable("HDP_Table")!, HDP_Table.Class2Dictionary(table)))
{ {
return false; return false;
} }
@ -330,7 +328,7 @@ namespace ZKLT.Hadoop
{ {
var _column = table.Columns![i]; var _column = table.Columns![i];
_column.TableId = table.Id; _column.TableId = table.Id;
if (!_TableService.Insert(_Source, GetTable("HDP_Column")!, HDP_Table.Class2JObject(_column))) if (!_TableService.Insert(_Source, GetTable("HDP_Column")!, HDP_Table.Class2Dictionary(_column)))
{ {
return false; return false;
} }
@ -364,9 +362,9 @@ namespace ZKLT.Hadoop
{ {
using (TransactionScope _scope = new TransactionScope()) using (TransactionScope _scope = new TransactionScope())
{ {
if (!_TableService.Update(_Source, GetTable("HDP_Table")!, new JObject{ if (!_TableService.Update(_Source, GetTable("HDP_Table")!, new Dictionary<string, string> {
{ "Id","="} { "Id","="}
}, HDP_Table.Class2JObject(table))) }, HDP_Table.Class2Dictionary(table)))
{ {
return false; return false;
} }
@ -375,21 +373,21 @@ namespace ZKLT.Hadoop
{ {
var _column = table.Columns![i]; var _column = table.Columns![i];
_column.TableId = table.Id; _column.TableId = table.Id;
if (_TableService.QuerySingle<HDP_Column>(_Source, GetTable("HDP_Column")!, new JObject if (_TableService.QuerySingle<HDP_Column>(_Source, GetTable("HDP_Column")!, new Dictionary<string, string>
{ {
{"Id","=" } {"Id","=" }
}, HDP_Table.Class2JObject(_column), null) == null) }, HDP_Table.Class2Dictionary(_column), null) == null)
{ {
if (!_TableService.Insert(_Source, GetTable("HDP_Column")!, HDP_Table.Class2JObject(_column))) if (!_TableService.Insert(_Source, GetTable("HDP_Column")!, HDP_Table.Class2Dictionary(_column)))
{ {
return false; return false;
} }
} }
else else
{ {
if (!_TableService.Update(_Source, GetTable("HDP_Column")!, new JObject { if (!_TableService.Update(_Source, GetTable("HDP_Column")!, new Dictionary<string, string> {
{"Id","=" } {"Id","=" }
}, HDP_Table.Class2JObject(_column))) }, HDP_Table.Class2Dictionary(_column)))
{ {
return false; return false;
} }
@ -425,17 +423,17 @@ namespace ZKLT.Hadoop
using (TransactionScope _scope = new TransactionScope()) using (TransactionScope _scope = new TransactionScope())
{ {
if (!_TableService.Delete(_Source, GetTable("HDP_Table")!, new JObject{ if (!_TableService.Delete(_Source, GetTable("HDP_Table")!, new Dictionary<string, string> {
{"Id","=" } {"Id","=" }
}, new JObject { }, new Dictionary<string, object> {
{"Id",tableId } {"Id",tableId }
})) }))
{ {
return false; return false;
} }
if (!_TableService.Delete(_Source, GetTable("HDP_Column")!, new JObject{ if (!_TableService.Delete(_Source, GetTable("HDP_Column")!, new Dictionary<string, string> {
{ "TableId","="} { "TableId","="}
}, new JObject { }, new Dictionary<string, object> {
{"TableId",tableId } {"TableId",tableId }
})) }))
{ {

@ -12,8 +12,6 @@ using MySqlX.XDevAPI.Relational;
using Mysqlx.Crud; using Mysqlx.Crud;
using Newtonsoft.Json; using Newtonsoft.Json;
using Mysqlx.Resultset; using Mysqlx.Resultset;
using Newtonsoft.Json.Linq;
using System.Transactions;
namespace ZKLT.Hadoop namespace ZKLT.Hadoop
{ {
@ -24,80 +22,60 @@ namespace ZKLT.Hadoop
/// </summary> /// </summary>
/// <param name="table">表</param> /// <param name="table">表</param>
/// <param name="where">条件</param> /// <param name="where">条件</param>
/// <param name="data">数据</param> /// <param name="row">数据</param>
/// <param name="command">命令</param>
/// <param name="param">参数</param> /// <param name="param">参数</param>
private string MergeWhere(HDP_Table table, JContainer? where, JContainer? data, Dictionary<string, object> param) private void MergeWhere(HDP_Table table, Dictionary<string, string>? where, Dictionary<string, object>? row, StringBuilder command, Dictionary<string, object> param)
{ {
StringBuilder _wherestr = new StringBuilder();
string _guid = ""; string _guid = "";
if (where != null && data != null) //执行条件
StringBuilder _wherestr = new StringBuilder();
_wherestr.Append("WHERE 1 = 1");
if (where != null && where.Count > 0)
{ {
_wherestr.AppendLine("WHERE"); for (var i = 0; i < table.Columns!.Length; i++)
var _wheres = new List<JObject>();
var _datas = new List<JObject>();
if (where.Type == JTokenType.Object)
{
_wheres.Add((JObject)where);
_datas.Add((JObject)data);
}
else if (where.Type == JTokenType.Array)
{ {
for(var i = 0;i < where.Count;i++) var _column = table.Columns[i];
if (where.ContainsKey(_column.Key!))
{ {
_wheres.Add((JObject)where.Children().ToArray()[i]); switch (where[_column.Key!])
_datas.Add((JObject)data.Children().ToArray()[i]);
}
}
for (var j = 0; j < _wheres.Count; j++) {
if (j > 0) {
_wherestr.AppendLine("OR");
}
_wherestr.AppendLine("(");
_wherestr.AppendLine("1 = 1");
var _where = _wheres[j];
var _data = _datas[j];
if (_where.Count > 0)
{
var _fileds = _where.Children().ToArray();
for (var i = 0; i < _fileds.Length; i++)
{ {
var _item = (JProperty)_fileds[i]; case HDP_WhereType.LIKE:
if (table.Columns!.Any(x => x.Key == _item.Name) && _data.ContainsKey(_item.Name)) _guid = Guid.NewGuid().ToString("N");
{ _wherestr.Append($@" AND `{_column.Key!}` {where[_column.Key!]} CONCAT('%',@{_guid},'%')");
if (_item.Value.Type == JTokenType.String) param.Add(_guid, row![_column.Key!]);
{ break;
_guid = Guid.NewGuid().ToString("N"); case HDP_WhereType.BETWEEN:
_wherestr.AppendLine(@$"AND `{_item.Name}` {_item.Value.ToString()} @{_guid}"); if (row![_column.Key!] != null)
if (_data[_item.Name]!.Type == JTokenType.Object || _data[_item.Name]!.Type == JTokenType.Array)
{
param.Add(_guid, _data[_item.Name]!);
}
else if (_item.Value.ToString() == HDP_WhereType.LIKE)
{
param.Add(_guid,$@"%{((JValue)_data[_item.Name]!).Value!}%" );
}
else {
param.Add(_guid, ((JValue)_data[_item.Name]!).Value!);
}
}
else if (_item.Value.Type == JTokenType.Array)
{ {
string[] _itemv = _item.Value.ToObject<string[]>()!; var _betweendata = JsonConvert.DeserializeObject<object[]>(JsonConvert.SerializeObject(row![_column.Key!]));
object[] _colv = _data[_item.Name]!.ToObject<object[]>()!; if (_betweendata != null)
for (var k = 0; k < _itemv.Length; k++)
{ {
_guid = Guid.NewGuid().ToString("N"); if (_betweendata[0] != null && _betweendata[0].ToString() != "")
_wherestr.AppendLine(@$"AND `{_item.Name}` {_itemv[k]} @{_guid}"); {
param.Add(_guid, _colv.Length > k ? _colv[k] : _colv[_colv.Length - 1]); _guid = Guid.NewGuid().ToString("N");
_wherestr.Append($@" AND `{_column.Key!}` >= @{_guid}");
param.Add(_guid, _betweendata[0]);
}
if (_betweendata[1] != null && _betweendata[1].ToString() != "")
{
_guid = Guid.NewGuid().ToString("N");
_wherestr.Append($@" AND `{_column.Key!}` <= @{_guid}");
param.Add(_guid, _betweendata[1]);
}
} }
} }
} break;
default:
_guid = Guid.NewGuid().ToString("N");
_wherestr.Append($@" AND `{_column.Key!}` {where[_column.Key!]} @{_guid}");
param.Add(_guid, row![_column.Key!]);
break;
} }
} }
_wherestr.AppendLine(")");
} }
command.AppendLine(_wherestr.ToString());
} }
return _wherestr.ToString();
} }
/// <summary> /// <summary>
@ -133,23 +111,21 @@ namespace ZKLT.Hadoop
/// <param name="table">表</param> /// <param name="table">表</param>
/// <param name="order">排序</param> /// <param name="order">排序</param>
/// <returns></returns> /// <returns></returns>
private string MergeOrder(HDP_Table table, JContainer? order, Dictionary<string, object> param) private string MergeOrder(HDP_Table table, Dictionary<string, object>? order, Dictionary<string, object> param)
{ {
string _guid = ""; string _guid = "";
StringBuilder _orderstr = new StringBuilder(); StringBuilder _orderstr = new StringBuilder();
if (order != null && order.Count > 0) if (order != null && order.Count > 0)
{ {
_orderstr.Append("ORDER BY "); _orderstr.Append("ORDER BY ");
var _fields = order.Children().ToArray(); foreach (var key in order.Keys)
foreach (var field in _fields)
{ {
var _field = (JProperty)field; if (table.Columns!.Any(x => x.Key == key))
if (table.Columns!.Any(x => x.Key == _field.Name))
{ {
var _column = table.Columns!.First(x => x.Key == _field.Name); var _column = table.Columns!.First(x => x.Key == key);
if (_field.Value.Type == JTokenType.String) if (order[key] is string)
{ {
switch (_field.Value.ToString()) switch (order[key])
{ {
case "DESC": case "DESC":
_orderstr.Append($@"`{_column.Key!}` DESC,"); _orderstr.Append($@"`{_column.Key!}` DESC,");
@ -159,9 +135,9 @@ namespace ZKLT.Hadoop
break; break;
} }
} }
else if (_field.Value.Type == JTokenType.Array) else if (order[key] is Newtonsoft.Json.Linq.JArray)
{ {
var _orderTemp = _field.Value.ToObject<object[]>(); var _orderTemp = JsonConvert.DeserializeObject<object[]>(JsonConvert.SerializeObject(order[key]));
_orderstr.Append(@$"CASE `{_column.Key!}`"); _orderstr.Append(@$"CASE `{_column.Key!}`");
for (var i = 0; i < _orderTemp!.Length; i++) for (var i = 0; i < _orderTemp!.Length; i++)
{ {
@ -397,9 +373,9 @@ namespace ZKLT.Hadoop
/// </summary> /// </summary>
/// <param name="source">数据源</param> /// <param name="source">数据源</param>
/// <param name="table">数据表</param> /// <param name="table">数据表</param>
/// <param name="data">数据</param> /// <param name="row">数据</param>
/// <returns>是否成功</returns> /// <returns>是否成功</returns>
public bool Insert(HDP_Source source, HDP_Table table, JContainer? data) public bool Insert(HDP_Source source, HDP_Table table, Dictionary<string, object> row)
{ {
//数据校验 //数据校验
if (string.IsNullOrEmpty(table.Key)) if (string.IsNullOrEmpty(table.Key))
@ -410,99 +386,80 @@ namespace ZKLT.Hadoop
{ {
throw new ArgumentNullException("列无效"); throw new ArgumentNullException("列无效");
} }
if (data == null || data.Count == 0) if (row == null || row.Count == 0)
{ {
throw new ArgumentNullException("数据无效"); throw new ArgumentNullException("数据无效");
} }
List<JObject> _data = new List<JObject>(); using (MySqlConnection _connection = new MySqlConnection(source.GetConnectString()))
if (data.Type == JTokenType.Object)
{
_data.Add((JObject)data);
}
else if (data.Type == JTokenType.Array)
{
_data = data.ToObject<List<JObject>>()!;
}
var _result = 0;
using (TransactionScope _scope = new TransactionScope())
{ {
using (MySqlConnection _connection = new MySqlConnection(source.GetConnectString())) try
{
_connection.Open();
}
catch
{ {
try throw new ArgumentException("数据源连接失败");
}
StringBuilder _command = new StringBuilder();
//主键检查
var _primarys = table.Columns.Where(x => x.IsPrimary == true).ToArray();
for (var i = 0; i < _primarys.Length; i++)
{
var _primary = _primarys[i];
if (!string.IsNullOrEmpty(_primary.InsertDefault) || (row.ContainsKey(_primary.Key!) && row[_primary.Key!] != null))
{ {
_connection.Open(); continue;
} }
catch else
{ {
throw new ArgumentException("数据源连接失败"); throw new ArgumentException($@"主键{_primary.Key}值无效");
} }
for (var j = 0; j < _data.Count; j++) }
{
var _row = _data[j];
StringBuilder _command = new StringBuilder();
//主键检查
var _primarys = table.Columns.Where(x => x.IsPrimary == true).ToArray();
for (var i = 0; i < _primarys.Length; i++)
{
var _primary = _primarys[i];
if (!string.IsNullOrEmpty(_primary.InsertDefault) || _row.ContainsKey(_primary.Key!))
{
continue;
}
else
{
throw new ArgumentException($@"主键{_primary.Key}值无效");
}
}
//插入命令 //插入命令
_command.AppendLine($@"INSERT INTO `{table.Key}` ("); _command.AppendLine($@"INSERT INTO `{table.Key}` (");
StringBuilder _colstr = new StringBuilder(); StringBuilder _colstr = new StringBuilder();
StringBuilder _parmstr = new StringBuilder(); StringBuilder _parmstr = new StringBuilder();
Dictionary<string, object> _params = new Dictionary<string, object>(); Dictionary<string, object> _params = new Dictionary<string, object>();
for (var i = 0; i < table.Columns.Length; i++) for (var i = 0; i < table.Columns.Length; i++)
{ {
var _column = table.Columns[i]; var _column = table.Columns[i];
if (_row.ContainsKey(_column.Key!)) if (row.ContainsKey(_column.Key!) && row[_column.Key!] != null)
{
_colstr.Append($@"`{_column.Key!}`,");
_parmstr.Append($@"@{_column.Key},");
_params.Add(_column.Key!, ((JValue)_row[_column.Key!]!).Value!);
}
else if (!string.IsNullOrEmpty(_column.InsertDefault))
{
_colstr.Append($@"`{_column.Key!}`,");
_parmstr.Append($@"@{_column.Key},");
_params.Add(_column.Key!, HDP_CommandAction.Convert(_column.InsertDefault, _row));
}
}
if (_colstr[_colstr.Length - 1] == ',')
{
_colstr.Remove(_colstr.Length - 1, 1);
}
if (_parmstr[_parmstr.Length - 1] == ',')
{
_parmstr.Remove(_parmstr.Length - 1, 1);
}
_command.AppendLine(_colstr.ToString());
_command.AppendLine(") VALUES (");
_command.AppendLine(_parmstr.ToString());
_command.AppendLine(")");
_result += _connection.Execute(_command.ToString(), _params);
}
_connection.Close();
if (_result >= _data.Count)
{ {
_scope.Complete(); _colstr.Append($@"`{_column.Key!}`,");
return true; _parmstr.Append($@"@{_column.Key},");
_params.Add(_column.Key!, row[_column.Key!]);
} }
else else if (!string.IsNullOrEmpty(_column.InsertDefault))
{ {
return false; _colstr.Append($@"`{_column.Key!}`,");
_parmstr.Append($@"@{_column.Key},");
_params.Add(_column.Key!, HDP_CommandAction.Convert(_column.InsertDefault, row));
} }
} }
if (_colstr[_colstr.Length - 1] == ',')
{
_colstr.Remove(_colstr.Length - 1, 1);
}
if (_parmstr[_parmstr.Length - 1] == ',')
{
_parmstr.Remove(_parmstr.Length - 1, 1);
}
_command.AppendLine(_colstr.ToString());
_command.AppendLine(") VALUES (");
_command.AppendLine(_parmstr.ToString());
_command.AppendLine(")");
var _result = _connection.Execute(_command.ToString(), _params);
_connection.Close();
if (_result > 0)
{
return true;
}
else
{
return false;
}
} }
} }
@ -514,7 +471,7 @@ namespace ZKLT.Hadoop
/// <param name="where">条件</param> /// <param name="where">条件</param>
/// <param name="row">数据</param> /// <param name="row">数据</param>
/// <returns>是否成功</returns> /// <returns>是否成功</returns>
public bool Update(HDP_Source source, HDP_Table table, JContainer? where, JContainer? data) public bool Update(HDP_Source source, HDP_Table table, Dictionary<string, string> where, Dictionary<string, object> row)
{ {
//数据校验 //数据校验
if (string.IsNullOrEmpty(table.Key)) if (string.IsNullOrEmpty(table.Key))
@ -525,90 +482,65 @@ namespace ZKLT.Hadoop
{ {
throw new ArgumentNullException("列无效"); throw new ArgumentNullException("列无效");
} }
if (where == null) if (where == null || where.Count == 0)
{ {
throw new ArgumentNullException("条件无效"); throw new ArgumentNullException("条件无效");
} }
List<JObject> _where = new List<JObject>(); if (row == null || row.Count == 0)
if (where.Type == JTokenType.Object)
{
_where.Add((JObject)where);
}
else if (where.Type == JTokenType.Array)
{
_where.AddRange(((JArray)where).ToObject<JObject[]>()!);
}
if (data == null || data.Count == 0)
{ {
throw new ArgumentNullException("数据无效"); throw new ArgumentNullException("数据无效");
} }
List<JObject> _data = new List<JObject>(); using (MySqlConnection _connection = new MySqlConnection(source.GetConnectString()))
if (data.Type == JTokenType.Object)
{
_data.Add((JObject)data);
}
else if (data.Type == JTokenType.Array)
{
_data = data.ToObject<List<JObject>>()!;
}
var _result = 0;
using (TransactionScope _scope = new TransactionScope())
{ {
using (MySqlConnection _connection = new MySqlConnection(source.GetConnectString())) try
{ {
try _connection.Open();
{ }
_connection.Open(); catch
} {
catch throw new ArgumentException("数据源连接失败");
{ }
throw new ArgumentException("数据源连接失败");
}
for (var j = 0; j < _data.Count; j++)
{
var _row = _data[j];
//更新命令
StringBuilder _command = new StringBuilder();
Dictionary<string, object> _params = new Dictionary<string, object>();
_command.AppendLine(@$"UPDATE `{table.Key}` SET ");
//更新列
StringBuilder _colstr = new StringBuilder();
for (var i = 0; i < table.Columns.Length; i++)
{
var _column = table.Columns[i];
if (_row.ContainsKey(_column.Key!) && !_where.Any(x => x.ContainsKey(_column.Key!)))
{
_colstr.Append(@$"`{_column.Key!}`={HDP_CommandAction.ColConvert(_column,_params, ((JValue)_row[_column.Key!]!).Value!)},");
}
else if (!string.IsNullOrEmpty(_column.UpdateDefault))
{
_colstr.Append($@"`{_column.Key!}`=@{_column.Key!},");
_params.Add(_column.Key!, HDP_CommandAction.Convert(_column.UpdateDefault, _row));
}
}
if (_colstr[_colstr.Length - 1] == ',')
{
_colstr.Remove(_colstr.Length - 1, 1);
}
_command.AppendLine(_colstr.ToString());
//执行条件 //更新命令
_command.AppendLine(MergeWhere(table, where, _row, _params)); StringBuilder _command = new StringBuilder();
Dictionary<string, object> _params = new Dictionary<string, object>();
_command.AppendLine(@$"UPDATE `{table.Key}` SET ");
_result += _connection.Execute(_command.ToString(), _params); //更新列
} StringBuilder _colstr = new StringBuilder();
_connection.Close(); for (var i = 0; i < table.Columns.Length; i++)
if (_result >= _data.Count) {
var _column = table.Columns[i];
if (row.ContainsKey(_column.Key!) && !where.ContainsKey(_column.Key!) && row[_column.Key!] != null)
{ {
_scope.Complete(); _colstr.Append($@"`{_column.Key!}`=@{_column.Key!},");
return true; _params.Add(_column.Key!, row[_column.Key!]);
} }
else else if (!string.IsNullOrEmpty(_column.UpdateDefault))
{ {
return false; _colstr.Append($@"`{_column.Key!}`=@{_column.Key!},");
_params.Add(_column.Key!, HDP_CommandAction.Convert(_column.UpdateDefault, row));
} }
} }
if (_colstr[_colstr.Length - 1] == ',')
{
_colstr.Remove(_colstr.Length - 1, 1);
}
_command.AppendLine(_colstr.ToString());
//执行条件
MergeWhere(table, where, row, _command, _params);
var _result = _connection.Execute(_command.ToString(), _params);
_connection.Close();
if (_result > 0)
{
return true;
}
else
{
return false;
}
} }
} }
@ -620,7 +552,7 @@ namespace ZKLT.Hadoop
/// <param name="where">条件</param> /// <param name="where">条件</param>
/// <param name="row">数据</param> /// <param name="row">数据</param>
/// <returns>是否成功</returns> /// <returns>是否成功</returns>
public bool Delete(HDP_Source source, HDP_Table table, JContainer? where, JContainer? data) public bool Delete(HDP_Source source, HDP_Table table, Dictionary<string, string> where, Dictionary<string, object> row)
{ {
//数据校验 //数据校验
if (string.IsNullOrEmpty(table.Key)) if (string.IsNullOrEmpty(table.Key))
@ -631,59 +563,41 @@ namespace ZKLT.Hadoop
{ {
throw new ArgumentNullException("列无效"); throw new ArgumentNullException("列无效");
} }
if (where == null) if (where == null || where.Count == 0)
{ {
throw new ArgumentNullException("条件无效"); throw new ArgumentNullException("条件无效");
} }
if (data == null || data.Count == 0) if (row == null || row.Count == 0)
{ {
throw new ArgumentNullException("数据无效"); throw new ArgumentNullException("数据无效");
} }
List<JObject> _data = new List<JObject>(); using (MySqlConnection _connection = new MySqlConnection(source.GetConnectString()))
if (data.Type == JTokenType.Object)
{
_data.Add((JObject)data);
}
else if (data.Type == JTokenType.Array)
{
_data = data.ToObject<List<JObject>>()!;
}
var _result = 0;
using (TransactionScope _scope = new TransactionScope())
{ {
using (MySqlConnection _connection = new MySqlConnection(source.GetConnectString())) try
{ {
try _connection.Open();
{ }
_connection.Open(); catch
} {
catch throw new ArgumentException("数据源连接失败");
{ }
throw new ArgumentException("数据源连接失败");
}
for (var j = 0; j < _data.Count; j++) //更新命令
{ StringBuilder _command = new StringBuilder();
var _row = _data[j]; Dictionary<string, object> _params = new Dictionary<string, object>();
//删除命令 _command.AppendLine(@$"DELETE FROM `{table.Key}`");
StringBuilder _command = new StringBuilder();
Dictionary<string, object> _params = new Dictionary<string, object>();
_command.AppendLine(@$"DELETE FROM `{table.Key}`");
_command.AppendLine(MergeWhere(table, where, _row, _params)); MergeWhere(table, where, row, _command, _params);
_result += _connection.Execute(_command.ToString(), _params); var _result = _connection.Execute(_command.ToString(), _params);
} _connection.Close();
_connection.Close(); if (_result > 0)
if (_result >= _data.Count) {
{ return true;
_scope.Complete(); }
return true; else
} {
else return false;
{
return false;
}
} }
} }
} }
@ -694,9 +608,9 @@ namespace ZKLT.Hadoop
/// <param name="source">数据源</param> /// <param name="source">数据源</param>
/// <param name="table">数据表</param> /// <param name="table">数据表</param>
/// <param name="where">条件</param> /// <param name="where">条件</param>
/// <param name="data">数据</param> /// <param name="row">数据</param>
/// <returns>结果</returns> /// <returns>结果</returns>
public T? QuerySingle<T>(HDP_Source source, HDP_Table table, JContainer? where, JContainer? data, public T? QuerySingle<T>(HDP_Source source, HDP_Table table, Dictionary<string, string> where, Dictionary<string, object> row,
string[]? col) string[]? col)
{ {
//数据校验 //数据校验
@ -708,11 +622,11 @@ namespace ZKLT.Hadoop
{ {
throw new ArgumentNullException("列无效"); throw new ArgumentNullException("列无效");
} }
if (where == null) if (where == null || where.Count == 0)
{ {
throw new ArgumentNullException("条件无效"); throw new ArgumentNullException("条件无效");
} }
if (data == null || data.Count == 0) if (row == null || row.Count == 0)
{ {
throw new ArgumentNullException("数据无效"); throw new ArgumentNullException("数据无效");
} }
@ -742,7 +656,7 @@ namespace ZKLT.Hadoop
} }
//执行条件 //执行条件
_command.AppendLine(MergeWhere(table, where, data, _params)); MergeWhere(table, where, row, _command, _params);
var _result = _connection.Query<T>(_command.ToString(), _params).ToArray(); var _result = _connection.Query<T>(_command.ToString(), _params).ToArray();
_connection.Close(); _connection.Close();
@ -764,10 +678,10 @@ namespace ZKLT.Hadoop
/// <param name="source">数据源</param> /// <param name="source">数据源</param>
/// <param name="table">数据表</param> /// <param name="table">数据表</param>
/// <param name="where">条件</param> /// <param name="where">条件</param>
/// <param name="data">数据</param> /// <param name="row">数据</param>
/// <returns>结果集</returns> /// <returns>结果集</returns>
public T[] Query<T>(HDP_Source source, HDP_Table table, JContainer? where, JContainer? data, public T[] Query<T>(HDP_Source source, HDP_Table table, Dictionary<string, string>? where, Dictionary<string, object>? row,
JContainer? order, string[]? col) Dictionary<string, object>? order, string[]? col)
{ {
//数据校验 //数据校验
if (string.IsNullOrEmpty(table.Key)) if (string.IsNullOrEmpty(table.Key))
@ -804,7 +718,7 @@ namespace ZKLT.Hadoop
} }
//执行条件 //执行条件
_command.AppendLine(MergeWhere(table, where, data, _params)); MergeWhere(table, where, row, _command, _params);
//执行排序 //执行排序
_command.AppendLine(MergeOrder(table, order, _params)); _command.AppendLine(MergeOrder(table, order, _params));
@ -824,8 +738,8 @@ namespace ZKLT.Hadoop
/// <param name="where">条件</param> /// <param name="where">条件</param>
/// <param name="row">数据</param> /// <param name="row">数据</param>
/// <returns>结果集</returns> /// <returns>结果集</returns>
public HDP_Page<T> QueryPage<T>(HDP_Source source, HDP_Table table, int pageIndex, int pageSize, JContainer? where, public HDP_Page<T> QueryPage<T>(HDP_Source source, HDP_Table table, int pageIndex, int pageSize, Dictionary<string, string>? where,
JContainer? data, JContainer? order, string[]? col) Dictionary<string, object>? row, Dictionary<string, object>? order, string[]? col)
{ {
//数据校验 //数据校验
if (string.IsNullOrEmpty(table.Key)) if (string.IsNullOrEmpty(table.Key))
@ -862,10 +776,35 @@ namespace ZKLT.Hadoop
} }
//执行条件 //执行条件
_command.AppendLine(MergeWhere(table, where, data, _params)); MergeWhere(table, where, row, _command, _params);
//执行排序 //执行排序
_command.AppendLine(MergeOrder(table, order, _params)); StringBuilder _orderstr = new StringBuilder();
_orderstr.Append("ORDER BY ");
if (order != null && order.Count > 0)
{
for (var i = 0; i < table.Columns.Length; i++)
{
var _column = table.Columns[i];
if (order.ContainsKey(_column.Key!))
{
switch (order[_column.Key!])
{
case "DESC":
_orderstr.Append($@"`{_column.Key!}` DESC,");
break;
default:
_orderstr.Append($@"`{_column.Key!}` ASC,");
break;
}
}
}
if (_orderstr[_orderstr.Length - 1] == ',')
{
_orderstr.Remove(_orderstr.Length - 1, 1);
}
_command.AppendLine(_orderstr.ToString());
}
var _result = new HDP_Page<T>(); var _result = new HDP_Page<T>();
_result.PageIndex = pageIndex; _result.PageIndex = pageIndex;
_result.PageSize = pageSize; _result.PageSize = pageSize;

@ -0,0 +1 @@
docker build -f Hadoop\ZKLT.Hadoop.API\Dockerfile -t hadoop:latest .

@ -13,6 +13,12 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ZKLT.Hadoop.Interface", "Ha
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ZKLT.Hadoop.API", "Hadoop\ZKLT.Hadoop.API\ZKLT.Hadoop.API.csproj", "{398DF3E5-B94B-4B2E-9DC6-B6741D7CF4DB}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ZKLT.Hadoop.API", "Hadoop\ZKLT.Hadoop.API\ZKLT.Hadoop.API.csproj", "{398DF3E5-B94B-4B2E-9DC6-B6741D7CF4DB}"
EndProject EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docker-compose", "docker-compose", "{1E26F2C2-6BCB-4E5D-ADC5-C6AD923155F9}"
ProjectSection(SolutionItems) = preProject
docker-compose\hadoop.yml = docker-compose\hadoop.yml
docker-compose\mysql.yml = docker-compose\mysql.yml
EndProjectSection
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU

@ -2,10 +2,9 @@ version: '3'
services: services:
hadoop: hadoop:
restart: always restart: always
image: hadoop:1.0.0 image: hadoop:latest
container_name: hadoop container_name: hadoop
volumes: # volumes:
- ./appsettings.json:/app/appsettings.json
# - /apps/mysql/mydir:/mydir # - /apps/mysql/mydir:/mydir
# - /apps/mysql/datadir:/var/lib/mysql # - /apps/mysql/datadir:/var/lib/mysql
# - /apps/mysql/conf/my.cnf:/etc/my.cnf # - /apps/mysql/conf/my.cnf:/etc/my.cnf
@ -17,4 +16,3 @@ services:
# 使用宿主机的3306端口映射到容器的3306端口 # 使用宿主机的3306端口映射到容器的3306端口
# 宿主机:容器 # 宿主机:容器
- 5000:8080 - 5000:8080
network_mode: bridge

@ -0,0 +1,20 @@
version: '3'
services:
hadoop_mysql:
restart: always
image: mysql:8
container_name: hadoop_mysql
# volumes:
# - /apps/mysql/mydir:/mydir
# - /apps/mysql/datadir:/var/lib/mysql
# - /apps/mysql/conf/my.cnf:/etc/my.cnf
# # 数据库还原目录 可将需要还原的sql文件放在这里
# - /apps/mysql/source:/docker-entrypoint-initdb.d
environment:
- "MYSQL_ROOT_PASSWORD=root"
- "MYSQL_DATABASE=hadoopdb"
- "TZ=Asia/Shanghai"
ports:
# 使用宿主机的3306端口映射到容器的3306端口
# 宿主机:容器
- 3306:3306
Loading…
Cancel
Save