diff --git a/Frontend/src/router/index.ts b/Frontend/src/router/index.ts
index 96e408e7..932736ea 100644
--- a/Frontend/src/router/index.ts
+++ b/Frontend/src/router/index.ts
@@ -92,6 +92,12 @@ const router = createRouter({
component: () => import('../views/admin/ProductsView.vue'),
meta: { requiresAuth: true, isAdmin: true, hideNav: true, permissionCode: 'product:view' }
},
+ {
+ path: 'coupons',
+ name: 'admin-coupons',
+ component: () => import('../views/admin/CouponsView.vue'),
+ meta: { requiresAuth: true, isAdmin: true, hideNav: true, permissionCode: 'coupon:view' }
+ },
{
path: 'shops',
name: 'admin-shops',
diff --git a/Frontend/src/views/ProfileView.vue b/Frontend/src/views/ProfileView.vue
index 6f806112..fc79959c 100644
--- a/Frontend/src/views/ProfileView.vue
+++ b/Frontend/src/views/ProfileView.vue
@@ -38,26 +38,6 @@
-
@@ -156,7 +136,7 @@
@@ -469,73 +421,6 @@ onMounted(() => {
z-index: 1;
}
-.permissions-section {
- padding: 0 15px 15px;
- position: relative;
- z-index: 1;
-}
-
-.permissions-card {
- border-radius: 20px;
- overflow: hidden;
- box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
-}
-
-.permissions-card :deep(.ant-card-head) {
- border-bottom: none;
- padding: 16px 20px 12px;
-}
-
-.card-title {
- display: flex;
- align-items: center;
- gap: 8px;
- font-size: 16px;
- font-weight: 600;
- color: #1a1a2e;
-}
-
-.title-icon {
- font-size: 20px;
- color: #667eea;
-}
-
-.permissions-card :deep(.ant-card-body) {
- padding: 0 20px 20px;
-}
-
-.permissions-content {
- display: flex;
- flex-direction: column;
- gap: 16px;
-}
-
-.permission-group {
- display: flex;
- flex-direction: column;
- gap: 10px;
-}
-
-.group-title {
- font-size: 14px;
- font-weight: 600;
- color: #667eea;
- margin-bottom: 4px;
-}
-
-.permission-tags {
- display: flex;
- flex-wrap: wrap;
- gap: 8px;
-}
-
-.permission-tag {
- font-size: 13px;
- padding: 4px 12px;
- border-radius: 12px;
- margin: 0;
-}
-
.profile-card {
border-radius: 20px;
overflow: hidden;
@@ -787,4 +672,4 @@ onMounted(() => {
color: white !important;
text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}
-
+
\ No newline at end of file
diff --git a/Frontend/src/views/admin/AdminLayout.vue b/Frontend/src/views/admin/AdminLayout.vue
index 13c8aa08..cb7850fb 100644
--- a/Frontend/src/views/admin/AdminLayout.vue
+++ b/Frontend/src/views/admin/AdminLayout.vue
@@ -90,7 +90,8 @@ import {
HomeOutlined,
SafetyCertificateOutlined,
DownOutlined,
- LogoutOutlined
+ LogoutOutlined,
+ GiftOutlined
} from '@ant-design/icons-vue'
import { message, Modal } from 'ant-design-vue'
import { userApi, type UserVO, adminAuthApi } from '@/api/admin'
@@ -129,6 +130,12 @@ const menuItems = [
label: '商品管理',
permissionCode: 'product:view'
},
+ {
+ key: '/admin/coupons',
+ icon: GiftOutlined,
+ label: '优惠券管理',
+ permissionCode: 'coupon:view'
+ },
{
key: '/admin/shops',
icon: HomeOutlined,
diff --git a/Frontend/src/views/admin/HomeView.vue b/Frontend/src/views/admin/HomeView.vue
index dbb7b149..6d7e095d 100644
--- a/Frontend/src/views/admin/HomeView.vue
+++ b/Frontend/src/views/admin/HomeView.vue
@@ -21,6 +21,28 @@
+
+
+
+
+ 我的权限
+
+
+
+
+ 暂无权限信息
+
+
+
快捷操作
@@ -47,12 +69,13 @@
import { ref, computed, onMounted } from 'vue'
import { useRouter } from 'vue-router'
import { DashboardOutlined, UserOutlined, ShopOutlined, SafetyCertificateOutlined, HomeOutlined } from '@ant-design/icons-vue'
-import { userApi, type UserVO } from '@/api/admin'
+import { userApi, type UserVO, permissionApi, type PermissionVO } from '@/api/admin'
import { DEFAULT_AVATAR } from '@/constants'
const router = useRouter()
const currentTime = ref('')
const userInfo = ref(null)
+const userPermissions = ref([])
const welcomeMessage = computed(() => {
const hour = new Date().getHours()
@@ -65,6 +88,17 @@ const welcomeMessage = computed(() => {
}
})
+const groupedPermissions = computed(() => {
+ const groups: Record = {}
+ userPermissions.value.forEach(permission => {
+ if (!groups[permission.permissionGroup]) {
+ groups[permission.permissionGroup] = []
+ }
+ groups[permission.permissionGroup].push(permission)
+ })
+ return groups
+})
+
const quickActions = computed(() => {
const actions = [
{
@@ -146,6 +180,15 @@ const fetchUserInfo = async () => {
}
}
+const fetchUserPermissions = async () => {
+ try {
+ const res = await permissionApi.getUserPermissions()
+ userPermissions.value = res as unknown as PermissionVO[]
+ } catch (error) {
+ console.error('获取用户权限失败:', error)
+ }
+}
+
const navigateTo = (path: string) => {
router.push(path)
}
@@ -154,6 +197,7 @@ onMounted(() => {
updateCurrentTime()
setInterval(updateCurrentTime, 1000)
fetchUserInfo()
+ fetchUserPermissions()
})
@@ -170,6 +214,10 @@ onMounted(() => {
margin-bottom: 24px;
}
+.permissions-card {
+ margin-bottom: 24px;
+}
+
.user-info {
display: flex;
align-items: center;
@@ -191,6 +239,58 @@ onMounted(() => {
color: #666;
}
+.card-title {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ font-size: 16px;
+ font-weight: 600;
+ color: #1a1a2e;
+}
+
+.title-icon {
+ font-size: 20px;
+ color: #667eea;
+}
+
+.permissions-content {
+ display: flex;
+ flex-direction: column;
+ gap: 16px;
+}
+
+.permission-group {
+ display: flex;
+ flex-direction: column;
+ gap: 10px;
+}
+
+.group-title {
+ font-size: 14px;
+ font-weight: 600;
+ color: #667eea;
+ margin-bottom: 4px;
+}
+
+.permission-tags {
+ display: flex;
+ flex-wrap: wrap;
+ gap: 8px;
+}
+
+.permission-tag {
+ font-size: 13px;
+ padding: 4px 12px;
+ border-radius: 12px;
+ margin: 0;
+}
+
+.no-permissions {
+ text-align: center;
+ padding: 20px;
+ color: #999;
+}
+
.quick-actions {
margin-top: 24px;
}
diff --git a/Frontend/src/views/admin/ProductsView.vue b/Frontend/src/views/admin/ProductsView.vue
index 13f75314..2dfa6847 100644
--- a/Frontend/src/views/admin/ProductsView.vue
+++ b/Frontend/src/views/admin/ProductsView.vue
@@ -230,7 +230,7 @@
:key="coupon.id"
:value="coupon.id.toString()"
>
- {{ coupon.name }}
+ {{ coupon.couponName }}
diff --git a/YumiNail-Core/src/main/resources/files/YumiNail.sql b/YumiNail-Core/src/main/resources/files/YumiNail.sql
index ded29071..754242bc 100644
--- a/YumiNail-Core/src/main/resources/files/YumiNail.sql
+++ b/YumiNail-Core/src/main/resources/files/YumiNail.sql
@@ -435,4 +435,121 @@ WHERE u.type = 3
'product:view',
'product:create',
'product:edit'
+ );
+
+use nailart;
+-- 优惠券信息表
+create table t_coupon
+(
+ id bigint unsigned auto_increment comment '优惠券唯一主键ID'
+ primary key comment '优惠券主键索引',
+ coupon_code varchar(50) not null comment '优惠券编码',
+ coupon_name varchar(100) not null comment '优惠券名称',
+ coupon_type tinyint not null comment '优惠券类型:1-折扣券,2-满减券',
+ discount_value decimal(10, 2) default 0.00 null comment '折扣值(如9.5表示95折)',
+ min_amount decimal(10, 2) default 0.00 null comment '满减券最低消费金额',
+ reduce_amount decimal(10, 2) default 0.00 null comment '满减券减免金额',
+ total_count int unsigned default 100 not null comment '优惠券总数量',
+ used_count int unsigned default 0 not null comment '已使用数量',
+ start_time datetime not null comment '开始时间',
+ end_time datetime not null comment '结束时间',
+ status tinyint unsigned default 1 not null comment '状态:1-可用,2-已过期,3-已用完',
+ 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_coupon_code
+ unique (coupon_code) comment '优惠券编码唯一索引'
+) comment '优惠券信息表';
+
+create index idx_status
+ on t_coupon (status) comment '按状态查询优惠券的索引';
+
+-- 用户优惠券关联表
+create table t_user_coupon
+(
+ id bigint unsigned auto_increment comment '用户优惠券关联唯一主键ID'
+ primary key comment '用户优惠券关联主键索引',
+ user_id bigint unsigned not null comment '关联用户表主键',
+ coupon_id bigint unsigned not null comment '关联优惠券表主键',
+ status tinyint unsigned default 1 not null comment '状态:1-未使用,2-已使用,3-已过期',
+ obtain_time datetime default CURRENT_TIMESTAMP not null comment '获取时间',
+ use_time datetime 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_user_coupon
+ unique (user_id, coupon_id) comment '用户-优惠券唯一索引'
+) comment '用户优惠券关联表';
+
+create index idx_status
+ on t_user_coupon (status) comment '按状态查询用户优惠券的索引';
+
+create index idx_user_id
+ on t_user_coupon (user_id) comment '按用户查询优惠券的索引';
+
+-- 优惠券标签关联表
+create table t_coupon_tag
+(
+ id bigint unsigned auto_increment comment '优惠券标签关联唯一主键ID'
+ primary key comment '优惠券标签关联主键索引',
+ coupon_id bigint unsigned not null comment '关联优惠券表主键',
+ tag_id bigint unsigned not null comment '关联标签表主键',
+ is_available tinyint unsigned default 1 not null comment '是否可用:1-可用,0-不可用',
+ 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_coupon_tag
+ unique (coupon_id, tag_id) comment '优惠券-标签唯一索引'
+) comment '优惠券标签关联表';
+
+create index idx_coupon_id
+ on t_coupon_tag (coupon_id) comment '按优惠券查询标签的索引';
+
+create index idx_tag_id
+ on t_coupon_tag (tag_id) comment '按标签查询优惠券的索引';
+
+-- 插入优惠券管理相关权限
+INSERT INTO t_permission (permission_code, permission_name, permission_group, description, create_time, update_time, is_delete) VALUES
+ ('coupon:view', '查看优惠券', '优惠券管理', '查看优惠券列表和详情', NOW(), NOW(), 0),
+ ('coupon:create', '新增优惠券', '优惠券管理', '新增优惠券', NOW(), NOW(), 0),
+ ('coupon:edit', '编辑优惠券', '优惠券管理', '编辑优惠券信息', NOW(), NOW(), 0),
+ ('coupon:delete', '删除优惠券', '优惠券管理', '删除优惠券', NOW(), NOW(), 0),
+ ('coupon:assign', '分配优惠券', '优惠券管理', '为用户分配优惠券', NOW(), NOW(), 0);
+
+-- 为管理员(type=4)分配优惠券管理权限
+INSERT INTO t_user_permission (user_id, permission_id, create_time, update_time)
+SELECT
+ u.id as user_id,
+ p.id as permission_id,
+ NOW() as create_time,
+ NOW() as update_time
+FROM t_user u
+ CROSS JOIN t_permission p
+WHERE u.type = 4
+ AND p.is_delete = 0
+ AND p.permission_code IN (
+ 'coupon:view',
+ 'coupon:create',
+ 'coupon:edit',
+ 'coupon:delete',
+ 'coupon:assign'
+ );
+
+-- 为店长(type=2)分配优惠券管理权限
+INSERT INTO t_user_permission (user_id, permission_id, create_time, update_time)
+SELECT
+ u.id as user_id,
+ p.id as permission_id,
+ NOW() as create_time,
+ NOW() as update_time
+FROM t_user u
+ CROSS JOIN t_permission p
+WHERE u.type = 2
+ AND p.is_delete = 0
+ AND p.permission_code IN (
+ 'coupon:view',
+ 'coupon:create',
+ 'coupon:edit',
+ 'coupon:delete',
+ 'coupon:assign'
);
\ No newline at end of file