Merge branch 'sqlsugar' of https://gitee.com/ccnetcore/Yi into sqlsugar

This commit is contained in:
chenchun
2022-04-08 18:24:18 +08:00
31 changed files with 24604 additions and 83 deletions

Binary file not shown.

View File

@@ -4,5 +4,59 @@
<name>Yi.Framework.ApiMicroservice</name>
</assembly>
<members>
<member name="T:Yi.Framework.ApiMicroservice.Controllers.BaseCrudController`1">
<summary>
6666
</summary>
<typeparam name="T"></typeparam>
</member>
<member name="M:Yi.Framework.ApiMicroservice.Controllers.BaseCrudController`1.#ctor(Microsoft.Extensions.Logging.ILogger{`0},Yi.Framework.Repository.IRepository{`0})">
<summary>
jb
</summary>
<param name="logger"></param>
<param name="iRepository"></param>
</member>
<member name="M:Yi.Framework.ApiMicroservice.Controllers.BaseCrudController`1.Get(System.Object)">
<summary>
主键查询
</summary>
<param name="id"></param>
<returns></returns>
</member>
<member name="M:Yi.Framework.ApiMicroservice.Controllers.BaseCrudController`1.GetList">
<summary>
列表查询
</summary>
<returns></returns>
</member>
<member name="M:Yi.Framework.ApiMicroservice.Controllers.BaseCrudController`1.Page(Yi.Framework.Model.Query.QueryCondition)">
<summary>
条件分页查询
</summary>
<param name="queryCondition"></param>
<returns></returns>
</member>
<member name="M:Yi.Framework.ApiMicroservice.Controllers.BaseCrudController`1.Add(`0)">
<summary>
添加
</summary>
<param name="entity"></param>
<returns></returns>
</member>
<member name="M:Yi.Framework.ApiMicroservice.Controllers.BaseCrudController`1.Update(`0)">
<summary>
修改
</summary>
<param name="entity"></param>
<returns></returns>
</member>
<member name="M:Yi.Framework.ApiMicroservice.Controllers.BaseCrudController`1.DeleteList(System.Object[])">
<summary>
列表删除
</summary>
<param name="ids"></param>
<returns></returns>
</member>
</members>
</doc>

View File

@@ -0,0 +1,53 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Yi.Framework.Common.Models;
using Yi.Framework.DTOModel;
using Yi.Framework.Interface;
using Yi.Framework.Model.Models;
using Yi.Framework.Repository;
using Yi.Framework.WebCore;
using Yi.Framework.WebCore.AttributeExtend;
using Yi.Framework.WebCore.AuthorizationPolicy;
namespace Yi.Framework.ApiMicroservice.Controllers
{
[ApiController]
[Route("api/[controller]/[action]")]
public class AccountController :ControllerBase
{
private IUserService _iUserService;
public AccountController(ILogger<UserEntity> logger, IUserService iUserService)
{
_iUserService = iUserService;
}
[AllowAnonymous]
[HttpPost]
public async Task<Result> Login(LoginDto loginDto)
{
UserEntity user=new();
if (await _iUserService.Login(loginDto.UserName, loginDto.Password,o=> user=o))
{
return Result.Success("登录成功!").SetData(user);
}
return Result.SuccessError("登录失败!用户名或者密码错误!");
}
[AllowAnonymous]
[HttpPost]
public async Task<Result> Register(RegisterDto registerDto)
{
UserEntity user = new();
if (await _iUserService.Register(WebCore.Mapper.MapperHelper.Map<UserEntity, RegisterDto>(registerDto), o => user = o))
{
return Result.Success("注册成功!").SetData(user);
}
return Result.SuccessError("注册失败!用户名已存在!");
}
}
}

View File

