From 19459be5ff2c2ca74b3f953bb1255061a36c24ad Mon Sep 17 00:00:00 2001
From: liaoxujun@qq.com <liaoxujun@qq.com>
Date: 星期三, 23 八月 2023 14:27:52 +0800
Subject: [PATCH] 修正授权函数类,增加数据库连接配置

---
 DocumentServiceAPI.Application/UserAndLogin/ViewMode/UserInfo.cs       |    6 
 DocumentServiceAPI.Model/Permissions/TenantPermissions.cs              |    2 
 DocumentServiceAPI.Web.Entry/appsettings.json                          |    2 
 DocumentServiceAPI.Application/DocumentServiceAPI.Application.xml      |   14 ++
 DocumentServiceApi.InitQMessage/DocumentServiceApi.InitQMessage.csproj |    1 
 DocumentServiceApi.InitQMessage/MessageReceive.cs                      |  158 ++++++++++++++++++++++++++++++
 DocumentServiceAPI.Model/UserInfoModel/TenantInfo.cs                   |    7 +
 DocumentServiceAPI.Model/Oder/Oder.cs                                  |   50 ++++++++++
 DocumentServiceApi.InitQMessage/INITQMessageDefine.cs                  |    7 +
 DocumentServiceApi.InitQMessage/TenantOderInfo.cs                      |   50 +++++++++
 10 files changed, 282 insertions(+), 15 deletions(-)

diff --git a/DocumentServiceAPI.Application/DocumentServiceAPI.Application.xml b/DocumentServiceAPI.Application/DocumentServiceAPI.Application.xml
index 91a23df..1855168 100644
--- a/DocumentServiceAPI.Application/DocumentServiceAPI.Application.xml
+++ b/DocumentServiceAPI.Application/DocumentServiceAPI.Application.xml
@@ -893,6 +893,7 @@
         <member name="M:DocumentServiceAPI.Application.UserAndLogin.LogInController.LogoIn(DocumentServiceAPI.Application.UserAndLogin.ViewMode.LoginPsWordIN)">
             <summary>
             鐧诲綍 1 杈撳叆鍛樺伐璐︽埛鎴栬�呯鎴疯处鎴凤紝2 閫夋嫨绉熸埛璐︽埛锛�3 閫夋嫨鍏徃
+            褰撳瘑鐮佷负绌烘椂锛屽甫鍏ョ敤鎴蜂腑蹇僼oken鍗冲彲瀹炵幇鐧诲綍
             </summary>
             <returns>鐧诲綍淇℃伅</returns>
         </member>
@@ -922,6 +923,15 @@
             <summary>
             鏂板缓涓�涓猅Oken 
             </summary>
+            <returns></returns>
+        </member>
+        <member name="M:DocumentServiceAPI.Application.UserAndLogin.Services.TokenService.CheckJwt(System.String,Microsoft.IdentityModel.Tokens.SecurityToken@)">
+            <summary>
+            鏍¢獙token 鐨勬湁鏁堟��
+            </summary>
+            <param name="Token"> Token鏍¢獙</param>
+            <param name="validationParameters"></param>
+            <param name="securityToken"></param>
             <returns></returns>
         </member>
         <member name="M:DocumentServiceAPI.Application.UserAndLogin.Services.TokenService.CheckToken">
@@ -1262,8 +1272,8 @@
         </member>
         <member name="P:DocumentServiceAPI.Application.UserAndLogin.ViewMode.EmployeeInfoVM.UserName">
             <summary>
-            鐢ㄦ埛鍚�
-            </summary>           
+            鐢ㄦ埛鍚� 鎵嬫満鍙烽獙璇� 蹇呭~
+            </summary>  
         </member>
         <member name="P:DocumentServiceAPI.Application.UserAndLogin.ViewMode.EmployeeInfoVM.UserPassWord">
             <summary>
diff --git a/DocumentServiceAPI.Application/UserAndLogin/ViewMode/UserInfo.cs b/DocumentServiceAPI.Application/UserAndLogin/ViewMode/UserInfo.cs
index 7494f98..2ec9abe 100644
--- a/DocumentServiceAPI.Application/UserAndLogin/ViewMode/UserInfo.cs
+++ b/DocumentServiceAPI.Application/UserAndLogin/ViewMode/UserInfo.cs
@@ -130,8 +130,10 @@
         /// </summary>           
         public string LastUpdateName { get; set; }
         /// <summary>
