完善了新增商品功能,将标签、美甲师和优惠券的输入方式改为下拉选择,并支持多选
## 1. 修复选择店铺后报错的问题
- 修改了 fetchArtists 方法,将 res 改为 res?.list ,因为后端返回的是分页数据结构,这样就不会再出现 Cannot read properties of undefined (reading '__asyncLoader') 错误。
## 2. 完善表单验证规则
- 在 formRules 中添加了标签和美甲师的必填验证规则,确保:
- 店铺是必填的
- 标签是必填的
- 美甲师是必填的
- 优惠券是可选的
## 3. 实现标签分店铺的功能
- 修改后端代码 :
- 修改了 TagDO 实体类,添加了 shopId 字段
- 修改了 TagDTO 和 TagVO 类,添加了 shopId 字段
- 修改了 TagService 接口,添加了 listTagsByShopId 方法
- 修改了 TagServiceImpl 实现类,添加了 listTagsByShopId 方法的实现
- 修改了 TagController 类,添加了 /list/by-shop/{shopId} 接口
- 修改前端代码 :
- 在 adminTagApi 中添加了 listTagsByShopId 方法
- 修改了 fetchTags 方法,添加了根据店铺ID获取标签的功能
- 修改了 watch 监听器,当选择店铺时,同时获取该店铺的标签和美甲师
## 4. 实现美甲师分店铺的功能
- 确保美甲师列表是根据选择的店铺动态加载的,只显示当前店铺的美甲师
This commit is contained in:
@@ -316,4 +316,25 @@ export const permissionApi = {
|
||||
}
|
||||
}
|
||||
|
||||
export const adminTagApi = {
|
||||
listAllTags: () => {
|
||||
return adminApi.get<any[]>('/tag/list/all')
|
||||
},
|
||||
listTagsByShopId: (shopId: number) => {
|
||||
return adminApi.get<any[]>('/tag/list/by-shop/' + shopId)
|
||||
}
|
||||
}
|
||||
|
||||
export const adminArtistApi = {
|
||||
listArtists: (shopId?: number) => {
|
||||
return adminApi.get<UserVO[]>('/admin/user/list', { params: { shopId, type: 3 } })
|
||||
}
|
||||
}
|
||||
|
||||
export const adminCouponApi = {
|
||||
listAllCoupons: () => {
|
||||
return adminApi.get<any[]>('/coupon/list/all')
|
||||
}
|
||||
}
|
||||
|
||||
export default adminApi
|
||||
@@ -100,52 +100,13 @@
|
||||
:rows="3"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="商品图片">
|
||||
<a-upload
|
||||
v-model:file-list="imageFileList"
|
||||
list-type="picture-card"
|
||||
:custom-request="handleUploadImage"
|
||||
:before-upload="beforeUpload"
|
||||
@preview="handlePreview"
|
||||
@remove="handleRemove"
|
||||
:max-count="5"
|
||||
>
|
||||
<div v-if="imageFileList.length < 5">
|
||||
<plus-outlined />
|
||||
<div style="margin-top: 8px">上传图片</div>
|
||||
</div>
|
||||
</a-upload>
|
||||
<a-modal v-model:open="previewVisible" :footer="null" @cancel="previewVisible = false">
|
||||
<img alt="预览" style="width: 100%" :src="previewImage" />
|
||||
</a-modal>
|
||||
</a-form-item>
|
||||
<a-form-item label="价格" name="price">
|
||||
<a-input-number
|
||||
v-model:value="formState.price"
|
||||
:min="0"
|
||||
:precision="2"
|
||||
style="width: 100%"
|
||||
placeholder="请输入价格"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="预计时长" name="approximateDuration">
|
||||
<a-input v-model:value="formState.approximateDuration" placeholder="例如:30分钟" />
|
||||
</a-form-item>
|
||||
<a-form-item label="标签ID" name="tags">
|
||||
<a-input v-model:value="formState.tags" placeholder="请输入标签ID,多个用分号分隔" />
|
||||
</a-form-item>
|
||||
<a-form-item label="可预约美甲师ID" name="bookableArtists">
|
||||
<a-input v-model:value="formState.bookableArtists" placeholder="请输入美甲师ID,多个用逗号分隔" />
|
||||
</a-form-item>
|
||||
<a-form-item label="可用优惠券ID" name="availableCoupons">
|
||||
<a-input v-model:value="formState.availableCoupons" placeholder="请输入优惠券ID,多个用逗号分隔" />
|
||||
</a-form-item>
|
||||
<a-form-item label="店铺" name="shopId">
|
||||
<a-select
|
||||
v-model:value="formState.shopId"
|
||||
placeholder="请选择店铺"
|
||||
style="width: 100%"
|
||||
:loading="loadingShops"
|
||||
:disabled="!isAdmin && formState.shopId"
|
||||
>
|
||||
<a-select-option
|
||||
v-if="shops.length === 0"
|
||||
@@ -163,18 +124,128 @@
|
||||
</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
<template v-if="formState.shopId">
|
||||
<a-form-item label="商品图片">
|
||||
<a-upload
|
||||
v-model:file-list="imageFileList"
|
||||
list-type="picture-card"
|
||||
:custom-request="handleUploadImage"
|
||||
:before-upload="beforeUpload"
|
||||
@preview="handlePreview"
|
||||
@remove="handleRemove"
|
||||
:max-count="5"
|
||||
>
|
||||
<div v-if="imageFileList.length < 5">
|
||||
<plus-outlined />
|
||||
<div style="margin-top: 8px">上传图片</div>
|
||||
</div>
|
||||
</a-upload>
|
||||
<a-modal v-model:open="previewVisible" :footer="null" @cancel="previewVisible = false">
|
||||
<img alt="预览" style="width: 100%" :src="previewImage" />
|
||||
</a-modal>
|
||||
</a-form-item>
|
||||
<a-form-item label="价格" name="price">
|
||||
<a-input-number
|
||||
v-model:value="formState.price"
|
||||
:min="0"
|
||||
:precision="2"
|
||||
style="width: 100%"
|
||||
placeholder="请输入价格"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="预计时长" name="approximateDuration">
|
||||
<a-input-number
|
||||
v-model:value="formState.approximateDuration"
|
||||
placeholder="请输入分钟数"
|
||||
:min="1"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="标签" name="tags">
|
||||
<a-select
|
||||
v-model:value="formState.tags"
|
||||
mode="multiple"
|
||||
placeholder="请选择标签"
|
||||
style="width: 100%"
|
||||
:loading="loadingTags"
|
||||
>
|
||||
<a-select-option
|
||||
v-if="tags.length === 0"
|
||||
disabled
|
||||
value=""
|
||||
>
|
||||
暂无标签数据
|
||||
</a-select-option>
|
||||
<a-select-option
|
||||
v-for="tag in tags"
|
||||
:key="tag.id"
|
||||
:value="tag.id.toString()"
|
||||
>
|
||||
{{ tag.tagName }}
|
||||
</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
<a-form-item label="可预约美甲师" name="bookableArtists">
|
||||
<a-select
|
||||
v-model:value="formState.bookableArtists"
|
||||
mode="multiple"
|
||||
placeholder="请选择美甲师"
|
||||
style="width: 100%"
|
||||
:loading="loadingArtists"
|
||||
>
|
||||
<a-select-option
|
||||
v-if="artists.length === 0"
|
||||
disabled
|
||||
value=""
|
||||
>
|
||||
暂无美甲师数据
|
||||
</a-select-option>
|
||||
<a-select-option
|
||||
v-for="artist in artists"
|
||||
:key="artist.id"
|
||||
:value="artist.id.toString()"
|
||||
>
|
||||
{{ artist.nickname }}
|
||||
</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
<a-form-item label="可用优惠券" name="availableCoupons">
|
||||
<a-select
|
||||
v-model:value="formState.availableCoupons"
|
||||
mode="multiple"
|
||||
placeholder="请选择优惠券"
|
||||
style="width: 100%"
|
||||
:loading="loadingCoupons"
|
||||
>
|
||||
<a-select-option
|
||||
v-if="coupons.length === 0"
|
||||
disabled
|
||||
value=""
|
||||
>
|
||||
暂无优惠券数据
|
||||
</a-select-option>
|
||||
<a-select-option
|
||||
v-for="coupon in coupons"
|
||||
:key="coupon.id"
|
||||
:value="coupon.id.toString()"
|
||||
>
|
||||
{{ coupon.name }}
|
||||
</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
</template>
|
||||
</a-form>
|
||||
</a-modal>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, onMounted } from 'vue'
|
||||
import { ref, reactive, onMounted, watch } from 'vue'
|
||||
import { message } from 'ant-design-vue'
|
||||
import type { FormInstance, UploadProps } from 'ant-design-vue'
|
||||
import { PlusOutlined } from '@ant-design/icons-vue'
|
||||
import { DEFAULT_PRODUCT_IMAGE } from '@/constants'
|
||||
import { adminProductApi, type Product, adminShopApi, type Shop, adminFileApi, type ObjectStorageFileVO } from '@/api/admin'
|
||||
import { adminProductApi, type Product, adminShopApi, type Shop, adminFileApi, type ObjectStorageFileVO, adminTagApi, adminArtistApi, adminCouponApi } from '@/api/admin'
|
||||
|
||||
const loading = ref(false)
|
||||
const searchText = ref('')
|
||||
@@ -182,16 +253,23 @@ const productList = ref<Product[]>([])
|
||||
const modalVisible = ref(false)
|
||||
const modalLoading = ref(false)
|
||||
const isEdit = ref(false)
|
||||
const formRef = ref<FormInstance>()
|
||||
const currentProduct = ref<Product | null>(null)
|
||||
const shops = ref<Shop[]>([])
|
||||
const loadingShops = ref(false)
|
||||
const tags = ref<any[]>([])
|
||||
const loadingTags = ref(false)
|
||||
const artists = ref<any[]>([])
|
||||
const loadingArtists = ref(false)
|
||||
const coupons = ref<any[]>([])
|
||||
const loadingCoupons = ref(false)
|
||||
const previewVisible = ref(false)
|
||||
const previewImage = ref('')
|
||||
const imageFileList = ref<any[]>([])
|
||||
const uploadedFileIds = ref<string[]>([])
|
||||
const imageUrls = ref<Record<number, string[]>>({})
|
||||
const imageIdCache = ref<Record<string, string>>({})
|
||||
const isAdmin = ref(false)
|
||||
const formRef = ref<any>(null)
|
||||
|
||||
const pagination = reactive({
|
||||
current: 1,
|
||||
@@ -203,22 +281,24 @@ const pagination = reactive({
|
||||
})
|
||||
|
||||
const formState = reactive({
|
||||
shopId: undefined as number | undefined,
|
||||
shopId: undefined,
|
||||
title: '',
|
||||
description: '',
|
||||
imageFileIds: '',
|
||||
price: 0,
|
||||
tags: '',
|
||||
approximateDuration: '',
|
||||
bookableArtists: '',
|
||||
availableCoupons: ''
|
||||
tags: [] as string[],
|
||||
approximateDuration: undefined,
|
||||
bookableArtists: [] as string[],
|
||||
availableCoupons: [] as string[]
|
||||
})
|
||||
|
||||
const formRules = {
|
||||
title: [{ required: true, message: '请输入商品名称', trigger: 'blur' }],
|
||||
description: [{ required: true, message: '请输入商品描述', trigger: 'blur' }],
|
||||
price: [{ required: true, message: '请输入价格', trigger: 'blur' }],
|
||||
shopId: [{ required: true, message: '请选择店铺', trigger: 'change' }]
|
||||
shopId: [{ required: true, message: '请选择店铺', trigger: 'change' }],
|
||||
tags: [{ required: true, message: '请选择标签', trigger: 'change' }],
|
||||
bookableArtists: [{ required: true, message: '请选择美甲师', trigger: 'change' }]
|
||||
}
|
||||
|
||||
const columns = [
|
||||
@@ -237,7 +317,10 @@ const getCurrentUserInfo = () => {
|
||||
try {
|
||||
const userInfoStr = localStorage.getItem('adminUserInfo')
|
||||
if (userInfoStr) {
|
||||
return JSON.parse(userInfoStr)
|
||||
const userInfo = JSON.parse(userInfoStr)
|
||||
// 判断用户是否为管理员(类型为4)
|
||||
isAdmin.value = userInfo.type === 4
|
||||
return userInfo
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取当前用户信息失败', error)
|
||||
@@ -249,11 +332,17 @@ const fetchShops = async () => {
|
||||
loadingShops.value = true
|
||||
try {
|
||||
const res = await adminShopApi.listAllShops()
|
||||
shops.value = res || []
|
||||
|
||||
const currentUser = getCurrentUserInfo()
|
||||
|
||||
// 根据用户权限控制店铺列表的显示
|
||||
if (currentUser && currentUser.type !== 4 && currentUser.shopId) {
|
||||
// 如果是店长,只显示用户所属的店铺
|
||||
shops.value = res?.filter(shop => shop.id === currentUser.shopId) || []
|
||||
// 默认选择用户所属的店铺,并且不可修改
|
||||
formState.shopId = currentUser.shopId
|
||||
} else {
|
||||
// 如果是管理员,显示所有店铺
|
||||
shops.value = res || []
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取店铺列表失败', error)
|
||||
@@ -263,6 +352,50 @@ const fetchShops = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
const fetchTags = async (shopId?: number) => {
|
||||
loadingTags.value = true
|
||||
try {
|
||||
let res
|
||||
if (shopId) {
|
||||
res = await adminTagApi.listTagsByShopId(shopId)
|
||||
} else {
|
||||
res = await adminTagApi.listAllTags()
|
||||
}
|
||||
tags.value = res || []
|
||||
} catch (error) {
|
||||
console.error('获取标签列表失败', error)
|
||||
message.error('获取标签列表失败')
|
||||
} finally {
|
||||
loadingTags.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const fetchArtists = async (shopId?: number) => {
|
||||
loadingArtists.value = true
|
||||
try {
|
||||
const res = await adminArtistApi.listArtists(shopId)
|
||||
artists.value = res?.list || []
|
||||
} catch (error) {
|
||||
console.error('获取美甲师列表失败', error)
|
||||
message.error('获取美甲师列表失败')
|
||||
} finally {
|
||||
loadingArtists.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const fetchCoupons = async () => {
|
||||
loadingCoupons.value = true
|
||||
try {
|
||||
const res = await adminCouponApi.listAllCoupons()
|
||||
coupons.value = res || []
|
||||
} catch (error) {
|
||||
console.error('获取优惠券列表失败', error)
|
||||
message.error('获取优惠券列表失败')
|
||||
} finally {
|
||||
loadingCoupons.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const fetchProductList = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
@@ -337,35 +470,50 @@ const handleTableChange = (pag: any) => {
|
||||
const showAddModal = () => {
|
||||
isEdit.value = false
|
||||
const currentUser = getCurrentUserInfo()
|
||||
const shopId = (currentUser && currentUser.type !== 4 && currentUser.shopId) ? currentUser.shopId : undefined
|
||||
Object.assign(formState, {
|
||||
shopId: (currentUser && currentUser.type !== 4 && currentUser.shopId) ? currentUser.shopId : undefined,
|
||||
shopId: shopId,
|
||||
title: '',
|
||||
description: '',
|
||||
imageFileIds: '',
|
||||
price: 0,
|
||||
tags: '',
|
||||
tags: [],
|
||||
approximateDuration: '',
|
||||
bookableArtists: '',
|
||||
availableCoupons: ''
|
||||
bookableArtists: [],
|
||||
availableCoupons: []
|
||||
})
|
||||
imageFileList.value = []
|
||||
uploadedFileIds.value = []
|
||||
// 如果有店铺ID,获取该店铺的美甲师列表
|
||||
if (shopId) {
|
||||
fetchArtists(shopId)
|
||||
}
|
||||
modalVisible.value = true
|
||||
}
|
||||
|
||||
const showEditModal = async (record: Product) => {
|
||||
isEdit.value = true
|
||||
currentProduct.value = record
|
||||
|
||||
// 处理标签
|
||||
const tagsArray = record.tags ? record.tags.split(';').filter(tag => tag) : []
|
||||
// 处理美甲师
|
||||
const artistsArray = record.bookableArtists ? record.bookableArtists.split(',').filter(artist => artist) : []
|
||||
// 处理优惠券
|
||||
const couponsArray = record.availableCoupons ? record.availableCoupons.split(',').filter(coupon => coupon) : []
|
||||
// 处理预计时长,将字符串转换为数字
|
||||
const durationNumber = record.approximateDuration ? parseInt(record.approximateDuration.replace('分钟', '')) : undefined
|
||||
|
||||
Object.assign(formState, {
|
||||
shopId: record.shopId,
|
||||
title: record.title,
|
||||
description: record.description,
|
||||
imageFileIds: record.imageFileIds,
|
||||
price: record.price,
|
||||
tags: record.tags,
|
||||
approximateDuration: record.approximateDuration,
|
||||
bookableArtists: record.bookableArtists,
|
||||
availableCoupons: record.availableCoupons
|
||||
tags: tagsArray,
|
||||
approximateDuration: durationNumber,
|
||||
bookableArtists: artistsArray,
|
||||
availableCoupons: couponsArray
|
||||
})
|
||||
|
||||
if (record.imageFileIds) {
|
||||
@@ -402,6 +550,12 @@ const showEditModal = async (record: Product) => {
|
||||
imageFileList.value = []
|
||||
uploadedFileIds.value = []
|
||||
}
|
||||
|
||||
// 获取该店铺的美甲师列表
|
||||
if (record.shopId) {
|
||||
await fetchArtists(record.shopId)
|
||||
}
|
||||
|
||||
modalVisible.value = true
|
||||
}
|
||||
|
||||
@@ -460,11 +614,30 @@ const handleModalOk = async () => {
|
||||
await formRef.value?.validate()
|
||||
modalLoading.value = true
|
||||
|
||||
// 处理标签,转换为分号分隔的字符串
|
||||
const tagsString = Array.isArray(formState.tags) ? formState.tags.join(';') : formState.tags
|
||||
// 处理美甲师,转换为逗号分隔的字符串
|
||||
const artistsString = Array.isArray(formState.bookableArtists) ? formState.bookableArtists.join(',') : formState.bookableArtists
|
||||
// 处理优惠券,转换为逗号分隔的字符串
|
||||
const couponsString = Array.isArray(formState.availableCoupons) ? formState.availableCoupons.join(',') : formState.availableCoupons
|
||||
// 处理预计时长,转换为字符串并添加"分钟"单位
|
||||
const durationString = formState.approximateDuration ? `${formState.approximateDuration}分钟` : ''
|
||||
|
||||
// 准备请求数据
|
||||
const requestData = {
|
||||
...formState,
|
||||
imageFileIds: uploadedFileIds.value.join(','),
|
||||
tags: tagsString,
|
||||
bookableArtists: artistsString,
|
||||
availableCoupons: couponsString,
|
||||
approximateDuration: durationString
|
||||
}
|
||||
|
||||
if (isEdit.value && currentProduct.value) {
|
||||
await adminProductApi.updateProduct(currentProduct.value.id, formState)
|
||||
await adminProductApi.updateProduct(currentProduct.value.id, requestData)
|
||||
message.success('更新成功')
|
||||
} else {
|
||||
await adminProductApi.createProduct(formState)
|
||||
await adminProductApi.createProduct(requestData)
|
||||
message.success('创建成功')
|
||||
}
|
||||
|
||||
@@ -498,8 +671,21 @@ const handleDelete = async (record: Product) => {
|
||||
|
||||
onMounted(() => {
|
||||
fetchShops()
|
||||
fetchTags()
|
||||
fetchCoupons()
|
||||
fetchProductList()
|
||||
})
|
||||
|
||||
// 监听店铺选择变化,获取对应的标签和美甲师列表
|
||||
watch(() => formState.shopId, (newShopId) => {
|
||||
if (newShopId) {
|
||||
fetchTags(newShopId)
|
||||
fetchArtists(newShopId)
|
||||
} else {
|
||||
tags.value = []
|
||||
artists.value = []
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
+3
-2
@@ -23,9 +23,10 @@ public class AdminUserController {
|
||||
@RequestParam(defaultValue = "1") Integer page,
|
||||
@RequestParam(defaultValue = "10") Integer size,
|
||||
@RequestParam(required = false) String keyword,
|
||||
@RequestParam(required = false) Long shopId
|
||||
@RequestParam(required = false) Long shopId,
|
||||
@RequestParam(required = false) Integer type
|
||||
) {
|
||||
PageResultVO<UserVO> result = userService.pageUsers(page, size, keyword, shopId);
|
||||
PageResultVO<UserVO> result = userService.pageUsers(page, size, keyword, shopId, type);
|
||||
return Result.success(result);
|
||||
}
|
||||
|
||||
|
||||
@@ -83,6 +83,18 @@ public class TagController {
|
||||
return Result.success(tagVOs);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据店铺ID查询标签
|
||||
*
|
||||
* @param shopId 店铺ID
|
||||
* @return 标签VO列表
|
||||
*/
|
||||
@GetMapping("/list/by-shop/{shopId}")
|
||||
public Result<List<TagVO>> listTagsByShopId(@PathVariable Long shopId) {
|
||||
List<TagVO> tagVOs = tagService.listTagsByShopId(shopId);
|
||||
return Result.success(tagVOs);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据标签名称查询标签
|
||||
*
|
||||
|
||||
@@ -31,4 +31,9 @@ public class TagDTO {
|
||||
* 标签边框颜色(16进制)
|
||||
*/
|
||||
private String borderColor;
|
||||
|
||||
/**
|
||||
* 店铺ID
|
||||
*/
|
||||
private Long shopId;
|
||||
}
|
||||
|
||||
@@ -46,4 +46,10 @@ public class TagDO extends BaseEntity {
|
||||
*/
|
||||
@TableField("is_delete")
|
||||
private Integer isDelete;
|
||||
|
||||
/**
|
||||
* 店铺ID
|
||||
*/
|
||||
@TableField("shop_id")
|
||||
private Long shopId;
|
||||
}
|
||||
|
||||
@@ -63,4 +63,12 @@ public interface TagService extends IService<TagDO> {
|
||||
* @return 标签VO
|
||||
*/
|
||||
TagVO getTagByTagName(String tagName);
|
||||
|
||||
/**
|
||||
* 根据店铺ID查询标签
|
||||
*
|
||||
* @param shopId 店铺ID
|
||||
* @return 标签VO列表
|
||||
*/
|
||||
List<TagVO> listTagsByShopId(Long shopId);
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ public interface UserService extends IService<UserDO> {
|
||||
|
||||
boolean resetPassword(Long targetUserId, Long currentUserId);
|
||||
|
||||
PageResultVO<UserVO> pageUsers(Integer page, Integer size, String keyword, Long shopId);
|
||||
PageResultVO<UserVO> pageUsers(Integer page, Integer size, String keyword, Long shopId, Integer type);
|
||||
|
||||
boolean updateUserStatus(Long id, Integer status);
|
||||
|
||||
|
||||
+19
-1
@@ -33,6 +33,7 @@ public class TagServiceImpl extends ServiceImpl<TagMapper, TagDO> implements Tag
|
||||
tagDO.setTextColor(tagDTO.getTextColor());
|
||||
tagDO.setBgColor(tagDTO.getBgColor());
|
||||
tagDO.setBorderColor(tagDTO.getBorderColor());
|
||||
tagDO.setShopId(tagDTO.getShopId());
|
||||
tagDO.setIsDelete(0);
|
||||
tagMapper.insert(tagDO);
|
||||
return tagDO.getId();
|
||||
@@ -48,6 +49,7 @@ public class TagServiceImpl extends ServiceImpl<TagMapper, TagDO> implements Tag
|
||||
tagDO.setTextColor(tagDTO.getTextColor());
|
||||
tagDO.setBgColor(tagDTO.getBgColor());
|
||||
tagDO.setBorderColor(tagDTO.getBorderColor());
|
||||
tagDO.setShopId(tagDTO.getShopId());
|
||||
return tagMapper.updateById(tagDO) > 0;
|
||||
}
|
||||
|
||||
@@ -72,7 +74,22 @@ public class TagServiceImpl extends ServiceImpl<TagMapper, TagDO> implements Tag
|
||||
|
||||
@Override
|
||||
public List<TagVO> listAllTags() {
|
||||
List<TagDO> tagDOs = tagMapper.selectList(null);
|
||||
List<TagDO> tagDOs = tagMapper.selectList(
|
||||
Wrappers.lambdaQuery(TagDO.class)
|
||||
.eq(TagDO::getIsDelete, 0)
|
||||
);
|
||||
return tagDOs.stream()
|
||||
.map(this::convertToVO)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TagVO> listTagsByShopId(Long shopId) {
|
||||
List<TagDO> tagDOs = tagMapper.selectList(
|
||||
Wrappers.lambdaQuery(TagDO.class)
|
||||
.eq(TagDO::getIsDelete, 0)
|
||||
.eq(TagDO::getShopId, shopId)
|
||||
);
|
||||
return tagDOs.stream()
|
||||
.map(this::convertToVO)
|
||||
.collect(Collectors.toList());
|
||||
@@ -103,6 +120,7 @@ public class TagServiceImpl extends ServiceImpl<TagMapper, TagDO> implements Tag
|
||||
tagVO.setTextColor(tagDO.getTextColor());
|
||||
tagVO.setBgColor(tagDO.getBgColor());
|
||||
tagVO.setBorderColor(tagDO.getBorderColor());
|
||||
tagVO.setShopId(tagDO.getShopId());
|
||||
tagVO.setCreateTime(tagDO.getCreateTime());
|
||||
tagVO.setUpdateTime(tagDO.getUpdateTime());
|
||||
return tagVO;
|
||||
|
||||
+4
-1
@@ -429,7 +429,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResultVO<UserVO> pageUsers(Integer page, Integer size, String keyword, Long shopId) {
|
||||
public PageResultVO<UserVO> pageUsers(Integer page, Integer size, String keyword, Long shopId, Integer type) {
|
||||
Page<UserDO> pageParam = new Page<>(page, size);
|
||||
|
||||
LambdaQueryWrapper<UserDO> wrapper = Wrappers.lambdaQuery(UserDO.class);
|
||||
@@ -442,6 +442,9 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
|
||||
if (shopId != null && shopId > 0) {
|
||||
wrapper.eq(UserDO::getShopId, shopId);
|
||||
}
|
||||
if (type != null && type > 0) {
|
||||
wrapper.eq(UserDO::getType, type);
|
||||
}
|
||||
wrapper.orderByDesc(UserDO::getCreateTime);
|
||||
|
||||
Page<UserDO> userPage = userMapper.selectPage(pageParam, wrapper);
|
||||
|
||||
@@ -48,4 +48,9 @@ public class TagVO {
|
||||
* 更新时间
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 店铺ID
|
||||
*/
|
||||
private Long shopId;
|
||||
}
|
||||
|
||||
@@ -1,242 +1,334 @@
|
||||
-- 商品信息表:存储商品的基础属性、关联资源及统计数据
|
||||
CREATE TABLE `t_product` (
|
||||
`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '商品唯一主键ID(雪花id)',
|
||||
`shop_id` BIGINT UNSIGNED NOT NULL COMMENT '所属店铺ID,关联店铺表主键',
|
||||
`title` VARCHAR(100) NOT NULL COMMENT '商品标题',
|
||||
`description` TEXT COMMENT '商品描述',
|
||||
`image_file_ids` TEXT COMMENT '图片文件ID集合,多个ID以逗号分隔',
|
||||
`price` DECIMAL(10,2) NOT NULL COMMENT '商品价格,保留2位小数',
|
||||
`tags` VARCHAR(512) DEFAULT '' COMMENT '标签集合,多个标签以逗号分隔,最多5个',
|
||||
`like_count` INT UNSIGNED DEFAULT 0 COMMENT '商品点赞数',
|
||||
`collect_count` INT UNSIGNED DEFAULT 0 COMMENT '商品收藏数',
|
||||
`approximate_duration` VARCHAR(50) DEFAULT '' COMMENT '商品对应的服务大约耗时(如“30分钟”)',
|
||||
`bookable_artists` VARCHAR(200) DEFAULT '' COMMENT '可预约的美甲师ID集合,多个ID以逗号分隔',
|
||||
`available_coupons` TEXT COMMENT '可用的优惠券ID集合,多个ID以逗号分隔',
|
||||
`create_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '商品创建时间',
|
||||
`update_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '商品信息最后更新时间',
|
||||
`is_delete` TINYINT UNSIGNED DEFAULT 0 COMMENT '逻辑删除标识:0-未删除,1-已删除',
|
||||
-- 主键及索引配置
|
||||
PRIMARY KEY (`id`) COMMENT '商品主键索引',
|
||||
INDEX `idx_shop_id` (`shop_id`) COMMENT '按所属店铺查询商品的索引',
|
||||
INDEX `idx_title` (`title`) COMMENT '商品标题搜索的索引',
|
||||
INDEX `idx_price` (`price`) COMMENT '按价格筛选商品的索引',
|
||||
INDEX `idx_tags` (`tags`) COMMENT '按标签筛选商品的索引'
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='商品信息表';
|
||||
-- 用户余额信息表
|
||||
create table t_balance
|
||||
(
|
||||
id bigint unsigned auto_increment comment '余额记录唯一主键ID(雪花ID)'
|
||||
primary key comment '余额表主键索引',
|
||||
user_id bigint unsigned not null comment '关联用户表主键',
|
||||
amount decimal(10, 2) default 0.00 not null comment '当前余额',
|
||||
create_time datetime default CURRENT_TIMESTAMP not null comment '余额账户创建时间',
|
||||
last_update_time datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '最近一次更新时间',
|
||||
constraint uk_user_id
|
||||
unique (user_id) comment '用户余额唯一索引(一个用户对应一条余额记录)'
|
||||
)
|
||||
comment '用户余额信息表';
|
||||
-- 用户余额变动明细表
|
||||
create table t_balance_change_detail
|
||||
(
|
||||
id bigint unsigned auto_increment comment '变动记录唯一主键ID(雪花ID)'
|
||||
primary key comment '余额变动明细主键索引',
|
||||
user_id bigint unsigned not null comment '关联用户表主键',
|
||||
amount decimal(10, 2) not null comment '本次变动金额(正数为增加,负数为减少)',
|
||||
type varchar(20) not null comment '变动类型(如充值、消费、退款)',
|
||||
current_balance decimal(10, 2) not null comment '变动后的当前余额',
|
||||
change_time datetime default CURRENT_TIMESTAMP not null comment '变动时间'
|
||||
)
|
||||
comment '用户余额变动明细表';
|
||||
|
||||
-- 商品效果图信息表:存储商品对应的效果图信息
|
||||
CREATE TABLE `t_effect_diagram` (
|
||||
`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '效果图唯一主键ID(雪花id)',
|
||||
`product_id` BIGINT UNSIGNED NOT NULL COMMENT '所属商品ID,关联商品表主键',
|
||||
`category` VARCHAR(50) DEFAULT '' COMMENT '效果图类别',
|
||||
`image_file_ids` TEXT COMMENT '图片文件ID集合,多ID以逗号分隔',
|
||||
`description` TEXT COMMENT '效果图描述',
|
||||
`price` DECIMAL(10,2) DEFAULT 0.00 COMMENT '效果图对应服务价格',
|
||||
`duration` VARCHAR(50) DEFAULT '' COMMENT '效果图对应服务耗时',
|
||||
`tag` VARCHAR(50) DEFAULT '' COMMENT '效果图标签',
|
||||
`like_count` INT UNSIGNED DEFAULT 0 COMMENT '效果图点赞数',
|
||||
`create_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`update_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
`is_delete` TINYINT UNSIGNED DEFAULT 0 COMMENT '逻辑删除:0-未删,1-已删',
|
||||
-- 主键及索引配置
|
||||
PRIMARY KEY (`id`) COMMENT '效果图主键索引',
|
||||
INDEX `idx_product_id` (`product_id`) COMMENT '按商品查询效果图的索引'
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='商品效果图信息表';
|
||||
create index idx_change_time
|
||||
on t_balance_change_detail (change_time)
|
||||
comment '按时间查询余额变动的索引';
|
||||
|
||||
-- 店铺信息表:存储店铺基础信息
|
||||
CREATE TABLE `t_shop` (
|
||||
`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '店铺唯一主键ID',
|
||||
`shop_name` VARCHAR(100) NOT NULL COMMENT '店铺名称',
|
||||
`description` TEXT COMMENT '店铺描述',
|
||||
`address` VARCHAR(200) NOT NULL COMMENT '店铺地址',
|
||||
`business_hours` VARCHAR(100) DEFAULT '' COMMENT '店铺营业时间',
|
||||
`cover_image_file_id` VARCHAR(50) DEFAULT '' COMMENT '店铺封面图文件ID',
|
||||
`create_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`update_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
`is_delete` TINYINT UNSIGNED DEFAULT 0 COMMENT '逻辑删除:0-未删,1-已删',
|
||||
-- 主键及索引配置
|
||||
PRIMARY KEY (`id`) COMMENT '店铺主键索引',
|
||||
INDEX `idx_shop_name` (`shop_name`) COMMENT '按店铺名称查询的索引'
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='店铺信息表';
|
||||
create index idx_user_id
|
||||
on t_balance_change_detail (user_id)
|
||||
comment '按用户查询余额变动的索引';
|
||||
|
||||
-- 系统用户信息表:存储系统用户信息(含店长、美甲师、管理员等角色)
|
||||
CREATE TABLE `t_user` (
|
||||
`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '用户唯一主键ID(雪花ID)',
|
||||
`shop_id` BIGINT UNSIGNED DEFAULT 0 COMMENT '所属店铺ID,关联店铺表主键(0表示无所属店铺)',
|
||||
`nickname` VARCHAR(50) NOT NULL COMMENT '用户昵称',
|
||||
`account` VARCHAR(50) NOT NULL COMMENT '用户账号(登录用)',
|
||||
`password` VARCHAR(100) NOT NULL COMMENT '用户密码(加密存储)',
|
||||
`avatar` VARCHAR(512) NOT NULL COMMENT '头像',
|
||||
`signature` VARCHAR(200) DEFAULT '' COMMENT '用户签名',
|
||||
`level` VARCHAR(20) DEFAULT '普通' COMMENT '用户等级',
|
||||
`type` tinyint NOT NULL COMMENT '用户类型,(0-用户,2-店长,3-美甲师,4-管理员)',
|
||||
`vip_id` BIGINT UNSIGNED DEFAULT 0 COMMENT '关联VIP信息表主键(0表示非VIP)',
|
||||
`create_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`update_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
`is_delete` TINYINT UNSIGNED DEFAULT 0 COMMENT '逻辑删除:0-未删,1-已删',
|
||||
-- 主键及索引配置
|
||||
PRIMARY KEY (`id`) COMMENT '用户主键索引',
|
||||
UNIQUE INDEX `uk_account` (`account`) COMMENT '用户账号唯一索引',
|
||||
INDEX `idx_shop_id` (`shop_id`) COMMENT '按店铺查询用户的索引',
|
||||
INDEX `idx_type` (`type`) COMMENT '按用户类型查询的索引'
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='系统用户信息表';
|
||||
-- 用户评论信息表
|
||||
create table t_comment
|
||||
(
|
||||
id bigint unsigned auto_increment comment '评论唯一主键ID(雪花ID)'
|
||||
primary key comment '评论主键索引',
|
||||
user_id bigint unsigned not null comment '评论用户ID,关联用户表主键',
|
||||
shop_id bigint unsigned default 0 null comment '关联店铺表主键(0表示非店铺评论)',
|
||||
product_id bigint unsigned default 0 null comment '关联商品表主键(0表示非商品评论)',
|
||||
comment_content text not null comment '评论内容',
|
||||
parent_comment_id bigint unsigned default 0 null comment '父级评论ID(0表示为根评论)',
|
||||
like_count int unsigned default 0 null comment '评论点赞数',
|
||||
create_time datetime default CURRENT_TIMESTAMP not null comment '评论创建时间',
|
||||
update_time datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '评论更新时间',
|
||||
is_delete tinyint unsigned default 0 null comment '逻辑删除标识:0-未删除,1-已删除'
|
||||
)
|
||||
comment '用户评论信息表';
|
||||
|
||||
-- 用户登录标识信息表:存储用户登录相关标识信息
|
||||
CREATE TABLE `t_login_identity` (
|
||||
`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '登录标识唯一主键ID(雪花id)',
|
||||
`user_id` BIGINT UNSIGNED NOT NULL COMMENT '关联用户表主键',
|
||||
`login_method` VARCHAR(50) NOT NULL COMMENT '登录方式(0-手机号、1-账号、2-邮箱)',
|
||||
`input_value` VARCHAR(100) NOT NULL COMMENT '前端输入的具体值(如手机号、账号、邮箱)',
|
||||
`input_time` DATETIME NOT NULL COMMENT '输入时间',
|
||||
`update_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
`status` TINYINT UNSIGNED DEFAULT 1 COMMENT '状态:1-有效,0-无效',
|
||||
-- 主键及索引配置
|
||||
PRIMARY KEY (`id`) COMMENT '登录标识主键索引',
|
||||
INDEX `idx_user_id` (`user_id`) COMMENT '按用户查询登录标识的索引',
|
||||
INDEX `idx_login_method` (`login_method`) COMMENT '按登录方式查询的索引'
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户登录标识信息表';
|
||||
create index idx_parent_comment_id
|
||||
on t_comment (parent_comment_id)
|
||||
comment '按父级评论查询回复的索引';
|
||||
|
||||
-- 用户VIP信息表:存储用户VIP相关信息
|
||||
CREATE TABLE `t_vip_info` (
|
||||
`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'VIP信息唯一主键ID(雪花ID)',
|
||||
`vip_level` VARCHAR(20) NOT NULL COMMENT 'VIP等级(如青铜、白银)',
|
||||
`start_time` DATETIME NOT NULL COMMENT 'VIP开通时间',
|
||||
`expire_time` DATETIME NOT NULL COMMENT 'VIP到期时间',
|
||||
`activation_method` VARCHAR(50) NOT NULL COMMENT 'VIP开通方式(如购买、赠送)',
|
||||
`benefit_id` BIGINT UNSIGNED NOT NULL COMMENT '关联VIP权益信息表主键',
|
||||
`create_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`update_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
-- 主键及索引配置
|
||||
PRIMARY KEY (`id`) COMMENT 'VIP信息主键索引',
|
||||
INDEX `idx_vip_level` (`vip_level`) COMMENT '按VIP等级查询的索引'
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户VIP信息表';
|
||||
create index idx_product_id
|
||||
on t_comment (product_id)
|
||||
comment '按商品查询评论的索引';
|
||||
|
||||
-- VIP权益信息表:存储各等级VIP对应的权益
|
||||
CREATE TABLE `t_vip_benefit` (
|
||||
`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'VIP权益唯一主键ID(雪花ID)',
|
||||
`benefit_info` TEXT NOT NULL COMMENT '权益详情(如折扣、专属服务)',
|
||||
`required_vip_level` VARCHAR(20) NOT NULL COMMENT '所需VIP等级',
|
||||
`create_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`update_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
-- 主键及索引配置
|
||||
PRIMARY KEY (`id`) COMMENT 'VIP权益主键索引',
|
||||
INDEX `idx_required_vip_level` (`required_vip_level`) COMMENT '按VIP等级查询权益的索引'
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='VIP权益信息表';
|
||||
create index idx_shop_id
|
||||
on t_comment (shop_id)
|
||||
comment '按店铺查询评论的索引';
|
||||
|
||||
-- 用户余额信息表:存储用户账户余额信息
|
||||
CREATE TABLE `t_balance` (
|
||||
`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '余额记录唯一主键ID(雪花ID)',
|
||||
`user_id` BIGINT UNSIGNED NOT NULL COMMENT '关联用户表主键',
|
||||
`amount` DECIMAL(10,2) NOT NULL DEFAULT 0.00 COMMENT '当前余额',
|
||||
`create_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '余额账户创建时间',
|
||||
`last_update_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最近一次更新时间',
|
||||
-- 主键及索引配置
|
||||
PRIMARY KEY (`id`) COMMENT '余额表主键索引',
|
||||
UNIQUE INDEX `uk_user_id` (`user_id`) COMMENT '用户余额唯一索引(一个用户对应一条余额记录)'
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户余额信息表';
|
||||
|
||||
-- 用户余额变动明细表:记录用户余额的每一次变动
|
||||
CREATE TABLE `t_balance_change_detail` (
|
||||
`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '变动记录唯一主键ID(雪花ID)',
|
||||
`user_id` BIGINT UNSIGNED NOT NULL COMMENT '关联用户表主键',
|
||||
`amount` DECIMAL(10,2) NOT NULL COMMENT '本次变动金额(正数为增加,负数为减少)',
|
||||
`type` VARCHAR(20) NOT NULL COMMENT '变动类型(如充值、消费、退款)',
|
||||
`current_balance` DECIMAL(10,2) NOT NULL COMMENT '变动后的当前余额',
|
||||
`change_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '变动时间',
|
||||
-- 主键及索引配置
|
||||
PRIMARY KEY (`id`) COMMENT '余额变动明细主键索引',
|
||||
INDEX `idx_user_id` (`user_id`) COMMENT '按用户查询余额变动的索引',
|
||||
INDEX `idx_change_time` (`change_time`) COMMENT '按时间查询余额变动的索引'
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户余额变动明细表';
|
||||
|
||||
-- 系统标签信息表:存储系统中可复用的标签样式信息
|
||||
CREATE TABLE `t_tag` (
|
||||
`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '标签唯一主键ID',
|
||||
`tag_name` VARCHAR(50) NOT NULL COMMENT '标签名称',
|
||||
`text_color` VARCHAR(20) DEFAULT '#333333' COMMENT '标签文字颜色(16进制)',
|
||||
`bg_color` VARCHAR(20) DEFAULT '#FFFFFF' COMMENT '标签背景颜色(16进制)',
|
||||
`border_color` VARCHAR(20) DEFAULT '#E5E5E5' COMMENT '标签边框颜色(16进制)',
|
||||
`create_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`update_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
`is_delete` TINYINT UNSIGNED DEFAULT 0 COMMENT '逻辑删除:0-未删,1-已删',
|
||||
-- 主键及索引配置
|
||||
PRIMARY KEY (`id`) COMMENT '标签主键索引',
|
||||
UNIQUE INDEX `uk_tag_name` (`tag_name`) COMMENT '标签名称唯一索引'
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='系统标签信息表';
|
||||
|
||||
|
||||
-- 对象存储文件信息表:存储上传文件的元信息
|
||||
CREATE TABLE `t_object_storage_file` (
|
||||
`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '文件记录唯一主键ID(雪花ID)',
|
||||
`file_name` VARCHAR(100) NOT NULL COMMENT '文件名称',
|
||||
`file_url` TEXT NOT NULL COMMENT '文件访问链接',
|
||||
`create_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '文件上传时间',
|
||||
`status` TINYINT UNSIGNED DEFAULT 1 COMMENT '文件状态:1-可用,0-不可用,2-回收站',
|
||||
`delete_time` DATETIME DEFAULT NULL COMMENT '文件删除时间(NULL表示未删除)',
|
||||
`recycle_time` DATETIME DEFAULT NULL COMMENT '文件移入回收站时间(NULL表示未移入)',
|
||||
-- 主键及索引配置
|
||||
PRIMARY KEY (`id`) COMMENT '对象存储文件主键索引',
|
||||
INDEX `idx_status` (`status`) COMMENT '按文件状态查询的索引'
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='对象存储文件信息表';
|
||||
|
||||
-- 用户评论信息表:存储用户对店铺、商品的评论及回复信息
|
||||
CREATE TABLE `t_comment` (
|
||||
`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '评论唯一主键ID(雪花ID)',
|
||||
`user_id` BIGINT UNSIGNED NOT NULL COMMENT '评论用户ID,关联用户表主键',
|
||||
`shop_id` BIGINT UNSIGNED DEFAULT 0 COMMENT '关联店铺表主键(0表示非店铺评论)',
|
||||
`product_id` BIGINT UNSIGNED DEFAULT 0 COMMENT '关联商品表主键(0表示非商品评论)',
|
||||
`comment_content` TEXT NOT NULL COMMENT '评论内容',
|
||||
`parent_comment_id` BIGINT UNSIGNED DEFAULT 0 COMMENT '父级评论ID(0表示为根评论)',
|
||||
`like_count` INT UNSIGNED DEFAULT 0 COMMENT '评论点赞数',
|
||||
`create_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '评论创建时间',
|
||||
`update_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '评论更新时间',
|
||||
`is_delete` TINYINT UNSIGNED DEFAULT 0 COMMENT '逻辑删除标识:0-未删除,1-已删除',
|
||||
-- 主键及索引配置
|
||||
PRIMARY KEY (`id`) COMMENT '评论主键索引',
|
||||
INDEX `idx_user_id` (`user_id`) COMMENT '按用户查询评论的索引',
|
||||
INDEX `idx_shop_id` (`shop_id`) COMMENT '按店铺查询评论的索引',
|
||||
INDEX `idx_product_id` (`product_id`) COMMENT '按商品查询评论的索引',
|
||||
INDEX `idx_parent_comment_id` (`parent_comment_id`) COMMENT '按父级评论查询回复的索引'
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户评论信息表';
|
||||
create index idx_user_id
|
||||
on t_comment (user_id)
|
||||
comment '按用户查询评论的索引';
|
||||
|
||||
|
||||
|
||||
-- 创建权限表
|
||||
CREATE TABLE IF NOT EXISTS t_permission (
|
||||
id BIGINT UNSIGNED AUTO_INCREMENT COMMENT '权限唯一主键ID' PRIMARY KEY,
|
||||
permission_code VARCHAR(100) NOT NULL COMMENT '权限编码(唯一标识)',
|
||||
permission_name VARCHAR(100) NOT NULL COMMENT '权限名称',
|
||||
permission_group VARCHAR(50) NOT NULL COMMENT '权限分组(商品管理、用户管理等)',
|
||||
description VARCHAR(255) NULL COMMENT '权限描述',
|
||||
create_time DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL COMMENT '创建时间',
|
||||
update_time DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
is_delete TINYINT UNSIGNED DEFAULT 0 NULL COMMENT '逻辑删除:0-未删,1-已删',
|
||||
CONSTRAINT uk_permission_code UNIQUE (permission_code) COMMENT '权限编码唯一索引'
|
||||
) COMMENT '系统权限表';
|
||||
-- 商品效果图信息表
|
||||
create table t_effect_diagram
|
||||
(
|
||||
id bigint unsigned auto_increment comment '效果图唯一主键ID(雪花id)'
|
||||
primary key comment '效果图主键索引',
|
||||
product_id bigint unsigned not null comment '所属商品ID,关联商品表主键',
|
||||
category varchar(50) default '' null comment '效果图类别',
|
||||
image_file_ids text null comment '图片文件ID集合,多ID以逗号分隔',
|
||||
description text null comment '效果图描述',
|
||||
price decimal(10, 2) default 0.00 null comment '效果图对应服务价格',
|
||||
duration varchar(50) default '' null comment '效果图对应服务耗时',
|
||||
tag varchar(50) default '' null comment '效果图标签',
|
||||
like_count int unsigned default 0 null comment '效果图点赞数',
|
||||
create_time datetime default CURRENT_TIMESTAMP not null comment '创建时间',
|
||||
update_time datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '更新时间',
|
||||
is_delete tinyint unsigned default 0 null comment '逻辑删除:0-未删,1-已删'
|
||||
)
|
||||
comment '商品效果图信息表';
|
||||
|
||||
create index idx_product_id
|
||||
on t_effect_diagram (product_id)
|
||||
comment '按商品查询效果图的索引';
|
||||
|
||||
-- 用户登录标识信息表
|
||||
create table t_login_identity
|
||||
(
|
||||
id bigint unsigned auto_increment comment '登录标识唯一主键ID(雪花id)'
|
||||
primary key comment '登录标识主键索引',
|
||||
user_id bigint unsigned not null comment '关联用户表主键',
|
||||
login_method varchar(50) not null comment '登录方式(0-手机号、1-账号、2-邮箱)',
|
||||
input_value varchar(100) not null comment '前端输入的具体值(如手机号、账号、邮箱)',
|
||||
input_time datetime not null comment '输入时间',
|
||||
update_time datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '更新时间',
|
||||
status tinyint unsigned default 1 null comment '状态:1-有效,0-无效'
|
||||
)
|
||||
comment '用户登录标识信息表';
|
||||
|
||||
create index idx_login_method
|
||||
on t_login_identity (login_method)
|
||||
comment '按登录方式查询的索引';
|
||||
|
||||
create index idx_user_id
|
||||
on t_login_identity (user_id)
|
||||
comment '按用户查询登录标识的索引';
|
||||
|
||||
-- 对象存储文件信息表
|
||||
create table t_object_storage_file
|
||||
(
|
||||
id bigint unsigned auto_increment comment '文件记录唯一主键ID(雪花ID)'
|
||||
primary key comment '对象存储文件主键索引',
|
||||
file_name varchar(100) not null comment '文件名称',
|
||||
file_url text not null comment '文件访问链接',
|
||||
create_time datetime default CURRENT_TIMESTAMP not null comment '文件上传时间',
|
||||
update_time datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '文件更新时间',
|
||||
status tinyint unsigned default 1 null comment '文件状态:1-可用,0-不可用,2-回收站',
|
||||
delete_time datetime null comment '文件删除时间(NULL表示未删除)',
|
||||
recycle_time datetime null comment '文件移入回收站时间(NULL表示未移入)'
|
||||
)
|
||||
comment '对象存储文件信息表';
|
||||
|
||||
create index idx_status
|
||||
on t_object_storage_file (status)
|
||||
comment '按文件状态查询的索引';
|
||||
|
||||
|
||||
-- 系统权限表
|
||||
create table t_permission
|
||||
(
|
||||
id bigint unsigned auto_increment comment '权限唯一主键ID'
|
||||
primary key,
|
||||
permission_code varchar(100) not null comment '权限编码(唯一标识)',
|
||||
permission_name varchar(100) not null comment '权限名称',
|
||||
permission_group varchar(50) not null comment '权限分组(商品管理、用户管理等)',
|
||||
description varchar(255) null comment '权限描述',
|
||||
create_time datetime default CURRENT_TIMESTAMP not null comment '创建时间',
|
||||
update_time datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '更新时间',
|
||||
is_delete tinyint unsigned default 0 null comment '逻辑删除:0-未删,1-已删',
|
||||
constraint uk_permission_code
|
||||
unique (permission_code) comment '权限编码唯一索引'
|
||||
)
|
||||
comment '系统权限表';
|
||||
|
||||
-- 商品信息表
|
||||
create table t_product
|
||||
(
|
||||
id bigint unsigned auto_increment comment '商品唯一主键ID(雪花id)'
|
||||
primary key comment '商品主键索引',
|
||||
shop_id bigint unsigned not null comment '所属店铺ID,关联店铺表主键',
|
||||
title varchar(100) not null comment '商品标题',
|
||||
description text null comment '商品描述',
|
||||
image_file_ids text null comment '图片文件ID集合,多个ID以逗号分隔',
|
||||
price decimal(10, 2) not null comment '商品价格,保留2位小数',
|
||||
tags varchar(512) default '' null comment '标签集合,多个标签以逗号分隔,最多5个',
|
||||
like_count int unsigned default 0 null comment '商品点赞数',
|
||||
collect_count int unsigned default 0 null comment '商品收藏数',
|
||||
approximate_duration varchar(50) default '' null comment '商品对应的服务大约耗时(如“30分钟”)',
|
||||
bookable_artists varchar(200) default '' null comment '可预约的美甲师ID集合,多个ID以逗号分隔',
|
||||
available_coupons text null comment '可用的优惠券ID集合,多个ID以逗号分隔',
|
||||
create_time datetime default CURRENT_TIMESTAMP not null comment '商品创建时间',
|
||||
update_time datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '商品信息最后更新时间',
|
||||
is_delete tinyint unsigned default 0 null comment '逻辑删除标识:0-未删除,1-已删除'
|
||||
)
|
||||
comment '商品信息表';
|
||||
|
||||
create index idx_price
|
||||
on t_product (price)
|
||||
comment '按价格筛选商品的索引';
|
||||
|
||||
create index idx_shop_id
|
||||
on t_product (shop_id)
|
||||
comment '按所属店铺查询商品的索引';
|
||||
|
||||
create index idx_tags
|
||||
on t_product (tags)
|
||||
comment '按标签筛选商品的索引';
|
||||
|
||||
create index idx_title
|
||||
on t_product (title)
|
||||
comment '商品标题搜索的索引';
|
||||
|
||||
-- 店铺信息表
|
||||
create table t_shop
|
||||
(
|
||||
id bigint unsigned auto_increment comment '店铺唯一主键ID'
|
||||
primary key comment '店铺主键索引',
|
||||
shop_name varchar(100) not null comment '店铺名称',
|
||||
description text null comment '店铺描述',
|
||||
address varchar(200) not null comment '店铺地址',
|
||||
business_hours varchar(100) default '' null comment '店铺营业时间',
|
||||
cover_image_file_id varchar(50) default '' null comment '店铺封面图文件ID',
|
||||
create_time datetime default CURRENT_TIMESTAMP not null comment '创建时间',
|
||||
update_time datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '更新时间',
|
||||
is_delete tinyint unsigned default 0 null comment '逻辑删除:0-未删,1-已删',
|
||||
image_file_ids text null comment '图片文件ID集合,多个ID以逗号分隔'
|
||||
)
|
||||
comment '店铺信息表';
|
||||
|
||||
create index idx_shop_name
|
||||
on t_shop (shop_name)
|
||||
comment '按店铺名称查询的索引';
|
||||
|
||||
|
||||
-- 系统标签信息表
|
||||
create table t_tag
|
||||
(
|
||||
id bigint unsigned auto_increment comment '标签唯一主键ID'
|
||||
primary key comment '标签主键索引',
|
||||
tag_name varchar(50) not null comment '标签名称',
|
||||
text_color varchar(20) default '#333333' null comment '标签文字颜色(16进制)',
|
||||
bg_color varchar(20) default '#FFFFFF' null comment '标签背景颜色(16进制)',
|
||||
border_color varchar(20) default '#E5E5E5' null comment '标签边框颜色(16进制)',
|
||||
create_time datetime default CURRENT_TIMESTAMP not null comment '创建时间',
|
||||
update_time datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '更新时间',
|
||||
is_delete tinyint unsigned default 0 null comment '逻辑删除:0-未删,1-已删',
|
||||
shop_id bigint null comment '店铺ID',
|
||||
constraint uk_tag_name
|
||||
unique (tag_name) comment '标签名称唯一索引'
|
||||
)
|
||||
comment '系统标签信息表';
|
||||
|
||||
-- 系统用户信息表
|
||||
create table t_user
|
||||
(
|
||||
id bigint unsigned auto_increment comment '用户唯一主键ID(雪花ID)'
|
||||
primary key comment '用户主键索引',
|
||||
shop_id bigint unsigned default 0 null comment '所属店铺ID,关联店铺表主键(0表示无所属店铺)',
|
||||
nickname varchar(50) not null comment '用户昵称',
|
||||
account varchar(50) not null comment '用户账号(登录用)',
|
||||
phone varchar(20) null comment '手机号',
|
||||
email varchar(100) null comment '邮箱',
|
||||
phone_verified tinyint unsigned default 0 null comment '手机号是否已验证:0-未验证,1-已验证',
|
||||
email_verified tinyint unsigned default 0 null comment '邮箱是否已验证:0-未验证,1-已验证',
|
||||
password varchar(100) not null comment '用户密码(加密存储)',
|
||||
signature varchar(200) default '' null comment '用户签名',
|
||||
level varchar(20) default '普通' null comment '用户等级',
|
||||
type tinyint not null comment '用户类型,(0-用户,2-店长,3-美甲师,4-管理员)',
|
||||
vip_id bigint unsigned default 0 null comment '关联VIP信息表主键(0表示非VIP)',
|
||||
create_time datetime default CURRENT_TIMESTAMP not null comment '创建时间',
|
||||
update_time datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '更新时间',
|
||||
is_delete tinyint unsigned default 0 null comment '逻辑删除:0-未删,1-已删',
|
||||
status tinyint unsigned default 1 null comment '用户状态:1-正常,0-禁用',
|
||||
avatar varchar(512) null comment '头像链接',
|
||||
constraint uk_account
|
||||
unique (account) comment '用户账号唯一索引'
|
||||
)
|
||||
comment '系统用户信息表';
|
||||
|
||||
create index idx_email
|
||||
on t_user (email)
|
||||
comment '按邮箱查询的索引';
|
||||
|
||||
create index idx_phone
|
||||
on t_user (phone)
|
||||
comment '按手机号查询的索引';
|
||||
|
||||
create index idx_shop_id
|
||||
on t_user (shop_id)
|
||||
comment '按店铺查询用户的索引';
|
||||
|
||||
create index idx_type
|
||||
on t_user (type)
|
||||
comment '按用户类型查询的索引';
|
||||
|
||||
-- 用户权限关联表
|
||||
create table t_user_permission
|
||||
(
|
||||
id bigint unsigned auto_increment comment '关联ID'
|
||||
primary key,
|
||||
user_id bigint unsigned not null comment '用户ID',
|
||||
permission_id bigint unsigned not null comment '权限ID',
|
||||
create_time datetime default CURRENT_TIMESTAMP not null comment '创建时间',
|
||||
update_time datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '更新时间',
|
||||
create_by bigint unsigned null comment '创建人ID',
|
||||
update_by bigint unsigned null comment '更新人ID',
|
||||
is_delete tinyint unsigned default 0 null comment '逻辑删除:0-未删,1-已删',
|
||||
constraint uk_user_permission
|
||||
unique (user_id, permission_id) comment '用户-权限唯一索引'
|
||||
)
|
||||
comment '用户权限关联表';
|
||||
|
||||
create index idx_permission_id
|
||||
on t_user_permission (permission_id)
|
||||
comment '权限ID索引';
|
||||
|
||||
create index idx_user_id
|
||||
on t_user_permission (user_id)
|
||||
comment '用户ID索引';
|
||||
|
||||
|
||||
-- VIP权益信息表
|
||||
create table t_vip_benefit
|
||||
(
|
||||
id bigint unsigned auto_increment comment 'VIP权益唯一主键ID(雪花ID)'
|
||||
primary key comment 'VIP权益主键索引',
|
||||
benefit_info text not null comment '权益详情(如折扣、专属服务)',
|
||||
required_vip_level varchar(20) not null comment '所需VIP等级',
|
||||
create_time datetime default CURRENT_TIMESTAMP not null comment '创建时间',
|
||||
update_time datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '更新时间'
|
||||
)
|
||||
comment 'VIP权益信息表';
|
||||
|
||||
create index idx_required_vip_level
|
||||
on t_vip_benefit (required_vip_level)
|
||||
comment '按VIP等级查询权益的索引';
|
||||
|
||||
-- 用户VIP信息表
|
||||
create table t_vip_info
|
||||
(
|
||||
id bigint unsigned auto_increment comment 'VIP信息唯一主键ID(雪花ID)'
|
||||
primary key comment 'VIP信息主键索引',
|
||||
vip_level varchar(20) not null comment 'VIP等级(如青铜、白银)',
|
||||
start_time datetime not null comment 'VIP开通时间',
|
||||
expire_time datetime not null comment 'VIP到期时间',
|
||||
activation_method varchar(50) not null comment 'VIP开通方式(如购买、赠送)',
|
||||
benefit_id bigint unsigned not null comment '关联VIP权益信息表主键',
|
||||
create_time datetime default CURRENT_TIMESTAMP not null comment '创建时间',
|
||||
update_time datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '更新时间'
|
||||
)
|
||||
comment '用户VIP信息表';
|
||||
|
||||
create index idx_vip_level
|
||||
on t_vip_info (vip_level)
|
||||
comment '按VIP等级查询的索引';
|
||||
|
||||
-- 创建用户权限关联表
|
||||
CREATE TABLE IF NOT EXISTS t_user_permission (
|
||||
id BIGINT UNSIGNED AUTO_INCREMENT COMMENT '关联ID' PRIMARY KEY,
|
||||
user_id BIGINT UNSIGNED NOT NULL COMMENT '用户ID',
|
||||
permission_id BIGINT UNSIGNED NOT NULL COMMENT '权限ID',
|
||||
create_time DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL COMMENT '创建时间',
|
||||
create_by BIGINT UNSIGNED NULL COMMENT '创建人ID',
|
||||
CONSTRAINT uk_user_permission UNIQUE (user_id, permission_id) COMMENT '用户-权限唯一索引',
|
||||
INDEX idx_user_id (user_id) COMMENT '用户ID索引',
|
||||
INDEX idx_permission_id (permission_id) COMMENT '权限ID索引'
|
||||
) COMMENT '用户权限关联表';
|
||||
|
||||
-- 插入默认权限数据
|
||||
INSERT INTO t_permission (permission_code, permission_name, permission_group, description) VALUES
|
||||
-- 商品管理权限
|
||||
('product:view', '查看商品', '商品管理', '查看商品列表和详情'),
|
||||
('product:create', '新增商品', '商品管理', '新增商品'),
|
||||
('product:update', '编辑商品', '商品管理', '编辑商品信息'),
|
||||
('product:delete', '删除商品', '商品管理', '删除商品'),
|
||||
-- 用户管理权限
|
||||
('user:view', '查看用户', '用户管理', '查看用户列表和详情'),
|
||||
('user:create', '新增用户', '用户管理', '新增用户'),
|
||||
('user:disable', '停用用户', '用户管理', '停用/启用用户'),
|
||||
('user:reset_password', '重置密码', '用户管理', '重置用户密码'),
|
||||
-- 权限管理权限
|
||||
('permission:view', '查看权限', '权限管理', '查看权限列表'),
|
||||
('permission:assign', '分配权限', '权限管理', '给用户分配权限');
|
||||
|
||||
Reference in New Issue
Block a user