@@ -6,48 +6,92 @@ using Yi.Framework.WebCore.AttributeExtend;
namespace Yi.Framework.ApiMicroservice.Controllers
{
/// <summary>
/// 6666
/// </summary>
/// <typeparam name="T"></typeparam>
[ApiController]
[Route("api/[controller]/[action]")]
public class BaseCrudController<T> : ControllerBase where T : class,new()
{
private readonly ILogger<T> _logger;
public IRepository<T> _iRepository;
/// <summary>
/// jb
/// </summary>
/// <param name="logger"></param>
/// <param name="iRepository"></param>
public BaseCrudController(ILogger<T> logger, IRepository<T> iRepository)
{
_logger = logger;
_iRepository = iRepository;
}
[Permission($"{nameof(T)}:Get:One")]
/// <summary>
/// 主键查询
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[Permission($"{nameof(T)}:get:one")]
[HttpGet]
public async Task<Result> Get(object id)
{
return Result.Success().SetData(await _iRepository.GetByIdAsync(id));
}
[Permission($"{nameof(T)}:Get:List")]
/// <summary>
/// 列表查询
/// </summary>
/// <returns></returns>
[Permission($"{nameof(T)}:get:list")]
[HttpGet]
public async Task<Result> GetList()
{
return Result.Success().SetData(await _iRepository.GetListAsync());
}
[Permission($"{nameof(T)}:Get:Page")]
/// <summary>
/// 条件分页查询
/// </summary>
/// <param name="queryCondition"></param>
/// <returns></returns>
[Permission($"{nameof(T)}:get:page")]
[HttpPost]
public async Task<Result> Page(QueryCondition queryCondition)
{
return Result.Success().SetData(await _iRepository.CommonPage(queryCondition));
}
[Permission($"{nameof(T)}:Add")]
/// <summary>
/// 添加
/// </summary>
/// <param name="entity"></param>
/// <returns></returns>
[Permission($"{nameof(T)}:add")]
[HttpPost]
public async Task<Result> Add(T entity)
{
return Result.Success().SetData(await _iRepository.InsertReturnEntityAsync(entity));
}
[Permission($"{nameof(T)}:Update")]
/// <summary>
/// 修改
/// </summary>
/// <param name="entity"></param>
/// <returns></returns>
[Permission($"{nameof(T)}:update")]
[HttpPut]
public async Task<Result> Update(T entity)
{
return Result.Success().SetStatus(await _iRepository.UpdateAsync(entity));
}
[Permission($"{nameof(T)}:Delete:List")]
/// <summary>
/// 列表删除
/// </summary>
/// <param name="ids"></param>
/// <returns></returns>
[Permission($"{nameof(T)}:delete:list")]
[HttpDelete]
public async Task<Result> DeleteList(object[] ids)
{

View File

@@ -0,0 +1,26 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Yi.Framework.Common.Models;
using Yi.Framework.Interface;
using Yi.Framework.Model.Models;
using Yi.Framework.Repository;
using Yi.Framework.WebCore;
using Yi.Framework.WebCore.AttributeExtend;
using Yi.Framework.WebCore.AuthorizationPolicy;
namespace Yi.Framework.ApiMicroservice.Controllers
{
[ApiController]
[Route("api/[controller]/[action]")]
public class TenantController : BaseCrudController<TenantEntity>
{
public TenantController(ILogger<TenantEntity> logger, ITenantService iTenantService) : base(logger, iTenantService)
{
}
}
}

View File

@@ -22,12 +22,5 @@ namespace Yi.Framework.ApiMicroservice.Controllers
public UserController(ILogger<UserEntity> logger, IUserService iUserService) : base(logger, iUserService)
{
}
[HttpGet]
[Permission("user:query:list")]
public async Task<Result> PermissionTest()
{
return Result.Success().SetData( await _iRepository.GetListAsync());
}
}
}

View File

@@ -1,5 +1,5 @@
{
"StartUrl": "http://localohost:19001",
"StartUrl": "http://*:19001",
"Logging": {
"LogLevel": {
"Default": "Information",

View File

@@ -0,0 +1,8 @@
{
"apollo": {
"AppId": "ApiMicroservice",
"Env": "DEV",
"MetaServer": "http://119.91.207.67:18080",
"ConfigServer": [ "http://119.91.207.67:18080" ]
}
}

View File

@@ -0,0 +1,10 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*"
}

View File

@@ -1,4 +1,5 @@
using System;
using System.IO;
using System.Security.Cryptography;
using System.Text;
@@ -7,63 +8,68 @@ namespace Yi.Framework.Common.Helper
public class MD5Helper
{
/// <summary>
/// 16位MD5加密
/// 生成PasswordSalt
/// </summary>
/// <param name="password"></param>
/// <returns></returns>
public static string MD5Encrypt16(string password)
/// <returns>返回string</returns>
public static string GenerateSalt()
{
byte[] buf = new byte[16];
#pragma warning disable SYSLIB0023 // 类型或成员已过时
(new RNGCryptoServiceProvider()).GetBytes(buf);
#pragma warning restore SYSLIB0023 // 类型或成员已过时
return Convert.ToBase64String(buf);
}
/// <summary>
/// 加密密码
/// </summary>
/// <param name="pass">密码</param>
/// <param name="passwordFormat">加密类型</param>
/// <param name="salt">PasswordSalt</param>
/// <returns>加密后的密码</returns>
public static string SHA2Encode(string pass, string salt, int passwordFormat = 1)
{
if (passwordFormat == 0) // MembershipPasswordFormat.Clear
return pass;
byte[] bIn = Encoding.Unicode.GetBytes(pass);
byte[] bSalt = Convert.FromBase64String(salt);
byte[] bAll = new byte[bSalt.Length + bIn.Length];
byte[] bRet = null;
Buffer.BlockCopy(bSalt, 0, bAll, 0, bSalt.Length);
Buffer.BlockCopy(bIn, 0, bAll, bSalt.Length, bIn.Length);
#pragma warning disable SYSLIB0021 // 类型或成员已过时
var md5 = new MD5CryptoServiceProvider();
var s = SHA512Managed.Create();
#pragma warning restore SYSLIB0021 // 类型或成员已过时
string t2 = BitConverter.ToString(md5.ComputeHash(Encoding.Default.GetBytes(password)), 4, 8);
t2 = t2.Replace("-", string.Empty);
return t2;
}
bRet = s.ComputeHash(bAll);
/// <summary>
/// 32位MD5加密
/// </summary>
/// <param name="password"></param>
/// <returns></returns>
public static string MD5Encrypt32(string password = "")
return ConvertEx.ToUrlBase64String(bRet);
}
}
public class ConvertEx
{
static readonly char[] padding = { '=' };
public static string ToUrlBase64String(byte[] inArray)
{
string pwd = string.Empty;
try
{
if (!string.IsNullOrEmpty(password) && !string.IsNullOrWhiteSpace(password))
{
MD5 md5 = MD5.Create(); //实例化一个md5对像
// 加密后是一个字节类型的数组这里要注意编码UTF8/Unicode等的选择 
byte[] s = md5.ComputeHash(Encoding.UTF8.GetBytes(password));
// 通过使用循环,将字节类型的数组转换为字符串,此字符串是常规字符格式化所得
foreach (var item in s)
{
// 将得到的字符串使用十六进制类型格式。格式后的字符是小写的字母如果使用大写X则格式后的字符是大写字符
pwd = string.Concat(pwd, item.ToString("X2"));
}
}
}
catch
{
throw new Exception($"错误的 password 字符串:【{password}】");
}
return pwd;
var str = Convert.ToBase64String(inArray);
str = str.TrimEnd(padding).Replace('+', '-').Replace('/', '_');
return str;
}
/// <summary>
/// 64位MD5加密
/// </summary>
/// <param name="password"></param>
/// <returns></returns>
public static string MD5Encrypt64(string password)
public static byte[] FromUrlBase64String(string s)
{
// 实例化一个md5对像
// 加密后是一个字节类型的数组这里要注意编码UTF8/Unicode等的选择 
MD5 md5 = MD5.Create();
byte[] s = md5.ComputeHash(Encoding.UTF8.GetBytes(password));
return Convert.ToBase64String(s);
}
string incoming = s.Replace('_', '/').Replace('-', '+');
switch (s.Length % 4)
{
case 2: incoming += "=="; break;
case 3: incoming += "="; break;
}
byte[] bytes = Convert.FromBase64String(incoming);
return bytes;
}
}
}

