移动系统liao
2024-08-15 d6e560e1d30bd6af259b0c07ffb51b9caf8ab925
萨达
18个文件已修改
8个文件已添加
649 ■■■■■ 已修改文件
.gitignore 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cylsg/EzTencentCloud/Class1.cs 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cylsg/EzTencentCloud/EzTencentCloud.csproj 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cylsg/EzTencentCloud/ITencentCloudService.cs 29 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cylsg/EzTencentCloud/TencentCloudConfig.json 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cylsg/EzTencentCloud/TencentCloudService.cs 141 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cylsg/EzUpFile/Class1.cs 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cylsg/EzUpFile/EzUpFile.csproj 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cylsg/EzWechat/EzWechat.csproj 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cylsg/EzWechat/IWechatService.cs 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cylsg/EzWechat/WechatConfig.json 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cylsg/EzWechat/WechatService.cs 83 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cylsg/cylsg.Application/LogoInController.cs 163 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cylsg/cylsg.Application/applicationsettings.json 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cylsg/cylsg.Application/cylsg.Application.csproj 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cylsg/cylsg.Application/cylsg.Application.xml 58 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cylsg/cylsg.Authorization/IEzAuthorizationService.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
cylsg/cylsg.Model/UserModel/User.cs 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cylsg/cylsg.Web.Core/Startup.cs 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cylsg/cylsg.Web.Entry/Properties/launchSettings.json 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cylsg/cylsg.Web.Entry/SingleFilePublish.cs 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cylsg/cylsg.Web.Entry/appsettings.json 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cylsg/cylsg.Web.Entry/cylsg.Web.Entry.csproj 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cylsg/cylsg.redis/RedisConfig.json 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
cylsg/cylsg.redis/cylsg.redis.csproj 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cylsg/cylsg.sln 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
.gitignore
@@ -19,3 +19,7 @@
cylsg/EzUpFiles/obj/
cylsg/EzWechat/obj/
cylsg/cylsg.redis/bin/
cylsg/EzWechat/bin/
cylsg/EzTencentCloud/bin/
cylsg/EzTencentCloud/obj/
cylsg/EzUpFile/obj/
cylsg/EzTencentCloud/Class1.cs
New file
@@ -0,0 +1,7 @@
namespace EzTencentCloud
{
    public class Class1
    {
    }
}
cylsg/EzTencentCloud/EzTencentCloud.csproj
New file
@@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net8.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="TencentCloudSDK" Version="3.0.1069" />
  </ItemGroup>
  <ItemGroup>
    <ProjectReference Include="..\cylsg.Core\cylsg.Core.csproj" />
  </ItemGroup>
  <ItemGroup>
    <None Update="TencentCloudConfig.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </None>
  </ItemGroup>
