234d9a9acb
- Change img1_base64/img2_base64 to image1_base64/image2_base64 - Match original AntiCAP API parameter names
112 lines
3.3 KiB
Go
112 lines
3.3 KiB
Go
package model
|
|
|
|
import (
|
|
"time"
|
|
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
type UserRole string
|
|
|
|
const (
|
|
RoleAdmin UserRole = "admin"
|
|
RoleUser UserRole = "user"
|
|
)
|
|
|
|
type User struct {
|
|
ID uint `gorm:"primarykey" json:"id"`
|
|
Username string `gorm:"uniqueIndex;size:50;not null" json:"username"`
|
|
HashedPassword string `gorm:"size:255;not null" json:"-"`
|
|
Role UserRole `gorm:"size:20;default:user" json:"role"`
|
|
Balance int `gorm:"default:1000" json:"balance"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
|
|
}
|
|
|
|
type RegistrationCode struct {
|
|
ID uint `gorm:"primarykey" json:"id"`
|
|
Code string `gorm:"uniqueIndex;size:100;not null" json:"code"`
|
|
IsUsed bool `gorm:"default:false" json:"is_used"`
|
|
Points int `gorm:"default:1000" json:"points"`
|
|
CreatedBy uint `json:"created_by"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
}
|
|
|
|
type EndpointCost struct {
|
|
ID uint `gorm:"primarykey" json:"id"`
|
|
Path string `gorm:"uniqueIndex;size:100;not null" json:"path"`
|
|
Cost int `gorm:"default:1" json:"cost"`
|
|
Description string `gorm:"size:255" json:"description"`
|
|
}
|
|
|
|
type Config struct {
|
|
ID uint `gorm:"primarykey" json:"id"`
|
|
Key string `gorm:"uniqueIndex;size:100;not null" json:"key"`
|
|
Value string `gorm:"type:text" json:"value"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|
|
|
|
// 验证码请求模型
|
|
|
|
type OCRRequest struct {
|
|
ImageBase64 string `json:"img_base64" binding:"required"`
|
|
}
|
|
|
|
type MathRequest struct {
|
|
ImageBase64 string `json:"img_base64" binding:"required"`
|
|
}
|
|
|
|
type SliderMatchRequest struct {
|
|
TargetBase64 string `json:"target_base64" binding:"required"`
|
|
BackgroundBase64 string `json:"background_base64" binding:"required"`
|
|
}
|
|
|
|
type RotateRequest struct {
|
|
ImageBase64 string `json:"img_base64" binding:"required"`
|
|
}
|
|
|
|
type DoubleRotateRequest struct {
|
|
InsideBase64 string `json:"inside_base64" binding:"required"`
|
|
OutsideBase64 string `json:"outside_base64" binding:"required"`
|
|
CheckPixel int `json:"check_pixel"` // 检查像素,默认0
|
|
SpeedRatio float64 `json:"speed_ratio"` // 速度比例,默认0
|
|
Grayscale bool `json:"grayscale"` // 灰度处理
|
|
Anticlockwise bool `json:"anticlockwise"` // 逆时针旋转
|
|
CutPixelValue int `json:"cut_pixel_value"` // 割像素值,默认0
|
|
}
|
|
|
|
type DetectIconRequest struct {
|
|
ImageBase64 string `json:"img_base64" binding:"required"`
|
|
}
|
|
|
|
type DetectIconOrderRequest struct {
|
|
OrderImgBase64 string `json:"order_img_base64" binding:"required"`
|
|
TargetImgBase64 string `json:"target_img_base64" binding:"required"`
|
|
}
|
|
|
|
type CompareImageRequest struct {
|
|
Image1Base64 string `json:"image1_base64" binding:"required"`
|
|
Image2Base64 string `json:"image2_base64" binding:"required"`
|
|
}
|
|
|
|
// 响应模型
|
|
|
|
type CaptchaResult struct {
|
|
Result interface{} `json:"result"`
|
|
}
|
|
|
|
type LoginResponse struct {
|
|
AccessToken string `json:"access_token"`
|
|
TokenType string `json:"token_type"`
|
|
Role string `json:"role"`
|
|
Balance int `json:"balance"`
|
|
}
|
|
|
|
type UserResponse struct {
|
|
ID uint `json:"id"`
|
|
Username string `json:"username"`
|
|
Role string `json:"role"`
|
|
Balance int `json:"balance"`
|
|
}
|