View File

@@ -1,16 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Yi.Framework.Common.Models
{
public class AxiosUrlsModel
{
public string get { get; set; }
public string update { get; set; }
public string del { get; set; }
public string add { get; set; }
}
}

View File

@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Yi.Framework.DTOModel
{
public class LoginDto
{
public string UserName { get; set; }
public string Password { get; set; }
}
}

View File

@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Yi.Framework.DTOModel
{
public class RegisterDto
{
public string UserName { get; set; }
public string Password { get; set; }
public string Name { get; set; }
}
}

View File

@@ -0,0 +1,81 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*",
"Consul_Enabled": false,
"DbSeed_Enabled": true,
"Apollo_Enabled": false,
"HealthCheck_Enabled": false,
"Cors_Enabled": true,
"RabbitMQ_Enabled": true,
"Redis_Enabled": true,
"RedisSeed_Enabled": true,
"Kafka_Enabled": false,
"ElasticSeach_Enabled": false,
"MutiDB_Enabled": false,
"SMS_Enabled": true,
"DbList": [ "Sqlite", "Mysql", "Sqlserver", "Oracle" ],
"DbSelect": "Mysql",
"DbConn": {
"WriteUrl": "server=118.195.191.41;port=3306;database=YIDB;user id=root;password=Qz52013142020.",
"ReadUrl": [
"server=118.195.191.41;port=3306;database=YIDB;user id=root;password=Qz52013142020.",
"server=118.195.191.41;port=3306;database=YIDB;user id=root;password=Qz52013142020.",
"server=118.195.191.41;port=3306;database=YIDB;user id=root;password=Qz52013142020."
]
},
"JWTTokenOptions": {
"Audience": "http://localhost:7000",
"Issuer": "http://localhost:7000",
"SecurityKey": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDI2a2EJ7m872v0afyoSDJT2o1+SitIeJSWtLJU8/Wz2m7gStexajkeD+Lka6DSTy8gt9UwfgVQo6uKjVLG5Ex7PiGOODVqAEghBuS7JzIYU5RvI543nNDAPfnJsas96mSA7L/mD7RTE2drj6hf3oZjJpMPZUQI/B1Qjb5H3K3PNwIDAQAB"
},
"RedisConnOptions": {
"Host": "118.195.191.41",
"Prot": 6379,
"DB": 1,
"Password": "Qz52013142020."
},
"RabbitConn": {
"HostName": "118.195.191.41",
"UserName": "cc",
"Password": "cc",
"Port": 5672
},
"ElasticSeachConn": {
"Url": "",
"IndexName": ""
},
"KafkaOptions": {
"BrokerList": "192.168.3.230:9092",
"TopicName": "kafkalog"
},
"ConsulClientOption": {
"IP": "118.195.191.41",
"Port": "8500",
"Datacenter": "dc1"
},
"ConsulRegisterOption": {
"IP": "183.216.18.15",
"Port": "44329",
"GroupName": "ApiMicroservice",
"HealthCheckUrl": "/Health",
"Interval": 10,
"Timeout": 5,
"DeregisterCriticalServiceAfter": 60,
"Tag": "13"
},
"SMS": {
"ID": "LTAI5tJvjPaXCyyPMfXLNbVA",
"Secret": "fLQv7jjj57fUKLFK8REeAQPFVDjUYn",
"Sign": "JiftCC",
"Template": "SMS_221640732"
},
"IPLibraryServiceUrl": "http://gRPCIPLibraryService"
}

View File

@@ -0,0 +1,8 @@
{
"Apollo": {
"AppId": "Yi.Framework.ApiMicroservice",
"Env": "DEV",
"MetaServer": "http://192.168.2.168:8080",
"ConfigServer": [ "http://192.168.2.168:8080" ]
}
}

