package model import "time" // 配置键 const ( KeyAccessKey = "access_key" // 页面进入密钥 ) // Setting 应用配置(key-value),初始数据在启动时写入数据库。 type Setting struct { Key string `gorm:"primaryKey;size:64" json:"key"` Value string `gorm:"size:255" json:"value"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` } // Response 统一响应格式 {code, message, data}。 type Response struct { Code int `json:"code"` Message string `json:"message"` Data interface{} `json:"data,omitempty"` } // 业务错误码 const ( CodeOK = 0 CodeBadParam = 400 CodeUnauthorized = 401 CodeForbidden = 403 CodeNotFound = 404 CodeConflict = 409 CodeServerErr = 500 ) func OK(data interface{}) *Response { return &Response{Code: CodeOK, Message: "ok", Data: data} } func Err(code int, msg string) *Response { return &Response{Code: code, Message: msg} }