Przeglądaj źródła

✨ feat(user): 添加学员用户类型

- 在UserType枚举中新增TRAINEE类型
- 为学员类型添加紫色徽章样式和显示文本
- 更新用户创建和编辑表单,支持选择学员类型
- 修改用户类型相关文档说明,包含学员类型说明
yourname 6 miesięcy temu
rodzic
commit
2131ee648d

+ 14 - 4
src/client/admin/pages/Users.tsx

@@ -291,11 +291,19 @@ export const UsersPage = () => {
                     <TableCell>{user.email || '-'}</TableCell>
                     <TableCell>{user.name || '-'}</TableCell>
                     <TableCell>
-                      <Badge 
-                        variant={user.userType === UserType.TEACHER ? 'default' : 'secondary'}
-                        className={user.userType === UserType.TEACHER ? 'bg-blue-100 text-blue-800' : 'bg-green-100 text-green-800'}
+                      <Badge
+                        variant={
+                          user.userType === UserType.TEACHER ? 'default' :
+                          user.userType === UserType.STUDENT ? 'secondary' : 'outline'
+                        }
+                        className={
+                          user.userType === UserType.TEACHER ? 'bg-blue-100 text-blue-800' :
+                          user.userType === UserType.STUDENT ? 'bg-green-100 text-green-800' :
+                          'bg-purple-100 text-purple-800'
+                        }
                       >
-                        {user.userType === UserType.TEACHER ? '老师' : '学生'}
+                        {user.userType === UserType.TEACHER ? '老师' :
+                         user.userType === UserType.STUDENT ? '学生' : '学员'}
                       </Badge>
                     </TableCell>
                     <TableCell>
@@ -462,6 +470,7 @@ export const UsersPage = () => {
                         <SelectContent>
                           <SelectItem value={UserType.TEACHER}>老师</SelectItem>
                           <SelectItem value={UserType.STUDENT}>学生</SelectItem>
+                          <SelectItem value={UserType.TRAINEE}>学员</SelectItem>
                         </SelectContent>
                       </Select>
                       <FormMessage />
@@ -587,6 +596,7 @@ export const UsersPage = () => {
                         <SelectContent>
                           <SelectItem value={UserType.TEACHER}>老师</SelectItem>
                           <SelectItem value={UserType.STUDENT}>学生</SelectItem>
+                          <SelectItem value={UserType.TRAINEE}>学员</SelectItem>
                         </SelectContent>
                       </Select>
                       <FormMessage />

+ 1 - 1
src/server/modules/users/user.entity.ts

@@ -49,7 +49,7 @@ export class UserEntity {
     type: 'enum',
     enum: UserType,
     default: UserType.STUDENT,
-    comment: '用户类型(teacher:老师,student:学生)'
+    comment: '用户类型(teacher:老师,student:学生,trainee:学员)'
   })
   userType!: UserType;
 

+ 2 - 1
src/server/modules/users/user.enum.ts

@@ -1,5 +1,6 @@
 
 export enum UserType {
     TEACHER = 'teacher',
-    STUDENT = 'student'
+    STUDENT = 'student',
+    TRAINEE = 'trainee'
   }

+ 6 - 6
src/server/modules/users/user.schema.ts

@@ -65,9 +65,9 @@ export const UserSchema = z.object({
     ],
     description: '用户角色列表'
   }),
-  userType: z.enum([UserType.TEACHER, UserType.STUDENT]).default(UserType.STUDENT).openapi({
+  userType: z.enum([UserType.TEACHER, UserType.STUDENT, UserType.TRAINEE]).default(UserType.STUDENT).openapi({
     example: UserType.STUDENT,
-    description: '用户类型(teacher:老师,student:学生)'
+    description: '用户类型(teacher:老师,student:学生,trainee:学员)'
   }),
   wechatOpenid: z.string().max(255, '微信openid最多255个字符').nullable().openapi({
     example: 'o6_bmjrPTlm6_2sgVt7hMZOPfL2M',
@@ -135,9 +135,9 @@ export const CreateUserDto = z.object({
     example: 1,
     description: '头像文件ID'
   }),
-  userType: z.enum([UserType.TEACHER, UserType.STUDENT]).default(UserType.STUDENT).openapi({
+  userType: z.enum([UserType.TEACHER, UserType.STUDENT, UserType.TRAINEE]).default(UserType.STUDENT).openapi({
     example: UserType.STUDENT,
-    description: '用户类型(teacher:老师,student:学生)'
+    description: '用户类型(teacher:老师,student:学生,trainee:学员)'
   }),
   isDisabled: z.number().int().min(0, '状态值只能是0或1').max(1, '状态值只能是0或1').default(DisabledStatus.ENABLED).optional().openapi({
     example: DisabledStatus.ENABLED,
@@ -179,8 +179,8 @@ export const UpdateUserDto = z.object({
     example: DisabledStatus.ENABLED,
     description: '是否禁用(0:启用,1:禁用)'
   }),
-  userType: z.enum([UserType.TEACHER, UserType.STUDENT]).optional().openapi({
+  userType: z.enum([UserType.TEACHER, UserType.STUDENT, UserType.TRAINEE]).optional().openapi({
     example: UserType.STUDENT,
-    description: '用户类型(teacher:老师,student:学生)'
+    description: '用户类型(teacher:老师,student:学生,trainee:学员)'
   })
 });