View File

@@ -0,0 +1,9 @@
using Yi.Framework.Model.Models;
using Yi.Framework.Repository;
namespace Yi.Framework.Interface
{
public partial interface ITenantService: IRepository<TenantEntity>
{
}
}

View File

@@ -1,9 +1,13 @@
using Yi.Framework.Model.Models;
using System;
using System.Threading.Tasks;
using Yi.Framework.Model.Models;
using Yi.Framework.Repository;
namespace Yi.Framework.Interface
{
public partial interface IUserService
{
{
public Task<bool> Login(string userName, string password, Action<UserEntity> userAction = null);
public Task<bool> Register(UserEntity userEntity, Action<UserEntity> userAction = null);
}
}

View File

@@ -0,0 +1,45 @@
using System;
using System.Collections.Generic;
using System.Linq;
using SqlSugar;
namespace Yi.Framework.Model.Models
{
/// <summary>
/// 租户表
///</summary>
[SugarTable("Tenant")]
public partial class TenantEntity
{
public TenantEntity()
{
this.Id=Guid.NewGuid();
this.IsDeleted=false;
this.CreateTime = DateTime.Now;
}
/// <summary>
/// 1
///</summary>
[SugarColumn(ColumnName="Id" ,IsPrimaryKey = true )]
public Guid Id { get; set; }
/// <summary>
/// 创建者
///</summary>
[SugarColumn(ColumnName="CreateUser" )]
public Guid? CreateUser { get; set; }
/// <summary>
/// 创建时间
///</summary>
[SugarColumn(ColumnName="CreateTime" )]
public DateTime? CreateTime { get; set; }
/// <summary>
/// 修改时间
///</summary>
[SugarColumn(ColumnName="ModifyTime" )]
public DateTime? ModifyTime { get; set; }
/// <summary>
/// 是否删除
///</summary>
[SugarColumn(ColumnName="IsDeleted" )]
public bool? IsDeleted { get; set; }
}
}

View File

@@ -55,5 +55,20 @@ namespace Yi.Framework.Model.Models
///</summary>
[SugarColumn(ColumnName="TenantId" )]
public Guid? TenantId { get; set; }
/// <summary>
/// 账户
///</summary>
[SugarColumn(ColumnName="UserName" )]
public string UserName { get; set; }
/// <summary>
/// 密码
///</summary>
[SugarColumn(ColumnName="Password" )]
public string Password { get; set; }
/// <summary>
/// 加密盐值
///</summary>
[SugarColumn(ColumnName="Salt" )]
public string Salt { get; set; }
}
}

View File

@@ -0,0 +1,21 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*",
"Apollo": {
"AppId": "Yi.Framework.OcelotGateway",
"Env": "DEV",
"MetaServer": "http://192.168.2.168:8080",
"ConfigServer": [ "http://192.168.2.168:8080" ]
},
"JWTTokenOptions": {
"Audience": "http://localhost:7000",
"Issuer": "http://localhost:7000",
"SecurityKey": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDI2a2EJ7m872v0afyoSDJT2o1+SitIeJSWtLJU8/Wz2m7gStexajkeD+Lka6DSTy8gt9UwfgVQo6uKjVLG5Ex7PiGOODVqAEghBuS7JzIYU5RvI543nNDAPfnJsas96mSA7L/mD7RTE2drj6hf3oZjJpMPZUQI/B1Qjb5H3K3PNwIDAQAB"
}
}

View File