</Project>
cylsg/EzTencentCloud/ITencentCloudService.cs
New file
@@ -0,0 +1,29 @@
using Furion.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TencentCloud.Ocr.V20181119.Models;
namespace EzTencentCloud
{
    /// <summary>
    /// 腾讯云服务
    /// </summary>
    public interface ITencentCloudService: IScoped
    {
        /// <summary>
        /// 身份证识别,并剪裁
        /// </summary>
        /// <param name="ImageBase64"></param>
        /// <param name="isFRONT"></param>
        /// <returns></returns>
        IDCardOCRResponse IdCord(string ImageBase64, bool isFRONT);
        /// <summary>
        /// 获取剪裁后的身份证照片
        /// </summary>
        /// <returns></returns>
        string GetIdCordImg();
    }
}
cylsg/EzTencentCloud/TencentCloudConfig.json
New file
@@ -0,0 +1,6 @@
{
  "TencentCloud": {
    "SecretId":    "AKIDIPFp9CyThfMmvoQlpeCl34pKYVBahY9T",
    "SecretKey":   "4rNcaHhrkMhmb9QQ9bmgKipfFZcOt86n"
  }
}
cylsg/EzTencentCloud/TencentCloudService.cs
New file
@@ -0,0 +1,141 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Sockets;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using TencentCloud.Ocr.V20181119;
using TencentCloud.Ocr.V20181119.Models;
using Newtonsoft.Json;
using TencentCloud.Common;
using TencentCloud.Common.Profile;
using Furion.DependencyInjection;
using Furion;
namespace EzTencentCloud
{
    public class TencentCloudService: ITencentCloudService, IScoped
    {
        /// <summary>
        /// 剪裁后的身份证图片
        /// </summary>
        public string CropIdCard { get; set; }
        public string GetIdCordImg()
        {
            if (string.IsNullOrEmpty(CropIdCard))
                return "";
            else
                return CropIdCard;
        }
        public   IDCardOCRResponse IdCord(string ImageBase64, bool isFRONT)
        {
            try
            {
                Credential cred = new Credential
                {
                    SecretId = App.Configuration["TencentCloud:SecretId"] ??"AKIDIPFp9CyThfMmvoQlpeCl34pKYVBahY9T",
                    SecretKey = App.Configuration["TencentCloud:SecretKey"] ?? "4rNcaHhrkMhmb9QQ9bmgKipfFZcOt86n"
                };
                ClientProfile clientProfile = new ClientProfile();
                HttpProfile httpProfile = new HttpProfile();
                httpProfile.Endpoint = ("ocr.tencentcloudapi.com");
                clientProfile.HttpProfile = httpProfile;
                OcrClient client = new OcrClient(cred, "ap-beijing", clientProfile);
                IDCardOCRRequest req = new IDCardOCRRequest();
                if (isFRONT)
                    req.CardSide = "FRONT";
                else
                    req.CardSide = "BACK";
                req.ImageBase64 = ImageBase64;
                req.Config = JsonConvert.SerializeObject(new
                {
                    //身份证照片裁剪(去掉证件外多余的边缘、自动矫正拍摄角度)
                    CropIdCard = true,
                    // CropPortrait = true,
                    //边框和框内遮挡告警
                    BorderCheckWarn = true,
                    //PS检测告警
                    DetectPsWarn = true,
                    //临时身份证告警
                    TempIdWarn = true,
                    //身份证有效日期不合法告警
                    InvalidDateWarn = true,
                    //图片质量分数(评价图片的模糊程度)
                    Quality = true,
                });
                IDCardOCRResponse resp =  client.IDCardOCRSync(req);
                if (resp == null)
                    throw new Exception("图片无法识别,请重新选择身份证图片");
                var adv = JsonConvert.DeserializeObject<AdvancedInfo>(resp.AdvancedInfo);
                if (adv == null)
                    throw new Exception("图片无法识别,请重新选择身份证图片");
                if (adv?.BorderCodeValue != null && adv.BorderCodeValue > 50)
                    throw new Exception("身份证图片不完整,请重新选择身份证图片");
                if (adv?.Quality != null && adv.Quality < 50)
                    throw new Exception("图片模糊,请重新选择身份证图片");
                if (adv?.WarnInfos?.Where(x => x == -9100) == null)
                    throw new Exception("身份证日期不合法,请重新选择身份证图片");
                if (adv?.WarnInfos?.Where(x => x == -9106) == null)
                    throw new Exception("该图片可能是被PS过,请重新选择身份证图片");
                CropIdCard = adv.IdCard;
                return resp;
            }
            catch (Exception)
            {
                throw;
            }
        }
    }
    //返回扩展参数
    internal class AdvancedInfo
    {
        /// <summary>
        /// idCard 裁剪后身份证照片的base64编码,请求 Config.CropIdCard 时返回;
        /// </summary>
        public string? IdCard { get; set; }
        /// <summary>
        /// 身份证头像照片的base64编码,请求 Config.CropPortrait 时返回;
        /// </summary>
        public string? Portrait { get; set; }
        /// <summary>
        /// 图片质量分数,请求 Config.Quality 时返回(取值范围:0 ~ 100,分数越低越模糊,建议阈值≥50);
        /// </summary>
        public int? Quality { get; set; }
        /// <summary>
        /// 身份证边框不完整告警阈值分数,请求 Config.BorderCheckWarn时返回(取值范围:0 ~ 100,分数越低边框遮挡可能性越低,建议阈值≤50);
        /// </summary>
        public int BorderCodeValue { get; set; }
        /// <summary>
        /// 告警信息,Code 告警码列表和释义:
        ///-9100 身份证有效日期不合法告警,
        ///-9101 身份证边框不完整告警,
        ///-9102 身份证复印件告警,
        ///-9103 身份证翻拍告警,
        ///-9105 身份证框内遮挡告警,
        ///-9104 临时身份证告警,
        ///-9106 身份证 PS 告警,
        ///-9107 身份证反光告警。
        /// </summary>
        public List<int> WarnInfos { get; set; }
    }
}
cylsg/EzUpFile/Class1.cs
New file
@@ -0,0 +1,7 @@
namespace EzUpFile
{
    public class Class1
    {
    }
}
cylsg/EzUpFile/EzUpFile.csproj
New file
@@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net8.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>
</Project>
cylsg/EzWechat/EzWechat.csproj
@@ -12,6 +12,13 @@
  <ItemGroup>
    <ProjectReference Include="..\cylsg.Core\cylsg.Core.csproj" />
    <ProjectReference Include="..\cylsg.redis\cylsg.redis.csproj" />
  </ItemGroup>
  <ItemGroup>
    <None Update="WechatConfig.json">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </None>
  </ItemGroup>
