一些问题的修复
This commit is contained in:
@@ -368,3 +368,6 @@ buildNumber.properties
|
|||||||
# JDT-specific (Eclipse Java Development Tools)
|
# JDT-specific (Eclipse Java Development Tools)
|
||||||
.classpath
|
.classpath
|
||||||
|
|
||||||
|
# Local Maven repository used for sandbox compile verification
|
||||||
|
m2repo/
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
import api from './index'
|
import api from './index'
|
||||||
|
|
||||||
|
export interface SendVerificationCodeRequest {
|
||||||
|
phone: string
|
||||||
|
}
|
||||||
|
|
||||||
export interface LoginRequest {
|
export interface LoginRequest {
|
||||||
account: string
|
account: string
|
||||||
password: string
|
password: string
|
||||||
@@ -48,7 +52,17 @@ export interface RefreshTokenResponse {
|
|||||||
refreshToken: string
|
refreshToken: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface ResetPasswordRequest {
|
||||||
|
phone: string
|
||||||
|
verificationCode: string
|
||||||
|
newPassword: string
|
||||||
|
}
|
||||||
|
|
||||||
export const authApi = {
|
export const authApi = {
|
||||||
|
sendVerificationCode: (data: SendVerificationCodeRequest) => {
|
||||||
|
return api.post('/user/send-verification-code', data)
|
||||||
|
},
|
||||||
|
|
||||||
login: (data: LoginRequest) => {
|
login: (data: LoginRequest) => {
|
||||||
return api.post<LoginResponse>('/user/login', data)
|
return api.post<LoginResponse>('/user/login', data)
|
||||||
},
|
},
|
||||||
@@ -75,5 +89,9 @@ export const authApi = {
|
|||||||
|
|
||||||
getUserInfo: () => {
|
getUserInfo: () => {
|
||||||
return api.get<UserInfo>('/user/info')
|
return api.get<UserInfo>('/user/info')
|
||||||
|
},
|
||||||
|
|
||||||
|
resetPasswordByPhone: (data: ResetPasswordRequest) => {
|
||||||
|
return api.post('/user/reset-password-by-phone', data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -16,6 +16,11 @@ export const cartApi = {
|
|||||||
return api.delete(`/cart/remove/${productId}`)
|
return api.delete(`/cart/remove/${productId}`)
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// 批量从购物车移除作品
|
||||||
|
batchRemoveFromCart: (cartItemIds: number[]) => {
|
||||||
|
return api.post('/cart/batch-remove', cartItemIds)
|
||||||
|
},
|
||||||
|
|
||||||
// 更新购物车作品数量
|
// 更新购物车作品数量
|
||||||
updateCartQuantity: (item: CartItem) => {
|
updateCartQuantity: (item: CartItem) => {
|
||||||
return api.put('/cart/update', item)
|
return api.put('/cart/update', item)
|
||||||
|
|||||||
@@ -1,8 +1,14 @@
|
|||||||
import api from './index'
|
import api from './index'
|
||||||
|
|
||||||
|
interface OrderItem {
|
||||||
|
productId: number
|
||||||
|
quantity: number
|
||||||
|
artistId?: number
|
||||||
|
}
|
||||||
|
|
||||||
interface CreateOrderRequest {
|
interface CreateOrderRequest {
|
||||||
couponId?: number
|
couponId?: number
|
||||||
artistId?: number
|
items: OrderItem[]
|
||||||
}
|
}
|
||||||
|
|
||||||
export const orderApi = {
|
export const orderApi = {
|
||||||
@@ -36,5 +42,10 @@ export const orderApi = {
|
|||||||
return api.put(`/order/admin/process/${orderId}`, {}, {
|
return api.put(`/order/admin/process/${orderId}`, {}, {
|
||||||
params: { status }
|
params: { status }
|
||||||
})
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
// 美甲师查看自己的订单
|
||||||
|
getArtistOrders: () => {
|
||||||
|
return api.get('/order/artist/list')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,6 +57,12 @@ const router = createRouter({
|
|||||||
component: () => import('../views/OrderView.vue'),
|
component: () => import('../views/OrderView.vue'),
|
||||||
meta: { requiresAuth: true, hideNav: true, isAdmin: false }
|
meta: { requiresAuth: true, hideNav: true, isAdmin: false }
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: '/artist-orders',
|
||||||
|
name: 'artist-orders',
|
||||||
|
component: () => import('../views/ArtistOrderView.vue'),
|
||||||
|
meta: { requiresAuth: true, hideNav: true, isAdmin: false, permissionCode: 'order:artist:view' }
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: '/settings',
|
path: '/settings',
|
||||||
name: 'settings',
|
name: 'settings',
|
||||||
|
|||||||
@@ -340,6 +340,12 @@ const handleSendVerificationCode = async () => {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const phoneRegex = /^1[3-9]\d{9}$/
|
||||||
|
if (!phoneRegex.test(bindPhoneForm.phone)) {
|
||||||
|
message.error('手机号格式不正确')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await userApi.sendVerificationCode({ phone: bindPhoneForm.phone })
|
await userApi.sendVerificationCode({ phone: bindPhoneForm.phone })
|
||||||
message.success('验证码发送成功')
|
message.success('验证码发送成功')
|
||||||
@@ -357,6 +363,12 @@ const handleSendChangePhoneVerificationCode = async () => {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const phoneRegex = /^1[3-9]\d{9}$/
|
||||||
|
if (!phoneRegex.test(changePhoneForm.newPhone)) {
|
||||||
|
message.error('手机号格式不正确')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await userApi.sendVerificationCode({ phone: changePhoneForm.newPhone })
|
await userApi.sendVerificationCode({ phone: changePhoneForm.newPhone })
|
||||||
message.success('验证码发送成功')
|
message.success('验证码发送成功')
|
||||||
@@ -374,6 +386,12 @@ const handleSendChangePasswordVerificationCode = async () => {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const phoneRegex = /^1[3-9]\d{9}$/
|
||||||
|
if (!phoneRegex.test(userInfo.value.phone)) {
|
||||||
|
message.error('手机号格式不正确')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await userApi.sendVerificationCode({ phone: userInfo.value.phone })
|
await userApi.sendVerificationCode({ phone: userInfo.value.phone })
|
||||||
message.success('验证码发送成功')
|
message.success('验证码发送成功')
|
||||||
|
|||||||
@@ -303,6 +303,85 @@
|
|||||||
</div>
|
</div>
|
||||||
</a-form>
|
</a-form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- 忘记密码弹窗 -->
|
||||||
|
<a-modal
|
||||||
|
v-model:visible="forgotPasswordVisible"
|
||||||
|
title="忘记密码"
|
||||||
|
:footer="null"
|
||||||
|
width="90%"
|
||||||
|
:destroyOnClose="true"
|
||||||
|
>
|
||||||
|
<a-form
|
||||||
|
:model="forgotPasswordForm"
|
||||||
|
:rules="forgotPasswordRules"
|
||||||
|
@finish="handleResetPassword"
|
||||||
|
layout="vertical"
|
||||||
|
>
|
||||||
|
<a-form-item name="phone" label="手机号">
|
||||||
|
<a-input
|
||||||
|
v-model:value="forgotPasswordForm.phone"
|
||||||
|
placeholder="请输入绑定的手机号"
|
||||||
|
size="large"
|
||||||
|
>
|
||||||
|
<template #prefix>
|
||||||
|
<UserOutlined style="color: #999" />
|
||||||
|
</template>
|
||||||
|
</a-input>
|
||||||
|
</a-form-item>
|
||||||
|
|
||||||
|
<a-form-item name="verificationCode" label="验证码">
|
||||||
|
<a-input
|
||||||
|
v-model:value="forgotPasswordForm.verificationCode"
|
||||||
|
placeholder="请输入验证码"
|
||||||
|
size="large"
|
||||||
|
>
|
||||||
|
<template #prefix>
|
||||||
|
<LockOutlined style="color: #999" />
|
||||||
|
</template>
|
||||||
|
<template #suffix>
|
||||||
|
<a-button
|
||||||
|
type="link"
|
||||||
|
:disabled="forgotCountdown > 0 || !forgotPasswordForm.phone"
|
||||||
|
@click="handleSendForgotCode"
|
||||||
|
>
|
||||||
|
{{ forgotCountdown > 0 ? `${forgotCountdown}秒后重发` : '发送验证码' }}
|
||||||
|
</a-button>
|
||||||
|
</template>
|
||||||
|
</a-input>
|
||||||
|
</a-form-item>
|
||||||
|
|
||||||
|
<a-form-item name="newPassword" label="新密码">
|
||||||
|
<a-input-password
|
||||||
|
v-model:value="forgotPasswordForm.newPassword"
|
||||||
|
placeholder="请输入新密码"
|
||||||
|
size="large"
|
||||||
|
>
|
||||||
|
<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="resettingPassword"
|
||||||
|
>
|
||||||
|
重置密码
|
||||||
|
</a-button>
|
||||||
|
</a-form-item>
|
||||||
|
|
||||||
|
<a-form-item>
|
||||||
|
<a-button size="large" block @click="forgotPasswordVisible = false">
|
||||||
|
取消
|
||||||
|
</a-button>
|
||||||
|
</a-form-item>
|
||||||
|
</a-form>
|
||||||
|
</a-modal>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -327,6 +406,16 @@ const accountStatus = ref<any>(null)
|
|||||||
const phoneUserStatus = ref<any>(null)
|
const phoneUserStatus = ref<any>(null)
|
||||||
const countdown = ref(0)
|
const countdown = ref(0)
|
||||||
|
|
||||||
|
const forgotPasswordVisible = ref(false)
|
||||||
|
const forgotCountdown = ref(0)
|
||||||
|
const resettingPassword = ref(false)
|
||||||
|
|
||||||
|
const forgotPasswordForm = reactive({
|
||||||
|
phone: '',
|
||||||
|
verificationCode: '',
|
||||||
|
newPassword: ''
|
||||||
|
})
|
||||||
|
|
||||||
const formData = reactive({
|
const formData = reactive({
|
||||||
account: '',
|
account: '',
|
||||||
password: '',
|
password: '',
|
||||||
@@ -342,6 +431,14 @@ const validatePassword = async (_rule: any, value: string) => {
|
|||||||
if (value.length < 6) {
|
if (value.length < 6) {
|
||||||
return Promise.reject('密码长度不能少于6位')
|
return Promise.reject('密码长度不能少于6位')
|
||||||
}
|
}
|
||||||
|
let count = 0
|
||||||
|
if (/\d/.test(value)) count++
|
||||||
|
if (/[a-z]/.test(value)) count++
|
||||||
|
if (/[A-Z]/.test(value)) count++
|
||||||
|
if (/[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]/.test(value)) count++
|
||||||
|
if (count < 3) {
|
||||||
|
return Promise.reject('密码必须包含数字、小写字母、大写字母和符号中的至少3种')
|
||||||
|
}
|
||||||
return Promise.resolve()
|
return Promise.resolve()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -357,9 +454,7 @@ const validateConfirmPassword = async (_rule: any, value: string) => {
|
|||||||
|
|
||||||
const rules: Record<string, Rule[]> = {
|
const rules: Record<string, Rule[]> = {
|
||||||
account: [
|
account: [
|
||||||
{ required: true, message: '请输入账号', trigger: 'blur' },
|
{ required: true, message: '请输入账号', trigger: 'blur' }
|
||||||
{ min: 3, max: 50, message: '账号长度在3到50个字符', trigger: 'blur' },
|
|
||||||
{ pattern: /^[a-zA-Z0-9_\-@.]+$/, message: '账号只能包含数字、字母、下划线、连字符、@和点号', trigger: 'blur' }
|
|
||||||
],
|
],
|
||||||
phone: [
|
phone: [
|
||||||
{ required: true, message: '请输入手机号', trigger: 'blur' },
|
{ required: true, message: '请输入手机号', trigger: 'blur' },
|
||||||
@@ -379,13 +474,28 @@ const rules: Record<string, Rule[]> = {
|
|||||||
],
|
],
|
||||||
nickname: [
|
nickname: [
|
||||||
{ required: true, message: '请输入昵称', trigger: 'blur' },
|
{ required: true, message: '请输入昵称', trigger: 'blur' },
|
||||||
{ min: 2, max: 20, message: '昵称长度在2到20个字符', trigger: 'blur' }
|
{ min: 2, max: 20, message: '昵称长度在2到20个字符', trigger: 'blur' },
|
||||||
|
{ pattern: /^[\u4e00-\u9fa5a-zA-Z0-9_]+$/, message: '昵称不能包含特殊符号', trigger: 'blur' }
|
||||||
],
|
],
|
||||||
shopId: [
|
shopId: [
|
||||||
{ required: true, message: '请选择店铺', trigger: 'change' }
|
{ required: true, message: '请选择店铺', trigger: 'change' }
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const forgotPasswordRules: Record<string, Rule[]> = {
|
||||||
|
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' }
|
||||||
|
],
|
||||||
|
newPassword: [
|
||||||
|
{ required: true, message: '请输入新密码', trigger: 'blur' }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
const fetchShops = async () => {
|
const fetchShops = async () => {
|
||||||
loadingShops.value = true
|
loadingShops.value = true
|
||||||
try {
|
try {
|
||||||
@@ -474,7 +584,55 @@ const handleSubmit = async () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const handleForgotPassword = () => {
|
const handleForgotPassword = () => {
|
||||||
message.info('忘记密码功能开发中')
|
forgotPasswordVisible.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleSendForgotCode = async () => {
|
||||||
|
if (!forgotPasswordForm.phone) {
|
||||||
|
message.error('请输入手机号')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const phoneRegex = /^1[3-9]\d{9}$/
|
||||||
|
if (!phoneRegex.test(forgotPasswordForm.phone)) {
|
||||||
|
message.error('手机号格式不正确')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
await authApi.sendVerificationCode({ phone: forgotPasswordForm.phone })
|
||||||
|
message.success('验证码已发送')
|
||||||
|
forgotCountdown.value = 60
|
||||||
|
const timer = setInterval(() => {
|
||||||
|
forgotCountdown.value--
|
||||||
|
if (forgotCountdown.value <= 0) {
|
||||||
|
clearInterval(timer)
|
||||||
|
}
|
||||||
|
}, 1000)
|
||||||
|
} catch (error: any) {
|
||||||
|
message.error(error.response?.data?.message || '发送验证码失败')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleResetPassword = async () => {
|
||||||
|
resettingPassword.value = true
|
||||||
|
try {
|
||||||
|
await authApi.resetPasswordByPhone({
|
||||||
|
phone: forgotPasswordForm.phone,
|
||||||
|
verificationCode: forgotPasswordForm.verificationCode,
|
||||||
|
newPassword: forgotPasswordForm.newPassword
|
||||||
|
})
|
||||||
|
message.success('密码重置成功,请使用新密码登录')
|
||||||
|
forgotPasswordVisible.value = false
|
||||||
|
|
||||||
|
forgotPasswordForm.phone = ''
|
||||||
|
forgotPasswordForm.verificationCode = ''
|
||||||
|
forgotPasswordForm.newPassword = ''
|
||||||
|
} catch (error: any) {
|
||||||
|
message.error(error.response?.data?.message || '重置密码失败')
|
||||||
|
} finally {
|
||||||
|
resettingPassword.value = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleWeChatLogin = () => {
|
const handleWeChatLogin = () => {
|
||||||
@@ -542,6 +700,12 @@ const handleSendVerificationCode = async () => {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const phoneRegex = /^1[3-9]\d{9}$/
|
||||||
|
if (!phoneRegex.test(formData.phone)) {
|
||||||
|
message.error('手机号格式不正确')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await userApi.sendVerificationCode({ phone: formData.phone })
|
await userApi.sendVerificationCode({ phone: formData.phone })
|
||||||
message.success('验证码已发送')
|
message.success('验证码已发送')
|
||||||
|
|||||||
+144
-58
@@ -42,6 +42,18 @@
|
|||||||
<h3 class="item-name" @click="handleProductClick(item)" style="cursor: pointer;">{{ item.productTitle }}</h3>
|
<h3 class="item-name" @click="handleProductClick(item)" style="cursor: pointer;">{{ item.productTitle }}</h3>
|
||||||
<p class="item-price">¥{{ item.price.toFixed(2) }}</p>
|
<p class="item-price">¥{{ item.price.toFixed(2) }}</p>
|
||||||
|
|
||||||
|
<!-- 美甲师选择 -->
|
||||||
|
<div class="artist-selector" @click="showArtistSelection(item)">
|
||||||
|
<span v-if="item.artist" class="selected-artist">
|
||||||
|
<img v-if="item.artist.avatar" :src="item.artist.avatar" class="artist-avatar-small" />
|
||||||
|
<span class="artist-name">{{ item.artist.name }}</span>
|
||||||
|
</span>
|
||||||
|
<span v-else class="select-artist">
|
||||||
|
选择美甲师
|
||||||
|
</span>
|
||||||
|
<RightOutlined class="arrow-icon" />
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- 数量控制和删除按钮 -->
|
<!-- 数量控制和删除按钮 -->
|
||||||
<div class="item-actions">
|
<div class="item-actions">
|
||||||
<div class="quantity-control">
|
<div class="quantity-control">
|
||||||
@@ -83,7 +95,7 @@
|
|||||||
<div class="coupon-header" @click="showCouponModal = true">
|
<div class="coupon-header" @click="showCouponModal = true">
|
||||||
<span class="coupon-title">优惠券</span>
|
<span class="coupon-title">优惠券</span>
|
||||||
<div class="coupon-value">
|
<div class="coupon-value">
|
||||||
{{ selectedCoupon ? '已选择: ' + selectedCoupon.couponName : '请选择' }}
|
{{ selectedCoupon ? selectedCoupon.couponName : '使用优惠券' }}
|
||||||
<RightOutlined :style="{ marginLeft: '4px' }" />
|
<RightOutlined :style="{ marginLeft: '4px' }" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -122,14 +134,14 @@
|
|||||||
block
|
block
|
||||||
@click="handleCheckout"
|
@click="handleCheckout"
|
||||||
>
|
>
|
||||||
结算 ({{ selectedCount }}) - ¥{{ totalAmount.toFixed(2) }}
|
确认 {{ selectedCount }} 笔订单- 预计金额 ¥{{ totalAmount.toFixed(2) }}
|
||||||
</a-button>
|
</a-button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 优惠券选择弹窗 -->
|
<!-- 优惠券选择弹窗 -->
|
||||||
<a-modal
|
<a-modal
|
||||||
v-model:visible="showCouponModal"
|
v-model:visible="showCouponModal"
|
||||||
title="选择优惠券"
|
title="使用优惠券"
|
||||||
width="90%"
|
width="90%"
|
||||||
@ok="confirmCouponSelection"
|
@ok="confirmCouponSelection"
|
||||||
@cancel="cancelCouponSelection"
|
@cancel="cancelCouponSelection"
|
||||||
@@ -192,11 +204,10 @@
|
|||||||
<!-- 美甲师选择弹窗 -->
|
<!-- 美甲师选择弹窗 -->
|
||||||
<a-modal
|
<a-modal
|
||||||
v-model:visible="showArtistModal"
|
v-model:visible="showArtistModal"
|
||||||
title="选择美甲师"
|
:title='currentEditingItem ? `为"${currentEditingItem.productTitle}"选择美甲师` : "选择美甲师"'
|
||||||
width="90%"
|
width="90%"
|
||||||
@ok="selectArtistAndCheckout"
|
@ok="confirmArtistSelection"
|
||||||
@cancel="closeArtistModal"
|
@cancel="closeArtistModal"
|
||||||
|
|
||||||
>
|
>
|
||||||
<div class="artist-modal-content">
|
<div class="artist-modal-content">
|
||||||
<a-empty v-if="availableArtists.length === 0" description="暂无可用美甲师" />
|
<a-empty v-if="availableArtists.length === 0" description="暂无可用美甲师" />
|
||||||
@@ -206,8 +217,8 @@
|
|||||||
v-for="artist in availableArtists"
|
v-for="artist in availableArtists"
|
||||||
:key="artist.id"
|
:key="artist.id"
|
||||||
class="artist-item"
|
class="artist-item"
|
||||||
:class="{ 'selected': selectedArtist && selectedArtist.id === artist.id }"
|
:class="{ 'selected': currentEditingItem && currentEditingItem.artistId === artist.id }"
|
||||||
@click="toggleArtistSelection(artist)"
|
@click="selectArtist(artist)"
|
||||||
>
|
>
|
||||||
<div class="artist-card">
|
<div class="artist-card">
|
||||||
<div class="artist-avatar">
|
<div class="artist-avatar">
|
||||||
@@ -238,7 +249,7 @@
|
|||||||
<span class="skill-tag" v-for="skill in getArtistSkills(artist)" :key="skill">{{ skill }}</span>
|
<span class="skill-tag" v-for="skill in getArtistSkills(artist)" :key="skill">{{ skill }}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="artist-selection-indicator" v-if="selectedArtist && selectedArtist.id === artist.id">
|
<div class="artist-selection-indicator" v-if="currentEditingItem && currentEditingItem.artistId === artist.id">
|
||||||
<CheckCircleOutlined style="color: #1890ff; font-size: 20px;" />
|
<CheckCircleOutlined style="color: #1890ff; font-size: 20px;" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -283,6 +294,18 @@ interface CartItem {
|
|||||||
totalPrice: number
|
totalPrice: number
|
||||||
tags: string
|
tags: string
|
||||||
selected: boolean
|
selected: boolean
|
||||||
|
artistId?: number
|
||||||
|
artist?: {
|
||||||
|
id: number
|
||||||
|
name: string
|
||||||
|
avatar?: string
|
||||||
|
signature?: string
|
||||||
|
shopName?: string
|
||||||
|
status?: number
|
||||||
|
experience?: number
|
||||||
|
skills?: string
|
||||||
|
rating?: number
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
@@ -516,7 +539,7 @@ const cancelCouponSelection = () => {
|
|||||||
|
|
||||||
// 美甲师选择相关状态
|
// 美甲师选择相关状态
|
||||||
const showArtistModal = ref(false)
|
const showArtistModal = ref(false)
|
||||||
const selectedArtist = ref<{id: number, name: string, avatar?: string, signature?: string, shopName?: string, status?: number, experience?: number, skills?: string, rating?: number} | null>(null)
|
const currentEditingItem = ref<CartItem | null>(null)
|
||||||
const availableArtists = ref<{id: number, name: string, avatar?: string, signature?: string, shopName?: string, status?: number, experience?: number, skills?: string, rating?: number}[]>([])
|
const availableArtists = ref<{id: number, name: string, avatar?: string, signature?: string, shopName?: string, status?: number, experience?: number, skills?: string, rating?: number}[]>([])
|
||||||
// 标签列表
|
// 标签列表
|
||||||
const tagList = ref<TagVO[]>([])
|
const tagList = ref<TagVO[]>([])
|
||||||
@@ -592,28 +615,30 @@ const handleCheckout = async () => {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 加载可用美甲师
|
// 检查所有选中的作品是否都选择了美甲师
|
||||||
await loadAvailableArtists()
|
const itemsWithoutArtist = selectedItems.filter(item => !item.artistId)
|
||||||
|
if (itemsWithoutArtist.length > 0) {
|
||||||
// 显示美甲师选择弹窗
|
message.warning(`请为"${itemsWithoutArtist.map(item => item.productTitle).join('、')}"选择美甲师`)
|
||||||
showArtistModal.value = true
|
|
||||||
}
|
|
||||||
|
|
||||||
// 选择美甲师并创建订单
|
|
||||||
const selectArtistAndCheckout = async () => {
|
|
||||||
if (!selectedArtist.value) {
|
|
||||||
message.warning('请选择美甲师')
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 创建订单
|
||||||
try {
|
try {
|
||||||
await orderApi.createOrder({
|
await orderApi.createOrder({
|
||||||
couponId: selectedCoupon.value ? selectedCoupon.value.id : undefined,
|
couponId: selectedCoupon.value ? selectedCoupon.value.id : undefined,
|
||||||
artistId: selectedArtist.value.id
|
items: selectedItems.map(item => ({
|
||||||
|
productId: item.productId,
|
||||||
|
quantity: item.quantity,
|
||||||
|
artistId: item.artistId
|
||||||
|
}))
|
||||||
})
|
})
|
||||||
message.success('订单创建成功')
|
message.success('订单创建成功')
|
||||||
showArtistModal.value = false
|
// 从购物车中移除已购买的商品
|
||||||
// 更新购物车数量(因为订单创建后购物车会被清空)
|
const selectedIds = selectedItems.map(item => item.id)
|
||||||
|
await cartApi.batchRemoveFromCart(selectedIds)
|
||||||
|
// 更新购物车数据
|
||||||
|
await loadCartItems()
|
||||||
|
// 更新购物车数量
|
||||||
await updateCartCount()
|
await updateCartCount()
|
||||||
router.push('/profile')
|
router.push('/profile')
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -621,10 +646,31 @@ const selectArtistAndCheckout = async () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 显示美甲师选择弹窗
|
||||||
|
const showArtistSelection = (item: CartItem) => {
|
||||||
|
currentEditingItem.value = item
|
||||||
|
loadAvailableArtists()
|
||||||
|
showArtistModal.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
// 选择美甲师
|
||||||
|
const selectArtist = (artist: any) => {
|
||||||
|
if (currentEditingItem.value) {
|
||||||
|
currentEditingItem.value.artistId = artist.id
|
||||||
|
currentEditingItem.value.artist = artist
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 确认选择
|
||||||
|
const confirmArtistSelection = () => {
|
||||||
|
showArtistModal.value = false
|
||||||
|
currentEditingItem.value = null
|
||||||
|
}
|
||||||
|
|
||||||
// 关闭美甲师选择弹窗
|
// 关闭美甲师选择弹窗
|
||||||
const closeArtistModal = () => {
|
const closeArtistModal = () => {
|
||||||
showArtistModal.value = false
|
showArtistModal.value = false
|
||||||
selectedArtist.value = null
|
currentEditingItem.value = null
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取美甲师头像
|
// 获取美甲师头像
|
||||||
@@ -670,17 +716,6 @@ const getArtistSkills = (artist: any) => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 切换美甲师选择状态
|
|
||||||
const toggleArtistSelection = (artist: any) => {
|
|
||||||
if (selectedArtist.value && selectedArtist.value.id === artist.id) {
|
|
||||||
// 取消选择
|
|
||||||
selectedArtist.value = null
|
|
||||||
} else {
|
|
||||||
// 选择新的美甲师
|
|
||||||
selectedArtist.value = artist
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 监听选中作品变化,重新加载可用优惠券
|
// 监听选中作品变化,重新加载可用优惠券
|
||||||
watch(
|
watch(
|
||||||
() => cartItems.value.map(item => ({ id: item.id, selected: item.selected, quantity: item.quantity })),
|
() => cartItems.value.map(item => ({ id: item.id, selected: item.selected, quantity: item.quantity })),
|
||||||
@@ -807,6 +842,55 @@ onMounted(() => {
|
|||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.artist-selector {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
padding: 8px 12px;
|
||||||
|
background: #f8f9ff;
|
||||||
|
border-radius: 8px;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all 0.3s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.artist-selector:hover {
|
||||||
|
background: #e6f7ff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.selected-artist {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
color: #1890ff;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
.artist-avatar-small {
|
||||||
|
width: 24px;
|
||||||
|
height: 24px;
|
||||||
|
border-radius: 50%;
|
||||||
|
object-fit: cover;
|
||||||
|
}
|
||||||
|
|
||||||
|
.select-artist {
|
||||||
|
color: #999;
|
||||||
|
font-size: 13px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.arrow-icon {
|
||||||
|
color: #999;
|
||||||
|
font-size: 12px;
|
||||||
|
transition: transform 0.3s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.artist-selector:hover .arrow-icon {
|
||||||
|
transform: translateX(4px);
|
||||||
|
}
|
||||||
|
|
||||||
.item-duration {
|
.item-duration {
|
||||||
color: #666;
|
color: #666;
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
@@ -907,7 +991,7 @@ onMounted(() => {
|
|||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
padding: 18px 20px;
|
padding: 12px 16px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
background: linear-gradient(135deg, #f6f9ff 0%, #ffffff 100%);
|
background: linear-gradient(135deg, #f6f9ff 0%, #ffffff 100%);
|
||||||
border-bottom: 1px solid #e6f7ff;
|
border-bottom: 1px solid #e6f7ff;
|
||||||
@@ -918,29 +1002,29 @@ onMounted(() => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.coupon-title {
|
.coupon-title {
|
||||||
font-size: 16px;
|
font-size: 14px;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
color: #333;
|
color: #333;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 8px;
|
gap: 6px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.coupon-title::before {
|
.coupon-title::before {
|
||||||
content: "🎁";
|
content: "🎁";
|
||||||
font-size: 18px;
|
font-size: 14px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.coupon-value {
|
.coupon-value {
|
||||||
font-size: 13px;
|
font-size: 12px;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
color: #1890ff;
|
color: #1890ff;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 6px;
|
gap: 4px;
|
||||||
padding: 6px 12px;
|
padding: 4px 10px;
|
||||||
background: rgba(24, 144, 255, 0.1);
|
background: rgba(24, 144, 255, 0.1);
|
||||||
border-radius: 20px;
|
border-radius: 16px;
|
||||||
transition: all 0.3s ease;
|
transition: all 0.3s ease;
|
||||||
box-shadow: 0 1px 3px rgba(24, 144, 255, 0.2);
|
box-shadow: 0 1px 3px rgba(24, 144, 255, 0.2);
|
||||||
}
|
}
|
||||||
@@ -952,7 +1036,7 @@ onMounted(() => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.coupon-discount {
|
.coupon-discount {
|
||||||
padding: 14px 20px;
|
padding: 10px 16px;
|
||||||
background-color: #f0f9ff;
|
background-color: #f0f9ff;
|
||||||
border-top: 1px solid #e6f7ff;
|
border-top: 1px solid #e6f7ff;
|
||||||
display: flex;
|
display: flex;
|
||||||
@@ -961,20 +1045,20 @@ onMounted(() => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.discount-label {
|
.discount-label {
|
||||||
font-size: 14px;
|
font-size: 12px;
|
||||||
color: #666;
|
color: #666;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 6px;
|
gap: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.discount-label::before {
|
.discount-label::before {
|
||||||
content: "💰";
|
content: "💰";
|
||||||
font-size: 14px;
|
font-size: 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.discount-amount {
|
.discount-amount {
|
||||||
font-size: 18px;
|
font-size: 16px;
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
color: #1890ff;
|
color: #1890ff;
|
||||||
text-shadow: 0 1px 2px rgba(24, 144, 255, 0.3);
|
text-shadow: 0 1px 2px rgba(24, 144, 255, 0.3);
|
||||||
@@ -1014,15 +1098,17 @@ onMounted(() => {
|
|||||||
.coupon-content {
|
.coupon-content {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
padding: 16px;
|
padding: 10px;
|
||||||
gap: 16px;
|
gap: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.coupon-value {
|
.coupon-value {
|
||||||
font-size: 24px;
|
font-size: 18px;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
color: #ff4d4f;
|
color: #ff4d4f;
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
|
min-width: 50px;
|
||||||
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.coupon-info {
|
.coupon-info {
|
||||||
@@ -1031,29 +1117,29 @@ onMounted(() => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.coupon-name {
|
.coupon-name {
|
||||||
font-size: 15px;
|
font-size: 13px;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
color: #333;
|
color: #333;
|
||||||
margin-bottom: 4px;
|
margin-bottom: 2px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
.coupon-condition {
|
.coupon-condition {
|
||||||
font-size: 13px;
|
font-size: 11px;
|
||||||
color: #666;
|
color: #666;
|
||||||
margin-bottom: 4px;
|
margin-bottom: 2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.coupon-time {
|
.coupon-time {
|
||||||
font-size: 12px;
|
font-size: 10px;
|
||||||
color: #999;
|
color: #999;
|
||||||
}
|
}
|
||||||
|
|
||||||
.coupon-select {
|
.coupon-select {
|
||||||
color: #1890ff;
|
color: #1890ff;
|
||||||
font-size: 20px;
|
font-size: 16px;
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,6 +33,10 @@
|
|||||||
<div class="item-info">
|
<div class="item-info">
|
||||||
<div class="item-title">{{ item.productTitle }}</div>
|
<div class="item-title">{{ item.productTitle }}</div>
|
||||||
<div class="item-price">¥{{ item.price.toFixed(2) }} x {{ item.quantity }}</div>
|
<div class="item-price">¥{{ item.price.toFixed(2) }} x {{ item.quantity }}</div>
|
||||||
|
<div v-if="item.artistName" class="item-artist">
|
||||||
|
<img v-if="item.artistAvatar" :src="item.artistAvatar" class="artist-avatar-small" />
|
||||||
|
<span>美甲师: {{ item.artistName }}</span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -299,6 +303,21 @@ onMounted(() => {
|
|||||||
color: #666;
|
color: #666;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.item-artist {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 6px;
|
||||||
|
font-size: 12px;
|
||||||
|
color: #1890ff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.artist-avatar-small {
|
||||||
|
width: 20px;
|
||||||
|
height: 20px;
|
||||||
|
border-radius: 50%;
|
||||||
|
object-fit: cover;
|
||||||
|
}
|
||||||
|
|
||||||
.order-footer {
|
.order-footer {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<h1>{{ product.name || '作品详情' }}</h1>
|
<h1>{{ product.name || '作品详情' }}</h1>
|
||||||
<div class="actions">
|
<div class="actions">
|
||||||
<el-icon @click="handleFavoriteClick" :style="{ fontSize: '20px' }" :class="{ active: isFavorite }"><Star /></el-icon>
|
<el-icon @click="handleFavoriteClick" :style="{ fontSize: '20px' }" :class="{ active: isFavorite }"><StarFilled /></el-icon>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
@@ -115,7 +115,7 @@
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, onMounted, inject } from 'vue'
|
import { ref, onMounted, inject } from 'vue'
|
||||||
import { ArrowLeft, Star, Clock, Collection, ShoppingCart, Right } from '@element-plus/icons-vue'
|
import { ArrowLeft, StarFilled, Clock, Collection, ShoppingCart, Right } from '@element-plus/icons-vue'
|
||||||
import { Icon } from '@iconify/vue'
|
import { Icon } from '@iconify/vue'
|
||||||
import { useRouter, useRoute } from 'vue-router'
|
import { useRouter, useRoute } from 'vue-router'
|
||||||
import { ElMessage } from 'element-plus'
|
import { ElMessage } from 'element-plus'
|
||||||
@@ -388,7 +388,7 @@ onMounted(() => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.actions .el-icon.active {
|
.actions .el-icon.active {
|
||||||
color: #f56c6c;
|
color: #fadb14;
|
||||||
}
|
}
|
||||||
|
|
||||||
.product-image-container {
|
.product-image-container {
|
||||||
|
|||||||
@@ -36,7 +36,7 @@
|
|||||||
|
|
||||||
<!-- Empty Wishlist Message -->
|
<!-- Empty Wishlist Message -->
|
||||||
<div v-if="wishlistItems.length === 0" class="empty-wishlist">
|
<div v-if="wishlistItems.length === 0" class="empty-wishlist">
|
||||||
<el-icon :size="60"><Star /></el-icon>
|
<el-icon :size="60" :style="{ color: '#fadb14' }"><StarFilled /></el-icon>
|
||||||
<p>收藏列表为空</p>
|
<p>收藏列表为空</p>
|
||||||
<el-button type="primary" @click="handleBrowseProducts">
|
<el-button type="primary" @click="handleBrowseProducts">
|
||||||
浏览作品
|
浏览作品
|
||||||
@@ -47,7 +47,7 @@
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, onMounted } from 'vue'
|
import { ref, onMounted } from 'vue'
|
||||||
import { ArrowLeft, Delete, Star } from '@element-plus/icons-vue'
|
import { ArrowLeft, Delete, StarFilled } from '@element-plus/icons-vue'
|
||||||
import { useRouter } from 'vue-router'
|
import { useRouter } from 'vue-router'
|
||||||
import { ElMessage } from 'element-plus'
|
import { ElMessage } from 'element-plus'
|
||||||
import { wishlistApi, type WishlistItem } from '@/api/wishlist'
|
import { wishlistApi, type WishlistItem } from '@/api/wishlist'
|
||||||
|
|||||||
+19
-2
@@ -12,12 +12,12 @@
|
|||||||
|
|
||||||
<groupId>com.xiaowang</groupId>
|
<groupId>com.xiaowang</groupId>
|
||||||
<artifactId>YumiNail-Core</artifactId>
|
<artifactId>YumiNail-Core</artifactId>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>1.0.0</version>
|
||||||
<name>YumiNail-Core</name>
|
<name>YumiNail-Core</name>
|
||||||
<description>YumiNail-Core - 核心业务微服务</description>
|
<description>YumiNail-Core - 核心业务微服务</description>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<java.version>17</java.version>
|
<java.version>21</java.version>
|
||||||
<spring-cloud.version>2021.0.8</spring-cloud.version>
|
<spring-cloud.version>2021.0.8</spring-cloud.version>
|
||||||
<spring-cloud-alibaba.version>2021.0.5.0</spring-cloud-alibaba.version>
|
<spring-cloud-alibaba.version>2021.0.5.0</spring-cloud-alibaba.version>
|
||||||
<mybatis-plus.version>3.5.3.1</mybatis-plus.version>
|
<mybatis-plus.version>3.5.3.1</mybatis-plus.version>
|
||||||
@@ -193,6 +193,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.projectlombok</groupId>
|
<groupId>org.projectlombok</groupId>
|
||||||
<artifactId>lombok</artifactId>
|
<artifactId>lombok</artifactId>
|
||||||
|
<version>1.18.32</version>
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
@@ -243,6 +244,22 @@
|
|||||||
</excludes>
|
</excludes>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.8.1</version>
|
||||||
|
<configuration>
|
||||||
|
<source>17</source>
|
||||||
|
<target>17</target>
|
||||||
|
<annotationProcessorPaths>
|
||||||
|
<path>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
<version>1.18.30</version>
|
||||||
|
</path>
|
||||||
|
</annotationProcessorPaths>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package com.xiaowang.yuminailcore.config;
|
package com.xiaowang.yuminailcore.config;
|
||||||
|
|
||||||
|
import com.xiaowang.yuminailcore.entity.UserDO;
|
||||||
|
import com.xiaowang.yuminailcore.mapper.UserMapper;
|
||||||
import com.xiaowang.yuminailcore.utils.JwtUtil;
|
import com.xiaowang.yuminailcore.utils.JwtUtil;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
@@ -13,6 +15,7 @@ import javax.servlet.http.HttpServletResponse;
|
|||||||
public class AuthInterceptor implements HandlerInterceptor {
|
public class AuthInterceptor implements HandlerInterceptor {
|
||||||
|
|
||||||
private final JwtUtil jwtUtil;
|
private final JwtUtil jwtUtil;
|
||||||
|
private final UserMapper userMapper;
|
||||||
|
|
||||||
private static final String AUTHORIZATION_HEADER = "Authorization";
|
private static final String AUTHORIZATION_HEADER = "Authorization";
|
||||||
private static final String BEARER_PREFIX = "Bearer ";
|
private static final String BEARER_PREFIX = "Bearer ";
|
||||||
@@ -40,17 +43,37 @@ public class AuthInterceptor implements HandlerInterceptor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!jwtUtil.isAccessToken(token)) {
|
if (!jwtUtil.isAccessToken(token)) {
|
||||||
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
|
writeJsonResponse(response, HttpServletResponse.SC_UNAUTHORIZED, "Token类型错误");
|
||||||
response.setContentType("application/json;charset=UTF-8");
|
|
||||||
response.getWriter().write("{\"code\":401,\"message\":\"Token类型错误\"}");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Long userId = jwtUtil.getUserIdFromToken(token);
|
Long userId = jwtUtil.getUserIdFromToken(token);
|
||||||
String account = jwtUtil.getAccountFromToken(token);
|
String account = jwtUtil.getAccountFromToken(token);
|
||||||
|
UserDO currentUser = userMapper.selectById(userId);
|
||||||
|
if (currentUser == null || Integer.valueOf(1).equals(currentUser.getIsDelete())) {
|
||||||
|
writeJsonResponse(response, HttpServletResponse.SC_UNAUTHORIZED, "用户不存在或已失效");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isAdminPath(path) && (currentUser.getType() == null || currentUser.getType() < 2)) {
|
||||||
|
writeJsonResponse(response, HttpServletResponse.SC_FORBIDDEN, "无后台访问权限");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
request.setAttribute("userId", userId);
|
request.setAttribute("userId", userId);
|
||||||
request.setAttribute("account", account);
|
request.setAttribute("account", account);
|
||||||
|
request.setAttribute("userType", currentUser.getType());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isAdminPath(String path) {
|
||||||
|
return path.startsWith("/admin/") || path.startsWith("/order/admin/");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void writeJsonResponse(HttpServletResponse response, int status, String message) throws Exception {
|
||||||
|
response.setStatus(status);
|
||||||
|
response.setContentType("application/json;charset=UTF-8");
|
||||||
|
response.getWriter().write("{\"code\":" + status + ",\"message\":\"" + message + "\"}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,13 +21,11 @@ public class WebMvcConfig implements WebMvcConfigurer {
|
|||||||
"/user/refresh-token",
|
"/user/refresh-token",
|
||||||
"/user/send-verification-code",
|
"/user/send-verification-code",
|
||||||
"/user/phone-login",
|
"/user/phone-login",
|
||||||
|
"/user/reset-password-by-phone",
|
||||||
"/user/get/account/**",
|
"/user/get/account/**",
|
||||||
"/shop/list/simple",
|
"/shop/list/simple",
|
||||||
"/product/**",
|
|
||||||
"/tag/**",
|
|
||||||
"/file/**",
|
|
||||||
"/admin/auth/login",
|
"/admin/auth/login",
|
||||||
"/admin/object-storage-file/upload",
|
"/admin/auth/refresh",
|
||||||
"/error",
|
"/error",
|
||||||
"/health/**"
|
"/health/**"
|
||||||
);
|
);
|
||||||
|
|||||||
+1
-1
@@ -17,7 +17,7 @@ import java.util.List;
|
|||||||
* @date 2026-02-13
|
* @date 2026-02-13
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/api/balance-change-detail")
|
@RequestMapping({"/balance-change-detail", "/api/balance-change-detail"})
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class BalanceChangeDetailController {
|
public class BalanceChangeDetailController {
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -17,7 +17,7 @@ import java.util.List;
|
|||||||
* @date 2026-02-13
|
* @date 2026-02-13
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/api/balance")
|
@RequestMapping({"/balance", "/api/balance"})
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class BalanceController {
|
public class BalanceController {
|
||||||
|
|
||||||
|
|||||||
@@ -31,6 +31,13 @@ public class CartController {
|
|||||||
return Result.success();
|
return Result.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/batch-remove")
|
||||||
|
public Result<Void> batchRemoveFromCart(@RequestBody List<Long> cartItemIds, HttpServletRequest request) {
|
||||||
|
Long userId = (Long) request.getAttribute("userId");
|
||||||
|
cartService.batchRemoveFromCart(userId, cartItemIds);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
@PutMapping("/update")
|
@PutMapping("/update")
|
||||||
public Result<Void> updateCartQuantity(@RequestBody CartDTO cartDTO, HttpServletRequest request) {
|
public Result<Void> updateCartQuantity(@RequestBody CartDTO cartDTO, HttpServletRequest request) {
|
||||||
Long userId = (Long) request.getAttribute("userId");
|
Long userId = (Long) request.getAttribute("userId");
|
||||||
|
|||||||
+1
-1
@@ -17,7 +17,7 @@ import java.util.List;
|
|||||||
* @date 2026-02-13
|
* @date 2026-02-13
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/api/comment")
|
@RequestMapping({"/comment", "/api/comment"})
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class CommentController {
|
public class CommentController {
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -17,7 +17,7 @@ import java.util.List;
|
|||||||
* @date 2026-02-13
|
* @date 2026-02-13
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/api/effect-diagram")
|
@RequestMapping({"/effect-diagram", "/api/effect-diagram"})
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class EffectDiagramController {
|
public class EffectDiagramController {
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -17,7 +17,7 @@ import java.util.List;
|
|||||||
* @date 2026-02-13
|
* @date 2026-02-13
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/api/login-identity")
|
@RequestMapping({"/login-identity", "/api/login-identity"})
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class LoginIdentityController {
|
public class LoginIdentityController {
|
||||||
|
|
||||||
|
|||||||
@@ -59,4 +59,12 @@ public class OrderController {
|
|||||||
orderService.processOrder(orderId, status);
|
orderService.processOrder(orderId, status);
|
||||||
return Result.success();
|
return Result.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 美甲师查看自己的订单
|
||||||
|
@GetMapping("/artist/list")
|
||||||
|
public Result<List<OrderVO>> getArtistOrders(HttpServletRequest request) {
|
||||||
|
Long userId = (Long) request.getAttribute("userId");
|
||||||
|
List<OrderVO> orderList = orderService.getOrdersByArtistId(userId);
|
||||||
|
return Result.success(orderList);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+1
-1
@@ -19,7 +19,7 @@ import java.util.List;
|
|||||||
* @date 2026-02-25
|
* @date 2026-02-25
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/api/permission")
|
@RequestMapping({"/permission", "/api/permission"})
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class PermissionController {
|
public class PermissionController {
|
||||||
|
|
||||||
|
|||||||
+13
-9
@@ -1,15 +1,7 @@
|
|||||||
package com.xiaowang.yuminailcore.controller;
|
package com.xiaowang.yuminailcore.controller;
|
||||||
|
|
||||||
import com.xiaowang.yuminailcore.common.Result;
|
import com.xiaowang.yuminailcore.common.Result;
|
||||||
import com.xiaowang.yuminailcore.dto.BindEmailRequestDTO;
|
import com.xiaowang.yuminailcore.dto.*;
|
||||||
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.entity.UserDO;
|
import com.xiaowang.yuminailcore.entity.UserDO;
|
||||||
import com.xiaowang.yuminailcore.mapper.UserMapper;
|
import com.xiaowang.yuminailcore.mapper.UserMapper;
|
||||||
import com.xiaowang.yuminailcore.vo.LoginResponseVO;
|
import com.xiaowang.yuminailcore.vo.LoginResponseVO;
|
||||||
@@ -190,6 +182,18 @@ public class UserController {
|
|||||||
return Result.success(true);
|
return Result.success(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过手机号验证码重置密码
|
||||||
|
*
|
||||||
|
* @param resetPasswordRequestDTO 重置密码请求DTO
|
||||||
|
* @return 是否重置成功
|
||||||
|
*/
|
||||||
|
@PostMapping("/reset-password-by-phone")
|
||||||
|
public Result<Boolean> resetPasswordByPhone(@RequestBody ResetPasswordRequestDTO resetPasswordRequestDTO) {
|
||||||
|
boolean success = userService.resetPasswordByPhone(resetPasswordRequestDTO);
|
||||||
|
return Result.success(success);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 刷新Token
|
* 刷新Token
|
||||||
*
|
*
|
||||||
|
|||||||
+1
-1
@@ -17,7 +17,7 @@ import java.util.List;
|
|||||||
* @date 2026-02-13
|
* @date 2026-02-13
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/api/vip-benefit")
|
@RequestMapping({"/vip-benefit", "/api/vip-benefit"})
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class VipBenefitController {
|
public class VipBenefitController {
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -17,7 +17,7 @@ import java.util.List;
|
|||||||
* @date 2026-02-13
|
* @date 2026-02-13
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/api/vip-info")
|
@RequestMapping({"/vip-info", "/api/vip-info"})
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class VipInfoController {
|
public class VipInfoController {
|
||||||
|
|
||||||
|
|||||||
@@ -2,9 +2,23 @@ package com.xiaowang.yuminailcore.dto;
|
|||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 绑定邮箱请求 DTO
|
||||||
|
* 用于用户绑定邮箱账号
|
||||||
|
*
|
||||||
|
* @author xiaowang
|
||||||
|
* @date 2026-03-12
|
||||||
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class BindEmailRequestDTO {
|
public class BindEmailRequestDTO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 邮箱地址
|
||||||
|
*/
|
||||||
private String email;
|
private String email;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 验证码
|
||||||
|
*/
|
||||||
private String code;
|
private String code;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,9 +2,23 @@ package com.xiaowang.yuminailcore.dto;
|
|||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 绑定手机号请求 DTO
|
||||||
|
* 用于用户绑定手机号
|
||||||
|
*
|
||||||
|
* @author xiaowang
|
||||||
|
* @date 2026-03-12
|
||||||
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class BindPhoneRequestDTO {
|
public class BindPhoneRequestDTO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 手机号
|
||||||
|
*/
|
||||||
private String phone;
|
private String phone;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 验证码
|
||||||
|
*/
|
||||||
private String code;
|
private String code;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,8 +2,23 @@ package com.xiaowang.yuminailcore.dto;
|
|||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 购物车 DTO
|
||||||
|
* 用于购物车商品信息的传输
|
||||||
|
*
|
||||||
|
* @author xiaowang
|
||||||
|
* @date 2026-03-12
|
||||||
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class CartDTO {
|
public class CartDTO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 商品ID
|
||||||
|
*/
|
||||||
private Long productId;
|
private Long productId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 商品数量
|
||||||
|
*/
|
||||||
private Integer quantity;
|
private Integer quantity;
|
||||||
}
|
}
|
||||||
@@ -1,21 +1,36 @@
|
|||||||
package com.xiaowang.yuminailcore.dto;
|
package com.xiaowang.yuminailcore.dto;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 登录请求 DTO
|
* 登录请求 DTO
|
||||||
|
* 用于用户账号密码登录
|
||||||
*
|
*
|
||||||
* @author xiaowang
|
* @author xiaowang
|
||||||
* @date 2026-02-14
|
* @date 2026-02-14
|
||||||
*/
|
*/
|
||||||
@Data
|
@Getter
|
||||||
|
@Setter
|
||||||
public class LoginRequestDTO {
|
public class LoginRequestDTO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 账号
|
||||||
|
*/
|
||||||
private String account;
|
private String account;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 密码
|
||||||
|
*/
|
||||||
private String password;
|
private String password;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 记住我标志
|
||||||
|
*/
|
||||||
private Boolean rememberMe;
|
private Boolean rememberMe;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 店铺ID
|
||||||
|
*/
|
||||||
private Long shopId;
|
private Long shopId;
|
||||||
}
|
}
|
||||||
@@ -2,7 +2,25 @@ package com.xiaowang.yuminailcore.dto;
|
|||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单 DTO
|
||||||
|
* 用于订单创建请求
|
||||||
|
*
|
||||||
|
* @author xiaowang
|
||||||
|
* @date 2026-03-12
|
||||||
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class OrderDTO {
|
public class OrderDTO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 优惠券ID
|
||||||
|
*/
|
||||||
private Long couponId;
|
private Long couponId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单商品列表
|
||||||
|
*/
|
||||||
|
private List<OrderItemDTO> items;
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package com.xiaowang.yuminailcore.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单商品项 DTO
|
||||||
|
* 用于订单中的单个商品信息
|
||||||
|
*
|
||||||
|
* @author xiaowang
|
||||||
|
* @date 2026-03-12
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class OrderItemDTO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 商品ID
|
||||||
|
*/
|
||||||
|
private Long productId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 商品数量
|
||||||
|
*/
|
||||||
|
private Integer quantity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 美甲师ID
|
||||||
|
*/
|
||||||
|
private Long artistId;
|
||||||
|
}
|
||||||
@@ -4,6 +4,7 @@ import lombok.Data;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 刷新Token请求 DTO
|
* 刷新Token请求 DTO
|
||||||
|
* 用于刷新访问令牌
|
||||||
*
|
*
|
||||||
* @author xiaowang
|
* @author xiaowang
|
||||||
* @date 2026-02-14
|
* @date 2026-02-14
|
||||||
@@ -11,5 +12,8 @@ import lombok.Data;
|
|||||||
@Data
|
@Data
|
||||||
public class RefreshTokenRequestDTO {
|
public class RefreshTokenRequestDTO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 刷新令牌
|
||||||
|
*/
|
||||||
private String refreshToken;
|
private String refreshToken;
|
||||||
}
|
}
|
||||||
@@ -2,9 +2,28 @@ package com.xiaowang.yuminailcore.dto;
|
|||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更换手机号请求 DTO
|
||||||
|
* 用于用户更换绑定的手机号
|
||||||
|
*
|
||||||
|
* @author xiaowang
|
||||||
|
* @date 2026-03-12
|
||||||
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class UpdatePhoneRequestDTO {
|
public class UpdatePhoneRequestDTO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 原手机号
|
||||||
|
*/
|
||||||
private String oldPhone;
|
private String oldPhone;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新手机号
|
||||||
|
*/
|
||||||
private String newPhone;
|
private String newPhone;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 验证码
|
||||||
|
*/
|
||||||
private String verificationCode;
|
private String verificationCode;
|
||||||
}
|
}
|
||||||
@@ -3,10 +3,33 @@ package com.xiaowang.yuminailcore.dto;
|
|||||||
import com.xiaowang.yuminailcore.vo.ProductVO;
|
import com.xiaowang.yuminailcore.vo.ProductVO;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 收藏夹 DTO
|
||||||
|
* 用于收藏夹商品信息的传输
|
||||||
|
*
|
||||||
|
* @author xiaowang
|
||||||
|
* @date 2026-03-12
|
||||||
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class WishlistDTO {
|
public class WishlistDTO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 收藏记录ID
|
||||||
|
*/
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户ID
|
||||||
|
*/
|
||||||
private Long userId;
|
private Long userId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 商品ID
|
||||||
|
*/
|
||||||
private Long productId;
|
private Long productId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 商品详细信息
|
||||||
|
*/
|
||||||
private ProductVO product;
|
private ProductVO product;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import java.time.LocalDateTime;
|
|||||||
public class OrderDO extends BaseEntity {
|
public class OrderDO extends BaseEntity {
|
||||||
private String orderNo;
|
private String orderNo;
|
||||||
private Long userId;
|
private Long userId;
|
||||||
|
private Long shopId;
|
||||||
private BigDecimal totalAmount;
|
private BigDecimal totalAmount;
|
||||||
private BigDecimal actualAmount;
|
private BigDecimal actualAmount;
|
||||||
private Long couponId;
|
private Long couponId;
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ public class OrderItemDO extends BaseEntity {
|
|||||||
private Long productId;
|
private Long productId;
|
||||||
private Integer quantity;
|
private Integer quantity;
|
||||||
private BigDecimal price;
|
private BigDecimal price;
|
||||||
|
private Long artistId;
|
||||||
private LocalDateTime createTime;
|
private LocalDateTime createTime;
|
||||||
private LocalDateTime updateTime;
|
private LocalDateTime updateTime;
|
||||||
private Integer isDelete;
|
private Integer isDelete;
|
||||||
|
|||||||
@@ -5,7 +5,8 @@ import com.baomidou.mybatisplus.annotation.TableId;
|
|||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import lombok.Data;
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -15,8 +16,9 @@ import lombok.EqualsAndHashCode;
|
|||||||
* @author xiaowang
|
* @author xiaowang
|
||||||
* @date 2026-02-13
|
* @date 2026-02-13
|
||||||
*/
|
*/
|
||||||
@Data
|
@Getter
|
||||||
@EqualsAndHashCode(callSuper = false)
|
@Setter
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@TableName("t_user")
|
@TableName("t_user")
|
||||||
public class UserDO extends BaseEntity {
|
public class UserDO extends BaseEntity {
|
||||||
|
|
||||||
|
|||||||
@@ -15,4 +15,10 @@ public interface OrderMapper extends BaseMapper<OrderDO> {
|
|||||||
|
|
||||||
@Select("SELECT * FROM t_order WHERE order_no = #{orderNo}")
|
@Select("SELECT * FROM t_order WHERE order_no = #{orderNo}")
|
||||||
OrderDO selectByOrderNo(@Param("orderNo") String orderNo);
|
OrderDO selectByOrderNo(@Param("orderNo") String orderNo);
|
||||||
|
|
||||||
|
@Select("SELECT DISTINCT o.* FROM t_order o " +
|
||||||
|
"INNER JOIN t_order_item oi ON o.id = oi.order_id " +
|
||||||
|
"WHERE oi.artist_id = #{artistId} AND o.is_delete = 0 " +
|
||||||
|
"ORDER BY o.create_time DESC")
|
||||||
|
List<OrderDO> selectByArtistId(@Param("artistId") Long artistId);
|
||||||
}
|
}
|
||||||
@@ -8,6 +8,7 @@ import java.util.List;
|
|||||||
public interface CartService {
|
public interface CartService {
|
||||||
void addToCart(Long userId, CartDTO cartDTO);
|
void addToCart(Long userId, CartDTO cartDTO);
|
||||||
void removeFromCart(Long userId, Long productId);
|
void removeFromCart(Long userId, Long productId);
|
||||||
|
void batchRemoveFromCart(Long userId, List<Long> cartItemIds);
|
||||||
void updateCartQuantity(Long userId, CartDTO cartDTO);
|
void updateCartQuantity(Long userId, CartDTO cartDTO);
|
||||||
List<CartVO> getCartList(Long userId);
|
List<CartVO> getCartList(Long userId);
|
||||||
void clearCart(Long userId);
|
void clearCart(Long userId);
|
||||||
|
|||||||
@@ -12,4 +12,5 @@ public interface OrderService {
|
|||||||
void cancelOrder(Long orderId, Long userId);
|
void cancelOrder(Long orderId, Long userId);
|
||||||
void processOrder(Long orderId, Integer status);
|
void processOrder(Long orderId, Integer status);
|
||||||
List<OrderVO> getAllOrders();
|
List<OrderVO> getAllOrders();
|
||||||
|
List<OrderVO> getOrdersByArtistId(Long artistId);
|
||||||
}
|
}
|
||||||
@@ -6,6 +6,7 @@ import com.xiaowang.yuminailcore.dto.BindPhoneRequestDTO;
|
|||||||
import com.xiaowang.yuminailcore.dto.LoginRequestDTO;
|
import com.xiaowang.yuminailcore.dto.LoginRequestDTO;
|
||||||
import com.xiaowang.yuminailcore.dto.PhoneLoginRequestDTO;
|
import com.xiaowang.yuminailcore.dto.PhoneLoginRequestDTO;
|
||||||
import com.xiaowang.yuminailcore.dto.RegisterRequestDTO;
|
import com.xiaowang.yuminailcore.dto.RegisterRequestDTO;
|
||||||
|
import com.xiaowang.yuminailcore.dto.ResetPasswordRequestDTO;
|
||||||
import com.xiaowang.yuminailcore.dto.UpdatePhoneRequestDTO;
|
import com.xiaowang.yuminailcore.dto.UpdatePhoneRequestDTO;
|
||||||
import com.xiaowang.yuminailcore.dto.UserDTO;
|
import com.xiaowang.yuminailcore.dto.UserDTO;
|
||||||
import com.xiaowang.yuminailcore.entity.UserDO;
|
import com.xiaowang.yuminailcore.entity.UserDO;
|
||||||
@@ -53,6 +54,8 @@ public interface UserService extends IService<UserDO> {
|
|||||||
|
|
||||||
boolean resetPassword(Long targetUserId, Long currentUserId);
|
boolean resetPassword(Long targetUserId, Long currentUserId);
|
||||||
|
|
||||||
|
boolean resetPasswordByPhone(ResetPasswordRequestDTO resetPasswordRequestDTO);
|
||||||
|
|
||||||
PageResultVO<UserVO> pageUsers(Integer page, Integer size, String keyword, Long shopId, Integer type);
|
PageResultVO<UserVO> pageUsers(Integer page, Integer size, String keyword, Long shopId, Integer type);
|
||||||
|
|
||||||
boolean updateUserStatus(Long id, Integer status);
|
boolean updateUserStatus(Long id, Integer status);
|
||||||
|
|||||||
+13
@@ -61,6 +61,19 @@ public class CartServiceImpl implements CartService {
|
|||||||
cartMapper.delete(wrapper);
|
cartMapper.delete(wrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public void batchRemoveFromCart(Long userId, List<Long> cartItemIds) {
|
||||||
|
if (cartItemIds == null || cartItemIds.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
QueryWrapper<CartDO> wrapper = new QueryWrapper<>();
|
||||||
|
wrapper.eq("user_id", userId)
|
||||||
|
.in("id", cartItemIds)
|
||||||
|
.eq("is_delete", 0);
|
||||||
|
cartMapper.delete(wrapper);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public void updateCartQuantity(Long userId, CartDTO cartDTO) {
|
public void updateCartQuantity(Long userId, CartDTO cartDTO) {
|
||||||
|
|||||||
+87
-22
@@ -2,6 +2,7 @@ package com.xiaowang.yuminailcore.service.impl;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.xiaowang.yuminailcore.dto.OrderDTO;
|
import com.xiaowang.yuminailcore.dto.OrderDTO;
|
||||||
|
import com.xiaowang.yuminailcore.dto.OrderItemDTO;
|
||||||
import com.xiaowang.yuminailcore.entity.*;
|
import com.xiaowang.yuminailcore.entity.*;
|
||||||
import com.xiaowang.yuminailcore.mapper.*;
|
import com.xiaowang.yuminailcore.mapper.*;
|
||||||
import com.xiaowang.yuminailcore.service.OrderService;
|
import com.xiaowang.yuminailcore.service.OrderService;
|
||||||
@@ -38,38 +39,79 @@ public class OrderServiceImpl implements OrderService {
|
|||||||
@Resource
|
@Resource
|
||||||
private UserCouponMapper userCouponMapper;
|
private UserCouponMapper userCouponMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private UserMapper userMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public OrderVO createOrder(Long userId, OrderDTO orderDTO) {
|
public OrderVO createOrder(Long userId, OrderDTO orderDTO) {
|
||||||
// 获取购物车商品
|
// 获取订单项列表
|
||||||
List<CartDO> cartList = cartMapper.selectByUserId(userId);
|
List<OrderItemDTO> orderItemDTOs = orderDTO.getItems();
|
||||||
if (cartList.isEmpty()) {
|
if (orderItemDTOs == null || orderItemDTOs.isEmpty()) {
|
||||||
throw new RuntimeException("购物车为空");
|
throw new RuntimeException("订单项不能为空");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 计算总金额
|
// 计算总金额
|
||||||
BigDecimal totalAmount = BigDecimal.ZERO;
|
BigDecimal totalAmount = BigDecimal.ZERO;
|
||||||
List<OrderItemDO> orderItems = new ArrayList<>();
|
List<OrderItemDO> orderItems = new ArrayList<>();
|
||||||
|
Long shopId = null;
|
||||||
|
|
||||||
for (CartDO cart : cartList) {
|
for (OrderItemDTO orderItemDTO : orderItemDTOs) {
|
||||||
if (cart.getIsDelete() == 0) {
|
ProductDO product = productMapper.selectById(orderItemDTO.getProductId());
|
||||||
ProductDO product = productMapper.selectById(cart.getProductId());
|
if (product == null || product.getIsDelete() == 1) {
|
||||||
if (product != null && product.getIsDelete() == 0) {
|
throw new RuntimeException("商品不存在或已下架");
|
||||||
BigDecimal itemTotal = product.getPrice().multiply(new BigDecimal(cart.getQuantity()));
|
|
||||||
totalAmount = totalAmount.add(itemTotal);
|
|
||||||
|
|
||||||
// 创建订单商品
|
|
||||||
OrderItemDO orderItem = new OrderItemDO();
|
|
||||||
orderItem.setProductId(product.getId());
|
|
||||||
orderItem.setQuantity(cart.getQuantity());
|
|
||||||
orderItem.setPrice(product.getPrice());
|
|
||||||
orderItems.add(orderItem);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 验证美甲师
|
||||||
|
if (orderItemDTO.getArtistId() != null) {
|
||||||
|
UserDO artist = userMapper.selectById(orderItemDTO.getArtistId());
|
||||||
|
if (artist == null || artist.getIsDelete() == 1) {
|
||||||
|
throw new RuntimeException("美甲师不存在或已删除");
|
||||||
|
}
|
||||||
|
if (artist.getType() != 3) {
|
||||||
|
throw new RuntimeException("指定的用户不是美甲师");
|
||||||
|
}
|
||||||
|
if (artist.getStatus() == 0) {
|
||||||
|
throw new RuntimeException("美甲师已被禁用");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 验证商品是否可以被该美甲师预约
|
||||||
|
if (product.getBookableArtists() != null && !product.getBookableArtists().isEmpty()) {
|
||||||
|
String[] artistIds = product.getBookableArtists().split(",");
|
||||||
|
boolean isBookable = false;
|
||||||
|
for (String artistId : artistIds) {
|
||||||
|
if (artistId.trim().equals(orderItemDTO.getArtistId().toString())) {
|
||||||
|
isBookable = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!isBookable) {
|
||||||
|
throw new RuntimeException("该美甲师无法预约此商品");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new RuntimeException("请为每个商品选择美甲师");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置店铺ID(从第一个商品获取)
|
||||||
|
if (shopId == null) {
|
||||||
|
shopId = product.getShopId();
|
||||||
|
}
|
||||||
|
|
||||||
|
BigDecimal itemTotal = product.getPrice().multiply(new BigDecimal(orderItemDTO.getQuantity()));
|
||||||
|
totalAmount = totalAmount.add(itemTotal);
|
||||||
|
|
||||||
|
// 创建订单商品
|
||||||
|
OrderItemDO orderItem = new OrderItemDO();
|
||||||
|
orderItem.setProductId(product.getId());
|
||||||
|
orderItem.setQuantity(orderItemDTO.getQuantity());
|
||||||
|
orderItem.setPrice(product.getPrice());
|
||||||
|
orderItem.setArtistId(orderItemDTO.getArtistId());
|
||||||
|
orderItems.add(orderItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (totalAmount.compareTo(BigDecimal.ZERO) == 0) {
|
if (totalAmount.compareTo(BigDecimal.ZERO) == 0) {
|
||||||
throw new RuntimeException("购物车商品无效");
|
throw new RuntimeException("订单金额无效");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 处理优惠券
|
// 处理优惠券
|
||||||
@@ -117,6 +159,7 @@ public class OrderServiceImpl implements OrderService {
|
|||||||
OrderDO order = new OrderDO();
|
OrderDO order = new OrderDO();
|
||||||
order.setOrderNo(orderNo);
|
order.setOrderNo(orderNo);
|
||||||
order.setUserId(userId);
|
order.setUserId(userId);
|
||||||
|
order.setShopId(shopId);
|
||||||
order.setTotalAmount(totalAmount);
|
order.setTotalAmount(totalAmount);
|
||||||
order.setActualAmount(actualAmount);
|
order.setActualAmount(actualAmount);
|
||||||
order.setCouponId(couponId);
|
order.setCouponId(couponId);
|
||||||
@@ -131,9 +174,6 @@ public class OrderServiceImpl implements OrderService {
|
|||||||
orderItemMapper.insert(item);
|
orderItemMapper.insert(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 清空购物车
|
|
||||||
cartMapper.delete(new QueryWrapper<CartDO>().eq("user_id", userId).eq("is_delete", 0));
|
|
||||||
|
|
||||||
// 构建返回对象
|
// 构建返回对象
|
||||||
return buildOrderVO(order);
|
return buildOrderVO(order);
|
||||||
}
|
}
|
||||||
@@ -258,10 +298,24 @@ public class OrderServiceImpl implements OrderService {
|
|||||||
return orderVOList;
|
return orderVOList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<OrderVO> getOrdersByArtistId(Long artistId) {
|
||||||
|
List<OrderDO> orderList = orderMapper.selectByArtistId(artistId);
|
||||||
|
List<OrderVO> orderVOList = new ArrayList<>();
|
||||||
|
|
||||||
|
for (OrderDO order : orderList) {
|
||||||
|
orderVOList.add(buildOrderVO(order));
|
||||||
|
}
|
||||||
|
|
||||||
|
return orderVOList;
|
||||||
|
}
|
||||||
|
|
||||||
private OrderVO buildOrderVO(OrderDO order) {
|
private OrderVO buildOrderVO(OrderDO order) {
|
||||||
OrderVO orderVO = new OrderVO();
|
OrderVO orderVO = new OrderVO();
|
||||||
orderVO.setId(order.getId());
|
orderVO.setId(order.getId());
|
||||||
orderVO.setOrderNo(order.getOrderNo());
|
orderVO.setOrderNo(order.getOrderNo());
|
||||||
|
orderVO.setUserId(order.getUserId());
|
||||||
|
orderVO.setShopId(order.getShopId());
|
||||||
orderVO.setTotalAmount(order.getTotalAmount());
|
orderVO.setTotalAmount(order.getTotalAmount());
|
||||||
orderVO.setActualAmount(order.getActualAmount());
|
orderVO.setActualAmount(order.getActualAmount());
|
||||||
orderVO.setCouponId(order.getCouponId());
|
orderVO.setCouponId(order.getCouponId());
|
||||||
@@ -311,6 +365,17 @@ public class OrderServiceImpl implements OrderService {
|
|||||||
itemVO.setQuantity(item.getQuantity());
|
itemVO.setQuantity(item.getQuantity());
|
||||||
itemVO.setPrice(item.getPrice());
|
itemVO.setPrice(item.getPrice());
|
||||||
itemVO.setTotalPrice(item.getPrice().multiply(new BigDecimal(item.getQuantity())));
|
itemVO.setTotalPrice(item.getPrice().multiply(new BigDecimal(item.getQuantity())));
|
||||||
|
|
||||||
|
// 设置美甲师信息
|
||||||
|
if (item.getArtistId() != null) {
|
||||||
|
itemVO.setArtistId(item.getArtistId());
|
||||||
|
UserDO artist = userMapper.selectById(item.getArtistId());
|
||||||
|
if (artist != null) {
|
||||||
|
itemVO.setArtistName(artist.getNickname());
|
||||||
|
itemVO.setArtistAvatar(artist.getAvatar());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
orderItemVOs.add(itemVO);
|
orderItemVOs.add(itemVO);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+28
@@ -794,4 +794,32 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
|
|||||||
userDO.setUpdateTime(LocalDateTime.now());
|
userDO.setUpdateTime(LocalDateTime.now());
|
||||||
return userMapper.updateById(userDO) > 0;
|
return userMapper.updateById(userDO) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean resetPasswordByPhone(ResetPasswordRequestDTO resetPasswordRequestDTO) {
|
||||||
|
String phone = resetPasswordRequestDTO.getPhone();
|
||||||
|
String verificationCode = resetPasswordRequestDTO.getVerificationCode();
|
||||||
|
String newPassword = resetPasswordRequestDTO.getNewPassword();
|
||||||
|
|
||||||
|
// 验证验证码
|
||||||
|
String redisKey = "verification_code:" + phone;
|
||||||
|
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, phone);
|
||||||
|
UserDO userDO = userMapper.selectOne(wrapper);
|
||||||
|
|
||||||
|
if (userDO == null) {
|
||||||
|
throw new RuntimeException("未绑定手机号,请联系店员");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 更新密码
|
||||||
|
userDO.setPassword(passwordEncoder.encode(newPassword));
|
||||||
|
userDO.setUpdateTime(LocalDateTime.now());
|
||||||
|
return userMapper.updateById(userDO) > 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,4 +13,7 @@ public class OrderItemVO {
|
|||||||
private Integer quantity;
|
private Integer quantity;
|
||||||
private BigDecimal price;
|
private BigDecimal price;
|
||||||
private BigDecimal totalPrice;
|
private BigDecimal totalPrice;
|
||||||
|
private Long artistId;
|
||||||
|
private String artistName;
|
||||||
|
private String artistAvatar;
|
||||||
}
|
}
|
||||||
@@ -10,6 +10,8 @@ import java.util.List;
|
|||||||
public class OrderVO {
|
public class OrderVO {
|
||||||
private Long id;
|
private Long id;
|
||||||
private String orderNo;
|
private String orderNo;
|
||||||
|
private Long userId;
|
||||||
|
private Long shopId;
|
||||||
private BigDecimal totalAmount;
|
private BigDecimal totalAmount;
|
||||||
private BigDecimal actualAmount;
|
private BigDecimal actualAmount;
|
||||||
private Long couponId;
|
private Long couponId;
|
||||||
|
|||||||
@@ -656,3 +656,6 @@ CREATE TABLE t_product_like (
|
|||||||
|
|
||||||
CREATE INDEX idx_user_id_like ON t_product_like (user_id) COMMENT '按用户查询点赞的索引';
|
CREATE INDEX idx_user_id_like ON t_product_like (user_id) COMMENT '按用户查询点赞的索引';
|
||||||
CREATE INDEX idx_product_id_like ON t_product_like (product_id) COMMENT '按商品查询点赞的索引';
|
CREATE INDEX idx_product_id_like ON t_product_like (product_id) COMMENT '按商品查询点赞的索引';
|
||||||
|
|
||||||
|
|
||||||
|
ALTER TABLE t_order_item ADD COLUMN artist_id BIGINT UNSIGNED DEFAULT NULL COMMENT '关联美甲师ID' AFTER price;
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
<description>YumiNail-Gateway - 服务网关</description>
|
<description>YumiNail-Gateway - 服务网关</description>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<java.version>17</java.version>
|
<java.version>21</java.version>
|
||||||
<spring-cloud.version>2021.0.8</spring-cloud.version>
|
<spring-cloud.version>2021.0.8</spring-cloud.version>
|
||||||
<spring-cloud-alibaba.version>2021.0.5.0</spring-cloud-alibaba.version>
|
<spring-cloud-alibaba.version>2021.0.5.0</spring-cloud-alibaba.version>
|
||||||
</properties>
|
</properties>
|
||||||
@@ -105,6 +105,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.projectlombok</groupId>
|
<groupId>org.projectlombok</groupId>
|
||||||
<artifactId>lombok</artifactId>
|
<artifactId>lombok</artifactId>
|
||||||
|
<version>1.18.32</version>
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|||||||
+20
-34
@@ -17,6 +17,7 @@ import org.springframework.web.server.ServerWebExchange;
|
|||||||
import reactor.core.publisher.Mono;
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 全局认证过滤器
|
* 全局认证过滤器
|
||||||
@@ -29,6 +30,23 @@ import java.nio.charset.StandardCharsets;
|
|||||||
@Component
|
@Component
|
||||||
public class AuthGlobalFilter implements GlobalFilter, Ordered {
|
public class AuthGlobalFilter implements GlobalFilter, Ordered {
|
||||||
|
|
||||||
|
private static final List<String> DEFAULT_WHITELIST = List.of(
|
||||||
|
"/api/user/login",
|
||||||
|
"/api/user/register",
|
||||||
|
"/api/user/refresh-token",
|
||||||
|
"/api/user/send-verification-code",
|
||||||
|
"/api/user/phone-login",
|
||||||
|
"/api/user/reset-password-by-phone",
|
||||||
|
"/api/user/get/account/**",
|
||||||
|
"/api/shop/list/simple",
|
||||||
|
"/api/admin/auth/login",
|
||||||
|
"/api/admin/auth/refresh",
|
||||||
|
"/admin/api/auth/login",
|
||||||
|
"/admin/api/auth/refresh",
|
||||||
|
"/api/health/**",
|
||||||
|
"/api/error"
|
||||||
|
);
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private GatewayConfig gatewayConfig;
|
private GatewayConfig gatewayConfig;
|
||||||
|
|
||||||
@@ -39,34 +57,15 @@ public class AuthGlobalFilter implements GlobalFilter, Ordered {
|
|||||||
ServerHttpRequest request = exchange.getRequest();
|
ServerHttpRequest request = exchange.getRequest();
|
||||||
String path = request.getURI().getPath();
|
String path = request.getURI().getPath();
|
||||||
|
|
||||||
log.info("Gateway received request: {}", path);
|
if (isWhitelist(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);
|
|
||||||
boolean isWhitelist = isWhitelist(path);
|
|
||||||
log.info("Whitelist check result: {}", isWhitelist);
|
|
||||||
if (isWhitelist) {
|
|
||||||
log.info("Path is in whitelist, passing through directly");
|
|
||||||
return chain.filter(exchange);
|
return chain.filter(exchange);
|
||||||
}
|
}
|
||||||
log.info("Path is not in whitelist, need to check Token");
|
|
||||||
|
|
||||||
// 2. Token 校验
|
|
||||||
String token = request.getHeaders().getFirst("Authorization");
|
String token = request.getHeaders().getFirst("Authorization");
|
||||||
if (!StringUtils.hasText(token)) {
|
if (!StringUtils.hasText(token)) {
|
||||||
return unAuthorized(exchange, "未携带Token,拒绝访问");
|
return unAuthorized(exchange, "未携带Token,拒绝访问");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. 双 Token 校验模式
|
|
||||||
// accessToken 用于 API 访问,refreshToken 用于刷新 accessToken
|
|
||||||
// 这里只验证 accessToken 是否存在,具体验证由后端服务处理
|
|
||||||
if (!token.startsWith("Bearer ")) {
|
if (!token.startsWith("Bearer ")) {
|
||||||
return unAuthorized(exchange, "Token格式错误");
|
return unAuthorized(exchange, "Token格式错误");
|
||||||
}
|
}
|
||||||
@@ -78,7 +77,6 @@ public class AuthGlobalFilter implements GlobalFilter, Ordered {
|
|||||||
* 判断是否在白名单中
|
* 判断是否在白名单中
|
||||||
*/
|
*/
|
||||||
private boolean isWhitelist(String path) {
|
private boolean isWhitelist(String path) {
|
||||||
// 首先检查配置文件中的白名单
|
|
||||||
if (gatewayConfig.getWhitelist() != null) {
|
if (gatewayConfig.getWhitelist() != null) {
|
||||||
for (String whitelistPath : gatewayConfig.getWhitelist()) {
|
for (String whitelistPath : gatewayConfig.getWhitelist()) {
|
||||||
if (pathMatcher.match(whitelistPath, path)) {
|
if (pathMatcher.match(whitelistPath, path)) {
|
||||||
@@ -87,19 +85,7 @@ public class AuthGlobalFilter implements GlobalFilter, Ordered {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 硬编码白名单作为备用
|
return DEFAULT_WHITELIST.stream().anyMatch(pattern -> pathMatcher.match(pattern, path));
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -89,6 +89,7 @@ spring:
|
|||||||
- RewritePath=/api/(?<remaining>.*), /${remaining}
|
- RewritePath=/api/(?<remaining>.*), /${remaining}
|
||||||
# 后台管理API路由(/api/admin/** 格式)
|
# 后台管理API路由(/api/admin/** 格式)
|
||||||
- id: admin-api-route
|
- id: admin-api-route
|
||||||
|
order: -10
|
||||||
uri: lb://yumi-nail-core
|
uri: lb://yumi-nail-core
|
||||||
predicates:
|
predicates:
|
||||||
- Path=/api/admin/**
|
- Path=/api/admin/**
|
||||||
@@ -96,8 +97,35 @@ spring:
|
|||||||
- RewritePath=/api/admin/(?<remaining>.*), /admin/${remaining}
|
- RewritePath=/api/admin/(?<remaining>.*), /admin/${remaining}
|
||||||
# 后台管理API路由(/admin/api/** 格式)
|
# 后台管理API路由(/admin/api/** 格式)
|
||||||
- id: admin-route
|
- id: admin-route
|
||||||
|
order: -9
|
||||||
uri: lb://yumi-nail-core
|
uri: lb://yumi-nail-core
|
||||||
predicates:
|
predicates:
|
||||||
- Path=/admin/api/**
|
- Path=/admin/api/**
|
||||||
filters:
|
filters:
|
||||||
- RewritePath=/admin/api/(?<remaining>.*), /admin/${remaining}
|
- RewritePath=/admin/api/(?<remaining>.*), /admin/${remaining}
|
||||||
|
# 前台API兜底路由,避免 Core 新增模块后 Gateway 未同步导致 404
|
||||||
|
- id: frontend-fallback-route
|
||||||
|
order: 100
|
||||||
|
uri: lb://yumi-nail-core
|
||||||
|
predicates:
|
||||||
|
- Path=/api/**
|
||||||
|
filters:
|
||||||
|
- RewritePath=/api/(?<remaining>.*), /${remaining}
|
||||||
|
|
||||||
|
yuminail:
|
||||||
|
gateway:
|
||||||
|
whitelist:
|
||||||
|
- /api/user/login
|
||||||
|
- /api/user/register
|
||||||
|
- /api/user/refresh-token
|
||||||
|
- /api/user/send-verification-code
|
||||||
|
- /api/user/phone-login
|
||||||
|
- /api/user/reset-password-by-phone
|
||||||
|
- /api/user/get/account/**
|
||||||
|
- /api/shop/list/simple
|
||||||
|
- /api/health/**
|
||||||
|
- /api/error
|
||||||
|
- /api/admin/auth/login
|
||||||
|
- /api/admin/auth/refresh
|
||||||
|
- /admin/api/auth/login
|
||||||
|
- /admin/api/auth/refresh
|
||||||
|
|||||||
Reference in New Issue
Block a user