diff --git a/Frontend/src/config/api.ts b/Frontend/src/config/api.ts index ca4670f5..10a72931 100644 --- a/Frontend/src/config/api.ts +++ b/Frontend/src/config/api.ts @@ -2,10 +2,10 @@ // 提取域名和端口,方便后续修改 export const API_CONFIG = { domain: 'http://127.0.0.1', - port: '8088', + port: '80', basePath: '/api', adminBasePath: '/admin/api' } export const API_BASE_URL = `${API_CONFIG.domain}:${API_CONFIG.port}${API_CONFIG.basePath}` -export const ADMIN_API_BASE_URL = `${API_CONFIG.domain}:${API_CONFIG.port}${API_CONFIG.adminBasePath}` \ No newline at end of file +export const ADMIN_API_BASE_URL = `${API_CONFIG.domain}:${API_CONFIG.port}${API_CONFIG.adminBasePath}` diff --git a/YumiNail-Core/src/main/resources/files/YumiNail.sql b/YumiNail-Core/src/main/resources/files/YumiNail.sql index 98a4bda4..fa40bbe8 100644 --- a/YumiNail-Core/src/main/resources/files/YumiNail.sql +++ b/YumiNail-Core/src/main/resources/files/YumiNail.sql @@ -1,4 +1,4 @@ --- 用户余额信息表 +-- auto-generated definition create table t_balance ( id bigint unsigned auto_increment comment '余额记录唯一主键ID(雪花ID)' @@ -11,7 +11,9 @@ create table t_balance unique (user_id) comment '用户余额唯一索引(一个用户对应一条余额记录)' ) comment '用户余额信息表'; --- 用户余额变动明细表 + + +-- auto-generated definition create table t_balance_change_detail ( id bigint unsigned auto_increment comment '变动记录唯一主键ID(雪花ID)' @@ -32,7 +34,27 @@ create index idx_user_id on t_balance_change_detail (user_id) comment '按用户查询余额变动的索引'; --- 用户评论信息表 +-- auto-generated definition +create table t_cart +( + id bigint unsigned auto_increment comment '购物车主键索引' + primary key, + user_id bigint unsigned not null comment '关联用户表主键', + product_id bigint unsigned not null comment '关联商品表主键', + quantity int unsigned default 1 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 '更新时间', + is_delete tinyint unsigned default 0 null comment '逻辑删除:0-未删,1-已删', + constraint uk_user_product + unique (user_id, product_id) comment '用户-商品唯一索引' +) + comment '购物车表'; + +create index idx_user_id + on t_cart (user_id) + comment '按用户查询购物车的索引'; + +-- auto-generated definition create table t_comment ( id bigint unsigned auto_increment comment '评论唯一主键ID(雪花ID)' @@ -65,9 +87,60 @@ create index idx_user_id on t_comment (user_id) comment '按用户查询评论的索引'; +-- auto-generated definition +create table t_coupon +( + id bigint unsigned auto_increment comment '优惠券主键索引' + primary key, + 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-已删', + shop_id bigint null comment '所属店铺ID', + constraint uk_coupon_code + unique (coupon_code) comment '优惠券编码唯一索引' +) + comment '优惠券信息表'; +create index idx_status + on t_coupon (status) + comment '按状态查询优惠券的索引'; --- 商品效果图信息表 +-- auto-generated definition +create table t_coupon_tag +( + id bigint unsigned auto_increment comment '优惠券标签关联主键索引' + primary key, + 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 '按标签查询优惠券的索引'; + +-- auto-generated definition create table t_effect_diagram ( id bigint unsigned auto_increment comment '效果图唯一主键ID(雪花id)' @@ -90,7 +163,7 @@ create index idx_product_id on t_effect_diagram (product_id) comment '按商品查询效果图的索引'; --- 用户登录标识信息表 +-- auto-generated definition create table t_login_identity ( id bigint unsigned auto_increment comment '登录标识唯一主键ID(雪花id)' @@ -112,7 +185,35 @@ create index idx_user_id on t_login_identity (user_id) comment '按用户查询登录标识的索引'; --- 对象存储文件信息表 +-- auto-generated definition +create table t_nail_artist_info +( + id bigint unsigned auto_increment comment '美甲师信息主键索引' + primary key, + user_id bigint unsigned not null comment '关联用户表主键(美甲师用户)', + identity varchar(50) default '' null comment '身份', + experience int unsigned default 0 null comment '从业年限', + skills text null comment '技能标签ID集合,多个ID以逗号分隔', + rating decimal(3, 1) default 0.0 null comment '评分', + status tinyint unsigned default 1 null comment '状态:1-营业中,0-休息中', + portfolio 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-已删', + constraint uk_user_id + unique (user_id) comment '用户ID唯一索引(一个美甲师对应一条信息记录)' +) + comment '美甲师信息表'; + +create index idx_status + on t_nail_artist_info (status) + comment '按状态查询美甲师的索引'; + +create index idx_user_id + on t_nail_artist_info (user_id) + comment '按用户查询美甲师信息的索引'; + +-- auto-generated definition create table t_object_storage_file ( id bigint unsigned auto_increment comment '文件记录唯一主键ID(雪花ID)' @@ -131,8 +232,54 @@ create index idx_status on t_object_storage_file (status) comment '按文件状态查询的索引'; +-- auto-generated definition +create table t_order +( + id bigint unsigned auto_increment comment '订单主键索引' + primary key, + order_no varchar(50) not null comment '订单编号', + user_id bigint unsigned not null comment '关联用户表主键', + total_amount decimal(10, 2) not null comment '订单总金额', + actual_amount decimal(10, 2) not null comment '实际支付金额', + coupon_id bigint unsigned default 0 null comment '使用的优惠券ID', + 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_order_no + unique (order_no) comment '订单编号唯一索引' +) + comment '订单表'; --- 系统权限表 +create index idx_status + on t_order (status) + comment '按状态查询订单的索引'; + +create index idx_user_id + on t_order (user_id) + comment '按用户查询订单的索引'; + +-- auto-generated definition +create table t_order_item +( + id bigint unsigned auto_increment comment '订单商品主键索引' + primary key, + order_id bigint unsigned not null comment '关联订单表主键', + product_id bigint unsigned not null comment '关联商品表主键', + quantity int unsigned not null comment '商品数量', + price decimal(10, 2) not null comment '商品单价', + artist_id bigint unsigned 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-已删' +) + comment '订单商品表'; + +create index idx_order_id + on t_order_item (order_id) + comment '按订单查询商品的索引'; + +-- auto-generated definition create table t_permission ( id bigint unsigned auto_increment comment '权限唯一主键ID' @@ -149,7 +296,7 @@ create table t_permission ) comment '系统权限表'; --- 商品信息表 +-- auto-generated definition create table t_product ( id bigint unsigned auto_increment comment '商品唯一主键ID(雪花id)' @@ -187,10 +334,33 @@ create index idx_title on t_product (title) comment '商品标题搜索的索引'; --- 店铺信息表 +-- auto-generated definition +create table t_product_like +( + id bigint unsigned auto_increment comment '商品点赞主键索引' + primary key, + user_id bigint unsigned not null comment '关联用户表主键', + product_id bigint unsigned 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 '更新时间', + is_delete tinyint unsigned default 0 null comment '逻辑删除:0-未删除,1-已删除', + constraint uk_user_product_like + unique (user_id, product_id) comment '用户-商品唯一索引' +) + comment '商品点赞记录表'; + +create index idx_product_id_like + on t_product_like (product_id) + comment '按商品查询点赞的索引'; + +create index idx_user_id_like + on t_product_like (user_id) + comment '按用户查询点赞的索引'; + +-- auto-generated definition create table t_shop ( - id bigint unsigned comment '店铺唯一主键ID(雪花ID)' + id bigint unsigned auto_increment comment '店铺唯一主键ID' primary key comment '店铺主键索引', shop_name varchar(100) not null comment '店铺名称', description text null comment '店铺描述', @@ -208,8 +378,7 @@ create index idx_shop_name on t_shop (shop_name) comment '按店铺名称查询的索引'; - --- 系统标签信息表 +-- auto-generated definition create table t_tag ( id bigint unsigned auto_increment comment '标签唯一主键ID' @@ -227,10 +396,10 @@ create table t_tag ) comment '系统标签信息表'; --- 系统用户信息表 +-- auto-generated definition create table t_user ( - id bigint unsigned comment '用户唯一主键ID(雪花ID)' + 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 '用户昵称', @@ -270,7 +439,33 @@ create index idx_type on t_user (type) comment '按用户类型查询的索引'; --- 用户权限关联表 +-- auto-generated definition +create table t_user_coupon +( + id bigint unsigned auto_increment comment '用户优惠券关联主键索引' + primary key, + 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 '按用户查询优惠券的索引'; + +-- auto-generated definition create table t_user_permission ( id bigint unsigned auto_increment comment '关联ID' @@ -295,8 +490,7 @@ create index idx_user_id on t_user_permission (user_id) comment '用户ID索引'; - --- VIP权益信息表 +-- auto-generated definition create table t_vip_benefit ( id bigint unsigned auto_increment comment 'VIP权益唯一主键ID(雪花ID)' @@ -312,7 +506,7 @@ create index idx_required_vip_level on t_vip_benefit (required_vip_level) comment '按VIP等级查询权益的索引'; --- 用户VIP信息表 +-- auto-generated definition create table t_vip_info ( id bigint unsigned auto_increment comment 'VIP信息唯一主键ID(雪花ID)' @@ -331,331 +525,28 @@ create index idx_vip_level on t_vip_info (vip_level) comment '按VIP等级查询的索引'; - - --- 清空现有数据 -DELETE FROM t_user_permission WHERE 1=1; -DELETE FROM t_permission WHERE 1=1; -DELETE FROM t_user WHERE 1=1; - --- 插入完整的系统权限 -INSERT INTO t_permission (permission_code, permission_name, permission_group, description, create_time, update_time, is_delete) VALUES --- 首页权限 -('home:view', '查看首页', '首页', '查看系统首页', NOW(), NOW(), 0), - --- 仪表盘权限 -('dashboard:view', '查看仪表盘', '仪表盘', '查看系统仪表盘', NOW(), NOW(), 0), - --- 用户管理权限 -('user:view', '查看用户', '用户管理', '查看用户列表和详情', NOW(), NOW(), 0), -('user:create', '新增用户', '用户管理', '新增用户', NOW(), NOW(), 0), -('user:edit', '编辑用户', '用户管理', '编辑用户信息', NOW(), NOW(), 0), -('user:reset_password', '重置密码', '用户管理', '重置用户密码', NOW(), NOW(), 0), -('user:delete', '删除用户', '用户管理', '删除用户', NOW(), NOW(), 0), - --- 商品管理权限 -('product:view', '查看商品', '商品管理', '查看商品列表和详情', NOW(), NOW(), 0), -('product:create', '新增商品', '商品管理', '新增商品', NOW(), NOW(), 0), -('product:edit', '编辑商品', '商品管理', '编辑商品信息', NOW(), NOW(), 0), -('product:delete', '删除商品', '商品管理', '删除商品', NOW(), NOW(), 0), -('product:category:manage', '管理商品分类', '商品管理', '管理商品分类', NOW(), NOW(), 0), - --- 店铺管理权限 -('shop:view', '查看店铺', '店铺管理', '查看店铺列表和详情', NOW(), NOW(), 0), -('shop:create', '新增店铺', '店铺管理', '新增店铺', NOW(), NOW(), 0), -('shop:edit', '编辑店铺', '店铺管理', '编辑店铺信息', NOW(), NOW(), 0), -('shop:delete', '删除店铺', '店铺管理', '删除店铺', NOW(), NOW(), 0), -('shop:staff:manage', '管理店铺员工', '店铺管理', '管理店铺员工', NOW(), NOW(), 0), - --- 权限管理权限 -('permission:view', '查看权限', '权限管理', '查看权限列表', NOW(), NOW(), 0), -('permission:create', '新增权限', '权限管理', '新增系统权限', NOW(), NOW(), 0), -('permission:edit', '编辑权限', '权限管理', '编辑系统权限', NOW(), NOW(), 0), -('permission:delete', '删除权限', '权限管理', '删除系统权限', NOW(), NOW(), 0), -('permission:assign', '分配权限', '权限管理', '为用户分配权限', NOW(), NOW(), 0), - --- 标签管理权限 -('tag:view', '查看标签', '标签管理', '查看标签列表和详情', NOW(), NOW(), 0), -('tag:create', '新增标签', '标签管理', '新增标签', NOW(), NOW(), 0), -('tag:edit', '编辑标签', '标签管理', '编辑标签信息', NOW(), NOW(), 0), -('tag:delete', '删除标签', '标签管理', '删除标签', NOW(), NOW(), 0), -('tag:assign', '分配标签', '标签管理', '为商品分配标签', NOW(), NOW(), 0), - --- 优惠券管理权限 -('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), - --- 订单管理权限 -('order:view', '查看订单', '订单管理', '查看订单列表和详情', NOW(), NOW(), 0), -('order:edit', '编辑订单', '订单管理', '编辑订单信息', NOW(), NOW(), 0), -('order:delete', '删除订单', '订单管理', '删除订单', NOW(), NOW(), 0), -('order:process', '处理订单', '订单管理', '处理订单状态', NOW(), NOW(), 0); - --- 初始化admin用户,密码为123456 --- 密码使用BCrypt加密,123456的加密值为:$2a$10$EixZaYVK1fsbw1ZfbX3OXePaWxn96p36WQoeG6Lruj3vjPGga31lW -INSERT INTO t_user (id, shop_id, nickname, account, password, type, status, create_time, update_time, is_delete) VALUES -(1, 0, '管理员', 'admin', '$2a$10$EixZaYVK1fsbw1ZfbX3OXePaWxn96p36WQoeG6Lruj3vjPGga31lW', 4, 1, NOW(), NOW(), 0); - --- 为管理员分配权限 --- 首页的全部权限 --- 仪表盘的全部权限 --- 所有店铺的用户管理的全部权限 --- 所有店铺的商品管理的查看权限,无新增编辑删除管理商品分类权限 --- 所有店铺的店铺管理的全部权限 --- 所有店铺的权限管理的全部权限 --- 所有店铺的标签管理的查看权限无新增编辑删除权限 --- 所有店铺的优惠券管理的查看权限 --- 所有店铺的订单管理的查看权限 -INSERT INTO t_user_permission (user_id, permission_id, create_time, update_time, create_by) -SELECT - 1 as user_id, - p.id as permission_id, - NOW() as create_time, - NOW() as update_time, - 1 as create_by -FROM t_permission p -WHERE p.is_delete = 0 -AND p.permission_code IN ( - 'home:view', - 'dashboard:view', - 'user:view', - 'user:create', - 'user:edit', - 'user:reset_password', - 'user:delete', - 'product:view', - 'shop:view', - 'shop:create', - 'shop:edit', - 'shop:delete', - 'shop:staff:manage', - 'permission:view', - 'permission:create', - 'permission:edit', - 'permission:delete', - 'permission:assign', - 'tag:view', - 'coupon:view', - 'order:view' -); - --- 注意:店长和美甲师的权限需要在系统中手动分配,因为需要关联具体的店铺 --- 这里只初始化管理员的权限 - --- 优惠券信息表 -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-已用完', - shop_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 '更新时间', - 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 index idx_shop_id - on t_coupon (shop_id) 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 '按标签查询优惠券的索引'; - --- 购物车表 -create table t_cart -( - id bigint unsigned auto_increment comment '购物车唯一主键ID' - primary key comment '购物车主键索引', - user_id bigint unsigned not null comment '关联用户表主键', - product_id bigint unsigned not null comment '关联商品表主键', - quantity int unsigned default 1 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 '更新时间', - is_delete tinyint unsigned default 0 null comment '逻辑删除:0-未删,1-已删', - constraint uk_user_product - unique (user_id, product_id) comment '用户-商品唯一索引' -) comment '购物车表'; - -create index idx_user_id - on t_cart (user_id) comment '按用户查询购物车的索引'; - --- 订单表 -create table t_order -( - id bigint unsigned auto_increment comment '订单唯一主键ID' - primary key comment '订单主键索引', - order_no varchar(50) not null comment '订单编号', - user_id bigint unsigned not null comment '关联用户表主键', - total_amount decimal(10, 2) not null comment '订单总金额', - actual_amount decimal(10, 2) not null comment '实际支付金额', - coupon_id bigint unsigned default 0 null comment '使用的优惠券ID', - 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_order_no - unique (order_no) comment '订单编号唯一索引' -) comment '订单表'; - -create index idx_status - on t_order (status) comment '按状态查询订单的索引'; - -create index idx_user_id - on t_order (user_id) comment '按用户查询订单的索引'; - --- 订单商品表 -create table t_order_item -( - id bigint unsigned auto_increment comment '订单商品唯一主键ID' - primary key comment '订单商品主键索引', - order_id bigint unsigned not null comment '关联订单表主键', - product_id bigint unsigned not null comment '关联商品表主键', - quantity int unsigned not null comment '商品数量', - price decimal(10, 2) 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 '更新时间', - is_delete tinyint unsigned default 0 null comment '逻辑删除:0-未删,1-已删' -) comment '订单商品表'; - -create index idx_order_id - on t_order_item (order_id) comment '按订单查询商品的索引'; - - --- 商品收藏表 +-- auto-generated definition create table t_wishlist ( - id bigint unsigned auto_increment comment '收藏记录唯一主键ID' - primary key comment '商品收藏主键索引', - user_id bigint unsigned not null comment '关联用户表主键', - product_id bigint unsigned 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 '更新时间', - is_delete tinyint unsigned default 0 null comment '逻辑删除:0-未删除,1-已删除', + id bigint unsigned auto_increment comment '商品收藏主键索引' + primary key, + user_id bigint unsigned not null comment '关联用户表主键', + product_id bigint unsigned 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 '更新时间', + is_delete tinyint unsigned default 0 null comment '逻辑删除:0-未删除,1-已删除', constraint uk_user_product unique (user_id, product_id) comment '用户-商品唯一索引' -) comment '商品收藏表'; - -create index idx_user_id - on t_wishlist (user_id) comment '按用户查询收藏的索引'; +) + comment '商品收藏表'; create index idx_product_id - on t_wishlist (product_id) comment '按商品查询收藏的索引'; + on t_wishlist (product_id) + comment '按商品查询收藏的索引'; + +create index idx_user_id + on t_wishlist (user_id) + comment '按用户查询收藏的索引'; --- 美甲师信息表 -CREATE TABLE t_nail_artist_info ( - id BIGINT UNSIGNED AUTO_INCREMENT COMMENT '美甲师信息唯一主键ID' - PRIMARY KEY COMMENT '美甲师信息主键索引', - user_id BIGINT UNSIGNED NOT NULL COMMENT '关联用户表主键(美甲师用户)', - identity VARCHAR(50) DEFAULT '' NULL COMMENT '身份', - experience INT UNSIGNED DEFAULT 0 NULL COMMENT '从业年限', - skills TEXT NULL COMMENT '技能标签ID集合,多个ID以逗号分隔', - rating DECIMAL(3, 1) DEFAULT 0.0 NULL COMMENT '评分', - status TINYINT UNSIGNED DEFAULT 1 NULL COMMENT '状态:1-营业中,0-休息中', - portfolio 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-已删', - CONSTRAINT uk_user_id - UNIQUE (user_id) COMMENT '用户ID唯一索引(一个美甲师对应一条信息记录)' -) COMMENT '美甲师信息表'; --- 为美甲师信息表添加索引 -CREATE INDEX idx_user_id ON t_nail_artist_info (user_id) COMMENT '按用户查询美甲师信息的索引'; -CREATE INDEX idx_status ON t_nail_artist_info (status) COMMENT '按状态查询美甲师的索引'; - --- 添加美甲师管理相关权限 -INSERT INTO t_permission (permission_code, permission_name, permission_group, description, create_time, update_time, is_delete) VALUES - ('nail_artist:view', '查看美甲师', '美甲师管理', '查看美甲师列表和详情', NOW(), NOW(), 0), - ('nail_artist:edit', '编辑美甲师', '美甲师管理', '编辑美甲师信息', NOW(), NOW(), 0); - --- 为管理员分配美甲师管理权限 -INSERT INTO t_user_permission (user_id, permission_id, create_time, update_time, create_by) -SELECT - 1 as user_id, - p.id as permission_id, - NOW() as create_time, - NOW() as update_time, - 1 as create_by -FROM t_permission p -WHERE p.is_delete = 0 - AND p.permission_code IN ( - 'nail_artist:view', - 'nail_artist:edit' - ); --- 商品点赞记录表 -CREATE TABLE t_product_like ( - id BIGINT UNSIGNED AUTO_INCREMENT COMMENT '点赞记录唯一主键ID' - PRIMARY KEY COMMENT '商品点赞主键索引', - user_id BIGINT UNSIGNED NOT NULL COMMENT '关联用户表主键', - product_id BIGINT UNSIGNED 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 '更新时间', - is_delete TINYINT UNSIGNED DEFAULT 0 NULL COMMENT '逻辑删除:0-未删除,1-已删除', - CONSTRAINT uk_user_product_like - UNIQUE (user_id, product_id) COMMENT '用户-商品唯一索引' -) 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 '按商品查询点赞的索引'; - - -ALTER TABLE t_order_item ADD COLUMN artist_id BIGINT UNSIGNED DEFAULT NULL COMMENT '关联美甲师ID' AFTER price; \ No newline at end of file diff --git a/YumiNail-Core/src/main/resources/files/YumiNail_like_table.sql b/YumiNail-Core/src/main/resources/files/YumiNail_like_table.sql deleted file mode 100644 index b4d7f9ca..00000000 --- a/YumiNail-Core/src/main/resources/files/YumiNail_like_table.sql +++ /dev/null @@ -1,16 +0,0 @@ - --- 商品点赞记录表 -CREATE TABLE t_product_like ( - id BIGINT UNSIGNED AUTO_INCREMENT COMMENT '点赞记录唯一主键ID' - PRIMARY KEY COMMENT '商品点赞主键索引', - user_id BIGINT UNSIGNED NOT NULL COMMENT '关联用户表主键', - product_id BIGINT UNSIGNED 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 '更新时间', - is_delete TINYINT UNSIGNED DEFAULT 0 NULL COMMENT '逻辑删除:0-未删除,1-已删除', - CONSTRAINT uk_user_product_like - UNIQUE (user_id, product_id) COMMENT '用户-商品唯一索引' -) 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 '按商品查询点赞的索引'; diff --git a/YumiNail-Core/src/main/resources/files/add_artist_id_index_to_order_item.sql b/YumiNail-Core/src/main/resources/files/add_artist_id_index_to_order_item.sql deleted file mode 100644 index e1d2f288..00000000 --- a/YumiNail-Core/src/main/resources/files/add_artist_id_index_to_order_item.sql +++ /dev/null @@ -1,2 +0,0 @@ --- 为订单商品表添加美甲师ID索引 -CREATE INDEX idx_artist_id ON t_order_item(artist_id) COMMENT '按美甲师查询订单商品的索引'; diff --git a/YumiNail-Core/src/main/resources/files/add_artist_id_to_order_item.sql b/YumiNail-Core/src/main/resources/files/add_artist_id_to_order_item.sql deleted file mode 100644 index f3aaafb4..00000000 --- a/YumiNail-Core/src/main/resources/files/add_artist_id_to_order_item.sql +++ /dev/null @@ -1,2 +0,0 @@ --- 为订单商品表添加美甲师ID字段 -ALTER TABLE t_order_item ADD COLUMN artist_id BIGINT UNSIGNED DEFAULT NULL COMMENT '关联美甲师ID' AFTER price; diff --git a/YumiNail-Core/src/main/resources/files/add_artist_order_permission.sql b/YumiNail-Core/src/main/resources/files/add_artist_order_permission.sql deleted file mode 100644 index ddd41ffa..00000000 --- a/YumiNail-Core/src/main/resources/files/add_artist_order_permission.sql +++ /dev/null @@ -1,16 +0,0 @@ --- 添加美甲师订单查看权限 -INSERT INTO t_permission (permission_code, permission_name, permission_group, description, create_time, update_time, is_delete) VALUES -('order:artist:view', '美甲师查看订单', '订单管理', '美甲师查看自己的订单', NOW(), NOW(), 0); - --- 为美甲师(type=3)分配订单查看权限 -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 = 3 - AND p.is_delete = 0 - AND p.permission_code = 'order:artist:view'; diff --git a/YumiNail-Core/src/main/resources/files/add_shop_id_to_order.sql b/YumiNail-Core/src/main/resources/files/add_shop_id_to_order.sql deleted file mode 100644 index db4cf78a..00000000 --- a/YumiNail-Core/src/main/resources/files/add_shop_id_to_order.sql +++ /dev/null @@ -1,5 +0,0 @@ --- 为订单表添加店铺ID字段 -ALTER TABLE t_order ADD COLUMN shop_id BIGINT UNSIGNED DEFAULT NULL COMMENT '所属店铺ID' AFTER user_id; - --- 为订单表添加店铺ID索引 -CREATE INDEX idx_shop_id ON t_order(shop_id) COMMENT '按店铺查询订单的索引'; diff --git a/YumiNail-Core/src/main/resources/files/add_user_permission_fields.sql b/YumiNail-Core/src/main/resources/files/add_user_permission_fields.sql deleted file mode 100644 index e0ecea6d..00000000 --- a/YumiNail-Core/src/main/resources/files/add_user_permission_fields.sql +++ /dev/null @@ -1,17 +0,0 @@ --- 给t_user_permission表添加缺失的字段 --- 用于记录更新时间和更新人 - --- 添加update_time字段 -ALTER TABLE t_user_permission -ADD COLUMN update_time DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间' -AFTER create_time; - --- 添加update_by字段 -ALTER TABLE t_user_permission -ADD COLUMN update_by BIGINT UNSIGNED NULL COMMENT '更新人ID' -AFTER create_by; - --- 添加is_delete字段(可选,用于逻辑删除) -ALTER TABLE t_user_permission -ADD COLUMN is_delete TINYINT UNSIGNED DEFAULT 0 COMMENT '逻辑删除:0-未删,1-已删' -AFTER update_by; diff --git a/YumiNail-Core/src/main/resources/files/cart_order.sql b/YumiNail-Core/src/main/resources/files/cart_order.sql deleted file mode 100644 index 9cd1632f..00000000 --- a/YumiNail-Core/src/main/resources/files/cart_order.sql +++ /dev/null @@ -1,101 +0,0 @@ --- 购物车表 -create table t_cart -( - id bigint unsigned auto_increment comment '购物车唯一主键ID' - primary key comment '购物车主键索引', - user_id bigint unsigned not null comment '关联用户表主键', - product_id bigint unsigned not null comment '关联商品表主键', - quantity int unsigned default 1 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 '更新时间', - is_delete tinyint unsigned default 0 null comment '逻辑删除:0-未删,1-已删', - constraint uk_user_product - unique (user_id, product_id) comment '用户-商品唯一索引' -) comment '购物车表'; - -create index idx_user_id - on t_cart (user_id) comment '按用户查询购物车的索引'; - --- 订单表 -create table t_order -( - id bigint unsigned auto_increment comment '订单唯一主键ID' - primary key comment '订单主键索引', - order_no varchar(50) not null comment '订单编号', - user_id bigint unsigned not null comment '关联用户表主键', - total_amount decimal(10, 2) not null comment '订单总金额', - actual_amount decimal(10, 2) not null comment '实际支付金额', - coupon_id bigint unsigned default 0 null comment '使用的优惠券ID', - 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_order_no - unique (order_no) comment '订单编号唯一索引' -) comment '订单表'; - -create index idx_status - on t_order (status) comment '按状态查询订单的索引'; - -create index idx_user_id - on t_order (user_id) comment '按用户查询订单的索引'; - --- 订单商品表 -create table t_order_item -( - id bigint unsigned auto_increment comment '订单商品唯一主键ID' - primary key comment '订单商品主键索引', - order_id bigint unsigned not null comment '关联订单表主键', - product_id bigint unsigned not null comment '关联商品表主键', - quantity int unsigned not null comment '商品数量', - price decimal(10, 2) 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 '更新时间', - is_delete tinyint unsigned default 0 null comment '逻辑删除:0-未删,1-已删' -) comment '订单商品表'; - -create index idx_order_id - on t_order_item (order_id) comment '按订单查询商品的索引'; - --- 插入订单管理相关权限 -INSERT INTO t_permission (permission_code, permission_name, permission_group, description, create_time, update_time, is_delete) VALUES -('order:view', '查看订单', '订单管理', '查看订单列表和详情', NOW(), NOW(), 0), -('order:edit', '编辑订单', '订单管理', '编辑订单信息', NOW(), NOW(), 0), -('order:delete', '删除订单', '订单管理', '删除订单', NOW(), NOW(), 0), -('order:process', '处理订单', '订单管理', '处理订单状态', 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 ( - 'order:view', - 'order:edit', - 'order:delete', - 'order:process' - ); - --- 为店长(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 ( - 'order:view', - 'order:edit', - 'order:delete', - 'order:process' - ); \ No newline at end of file diff --git a/YumiNail-Core/src/main/resources/files/coupon.sql b/YumiNail-Core/src/main/resources/files/coupon.sql deleted file mode 100644 index 49caebdf..00000000 --- a/YumiNail-Core/src/main/resources/files/coupon.sql +++ /dev/null @@ -1,115 +0,0 @@ --- 优惠券信息表 -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 diff --git a/YumiNail-Core/src/main/resources/files/init_admin_permissions.sql b/YumiNail-Core/src/main/resources/files/init_admin_permissions.sql deleted file mode 100644 index 09c06a38..00000000 --- a/YumiNail-Core/src/main/resources/files/init_admin_permissions.sql +++ /dev/null @@ -1,47 +0,0 @@ --- 初始化权限数据并给管理员用户分配所有权限 --- 请先执行 add_user_permission_fields.sql 添加缺失字段 - --- 首先查看当前有哪些用户 --- SELECT id, nickname, type FROM t_user WHERE is_delete = 0; - --- 假设管理员用户的id是1或4(根据type=4判断),先查询一下 --- SET @admin_user_id = (SELECT id FROM t_user WHERE type = 4 AND is_delete = 0 LIMIT 1); - --- 如果没有管理员用户,可以创建一个测试用的管理员用户 --- INSERT INTO t_user (shop_id, nickname, account, password, avatar, signature, level, type, vip_id, status) --- VALUES (0, '系统管理员', 'admin', '$2a$10$N.zmdr9k7uOCQb376NoUnuTJ8iAt6Z5EHsM8lE9lBOsl7iAt6Z5EH', 'https://via.placeholder.com/100', '系统管理员账号', '普通', 4, 0, 1); - --- 给管理员用户分配所有权限 --- 首先获取管理员用户ID -SET @admin_user_id = (SELECT id FROM t_user WHERE type = 4 AND is_delete = 0 ORDER BY id ASC LIMIT 1); - --- 如果找到了管理员用户,分配所有权限 -INSERT INTO t_user_permission (user_id, permission_id, create_by, create_time) -SELECT - @admin_user_id, - id, - @admin_user_id, - NOW() -FROM t_permission -WHERE is_delete = 0 -AND id NOT IN ( - SELECT permission_id - FROM t_user_permission - WHERE user_id = @admin_user_id -); - --- 查看分配结果 -SELECT - u.id AS user_id, - u.nickname, - u.type, - p.permission_code, - p.permission_name, - p.permission_group -FROM t_user u -JOIN t_user_permission up ON u.id = up.user_id -JOIN t_permission p ON up.permission_id = p.id -WHERE u.id = @admin_user_id -AND u.is_delete = 0 -AND p.is_delete = 0 -ORDER BY p.permission_group, p.permission_code; diff --git a/YumiNail-Core/src/main/resources/files/init_permissions.sql b/YumiNail-Core/src/main/resources/files/init_permissions.sql deleted file mode 100644 index 49623534..00000000 --- a/YumiNail-Core/src/main/resources/files/init_permissions.sql +++ /dev/null @@ -1,109 +0,0 @@ --- 清空现有数据 -DELETE FROM t_user_permission WHERE 1=1; -DELETE FROM t_permission WHERE 1=1; -DELETE FROM t_user WHERE 1=1; - --- 插入完整的系统权限 -INSERT INTO t_permission (permission_code, permission_name, permission_group, description, create_time, update_time, is_delete) VALUES --- 首页权限 -('home:view', '查看首页', '首页', '查看系统首页', NOW(), NOW(), 0), - --- 仪表盘权限 -('dashboard:view', '查看仪表盘', '仪表盘', '查看系统仪表盘', NOW(), NOW(), 0), - --- 用户管理权限 -('user:view', '查看用户', '用户管理', '查看用户列表和详情', NOW(), NOW(), 0), -('user:create', '新增用户', '用户管理', '新增用户', NOW(), NOW(), 0), -('user:edit', '编辑用户', '用户管理', '编辑用户信息', NOW(), NOW(), 0), -('user:reset_password', '重置密码', '用户管理', '重置用户密码', NOW(), NOW(), 0), -('user:delete', '删除用户', '用户管理', '删除用户', NOW(), NOW(), 0), - --- 商品管理权限 -('product:view', '查看商品', '商品管理', '查看商品列表和详情', NOW(), NOW(), 0), -('product:create', '新增商品', '商品管理', '新增商品', NOW(), NOW(), 0), -('product:edit', '编辑商品', '商品管理', '编辑商品信息', NOW(), NOW(), 0), -('product:delete', '删除商品', '商品管理', '删除商品', NOW(), NOW(), 0), -('product:category:manage', '管理商品分类', '商品管理', '管理商品分类', NOW(), NOW(), 0), - --- 店铺管理权限 -('shop:view', '查看店铺', '店铺管理', '查看店铺列表和详情', NOW(), NOW(), 0), -('shop:create', '新增店铺', '店铺管理', '新增店铺', NOW(), NOW(), 0), -('shop:edit', '编辑店铺', '店铺管理', '编辑店铺信息', NOW(), NOW(), 0), -('shop:delete', '删除店铺', '店铺管理', '删除店铺', NOW(), NOW(), 0), -('shop:staff:manage', '管理店铺员工', '店铺管理', '管理店铺员工', NOW(), NOW(), 0), - --- 权限管理权限 -('permission:view', '查看权限', '权限管理', '查看权限列表', NOW(), NOW(), 0), -('permission:create', '新增权限', '权限管理', '新增系统权限', NOW(), NOW(), 0), -('permission:edit', '编辑权限', '权限管理', '编辑系统权限', NOW(), NOW(), 0), -('permission:delete', '删除权限', '权限管理', '删除系统权限', NOW(), NOW(), 0), -('permission:assign', '分配权限', '权限管理', '为用户分配权限', NOW(), NOW(), 0), - --- 标签管理权限 -('tag:view', '查看标签', '标签管理', '查看标签列表和详情', NOW(), NOW(), 0), -('tag:create', '新增标签', '标签管理', '新增标签', NOW(), NOW(), 0), -('tag:edit', '编辑标签', '标签管理', '编辑标签信息', NOW(), NOW(), 0), -('tag:delete', '删除标签', '标签管理', '删除标签', NOW(), NOW(), 0), -('tag:assign', '分配标签', '标签管理', '为商品分配标签', NOW(), NOW(), 0), - --- 优惠券管理权限 -('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), - --- 订单管理权限 -('order:view', '查看订单', '订单管理', '查看订单列表和详情', NOW(), NOW(), 0), -('order:edit', '编辑订单', '订单管理', '编辑订单信息', NOW(), NOW(), 0), -('order:delete', '删除订单', '订单管理', '删除订单', NOW(), NOW(), 0), -('order:process', '处理订单', '订单管理', '处理订单状态', NOW(), NOW(), 0); - --- 初始化admin用户,密码为123456 --- 密码使用BCrypt加密,123456的加密值为:$2a$10$EixZaYVK1fsbw1ZfbX3OXePaWxn96p36WQoeG6Lruj3vjPGga31lW -INSERT INTO t_user (id, shop_id, nickname, account, password, type, status, create_time, update_time, is_delete) VALUES -(1, 0, '管理员', 'admin', '$2a$10$EixZaYVK1fsbw1ZfbX3OXePaWxn96p36WQoeG6Lruj3vjPGga31lW', 4, 1, NOW(), NOW(), 0); - --- 为管理员分配权限 --- 首页的全部权限 --- 仪表盘的全部权限 --- 所有店铺的用户管理的全部权限 --- 所有店铺的商品管理的查看权限,无新增编辑删除管理商品分类权限 --- 所有店铺的店铺管理的全部权限 --- 所有店铺的权限管理的全部权限 --- 所有店铺的标签管理的查看权限 --- 所有店铺的优惠券管理的查看权限 -INSERT INTO t_user_permission (user_id, permission_id, create_time, update_time, create_by) -SELECT - 1 as user_id, - p.id as permission_id, - NOW() as create_time, - NOW() as update_time, - 1 as create_by -FROM t_permission p -WHERE p.is_delete = 0 -AND p.permission_code IN ( - 'home:view', - 'dashboard:view', - 'user:view', - 'user:create', - 'user:edit', - 'user:reset_password', - 'user:delete', - 'product:view', - 'shop:view', - 'shop:create', - 'shop:edit', - 'shop:delete', - 'shop:staff:manage', - 'permission:view', - 'permission:create', - 'permission:edit', - 'permission:delete', - 'permission:assign', - 'tag:view', - 'coupon:view' -); - --- 注意:店长和美甲师的权限需要在系统中手动分配,因为需要关联具体的店铺 --- 这里只初始化管理员的权限 diff --git a/YumiNail-Core/src/main/resources/files/migration_add_status_to_user.sql b/YumiNail-Core/src/main/resources/files/migration_add_status_to_user.sql deleted file mode 100644 index 4009f3f5..00000000 --- a/YumiNail-Core/src/main/resources/files/migration_add_status_to_user.sql +++ /dev/null @@ -1,9 +0,0 @@ --- 为t_user表添加status字段 --- 执行时间:2026-02-25 - -ALTER TABLE `t_user` -ADD COLUMN `status` TINYINT UNSIGNED DEFAULT 1 COMMENT '用户状态:1-正常,0-禁用' -AFTER `is_delete`; - --- 为现有用户设置默认状态为正常(1) -UPDATE `t_user` SET `status` = 1 WHERE `status` IS NULL; diff --git a/YumiNail-Core/src/main/resources/files/nail_artist_info.sql b/YumiNail-Core/src/main/resources/files/nail_artist_info.sql deleted file mode 100644 index b7cc5ff2..00000000 --- a/YumiNail-Core/src/main/resources/files/nail_artist_info.sql +++ /dev/null @@ -1,41 +0,0 @@ --- 美甲师信息表 -CREATE TABLE t_nail_artist_info ( - id BIGINT UNSIGNED AUTO_INCREMENT COMMENT '美甲师信息唯一主键ID' - PRIMARY KEY COMMENT '美甲师信息主键索引', - user_id BIGINT UNSIGNED NOT NULL COMMENT '关联用户表主键(美甲师用户)', - identity VARCHAR(50) DEFAULT '' NULL COMMENT '身份', - experience INT UNSIGNED DEFAULT 0 NULL COMMENT '从业年限', - skills TEXT NULL COMMENT '技能标签ID集合,多个ID以逗号分隔', - rating DECIMAL(3, 1) DEFAULT 0.0 NULL COMMENT '评分', - status TINYINT UNSIGNED DEFAULT 1 NULL COMMENT '状态:1-营业中,0-休息中', - portfolio 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-已删', - CONSTRAINT uk_user_id - UNIQUE (user_id) COMMENT '用户ID唯一索引(一个美甲师对应一条信息记录)' -) COMMENT '美甲师信息表'; - --- 为美甲师信息表添加索引 -CREATE INDEX idx_user_id ON t_nail_artist_info (user_id) COMMENT '按用户查询美甲师信息的索引'; -CREATE INDEX idx_status ON t_nail_artist_info (status) COMMENT '按状态查询美甲师的索引'; - --- 添加美甲师管理相关权限 -INSERT INTO t_permission (permission_code, permission_name, permission_group, description, create_time, update_time, is_delete) VALUES -('nail_artist:view', '查看美甲师', '美甲师管理', '查看美甲师列表和详情', NOW(), NOW(), 0), -('nail_artist:edit', '编辑美甲师', '美甲师管理', '编辑美甲师信息', NOW(), NOW(), 0); - --- 为管理员分配美甲师管理权限 -INSERT INTO t_user_permission (user_id, permission_id, create_time, update_time, create_by) -SELECT - 1 as user_id, - p.id as permission_id, - NOW() as create_time, - NOW() as update_time, - 1 as create_by -FROM t_permission p -WHERE p.is_delete = 0 -AND p.permission_code IN ( - 'nail_artist:view', - 'nail_artist:edit' -); diff --git a/docs/features/待优化建议.md b/docs/features/待优化建议.md index ac1570f1..ec1e462f 100644 --- a/docs/features/待优化建议.md +++ b/docs/features/待优化建议.md @@ -7,3 +7,10 @@ 本轮已归档到: - `docs/changes/2026-03-20-待优化建议落地.md` + +1、接下来我会按照YumiNail.sql来重新创建需数据库所有的表,你检查一下所有的sql是否有问题 +2、创建表之后,我需要一些初始化数据实现以下的功能: + 1)添加一个管理员账号,账号为admin01,密码为122503wcy.... + 2)初始化权限表,你先展示出所有功能权限,我在告诉你每个用户具体的权限分配规则,将功能权限全部整理到一个文件中 + 3)按照我所设立的权限规则,写出初始化的sql语句 +