-        /// 鐢ㄦ埛鍚�
-        /// </summary>           
+        /// 鐢ㄦ埛鍚� 鎵嬫満鍙烽獙璇� 蹇呭~
+        /// </summary>  
+        [Required]
+        [RegularExpression("/^(?:(?:\\+|00)86)?1\\d{10}$/")]
         public string UserName { get; set; }
         /// <summary>
         /// 鐢ㄦ埛瀵嗙爜
diff --git a/DocumentServiceAPI.Model/Oder/Oder.cs b/DocumentServiceAPI.Model/Oder/Oder.cs
index 214e718..818f1a7 100644
--- a/DocumentServiceAPI.Model/Oder/Oder.cs
+++ b/DocumentServiceAPI.Model/Oder/Oder.cs
@@ -1,6 +1,8 @@
 锘縰sing DocumentServiceAPI.Enum;
+using SqlSugar;
 using System;
 using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
@@ -12,6 +14,54 @@
     /// </summary>
     public class Oder:BaseModel
     {
+        /// <summary>
+        /// OderID
+        /// </summary>
+        [SugarColumn( IsPrimaryKey =true,IsIdentity =true)]
+        public int Id { get; set; }
+        /// <summary>
+        /// 鏈堜唤
+        /// </summary>
+        [Display(Name = "鏈堜唤")]
+        public int? MonthCount { get; set; }
+
+        /// <summary>
+        /// 鍗曚綅涓暟
+        /// </summary>
+        [Display(Name = "鍗曚綅涓暟")]
+        public int? UnitCount { get; set; }
+
+        /// <summary>
+        /// 鍛樺伐
+        /// </summary>
+        [Display(Name = "鍛樺伐涓暟")]
+        public int? EmployeeCount { get; set; }
+        /// <summary>
+        /// 鍗曚环
+        /// </summary>
+        [Display(Name = "閲戦")]
+        public decimal Amount { get; set; }
+       /// <summary>
+       /// 鏀粯鏂瑰紡
+       /// </summary>
+        public string? PayType { get; set; }
+        /// <summary>
+        /// 鏀粯鏃堕棿
+        /// </summary>
+        public DateTime? PayTime { get; set; }
+        /// <summary>
+        /// 鎻忚堪
+        /// </summary>        
+        public string? Description { get; set; }
+
+        /// <summary>
+        /// 鎵嬫満鍙风爜
+        /// </summary>
+        public string ITCode { get; set; }
+        /// <summary>
+        /// 鏀块噰鐢ㄦ埛涓績ID
+        /// </summary>
+        public Guid? ZcUserID { get; set; }
 
 
     }
diff --git a/DocumentServiceAPI.Model/Permissions/TenantPermissions.cs b/DocumentServiceAPI.Model/Permissions/TenantPermissions.cs
index f896efb..d5b331b 100644
--- a/DocumentServiceAPI.Model/Permissions/TenantPermissions.cs
+++ b/DocumentServiceAPI.Model/Permissions/TenantPermissions.cs
@@ -18,7 +18,7 @@
         /// id
         /// </summary>
         [Display(Name = "id ")]
-        [SugarColumn(ColumnDescription = "id ")]
+        [SugarColumn(ColumnDescription = "id " ,IsPrimaryKey =true,IsIdentity =true)]
         public int Id { get; set; }
 
         /// <summary>
diff --git a/DocumentServiceAPI.Model/UserInfoModel/TenantInfo.cs b/DocumentServiceAPI.Model/UserInfoModel/TenantInfo.cs
index 2773ab1..d84de91 100644
--- a/DocumentServiceAPI.Model/UserInfoModel/TenantInfo.cs
+++ b/DocumentServiceAPI.Model/UserInfoModel/TenantInfo.cs
@@ -68,7 +68,12 @@
         /// 瀵嗙爜
         /// </summary>
         [SugarColumn(Length =30)]