@@ -0,0 +1,432 @@
////*****************************单地址多实例负载均衡+Consul********************************
//{
// "Routes": [
// {
// "DownstreamPathTemplate": "/api/{url}", //服务地址--url变量
// "DownstreamScheme": "http",
// "UpstreamPathTemplate": "/T/{url}", //网关地址--url变量
// "UpstreamHttpMethod": [ "Get", "Post" ],
// "UseServiceDiscovery": true,
// "ServiceName": "ZhaoxiService", //consul服务名称
// "LoadBalancerOptions": {
// "Type": "RoundRobin" //轮询 LeastConnection-最少连接数的服务器 NoLoadBalance不负载均衡
// }
// }
// ],
// "GlobalConfiguration": {
// "BaseUrl": "http://127.0.0.1:6299", //网关对外地址
// "ServiceDiscoveryProvider": {
// "Host": "47.95.2.2",
// "Port": 8089,
// "Type": "Consul" //由Consul提供服务发现, 每次请求去consul
// } //Ocelot没有支持配置多个Consul
// //,"ServiceDiscoveryProvider": {
// // "Host": "localhost",
// // "Port": 8500,
// // "Type": "PollConsul", //由Consul提供服务发现,
// // "PollingInterval": 1000 //轮询consul,频率毫秒--down掉是不知道的
// // //"Token": "footoken"//需要ACL的话
// //}
// }
//}
//*****************************Ocelot+Consul********************************
{
"Routes": [
{
"UpstreamPathTemplate": "api/api/{url}", //上游请求地址--网关
"UpstreamHttpMethod": [ "Get", "Post", "Put", "PATCH", "Delete", "Options" ],
"UseServiceDiscovery": true,
"ServiceName": "ApiMicroservice",
"LoadBalancerOptions": {
"Type": "RoundRobin" //轮询 LeastConnection-最少连接数的服务器 NoLoadBalance不负载均衡
},
"DownstreamPathTemplate": "api/api/{url}", //服务地址--url变量
"DownstreamScheme": "https",
"DownstreamHeaderTransform": {
"Access-Control-Allow-Origin": "*", //不存在就添加
"Access-Control-Allow-Methods": "*",
"Access-Control-Allow-Headers": "*"
}
},
{
"UpstreamPathTemplate": "api/item/{url}", //上游请求地址--网关
"UpstreamHttpMethod": [ "Get", "Post", "Put", "PATCH", "Delete", "Options" ],
"UseServiceDiscovery": true,
"ServiceName": "PageDetail",
"LoadBalancerOptions": {
"Type": "RoundRobin" //轮询 LeastConnection-最少连接数的服务器 NoLoadBalance不负载均衡
},
"DownstreamPathTemplate": "api/item/{url}", //服务地址--url变量
"DownstreamScheme": "https",
"DownstreamHeaderTransform": {
"Access-Control-Allow-Origin": "*", //不存在就添加
"Access-Control-Allow-Methods": "*",
"Access-Control-Allow-Headers": "*"
}
}
],
"GlobalConfiguration": {
"BaseUrl": "http://127.0.0.1:7200", //网关对外地址
"ServiceDiscoveryProvider": {
"Host": "192.168.2.128",
"Port": 8500,
"Type": "Consul" //由Consul提供服务发现, 每次请求去consul
},
"RateLimitOptions": {
"QuotaExceededMessage": "你的请求过于频繁,请稍后再试!", // 当请求过载被截断时返回的消息
"HttpStatusCode": 666 // 当请求过载被截断时返回的http status
//"ClientIdHeader": "client_id" // 用来识别客户端的请求头,默认是 ClientId
}
//,"ServiceDiscoveryProvider": {
// "Host": "localhost",
// "Port": 8500,
// "Type": "PollConsul", //由Consul提供服务发现,
// "PollingInterval": 1000 //轮询consul,频率毫秒--down掉是不知道的
// //"Token": "footoken"//需要ACL的话
//}
}
}
////*****************************单地址--无Consul********************************
//{
// "Routes": [
// {
// "UpstreamPathTemplate": "/api/auth/{url}", //上游请求地址--网关
// "UpstreamHttpMethod": [ "Get", "Post", "Put", "PATCH", "Delete", "Options" ],
// "DownstreamHostAndPorts": [
// {
// "Host": "localhost",
// "Port": 7200 //网关api 端口
// }
// ],
// "DownstreamPathTemplate": "/api/{url}", //服务地址--url变量
// "DownstreamScheme": "http",
// "DownstreamHeaderTransform": {
// "Access-Control-Allow-Origin": "*", //不存在就添加
// "Access-Control-Allow-Methods": "*",
// "Access-Control-Allow-Headers": "*"
// }
// }
// ]
//}
////*****************************单地址全匹配********************************
//{
// "Routes": [
// {
// "DownstreamPathTemplate": "/{url}", //服务地址--url变量
// "DownstreamScheme": "http",
// "DownstreamHostAndPorts": [
// {
// "Host": "localhost",
// "Port": 5726 //服务端口
// }
// ],
// "UpstreamPathTemplate": "/{url}", //网关地址--url变量 //冲突的还可以加权重Priority
// "UpstreamHttpMethod": [ "Get", "Post" ]
// }
// ]
//}
////*****************************多地址多实例********************************
//{
// "Routes": [
// {
// "DownstreamPathTemplate": "/api/{url}", //服务地址--url变量
// "DownstreamScheme": "http",
// "DownstreamHostAndPorts": [
// {
// "Host": "localhost",
// "Port": 5726 //服务端口
// }
// ],
// "UpstreamPathTemplate": "/T5726/{url}", //网关地址--url变量
// "UpstreamHttpMethod": [ "Get", "Post" ]
// },
// {
// "DownstreamPathTemplate": "/api/{url}", //服务地址--url变量
// "DownstreamScheme": "http",
// "DownstreamHostAndPorts": [
// {
// "Host": "localhost",
// "Port": 5727 //服务端口
// }
// ],
// "UpstreamPathTemplate": "/T5727/{url}", //网关地址--url变量
// "UpstreamHttpMethod": [ "Get", "Post" ]
// },
// {
// "DownstreamPathTemplate": "/api/{url}", //服务地址--url变量
// "DownstreamScheme": "http",
// "DownstreamHostAndPorts": [
// {
// "Host": "localhost",
// "Port": 5728 //服务端口
// }
// ],
// "UpstreamPathTemplate": "/T5728/{url}", //网关地址--url变量
// "UpstreamHttpMethod": [ "Get", "Post" ]
// }
// ]
//}
//////MVC的路由规则是近水楼台先得月--
////*****************************路由冲突+带权匹配********************************
//{
// "Routes": [
// {
// "DownstreamPathTemplate": "/{url}", //服务地址--url变量
// "DownstreamScheme": "http",
// "DownstreamHostAndPorts": [
// {
// "Host": "localhost",
// "Port": 5726 //服务端口
// }
// ],
// "UpstreamPathTemplate": "/{url}", //网关地址--url变量 //冲突的还可以加权重Priority
// "UpstreamHttpMethod": [ "Get", "Post" ],
// "Priority": 0 //默认是0 加个1
// },
// {
// "DownstreamPathTemplate": "/api/users/get?id={id}", //服务地址--url变量
// "DownstreamScheme": "http",
// "DownstreamHostAndPorts": [
// {
// "Host": "localhost",
// "Port": 5727 //服务端口
// }
// ],
// "UpstreamPathTemplate": "/api/users/get/{id}", //网关地址--url变量 //冲突的还可以加权重Priority
// "UpstreamHttpMethod": [ "Get", "Post" ],
// "Priority": 1 //默认是0 加个1
// },
// {
// "DownstreamPathTemplate": "/api/users/{url}?id={id}", //服务地址--url变量
// "DownstreamScheme": "http",
// "DownstreamHostAndPorts": [
// {
// "Host": "localhost",
// "Port": 5728 //服务端口
// }
// ],
// "UpstreamPathTemplate": "/api/users/{url}/{id}", //网关地址--url变量 //冲突的还可以加权重Priority
// "UpstreamHttpMethod": [ "Get", "Post" ],
// "Priority": 2 //默认是0 加个1
// }
// ]
//}
////*****************************单地址多实例负载均衡********************************
//{
// "Routes": [
// {
// "DownstreamPathTemplate": "/api/{url}", //服务地址--url变量
// "DownstreamScheme": "http",
// "DownstreamHostAndPorts": [
// {
// "Host": "47.95.2.2",
// "Port": 5726
// }, //Ocelot负载均衡
// {
// "Host": "47.95.2.2",
// "Port": 5727
// },
// {
// "Host": "47.95.2.2",
// "Port": 5728
// }
// ],
// "UpstreamPathTemplate": "/T/{url}", //网关地址--url变量 //冲突的还可以加权重Priority
// "UpstreamHttpMethod": [ "Get", "Post" ],
// "LoadBalancerOptions": {
// "Type": "RoundRobin" //轮询 //"LeastConnection" //最少连接数的服务器 "NoLoadBalance" //不负载均衡 //"CookieStickySessions" //会话粘滞 //
// }
// //"LoadBalancerOptions": {
// // "Type": "CookieStickySessions",
// // "Key": "ASP.NET_SessionId",
// // "Expiry": 1800000
// //}
// }
// ]
//}
////*****************************单地址多实例负载均衡+Consul********************************
//{
// "Routes": [
// {
// "DownstreamPathTemplate": "/api/{url}", //服务地址--url变量
// "DownstreamScheme": "http",
// "UpstreamPathTemplate": "/T/{url}", //网关地址--url变量
// "UpstreamHttpMethod": [ "Get", "Post" ],
// "UseServiceDiscovery": true,
// "ServiceName": "ZhaoxiService", //consul服务名称
// "LoadBalancerOptions": {
// "Type": "RoundRobin" //轮询 LeastConnection-最少连接数的服务器 NoLoadBalance不负载均衡
// }
// }
// ],
// "GlobalConfiguration": {
// "BaseUrl": "http://127.0.0.1:6299", //网关对外地址
// "ServiceDiscoveryProvider": {
// "Host": "47.95.2.2",
// "Port": 8089,
// "Type": "Consul" //由Consul提供服务发现, 每次请求去consul
// } //Ocelot没有支持配置多个Consul
// //,"ServiceDiscoveryProvider": {
// // "Host": "localhost",
// // "Port": 8500,
// // "Type": "PollConsul", //由Consul提供服务发现,
// // "PollingInterval": 1000 //轮询consul,频率毫秒--down掉是不知道的
// // //"Token": "footoken"//需要ACL的话
// //}
// }
//}
////*****************************Consul+缓存Cache********************************
//{
// "Routes": [
// {
// "DownstreamPathTemplate": "/api/{url}", //服务地址--url变量
// "DownstreamScheme": "http",
// "UpstreamPathTemplate": "/T/{url}", //网关地址--url变量
// "UpstreamHttpMethod": [ "Get", "Post" ],
// "UseServiceDiscovery": true,
// "ServiceName": "ZhaoxiService", //consul服务名称
// "LoadBalancerOptions": {
// "Type": "RoundRobin" //轮询 LeastConnection-最少连接数的服务器 NoLoadBalance不负载均衡
// },
// "FileCacheOptions": {
// "TtlSeconds": 15, //Second
// "Region": "UserCache" //可以调用Api缓存清理
// }
// }
// ],
// "GlobalConfiguration": {
// "BaseUrl": "http://127.0.0.1:6299", //网关对外地址
// "ServiceDiscoveryProvider": {
// "Host": "47.95.2.2",
// "Port": 8089,
// "Type": "Consul" //由Consul提供服务发现, 每次请求去consul
// }
// //"ServiceDiscoveryProvider": {
// // "Host": "localhost",
// // "Port": 8500,
// // "Type": "PollConsul", //由Consul提供服务发现,
// // "PollingInterval": 1000 //轮询consul,频率毫秒--down掉是不知道的
// // //"Token": "footoken"//需要ACL的话
// //}
// }
//}
////*****************************超时+限流+熔断+降级+Consul+Polly********************************
//{
// "Routes": [
// {
// "DownstreamPathTemplate": "/api/{url}", //服务地址--url变量
// "DownstreamScheme": "http",
// "UpstreamPathTemplate": "/T/{url}", //网关地址--url变量
// "UpstreamHttpMethod": [ "Get", "Post" ],
// "UseServiceDiscovery": true,
// "ServiceName": "ZhaoxiService", //consul服务名称
// "LoadBalancerOptions": {
// "Type": "RoundRobin" //轮询 LeastConnection-最少连接数的服务器 NoLoadBalance不负载均衡
// },
// "RateLimitOptions": {
// "ClientWhitelist": [ "eleven", "seven" ], //白名单 ClientId 区分大小写
// "EnableRateLimiting": true,
// "Period": "5m", //1s, 5m, 1h, 1d
// "PeriodTimespan": 30, //多少秒之后客户端可以重试
// "Limit": 5 //统计时间段内允许的最大请求数量
// },
// "AuthenticationOptions": {
// "AuthenticationProviderKey": "UserGatewayKey",
// "AllowedScopes": []
// },
// "QoSOptions": {
// "ExceptionsAllowedBeforeBreaking": 3, //允许多少个异常请求
// "DurationOfBreak": 10000, // 熔断的时间单位为ms
// "TimeoutValue": 2000 //单位ms 如果下游请求的处理时间超过多少则自如将请求设置为超时 默认90秒
// }
// //"FileCacheOptions": {
// // "TtlSeconds": 15,
// // "Region": "UserCache" //可以调用Api清理
// //}
// }
// ],
// "GlobalConfiguration": {
// "BaseUrl": "http://127.0.0.1:6299", //网关对外地址
// "ServiceDiscoveryProvider": {
// "Host": "47.95.2.2",
// "Port": 8089,
// "Type": "Consul" //由Consul提供服务发现
// },
// "RateLimitOptions": {
// "QuotaExceededMessage": "Too many requests, maybe later? 11", // 当请求过载被截断时返回的消息
// "HttpStatusCode": 666, // 当请求过载被截断时返回的http status
// //"ClientIdHeader": "client_id" // 用来识别客户端的请求头,默认是 ClientId
// }
// }
//}
////*****************************请求聚合Aggregator********************************
//{
// "Routes": [
// {
// "DownstreamPathTemplate": "/api/users/all",
// "DownstreamScheme": "http",
// "DownstreamHostAndPorts": [
// {
// "Host": "localhost",
// "Port": 5726 //服务端口
// } //可以多个,自行负载均衡
// ],
// "UpstreamPathTemplate": "/T5726/users/all",
// "UpstreamHttpMethod": [ "Get", "Post" ],
// "key": "T5726"
// },
// {
// "DownstreamPathTemplate": "/api/users/all",
// "DownstreamScheme": "http",
// "DownstreamHostAndPorts": [
// {
// "Host": "localhost",
// "Port": 5727 //服务端口
// }
// ],
// "UpstreamPathTemplate": "/T5727/users/all",
// "UpstreamHttpMethod": [ "Get", "Post" ],
// "key": "T5727"
// },
// {
// "DownstreamPathTemplate": "/api/users/all",
// "DownstreamScheme": "http",
// "DownstreamHostAndPorts": [
// {
// "Host": "localhost",
// "Port": 5728 //服务端口
// }
// ],
// "UpstreamPathTemplate": "/T5728/users/all",
// "UpstreamHttpMethod": [ "Get", "Post" ],
// "key": "T5728"
// }
// ],
// "Aggregates": [
// {
// "RouteKeys": [
// "T5726",
// "T5727",
// "T5728"
// ],
// "UpstreamPathTemplate": "/UserAggregator", //如果某个404 是不影响返回当成null
// "Aggregator": "CustomUserAggregator" //自定义聚合器
// }
// ]
//}

