From 57c0156fe021f9c690993e91da5dd280187f4fad Mon Sep 17 00:00:00 2001
From: liaoxujun@qq.com <liaoxujun@qq.com>
Date: 星期二, 01 八月 2023 17:15:03 +0800
Subject: [PATCH] Merge branch 'master' of http://47.108.235.38:8080/r/DocumentService

---
 DocumentServiceAPI.Application/UserAndLogin/Services/UserService.cs |  176 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 176 insertions(+), 0 deletions(-)

diff --git a/DocumentServiceAPI.Application/UserAndLogin/Services/UserService.cs b/DocumentServiceAPI.Application/UserAndLogin/Services/UserService.cs
new file mode 100644
index 0000000..565e374
--- /dev/null
+++ b/DocumentServiceAPI.Application/UserAndLogin/Services/UserService.cs
@@ -0,0 +1,176 @@
+锘縰sing DocumentServiceAPI.Application.UserAndLogin.Services.Interfaces;
+using DocumentServiceAPI.Application.UserAndLogin.ViewMode;
+using DocumentServiceAPI.Model;
+using DocumentServiceAPI.Model.cyDocumentModel;
+using DocumentServiceAPI.Model.UserInfoModel;
+using SqlSugar.Extensions;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Security.Claims;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DocumentServiceAPI.Application.UserAndLogin.Services
+{
+    /// <summary>
+    /// 鐧诲綍楠岃瘉鏈嶅姟
+    /// </summary>
+    public class UserService : ILoginVerifyService, IScoped
+    {
+        private ISqlSugarClient _db { get; set; }
+        public UserService(ISqlSugarClient db)
+        {
+            _db = db;
+        }
+        /// <summary>
+        /// 鍛樺伐璇︽儏
+        /// </summary>
+        /// <param name="ID"></param>
+        /// <param name="TenantID"></param>
+        /// <returns></returns>
+        public async Task<EmployeeTenantInfo> GetEmployeeInfo(int ID, int TenantID)
+        {
+            var ret = await _db.Queryable<EmployeeInfo, EmployeeAtTenant, TenantInfo>((ei, eiat, ti) =>
+              new JoinQueryInfos(
+      JoinType.Right, ei.Id == eiat.EmployeeID, //宸﹁繛鎺� 宸﹂摼鎺� 宸﹁仈 
+      JoinType.Right, ti.Id == eiat.TenantID
+                              )).Where((ei, eiat, ti) => ei.Id == ID && TenantID == ti.Id)
+                              .Select(expression: (ei, eiat, ti) => new EmployeeTenantInfo
+                              {
+                                  _employeeInfo = ei,
+                                  _tenantInfo = ti
+
+                              }).SingleAsync();
+
+            return ret;
+        }
+
+        /// <summary>
+        /// 鑾峰彇Jwt鐩稿叧淇℃伅
+        /// </summary>
+        public JwtInfo GetJwtInfo()
+        {
+            JwtInfo jwtInfo = new JwtInfo();
+            jwtInfo.LogInSource = (LogInFrom)(App.User?.FindFirstValue("loginfrom")?.ObjToInt() ?? 0);
+            jwtInfo.EID = App.User?.FindFirstValue("eid")?.ObjToInt();
+            jwtInfo.UID = App.User?.FindFirstValue("uid")?.ObjToInt();
+            jwtInfo.TID = App.User?.FindFirstValue("tid")?.ObjToInt();
+            var guid = App.User?.FindFirstValue("jid");
+            jwtInfo.JID = string.IsNullOrEmpty(guid) ? new Guid(guid) : null;
+            return jwtInfo;
+        }
+        /// <summary>
+        /// 鑾峰彇鍗曚綅鍒楄〃
+        /// </summary>
+        /// <returns></returns>
+        public async Task<List<UnitVM>> GetUserUnitInfo(int  tid )
+        {
+
+            var list = await _db.Queryable<DocumentServiceAPI.Model.cyDocumentModel.Document_TenderUnit>()
+                   .Where((tu) => tu.TenantId == tid && tu.IsEn == true && tu.IsDeled != true)
+                   .Select((tu) => new UnitVM
+                   {
+                       UnitID = tu.UnitId,
+                       UnitName = tu.UnitName,
+                       Remark = tu.Remark,
+                       UnitLogo = tu.UnitLogo,
+                   })
+                   .ToListAsync();
+            return list;
+        }
+
+        /// <summary>
+        /// 鏍规嵁璐﹀彿鑾峰彇 Tender 鍒楄〃
+        /// </summary>
+        /// <param name="ItCode"></param>
+        /// <returns></returns>
+        public async Task<List<TenderVM>> GetUserTenderList(string ItCode)
+            
+        {
+          
+            var tentlist= await _db.Queryable<TenantInfo, EmployeeAtTenant, Document_EmployeeInfo>((ti, et, ei) =>
+
+              new JoinQueryInfos
+              (
+                 JoinType.Right, ti.Id == et.TenantID, //宸﹁繛鎺� 宸﹂摼鎺� 宸﹁仈 
+             JoinType.Right, ei.EmployeeId == et.EmployeeID
+                  )
+             )
+                .Where((ti, et, ei) =>
+              ( ei.UserName == ItCode) && (ti.IsEn == true) && (ti.IsDel != true) && (ei.IsWork == null || ei.IsWork == 1))
+
+             .Select((ti, et, ei) => new TenderVM
+             {
+                 EmployeeID = ei.EmployeeId,
+                 Description = ti.Description,
+                 ItCode = ItCode,
+                 Name = ti.Name,
+                 TenderId = ti.Id
+                 
+             }
+              ).ToListAsync();
+
+            var ten = await _db.Queryable<TenantInfo>().Where(x => x.IsEn == true && x.IsDel != true && x.ItCode == ItCode)
+                   .Select(x => new TenderVM
+                   {
+
+                       Description = x.Description,
+                       ItCode = ItCode,
+                       Name = x.Name,
+                       TenderId = x.Id,
+                       IsTender = true
+
+                   }
+              ).ToListAsync()  ;
+            ten.AddRange(tentlist);
+            return ten;
+
+        }
+
+        /// <summary>
+        /// 妫�鏌ュ瘑鐮佹槸鍚︾櫥褰�
+        /// </summary>
+        /// <param name="TenantID"> 绉熸埛ID</param>
+        /// <param name="employeeID">鍛樺伐ID</param>
+        /// <param name="PsW">瀵嗙爜</param>
+        /// <returns></returns>
+        public async Task<bool> CheckPsw(int TenantID, int? employeeID, string PsW)
+        {
+            if (employeeID == null)
+            {
+                var psw = await _db.Queryable<TenantInfo>().Where(x => x.Id == TenantID).Select(x => x.PsW).SingleAsync();
+                if (PsW == psw)
+                    return true;
+            }
+            else
+            {
+                var psw = await _db.Queryable<Document_EmployeeInfo, EmployeeAtTenant, TenantInfo>((ei, et, ti) =>
+
+             new JoinQueryInfos
+             (
+                JoinType.Left, ei.EmployeeId == et.EmployeeID, //宸﹁繛鎺� 宸﹂摼鎺� 宸﹁仈 
+            JoinType.Left, ti.Id == et.TenantID
+                 )
+            ).Where((ei, et, ti) =>
+
+                ei.EmployeeId == employeeID && ti.Id == TenantID
+            )
+            .Select((ei, et, ti) => ei.UserPassWord)
+            .SingleAsync();
+                if (PsW == psw)
+                    return true;
+            }
+            return false;
+
+        }
+
+
+       
+    }
+
+
+}
+
+
+

--
Gitblit v1.9.1