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/LogInController.cs | 175 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 175 insertions(+), 0 deletions(-) diff --git a/DocumentServiceAPI.Application/UserAndLogin/LogInController.cs b/DocumentServiceAPI.Application/UserAndLogin/LogInController.cs new file mode 100644 index 0000000..ddcbf1f --- /dev/null +++ b/DocumentServiceAPI.Application/UserAndLogin/LogInController.cs @@ -0,0 +1,175 @@ +锘縰sing DocumentServiceAPI.Application.UserAndLogin.Services; +using DocumentServiceAPI.Application.UserAndLogin.ViewMode; +using DocumentServiceAPI.Utility; +using Furion.DynamicApiController; +using Furion.JsonSerialization; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DocumentServiceAPI.Application.UserAndLogin +{ + /// <summary> + /// 鐧诲綍鎺у埗鍣� + /// </summary> + [ApiDescriptionSettings("LogInAndUser")] + [DynamicApiController] + public class LogInController + { + private TokenService _tokenService; + private UserService _userService; + public LogInController(TokenService tokenService,UserService userService) { + _tokenService = tokenService; + _userService = userService; + } + /// <summary> + /// 鐧诲綍 1 杈撳叆鍛樺伐璐︽埛鎴栬�呯鎴疯处鎴凤紝2 閫夋嫨绉熸埛璐︽埛锛�3 閫夋嫨鍏徃 + /// </summary> + /// <returns>鐧诲綍淇℃伅</returns> + [HttpPost("LogoIn")] + public async Task<RetLoginVM> LogoIn (LoginPsWordIN Parma) + { + bool needtoken=false; + if (Parma.TenantId==null) + { + //濡傛灉杩樻病纭畾绉熸埛ID 闇�瑕佸厛纭畾绉熸埛ID + List<TenderVM>Tender = await _userService.GetUserTenderList(Parma.ITCode); + + switch (Tender.Count) + { + case 0: + throw Oops.Oh($"璐︽埛鎴栬�呭瘑鐮侀敊璇�"); + case 1: + needtoken = await _userService.CheckPsw(Tender[0].TenderId, Tender[0].EmployeeID,Parma.PassWord); + + if(!needtoken) + throw Oops.Oh($"璐︽埛鎴栬�呭瘑鐮侀敊璇�"); + if (Parma.UnitID == null) + { + var Units = await _userService.GetUserUnitInfo(Parma.TenantId ?? 0); + if (Units.Count == 0) + { + //娌℃湁鍏徃 + needtoken = true; + } + else if (Units.Count == 1) + { + Parma.UnitID = Units[0].UnitID; + needtoken = true; + } + else + { + //鍏朵粬闇�瑕佺敤鎴烽�夋嫨绉熸埛 + return new RetLoginVM + { + NeedNext = true, + Units = Units, + + }; + } + } + Parma.TenantId = Tender[0].TenderId; + break; + + default: + //鍏朵粬闇�瑕佺敤鎴烽�夋嫨绉熸埛 + return new RetLoginVM + { + NeedNext = true, + Tenders = Tender, + + }; + + + } + + + + + + } + else if(Parma.UnitID==null) + { + + var Units = await _userService.GetUserUnitInfo(Parma.TenantId??0); + if(Units.Count==0) + { + //娌℃湁鍏徃 + needtoken = true; + } + else if (Units.Count==1) { + Parma.UnitID= Units[0].UnitID; + needtoken = true; + } + else + { + //鍏朵粬闇�瑕佺敤鎴烽�夋嫨绉熸埛 + return new RetLoginVM + { + NeedNext = true, + Units = Units, + + }; + } + + } + + if(needtoken|| Parma.UnitID!=null) + { + TenderVM Tender = (await _userService.GetUserTenderList(Parma.ITCode)).Where(x=>x.TenderId==Parma.TenantId&&x.EmployeeID==Parma.employeeID).SingleOrDefault(); + if(Tender==null) + { + throw Oops.Oh($"璐︽埛瀵嗙爜鎴栬�呯鎴烽�夋嫨閿欒"); + } + needtoken = await _userService.CheckPsw(Tender. TenderId, Tender.EmployeeID, Parma.PassWord); + + if (!needtoken) + throw Oops.Oh($"璐︽埛鎴栬�呭瘑鐮侀敊璇�"); + var token= _tokenService.CreateToken(new Model.JwtInfo + { + EID = Tender.EmployeeID, + LogInSource = Parma.Form, + TID = Tender.TenderId, + UID = Parma.UnitID, + }); + return new RetLoginVM + { + NeedNext = false, + Token = token, + + }; + } + throw Oops.Oh($"鍙傛暟閿欒"); + + + } + + + + + /// <summary> + /// 鑾峰彇鍏徃鍒楄〃 + /// </summary> + /// <returns>鐧诲綍淇℃伅</returns> + public bool GetUnitList() + { + + return true; + } + /// <summary> + /// 鑾峰彇鍏徃鍒楄〃 + /// </summary> + /// <returns>鐧诲綍淇℃伅</returns> + public bool GetTenantInfoList() + { + + return true; + } + public string Get() + { + return $"Hello {nameof(Furion)}"; + } + } +} -- Gitblit v1.9.1