View File

@@ -0,0 +1,45 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"RabbitMQ_Enabled": true,
"SMS_Enabled": true,
"RedisConn": {
"Host": "192.168.2.128",
"Prot": 6379,
"DB": 0,
"Password": "123456"
},
"RabbitConn": {
"HostName": "118.195.191.41",
"UserName": "cc",
"Password": "cc",
"Port": 5672
},
//"DetailPageUrl": "http://localhost:5728/item/",
"DetailPageUrl": "http://PageDetail/item/",
"ConsulClientOption": {
"IP": "192.168.2.128",
"Port": "8500",
"Datacenter": "dc1"
},
"MysqlConn": {
"Url": "server=192.168.2.128;port=3306;database=ECDB;user id=root;password=123456"
},
"Apollo": {
"AppId": "Yi.Framework.StaticPageProcessor",
"Env": "DEV",
"MetaServer": "http://192.168.2.168:8080",
"ConfigServer": [ "http://192.168.2.168:8080" ]
},
"SMS": {
"ID": "LTAI5tJvjPaXCyyPMfXLNbVA",
"Secret": "fLQv7jjj57fUKLFK8REeAQPFVDjUYn",
"Sign": "JiftCC",
"Template": "SMS_221640732"
}
}

View File

@@ -0,0 +1,8 @@
{
"apollo": {
"AppId": "SMSProcessor",
"Env": "DEV",
"MetaServer": "http://119.91.207.67:18080",
"ConfigServer": [ "http://119.91.207.67:18080" ]
}
}