</Project>
cylsg/EzWechat/IWechatService.cs
@@ -1,4 +1,5 @@
using System;
using SKIT.FlurlHttpClient.Wechat.Api.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -9,5 +10,17 @@
    public interface IWechatService
    {
        /// <summary>
        /// 使用jsocde 换区 code
        /// </summary>
        /// <param name="jscode"></param>
        /// <returns></returns>
        Task<string> GetOpenID(string jscode);
        /// <summary>
        /// 获取手机号码
        /// </summary>
        /// <param name="bindgetphonenumber"></param>
        /// <returns></returns>
        Task<string> GetPhone(string bindgetphonenumber);
    }
}
cylsg/EzWechat/WechatConfig.json
@@ -1,7 +1,7 @@
{
  "WechatAPP" :{
    "AppId": "微信 AppId",
    "AppSecret": "微信 AppSecret"
  "WechatAPP": {
    "AppId": "wx983556688354dd14",
    "AppSecret": "2ab1aefaac926855dc9d5f7bf7f04477"
  }
}
cylsg/EzWechat/WechatService.cs
@@ -1,26 +1,35 @@
using Furion;
using EzCoreNet.Redis;
using Furion;
using Furion.DependencyInjection;
using Furion.DynamicApiController;
using Furion.FriendlyException;
using Microsoft.Extensions.Options;
using SKIT.FlurlHttpClient.Wechat.Api;
using SKIT.FlurlHttpClient.Wechat.Api.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
namespace EzWechat
{
    public class WechatService:IWechatService
    public class WechatService:IWechatService ,IScoped
    {
        private readonly WechatApiClient _client;
        private readonly IEzCoreNetRedisService _redisService;
        public WechatService() {
        public WechatService(IEzCoreNetRedisService ezCoreNetRedis) {
            /* 以公众号获取用户信息接口为例 */
            var request = new WechatApiClientOptions()
            {
                AppId = App.Configuration["WechatAPP:AppId"],
                AppSecret = App.Configuration["WechatAPP:AppSecret"],
                Timeout=3000,
                //ImmeDeliveryAppKey = "即时配送相关服务 AppKey,不用则不填",
                //ImmeDeliveryAppSecret = "即时配送相关服务 AppSecret,不用则不填",
                //VirtualPaymentAppKey = "虚拟支付相关服务 AppKey,不用则不填",
@@ -28,9 +37,73 @@
                //MidasAppKey = "米大师 1.0 相关服务 AppKey,不用则不填",
                //MidasOfferIdV2 = "米大师 2.0 相关服务 OfferId,不用则不填",
                //MidasAppKeyV2 = "米大师 2.0 相关服务 AppKey,不用则不填"
            };
            _client = WechatApiClientBuilder.Create(request).Build();
            _redisService = ezCoreNetRedis;
        }
        public async Task<string> GetOpenID(string jscode)
        {
            var reques = new SnsComponentJsCode2SessionRequest()
            {
                AppId = App.Configuration["WechatAPP:AppId"],
                JsCode = jscode
            };
          var a= await _client.ExecuteSnsComponentJsCode2SessionAsync(reques);
            if(a.IsSuccessful())
            {
                return a.OpenId;
            }
            else
            {
                throw Oops.Oh($"{a.ErrorCode}+++{a.ErrorMessage}");
            }
        }
        public async Task<string> GetPhone( string bindgetphonenumber)
        {
            var requs = new WxaBusinessGetUserPhoneNumberRequest()
            {
                AccessToken = await GetAccessToken(),
                 Code= bindgetphonenumber
            };
            var a= await _client.ExecuteWxaBusinessGetUserPhoneNumberAsync(requs);
            if (a.IsSuccessful())
                return a.PhoneInfo.PurePhoneNumber;
            else
            {
                throw Oops.Oh($"{a.ErrorCode}+++{a.ErrorMessage}");
            }
        }
        /// <summary>
        /// 获取AccToken
        /// </summary>
        /// <returns></returns>
         private  async Task<string> GetAccessToken()
        {
            string key = _redisService.Get<string>("WxAccessToken");
            if(string.IsNullOrEmpty(key))
            {
               var a  =  await  _client.ExecuteCgibinTokenAsync(new CgibinTokenRequest { });
                if(!a.IsSuccessful())
                {
                    throw Oops.Oh($"{a.ErrorCode}+++{a.ErrorMessage}");
                }
                key=a.AccessToken;
                 _redisService.Add<string>("WxAccessToken", a.AccessToken, 7000);
            }
            return key;
        }
    }
}
cylsg/cylsg.Application/LogoInController.cs
New file
@@ -0,0 +1,163 @@
using cylsg.Authorization;
using cylsg.Core;
using cylsg.Model.UserModel;
using EzWechat;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace cylsg.Application
{
    /// <summary>
    /// 登录
    /// </summary>
    [DynamicApiController]
    public class LogoIn
    {
        private readonly IWechatService _wechatService;
        private readonly IEzAuthorizationService _ezAuthorizationService;
        public LogoIn(IWechatService wechatService,
            IEzAuthorizationService ezAuthorizationService)
        {
            _wechatService = wechatService;
            _ezAuthorizationService = ezAuthorizationService;
        }
        /// <summary>
        /// 快速登录
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        [QueryParameters]
        public async Task<TokenInfo> LogoinFast(string jscode)
        {
            var opeid = await _wechatService.GetOpenID(jscode);
            var UserRes = new BaseRepository<User>();
            var user = await UserRes.GetFirstAsync(x => x.WxAppId == opeid);
            if (user == null)
            {
                throw Oops.Oh("没找到用户,需要重新注册登录");
            }
            var jwt = new EzJwtModel()
            {
                ITCode = user.ItCode,
                NickName = user.Nickname,
                UserID = user.Id,
            };
            return   _ezAuthorizationService.CreateToken<EzJwtModel>(jwt);
        }
        /// <summary>
        /// 注册用户并登录
        /// </summary>
        /// <param name="Param">logoinjscode</param>
        /// <returns></returns>
        [HttpPost]
        public async Task<TokenInfo> CreateUser(UserInfoIn Param)
        {
            var opeid = await _wechatService.GetOpenID(Param.JsCode);
            var UserRes = new BaseRepository<User>();
            var user = await UserRes.GetFirstAsync(x => x.WxAppId == opeid);
            if (user == null)
            {
                //没有用户 ,需要新建用户
                var phone = await _wechatService.GetPhone(Param.Bindgetphonenumber);
                user = new User
                {
                    Avatar = phone,
                    Nickname = Param.Nickname,
                    name = Param.Name ?? phone,
                    Phone = phone,
                    ItCode = phone,
                    PassWord = "123456",
                    WxAppId = opeid,
                };
                await UserRes.EzInsertAsync(user);
            }
            var jwt = new EzJwtModel()
            {
                ITCode = user.ItCode,
                NickName = user.Nickname,
                UserID = user.Id,
            };
            return _ezAuthorizationService.CreateToken<EzJwtModel>(jwt);
        }
    }
    /// <summary>
    /// 创建用户模型
    /// </summary>
      public class  UserInfoIn()
    {
        /// <summary>
        /// 头像
        /// </summary>
        public string? Avatar { get; set; }
        /// <summary>
        /// 昵称
        /// </summary>
        public string? Nickname { get; set; }
        /// <summary>
        /// 电话
        /// </summary>
        public string? Phone { get; set; }
        /// <summary>
        /// 名称
        /// </summary>
        public string? Name { get; set; }
        /// <summary>
        /// 手机号换取码
        /// </summary>
        [Required]
        public string Bindgetphonenumber {  get; set; }
        /// <summary>
        /// jscode
        /// </summary>
        [Required]
        public string JsCode { get; set;}
    }
}
cylsg/cylsg.Application/applicationsettings.json
@@ -1,22 +1,22 @@
{
  "$schema": "https://gitee.com/dotnetchina/Furion/raw/v4/schemas/v4/furion-schema.json",
  "SpecificationDocumentSettings": {
    "DocumentTitle": "Furion | 规范化接口",
    "DocumentTitle": "Furion | 川印零时工",
    "GroupOpenApiInfos": [
      {
        "Group": "Default",
        "Title": "规范化演示",
        "Description": "川印灵时工",
        "Title": "川印零时工",
        "Description": "川印零时工",
        "Version": "1.0.0",
        "Contact": {
          "Name": "",
          "Email": "monksoul@outlook.com"
        },
        "License": {
          "Name": "Apache-2.0"
        }
      }
    ]
cylsg/cylsg.Application/cylsg.Application.csproj
@@ -22,8 +22,12 @@
    </ItemGroup>
    <ItemGroup>
        <ProjectReference Include="..\cylsg.Authorization\cylsg.Authorization.csproj" />
        <ProjectReference Include="..\cylsg.Core\cylsg.Core.csproj" />
        <ProjectReference Include="..\cylsg.Model\cylsg.Model.csproj" />
        <ProjectReference Include="..\cylsg.redis\cylsg.redis.csproj" />
        <ProjectReference Include="..\EzTencentCloud\EzTencentCloud.csproj" />
        <ProjectReference Include="..\EzWechat\EzWechat.csproj" />
    </ItemGroup>
    <ItemGroup>
cylsg/cylsg.Application/cylsg.Application.xml
@@ -4,6 +4,64 @@
        <name>cylsg.Application</name>
    </assembly>
    <members>
        <member name="T:cylsg.Application.LogoIn">
            <summary>
            登录
            </summary>
        </member>
        <member name="M:cylsg.Application.LogoIn.LogoinFast(System.String)">
            <summary>
            快速登录
            </summary>
            <returns></returns>
        </member>
        <member name="M:cylsg.Application.LogoIn.CreateUser(cylsg.Application.UserInfoIn)">
            <summary>
            注册用户并登录
            </summary>
            <param name="Param">logoinjscode</param>
            <returns></returns>
        </member>
        <member name="T:cylsg.Application.UserInfoIn">
            <summary>
            创建用户模型
            </summary>
        </member>
        <member name="M:cylsg.Application.UserInfoIn.#ctor">
            <summary>
            创建用户模型
            </summary>
        </member>
        <member name="P:cylsg.Application.UserInfoIn.Avatar">
            <summary>
            头像
            </summary>
        </member>
        <member name="P:cylsg.Application.UserInfoIn.Nickname">
            <summary>
            昵称
            </summary>
        </member>
        <member name="P:cylsg.Application.UserInfoIn.Phone">
            <summary>
            电话
            </summary>
        </member>
        <member name="P:cylsg.Application.UserInfoIn.Name">
            <summary>
            名称
            </summary>
        </member>
        <member name="P:cylsg.Application.UserInfoIn.Bindgetphonenumber">
            <summary>
            手机号换取码
            </summary>
        </member>
        <member name="P:cylsg.Application.UserInfoIn.JsCode">
            <summary>
            jscode
            </summary>
        </member>
        <member name="T:cylsg.Application.SystemAppService">
            <summary>
            系统服务接口
cylsg/cylsg.Authorization/IEzAuthorizationService.cs
@@ -12,7 +12,7 @@
    public interface IEzAuthorizationService
    {
        TokenInfo CreateToken<T>(T jwt) where T : EzJwtModel;
        public Task<TokenInfo?> RefreshToken<T>(string refToken) where T : EzJwtModel;
         Task<TokenInfo?> RefreshToken<T>(string refToken) where T : EzJwtModel;
    }
cylsg/cylsg.Model/UserModel/User.cs
@@ -43,20 +43,25 @@
        /// <summary>
        /// 昵称
        /// </summary>
        [SugarColumn(ColumnDescription = "用户ID", Length = 100)]
        public int Nickname { get; set; }
        [SugarColumn(ColumnDescription = "昵称", Length = 100)]
        public string Nickname { get; set; }
        /// <summary>
        /// 密码
        /// </summary>
        [SugarColumn(ColumnDescription = "密码", Length = 100)]
        public int PassWord { get; set; }
        public string PassWord { get; set; }
        /// <summary>
        /// 头像地址
        /// </summary>
        [SugarColumn(ColumnDescription = "头像地址")]
        public int Avatar { get; set; }
        public string Avatar { get; set; }
        /// <summary>
        /// 微信APPID
        /// </summary>
        [SugarColumn(ColumnDescription = "WxAppId",Length =30)]
        public string?  WxAppId { get; set; }
    }
}
cylsg/cylsg.Web.Core/Startup.cs
@@ -7,6 +7,9 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using SqlSugar;
using System.Text.Encodings.Web;
using System.Text.Json.Serialization;
using System.Text.Unicode;
namespace cylsg.Web.Core;
@@ -25,7 +28,20 @@
            return DbContext.Instance;
        }
        );
        services.AddJsonOptions(options =>
           {
               //更改输出输入枚举属性为 字段名
               options.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter());
               //空值不输出json格式
               options.JsonSerializerOptions.DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull;
               options.JsonSerializerOptions.Encoder = JavaScriptEncoder.Create(UnicodeRanges.All);
               options.JsonSerializerOptions.Encoder = JavaScriptEncoder.Create(UnicodeRanges.All);
               //  options.JsonSerializerOptions.Encoder = JavaScriptEncoder.Create(UnicodeRanges.All);
               // options.JsonSerializerOptions.Encoder = JavaScriptEncoder.Create();
           });
        services.AddControllersWithViews()
                    .AddInjectWithUnifyResult<EzCoreRESTFulResultProvider>();
    }
