44 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			44 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
| package dto
 | |
| 
 | |
| // CreateUserRequest 定义创建用户请求的结构体
 | |
| type CreateUserRequest struct {
 | |
| 	Username string `json:"username" binding:"required" example:"newuser"`
 | |
| 	Password string `json:"password" binding:"required" example:"password123"`
 | |
| }
 | |
| 
 | |
| // LoginRequest 定义登录请求的结构体
 | |
| type LoginRequest struct {
 | |
| 	// Identifier 可以是用户名、邮箱、手机号、微信号或飞书账号
 | |
| 	Identifier string `json:"identifier" binding:"required" example:"testuser"`
 | |
| 	Password   string `json:"password" binding:"required" example:"password123"`
 | |
| }
 | |
| 
 | |
| // CreateUserResponse 定义创建用户成功响应的结构体
 | |
| type CreateUserResponse struct {
 | |
| 	Username string `json:"username" example:"newuser"`
 | |
| 	ID       uint   `json:"id" example:"1"`
 | |
| }
 | |
| 
 | |
| // LoginResponse 定义登录成功响应的结构体
 | |
| type LoginResponse struct {
 | |
| 	Username string `json:"username" example:"testuser"`
 | |
| 	ID       uint   `json:"id" example:"1"`
 | |
| 	Token    string `json:"token" example:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."`
 | |
| }
 | |
| 
 | |
| // HistoryResponse 定义单条操作历史的响应结构体
 | |
| type HistoryResponse struct {
 | |
| 	UserID         uint        `json:"user_id" example:"101"`
 | |
| 	Username       string      `json:"username" example:"testuser"`
 | |
| 	ActionType     string      `json:"action_type" example:"更新设备"`
 | |
| 	Description    string      `json:"description" example:"设备更新成功"`
 | |
| 	TargetResource interface{} `json:"target_resource"`
 | |
| 	Time           string      `json:"time"`
 | |
| }
 | |
| 
 | |
| // ListHistoryResponse 定义操作历史列表的响应结构体
 | |
| type ListHistoryResponse struct {
 | |
| 	History []HistoryResponse `json:"history"`
 | |
| 	Total   int64             `json:"total" example:"100"`
 | |
| }
 |