Ver código fonte

♻️ refactor(component): rename AvatarSelector to ImageSelector

- replace AvatarSelector with ImageSelector in form component
- update documentation to reflect component name change

📝 docs(database): standardize timestamp fields for TypeORM

- update all tables to use created_at and updated_at timestamp format
- add comments for TypeORM decorator usage
- remove unnecessary MySQL client settings and data dump comments
- add table type comments for better clarity
yourname 4 meses atrás
pai
commit
c0f8fd0fc5
2 arquivos alterados com 26 adições e 111 exclusões
  1. 3 3
      .roo/commands/shadcn-manage-page.md
  2. 23 108
      docs/旧数据表.sql

+ 3 - 3
.roo/commands/shadcn-manage-page.md

@@ -250,7 +250,7 @@ const updateForm = useForm<UpdateRequest>({
 
 ## 图片上传集成
 
-### 1. AvatarSelector组件使用
+### 1. ImageSelector组件使用
 ```tsx
 <FormField
   control={form.control}
@@ -259,7 +259,7 @@ const updateForm = useForm<UpdateRequest>({
     <FormItem>
       <FormLabel>头像</FormLabel>
       <FormControl>
-        <AvatarSelector
+        <ImageSelector
           value={field.value || undefined}
           onChange={(value) => field.onChange(value)}
           maxSize={2} // MB
@@ -416,7 +416,7 @@ const [entityToDelete, setEntityToDelete] = useState<number | null>(null);
 - **选择字段**: 使用 `Select`
 - **开关字段**: 使用 `Switch`
 - **日期字段**: 使用 `DatePicker`
-- **图片字段**: 使用 `AvatarSelector`
+- **图片字段**: 使用 `ImageSelector`
 
 ### 3. 业务逻辑复用
 - 保持相同的CRUD操作模式

+ 23 - 108
docs/旧数据表.sql

@@ -1,7 +1,8 @@
+-- 统一改为 TypeORM 标准时间字段格式
+-- 使用 @CreateDateColumn({ name: 'created_at', type: 'timestamp' }) 和 @UpdateDateColumn({ name: 'updated_at', type: 'timestamp' })
 
+-- 广告表
 DROP TABLE IF EXISTS `ad`;
-/*!40101 SET @saved_cs_client     = @@character_set_client */;
-/*!50503 SET character_set_client = utf8mb4 */;
 CREATE TABLE `ad` (
   `id` int unsigned NOT NULL AUTO_INCREMENT,
   `title` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '标题',
@@ -10,81 +11,44 @@ CREATE TABLE `ad` (
   `url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT 'url',
   `img` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '图片',
   `sort` int DEFAULT '0' COMMENT '排序',
-  `create_time` int DEFAULT NULL COMMENT '创建时间',
-  `update_time` int DEFAULT '0' COMMENT '更新时间',
+  `created_at` timestamp DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+  `updated_at` timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
   `status` int unsigned DEFAULT '0' COMMENT '状态',
   `action_type` int DEFAULT '1' COMMENT '跳转类型 0 不跳转 1webview 2小程序页面',
   PRIMARY KEY (`id`) USING BTREE
 ) ENGINE=InnoDB AUTO_INCREMENT=14 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC COMMENT='广告';
-/*!40101 SET character_set_client = @saved_cs_client */;
-
---
--- Dumping data for table `ad`
---
-
---
--- Table structure for table `ad_type`
---
 
+-- 广告类型表
 DROP TABLE IF EXISTS `ad_type`;
-/*!40101 SET @saved_cs_client     = @@character_set_client */;
-/*!50503 SET character_set_client = utf8mb4 */;
 CREATE TABLE `ad_type` (
   `id` int unsigned NOT NULL AUTO_INCREMENT,
   `name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '类型名称',
   `code` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '调用别名',
   `remark` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '备注',
-  `create_time` int unsigned DEFAULT NULL COMMENT '创建时间',
-  `update_time` int unsigned DEFAULT NULL COMMENT '更新时间',
+  `created_at` timestamp DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+  `updated_at` timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
   `status` int DEFAULT '0' COMMENT '状态',
   PRIMARY KEY (`id`) USING BTREE
 ) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC COMMENT='广告类型';
-/*!40101 SET character_set_client = @saved_cs_client */;
-
---
--- Dumping data for table `ad_type`
---
-
-
---
--- Dumping data for table `agent`
---
-
-
---
--- Table structure for table `card`
---
 
+-- 卡表
 DROP TABLE IF EXISTS `card`;
-/*!40101 SET @saved_cs_client     = @@character_set_client */;
-/*!50503 SET character_set_client = utf8mb4 */;
 CREATE TABLE `card` (
   `id` int unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
   `agent_id` int DEFAULT NULL,
   `card_type` int DEFAULT NULL COMMENT '1盛京通卡 2通用联名电子卡',
   `card_no` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '卡号',
   `password` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
-  `create_time` int unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
-  `update_time` int unsigned NOT NULL DEFAULT '0' COMMENT '修改时间',
+  `created_at` timestamp DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+  `updated_at` timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
   `state` int unsigned NOT NULL DEFAULT '1' COMMENT '状态 1绑定 2解绑 通用联名电子卡不可解绑',
   `face_value` decimal(10,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '面值',
   PRIMARY KEY (`id`) USING BTREE,
   UNIQUE KEY `card_no` (`card_no`) USING BTREE
 ) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=COMPACT COMMENT='卡';
-/*!40101 SET character_set_client = @saved_cs_client */;
-
---
--- Dumping data for table `card`
---
-
-
---
--- Table structure for table `category`
---
 
+-- 分类表
 DROP TABLE IF EXISTS `category`;
-/*!40101 SET @saved_cs_client     = @@character_set_client */;
-/*!50503 SET character_set_client = utf8mb4 */;
 CREATE TABLE `category` (
   `id` int NOT NULL AUTO_INCREMENT COMMENT '类别id',
   `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '类别名称',
@@ -94,20 +58,9 @@ CREATE TABLE `category` (
   `state` int DEFAULT '1' COMMENT '状态1可用2不可用',
   PRIMARY KEY (`id`) USING BTREE
 ) ENGINE=InnoDB AUTO_INCREMENT=777709 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC COMMENT='分类表';
-/*!40101 SET character_set_client = @saved_cs_client */;
-
---
--- Dumping data for table `category`
---
-
-
---
--- Table structure for table `city`
---
 
+-- 城市表
 DROP TABLE IF EXISTS `city`;
-/*!40101 SET @saved_cs_client     = @@character_set_client */;
-/*!50503 SET character_set_client = utf8mb4 */;
 CREATE TABLE `city` (
   `id` bigint DEFAULT NULL COMMENT '地区id',
   `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '地区名称',
@@ -116,41 +69,22 @@ CREATE TABLE `city` (
   `state` int DEFAULT '1' COMMENT '状态1可用',
   `sort` int DEFAULT '0' COMMENT '排序数值越大越靠前'
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=COMPACT COMMENT='省、市、区、街道';
-/*!40101 SET character_set_client = @saved_cs_client */;
-
---
--- Dumping data for table `city`
---
-
---
--- Table structure for table `config`
---
 
+-- 配置表
 DROP TABLE IF EXISTS `config`;
-/*!40101 SET @saved_cs_client     = @@character_set_client */;
-/*!50503 SET character_set_client = utf8mb4 */;
 CREATE TABLE `config` (
   `id` int unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
   `key` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '名称',
   `value` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '值',
   `state` int DEFAULT '2' COMMENT '状态 1可用 2禁用',
+  `created_at` timestamp DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+  `updated_at` timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
   PRIMARY KEY (`id`),
   UNIQUE KEY `key_state` (`key`,`state`) USING BTREE COMMENT 'key_state唯一'
 ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
-/*!40101 SET character_set_client = @saved_cs_client */;
-
---
--- Dumping data for table `config`
---
-
-
---
--- Table structure for table `delivery_address`
---
 
+-- 收货地址表
 DROP TABLE IF EXISTS `delivery_address`;
-/*!40101 SET @saved_cs_client     = @@character_set_client */;
-/*!50503 SET character_set_client = utf8mb4 */;
 CREATE TABLE `delivery_address` (
   `id` int NOT NULL AUTO_INCREMENT COMMENT '收货地址id',
   `user_id` int DEFAULT '0' COMMENT '用户id',
@@ -163,45 +97,26 @@ CREATE TABLE `delivery_address` (
   `receiver_town` bigint DEFAULT '0' COMMENT '街道',
   `state` int DEFAULT '1' COMMENT '是否可用1正常2禁用3删除(不显示)',
   `is_default` int DEFAULT '0' COMMENT '是否常用1是 2否',
+  `created_at` timestamp DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+  `updated_at` timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
   PRIMARY KEY (`id`) USING BTREE
 ) ENGINE=InnoDB AUTO_INCREMENT=36 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC COMMENT='用户收货地址表';
-/*!40101 SET character_set_client = @saved_cs_client */;
-
---
--- Dumping data for table `delivery_address`
---
-
-
-
---
--- Table structure for table `express_company`
---
 
+-- 快递公司表
 DROP TABLE IF EXISTS `express_company`;
-/*!40101 SET @saved_cs_client     = @@character_set_client */;
-/*!50503 SET character_set_client = utf8mb4 */;
 CREATE TABLE `express_company` (
   `id` int NOT NULL AUTO_INCREMENT COMMENT '表序号',
   `name` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '物流公司名称',
   `code` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '物流编号',
   `state` int NOT NULL DEFAULT '1' COMMENT '使用状态 1可用 2禁用',
   `sort` int DEFAULT NULL COMMENT '优先级 值越大越优先',
+  `created_at` timestamp DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+  `updated_at` timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
   PRIMARY KEY (`id`) USING BTREE
 ) ENGINE=InnoDB AUTO_INCREMENT=45 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci AVG_ROW_LENGTH=420 ROW_FORMAT=COMPACT COMMENT='物流公司';
-/*!40101 SET character_set_client = @saved_cs_client */;
-
---
--- Dumping data for table `express_company`
---
-
-
---
--- Table structure for table `goods`
---
 
+-- 商品表
 DROP TABLE IF EXISTS `goods`;
-/*!40101 SET @saved_cs_client     = @@character_set_client */;
-/*!50503 SET character_set_client = utf8mb4 */;
 CREATE TABLE `goods` (
   `id` int NOT NULL AUTO_INCREMENT,
   `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '商品名称',