From 24a3e64f5713fb0c6f8bae865715c66308371955 Mon Sep 17 00:00:00 2001
From: username@email.com <yzy2002yzy@163.com>
Date: 星期四, 15 八月 2024 12:54:55 +0800
Subject: [PATCH] Merge branch 'master' of http://47.108.235.38:8080/r/cylsg

---
 cylsg/cylsg.Application/LogoInController.cs |  164 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 164 insertions(+), 0 deletions(-)

diff --git a/cylsg/cylsg.Application/LogoInController.cs b/cylsg/cylsg.Application/LogoInController.cs
new file mode 100644
index 0000000..8521f42
--- /dev/null
+++ b/cylsg/cylsg.Application/LogoInController.cs
@@ -0,0 +1,164 @@
+锘縰sing cylsg.Authorization;
+using cylsg.Core;
+using cylsg.Model.UserModel;
+using cylsg.utility.Extend;
+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.WxOpenId == 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.WxOpenId == opeid);
+            if (user == null)
+            {
+                //娌℃湁鐢ㄦ埛 锛岄渶瑕佹柊寤虹敤鎴�
+                var phone = await _wechatService.GetPhone(Param.Bindgetphonenumber);
+
+                user = new User
+                {
+
+                    Avatar = phone,
+                    Nickname = Param.Nickname??phone.PrivacyStr(),
+                    name = Param.Name ?? phone,
+                    Phone = phone,
+                    ItCode = phone,
+                    PassWord = "123456",
+                    WxOpenId = 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;}
+    }
+}

--
Gitblit v1.9.1