注册集成手机号登录,修改密码,修改手机号
This commit is contained in:
@@ -35,6 +35,14 @@ const cartCount = ref(0)
|
||||
// 加载购物车数量
|
||||
const loadCartCount = async () => {
|
||||
try {
|
||||
// 检查用户是否已登录
|
||||
const token = localStorage.getItem('accessToken') || sessionStorage.getItem('accessToken')
|
||||
if (!token) {
|
||||
console.log('用户未登录,不加载购物车数据')
|
||||
cartCount.value = 0
|
||||
return
|
||||
}
|
||||
|
||||
const response = await cartApi.getCartList() as any
|
||||
const data = response || []
|
||||
const cartList = Array.isArray(data) ? data : []
|
||||
@@ -43,6 +51,7 @@ const loadCartCount = async () => {
|
||||
cartCount.value = totalQuantity
|
||||
} catch (error) {
|
||||
console.error('获取购物车数量失败:', error)
|
||||
cartCount.value = 0
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,11 @@ export interface LoginRequest {
|
||||
rememberMe?: boolean
|
||||
}
|
||||
|
||||
export interface PhoneLoginRequest {
|
||||
phone: string
|
||||
verificationCode: string
|
||||
}
|
||||
|
||||
export interface RegisterRequest {
|
||||
account: string
|
||||
password: string
|
||||
@@ -44,6 +49,10 @@ export const authApi = {
|
||||
return api.post<LoginResponse>('/user/login', data)
|
||||
},
|
||||
|
||||
phoneLogin: (data: PhoneLoginRequest) => {
|
||||
return api.post<LoginResponse>('/user/phone-login', data)
|
||||
},
|
||||
|
||||
adminLogin: (data: LoginRequest) => {
|
||||
return api.post<LoginResponse>('/admin/auth/login', data)
|
||||
},
|
||||
|
||||
@@ -131,6 +131,8 @@ api.interceptors.response.use(
|
||||
return url?.includes('/user/login') ||
|
||||
url?.includes('/user/register') ||
|
||||
url?.includes('/user/refresh-token') ||
|
||||
url?.includes('/user/send-verification-code') ||
|
||||
url?.includes('/user/phone-login') ||
|
||||
url?.includes('/shop/list/simple') ||
|
||||
url?.includes('/admin/login')
|
||||
}
|
||||
|
||||
@@ -48,6 +48,21 @@ export interface UpdateUserRequest {
|
||||
shopId?: number
|
||||
}
|
||||
|
||||
export interface UpdatePasswordRequest {
|
||||
password: string
|
||||
}
|
||||
|
||||
export interface BindPhoneRequest {
|
||||
phone: string
|
||||
verificationCode: string
|
||||
}
|
||||
|
||||
export interface UpdatePhoneRequest {
|
||||
oldPhone: string
|
||||
newPhone: string
|
||||
verificationCode: string
|
||||
}
|
||||
|
||||
export const userApi = {
|
||||
getUserInfo: () => {
|
||||
return api.get<UserVO>('/user/info')
|
||||
@@ -55,10 +70,22 @@ export const userApi = {
|
||||
updateUserInfo: (data: UpdateUserInfoRequest) => {
|
||||
return api.put('/user/info', data)
|
||||
},
|
||||
updatePassword: (data: UpdatePasswordRequest) => {
|
||||
return api.put('/user/password', data)
|
||||
},
|
||||
bindPhone: (data: BindPhoneRequest) => {
|
||||
return api.post('/user/bind-phone', data)
|
||||
},
|
||||
updatePhone: (data: UpdatePhoneRequest) => {
|
||||
return api.put('/user/phone', data)
|
||||
},
|
||||
getUserByAccount: (account: string) => {
|
||||
return api.get<UserVO>(`/user/get/account/${account}`)
|
||||
},
|
||||
listUsersByType: (type: number) => {
|
||||
return api.get<UserVO[]>(`/user/list/type/${type}`)
|
||||
},
|
||||
sendVerificationCode: (data: { phone: string }) => {
|
||||
return api.post('/user/send-verification-code', data)
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+1
@@ -49,6 +49,7 @@ declare module 'vue' {
|
||||
APageHeader: typeof import('ant-design-vue/es')['PageHeader']
|
||||
APopconfirm: typeof import('ant-design-vue/es')['Popconfirm']
|
||||
ARadio: typeof import('ant-design-vue/es')['Radio']
|
||||
ARadioButton: typeof import('ant-design-vue/es')['RadioButton']
|
||||
ARadioGroup: typeof import('ant-design-vue/es')['RadioGroup']
|
||||
ARow: typeof import('ant-design-vue/es')['Row']
|
||||
ASegmented: typeof import('ant-design-vue/es')['Segmented']
|
||||
|
||||
@@ -63,6 +63,18 @@ const router = createRouter({
|
||||
component: () => import('../views/SettingsView.vue'),
|
||||
meta: { requiresAuth: true, hideNav: true, isAdmin: false }
|
||||
},
|
||||
{
|
||||
path: '/settings/account',
|
||||
name: 'account-settings',
|
||||
component: () => import('../views/AccountSettingsView.vue'),
|
||||
meta: { requiresAuth: true, hideNav: true, isAdmin: false }
|
||||
},
|
||||
{
|
||||
path: '/settings/password',
|
||||
name: 'password-settings',
|
||||
component: () => import('../views/PasswordSettingsView.vue'),
|
||||
meta: { requiresAuth: true, hideNav: true, isAdmin: false }
|
||||
},
|
||||
{
|
||||
path: '/coupons',
|
||||
name: 'coupons',
|
||||
|
||||
@@ -0,0 +1,565 @@
|
||||
<template>
|
||||
<div class="mobile-container">
|
||||
<!-- 头部区域 -->
|
||||
<header class="header">
|
||||
<a-button class="back-btn" type="text" @click="handleBackClick">
|
||||
<LeftOutlined :style="{ fontSize: '20px' }" />
|
||||
</a-button>
|
||||
<h1>账号设置</h1>
|
||||
<div class="empty"></div>
|
||||
</header>
|
||||
|
||||
<!-- 账号设置内容 -->
|
||||
<div class="account-settings">
|
||||
<!-- 状态提示 -->
|
||||
<div v-if="!hasPassword || !hasPhone" class="status-tips">
|
||||
<a-alert
|
||||
v-if="!hasPassword"
|
||||
type="warning"
|
||||
message="请设置密码"
|
||||
description="为了账户安全,建议您设置一个安全的密码"
|
||||
show-icon
|
||||
:closable="false"
|
||||
>
|
||||
<template #action>
|
||||
<a-button size="small" type="primary" @click="handleSetPassword">去设置</a-button>
|
||||
</template>
|
||||
</a-alert>
|
||||
<a-alert
|
||||
v-if="!hasPhone"
|
||||
type="warning"
|
||||
message="请绑定手机号"
|
||||
description="绑定手机号可以提高账户安全性"
|
||||
show-icon
|
||||
:closable="false"
|
||||
>
|
||||
<template #action>
|
||||
<a-button size="small" type="primary" @click="handleBindPhone">去绑定</a-button>
|
||||
</template>
|
||||
</a-alert>
|
||||
</div>
|
||||
|
||||
<!-- 账号设置选项 -->
|
||||
<a-card :bordered="false" class="settings-card" v-if="hasPassword && hasPhone">
|
||||
<a-list :data-source="accountSettings" :split="false">
|
||||
<template #renderItem="{ item }">
|
||||
<a-list-item class="setting-item" @click="handleSettingClick(item.key)">
|
||||
<template #actions>
|
||||
<RightOutlined />
|
||||
</template>
|
||||
<a-list-item-meta>
|
||||
<template #avatar>
|
||||
<div class="setting-icon" :style="{ backgroundColor: item.bgColor }">
|
||||
<component :is="item.icon" />
|
||||
</div>
|
||||
</template>
|
||||
<template #title>
|
||||
<span>{{ item.title }}</span>
|
||||
</template>
|
||||
<template #description v-if="item.desc">
|
||||
<span>{{ item.desc }}</span>
|
||||
</template>
|
||||
</a-list-item-meta>
|
||||
</a-list-item>
|
||||
</template>
|
||||
</a-list>
|
||||
</a-card>
|
||||
</div>
|
||||
|
||||
<!-- 绑定手机号弹窗 -->
|
||||
<a-modal
|
||||
v-model:visible="bindPhoneModalVisible"
|
||||
title="绑定手机号"
|
||||
@ok="handleBindPhoneSubmit"
|
||||
@cancel="handleBindPhoneCancel"
|
||||
:confirmLoading="bindPhoneLoading"
|
||||
>
|
||||
<a-form layout="vertical">
|
||||
<a-form-item label="手机号" name="phone">
|
||||
<a-input
|
||||
v-model:value="bindPhoneForm.phone"
|
||||
placeholder="请输入手机号"
|
||||
:disabled="!!userInfo.phone"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="验证码" name="verificationCode">
|
||||
<a-input
|
||||
v-model:value="bindPhoneForm.verificationCode"
|
||||
placeholder="请输入验证码"
|
||||
>
|
||||
<template #suffix>
|
||||
<a-button
|
||||
type="link"
|
||||
:disabled="countdown > 0 || !bindPhoneForm.phone"
|
||||
@click="handleSendVerificationCode"
|
||||
>
|
||||
{{ countdown > 0 ? `${countdown}秒后重发` : '发送验证码' }}
|
||||
</a-button>
|
||||
</template>
|
||||
</a-input>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</a-modal>
|
||||
|
||||
<!-- 修改手机号弹窗 -->
|
||||
<a-modal
|
||||
v-model:visible="changePhoneModalVisible"
|
||||
title="修改手机号"
|
||||
@ok="handleChangePhoneSubmit"
|
||||
@cancel="handleChangePhoneCancel"
|
||||
:confirmLoading="changePhoneLoading"
|
||||
>
|
||||
<a-form layout="vertical">
|
||||
<a-form-item label="旧手机号">
|
||||
<a-input :value="userInfo.phone" disabled />
|
||||
</a-form-item>
|
||||
<a-form-item label="新手机号" name="newPhone">
|
||||
<a-input
|
||||
v-model:value="changePhoneForm.newPhone"
|
||||
placeholder="请输入新手机号"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="验证码" name="verificationCode">
|
||||
<a-input
|
||||
v-model:value="changePhoneForm.verificationCode"
|
||||
placeholder="请输入验证码"
|
||||
>
|
||||
<template #suffix>
|
||||
<a-button
|
||||
type="link"
|
||||
:disabled="countdown > 0 || !changePhoneForm.newPhone"
|
||||
@click="handleSendChangePhoneVerificationCode"
|
||||
>
|
||||
{{ countdown > 0 ? `${countdown}秒后重发` : '发送验证码' }}
|
||||
</a-button>
|
||||
</template>
|
||||
</a-input>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</a-modal>
|
||||
|
||||
<!-- 修改密码弹窗 -->
|
||||
<a-modal
|
||||
v-model:visible="changePasswordModalVisible"
|
||||
title="修改密码"
|
||||
@ok="handleChangePasswordSubmit"
|
||||
@cancel="handleChangePasswordCancel"
|
||||
:confirmLoading="changePasswordLoading"
|
||||
>
|
||||
<a-form layout="vertical">
|
||||
<a-form-item label="手机号">
|
||||
<a-input :value="userInfo.phone" disabled />
|
||||
</a-form-item>
|
||||
<a-form-item label="验证码" name="verificationCode">
|
||||
<a-input
|
||||
v-model:value="changePasswordForm.verificationCode"
|
||||
placeholder="请输入验证码"
|
||||
>
|
||||
<template #suffix>
|
||||
<a-button
|
||||
type="link"
|
||||
:disabled="countdown > 0"
|
||||
@click="handleSendChangePasswordVerificationCode"
|
||||
>
|
||||
{{ countdown > 0 ? `${countdown}秒后重发` : '发送验证码' }}
|
||||
</a-button>
|
||||
</template>
|
||||
</a-input>
|
||||
</a-form-item>
|
||||
<a-form-item label="新密码" name="password">
|
||||
<a-input-password
|
||||
v-model:value="changePasswordForm.password"
|
||||
placeholder="请输入新密码"
|
||||
/>
|
||||
<div class="password-tip">
|
||||
密码长度至少8位,包含字母和数字
|
||||
</div>
|
||||
</a-form-item>
|
||||
<a-form-item label="确认密码" name="confirmPassword">
|
||||
<a-input-password
|
||||
v-model:value="changePasswordForm.confirmPassword"
|
||||
placeholder="请再次输入新密码"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</a-modal>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, onMounted } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { LeftOutlined, RightOutlined, LockOutlined, PhoneOutlined } from '@ant-design/icons-vue'
|
||||
import { message } from 'ant-design-vue'
|
||||
import { userApi } from '@/api/user'
|
||||
import type { UserVO } from '@/api/user'
|
||||
|
||||
const router = useRouter()
|
||||
|
||||
// 用户信息
|
||||
const userInfo = ref<UserVO>({
|
||||
id: 0,
|
||||
nickname: '',
|
||||
account: '',
|
||||
avatar: '',
|
||||
type: 0,
|
||||
status: 0,
|
||||
createTime: '',
|
||||
updateTime: ''
|
||||
})
|
||||
|
||||
// 状态标识
|
||||
const hasPassword = ref(false)
|
||||
const hasPhone = ref(false)
|
||||
|
||||
// 绑定手机号表单
|
||||
const bindPhoneModalVisible = ref(false)
|
||||
const bindPhoneLoading = ref(false)
|
||||
const bindPhoneForm = reactive({
|
||||
phone: '',
|
||||
verificationCode: ''
|
||||
})
|
||||
|
||||
// 修改手机号表单
|
||||
const changePhoneModalVisible = ref(false)
|
||||
const changePhoneLoading = ref(false)
|
||||
const changePhoneForm = reactive({
|
||||
newPhone: '',
|
||||
verificationCode: ''
|
||||
})
|
||||
|
||||
// 修改密码表单
|
||||
const changePasswordModalVisible = ref(false)
|
||||
const changePasswordLoading = ref(false)
|
||||
const changePasswordForm = reactive({
|
||||
verificationCode: '',
|
||||
password: '',
|
||||
confirmPassword: ''
|
||||
})
|
||||
|
||||
// 倒计时
|
||||
const countdown = ref(0)
|
||||
|
||||
// 账号设置选项
|
||||
const accountSettings = ref([
|
||||
{
|
||||
key: 'changePhone',
|
||||
title: '修改手机号',
|
||||
icon: PhoneOutlined,
|
||||
bgColor: '#e6f7ff'
|
||||
},
|
||||
{
|
||||
key: 'changePassword',
|
||||
title: '修改密码',
|
||||
icon: LockOutlined,
|
||||
bgColor: '#f6ffed'
|
||||
}
|
||||
])
|
||||
|
||||
// 获取用户信息
|
||||
const fetchUserInfo = async () => {
|
||||
try {
|
||||
const response = await userApi.getUserInfo() as any
|
||||
userInfo.value = response
|
||||
// 检查是否绑定手机号
|
||||
hasPhone.value = !!userInfo.value.phone
|
||||
// 检查是否设置密码(通过localStorage中的标识)
|
||||
hasPassword.value = localStorage.getItem('needSetPassword') !== 'true'
|
||||
} catch (error) {
|
||||
console.error('获取用户信息失败:', error)
|
||||
message.error('获取用户信息失败')
|
||||
}
|
||||
}
|
||||
|
||||
// 处理返回
|
||||
const handleBackClick = () => {
|
||||
router.back()
|
||||
}
|
||||
|
||||
// 处理设置项点击
|
||||
const handleSettingClick = (key: string) => {
|
||||
switch (key) {
|
||||
case 'changePhone':
|
||||
changePhoneModalVisible.value = true
|
||||
break
|
||||
case 'changePassword':
|
||||
changePasswordModalVisible.value = true
|
||||
break
|
||||
default:
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
// 处理设置密码
|
||||
const handleSetPassword = () => {
|
||||
router.push('/settings/password')
|
||||
}
|
||||
|
||||
// 处理绑定手机号
|
||||
const handleBindPhone = () => {
|
||||
bindPhoneModalVisible.value = true
|
||||
}
|
||||
|
||||
// 发送验证码
|
||||
const handleSendVerificationCode = async () => {
|
||||
if (!bindPhoneForm.phone) {
|
||||
message.error('请输入手机号')
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
await userApi.sendVerificationCode({ phone: bindPhoneForm.phone })
|
||||
message.success('验证码发送成功')
|
||||
startCountdown()
|
||||
} catch (error) {
|
||||
console.error('发送验证码失败:', error)
|
||||
message.error('发送验证码失败')
|
||||
}
|
||||
}
|
||||
|
||||
// 发送修改手机号验证码
|
||||
const handleSendChangePhoneVerificationCode = async () => {
|
||||
if (!changePhoneForm.newPhone) {
|
||||
message.error('请输入新手机号')
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
await userApi.sendVerificationCode({ phone: changePhoneForm.newPhone })
|
||||
message.success('验证码发送成功')
|
||||
startCountdown()
|
||||
} catch (error) {
|
||||
console.error('发送验证码失败:', error)
|
||||
message.error('发送验证码失败')
|
||||
}
|
||||
}
|
||||
|
||||
// 发送修改密码验证码
|
||||
const handleSendChangePasswordVerificationCode = async () => {
|
||||
if (!userInfo.value.phone) {
|
||||
message.error('请先绑定手机号')
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
await userApi.sendVerificationCode({ phone: userInfo.value.phone })
|
||||
message.success('验证码发送成功')
|
||||
startCountdown()
|
||||
} catch (error) {
|
||||
console.error('发送验证码失败:', error)
|
||||
message.error('发送验证码失败')
|
||||
}
|
||||
}
|
||||
|
||||
// 开始倒计时
|
||||
const startCountdown = () => {
|
||||
countdown.value = 60
|
||||
const timer = setInterval(() => {
|
||||
countdown.value--
|
||||
if (countdown.value <= 0) {
|
||||
clearInterval(timer)
|
||||
}
|
||||
}, 1000)
|
||||
}
|
||||
|
||||
// 处理绑定手机号提交
|
||||
const handleBindPhoneSubmit = async () => {
|
||||
if (!bindPhoneForm.phone || !bindPhoneForm.verificationCode) {
|
||||
message.error('请填写完整信息')
|
||||
return
|
||||
}
|
||||
|
||||
bindPhoneLoading.value = true
|
||||
try {
|
||||
await userApi.bindPhone({
|
||||
phone: bindPhoneForm.phone,
|
||||
verificationCode: bindPhoneForm.verificationCode
|
||||
})
|
||||
message.success('手机号绑定成功')
|
||||
bindPhoneModalVisible.value = false
|
||||
await fetchUserInfo()
|
||||
} catch (error: any) {
|
||||
console.error('绑定手机号失败:', error)
|
||||
message.error(error.message || '绑定手机号失败')
|
||||
} finally {
|
||||
bindPhoneLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 处理绑定手机号取消
|
||||
const handleBindPhoneCancel = () => {
|
||||
bindPhoneModalVisible.value = false
|
||||
bindPhoneForm.phone = ''
|
||||
bindPhoneForm.verificationCode = ''
|
||||
}
|
||||
|
||||
// 处理修改手机号提交
|
||||
const handleChangePhoneSubmit = async () => {
|
||||
if (!changePhoneForm.newPhone || !changePhoneForm.verificationCode) {
|
||||
message.error('请填写完整信息')
|
||||
return
|
||||
}
|
||||
|
||||
changePhoneLoading.value = true
|
||||
try {
|
||||
await userApi.updatePhone({
|
||||
oldPhone: userInfo.value.phone!,
|
||||
newPhone: changePhoneForm.newPhone,
|
||||
verificationCode: changePhoneForm.verificationCode
|
||||
})
|
||||
message.success('手机号修改成功')
|
||||
changePhoneModalVisible.value = false
|
||||
await fetchUserInfo()
|
||||
} catch (error: any) {
|
||||
console.error('修改手机号失败:', error)
|
||||
message.error(error.message || '修改手机号失败')
|
||||
} finally {
|
||||
changePhoneLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 处理修改手机号取消
|
||||
const handleChangePhoneCancel = () => {
|
||||
changePhoneModalVisible.value = false
|
||||
changePhoneForm.newPhone = ''
|
||||
changePhoneForm.verificationCode = ''
|
||||
}
|
||||
|
||||
// 处理修改密码提交
|
||||
const handleChangePasswordSubmit = async () => {
|
||||
if (!changePasswordForm.verificationCode || !changePasswordForm.password || !changePasswordForm.confirmPassword) {
|
||||
message.error('请填写完整信息')
|
||||
return
|
||||
}
|
||||
|
||||
if (changePasswordForm.password !== changePasswordForm.confirmPassword) {
|
||||
message.error('两次输入的密码不一致')
|
||||
return
|
||||
}
|
||||
|
||||
changePasswordLoading.value = true
|
||||
try {
|
||||
await userApi.updatePassword({ password: changePasswordForm.password })
|
||||
message.success('密码修改成功')
|
||||
changePasswordModalVisible.value = false
|
||||
// 清除需要设置密码的标识
|
||||
localStorage.removeItem('needSetPassword')
|
||||
hasPassword.value = true
|
||||
} catch (error: any) {
|
||||
console.error('修改密码失败:', error)
|
||||
message.error(error.message || '修改密码失败')
|
||||
} finally {
|
||||
changePasswordLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 处理修改密码取消
|
||||
const handleChangePasswordCancel = () => {
|
||||
changePasswordModalVisible.value = false
|
||||
changePasswordForm.verificationCode = ''
|
||||
changePasswordForm.password = ''
|
||||
changePasswordForm.confirmPassword = ''
|
||||
}
|
||||
|
||||
// 生命周期
|
||||
onMounted(() => {
|
||||
fetchUserInfo()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.mobile-container {
|
||||
min-height: 100vh;
|
||||
background: #f5f5f5;
|
||||
}
|
||||
|
||||
.header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 10px 15px;
|
||||
background: white;
|
||||
border-bottom: 1px solid #f0f0f0;
|
||||
}
|
||||
|
||||
.header h1 {
|
||||
font-size: 18px;
|
||||
font-weight: bold;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.back-btn,
|
||||
.empty {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.account-settings {
|
||||
padding: 15px;
|
||||
}
|
||||
|
||||
.status-tips {
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
.settings-card {
|
||||
border-radius: 16px;
|
||||
overflow: hidden;
|
||||
background: white;
|
||||
}
|
||||
|
||||
.settings-card :deep(.ant-card-body) {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.setting-item {
|
||||
padding: 16px;
|
||||
cursor: pointer;
|
||||
transition: background 0.3s;
|
||||
border-bottom: 1px solid #f0f0f0;
|
||||
}
|
||||
|
||||
.setting-item:hover {
|
||||
background: #fafafa;
|
||||
}
|
||||
|
||||
.setting-item:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.setting-item :deep(.ant-list-item-action) {
|
||||
margin-left: 8px;
|
||||
color: #ccc;
|
||||
}
|
||||
|
||||
.setting-icon {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
border-radius: 10px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 18px;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.setting-item :deep(.ant-list-item-meta-title) {
|
||||
font-size: 15px;
|
||||
font-weight: 500;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.setting-item :deep(.ant-list-item-meta-description) {
|
||||
font-size: 12px;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.password-tip {
|
||||
font-size: 12px;
|
||||
color: #999;
|
||||
margin-top: 8px;
|
||||
}
|
||||
</style>
|
||||
@@ -23,6 +23,13 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="activeTab === 'login'" class="login-type-toggle">
|
||||
<a-radio-group v-model:value="loginType" button-style="solid">
|
||||
<a-radio-button value="password">账号密码登录</a-radio-button>
|
||||
<a-radio-button value="phone">手机验证码登录</a-radio-button>
|
||||
</a-radio-group>
|
||||
</div>
|
||||
|
||||
<a-form
|
||||
:model="formData"
|
||||
:rules="rules"
|
||||
@@ -42,7 +49,7 @@
|
||||
</a-input>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item name="account" label="账号">
|
||||
<a-form-item name="account" label="账号" v-if="activeTab === 'login' && loginType === 'password'">
|
||||
<a-input
|
||||
v-model:value="formData.account"
|
||||
placeholder="请输入账号"
|
||||
@@ -63,7 +70,40 @@
|
||||
</div>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item name="password" label="密码">
|
||||
<a-form-item name="phone" label="手机号" v-if="activeTab === 'login' && loginType === 'phone'">
|
||||
<a-input
|
||||
v-model:value="formData.phone"
|
||||
placeholder="请输入手机号"
|
||||
size="large"
|
||||
>
|
||||
<template #prefix>
|
||||
<UserOutlined style="color: #999" />
|
||||
</template>
|
||||
</a-input>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item name="verificationCode" label="验证码" v-if="activeTab === 'login' && loginType === 'phone'">
|
||||
<a-input
|
||||
v-model:value="formData.verificationCode"
|
||||
placeholder="请输入验证码"
|
||||
size="large"
|
||||
>
|
||||
<template #prefix>
|
||||
<LockOutlined style="color: #999" />
|
||||
</template>
|
||||
<template #suffix>
|
||||
<a-button
|
||||
type="link"
|
||||
:disabled="countdown > 0 || !formData.phone"
|
||||
@click="handleSendVerificationCode"
|
||||
>
|
||||
{{ countdown > 0 ? `${countdown}秒后重发` : '发送验证码' }}
|
||||
</a-button>
|
||||
</template>
|
||||
</a-input>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item name="password" label="密码" v-if="activeTab === 'login' && loginType === 'password' || activeTab === 'register'">
|
||||
<a-input-password
|
||||
v-model:value="formData.password"
|
||||
placeholder="请输入密码"
|
||||
@@ -164,10 +204,12 @@ import { userApi } from '@/api/user'
|
||||
const router = useRouter()
|
||||
|
||||
const activeTab = ref<'login' | 'register'>('login')
|
||||
const loginType = ref<'password' | 'phone'>('password')
|
||||
const loading = ref(false)
|
||||
const loadingShops = ref(false)
|
||||
const shops = ref<any[]>([])
|
||||
const accountStatus = ref<any>(null)
|
||||
const countdown = ref(0)
|
||||
|
||||
const formData = reactive({
|
||||
account: '',
|
||||
@@ -175,6 +217,8 @@ const formData = reactive({
|
||||
confirmPassword: '',
|
||||
nickname: '',
|
||||
shopId: undefined as number | undefined,
|
||||
phone: '',
|
||||
verificationCode: '',
|
||||
rememberMe: false
|
||||
})
|
||||
|
||||
@@ -201,6 +245,14 @@ const rules = {
|
||||
{ min: 3, max: 50, message: '账号长度在3到50个字符', trigger: 'blur' },
|
||||
{ pattern: /^[a-zA-Z0-9_\-@.]+$/, message: '账号只能包含数字、字母、下划线、连字符、@和点号', trigger: 'blur' }
|
||||
],
|
||||
phone: [
|
||||
{ required: true, message: '请输入手机号', trigger: 'blur' },
|
||||
{ pattern: /^1[3-9]\d{9}$/, message: '手机号格式不正确', trigger: 'blur' }
|
||||
],
|
||||
verificationCode: [
|
||||
{ required: true, message: '请输入验证码', trigger: 'blur' },
|
||||
{ pattern: /^\d{6}$/, message: '验证码必须是6位数字', trigger: 'blur' }
|
||||
],
|
||||
password: [
|
||||
{ required: true, message: '请输入密码', trigger: 'blur' },
|
||||
{ validator: validatePassword, trigger: 'blur' }
|
||||
@@ -236,11 +288,20 @@ const handleSubmit = async () => {
|
||||
try {
|
||||
if (activeTab.value === 'login') {
|
||||
console.log('开始登录...')
|
||||
const response = await authApi.login({
|
||||
account: formData.account,
|
||||
password: formData.password,
|
||||
rememberMe: formData.rememberMe
|
||||
})
|
||||
let response
|
||||
|
||||
if (loginType.value === 'phone') {
|
||||
response = await authApi.phoneLogin({
|
||||
phone: formData.phone,
|
||||
verificationCode: formData.verificationCode
|
||||
})
|
||||
} else {
|
||||
response = await authApi.login({
|
||||
account: formData.account,
|
||||
password: formData.password,
|
||||
rememberMe: formData.rememberMe
|
||||
})
|
||||
}
|
||||
|
||||
console.log('登录响应:', response)
|
||||
|
||||
@@ -251,6 +312,12 @@ const handleSubmit = async () => {
|
||||
localStorage.setItem('accessToken', loginData.accessToken)
|
||||
localStorage.setItem('refreshToken', loginData.refreshToken)
|
||||
localStorage.setItem('userInfo', JSON.stringify(loginData.userInfo))
|
||||
// 存储是否需要设置密码的标识
|
||||
if (loginData.needSetPassword) {
|
||||
localStorage.setItem('needSetPassword', 'true')
|
||||
} else {
|
||||
localStorage.removeItem('needSetPassword')
|
||||
}
|
||||
sessionStorage.setItem('accessToken', loginData.accessToken)
|
||||
|
||||
console.log('Token存储成功')
|
||||
@@ -317,6 +384,27 @@ const handleAccountBlur = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
const handleSendVerificationCode = async () => {
|
||||
if (!formData.phone) {
|
||||
message.error('请输入手机号')
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
await userApi.sendVerificationCode({ phone: formData.phone })
|
||||
message.success('验证码已发送')
|
||||
countdown.value = 60
|
||||
const timer = setInterval(() => {
|
||||
countdown.value--
|
||||
if (countdown.value <= 0) {
|
||||
clearInterval(timer)
|
||||
}
|
||||
}, 1000)
|
||||
} catch (error: any) {
|
||||
message.error(error.message || '发送验证码失败')
|
||||
}
|
||||
}
|
||||
|
||||
const handleAdminLogin = () => {
|
||||
console.log('跳转到管理后台登录')
|
||||
localStorage.removeItem('accessToken')
|
||||
@@ -406,6 +494,11 @@ onMounted(() => {
|
||||
background: #667eea;
|
||||
}
|
||||
|
||||
.login-type-toggle {
|
||||
margin-bottom: 20px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.auth-form {
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,192 @@
|
||||
<template>
|
||||
<div class="mobile-container">
|
||||
<!-- 头部区域 -->
|
||||
<header class="header">
|
||||
<a-button class="back-btn" type="text" @click="handleBackClick">
|
||||
<LeftOutlined :style="{ fontSize: '20px' }" />
|
||||
</a-button>
|
||||
<h1>设置密码</h1>
|
||||
<div class="empty"></div>
|
||||
</header>
|
||||
|
||||
<!-- 密码设置表单 -->
|
||||
<div class="password-form">
|
||||
<a-card :bordered="false" class="form-card">
|
||||
<a-form
|
||||
ref="formRef"
|
||||
:model="formState"
|
||||
:rules="formRules"
|
||||
layout="vertical"
|
||||
@finish="handleSubmit"
|
||||
>
|
||||
<a-form-item label="新密码" name="password">
|
||||
<a-input-password
|
||||
v-model:value="formState.password"
|
||||
placeholder="请输入新密码"
|
||||
size="large"
|
||||
@pressEnter="handleSubmit"
|
||||
>
|
||||
<template #prefix>
|
||||
<LockOutlined style="color: #999" />
|
||||
</template>
|
||||
</a-input-password>
|
||||
<div class="password-tip">
|
||||
密码长度至少8位,包含字母和数字
|
||||
</div>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item label="确认密码" name="confirmPassword">
|
||||
<a-input-password
|
||||
v-model:value="formState.confirmPassword"
|
||||
placeholder="请再次输入新密码"
|
||||
size="large"
|
||||
@pressEnter="handleSubmit"
|
||||
>
|
||||
<template #prefix>
|
||||
<LockOutlined style="color: #999" />
|
||||
</template>
|
||||
</a-input-password>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item>
|
||||
<a-button
|
||||
type="primary"
|
||||
html-type="submit"
|
||||
size="large"
|
||||
block
|
||||
:loading="loading"
|
||||
>
|
||||
确认设置
|
||||
</a-button>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</a-card>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { LeftOutlined, LockOutlined } from '@ant-design/icons-vue'
|
||||
import { message } from 'ant-design-vue'
|
||||
import type { FormInstance } from 'ant-design-vue'
|
||||
import { userApi } from '@/api/user'
|
||||
|
||||
const router = useRouter()
|
||||
const formRef = ref<FormInstance>()
|
||||
const loading = ref(false)
|
||||
|
||||
const formState = reactive({
|
||||
password: '',
|
||||
confirmPassword: ''
|
||||
})
|
||||
|
||||
const formRules = {
|
||||
password: [
|
||||
{ required: true, message: '请输入新密码', trigger: 'blur' },
|
||||
{ min: 8, message: '密码长度至少8位', trigger: 'blur' },
|
||||
{ pattern: /^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d@$!%*#?&]{8,}$/, message: '密码必须包含字母和数字', trigger: 'blur' }
|
||||
],
|
||||
confirmPassword: [
|
||||
{ required: true, message: '请确认新密码', trigger: 'blur' },
|
||||
{ validator: validateConfirmPassword, trigger: 'blur' }
|
||||
]
|
||||
}
|
||||
|
||||
const validateConfirmPassword = (_, value: string) => {
|
||||
if (value !== formState.password) {
|
||||
return Promise.reject(new Error('两次输入的密码不一致'))
|
||||
}
|
||||
return Promise.resolve()
|
||||
}
|
||||
|
||||
const handleSubmit = async () => {
|
||||
if (!formRef.value) return
|
||||
|
||||
try {
|
||||
await formRef.value.validate()
|
||||
loading.value = true
|
||||
|
||||
await userApi.updatePassword({
|
||||
password: formState.password
|
||||
})
|
||||
|
||||
message.success('密码设置成功')
|
||||
// 清除需要设置密码的标识
|
||||
localStorage.removeItem('needSetPassword')
|
||||
// 跳转回个人中心
|
||||
router.push('/profile')
|
||||
} catch (error: any) {
|
||||
console.error('设置密码失败:', error)
|
||||
message.error(error.message || '设置密码失败')
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const handleBackClick = () => {
|
||||
router.back()
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.mobile-container {
|
||||
min-height: 100vh;
|
||||
background: #f5f5f5;
|
||||
}
|
||||
|
||||
.header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 10px 15px;
|
||||
background: white;
|
||||
border-bottom: 1px solid #f0f0f0;
|
||||
}
|
||||
|
||||
.header h1 {
|
||||
font-size: 18px;
|
||||
font-weight: bold;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.back-btn,
|
||||
.empty {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.password-form {
|
||||
padding: 15px;
|
||||
}
|
||||
|
||||
.form-card {
|
||||
border-radius: 16px;
|
||||
overflow: hidden;
|
||||
background: white;
|
||||
}
|
||||
|
||||
.form-card :deep(.ant-card-body) {
|
||||
padding: 24px;
|
||||
}
|
||||
|
||||
.password-tip {
|
||||
font-size: 12px;
|
||||
color: #999;
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
.form-card :deep(.ant-btn-primary) {
|
||||
height: 48px;
|
||||
border-radius: 12px;
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
border: none;
|
||||
box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
|
||||
}
|
||||
</style>
|
||||
@@ -33,6 +33,20 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 密码设置提示 -->
|
||||
<div v-if="needSetPassword" class="password-tip">
|
||||
<a-alert
|
||||
type="warning"
|
||||
message="请尽快设置密码"
|
||||
description="为了账户安全,建议您设置一个安全的密码"
|
||||
show-icon
|
||||
:closable="false"
|
||||
>
|
||||
<template #action>
|
||||
<a-button size="small" type="primary" @click="handleSetPassword">去设置</a-button>
|
||||
</template>
|
||||
</a-alert>
|
||||
</div>
|
||||
<a-button type="primary" block @click="handleEditProfile" class="edit-btn">
|
||||
编辑资料
|
||||
</a-button>
|
||||
@@ -217,6 +231,7 @@ const userInfo = ref<UserVO>({
|
||||
})
|
||||
|
||||
const hasNotification = ref(true)
|
||||
const needSetPassword = ref(false)
|
||||
|
||||
const editModalVisible = ref(false)
|
||||
const saving = ref(false)
|
||||
@@ -282,6 +297,8 @@ const fetchUserInfo = async () => {
|
||||
console.log('获取到的用户信息:', response)
|
||||
userInfo.value = response
|
||||
console.log('设置后的 userInfo:', userInfo.value)
|
||||
// 检查是否需要设置密码
|
||||
needSetPassword.value = localStorage.getItem('needSetPassword') === 'true'
|
||||
} catch (error) {
|
||||
console.error('获取用户信息失败:', error)
|
||||
message.error('获取用户信息失败')
|
||||
@@ -438,6 +455,8 @@ const handleLogout = () => {
|
||||
} finally {
|
||||
localStorage.removeItem('accessToken')
|
||||
localStorage.removeItem('refreshToken')
|
||||
localStorage.removeItem('userInfo')
|
||||
localStorage.removeItem('needSetPassword')
|
||||
sessionStorage.removeItem('accessToken')
|
||||
message.success('已退出登录')
|
||||
router.push('/')
|
||||
@@ -451,6 +470,11 @@ const handleSettingsClick = () => {
|
||||
router.push('/settings')
|
||||
}
|
||||
|
||||
const handleSetPassword = () => {
|
||||
console.log('去设置密码')
|
||||
router.push('/settings/password')
|
||||
}
|
||||
|
||||
const handleShopClick = () => {
|
||||
console.log('店铺信息被点击')
|
||||
if (userInfo.value.shopId) {
|
||||
|
||||
@@ -157,7 +157,7 @@ const handleSettingClick = (key: string) => {
|
||||
|
||||
switch (key) {
|
||||
case 'account':
|
||||
message.info('账号设置功能开发中...')
|
||||
router.push('/settings/account')
|
||||
break
|
||||
case 'notifications':
|
||||
message.info('消息通知功能开发中...')
|
||||
|
||||
@@ -1,8 +1,3 @@
|
||||
spring:
|
||||
application:
|
||||
name: MessageHub
|
||||
|
||||
spug:
|
||||
sms:
|
||||
url: https://push.spug.cc/sms/A27L33fbgEY # SPUG短信发送接口URL
|
||||
token: d3f334****567890 # SPUG用户ID,用于查询发送状态
|
||||
@@ -21,10 +21,6 @@ public class AuthInterceptor implements HandlerInterceptor {
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
||||
String path = request.getRequestURI();
|
||||
|
||||
if (isWhitelistedPath(path)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
String authHeader = request.getHeader(AUTHORIZATION_HEADER);
|
||||
|
||||
if (authHeader == null || !authHeader.startsWith(BEARER_PREFIX)) {
|
||||
@@ -57,16 +53,4 @@ public class AuthInterceptor implements HandlerInterceptor {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean isWhitelistedPath(String path) {
|
||||
return path.contains("/user/login") ||
|
||||
path.contains("/user/register") ||
|
||||
path.contains("/user/refresh-token") ||
|
||||
path.contains("/user/get/account") ||
|
||||
path.contains("/shop/list/simple") ||
|
||||
path.contains("/admin/auth/login") ||
|
||||
path.contains("/admin/object-storage-file/upload") ||
|
||||
path.contains("/health") ||
|
||||
path.contains("/error");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,8 @@ public class WebMvcConfig implements WebMvcConfigurer {
|
||||
"/user/login",
|
||||
"/user/register",
|
||||
"/user/refresh-token",
|
||||
"/user/send-verification-code",
|
||||
"/user/phone-login",
|
||||
"/user/get/account/**",
|
||||
"/shop/list/simple",
|
||||
"/admin/auth/login",
|
||||
|
||||
@@ -4,13 +4,18 @@ import com.xiaowang.yuminailcore.common.Result;
|
||||
import com.xiaowang.yuminailcore.dto.BindEmailRequestDTO;
|
||||
import com.xiaowang.yuminailcore.dto.BindPhoneRequestDTO;
|
||||
import com.xiaowang.yuminailcore.dto.LoginRequestDTO;
|
||||
import com.xiaowang.yuminailcore.dto.PhoneLoginRequestDTO;
|
||||
import com.xiaowang.yuminailcore.dto.RefreshTokenRequestDTO;
|
||||
import com.xiaowang.yuminailcore.dto.RegisterRequestDTO;
|
||||
import com.xiaowang.yuminailcore.dto.SendVerificationCodeRequestDTO;
|
||||
import com.xiaowang.yuminailcore.dto.UpdatePhoneRequestDTO;
|
||||
import com.xiaowang.yuminailcore.dto.UserDTO;
|
||||
import com.xiaowang.yuminailcore.vo.LoginResponseVO;
|
||||
import com.xiaowang.yuminailcore.vo.UserVO;
|
||||
import com.xiaowang.yuminailcore.service.MinioService;
|
||||
import com.xiaowang.yuminailcore.service.UserService;
|
||||
import com.xiaowang.yuminailcore.service.VerificationCodeService;
|
||||
import lombok.Data;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@@ -33,6 +38,7 @@ public class UserController {
|
||||
|
||||
private final UserService userService;
|
||||
private final MinioService minioService;
|
||||
private final VerificationCodeService verificationCodeService;
|
||||
|
||||
/**
|
||||
* 创建用户
|
||||
@@ -142,6 +148,18 @@ public class UserController {
|
||||
return Result.success(loginResponseVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 手机号验证码登录
|
||||
*
|
||||
* @param phoneLoginRequestDTO 手机号验证码登录请求DTO
|
||||
* @return 登录响应VO
|
||||
*/
|
||||
@PostMapping("/phone-login")
|
||||
public Result<LoginResponseVO> phoneLogin(@RequestBody PhoneLoginRequestDTO phoneLoginRequestDTO) {
|
||||
LoginResponseVO loginResponseVO = userService.phoneLogin(phoneLoginRequestDTO);
|
||||
return Result.success(loginResponseVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户注册
|
||||
*
|
||||
@@ -154,6 +172,21 @@ public class UserController {
|
||||
return Result.success(success);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送验证码
|
||||
*
|
||||
* @param sendVerificationCodeRequestDTO 发送验证码请求DTO
|
||||
* @return 是否发送成功
|
||||
*/
|
||||
@PostMapping("/send-verification-code")
|
||||
public Result<Boolean> sendVerificationCode(@RequestBody SendVerificationCodeRequestDTO sendVerificationCodeRequestDTO) {
|
||||
if (!verificationCodeService.canResend(sendVerificationCodeRequestDTO.getPhone())) {
|
||||
throw new RuntimeException("验证码发送过于频繁,请1分钟后再试");
|
||||
}
|
||||
verificationCodeService.sendVerificationCode(sendVerificationCodeRequestDTO.getPhone());
|
||||
return Result.success(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新Token
|
||||
*
|
||||
@@ -264,4 +297,37 @@ public class UserController {
|
||||
boolean success = userService.resetPassword(userId, currentUserId);
|
||||
return Result.success(success);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新用户密码
|
||||
*
|
||||
* @param request 请求对象
|
||||
* @param passwordDTO 密码DTO
|
||||
* @return 是否更新成功
|
||||
*/
|
||||
@PutMapping("/password")
|
||||
public Result<Boolean> updatePassword(HttpServletRequest request, @RequestBody PasswordDTO passwordDTO) {
|
||||
Long userId = (Long) request.getAttribute("userId");
|
||||
boolean success = userService.updatePassword(userId, passwordDTO.getPassword());
|
||||
return Result.success(success);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改手机号
|
||||
*
|
||||
* @param request 请求对象
|
||||
* @param updatePhoneDTO 修改手机号DTO
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
@PutMapping("/phone")
|
||||
public Result<Boolean> updatePhone(HttpServletRequest request, @RequestBody UpdatePhoneRequestDTO updatePhoneDTO) {
|
||||
Long userId = (Long) request.getAttribute("userId");
|
||||
boolean success = userService.updatePhone(userId, updatePhoneDTO);
|
||||
return Result.success(success);
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class PasswordDTO {
|
||||
private String password;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.xiaowang.yuminailcore.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.Pattern;
|
||||
|
||||
/**
|
||||
* 手机号验证码登录请求 DTO
|
||||
*
|
||||
* @author xiaowang
|
||||
* @date 2026-03-03
|
||||
*/
|
||||
@Data
|
||||
public class PhoneLoginRequestDTO {
|
||||
|
||||
@NotBlank(message = "手机号不能为空")
|
||||
@Pattern(regexp = "^1[3-9]\\d{9}$", message = "手机号格式不正确")
|
||||
private String phone;
|
||||
|
||||
@NotBlank(message = "验证码不能为空")
|
||||
@Pattern(regexp = "^\\d{6}$", message = "验证码必须是6位数字")
|
||||
private String verificationCode;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.xiaowang.yuminailcore.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class UpdatePhoneRequestDTO {
|
||||
private String oldPhone;
|
||||
private String newPhone;
|
||||
private String verificationCode;
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
package com.xiaowang.yuminailcore.service;
|
||||
|
||||
/**
|
||||
* MessageHub客户端服务接口
|
||||
* 用于调用MessageHub服务发送消息
|
||||
*
|
||||
* @author xiaowang
|
||||
* @date 2026-03-03
|
||||
*/
|
||||
public interface MessageHubClientService {
|
||||
|
||||
void sendSmsVerificationCode(String phone, String code);
|
||||
}
|
||||
@@ -4,7 +4,9 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.xiaowang.yuminailcore.dto.BindEmailRequestDTO;
|
||||
import com.xiaowang.yuminailcore.dto.BindPhoneRequestDTO;
|
||||
import com.xiaowang.yuminailcore.dto.LoginRequestDTO;
|
||||
import com.xiaowang.yuminailcore.dto.PhoneLoginRequestDTO;
|
||||
import com.xiaowang.yuminailcore.dto.RegisterRequestDTO;
|
||||
import com.xiaowang.yuminailcore.dto.UpdatePhoneRequestDTO;
|
||||
import com.xiaowang.yuminailcore.dto.UserDTO;
|
||||
import com.xiaowang.yuminailcore.entity.UserDO;
|
||||
import com.xiaowang.yuminailcore.vo.LoginResponseVO;
|
||||
@@ -33,6 +35,8 @@ public interface UserService extends IService<UserDO> {
|
||||
|
||||
LoginResponseVO login(LoginRequestDTO loginRequestDTO);
|
||||
|
||||
LoginResponseVO phoneLogin(PhoneLoginRequestDTO phoneLoginRequestDTO);
|
||||
|
||||
LoginResponseVO adminLogin(LoginRequestDTO loginRequestDTO);
|
||||
|
||||
boolean register(RegisterRequestDTO registerRequestDTO);
|
||||
@@ -54,4 +58,8 @@ public interface UserService extends IService<UserDO> {
|
||||
boolean updateUserStatus(Long id, Integer status);
|
||||
|
||||
boolean updateUserAvatar(Long userId, String avatarUrl);
|
||||
|
||||
boolean updatePassword(Long userId, String password);
|
||||
|
||||
boolean updatePhone(Long userId, UpdatePhoneRequestDTO updatePhoneDTO);
|
||||
}
|
||||
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
package com.xiaowang.yuminailcore.service.impl;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.xiaowang.yuminailcore.service.MessageHubClientService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.amqp.core.Message;
|
||||
import org.springframework.amqp.core.MessageBuilder;
|
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* MessageHub客户端服务实现
|
||||
* 通过RabbitMQ发送消息到MessageHub服务
|
||||
*
|
||||
* @author xiaowang
|
||||
* @date 2026-03-03
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class MessageHubClientServiceImpl implements MessageHubClientService {
|
||||
|
||||
private final RabbitTemplate rabbitTemplate;
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
private static final String SMS_QUEUE = "smsQueue";
|
||||
|
||||
@Override
|
||||
public void sendSmsVerificationCode(String phone, String code) {
|
||||
try {
|
||||
Map<String, Object> messageBody = new HashMap<>();
|
||||
messageBody.put("receiver", phone);
|
||||
messageBody.put("channelType", "SMS");
|
||||
messageBody.put("msgType", "VERIFICATION");
|
||||
messageBody.put("templateCode", "SPUG0001");
|
||||
messageBody.put("sourceSystem", "yuminail");
|
||||
messageBody.put("uniqueId", UUID.randomUUID().toString());
|
||||
messageBody.put("sendMethod", "SPUG");
|
||||
|
||||
Map<String, Object> templateParams = new HashMap<>();
|
||||
templateParams.put("name", "屿Nail");
|
||||
templateParams.put("code", code);
|
||||
templateParams.put("number", "5");
|
||||
messageBody.put("templateParams", templateParams);
|
||||
|
||||
String jsonBody = objectMapper.writeValueAsString(messageBody);
|
||||
|
||||
Message message = MessageBuilder
|
||||
.withBody(jsonBody.getBytes())
|
||||
.setMessageId(UUID.randomUUID().toString())
|
||||
.build();
|
||||
|
||||
rabbitTemplate.convertAndSend(SMS_QUEUE, message);
|
||||
|
||||
log.info("短信验证码消息已发送到队列,手机号: {}, 验证码: {}", phone, code);
|
||||
} catch (Exception e) {
|
||||
log.error("发送短信验证码失败", e);
|
||||
throw new RuntimeException("发送短信验证码失败: " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
+130
-5
@@ -4,11 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.xiaowang.yuminailcore.dto.BindEmailRequestDTO;
|
||||
import com.xiaowang.yuminailcore.dto.BindPhoneRequestDTO;
|
||||
import com.xiaowang.yuminailcore.dto.LoginRequestDTO;
|
||||
import com.xiaowang.yuminailcore.dto.RegisterRequestDTO;
|
||||
import com.xiaowang.yuminailcore.dto.UserDTO;
|
||||
import com.xiaowang.yuminailcore.dto.*;
|
||||
import com.xiaowang.yuminailcore.entity.UserDO;
|
||||
import com.xiaowang.yuminailcore.entity.UserPermissionDO;
|
||||
import com.xiaowang.yuminailcore.entity.PermissionDO;
|
||||
@@ -17,12 +13,14 @@ import com.xiaowang.yuminailcore.mapper.UserPermissionMapper;
|
||||
import com.xiaowang.yuminailcore.mapper.PermissionMapper;
|
||||
import com.xiaowang.yuminailcore.service.ShopService;
|
||||
import com.xiaowang.yuminailcore.service.UserService;
|
||||
import com.xiaowang.yuminailcore.service.VerificationCodeService;
|
||||
import com.xiaowang.yuminailcore.utils.JwtUtil;
|
||||
import com.xiaowang.yuminailcore.vo.LoginResponseVO;
|
||||
import com.xiaowang.yuminailcore.vo.PageResultVO;
|
||||
import com.xiaowang.yuminailcore.vo.UserVO;
|
||||
import com.xiaowang.yuminailcore.vo.ShopVO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -50,6 +48,8 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
|
||||
private final UserPermissionMapper userPermissionMapper;
|
||||
private final PermissionMapper permissionMapper;
|
||||
private final BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
|
||||
private final VerificationCodeService verificationCodeService;
|
||||
private final RedisTemplate<String, String> redisTemplate;
|
||||
|
||||
/**
|
||||
* 创建新用户
|
||||
@@ -370,6 +370,11 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
|
||||
throw new RuntimeException("用户不存在");
|
||||
}
|
||||
|
||||
// 检查是否为未设置密码的账号
|
||||
if (ENCODED_UNSET_PASSWORD.equals(userDO.getPassword())) {
|
||||
throw new RuntimeException("请使用手机号验证码登录,并在个人中心设置密码");
|
||||
}
|
||||
|
||||
if (!passwordEncoder.matches(loginRequestDTO.getPassword(), userDO.getPassword())) {
|
||||
throw new RuntimeException("密码错误");
|
||||
}
|
||||
@@ -393,6 +398,68 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
|
||||
return responseVO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LoginResponseVO phoneLogin(PhoneLoginRequestDTO phoneLoginRequestDTO) {
|
||||
if (!verificationCodeService.verifyCode(phoneLoginRequestDTO.getPhone(), phoneLoginRequestDTO.getVerificationCode())) {
|
||||
throw new RuntimeException("验证码错误或已过期");
|
||||
}
|
||||
|
||||
UserDO userDO = userMapper.selectOne(
|
||||
Wrappers.lambdaQuery(UserDO.class)
|
||||
.eq(UserDO::getPhone, phoneLoginRequestDTO.getPhone())
|
||||
.eq(UserDO::getIsDelete, 0)
|
||||
);
|
||||
|
||||
if (userDO == null) {
|
||||
userDO = registerByPhone(phoneLoginRequestDTO.getPhone());
|
||||
}
|
||||
|
||||
String accessToken = jwtUtil.generateAccessToken(userDO.getId(), userDO.getAccount());
|
||||
String refreshToken = jwtUtil.generateRefreshToken(userDO.getId(), userDO.getAccount());
|
||||
|
||||
LoginResponseVO responseVO = new LoginResponseVO();
|
||||
responseVO.setAccessToken(accessToken);
|
||||
responseVO.setRefreshToken(refreshToken);
|
||||
|
||||
LoginResponseVO.UserInfo userInfo = new LoginResponseVO.UserInfo();
|
||||
userInfo.setId(userDO.getId());
|
||||
userInfo.setAccount(userDO.getAccount());
|
||||
userInfo.setNickname(userDO.getNickname());
|
||||
userInfo.setType(userDO.getType());
|
||||
userInfo.setShopId(userDO.getShopId());
|
||||
userInfo.setCreateTime(userDO.getCreateTime());
|
||||
responseVO.setUserInfo(userInfo);
|
||||
|
||||
// 设置是否需要设置密码
|
||||
responseVO.setNeedSetPassword(ENCODED_UNSET_PASSWORD.equals(userDO.getPassword()));
|
||||
|
||||
return responseVO;
|
||||
}
|
||||
|
||||
// 未设置密码的特殊标识
|
||||
private static final String UNSET_PASSWORD_MARKER = "__UNSET_PASSWORD__";
|
||||
private static final String ENCODED_UNSET_PASSWORD = "$2a$10$EixZaYVK1fsbw1ZfbX3OXePaWxn96p36WQoeG6Lruj3vjPGga31lW"; // 加密后的特殊标识
|
||||
|
||||
private UserDO registerByPhone(String phone) {
|
||||
UserDO userDO = new UserDO();
|
||||
userDO.setAccount(phone);
|
||||
userDO.setPhone(phone);
|
||||
userDO.setPhoneVerified(1);
|
||||
userDO.setNickname("用户" + phone.substring(7));
|
||||
userDO.setType(0);
|
||||
userDO.setLevel("普通");
|
||||
userDO.setShopId(0L);
|
||||
userDO.setIsDelete(0);
|
||||
userDO.setStatus(1);
|
||||
userDO.setCreateTime(LocalDateTime.now());
|
||||
userDO.setUpdateTime(LocalDateTime.now());
|
||||
// 设置未设置密码的特殊标识
|
||||
userDO.setPassword(ENCODED_UNSET_PASSWORD);
|
||||
|
||||
userMapper.insert(userDO);
|
||||
return userDO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LoginResponseVO adminLogin(LoginRequestDTO loginRequestDTO) {
|
||||
UserDO userDO = userMapper.selectOne(
|
||||
@@ -434,6 +501,10 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
|
||||
|
||||
@Override
|
||||
public boolean register(RegisterRequestDTO registerRequestDTO) {
|
||||
if (!verificationCodeService.verifyCode(registerRequestDTO.getPhone(), registerRequestDTO.getVerificationCode())) {
|
||||
throw new RuntimeException("验证码错误或已过期");
|
||||
}
|
||||
|
||||
UserDO existingUser = userMapper.selectOne(
|
||||
Wrappers.lambdaQuery(UserDO.class)
|
||||
.eq(UserDO::getAccount, registerRequestDTO.getAccount())
|
||||
@@ -443,11 +514,23 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
|
||||
throw new RuntimeException("账号已存在");
|
||||
}
|
||||
|
||||
UserDO existingPhoneUser = userMapper.selectOne(
|
||||
Wrappers.lambdaQuery(UserDO.class)
|
||||
.eq(UserDO::getPhone, registerRequestDTO.getPhone())
|
||||
.eq(UserDO::getIsDelete, 0)
|
||||
);
|
||||
|
||||
if (existingPhoneUser != null) {
|
||||
throw new RuntimeException("该手机号已被注册");
|
||||
}
|
||||
|
||||
UserDO userDO = new UserDO();
|
||||
userDO.setShopId(registerRequestDTO.getShopId());
|
||||
userDO.setAccount(registerRequestDTO.getAccount());
|
||||
userDO.setPassword(passwordEncoder.encode(registerRequestDTO.getPassword()));
|
||||
userDO.setNickname(registerRequestDTO.getNickname());
|
||||
userDO.setPhone(registerRequestDTO.getPhone());
|
||||
userDO.setPhoneVerified(1);
|
||||
userDO.setType(Integer.valueOf(0));
|
||||
userDO.setLevel("普通");
|
||||
userDO.setIsDelete(Integer.valueOf(0));
|
||||
@@ -614,4 +697,46 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
|
||||
userDO.setUpdateTime(LocalDateTime.now());
|
||||
return userMapper.updateById(userDO) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updatePassword(Long userId, String password) {
|
||||
UserDO userDO = userMapper.selectById(userId);
|
||||
if (userDO == null) {
|
||||
throw new RuntimeException("用户不存在");
|
||||
}
|
||||
userDO.setPassword(passwordEncoder.encode(password));
|
||||
userDO.setUpdateTime(LocalDateTime.now());
|
||||
return userMapper.updateById(userDO) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updatePhone(Long userId, UpdatePhoneRequestDTO updatePhoneDTO) {
|
||||
String oldPhone = updatePhoneDTO.getOldPhone();
|
||||
String newPhone = updatePhoneDTO.getNewPhone();
|
||||
String verificationCode = updatePhoneDTO.getVerificationCode();
|
||||
|
||||
// 验证验证码
|
||||
String redisKey = "verification_code:" + newPhone;
|
||||
String storedCode = redisTemplate.opsForValue().get(redisKey);
|
||||
if (storedCode == null || !storedCode.equals(verificationCode)) {
|
||||
throw new RuntimeException("验证码错误");
|
||||
}
|
||||
|
||||
// 检查新手机号是否已被其他用户使用
|
||||
LambdaQueryWrapper<UserDO> wrapper = Wrappers.lambdaQuery(UserDO.class);
|
||||
wrapper.eq(UserDO::getPhone, newPhone);
|
||||
wrapper.ne(UserDO::getId, userId);
|
||||
if (userMapper.selectOne(wrapper) != null) {
|
||||
throw new RuntimeException("手机号已被使用");
|
||||
}
|
||||
|
||||
// 更新手机号
|
||||
UserDO userDO = userMapper.selectById(userId);
|
||||
if (userDO == null) {
|
||||
throw new RuntimeException("用户不存在");
|
||||
}
|
||||
userDO.setPhone(newPhone);
|
||||
userDO.setUpdateTime(LocalDateTime.now());
|
||||
return userMapper.updateById(userDO) > 0;
|
||||
}
|
||||
}
|
||||
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
package com.xiaowang.yuminailcore.service.impl;
|
||||
|
||||
import com.xiaowang.yuminailcore.service.MessageHubClientService;
|
||||
import com.xiaowang.yuminailcore.service.VerificationCodeService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.security.SecureRandom;
|
||||
import java.time.Duration;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* 验证码服务实现
|
||||
*
|
||||
* @author xiaowang
|
||||
* @date 2026-03-03
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class VerificationCodeServiceImpl implements VerificationCodeService {
|
||||
|
||||
private final StringRedisTemplate redisTemplate;
|
||||
private final MessageHubClientService messageHubClientService;
|
||||
|
||||
private static final String CODE_PREFIX = "verification:code:";
|
||||
private static final String SEND_TIME_PREFIX = "verification:send_time:";
|
||||
private static final int CODE_LENGTH = 6;
|
||||
private static final int CODE_EXPIRE_MINUTES = 5;
|
||||
private static final int RESEND_INTERVAL_SECONDS = 60;
|
||||
|
||||
@Override
|
||||
public String generateVerificationCode() {
|
||||
SecureRandom random = new SecureRandom();
|
||||
StringBuilder code = new StringBuilder();
|
||||
for (int i = 0; i < CODE_LENGTH; i++) {
|
||||
code.append(random.nextInt(10));
|
||||
}
|
||||
return code.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendVerificationCode(String phone) {
|
||||
String code = generateVerificationCode();
|
||||
|
||||
String codeKey = CODE_PREFIX + phone;
|
||||
String sendTimeKey = SEND_TIME_PREFIX + phone;
|
||||
|
||||
redisTemplate.opsForValue().set(codeKey, code, Duration.ofMinutes(CODE_EXPIRE_MINUTES));
|
||||
redisTemplate.opsForValue().set(sendTimeKey, String.valueOf(System.currentTimeMillis()),
|
||||
Duration.ofSeconds(RESEND_INTERVAL_SECONDS));
|
||||
|
||||
messageHubClientService.sendSmsVerificationCode(phone, code);
|
||||
|
||||
log.info("验证码已发送,手机号: {}, 验证码: {}", phone, code);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean verifyCode(String phone, String code) {
|
||||
String codeKey = CODE_PREFIX + phone;
|
||||
String storedCode = redisTemplate.opsForValue().get(codeKey);
|
||||
|
||||
if (storedCode == null) {
|
||||
log.warn("验证码不存在或已过期,手机号: {}", phone);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!storedCode.equals(code)) {
|
||||
log.warn("验证码错误,手机号: {}, 输入: {}, 正确: {}", phone, code, storedCode);
|
||||
return false;
|
||||
}
|
||||
|
||||
redisTemplate.delete(codeKey);
|
||||
log.info("验证码验证成功,手机号: {}", phone);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canResend(String phone) {
|
||||
String sendTimeKey = SEND_TIME_PREFIX + phone;
|
||||
String sendTime = redisTemplate.opsForValue().get(sendTimeKey);
|
||||
return sendTime == null;
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,8 @@ public class LoginResponseVO {
|
||||
|
||||
private UserInfo userInfo;
|
||||
|
||||
private boolean needSetPassword; // 是否需要设置密码
|
||||
|
||||
@Data
|
||||
public static class UserInfo {
|
||||
private Long id;
|
||||
|
||||
@@ -40,7 +40,7 @@ spring:
|
||||
password: 122503wcy....
|
||||
# 共享配置文件列表
|
||||
shared-configs:
|
||||
- data-id: rabbitmq.yaml
|
||||
- data-id: rabbit-mq.yaml
|
||||
group: DEFAULT_GROUP
|
||||
refresh: true
|
||||
- data-id: datasource.yaml
|
||||
@@ -52,3 +52,6 @@ spring:
|
||||
- data-id: logging.yaml
|
||||
group: DEFAULT_GROUP
|
||||
refresh: true
|
||||
- data-id: redis.yaml
|
||||
group: DEFAULT_GROUP
|
||||
refresh: true
|
||||
|
||||
+29
-8
@@ -40,6 +40,13 @@ public class AuthGlobalFilter implements GlobalFilter, Ordered {
|
||||
String path = request.getURI().getPath();
|
||||
|
||||
log.info("Gateway received request: {}", path);
|
||||
|
||||
// 打印白名单配置
|
||||
if (gatewayConfig.getWhitelist() != null) {
|
||||
log.info("Whitelist from config: {}", gatewayConfig.getWhitelist());
|
||||
} else {
|
||||
log.info("Whitelist from config is null");
|
||||
}
|
||||
|
||||
// 1. Whitelist check (login and register interfaces don't need authentication)
|
||||
log.info("Checking if path is in whitelist: {}", path);
|
||||
@@ -71,14 +78,28 @@ public class AuthGlobalFilter implements GlobalFilter, Ordered {
|
||||
* 判断是否在白名单中
|
||||
*/
|
||||
private boolean isWhitelist(String path) {
|
||||
return path.equals("/api/user/login") ||
|
||||
path.equals("/api/user/register") ||
|
||||
path.equals("/api/user/refresh-token") ||
|
||||
path.equals("/api/shop/list/simple") ||
|
||||
path.equals("/api/admin/auth/login") ||
|
||||
path.equals("/admin/api/auth/login") ||
|
||||
path.startsWith("/api/user/get/account") ||
|
||||
path.startsWith("/api/health");
|
||||
// 首先检查配置文件中的白名单
|
||||
if (gatewayConfig.getWhitelist() != null) {
|
||||
for (String whitelistPath : gatewayConfig.getWhitelist()) {
|
||||
if (pathMatcher.match(whitelistPath, path)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 硬编码白名单作为备用
|
||||
return pathMatcher.match("/api/user/login", path) ||
|
||||
pathMatcher.match("/api/user/register", path) ||
|
||||
pathMatcher.match("/api/user/refresh-token", path) ||
|
||||
pathMatcher.match("/api/user/send-verification-code", path) ||
|
||||
pathMatcher.match("/api/user/phone-login", path) ||
|
||||
pathMatcher.match("/api/user/get/account/**", path) ||
|
||||
pathMatcher.match("/api/shop/list/simple", path) ||
|
||||
pathMatcher.match("/api/admin/auth/login", path) ||
|
||||
pathMatcher.match("/admin/api/auth/login", path) ||
|
||||
pathMatcher.match("/api/health/**", path) ||
|
||||
pathMatcher.match("/api/error", path) ||
|
||||
pathMatcher.match("/api/admin/object-storage-file/upload", path);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -75,4 +75,4 @@ spring:
|
||||
predicates:
|
||||
- Path=/admin/api/**
|
||||
filters:
|
||||
- RewritePath=/admin/api/(?<remaining>.*), /admin/${remaining}
|
||||
- RewritePath=/admin/api/(?<remaining>.*), /admin/${remaining}
|
||||
@@ -32,3 +32,6 @@ spring:
|
||||
- data-id: mybatis-plus.yaml
|
||||
group: DEFAULT_GROUP
|
||||
refresh: true
|
||||
- data-id: redis.yaml
|
||||
group: DEFAULT_GROUP
|
||||
refresh: true
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
spring:
|
||||
rabbitmq:
|
||||
host: wcy111.top
|
||||
port: 5672
|
||||
username: guest
|
||||
password: guest
|
||||
virtual-host: /
|
||||
connection-timeout: 10000
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
spring:
|
||||
redis:
|
||||
host: wcy111.top
|
||||
port: 6379
|
||||
password: 122503wcy
|
||||
timeout: 10000
|
||||
lettuce:
|
||||
pool:
|
||||
max-active: 8
|
||||
max-wait: -1
|
||||
max-idle: 8
|
||||
min-idle: 0
|
||||
Reference in New Issue
Block a user