-        public string? PsW { get; set; }  
+        public string? PsW { get; set; }
+
+        /// <summary>
+        /// 鏀块噰鐢ㄦ埛涓績ID
+        /// </summary>
+        public Guid? ZcUserID { get; set; }
 
     }
 
diff --git a/DocumentServiceAPI.Web.Entry/appsettings.json b/DocumentServiceAPI.Web.Entry/appsettings.json
index 396bcc1..749ed0e 100644
--- a/DocumentServiceAPI.Web.Entry/appsettings.json
+++ b/DocumentServiceAPI.Web.Entry/appsettings.json
@@ -21,7 +21,7 @@
     }
   ],
 
-  "isCodeFirst": false, //鏄惁鎵цcodefirst 娉ㄦ剰杩欎釜鍦ㄨ縼寰欏畬鎴愬悗搴旇璁剧疆涓篺alse 闃叉鏇存敼鏁版嵁搴�
+  "isCodeFirst": true, //鏄惁鎵цcodefirst 娉ㄦ剰杩欎釜鍦ㄨ縼寰欏畬鎴愬悗搴旇璁剧疆涓篺alse 闃叉鏇存敼鏁版嵁搴�
   //璇蜂繚鎸乺edis涓烘甯稿彲鐢�
   "RedisConfig": {
     // 濡傛灉閲囩敤瀹瑰櫒鍖栭儴缃睸ervice 瑕佸啓鎴恟edis鐨勬湇鍔″悕锛屽惁鍒欏啓鍦板潃
diff --git a/DocumentServiceApi.InitQMessage/DocumentServiceApi.InitQMessage.csproj b/DocumentServiceApi.InitQMessage/DocumentServiceApi.InitQMessage.csproj
index 04978e7..cd7176f 100644
--- a/DocumentServiceApi.InitQMessage/DocumentServiceApi.InitQMessage.csproj
+++ b/DocumentServiceApi.InitQMessage/DocumentServiceApi.InitQMessage.csproj
@@ -12,6 +12,7 @@
 
   <ItemGroup>
     <ProjectReference Include="..\DocumentServiceAPI.Core\DocumentServiceAPI.Core.csproj" />
+    <ProjectReference Include="..\DocumentServiceAPI.Model\DocumentServiceAPI.Model.csproj" />
   </ItemGroup>
 
 </Project>
diff --git a/DocumentServiceApi.InitQMessage/INITQMessageDefine.cs b/DocumentServiceApi.InitQMessage/INITQMessageDefine.cs
index 55ad3dd..a95de16 100644
--- a/DocumentServiceApi.InitQMessage/INITQMessageDefine.cs
+++ b/DocumentServiceApi.InitQMessage/INITQMessageDefine.cs
@@ -14,6 +14,11 @@
         /// <summary>
         /// 璐叆Oder娑堟伅
         /// </summary>
-        public const string InitTentOder  = "DocumentServiceAPI_OderINIT";
+        public const string InitTenantOder = "DocumentServiceAPI_OderINIT";
+
+        /// <summary>
+        /// 鎾ゅ崟
+        /// </summary>
+        public const string DecTenantOder = "DocumentServiceAPI_DecOderINIT";
     }
 }
diff --git a/DocumentServiceApi.InitQMessage/MessageReceive.cs b/DocumentServiceApi.InitQMessage/MessageReceive.cs
index 1451c2d..39221e6 100644
--- a/DocumentServiceApi.InitQMessage/MessageReceive.cs
+++ b/DocumentServiceApi.InitQMessage/MessageReceive.cs
@@ -1,5 +1,13 @@
-锘縰sing InitQ.Abstractions;
+锘縰sing DocumentServiceAPI.Model.Oder;
+using DocumentServiceAPI.Model.Permissions;
+using DocumentServiceAPI.Model.UserInfoModel;
+using Furion;
+using Furion.JsonSerialization;
+using Furion.Logging.Extensions;
+using InitQ.Abstractions;
 using InitQ.Attributes;
+using Microsoft.Extensions.Options;
+using SqlSugar;
 using System;
 using System.Collections.Generic;
 using System.Linq;
@@ -13,15 +21,157 @@
     /// </summary>
     public class MessageReceive: IRedisSubscribe
     {
+
+         
         /// <summary>
         /// 鍒濆鍖栬鍗曞鐞�
         /// </summary>
         /// <param name="msg"></param>
-        /// <returns></returns>
-       
-        [Subscribe(INITQMessageDefine.InitTentOder)]
+        /// <returns></returns>       
+        [Subscribe(INITQMessageDefine.InitTenantOder)]
         private async Task InitTenantOder(string msg)
         {
+            TenantOderInfo? obj = JSON.Deserialize<TenantOderInfo>(msg);
+            if(obj==null)
+            {
+                $"InitTenantOder 鍒濆鍖� msg 瀵硅薄閿欒 ,msg涓簕msg}".LogInformation<MessageReceive>();
+                return;
+            }
+            var    _db=  App.GetService<ISqlSugarClient>();
+
+
+            Oder oder = new Oder()
+            {
+                Amount = obj.Amount,
+                CreatBy = "娑堟伅闃熷垪 InitTenantOder",
+                CreatTime = DateTime.Now,
+                Description = obj.Description,
+                EmployeeCount = obj.EmployeeCount,
+                MonthCount = obj.MonthCount,
+                UnitCount = obj.UnitCount,
+                PayType = obj.PayType,
+                PayTime = obj.PayTime,
+                ZcUserID = obj.ZcUserID,
+                ITCode = obj.ITCode,
+            };
+            TenantInfo? Tinfo = await _db.Queryable<TenantInfo>().Where(x=>x.ZcUserID==obj.ZcUserID).SingleAsync();
+            if(Tinfo==null)
+            {
+                Tinfo = new TenantInfo
+                {
+                    ZcUserID = obj.ZcUserID,
+                    ItCode = obj.ITCode,
+                    CreatBy = "娑堟伅闃熷垪 InitTenantOder",
+                    CreatTime = DateTime.Now,
+                    Description = obj.Description,
+                    Name = obj.ITCode,
+                    PsW = obj.ITCode.Substring(obj.ITCode.Length - 4),
+
+
+                };
+                TenantPermissions permissions = new TenantPermissions()
+                {
+                    CreatBy = "娑堟伅闃熷垪 InitTenantOder",
+                    CreatTime = DateTime.Now,
+                    Description = obj.Description,
+                    EmployeeMaxCount = obj.EmployeeCount ?? 0,
+                    UnitMaxCount = obj.UnitCount ?? 0,
+                    OverTime = DateTime.Now.AddMonths(obj.MonthCount ?? 0),
+
+
+
+                };
+                try
+                {
+                    await _db.AsTenant().BeginTranAsync();
+
+                  var id=  await _db.Insertable(Tinfo).ExecuteReturnIdentityAsync();
+                    permissions.TenantId = id;
+                    await _db.Insertable(permissions).ExecuteCommandAsync ();
+                    await _db.Insertable(oder).ExecuteCommandAsync();
+                    await _db.AsTenant().CommitTranAsync();
+                }
+                catch (Exception e)
+                {
+                    await _db.AsTenant().RollbackTranAsync();
+                    $"鏂板缓绉熸埛澶勭悊澶辫触 msg:{msg},e:{e.ToString()} BY锛氭秷鎭槦鍒� InitTenantOder".LogInformation<MessageReceive>();
+                    return;
+                }
+
+
+            }
+            else
+            {
+                Tinfo.ItCode = obj.ITCode;
+                Tinfo.UpdataBy = "娑堟伅闃熷垪 InitTenantOder";
+                Tinfo.UpdataTime = DateTime.Now;
+                Tinfo.IsDel = false;
+                Tinfo.IsEn = true;
+              var tp= await _db.Queryable<TenantPermissions>().Where(x=>x.TenantId==Tinfo.Id).FirstAsync();
+
+                try
+                {
+                    await _db.AsTenant().BeginTranAsync();
+                    if (Tinfo.ItCode != obj.ITCode)
+                    {
+                     
+                       await _db.Updateable(Tinfo).ExecuteCommandAsync();
+                    };
+                    if (tp == null)
+                    {
+                        tp = new TenantPermissions()
+                        {
+                            CreatBy = "娑堟伅闃熷垪 InitTenantOder",
+                             CreatTime = DateTime.Now,
+                              IsDel = false,
+                               IsEn = true,
+                                EmployeeMaxCount=obj.EmployeeCount??0,
+                                 UnitMaxCount=obj.UnitCount??0,
+                                  OverTime=DateTime.Now.AddMinutes(obj.MonthCount??0),
+                                   TenantId= Tinfo.Id,
+                                   
+                        };
+                        await _db.Insertable(tp).ExecuteCommandAsync();
+
+                        
+                    }
+                    else
+                    {
+                        tp.IsDel = false;
+                        tp.IsEn = true;
+                        tp.UnitMaxCount = obj.UnitCount ?? tp.UnitMaxCount;
+                        tp.EmployeeMaxCount = obj.EmployeeCount ?? tp.EmployeeMaxCount;
+                        tp.OverTime = tp.OverTime.AddMonths(obj.MonthCount??0);
+                        tp.UpdataBy = "娑堟伅闃熷垪 InitTenantOder";
+                        tp.UpdataTime = DateTime.Now;
+
+                        await _db.Updateable(tp).ExecuteCommandAsync();
+
+                    }
+                    await _db.Insertable(oder).ExecuteCommandAsync();
+                    await _db.AsTenant().CommitTranAsync();
+                
+
+
+
+
+                }
+                catch (Exception e)
+                {
+
+                    await _db.AsTenant().RollbackTranAsync();
+                    $"淇敼绉熸埛鏉冮檺澶辫触 msg:{msg},e:{e.ToString()}  By锛氭秷鎭槦鍒� InitTenantOder".LogInformation<MessageReceive>();
+                    return;
+                }
+            
+            }
+        
+
+
+
+           
+
+         
 
 
 
diff --git a/DocumentServiceApi.InitQMessage/TenantOderInfo.cs b/DocumentServiceApi.InitQMessage/TenantOderInfo.cs
index b27b16f..26eac2c 100644
--- a/DocumentServiceApi.InitQMessage/TenantOderInfo.cs
+++ b/DocumentServiceApi.InitQMessage/TenantOderInfo.cs
@@ -1,5 +1,6 @@
 锘縰sing System;
 using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
@@ -7,10 +8,53 @@
 namespace DocumentServiceApi.InitQMessage
 {
     /// <summary>
-    /// 璁㈠崟璇︽儏
+    /// 璁㈠崟娑堟伅妯″瀷璇︽儏
     /// </summary>
-    public class TenantOderInfo
+    internal class TenantOderInfo
     {
-        public int MyProperty { get; set; }
+        /// <summary>
+        /// 鎵嬫満鍙风爜
+        /// </summary>
+        public string ITCode { get; set; }
+        /// <summary>
+        /// 鏀块噰鐢ㄦ埛涓績ID
+        /// </summary>
+        public Guid? ZcUserID { get; set; }
+        /// <summary>
+        /// 鏈堜唤
+        /// </summary>
+        [Display(Name = "鏈堜唤")]
+        public int? MonthCount { get; set; }
+
+        /// <summary>
+        /// 鍗曚綅涓暟
+        /// </summary>
+        [Display(Name = "鍗曚綅涓暟")]
+        public int? UnitCount { get; set; }
+
+        /// <summary>
+        /// 鍛樺伐
+        /// </summary>
+        [Display(Name = "鍛樺伐涓暟")]
+        public int? EmployeeCount { get; set; }
+        /// <summary>
+        /// 鍗曚环
+        /// </summary>
+        [Display(Name = "閲戦")]
+        public decimal Amount { get; set; }
+        /// <summary>
+        /// 鏀粯鏂瑰紡
+        /// </summary>
+        public string? PayType { get; set; }
+        /// <summary>
+        /// 鏀粯鏃堕棿
+        /// </summary>
+        public DateTime? PayTime { get; set; }
+        /// <summary>
+        /// 鎻忚堪
+        /// </summary>        
+        public string? Description { get; set; }
+
+
     }
 }

--
Gitblit v1.9.1