server/api/v1层代码swagger备注错误修改及代码优化

This commit is contained in:
SliverHorn
2020-11-08 02:43:11 +08:00
parent c342e63e63
commit 96380bd031
21 changed files with 617 additions and 658 deletions
+2 -2
View File
@@ -3,7 +3,7 @@ package request
import uuid "github.com/satori/go.uuid"
// User register structure
type RegisterStruct struct {
type Register struct {
Username string `json:"userName"`
Password string `json:"passWord"`
NickName string `json:"nickName" gorm:"default:'QMPlusUser'"`
@@ -12,7 +12,7 @@ type RegisterStruct struct {
}
// User login structure
type RegisterAndLoginStruct struct {
type Login struct {
Username string `json:"username"`
Password string `json:"password"`
Captcha string `json:"captcha"`
+54
View File
@@ -0,0 +1,54 @@
package response
import (
"github.com/gin-gonic/gin"
"net/http"
)
type Response struct {
Code int `json:"code"`
Data interface{} `json:"data"`
Msg string `json:"msg"`
}
const (
ERROR = 7
SUCCESS = 0
)
func Result(code int, data interface{}, msg string, c *gin.Context) {
// 开始时间
c.JSON(http.StatusOK, Response{
code,
data,
msg,
})
}
func Ok(c *gin.Context) {
Result(SUCCESS, map[string]interface{}{}, "操作成功", c)
}
func OkWithMessage(message string, c *gin.Context) {
Result(SUCCESS, map[string]interface{}{}, message, c)
}
func OkWithData(data interface{}, c *gin.Context) {
Result(SUCCESS, data, "操作成功", c)
}
func OkWithDetailed(data interface{}, message string, c *gin.Context) {
Result(SUCCESS, data, message, c)
}
func Fail(c *gin.Context) {
Result(ERROR, map[string]interface{}{}, "操作失败", c)
}
func FailWithMessage(message string, c *gin.Context) {
Result(ERROR, map[string]interface{}{}, message, c)
}
func FailWithDetailed(data interface{}, message string, c *gin.Context) {
Result(ERROR, data, message, c)
}