Commit 0660d84b authored by youjie's avatar youjie

优化

parent 279a70f5
import OtaRequest,{ type HttpResponse} from '@/api/OtaRequest'
import OtaRequest, { type HttpResponse } from '@/api/OtaRequest'
/**
* 用户服务 - 处理所有用户相关的 API 请求
......@@ -57,39 +57,39 @@ export interface DistributorLoginDto {
*/
export interface DistributorSelfRegisterDto {
/*** 出生日期*/
birthday?: Date | null | string;
birthday?: Date | null | string
/*** 确认密码*/
confirmPassword: string;
confirmPassword: string
/*** 分销商推广码*/
distributorCode?: null | string;
distributorCode?: null | string
/*** 分销商ID*/
distributorId?: number;
distributorId?: number
/*** 电子邮箱(需要判断唯一,作为登录账号)*/
email: string;
email: string
/*** 勾選「我願意接收優惠與電子報」 1是*/
isReceivePush?: number;
isReceivePush?: number
/*** LINE ID*/
lineId?: null | string;
lineId?: null | string
/*** 会员昵称*/
name?: null | string;
name?: null | string
/*** 父级会员ID*/
parentId?: null | string;
parentId?: null | string
/*** 密码*/
password: string;
password: string
/*** 电话*/
phone?: null | string;
phone?: null | string
/*** 居住地區*/
residentialArea?: null | string;
residentialArea?: null | string
/*** 注册类型 0邮箱验证码 1谷歌授权 3LINE授权 7FaceBook授权*/
reType?: number;
reType?: number
/*** 性别 1男 2女*/
sex?: number;
sex?: number
/*** 临时令牌token*/
temporaryToken?: null | string;
temporaryToken?: null | string
/*** 租户ID(手动传入,用于多租户隔离)*/
tenantId: string;
tenantId: string
/*** 微信ID*/
wechatId?: null | string;
wechatId?: null | string
}
/**
......@@ -97,11 +97,11 @@ export interface DistributorSelfRegisterDto {
*/
export interface MemberUpdateEmailDto {
/** 临时令牌token(可选) */
temporaryToken?: string | null;
temporaryToken?: string | null
/** 电子邮箱(必填,最小长度1,格式email,需判断唯一性作为登录账号) */
email: string;
email: string
/** 第一次绑定邮箱时需输入密码(修改邮箱不需要,可选) */
newPassword?: string | null;
newPassword?: string | null
}
// ==================== 响应 DTO ====================
......@@ -137,21 +137,21 @@ export interface DistributorLevelDto {
*/
export interface DistributorLoginResultDto {
/*** 域名*/
domain?: null | string;
domain?: null | string
/*** 令牌过期时间*/
expireTime?: Date;
expireTime?: Date
/*** 会员基础信息*/
memberData?: null;
memberData?: null
/*** 🆕 权限列表*/
permissions?: string[] | null;
permissions?: string[] | null
/*** 🆕 刷新令牌*/
refreshToken?: null | string;
refreshToken?: null | string
/*** 租户ID(ABP 多租户)*/
tenantId?: null | string;
tenantId?: null | string
/*** JWT访问令牌*/
token?: null | string;
token?: null | string
/*** 🆕 用户基础信息*/
userInfo?: null;
userInfo?: null
}
/**
......@@ -240,10 +240,6 @@ export interface ResetPasswordDto {
newPassword: string
}
/**
* 重置密码响应
*/
......@@ -265,69 +261,68 @@ export interface GeneralResponseDto {
}
/**
* 微信AppID响应
*/
* 微信AppID响应
*/
export interface WechatAppIdResponseDto {
appId?: string,
redirectUri?: string,
appId?: string
redirectUri?: string
}
/**
* 修改密码请求参数
*/
* 修改密码请求参数
*/
export interface NewPasswordDto {
/** 旧密码 */
oldPassword: string,
oldPassword: string
/** 新密码 */
newPassword: string,
newPassword: string
}
/**
* 修改密码响应
*/
* 修改密码响应
*/
export interface NewPasswordResponseDto {
code?: number,
code?: number
}
// 外部登录信息DTO(对应接口 ExternalLoginInfoDto)
export interface ExternalLoginInfoDto {
/** 主键ID(UUID格式) */
id: string;
id: string
/** 登录提供商(如Google/WeChat,可选) */
provider?: string | null;
provider?: string | null
/** 提供商显示名称(可选) */
providerDisplayName?: string | null;
providerDisplayName?: string | null
/** 创建时间(date-time格式) */
creationTime: string;
creationTime: string
}
/**
* 个人中心信息响应
*/
* 个人中心信息响应
*/
export interface PersonalCenterResponseDto {
/** 会员昵称(最大长度200,可选) */
name?: string | null;
/** 会员昵称(最大长度200,可选) */
name?: string | null
/** 会员等级(UUID格式,可选) */
memberGrade?: string | null;
memberGrade?: string | null
/** 会员等级名称(可选) */
memberGradeName?: string | null;
memberGradeName?: string | null
/** 会员等级图标(可选) */
memberGradeIcon?: string | null;
memberGradeIcon?: string | null
/** 头像(最大长度500,可选) */
photo?: string | null;
photo?: string | null
/** 邮箱(最大长度100,可选) */
email?: string | null;
email?: string | null
/** 分销佣金(double格式) */
balance: number;
balance: number
/** 积分(double格式) */
integral: number;
integral: number
/** 资料是否完整(1=完整,int32格式) */
isComplete: number;
isComplete: number
/** 快捷登录列表(外部登录信息数组,可选) */
externalLoginList?: ExternalLoginInfoDto[] | null;
externalLoginList?: ExternalLoginInfoDto[] | null
/** 密码安全等级(1低/2中/3高,int32格式) */
passwordSecurity: number;
passwordSecurity: number
}
/**
......@@ -342,47 +337,47 @@ export interface MemberUpdateEmailResponseDto {
export interface MemberUserOutputDto {
/** 主键ID(UUID格式) */
id: string;
id: string
/** 归属分销商ID */
distributorId: number;
distributorId: number
/** 归属分销商名称 */
distributorName?: string | null;
distributorName?: string | null
/** 名(最大长度200) */
name?: string | null;
name?: string | null
/** 姓(最大长度200) */
surName?: string | null;
surName?: string | null
/** 父级ID(UUID格式) */
parentId?: string | null;
parentId?: string | null
/** 上级会员 */
parentName?: string | null;
parentName?: string | null
/** 会员等级(UUID格式) */
memberGrade?: string | null;
memberGrade?: string | null
/** 会员等级名称 */
memberGradeName?: string | null;
memberGradeName?: string | null
/** 头像(最大长度500) */
photo?: string | null;
photo?: string | null
/** 性别(1男 2女) */
sex: number;
sex: number
/** 出生日期(date-time格式) */
birthday?: string | null;
birthday?: string | null
/** 邮箱(最大长度100) */
email?: string | null;
email?: string | null
/** LINE ID */
lineId?: string | null;
lineId?: string | null
/** 微信ID */
wechatId?: string | null;
wechatId?: string | null
/** 电话区号(最大长度10) */
phoneCode?: string | null;
phoneCode?: string | null
/** 电话(最大长度50) */
phone?: string | null;
phone?: string | null
/** 居住地區 */
residentialArea?: string | null;
residentialArea?: string | null
/** 是否接收推送(1是) */
isReceivePush: number;
isReceivePush: number
/** 是否黑名单(1是) */
isBlacklist: number;
isBlacklist: number
/** 创建时间(date-time格式) */
creationTime: string;
creationTime: string
}
/**
......@@ -392,69 +387,69 @@ export interface MemberUserOutputDto {
// 分页结果DTO(泛型,对应接口 PagedResultDto)
export interface PagedResultDto<T> {
/** 数据列表(可空) */
items?: T[] | null;
items?: T[] | null
/** 总条数(int64格式) */
totalCount: number;
totalCount: number
}
// 旅客输出DTO(对应接口 MemberGuestOutputDto)
export interface MemberGuestOutputDto {
/** 主键ID(UUID格式) */
id: string;
id: string
/** 会员用户ID(UUID格式) */
memberId: string;
memberId: string
/** 名(最大长度50,可选) */
name?: string | null;
name?: string | null
/** 姓(最大长度100,可选) */
surName?: string | null;
surName?: string | null
/** 性别(1男 2女,int32格式) */
sex: number;
sex: number
/** 出生日期(date-time格式,可选) */
birthday?: string | null;
birthday?: string | null
/** 国籍(UUID格式,可选) */
countryId?: string | null;
countryId?: string | null
/** 证件列表(JSON格式,最大长度600,可选) */
idCard?: string | null;
idCard?: string | null
/** 邮箱(最大长度50,可选) */
email?: string | null;
email?: string | null
/** 电话区号(最大长度10,可选) */
phoneCode?: string | null;
phoneCode?: string | null
/** 电话(最大长度50,可选) */
phone?: string | null;
phone?: string | null
}
// 旅客分页查询参数DTO(对应接口 query 参数)
export interface MemberGuestQueryParams {
/** 跳过条数(最小0,最大2147483647,可选) */
SkipCount?: number;
SkipCount?: number
/** 每页条数(最小1,最大2147483647,可选) */
MaxResultCount?: number;
MaxResultCount?: number
/** 姓名(可选) */
Name?: string;
Name?: string
}
// 旅客输入DTO(对应接口 MemberGuestInputDto,用于新增/修改旅客资料)
export interface MemberGuestInputDto {
/** 主键ID(UUID格式,可选,新增时不传,修改时传) */
id?: string | null;
id?: string | null
/** 名(最大长度50,可选) */
name?: string | null;
name?: string | null
/** 姓(最大长度100,可选) */
surName?: string | null;
surName?: string | null
/** 性别(1男 2女,int32格式,必填) */
sex: number;
sex: number
/** 出生日期(date-time格式,可选) */
birthday?: string | null;
birthday?: string | null
/** 国籍(UUID格式,可选) */
countryId?: string | null;
countryId?: string | null
/** 证件列表(JSON格式,最大长度600,可选) */
idCard?: string | null;
idCard?: string | null
/** 邮箱(最大长度50,可选) */
email?: string | null;
email?: string | null
/** 电话区号(最大长度10,可选) */
phoneCode?: string | null;
phoneCode?: string | null
/** 电话(最大长度50,可选) */
phone?: string | null;
phone?: string | null
}
/**
......@@ -464,75 +459,76 @@ export interface MemberGuestInputDto {
// 分页结果DTO(泛型,复用通用分页结构)
export interface PagedResultDto<T> {
/** 数据列表(可空) */
items?: T[] | null;
items?: T[] | null
/** 总条数(int64格式) */
totalCount: number;
totalCount: number
}
// 邮寄地址输出DTO(对应接口 MemberMailingAddressOutputDto)
export interface MemberMailingAddressOutputDto {
/** 主键ID(UUID格式) */
id: string;
id: string
/** 会员用户ID(UUID格式) */
memberId: string;
memberId: string
/** 收件人(最大长度50,可选) */
name?: string | null;
name?: string | null
/** 国家(UUID格式,可选) */
countryId?: string | null;
countryId?: string | null
/** 所在城市(最大长度200,可选) */
cityName?: string | null;
cityName?: string | null
/** 详细地址(最大长度200,可选) */
address?: string | null;
address?: string | null
/** 邮编(最大长度20,可选) */
postalCode?: string | null;
postalCode?: string | null
/** 电话区号(最大长度10,可选) */
phoneCode?: string | null;
phoneCode?: string | null
/** 电话(最大长度50,可选) */
phone?: string | null;
phone?: string | null
/** 是否默认(1=是,int32格式,必填) */
isDefault: number;
isDefault: number
}
// 邮寄地址分页查询参数DTO(对应接口 query 参数)
export interface MemberMailingAddressQueryParams {
/** 跳过条数(最小0,最大2147483647,可选) */
SkipCount?: number;
SkipCount?: number
/** 每页条数(最小1,最大2147483647,可选) */
MaxResultCount?: number;
MaxResultCount?: number
/** 姓名(收件人姓名,可选) */
Name?: string;
Name?: string
}
/**
* 新增/修改邮寄地址相关类型定义
*/
export interface MemberMailingAddressInputDto {
/** 主键ID(UUID格式,可选,新增时不传,修改时传) */
id?: string | null;
id?: string | null
/** 收件人(最大长度50,可选) */
name?: string | null;
name?: string | null
/** 国家(UUID格式,可选) */
countryId?: string | null;
countryId?: string | null
/** 所在城市(最大长度200,可选) */
cityName?: string | null;
cityName?: string | null
/** 详细地址(最大长度200,可选) */
address?: string | null;
address?: string | null
/** 邮编(最大长度20,可选) */
postalCode?: string | null;
postalCode?: string | null
/** 电话区号(最大长度10,可选) */
phoneCode?: string | null;
phoneCode?: string | null
/** 电话(最大长度50,可选) */
phone?: string | null;
phone?: string | null
/** 是否默认(1=是,int32格式,必填) */
isDefault: number;
isDefault: number
}
// ==================== 服务类 ====================
/**
* 用户服务
*/
class UserService {
/**
/**
* 注册
* @param data 注册信息
* @returns 注册响应
......@@ -551,6 +547,7 @@ class UserService {
)
return response as unknown as DistributorLoginResultDto
}
/**
* 登录
* @param email 邮箱
......@@ -584,12 +581,19 @@ class UserService {
)
return response as unknown as DistributorLoginResultDto
}
/**
/**
* 谷歌登录
* @param credential 谷歌token
* @returns
*/
static async GoogleLoginAsync(tenantId: string,code: string,distributorId: number,parentId?: any,redirectUri?: string): Promise<DistributorLoginResultDto> {
static async GoogleLoginAsync(
tenantId: string,
code: string,
distributorId: number,
parentId?: any,
redirectUri?: string
): Promise<DistributorLoginResultDto> {
const data = {
tenantId,
code,
......@@ -602,9 +606,7 @@ class UserService {
'/member-auth/google-login-by-code',
data,
{
headers: {
}
headers: {}
}
)
return response as unknown as DistributorLoginResultDto
......@@ -615,7 +617,13 @@ class UserService {
* @param credential 谷歌token
* @returns
*/
static async GoogleBindAsync(tenantId: string,code: string,distributorId: number,parentId?: any,redirectUri?: string): Promise<GeneralResponseDto> {
static async GoogleBindAsync(
tenantId: string,
code: string,
distributorId: number,
parentId?: any,
redirectUri?: string
): Promise<GeneralResponseDto> {
const data = {
tenantId,
code,
......@@ -628,9 +636,7 @@ class UserService {
'/member-auth/google-bind-by-code',
data,
{
headers: {
}
headers: {}
}
)
return response as unknown as GeneralResponseDto
......@@ -641,7 +647,13 @@ class UserService {
* @param tenantId 租户ID
* @returns
*/
static async wechatLoginAsync(tenantId: string,code: string,distributorId: number,parentId?: any,redirectUri?: string): Promise<DistributorLoginResultDto> {
static async wechatLoginAsync(
tenantId: string,
code: string,
distributorId: number,
parentId?: any,
redirectUri?: string
): Promise<DistributorLoginResultDto> {
const data = {
tenantId,
code,
......@@ -661,12 +673,19 @@ class UserService {
)
return response as unknown as DistributorLoginResultDto
}
/**
* 微信绑定
* @param tenantId 租户ID
* @returns
*/
static async wechatBindAsync(tenantId: string,code: string,distributorId: number,parentId?: any,redirectUri?: string): Promise<GeneralResponseDto> {
static async wechatBindAsync(
tenantId: string,
code: string,
distributorId: number,
parentId?: any,
redirectUri?: string
): Promise<GeneralResponseDto> {
const data = {
tenantId,
code,
......@@ -686,12 +705,19 @@ class UserService {
)
return response as unknown as GeneralResponseDto
}
/**
* line登录
* @param tenantId 租户ID
* @returns
*/
static async lineLoginAsync(tenantId: string,code: string,distributorId: number,parentId?: any,redirectUri?: string): Promise<DistributorLoginResultDto> {
static async lineLoginAsync(
tenantId: string,
code: string,
distributorId: number,
parentId?: any,
redirectUri?: string
): Promise<DistributorLoginResultDto> {
const data = {
tenantId,
code,
......@@ -711,12 +737,19 @@ class UserService {
)
return response as unknown as DistributorLoginResultDto
}
/**
* line绑定
* @param tenantId 租户ID
* @returns
*/
static async lineBindAsync(tenantId: string,code: string,distributorId: number,parentId?: any,redirectUri?: string): Promise<GeneralResponseDto> {
static async lineBindAsync(
tenantId: string,
code: string,
distributorId: number,
parentId?: any,
redirectUri?: string
): Promise<GeneralResponseDto> {
const data = {
tenantId,
code,
......@@ -736,12 +769,16 @@ class UserService {
)
return response as unknown as GeneralResponseDto
}
/**
* 获取微信AppID
* @param tenantId 租户ID
* @returns
*/
static async wechatThirdConfigAsync(tenantId: string,providerType: string): Promise<WechatAppIdResponseDto> {
static async wechatThirdConfigAsync(
tenantId: string,
providerType: string
): Promise<WechatAppIdResponseDto> {
const data = {
providerType
}
......@@ -763,7 +800,9 @@ class UserService {
* @param refreshToken 刷新令牌
* @returns 新的访问令牌
*/
static async refreshTokenAsync(refreshToken: string): Promise<DistributorLoginResultDto> {
static async refreshTokenAsync(
refreshToken: string
): Promise<DistributorLoginResultDto> {
const response = await OtaRequest.post('/auth/refresh-token', {
refreshToken
})
......@@ -895,7 +934,7 @@ class UserService {
return response as unknown as ResetPasswordResponseDto
}
/**
/**
* 修改密码
* @param email 邮箱地址
* @param code 验证码
......@@ -930,7 +969,9 @@ class UserService {
* @param tenantId 租户ID(可选)
* @returns 验证结果
*/
static async memberCenterAsync(tenantId: string): Promise<PersonalCenterResponseDto> {
static async memberCenterAsync(
tenantId: string
): Promise<PersonalCenterResponseDto> {
const response = await OtaRequest.get(
'/member-auth/member-center',
{},
......@@ -942,19 +983,23 @@ class UserService {
)
return response as unknown as PersonalCenterResponseDto
}
/**
* 设置邮箱
* @param tenantId 租户ID(可选)
* @param email 邮箱地址
* @returns 验证结果
*/
static async resetEmail(tenantId: string,data: MemberUpdateEmailDto): Promise<GeneralResponseDto> {
static async resetEmail(
tenantId: string,
data: MemberUpdateEmailDto
): Promise<GeneralResponseDto> {
const response = await OtaRequest.post(
'/member-auth/reset-email',
data,
{
headers: tenantId ? {
'__tenant': tenantId
'__tenant': tenantId
} : {}
}
)
......@@ -966,7 +1011,10 @@ class UserService {
* @param tenantId 租户ID(可选)
* @param provider 外部id
*/
static async externalunbindBind(tenantId: string,ProviderType:string): Promise<GeneralResponseDto> {
static async externalunbindBind(
tenantId: string,
ProviderType: string
): Promise<GeneralResponseDto> {
const Query = {
ProviderType
}
......@@ -977,21 +1025,23 @@ class UserService {
params: {
...Query
},
headers: {
'__tenant': tenantId?tenantId:'',
headers: {
'__tenant': tenantId ? tenantId : ''
}
}
)
return response as unknown as GeneralResponseDto
}
/**
/**
* 获取基础资料
* @param tenantId 租户ID(可选)
* @param provider 外部id
*/
static async memberUserDetail(tenantId: string,id:any): Promise<MemberUserOutputDto> {
static async memberUserDetail(
tenantId: string,
id: any
): Promise<MemberUserOutputDto> {
const response = await OtaRequest.get(
`/member-user/${id}/detail`,
{},
......@@ -1009,7 +1059,10 @@ class UserService {
* @param tenantId 租户ID(可选)
* @param provider 外部id
*/
static async updateMemberUser(tenantId: string,data:any): Promise<GeneralResponseDto> {
static async updateMemberUser(
tenantId: string,
data: any
): Promise<GeneralResponseDto> {
const response = await OtaRequest.put(
'/member-user',
data,
......@@ -1021,11 +1074,15 @@ class UserService {
)
return response as unknown as GeneralResponseDto
}
/**
/**
* 旅客分页列表
* @param tenantId 租户ID(可选)
*/
static async memberGuest(tenantId: string,data:MemberGuestQueryParams): Promise<PagedResultDto<MemberGuestOutputDto>> {
static async memberGuest(
tenantId: string,
data: MemberGuestQueryParams
): Promise<PagedResultDto<MemberGuestOutputDto>> {
const response = await OtaRequest.get(
'/member-guest/paged',
data,
......@@ -1037,11 +1094,15 @@ class UserService {
)
return response as unknown as PagedResultDto<MemberGuestOutputDto>
}
/**
/**
* 新增修改旅客
* @param tenantId 租户ID(可选)
*/
static async updateMemberGuest(tenantId: string,data:MemberGuestInputDto): Promise<MemberGuestInputDto> {
static async updateMemberGuest(
tenantId: string,
data: MemberGuestInputDto
): Promise<MemberGuestInputDto> {
const response = await OtaRequest.post(
'/member-guest/or-update',
data,
......@@ -1054,11 +1115,14 @@ class UserService {
return response as unknown as MemberGuestInputDto
}
/**
/**
* 删除旅客
* @param tenantId 租户ID(可选)
*/
static async deleteMemberGuest(tenantId: string,id:any): Promise<GeneralResponseDto> {
static async deleteMemberGuest(
tenantId: string,
id: any
): Promise<GeneralResponseDto> {
const response = await OtaRequest.delete(
`/member-guest/${id}`,
{
......@@ -1069,11 +1133,15 @@ class UserService {
)
return response as unknown as GeneralResponseDto
}
/**
* 邮寄地址分页列表
* @param tenantId 租户ID(可选)
*/
static async memberMailingAddress(tenantId: string,data:MemberMailingAddressQueryParams): Promise<PagedResultDto<MemberMailingAddressOutputDto>> {
static async memberMailingAddress(
tenantId: string,
data: MemberMailingAddressQueryParams
): Promise<PagedResultDto<MemberMailingAddressOutputDto>> {
const response = await OtaRequest.get(
'/member-mailing-address/paged',
data,
......@@ -1086,11 +1154,14 @@ class UserService {
return response as unknown as PagedResultDto<MemberMailingAddressOutputDto>
}
/**
/**
* 新增修改邮寄地址
* @param tenantId 租户ID(可选)
*/
static async updateMemberMailingAddress(tenantId: string,data:MemberMailingAddressInputDto): Promise<MemberMailingAddressInputDto> {
static async updateMemberMailingAddress(
tenantId: string,
data: MemberMailingAddressInputDto
): Promise<MemberMailingAddressInputDto> {
const response = await OtaRequest.post(
'/member-mailing-address/or-update',
data,
......@@ -1104,10 +1175,13 @@ class UserService {
}
/**
* 删除旅客
* 删除邮寄地址
* @param tenantId 租户ID(可选)
*/
static async deleteMemberMailingAddress(tenantId: string,id:any): Promise<GeneralResponseDto> {
static async deleteMemberMailingAddress(
tenantId: string,
id: any
): Promise<GeneralResponseDto> {
const response = await OtaRequest.delete(
`/member-mailing-address/${id}`,
{
......@@ -1120,4 +1194,4 @@ class UserService {
}
}
export default UserService
export default UserService
\ No newline at end of file
......@@ -391,12 +391,11 @@ const handleSubmit = async () => {
try {
const registerData = formData
const response = await UserService.updateMemberUser(tenantId|| 'default',registerData)
// if (response) {}
if (response) {
Message.success(t('personal.updateSuccess'))
getUserDetail()
getPersonalInfor()
// userStore.updateProfile({photo:formData.photo,name:formData.name})
}
} catch (error: any) {
console.error('提交失败:', error)
Message.error(error.message)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment