From 48dd3de120b70d50c74df4075cdda0a59e176b4d Mon Sep 17 00:00:00 2001 From: wtp <1813748440@qq.com> Date: Thu, 14 Dec 2023 16:45:40 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E7=8C=8E=E5=A4=B4=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E7=94=A8=E6=88=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- GDZZ.Application/Entity/BaseUser.cs | 8 +- GDZZ.Application/Enum/UserEnum.cs | 6 +- GDZZ.Application/GDZZ.Application.xml | 10 +- GDZZ.Application/Service/Auth/AuthService.cs | 135 +++++++++---------- 4 files changed, 77 insertions(+), 82 deletions(-) diff --git a/GDZZ.Application/Entity/BaseUser.cs b/GDZZ.Application/Entity/BaseUser.cs index bd01271..6138115 100644 --- a/GDZZ.Application/Entity/BaseUser.cs +++ b/GDZZ.Application/Entity/BaseUser.cs @@ -7,14 +7,10 @@ namespace GDZZ.Application.Entity /// /// 微信端基础用户 /// - [SugarTable("baseuser")] + [SugarTable("mini_baseuser")] [Description("微信端基础用户")] public class BaseUser : DEntityBase { - /// - /// 租户Id - /// - public long TenantId { get; set; } /// /// 用户类型 /// @@ -46,7 +42,7 @@ namespace GDZZ.Application.Entity /// /// 公司ID /// - public long? CompanyID { get; set; } + public long CompanyID { get; set; } /// /// 描述 /// diff --git a/GDZZ.Application/Enum/UserEnum.cs b/GDZZ.Application/Enum/UserEnum.cs index 3a522c2..ed8fa39 100644 --- a/GDZZ.Application/Enum/UserEnum.cs +++ b/GDZZ.Application/Enum/UserEnum.cs @@ -24,6 +24,10 @@ namespace GDZZ.Application [Description("招聘者")] ADVERTISE = 2, - + /// + /// 猎头 + /// + [Description("猎头")] + HEADHUNTERS = 3 } } diff --git a/GDZZ.Application/GDZZ.Application.xml b/GDZZ.Application/GDZZ.Application.xml index eaac283..1892311 100644 --- a/GDZZ.Application/GDZZ.Application.xml +++ b/GDZZ.Application/GDZZ.Application.xml @@ -44,11 +44,6 @@ 微信端基础用户 - - - 租户Id - - 用户类型 @@ -959,6 +954,11 @@ 招聘者 + + + 猎头 + + 系统缓存服务 diff --git a/GDZZ.Application/Service/Auth/AuthService.cs b/GDZZ.Application/Service/Auth/AuthService.cs index 8591648..8cde910 100644 --- a/GDZZ.Application/Service/Auth/AuthService.cs +++ b/GDZZ.Application/Service/Auth/AuthService.cs @@ -23,6 +23,7 @@ using TencentCloud.Common; using Polly; using System.IO; using System.Diagnostics.Eventing.Reader; +using System.Diagnostics; namespace GDZZ.Application.Service.Auth { @@ -109,6 +110,7 @@ namespace GDZZ.Application.Service.Auth //解析电话 var phoneInfo = MiniProgramUtil.AESDecrypt(phoneModel.EncryptedDataStr, tokenModel.SessionKey, phoneModel.Iv); + //查询系统用户 var sysUser = this._sysUserRep.AsQueryable() .Filter("TenantId", true) @@ -144,48 +146,44 @@ namespace GDZZ.Application.Service.Auth Tel = null, }); } - - //区分不同类型账号 - if (phoneModel.LogInType ==(int)UserEnum.JOB) + + if (wxUser.IsEmpty()) { - if (wxUser.IsEmpty()) - { - wxUser = await this.Baseuser.InsertReturnEntityAsync(new BaseUser() - { - UnionId = tokenModel.Unionid, - CreatedUserId = sysUser.Id, - CreatedTime = DateTime.Now, - CreatedUserName = sysUser.Name, - AvatarUrl = "https://gdzongzhi.com/assets/img/logo.png", - Status =(int)CommonStatus.ENABLE, - OpenID = tokenModel.OpenId, - TenantId = 392820661919813, - Type = (int)UserEnum.JOB, - UserName = phoneInfo.PhoneNumber, - }); - } - else + wxUser = await this.Baseuser.InsertReturnEntityAsync(new BaseUser() { - wxUser.Type = (int)UserEnum.JOB; - var bsUser = await this.Baseuser.UpdateAsync(wxUser); - } + UnionId = tokenModel.Unionid, + CreatedUserId = sysUser.Id, + CreatedTime = DateTime.Now, + CreatedUserName = sysUser.Name, + AvatarUrl = "https://gdzongzhi.com/assets/img/logo.png", + Status = (int)CommonStatus.ENABLE, + OpenID = tokenModel.OpenId, + UserName = phoneModel.Phone.ToString(), + }); } - else + //区分账号类型 + switch (phoneModel.LogInType) { - //如果是企业账号,应该是绑定了企业租户信息 - wxUser.Type = (int)UserEnum.ADVERTISE; - var bsUser = await this.Baseuser.UpdateAsync(wxUser); - - //企业用户情况下,允许后续补充公司信息 - //if (wxUser.IsEmpty()|| wxUser.CompanyID.IsNullOrZero()) - // throw Oops.Oh(ErrorCode.xg1002); - - ////获取公司信息 - //company = await this.CompanyRep.SingleAsync(x=>x.Id == wxUser.CompanyID); - //authUserOut.companyDto = company.Adapt(); + case (int)UserEnum.JOB: + wxUser.Type = (int)UserEnum.JOB; + await this.Baseuser.UpdateAsync(wxUser); + break; + case (int)UserEnum.HEADHUNTERS: + wxUser.Type = (int)UserEnum.HEADHUNTERS; + await this.Baseuser.UpdateAsync(wxUser); + break; + case (int)UserEnum.ADVERTISE: + wxUser.Type = (int)UserEnum.ADVERTISE; + await this.Baseuser.UpdateAsync(wxUser); + //获取公司信息 + company = await this.CompanyRep.FirstOrDefaultAsync(x => x.Id == wxUser.CompanyID); + authUserOut.companyDto = company.Adapt(); + break; + default: + break; + } - } if (wxUser.IsEmpty() || sysUser.IsEmpty()) throw Oops.Oh(ErrorCode.xg1002); //判断是否存在邀请 @@ -325,47 +323,44 @@ namespace GDZZ.Application.Service.Auth .Filter("TenantId", true) .Where(x => x.OpenID == tokenModel.OpenId).SingleAsync(); - - //区分不同类型账号 - if (phoneModel.LogInType == (int)UserEnum.JOB) + if (wxUser.IsEmpty()) { - if (wxUser.IsEmpty()) + wxUser = await this.Baseuser.InsertReturnEntityAsync(new BaseUser() { - wxUser = await this.Baseuser.InsertReturnEntityAsync(new BaseUser() - { - UnionId = tokenModel.Unionid, - CreatedUserId = sysUser.Id, - CreatedTime = DateTime.Now, - CreatedUserName = sysUser.Name, - AvatarUrl = "https://gdzongzhi.com/assets/img/logo.png", - Status = (int)CommonStatus.ENABLE, - OpenID = tokenModel.OpenId, - TenantId = 392820661919813, - Type = (int)UserEnum.JOB, - UserName = phoneModel.Phone.ToString(), - }); - } - else - { - wxUser.Type = (int)UserEnum.JOB; - var bsUser = await this.Baseuser.UpdateAsync(wxUser); - } + UnionId = tokenModel.Unionid, + CreatedUserId = sysUser.Id, + CreatedTime = DateTime.Now, + CreatedUserName = sysUser.Name, + AvatarUrl = "https://gdzongzhi.com/assets/img/logo.png", + Status = (int)CommonStatus.ENABLE, + OpenID = tokenModel.OpenId, + UserName = phoneModel.Phone.ToString(), + }); } - else + //区分账号类型 + switch (phoneModel.LogInType) { - //如果是企业账号,应该是绑定了企业租户信息 - if (wxUser.IsEmpty() || wxUser.CompanyID.IsNullOrZero()) - throw Oops.Oh(ErrorCode.xg1002); - - wxUser.Type = (int)UserEnum.ADVERTISE; - var bsUser = await this.Baseuser.UpdateAsync(wxUser); + case (int)UserEnum.JOB : + wxUser.Type = (int)UserEnum.JOB; + await this.Baseuser.UpdateAsync(wxUser); + break; + case (int)UserEnum.HEADHUNTERS: + wxUser.Type = (int)UserEnum.HEADHUNTERS; + await this.Baseuser.UpdateAsync(wxUser); + break; + case (int)UserEnum.ADVERTISE: + wxUser.Type = (int)UserEnum.ADVERTISE; + await this.Baseuser.UpdateAsync(wxUser); + //获取公司信息 + company = await this.CompanyRep.FirstOrDefaultAsync(x => x.Id == wxUser.CompanyID); + authUserOut.companyDto = company.Adapt(); + break; + default: + break; + } - //获取公司信息 - company = await this.CompanyRep.SingleAsync(x => x.Id == wxUser.CompanyID); - authUserOut.companyDto = company.Adapt(); - } if (wxUser.IsEmpty() || sysUser.IsEmpty()) throw Oops.Oh(ErrorCode.xg1002);