feat: integrate swagger documentation and gin cors middleware

This commit is contained in:
2026-02-12 19:13:58 +08:00
parent aed996f409
commit d51e2dc500
13 changed files with 3378 additions and 131 deletions

View File

@@ -22,13 +22,13 @@ type User struct {
// Company 模型
type Company struct {
ID uint `gorm:"primaryKey"`
CompanyName string `gorm:"uniqueIndex;size:255"`
IsActive bool `gorm:"default:true"`
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt gorm.DeletedAt `gorm:"index"`
Serials []Serial `gorm:"foreignKey:CompanyName;references:CompanyName"`
ID uint `gorm:"primaryKey" json:"id"`
CompanyName string `gorm:"uniqueIndex;size:255" json:"companyName"`
IsActive bool `gorm:"default:true" json:"isActive"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
Serials []Serial `gorm:"foreignKey:CompanyName;references:CompanyName" json:"-"`
}
// Serial 模型
@@ -100,3 +100,66 @@ type UpdateSerialDTO struct {
type QRCodeDTO struct {
BaseUrl string `json:"baseUrl,omitempty"`
}
// LoginResponse 登录响应
type LoginResponse struct {
Message string `json:"message"`
AccessToken string `json:"accessToken"`
User UserDTO `json:"user"`
}
// BaseResponse 基础响应
type BaseResponse struct {
Message string `json:"message"`
}
// ErrorResponse 错误响应
type ErrorResponse struct {
Message string `json:"message"`
Error string `json:"error,omitempty"`
}
// DataResponse 数据响应
type DataResponse struct {
Message string `json:"message"`
Data any `json:"data"`
}
// PaginationResponse 分页响应
type PaginationResponse struct {
Message string `json:"message"`
Data any `json:"data"`
Pagination Pagination `json:"pagination"`
}
// Pagination 分页信息
type Pagination struct {
Page int `json:"page"`
Limit int `json:"limit"`
Total int64 `json:"total"`
TotalPages int `json:"totalPages"`
}
// QRCodeResponse 二维码响应
type QRCodeResponse struct {
Message string `json:"message"`
QRCodeData string `json:"qrCodeData"`
QueryURL string `json:"queryUrl"`
}
// CompanyResponse 企业响应
type CompanyResponse struct {
Message string `json:"message"`
Company Company `json:"company"`
}
// CompanyDataRequest 企业数据请求
type CompanyDataRequest struct {
CompanyName string `json:"companyName" validate:"required"`
}
// CompanyUpdateRequest 企业更新请求
type CompanyUpdateRequest struct {
CompanyName string `json:"companyName"`
IsActive *bool `json:"isActive"`
}