View File

@@ -0,0 +1,14 @@
using SqlSugar;
using Yi.Framework.Interface;
using Yi.Framework.Model.Models;
using Yi.Framework.Repository;
namespace Yi.Framework.Service
{
public partial class TenantService : Repository<TenantEntity>, ITenantService
{
public TenantService(ISqlSugarClient context) : base(context)
{
}
}
}

View File

@@ -1,4 +1,5 @@
using Yi.Framework.Interface;
using SqlSugar;
using Yi.Framework.Interface;
using Yi.Framework.Model.Models;
using Yi.Framework.Repository;
@@ -6,6 +7,8 @@ namespace Yi.Framework.Service
{
public partial class UserService : Repository<UserEntity>, IUserService
{
public UserService(ISqlSugarClient context) : base(context)
{
}
}
}

View File

@@ -1,4 +1,7 @@
using SqlSugar;
using System;
using System.Threading;
using System.Threading.Tasks;
using Yi.Framework.Interface;
using Yi.Framework.Model.Models;
using Yi.Framework.Repository;
@@ -7,8 +10,55 @@ namespace Yi.Framework.Service
{
public partial class UserService
{
public UserService(ISqlSugarClient context) : base(context)
public async Task<bool> Exist(Guid id, Action<UserEntity> userAction = null)
{
var user = await GetByIdAsync(id);
userAction.Invoke(user);
if (user == null)
{
return false;
}
return true;
}
public async Task<bool> Exist(string userName, Action<UserEntity> userAction = null)
{
var user = await GetFirstAsync(u=>u.UserName== userName);
if (userAction != null)
{
userAction.Invoke(user);
}
if (user == null)
{
return false;
}
return true;
}
public async Task<bool> Login(string userName, string password,Action<UserEntity> userAction = null)
{
var user=new UserEntity();
if (await Exist(userName, o => user = o))
{
userAction.Invoke(user);
if (user.Password== Common.Helper.MD5Helper.SHA2Encode(password, user.Salt))
{
return true;
}
}
return false;
}
public async Task<bool> Register(UserEntity userEntity, Action<UserEntity> userAction = null)
{
var user = new UserEntity();
if (!await Exist(user.Name))
{
user.UserName= userEntity.UserName;
user.Salt = Common.Helper.MD5Helper.GenerateSalt();
user.Password = Common.Helper.MD5Helper.SHA2Encode(userEntity.Password,user.Salt);
userAction.Invoke(await InsertReturnEntityAsync(user));
return true;
}
return false;
}
}
}

