feat: initial commit - Go + CGO captcha recognition service
Features: - Go + CGO ONNX/OpenCV wrapper for high performance - SQLite (default) / MySQL database support - Optional Redis caching - JWT authentication system - Multiple captcha recognition APIs: - OCR text recognition - Slider captcha matching - Image similarity comparison - Rotation captcha detection - Object detection - React frontend with install wizard - Docker and docker-compose support - Gitea CI/CD pipeline Project structure: - cmd/server: Main entry point - internal/: Core business logic - pkg/onnx: ONNX Runtime CGO wrapper - pkg/opencv: OpenCV CGO wrapper - web/: React frontend - deploy/: Deployment configs - scripts/: Utility scripts
This commit is contained in:
@@ -0,0 +1,106 @@
|
||||
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"`
|
||||
}
|
||||
|
||||
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:"img1_base64" binding:"required"`
|
||||
Image2Base64 string `json:"img2_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"`
|
||||
}
|
||||
Reference in New Issue
Block a user