From 0c9a162284878860b78eff1fdad6a4a5337624af Mon Sep 17 00:00:00 2001
From: 移动系统liao <liaoxujun@qq.com>
Date: 星期四, 21 八月 2025 13:17:37 +0800
Subject: [PATCH] 修正用户API相关参数
---
Admin.NET/FZCTB.NET.API.Application/Auth/DTO/CustomerLoginOutput.cs | 4
Admin.NET/FZCTB.NET.API.Application/Auth/AuthService.cs | 238 ++++++++++++++++++++--------------------------
Admin.NET/FZCTB.NET.API.Application/User/CustomerService.cs | 52 +++++++++-
Admin.NET/FZCZTB.TSCL.Application/Service/ProcurementComplaint/ProcurementComplaintService.cs | 3
4 files changed, 158 insertions(+), 139 deletions(-)
diff --git a/Admin.NET/FZCTB.NET.API.Application/Auth/AuthService.cs b/Admin.NET/FZCTB.NET.API.Application/Auth/AuthService.cs
index b651365..252f050 100644
--- a/Admin.NET/FZCTB.NET.API.Application/Auth/AuthService.cs
+++ b/Admin.NET/FZCTB.NET.API.Application/Auth/AuthService.cs
@@ -1,31 +1,23 @@
-锘縰sing Admin.NET.Core.Service;
-using Admin.NET.Core;
+锘縰sing Admin.NET.Core;
+using Admin.NET.Core.Service;
+using cylsg.utility.Extend;
+using Furion;
using Furion.DataEncryption;
using Furion.DynamicApiController;
using Furion.EventBus;
-using Microsoft.AspNetCore.Mvc;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using Lazy.Captcha.Core;
-using Microsoft.AspNetCore.Http;
-using FZCZTB.NET.MD.CutomerMd;
-using Microsoft.AspNetCore.Authorization;
-using System.ComponentModel.DataAnnotations;
-using System.ComponentModel;
-using FZCZTB.NET.SYSService.MSM;
-using FZCTB.NET.API.Application.Auth.DTO;
using Furion.FriendlyException;
-using FZCZTB.NET.SYSService.CustomerSYS;
-using Furion;
-using NewLife;
-using cylsg.utility.Extend;
-using static QRCoder.PayloadGenerator;
+using FZCTB.NET.API.Application.Auth.DTO;
+using FZCZTB.NET.MD.CutomerMd;
using FZCZTB.NET.MD.CutomerMd.Extend;
-using Furion.DependencyInjection;
+using FZCZTB.NET.SYSService.MSM;
+using Lazy.Captcha.Core;
+using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options;
+using NewLife;
+using System.ComponentModel;
+using System.ComponentModel.DataAnnotations;
namespace FZCTB.NET.API.Application.Auth
{
@@ -33,25 +25,22 @@
/// 閴存潈鏈嶅姟
/// </summary>
[ApiDescriptionSettings("FZCAPISYS", Order = 149)]
- public class AuthService: IDynamicApiController
+ public class AuthService : IDynamicApiController
{
-
-
- private readonly SMSConfigOptions _smsOptions;
- private readonly SqlSugarRepository<FBS_CustormerUsers> _sysUserRep;
- private readonly SqlSugarRepository<FBS_CoutomerExRole> _sysUserExRol;
- private readonly SqlSugarRepository<FBS_ExRole> _sysExRol;
- private readonly IHttpContextAccessor _httpContextAccessor;
- private readonly SysMenuService _sysMenuService;
- private readonly SysOnlineUserService _sysOnlineUserService;
- private readonly SysConfigService _sysConfigService;
- private readonly SysUserService _sysUserService;
- private readonly ZCSMSService _sysSmsService;
- private readonly SysLdapService _sysLdapService;
private readonly ICaptcha _captcha;
private readonly IEventPublisher _eventPublisher;
+ private readonly IHttpContextAccessor _httpContextAccessor;
+ private readonly SMSConfigOptions _smsOptions;
private readonly SysCacheService _sysCacheService;
-
+ private readonly SysConfigService _sysConfigService;
+ private readonly SqlSugarRepository<FBS_ExRole> _sysExRol;
+ private readonly SysLdapService _sysLdapService;
+ private readonly SysMenuService _sysMenuService;
+ private readonly SysOnlineUserService _sysOnlineUserService;
+ private readonly ZCSMSService _sysSmsService;
+ private readonly SqlSugarRepository<FBS_CoutomerExRole> _sysUserExRol;
+ private readonly SqlSugarRepository<FBS_CustormerUsers> _sysUserRep;
+ private readonly SysUserService _sysUserService;
public AuthService(
SqlSugarRepository<FBS_CustormerUsers> sysUserRep,
SqlSugarRepository<FBS_CoutomerExRole> sysUserExRol,
@@ -66,14 +55,14 @@
SysUserService sysUserService,
IOptions<SMSConfigOptions> smsConfigOptions,
SqlSugarRepository<FBS_ExRole> exrel,
-
+
ICaptcha captcha
-
+
)
{
_captcha = captcha;
_sysUserRep = sysUserRep;
-
+
_sysSmsService = sysSmsService;
_eventPublisher = eventPublisher;
_sysUserService = sysUserService;
@@ -89,78 +78,6 @@
}
/// <summary>
- /// 鎵嬫満鍙风櫥褰� 馃敄
- /// </summary>
- /// <param name="input"></param>
- /// <returns></returns>
- [AllowAnonymous]
- [DisplayName("鎵嬫満鍙风櫥褰�")]
- public virtual async Task<CustomerLoginOutput> LoginPhone([Required] CustomerLoginPhoneInput input)
- {
- if(input.Id>0)
- {
- //鏈�鍚庝竴娆$‘璁ょ櫥闄嗙姸鎬�
- var verifyCode = _sysCacheService.Get<string>($"{CacheConst.KeyPhoneVerCode}{input.Phone}");
- if (string.IsNullOrWhiteSpace(verifyCode)) throw Oops.Oh("楠岃瘉鐮佷笉瀛樺湪鎴栧凡澶辨晥锛岃閲嶆柊鑾峰彇锛�");
-
- _sysCacheService.Remove($"{CacheConst.KeyPhoneVerCode}{input.Phone}");
- if (verifyCode != input.Code)
- throw Oops.Oh("鐧诲綍鐮佸け鏁�");
- var user = await _sysUserRep.AsQueryable().Where(x => x.Id == input.Id && x.IsEn == true).FirstAsync();
- if(user == null)
- throw Oops.Oh("娌℃湁鎵惧埌璇ユ墜鏈虹敤鎴�");
- return await CreateToken(user, input.ExRuleCode ?? "");
- }
- if(input.Code!="TEST")
- // 鏍¢獙鐭俊楠岃瘉鐮�
- _sysSmsService.VerifyCode(new SmsVerifyCodeInput { Phone = input.Phone, Code = input.Code });
-
- // 鑾峰彇鐧诲綍绉熸埛鍜岀敤鎴�
- // 鑾峰彇鐧诲綍绉熸埛鍜岀敤鎴�
- var userList = await _sysUserRep.AsQueryable().Where(x => x.PhoneNumber == input.Phone&&x.IsEn==true).Includes(x=>x.CusExtend).ToListAsync();
- if (userList == null)
- {
- throw Oops.Oh("娌℃湁鎵惧埌璇ユ墜鏈虹敤鎴�");
- }
- if(userList.Count>1)
- {
- // 鐢熸垚闅忔満楠岃瘉鐮�
- var random = new Random();
- var verifyCode = random.Next(100000, 999999);
- //闇�瑕佷簩娆$櫥闄�
- var aRet = new CustomerLoginOutput
- {
- TheLastLogo = false,
- CustomerExs = new List<CustomerExVm>(),
- Code = verifyCode.ToString(),
-
-
-
- };
- _sysCacheService.Set($"{CacheConst.KeyPhoneVerCode}{input.Phone}", verifyCode.ToString(), TimeSpan.FromSeconds(_smsOptions.lingKai.VerifyTimeOut.ToInt()));
- foreach (var item in userList)
- {
- aRet.CustomerExs.Add(new CustomerExVm
- {
- CustomerUserID = item.Id,
- EnterpriseName = item.CusExtend.EnterpriseName,
- UnifiedSocialCreditCode = item.CusExtend.UnifiedSocialCreditCode.MaskMiddle(),
- IsManger = item.IsManager
-
-
- });
- }
- return aRet;
-
- }
-
-
-
-
- return await CreateToken(userList[0], input.ExRuleCode??"");
- }
-
- /// <summary>
/// 鍒囨崲瑙掕壊 宸茬櫥褰曡繘鍘昏鑹叉垨鑰呭垏鎹㈣鑹叉槸璋冪敤锛岄渶瑕佹浛鎹oken,鐩稿綋浜庣櫥褰�
/// </summary>
[DisplayName("鍒囨崲瑙掕壊")]
@@ -170,10 +87,9 @@
if (id == 0)
{
throw Oops.Oh("鐢ㄦ埛鍑瘉閿欒");
-
}
var rols = await _sysExRol.GetFirstAsync(x => x.Code == RuleCode && x.Status == StatusEnum.Enable);
- if(rols==null)
+ if (rols == null)
throw Oops.Oh("瑙掕壊宸茬粡涓嬬嚎");
// 鑾峰彇鐧诲綍绉熸埛鍜岀敤鎴�
@@ -187,14 +103,79 @@
{
throw Oops.Oh("鐢ㄥ紓甯�");
}
- var exr= await _sysUserExRol.GetFirstAsync(x=>x.CusExtendId==user.CusExtendId&&x.ExRoleId== rols.Id);
- if (exr==null)
+ var exr = await _sysUserExRol.GetFirstAsync(x => x.CusExtendId == user.CusExtendId && x.ExRoleId == rols.Id);
+ if (exr == null)
throw Oops.Oh("娌℃湁鐢宠璇ヨ鑹�");
return await CreateToken(user, RuleCode);
-
}
+ /// <summary>
+ /// 鎵嬫満鍙风櫥褰� 馃敄
+ /// </summary>
+ /// <param name="input"></param>
+ /// <returns></returns>
+ [AllowAnonymous]
+ [DisplayName("鎵嬫満鍙风櫥褰�")]
+ public virtual async Task<CustomerLoginOutput> LoginPhone([Required] CustomerLoginPhoneInput input)
+ {
+ if (input.Id > 0)
+ {
+ //鏈�鍚庝竴娆$‘璁ょ櫥闄嗙姸鎬�
+ var verifyCode = _sysCacheService.Get<string>($"{CacheConst.KeyPhoneVerCode}{input.Phone}");
+ if (string.IsNullOrWhiteSpace(verifyCode)) throw Oops.Oh("楠岃瘉鐮佷笉瀛樺湪鎴栧凡澶辨晥锛岃閲嶆柊鑾峰彇锛�");
+
+ _sysCacheService.Remove($"{CacheConst.KeyPhoneVerCode}{input.Phone}");
+ if (verifyCode != input.Code)
+ throw Oops.Oh("鐧诲綍鐮佸け鏁�");
+ var user = await _sysUserRep.AsQueryable().Where(x => x.Id == input.Id && x.IsEn == true).FirstAsync();
+ if (user == null)
+ throw Oops.Oh("娌℃湁鎵惧埌璇ユ墜鏈虹敤鎴�");
+ return await CreateToken(user, input.ExRuleCode ?? "");
+ }
+ if (input.Code != "TEST")
+ // 鏍¢獙鐭俊楠岃瘉鐮�
+ _sysSmsService.VerifyCode(new SmsVerifyCodeInput { Phone = input.Phone, Code = input.Code });
+
+ // 鑾峰彇鐧诲綍绉熸埛鍜岀敤鎴�
+ // 鑾峰彇鐧诲綍绉熸埛鍜岀敤鎴�
+ var userList = await _sysUserRep.AsQueryable().Where(x => x.PhoneNumber == input.Phone && x.IsEn == true).Includes(x => x.CusExtend).ToListAsync();
+ if (userList == null)
+ {
+ throw Oops.Oh("娌℃湁鎵惧埌璇ユ墜鏈虹敤鎴�");
+ }
+ if (userList.Count > 1)
+ {
+ // 鐢熸垚闅忔満楠岃瘉鐮�
+ var random = new Random();
+ var verifyCode = random.Next(100000, 999999);
+ //闇�瑕佷簩娆$櫥闄�
+ var aRet = new CustomerLoginOutput
+ {
+ TheLastLogo = false,
+ CustomerExs = new List<CustomerExVm>(),
+ Code = verifyCode.ToString(),
+ };
+ _sysCacheService.Set($"{CacheConst.KeyPhoneVerCode}{input.Phone}", verifyCode.ToString(), TimeSpan.FromSeconds(_smsOptions.lingKai.VerifyTimeOut.ToInt()));
+ foreach (var item in userList)
+ {
+ aRet.CustomerExs.Add(new CustomerExVm
+ {
+ CustomerUserID = item.Id,
+ EnterpriseName = item.CusExtend.EnterpriseName,
+ UnifiedSocialCreditCode = item.CusExtend.UnifiedSocialCreditCode.MaskMiddle(),
+ IsManger = item.IsManager
+
+
+
+
+ });
+ }
+ return aRet;
+ }
+
+ return await CreateToken(userList[0], input.ExRuleCode ?? "");
+ }
/// <summary>
/// 鎵嬫満鍙风櫥褰� 馃敄
/// </summary>
@@ -212,7 +193,6 @@
//var user = await _sysUserRep.AsQueryable().Where(x=>x.Account==input.Phone).Includes(x => x.CoutomerExRols, y => y.ExRole).FirstAsync();
//if(user==null)
//{
-
//}
//return await CreateToken(user, input.ExRuleCode );
@@ -225,7 +205,7 @@
/// <param name="sysUserEventTypeEnum"></param>\
/// <returns></returns>
[NonAction]
- internal async Task<CustomerLoginOutput> CreateToken(FBS_CustormerUsers user,string ExRuleCode, SysUserEventTypeEnum sysUserEventTypeEnum = SysUserEventTypeEnum.Login)
+ internal async Task<CustomerLoginOutput> CreateToken(FBS_CustormerUsers user, string ExRuleCode, SysUserEventTypeEnum sysUserEventTypeEnum = SysUserEventTypeEnum.Login)
{
// 鍗曠敤鎴风櫥褰�
await _sysOnlineUserService.SingleLogin(user.Id);
@@ -237,8 +217,8 @@
{ ClaimConst.UserId, user.Id },
{ ClaimConst.TenantId, user.CusExtendId },
{ ClaimConst.Account, user.PhoneNumber.PrivacyStr() },
- { ClaimConst.RealName, user.Nickname??user.Name },
-
+ { ClaimConst.RealName, user.Nickname??user.Name },
+
{ ClaimConst.UserType, "Customer" },
{ ClaimConst.CustomerExId, user.CusExtendId },
{ ClaimConst.CustomerLogoinType, ExRuleCode },
@@ -274,20 +254,11 @@
{
AccessToken = accessToken,
RefreshToken = refreshToken,
- TheLastLogo=true,
-
-
-
-
-
-
-
+ TheLastLogo = true,
+ IsManager = user.IsManager
}
-
-
};
payload.Output.ExRoles = new List<CustomerExRoleVm>();
-
payload.Output.ExRoles = await _sysUserExRol.AsQueryable().Where(x => x.CusExtendId == user.CusExtendId).Includes(x => x.ExRole).Select(x => new CustomerExRoleVm
{
@@ -296,11 +267,10 @@
Name = x.ExRole.Name
}).ToListAsync();
-
//鏆傛椂涓嶅嚭鐢ㄦ埛浜嬩欢
// 鍙戝竷绯荤粺鐢ㄦ埛鎿嶄綔浜嬩欢
//await _eventPublisher.PublishAsync(sysUserEventTypeEnum, payload);
return payload.Output;
}
}
-}
+}
\ No newline at end of file
diff --git a/Admin.NET/FZCTB.NET.API.Application/Auth/DTO/CustomerLoginOutput.cs b/Admin.NET/FZCTB.NET.API.Application/Auth/DTO/CustomerLoginOutput.cs
index e120cf2..70f1c78 100644
--- a/Admin.NET/FZCTB.NET.API.Application/Auth/DTO/CustomerLoginOutput.cs
+++ b/Admin.NET/FZCTB.NET.API.Application/Auth/DTO/CustomerLoginOutput.cs
@@ -44,6 +44,10 @@
/// 涓存椂楠岃瘉鐮�
/// </summary>
public string? Code { get; set; }
+ /// <summary>
+ /// 鏄惁鏄鐞嗗憳
+ /// </summary>
+ public bool IsManager { get; set; }
}
/// <summary>
diff --git a/Admin.NET/FZCTB.NET.API.Application/User/CustomerService.cs b/Admin.NET/FZCTB.NET.API.Application/User/CustomerService.cs
index d641f88..1dfb61f 100644
--- a/Admin.NET/FZCTB.NET.API.Application/User/CustomerService.cs
+++ b/Admin.NET/FZCTB.NET.API.Application/User/CustomerService.cs
@@ -448,7 +448,7 @@
}
if (!await isManger())
throw Oops.Oh("鐢ㄦ埛娌℃湁鏉冮檺");
- return (await _fBS_CustormerUsersRep.GetListAsync(x => x.CusExtendId == id&&x.IsEn==true)).Adapt<List<FBS_CustormerUsersOutput>>();
+ return (await _fBS_CustormerUsersRep.GetListAsync(x => x.CusExtendId == id)).Adapt<List<FBS_CustormerUsersOutput>>();
}
public FBS_CustormerUsers? ThisUser { get; set; }
/// <summary>
@@ -521,14 +521,14 @@
}
var User = await _fBS_CustormerUsersRep.GetFirstAsync(x =>x.CusExtendId==ThisUser.CusExtendId &&x.Id== CustormerUserId);
- if (User != null)
+ if (User == null)
{
throw Oops.Oh("鐢ㄦ埛涓嶅瓨鍦�");
}
if(User.IsEn==false)
throw Oops.Oh("鏃犳晥鐢ㄦ埛涓嶅彲璁剧疆涓虹鐞嗗憳");
- User.IsManager = true;
+ User.IsManager = !User.IsManager;
User.UpdateTime = DateTime.Now;
User.UpdateUserName= "浼佷笟鐢ㄦ埛:" + ThisUser?.Name;
User.UpdateUserId = ThisUser.Id;
@@ -581,13 +581,13 @@
{
throw Oops.Oh("Id閿欒");
}
- if(Param.CusExtendId!=Param.Id)
+ if(Param.CusExtendId!= cid)
{
throw Oops.Oh("缁勭粐鏈烘瀯涓嶅悓涓嶅彲淇敼");
}
var User = await _fBS_CustormerUsersRep.GetFirstAsync(x => x.CusExtendId == Param.CusExtendId && x.Id == Param.Id);
- if (User != null)
+ if (User == null)
{
throw Oops.Oh("鐢ㄦ埛涓嶅瓨鍦�");
}
@@ -602,6 +602,48 @@
}
+
+ /// <summary>
+ /// 鍒犻櫎鍛樺伐
+ /// </summary>
+ /// <param name="CustormerUserId"> UserList 鐨処D</param>
+ /// <returns></returns>
+ [HttpDelete]
+ public async Task<bool> DelCustormerUsers(long CustormerUserId)
+ {
+ if (!await isManger())
+ throw Oops.Oh("鐢ㄦ埛娌℃湁鏉冮檺");
+ var cid = App.User.FindFirst(ClaimConst.CustomerExId)?.Value.ToLong() ?? 0;
+ if (cid == 0)
+ {
+ throw Oops.Oh("鐢ㄦ埛鍑瘉閿欒");
+
+ }
+ var uid = App.User.FindFirst(ClaimConst.UserId)?.Value.ToLong() ?? 0;
+ if (uid == 0)
+ {
+
+
+ }
+ if (CustormerUserId == uid)
+ throw Oops.Oh("鑷繁涓嶅彲鍒犻櫎鑷繁");
+ if (ThisUser == null)
+ {
+
+ ThisUser = await _fBS_CustormerUsersRep.GetFirstAsync(x => x.Id == uid && x.CusExtendId == cid && x.IsEn == true);
+
+ }
+ var User = await _fBS_CustormerUsersRep.GetFirstAsync(x => x.CusExtendId == ThisUser.CusExtendId && x.Id == CustormerUserId);
+ if (User == null)
+ {
+ throw Oops.Oh("鐢ㄦ埛涓嶅瓨鍦�");
+ }
+ return await _fBS_CustormerUsersRep.DeleteByIdAsync(CustormerUserId);
+
+
+
+ }
+
/// <summary>
/// 鏉冮檺楠岃瘉鏄惁鏄鐞嗗憳
/// </summary>
diff --git a/Admin.NET/FZCZTB.TSCL.Application/Service/ProcurementComplaint/ProcurementComplaintService.cs b/Admin.NET/FZCZTB.TSCL.Application/Service/ProcurementComplaint/ProcurementComplaintService.cs
index 4d107d0..8d2a0f8 100644
--- a/Admin.NET/FZCZTB.TSCL.Application/Service/ProcurementComplaint/ProcurementComplaintService.cs
+++ b/Admin.NET/FZCZTB.TSCL.Application/Service/ProcurementComplaint/ProcurementComplaintService.cs
@@ -64,6 +64,7 @@
.WhereIF(input.Status != null && input.Status == PComplaintStatus.Valid, u =>( u.Complaints.Any(uu => uu.HandlingStatus == PComplaintStatus.Valid)))
.WhereIF(input.Status != null && input.Status == PComplaintStatus.Rejected, u => ( !u.Complaints.Any(uu=>uu.HandlingStatus== PComplaintStatus.Other||uu.HandlingStatus== PComplaintStatus.Valid||uu.HandlingStatus==null)))
.WhereIF(input.Status != null && input.Status == PComplaintStatus.Other, u =>!( u.Complaints.Any(uu=>uu.HandlingStatus== PComplaintStatus.Valid)|| (!u.Complaints.Any(uu => uu.HandlingStatus == PComplaintStatus.Other || uu.HandlingStatus == PComplaintStatus.Valid || uu.HandlingStatus == null))))
+
.Select(n => new ProcurementComplaintOutput
{
Complaints = n.Complaints
@@ -92,6 +93,8 @@
return await _procurementComplaintRep.AsQueryable().Where(x=>x.Id==input.Id).Includes(x=>x.Complaints.OrderBy(xx=>xx.sort).ToList()).FirstAsync();
}
+
+
/// <summary>
/// 澧炲姞鏀垮簻閲囪喘鎶曡瘔鏁版嵁澶勭悊 鉃�
/// </summary>
--
Gitblit v1.9.1