fix swagger

This commit is contained in:
2026-01-18 19:07:41 +08:00
parent 20ed44aa74
commit 7d3915aae2
319 changed files with 7888 additions and 4559 deletions

View File

@@ -1,12 +1,13 @@
package cmd
import (
"TrangleAgent/internal/controller"
"TrangleAgent/internal/controller/websocket"
"context"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/net/ghttp"
"github.com/gogf/gf/v2/os/gcmd"
"leke/internal/controller"
"leke/internal/controller/websocket"
)
var (
@@ -17,9 +18,15 @@ var (
Func: func(ctx context.Context, parser *gcmd.Parser) (err error) {
s := g.Server()
// ... existing code ...
// CORS 中间件
// CORS 中间件 - 排除 swagger 和 openapi 路径
s.Use(func(r *ghttp.Request) {
// 排除 swagger 相关路径
path := r.URL.Path
if path == "/swagger" || path == "/api.json" || path == "/swagger/" || path == "/api.json/" {
r.Middleware.Next()
return
}
r.Response.CORS(ghttp.CORSOptions{
AllowOrigin: "http://localhost:3000,http://localhost:8080",
AllowMethods: "GET,POST,PUT,DELETE,OPTIONS",
@@ -33,7 +40,6 @@ var (
}
r.Middleware.Next()
})
// ... existing code ...
// 注册 API 路由组
s.Group("/api", func(group *ghttp.RouterGroup) {
@@ -44,8 +50,7 @@ var (
// 注册 WebSocket 聊天室路由(不在 /api 组下,因为 WebSocket 不需要中间件)
s.BindHandler("/ws/chat", websocket.HandleChatConnections)
// 配置静态文件服务(用于提供 HTML 客户端页面)
s.SetServerRoot("resource/public")
s.SetDumpRouterMap(false)
s.Run()
return nil

View File

@@ -1,5 +1,4 @@
package consts
// 加盐
const Salt = "leke"
const qa_empathy, qa_presence, qa_initiative, qa_vigor, qa_tenacity = "empathy", "presence", "initiative", "vigor", "tenacity"
const Salt = "TrangleAgent"

View File

@@ -1,13 +1,13 @@
package controller
import (
"leke/internal/controller/containment"
"leke/internal/controller/department"
"leke/internal/controller/forum"
"leke/internal/controller/login"
"leke/internal/controller/room"
"leke/internal/controller/user"
"leke/internal/middleware"
"TrangleAgent/internal/controller/containment"
"TrangleAgent/internal/controller/department"
"TrangleAgent/internal/controller/forum"
"TrangleAgent/internal/controller/login"
"TrangleAgent/internal/controller/room"
"TrangleAgent/internal/controller/user"
"TrangleAgent/internal/middleware"
"github.com/gogf/gf/v2/net/ghttp"
)

View File

@@ -2,10 +2,10 @@ package containment
import (
"context"
"leke/api/containment"
"TrangleAgent/api/containment"
"leke/api/containment/v1"
"leke/internal/service"
"TrangleAgent/api/containment/v1"
"TrangleAgent/internal/service"
)
// ControllerV1 控制器结构体

View File

@@ -3,9 +3,9 @@ package department
import (
"context"
"leke/api/department"
v1 "leke/api/department/v1"
"leke/internal/service"
"TrangleAgent/api/department"
v1 "TrangleAgent/api/department/v1"
"TrangleAgent/internal/service"
)
type ControllerV1 struct{}

View File

@@ -2,8 +2,8 @@ package forum
import (
"context"
v1 "leke/api/forum/v1"
"leke/internal/service"
v1 "TrangleAgent/api/forum/v1"
"TrangleAgent/internal/service"
)
// ForumCommentsCreate 创建评论

View File

@@ -2,8 +2,8 @@ package forum
import (
"context"
v1 "leke/api/forum/v1"
"leke/internal/service"
v1 "TrangleAgent/api/forum/v1"
"TrangleAgent/internal/service"
)
type ControllerV1 struct{}

View File

@@ -3,9 +3,9 @@ package login
import (
"context"
"leke/api/login"
v1 "leke/api/login/v1"
"leke/internal/service"
"TrangleAgent/api/login"
v1 "TrangleAgent/api/login/v1"
"TrangleAgent/internal/service"
"github.com/gogf/gf/v2/errors/gcode"
"github.com/gogf/gf/v2/errors/gerror"

View File

@@ -2,9 +2,9 @@ package room
import (
"context"
"leke/api/room"
v1 "leke/api/room/v1"
"leke/internal/service"
"TrangleAgent/api/room"
v1 "TrangleAgent/api/room/v1"
"TrangleAgent/internal/service"
)
type ControllerV1 struct{}

View File

@@ -3,8 +3,8 @@ package user
import (
"context"
v1 "leke/api/user/v1"
"leke/internal/service"
v1 "TrangleAgent/api/user/v1"
"TrangleAgent/internal/service"
)
type RoleControllerV1 struct{}

View File

@@ -3,8 +3,8 @@ package user
import (
"context"
v1 "leke/api/user/v1"
"leke/internal/service"
v1 "TrangleAgent/api/user/v1"
"TrangleAgent/internal/service"
)
type ControllerV1 struct{}

View File

@@ -5,7 +5,7 @@
package dao
import (
"leke/internal/dao/internal"
"TrangleAgent/internal/dao/internal"
)
// coachesDao is the data access object for the table coaches.

View File

@@ -5,7 +5,7 @@
package dao
import (
"leke/internal/dao/internal"
"TrangleAgent/internal/dao/internal"
)
// commentsDao is the data access object for the table comments.

View File

@@ -5,7 +5,7 @@
package dao
import (
"leke/internal/dao/internal"
"TrangleAgent/internal/dao/internal"
)
// containmentRepoDao is the data access object for the table containment_repo.

View File

@@ -5,7 +5,7 @@
package dao
import (
"leke/internal/dao/internal"
"TrangleAgent/internal/dao/internal"
)
// departmentDao is the data access object for the table department.

View File

@@ -5,7 +5,7 @@
package dao
import (
"leke/internal/dao/internal"
"TrangleAgent/internal/dao/internal"
)
// fansDao is the data access object for the table fans.

View File

@@ -5,7 +5,7 @@
package dao
import (
"leke/internal/dao/internal"
"TrangleAgent/internal/dao/internal"
)
// forumCommentsDao is the data access object for the table forum_comments.

View File

@@ -5,7 +5,7 @@
package dao
import (
"leke/internal/dao/internal"
"TrangleAgent/internal/dao/internal"
)
// forumPostsDao is the data access object for the table forum_posts.

View File

@@ -5,7 +5,7 @@
package dao
import (
"leke/internal/dao/internal"
"TrangleAgent/internal/dao/internal"
)
// groupClassEnrollmentsDao is the data access object for the table group_class_enrollments.

View File

@@ -5,7 +5,7 @@
package dao
import (
"leke/internal/dao/internal"
"TrangleAgent/internal/dao/internal"
)
// groupClassesDao is the data access object for the table group_classes.

View File

@@ -5,7 +5,7 @@
package dao
import (
"leke/internal/dao/internal"
"TrangleAgent/internal/dao/internal"
)
// roleCardsDao is the data access object for the table role_cards.

View File

@@ -5,7 +5,7 @@
package dao
import (
"leke/internal/dao/internal"
"TrangleAgent/internal/dao/internal"
)
// subscribeDao is the data access object for the table subscribe.

View File

@@ -5,7 +5,7 @@
package dao
import (
"leke/internal/dao/internal"
"TrangleAgent/internal/dao/internal"
)
// trpgRoomDao is the data access object for the table trpg_room.

View File

@@ -5,7 +5,7 @@
package dao
import (
"leke/internal/dao/internal"
"TrangleAgent/internal/dao/internal"
)
// userDepartmentDao is the data access object for the table user_department.

View File

@@ -5,7 +5,7 @@
package dao
import (
"leke/internal/dao/internal"
"TrangleAgent/internal/dao/internal"
)
// usersDao is the data access object for the table users.

View File

@@ -5,7 +5,7 @@
package dao
import (
"leke/internal/dao/internal"
"TrangleAgent/internal/dao/internal"
)
// workoutLogsDao is the data access object for the table workout_logs.

View File

@@ -5,10 +5,10 @@ import (
"errors"
"github.com/gogf/gf/v2/errors/gerror"
"github.com/gogf/gf/v2/frame/g"
"leke/api/forum/v1"
"leke/internal/dao"
"leke/internal/model/entity"
"leke/internal/service"
"TrangleAgent/api/forum/v1"
"TrangleAgent/internal/dao"
"TrangleAgent/internal/model/entity"
"TrangleAgent/internal/service"
)
// ForumComments 评论相关方法

View File

@@ -3,10 +3,10 @@ package ForumComments
import (
"context"
"errors"
"leke/api/forum/v1"
"leke/internal/dao"
"leke/internal/model/entity"
"leke/internal/service"
"TrangleAgent/api/forum/v1"
"TrangleAgent/internal/dao"
"TrangleAgent/internal/model/entity"
"TrangleAgent/internal/service"
"github.com/gogf/gf/v2/errors/gerror"
"github.com/gogf/gf/v2/frame/g"

View File

@@ -3,9 +3,9 @@ package containment
import (
"context"
"github.com/gogf/gf/v2/frame/g"
v1 "leke/api/containment/v1"
"leke/internal/model/response"
"leke/internal/service"
v1 "TrangleAgent/api/containment/v1"
"TrangleAgent/internal/model/response"
"TrangleAgent/internal/service"
)
type sContainment struct{}

View File

@@ -2,10 +2,10 @@ package department
import (
"context"
v1 "leke/api/department/v1"
"leke/internal/dao"
"leke/internal/model"
"leke/internal/service"
v1 "TrangleAgent/api/department/v1"
"TrangleAgent/internal/dao"
"TrangleAgent/internal/model"
"TrangleAgent/internal/service"
)
type sDepartment struct{}

View File

@@ -4,9 +4,9 @@ import (
"context"
"github.com/gogf/gf/v2/os/gtime"
v1 "leke/api/user/v1"
"leke/internal/dao"
"leke/internal/service"
v1 "TrangleAgent/api/user/v1"
"TrangleAgent/internal/dao"
"TrangleAgent/internal/service"
)
type sFans struct{}

View File

@@ -5,13 +5,13 @@
package logic
import (
_ "leke/internal/logic/ForumComments"
_ "leke/internal/logic/containment"
_ "leke/internal/logic/department"
_ "leke/internal/logic/fans"
_ "leke/internal/logic/login"
_ "leke/internal/logic/room"
_ "leke/internal/logic/subscribe"
_ "leke/internal/logic/trace"
_ "leke/internal/logic/user"
_ "TrangleAgent/internal/logic/ForumComments"
_ "TrangleAgent/internal/logic/containment"
_ "TrangleAgent/internal/logic/department"
_ "TrangleAgent/internal/logic/fans"
_ "TrangleAgent/internal/logic/login"
_ "TrangleAgent/internal/logic/room"
_ "TrangleAgent/internal/logic/subscribe"
_ "TrangleAgent/internal/logic/trace"
_ "TrangleAgent/internal/logic/user"
)

View File

@@ -6,12 +6,12 @@ import (
"database/sql"
"errors"
"fmt"
v1 "leke/api/login/v1"
"leke/internal/consts"
"leke/internal/dao"
"leke/internal/middleware"
"leke/internal/model"
"leke/internal/service"
v1 "TrangleAgent/api/login/v1"
"TrangleAgent/internal/consts"
"TrangleAgent/internal/dao"
"TrangleAgent/internal/middleware"
"TrangleAgent/internal/model"
"TrangleAgent/internal/service"
"time"
"github.com/gogf/gf/v2/crypto/gmd5"

View File

@@ -2,11 +2,11 @@ package room
import (
"context"
v1 "leke/api/room/v1"
"leke/internal/dao"
"leke/internal/model"
"leke/internal/model/entity"
"leke/internal/service"
v1 "TrangleAgent/api/room/v1"
"TrangleAgent/internal/dao"
"TrangleAgent/internal/model"
"TrangleAgent/internal/model/entity"
"TrangleAgent/internal/service"
)
type sRoom struct{}

View File

@@ -2,9 +2,9 @@ package subscribe
import (
"context"
v1 "leke/api/user/v1"
"leke/internal/dao"
"leke/internal/service"
v1 "TrangleAgent/api/user/v1"
"TrangleAgent/internal/dao"
"TrangleAgent/internal/service"
"github.com/gogf/gf/v2/os/gtime"
)
@@ -143,4 +143,4 @@ func (s *sSubscribe) SubscribeCreate(ctx context.Context, req *v1.SubscribeCreat
}
return
}
}

View File

@@ -3,10 +3,10 @@ package trace
import (
"context"
"fmt"
v1 "leke/api/user/v1"
"leke/internal/dao"
"leke/internal/model/entity"
"leke/internal/service"
v1 "TrangleAgent/api/user/v1"
"TrangleAgent/internal/dao"
"TrangleAgent/internal/model/entity"
"TrangleAgent/internal/service"
"github.com/gogf/gf/v2/database/gdb"
"github.com/gogf/gf/v2/os/gtime"

View File

@@ -2,11 +2,11 @@ package user
import (
"context"
v1 "leke/api/user/v1"
"leke/internal/dao"
"leke/internal/model"
"leke/internal/model/entity"
"leke/internal/service"
v1 "TrangleAgent/api/user/v1"
"TrangleAgent/internal/dao"
"TrangleAgent/internal/model"
"TrangleAgent/internal/model/entity"
"TrangleAgent/internal/service"
"github.com/gogf/gf/v2/errors/gcode"
"github.com/gogf/gf/v2/errors/gerror"

View File

@@ -19,7 +19,7 @@ const (
CtxUsername gctx.StrKey = "username"
// JwtSecretKey is the secret key for JWT signing and validation
// Note: In production, this should be replaced with a secure key
JwtSecretKey = "leke"
JwtSecretKey = "TrangleAgent"
)
// JWTAuth is a middleware that validates JWT tokens in the request header

View File

@@ -7,7 +7,7 @@ package service
import (
"context"
v1 "leke/api/containment/v1"
v1 "TrangleAgent/api/containment/v1"
)
type (

View File

@@ -7,7 +7,7 @@ package service
import (
"context"
v1 "leke/api/department/v1"
v1 "TrangleAgent/api/department/v1"
)
type (

View File

@@ -7,7 +7,7 @@ package service
import (
"context"
v1 "leke/api/user/v1"
v1 "TrangleAgent/api/user/v1"
)
type (

View File

@@ -7,7 +7,7 @@ package service
import (
"context"
v1 "leke/api/forum/v1"
v1 "TrangleAgent/api/forum/v1"
)
type (

View File

@@ -7,7 +7,7 @@ package service
import (
"context"
v1 "leke/api/login/v1"
v1 "TrangleAgent/api/login/v1"
)
type (

View File

@@ -7,7 +7,7 @@ package service
import (
"context"
v1 "leke/api/room/v1"
v1 "TrangleAgent/api/room/v1"
)
type (

View File

@@ -7,7 +7,7 @@ package service
import (
"context"
v1 "leke/api/user/v1"
v1 "TrangleAgent/api/user/v1"
)
type (

View File

@@ -7,7 +7,7 @@ package service
import (
"context"
v1 "leke/api/user/v1"
v1 "TrangleAgent/api/user/v1"
)
type (

View File

@@ -7,7 +7,7 @@ package service
import (
"context"
v1 "leke/api/user/v1"
v1 "TrangleAgent/api/user/v1"
)
type (