username@email.com
2025-02-05 d86bc04d0b34f2b7d9ddbd30ee703b51d48876e8
cylsg/cylsg.Application/LogoInController.cs
@@ -1,6 +1,7 @@
using cylsg.Authorization;
using cylsg.Core;
using cylsg.Model.UserModel;
using cylsg.utility.Extend;
using EzWechat;
using System;
using System.Collections.Generic;
@@ -14,6 +15,7 @@
    /// 登录
    /// </summary>
    [DynamicApiController]
    [ApiDescriptionSettings("Default@1")]
    public class LogoIn
    {
        private readonly IWechatService _wechatService;
@@ -39,14 +41,14 @@
            var UserRes = new BaseRepository<User>();
            var user = await UserRes.GetFirstAsync(x => x.WxAppId == opeid);
            var user = await UserRes.GetFirstAsync(x => x.WxOpenId == opeid);
            if (user == null)
            {
                throw Oops.Oh("没找到用户,需要重新注册登录");
            }
            var jwt = new EzJwtModel()
            {
                ITCode = user.ItCode,
                //ITCode = user.ItCode, 不在明文中使用Itcode
                NickName = user.Nickname,
                UserID = user.Id,
@@ -76,34 +78,45 @@
            var UserRes = new BaseRepository<User>();
            var user = await UserRes.GetFirstAsync(x => x.WxAppId == opeid);
            var user = await UserRes.GetFirstAsync(x => x.WxOpenId == opeid);
            if (user == null)
            {
                //没有用户 ,需要新建用户
                var phone = await _wechatService.GetPhone(Param.Bindgetphonenumber);
                 user = await UserRes.GetFirstAsync(x => x.ItCode == phone);
                if(user == null) {
                user = new User
                {
                    Avatar = phone,
                    Nickname = Param.Nickname,
                    Nickname = Param.Nickname??phone.PrivacyStr(),
                    name = Param.Name ?? phone,
                    Phone = phone,
                    ItCode = phone,
                    PassWord = "123456",
                    WxAppId = opeid,
                    WxOpenId = opeid,
                    CreateBy="微信注册登录",
                    CreateTime = DateTime.UtcNow,
                };
                await UserRes.EzInsertAsync(user);
              user=    await UserRes.InsertReturnEntityAsync(user);
                }
                else
                {
                    user.WxOpenId = opeid;
                    await UserRes.EzUpdateAsync(user);
                }
            }
            var jwt = new EzJwtModel()
            {
                ITCode = user.ItCode,
               // ITCode = user.ItCode,
                NickName = user.Nickname,
                UserID = user.Id,
@@ -121,9 +134,7 @@
        }
    }
    /// <summary>