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

@@ -28,9 +28,9 @@ func NewAuthController() *AuthController {
// @Accept json
// @Produce json
// @Param loginData body models.LoginDTO true "登录数据"
// @Success 200 {object} gin.H{message: string, accessToken: string, user: models.UserDTO}
// @Failure 400 {object} gin.H{message: string}
// @Failure 401 {object} gin.H{message: string}
// @Success 200 {object} models.LoginResponse
// @Failure 400 {object} models.ErrorResponse
// @Failure 401 {object} models.ErrorResponse
// @Router /auth/login [post]
func (c *AuthController) Login(ctx *gin.Context) {
var loginData models.LoginDTO
@@ -78,8 +78,8 @@ func (c *AuthController) Login(ctx *gin.Context) {
// @Tags 认证
// @Produce json
// @Security BearerAuth
// @Success 200 {object} models.UserDTO
// @Failure 401 {object} gin.H{message: string}
// @Success 200 {object} models.DataResponse
// @Failure 401 {object} models.ErrorResponse
// @Router /auth/profile [get]
func (c *AuthController) GetProfile(ctx *gin.Context) {
userModel, ok := GetCurrentUser(ctx)
@@ -106,9 +106,9 @@ func (c *AuthController) GetProfile(ctx *gin.Context) {
// @Produce json
// @Security BearerAuth
// @Param passwordData body models.ChangePasswordDTO true "密码修改数据"
// @Success 200 {object} gin.H{message: string}
// @Failure 400 {object} gin.H{message: string}
// @Failure 401 {object} gin.H{message: string}
// @Success 200 {object} models.BaseResponse
// @Failure 400 {object} models.ErrorResponse
// @Failure 401 {object} models.ErrorResponse
// @Router /auth/change-password [post]
func (c *AuthController) ChangePassword(ctx *gin.Context) {
userModel, ok := GetCurrentUser(ctx)
@@ -138,9 +138,9 @@ func (c *AuthController) ChangePassword(ctx *gin.Context) {
// @Produce json
// @Security BearerAuth
// @Param profileData body models.UpdateProfileDTO true "用户信息更新数据"
// @Success 200 {object} models.UserDTO
// @Failure 400 {object} gin.H{message: string}
// @Failure 401 {object} gin.H{message: string}
// @Success 200 {object} models.DataResponse
// @Failure 400 {object} models.ErrorResponse
// @Failure 401 {object} models.ErrorResponse
// @Router /auth/profile [put]
func (c *AuthController) UpdateProfile(ctx *gin.Context) {
userModel, ok := GetCurrentUser(ctx)