cylsg/cylsg.Web.Entry/Properties/launchSettings.json
@@ -3,7 +3,7 @@
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iisExpress": {
      "applicationUrl": "http://localhost:58595",
      "applicationUrl": "http://127.0.0.1:58595",
      "sslPort": 44326
    }
  },
@@ -19,7 +19,7 @@
      "commandName": "Project",
      "dotnetRunMessages": true,
      "launchBrowser": true,
      "applicationUrl": "https://localhost:5001;http://localhost:5000",
      "applicationUrl": "http://0.0.0.0:5000",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
cylsg/cylsg.Web.Entry/SingleFilePublish.cs
@@ -16,7 +16,10 @@
        {
            "cylsg.Application",
            "cylsg.Core",
            "cylsg.Web.Core"
            "cylsg.Web.Core",
            "EzWechat",
              "EzWechat",
              "cylsg.redis"
        };
    }
}
cylsg/cylsg.Web.Entry/appsettings.json
@@ -24,6 +24,12 @@
  ],
  "DynamicApiControllerSettings": {
    "KeepName": true,
    "KeepVerb": true,
    "LowercaseRoute": false
  },
  "JWTSettings": {
    "ValidateIssuerSigningKey": true, // 是否验证密钥,bool 类型,默认true
    "IssuerSigningKey": "129(*dasd09213)*(*jKDl65656656532jiohi", // 密钥,string 类型,必须是复杂密钥,长度大于16
cylsg/cylsg.Web.Entry/cylsg.Web.Entry.csproj
@@ -12,6 +12,7 @@
    <ItemGroup>
        <ProjectReference Include="..\cylsg.Web.Core\cylsg.Web.Core.csproj" />
        <ProjectReference Include="..\EzWechat\EzWechat.csproj" />
    </ItemGroup>
</Project>
cylsg/cylsg.redis/RedisConfig.json
@@ -2,7 +2,7 @@
  //请保持redis为正常可用
  "RedisConfig": {
    // 如果采用容器化部署Service 要写成redis的服务名,否则写地址
    "ConnectionString": "127.0.0.1:6379,password=,connectTimeout=30000,responseTimeout=30000,abortConnect=false,connectRetry=1,syncTimeout=10000,DefaultDatabase=1" //redis数据库连接字符串
    "ConnectionString": "127.0.0.1:6379,password=,connectTimeout=30000,responseTimeout=30000,abortConnect=false,connectRetry=1,syncTimeout=10000,DefaultDatabase=3" //redis数据库连接字符串
  }
}
cylsg/cylsg.redis/cylsg.redis.csproj
@@ -14,4 +14,10 @@
    <ProjectReference Include="..\cylsg.Core\cylsg.Core.csproj" />
  </ItemGroup>
  <ItemGroup>
    <None Update="RedisConfig.json">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </None>
  </ItemGroup>