10192
Yi.Vue2.x/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

27
Yi.Vue2.x/package.json Normal file
View File

@@ -0,0 +1,27 @@
{
"name": "vuetify-test",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build"
},
"dependencies": {
"axios": "^0.22.0",
"vue": "^2.6.11",
"vue-chartist": "^2.3.1",
"vue-router": "^3.2.0",
"vuetify": "^2.4.0",
"vuetify-dialog": "^2.0.17",
"vuex": "^3.6.2"
},
"devDependencies": {
"@vue/cli-plugin-router": "~4.5.0",
"@vue/cli-service": "~4.5.0",
"sass": "~1.32.0",
"sass-loader": "^10.0.0",
"vue-cli-plugin-vuetify": "~2.4.2",
"vue-template-compiler": "^2.6.11",
"vuetify-loader": "^1.7.0"
}
}

13283
Yi.Vue3.x/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

36
Yi.Vue3.x/package.json Normal file
View File

@@ -0,0 +1,36 @@
{
"name": "my-app",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
"dependencies": {
"@element-plus/icons-vue": "^0.2.4",
"core-js": "^3.6.5",
"element-plus": "^1.3.0-beta.5",
"vue": "^3.0.0",
"vue-class-component": "^8.0.0-0",
"vue-router": "^4.0.0-0",
"vuex": "^4.0.0-0"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^4.18.0",
"@typescript-eslint/parser": "^4.18.0",
"@vue/cli-plugin-babel": "~4.5.0",
"@vue/cli-plugin-eslint": "~4.5.0",
"@vue/cli-plugin-router": "~4.5.0",
"@vue/cli-plugin-typescript": "~4.5.0",
"@vue/cli-plugin-vuex": "~4.5.0",
"@vue/cli-service": "~4.5.0",
"@vue/compiler-sfc": "^3.0.0",
"@vue/eslint-config-typescript": "^7.0.0",
"eslint": "^6.7.2",
"eslint-plugin-vue": "^7.0.0",
"sass": "^1.26.5",
"sass-loader": "^8.0.2",
"typescript": "~4.1.5"
}
}

40
Yi.Vue3.x/tsconfig.json Normal file
View File

@@ -0,0 +1,40 @@
{
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"strict": true,
"jsx": "preserve",
"importHelpers": true,
"moduleResolution": "node",
"experimentalDecorators": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"sourceMap": true,
"baseUrl": ".",
"types": [
"webpack-env"
],
"paths": {
"@/*": [
"src/*"
]
},
"lib": [
"esnext",
"dom",
"dom.iterable",
"scripthost"
]
},
"include": [
"src/**/*.ts",
"src/**/*.tsx",
"src/**/*.vue",
"tests/**/*.ts",
"tests/**/*.tsx"
],
"exclude": [
"node_modules"
]
}