🎉 初始化项目

This commit is contained in:
2026-03-03 06:05:51 +08:00
commit e1c70fe218
241 changed files with 148285 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
package request
import (
"github.com/golang-jwt/jwt/v5"
"github.com/google/uuid"
)
// BaseClaims 基础 Claims
type BaseClaims struct {
UUID uuid.UUID
ID uint
Username string
NickName string
AuthorityId uint
}
// CustomClaims 自定义 Claims
type CustomClaims struct {
BaseClaims
BufferTime int64
jwt.RegisteredClaims
}

View File

@@ -0,0 +1,27 @@
package request
// CreateApiRequest 创建API请求
type CreateApiRequest struct {
Path string `json:"path" binding:"required"`
Description string `json:"description"`
ApiGroup string `json:"apiGroup" binding:"required"`
Method string `json:"method" binding:"required,oneof=GET POST PUT DELETE PATCH"`
}
// UpdateApiRequest 更新API请求
type UpdateApiRequest struct {
ID uint `json:"id" binding:"required"`
Path string `json:"path" binding:"required"`
Description string `json:"description"`
ApiGroup string `json:"apiGroup" binding:"required"`
Method string `json:"method" binding:"required,oneof=GET POST PUT DELETE PATCH"`
}
// GetApiListRequest 获取API列表请求
type GetApiListRequest struct {
Page int `json:"page" form:"page"`
PageSize int `json:"pageSize" form:"pageSize"`
Path string `json:"path" form:"path"`
ApiGroup string `json:"apiGroup" form:"apiGroup"`
Method string `json:"method" form:"method"`
}

View File

@@ -0,0 +1,22 @@
package request
type LoginRequest struct {
Username string `json:"username" binding:"required"`
Password string `json:"password" binding:"required"`
}
type RegisterRequest struct {
Username string `json:"username" binding:"required,min=3,max=50"`
Password string `json:"password" binding:"required,min=6"`
Email string `json:"email" binding:"email"`
}
type UpdateUserRequest struct {
ID uint `json:"id"`
Nickname string `json:"nickname"`
Email string `json:"email"`
Phone string `json:"phone"`
Avatar string `json:"avatar"`
Role string `json:"role"`
Status string `json:"status"`
}

View File

@@ -0,0 +1,14 @@
package response
import "time"
// ApiInfo API信息
type ApiInfo struct {
ID uint `json:"id"`
Path string `json:"path"`
Description string `json:"description"`
ApiGroup string `json:"apiGroup"`
Method string `json:"method"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}

View File

@@ -0,0 +1,17 @@
package response
type LoginResponse struct {
Token string `json:"token"`
User UserInfo `json:"user"`
}
type UserInfo struct {
ID uint `json:"id"`
Username string `json:"username"`
Nickname string `json:"nickname"`
Email string `json:"email"`
Phone string `json:"phone"`
Avatar string `json:"avatar"`
Role string `json:"role"`
Status string `json:"status"`
}

View File

@@ -0,0 +1,18 @@
package system
import (
"git.echol.cn/loser/ai_proxy/server/global"
)
// SysApi API管理
type SysApi struct {
global.GVA_MODEL
Path string `json:"path" gorm:"comment:API路径;size:255;not null"`
Description string `json:"description" gorm:"comment:API描述;size:500"`
ApiGroup string `json:"apiGroup" gorm:"comment:API分组;size:100"`
Method string `json:"method" gorm:"comment:请求方法;size:20;not null"` // GET/POST/PUT/DELETE
}
func (SysApi) TableName() string {
return "sys_apis"
}

View File

@@ -0,0 +1,56 @@
package system
import (
"git.echol.cn/loser/ai_proxy/server/global"
"github.com/google/uuid"
)
// SysUser 系统用户
type SysUser struct {
global.GVA_MODEL
Username string `json:"username" gorm:"comment:用户名;size:100;uniqueIndex;not null"`
Password string `json:"-" gorm:"comment:密码;size:255;not null"`
Nickname string `json:"nickname" gorm:"comment:昵称;size:100"`
Email string `json:"email" gorm:"comment:邮箱;size:100"`
Phone string `json:"phone" gorm:"comment:手机号;size:20"`
Avatar string `json:"avatar" gorm:"comment:头像;size:500"`
Role string `json:"role" gorm:"comment:角色;size:20;default:'user'"` // admin/user
Status string `json:"status" gorm:"comment:状态;size:20;default:'active'"` // active/disabled
APIKey string `json:"apiKey" gorm:"comment:API密钥;size:255;uniqueIndex"`
}
func (SysUser) TableName() string {
return "sys_users"
}
// Login 接口实现
type Login interface {
GetUUID() uuid.UUID
GetUserId() uint
GetUsername() string
GetNickname() string
GetAuthorityId() uint
}
func (s *SysUser) GetUUID() uuid.UUID {
return uuid.New()
}
func (s *SysUser) GetUserId() uint {
return s.ID
}
func (s *SysUser) GetUsername() string {
return s.Username
}
func (s *SysUser) GetNickname() string {
return s.Nickname
}
func (s *SysUser) GetAuthorityId() uint {
if s.Role == "admin" {
return 1
}
return 2
}