</Project>
cylsg/cylsg.sln
@@ -11,17 +11,19 @@
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "cylsg.Web.Entry", "cylsg.Web.Entry\cylsg.Web.Entry.csproj", "{9826E365-EEE9-4721-A738-B02AB64D47E5}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "cylsg.Model", "cylsg.Model\cylsg.Model.csproj", "{09E3AFC0-0975-4842-891F-9B5C78E12458}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "cylsg.Model", "cylsg.Model\cylsg.Model.csproj", "{09E3AFC0-0975-4842-891F-9B5C78E12458}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "cylsg.utility", "cylsg.utility\cylsg.utility.csproj", "{5ED2C481-2D74-43BC-ABAF-1455A052FAA4}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "cylsg.utility", "cylsg.utility\cylsg.utility.csproj", "{5ED2C481-2D74-43BC-ABAF-1455A052FAA4}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EzWechat", "EzWechat\EzWechat.csproj", "{709CC927-07D3-4400-BD57-838A44B4FBD4}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EzWechat", "EzWechat\EzWechat.csproj", "{709CC927-07D3-4400-BD57-838A44B4FBD4}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "cylsg.services", "cylsg.services\cylsg.services.csproj", "{28CCF771-A760-4191-B299-4E53B5B23D91}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "cylsg.services", "cylsg.services\cylsg.services.csproj", "{28CCF771-A760-4191-B299-4E53B5B23D91}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "cylsg.redis", "cylsg.redis\cylsg.redis.csproj", "{15042E77-32D5-46DE-9CE5-24D093C63422}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "cylsg.redis", "cylsg.redis\cylsg.redis.csproj", "{15042E77-32D5-46DE-9CE5-24D093C63422}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "cylsg.Authorization", "cylsg.Authorization\cylsg.Authorization.csproj", "{1197C9BB-C73D-42FB-A114-AFB0A7466615}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "cylsg.Authorization", "cylsg.Authorization\cylsg.Authorization.csproj", "{1197C9BB-C73D-42FB-A114-AFB0A7466615}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EzTencentCloud", "EzTencentCloud\EzTencentCloud.csproj", "{8E2530EC-45FE-4EC6-A29A-1B8F25E0F94B}"
EndProject
Global
    GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -69,6 +71,10 @@
        {1197C9BB-C73D-42FB-A114-AFB0A7466615}.Debug|Any CPU.Build.0 = Debug|Any CPU
        {1197C9BB-C73D-42FB-A114-AFB0A7466615}.Release|Any CPU.ActiveCfg = Release|Any CPU
        {1197C9BB-C73D-42FB-A114-AFB0A7466615}.Release|Any CPU.Build.0 = Release|Any CPU
        {8E2530EC-45FE-4EC6-A29A-1B8F25E0F94B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
        {8E2530EC-45FE-4EC6-A29A-1B8F25E0F94B}.Debug|Any CPU.Build.0 = Debug|Any CPU
        {8E2530EC-45FE-4EC6-A29A-1B8F25E0F94B}.Release|Any CPU.ActiveCfg = Release|Any CPU
        {8E2530EC-45FE-4EC6-A29A-1B8F25E0F94B}.Release|Any CPU.Build.0 = Release|Any CPU
    EndGlobalSection
    GlobalSection(SolutionProperties) = preSolution
        HideSolutionNode = FALSE