Add user management for admin (CRUD + role + reset password)
Adds /api/users endpoints (admin only) plus /api/users/assignable (admin + technician) used by the aftersales reassign picker. Guards prevent self-demotion, self-deletion, and removing the last admin. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -74,6 +74,27 @@ type UpdateProfileDTO struct {
|
||||
Email string `json:"email" validate:"required,email"`
|
||||
}
|
||||
|
||||
// CreateUserDTO 管理员创建用户请求
|
||||
type CreateUserDTO struct {
|
||||
Username string `json:"username" validate:"required,min=3,max=50"`
|
||||
Password string `json:"password" validate:"required,min=6"`
|
||||
Name string `json:"name" validate:"required"`
|
||||
Email string `json:"email" validate:"omitempty,email"`
|
||||
Role string `json:"role" validate:"required,oneof=admin technician user"`
|
||||
}
|
||||
|
||||
// UpdateUserDTO 管理员更新用户信息请求
|
||||
type UpdateUserDTO struct {
|
||||
Name string `json:"name,omitempty"`
|
||||
Email string `json:"email,omitempty" validate:"omitempty,email"`
|
||||
Role string `json:"role,omitempty" validate:"omitempty,oneof=admin technician user"`
|
||||
}
|
||||
|
||||
// AdminResetPasswordDTO 管理员重置用户密码
|
||||
type AdminResetPasswordDTO struct {
|
||||
NewPassword string `json:"newPassword" validate:"required,min=6"`
|
||||
}
|
||||
|
||||
// GenerateSerialDTO 生成序列号请求数据
|
||||
type GenerateSerialDTO struct {
|
||||
CompanyName string `json:"companyName" validate:"required"`
|
||||
|
||||
Reference in New Issue
Block a user