Merge branch 'dev' of github.com:wenjianzhang/go-admin into table/dev
This commit is contained in:
commit
61451d149a
10 files changed
+64
-55
No files matched your search
+1
-15
@@ -16,15 +16,6 @@ type Page struct {
|
||||
PageSize int `json:"pageSize"`
|
||||
}
|
||||
|
||||
type PageResponse struct {
|
||||
// 代码
|
||||
Code int `json:"code" example:"200"`
|
||||
// 数据集
|
||||
Data Page `json:"data"`
|
||||
// 消息
|
||||
Msg string `json:"msg"`
|
||||
}
|
||||
|
||||
func (res *Response) ReturnOK() *Response {
|
||||
res.Code = 200
|
||||
return res
|
||||
@@ -33,9 +24,4 @@ func (res *Response) ReturnOK() *Response {
|
||||
func (res *Response) ReturnError(code int) *Response {
|
||||
res.Code = code
|
||||
return res
|
||||
}
|
||||
|
||||
func (res *PageResponse) ReturnOK() *PageResponse {
|
||||
res.Code = 200
|
||||
return res
|
||||
}
|
||||
}
|
||||
+6
-9
@@ -27,15 +27,12 @@ func OK(c *gin.Context, data interface{}, msg string) {
|
||||
|
||||
// 分页数据处理
|
||||
func PageOK(c *gin.Context, result interface{}, count int, pageIndex int, pageSize int, msg string) {
|
||||
var res PageResponse
|
||||
res.Data.List = result
|
||||
res.Data.Count = count
|
||||
res.Data.PageIndex = pageIndex
|
||||
res.Data.PageSize = pageSize
|
||||
if msg != "" {
|
||||
res.Msg = msg
|
||||
}
|
||||
c.JSON(http.StatusOK, res.ReturnOK())
|
||||
var res Page
|
||||
res.List = result
|
||||
res.Count = count
|
||||
res.PageIndex = pageIndex
|
||||
res.PageSize = pageSize
|
||||
OK(c, res, msg)
|
||||
}
|
||||
|
||||
// 兼容函数
|
||||
|
||||
+1
-1
@@ -34,7 +34,7 @@ func (g GeneralDelDto) GetIds() []string {
|
||||
}
|
||||
|
||||
type GeneralGetDto struct {
|
||||
Id string `uri:"id" json:"id" validate:"required"`
|
||||
Id int `uri:"id" json:"id" validate:"required"`
|
||||
}
|
||||
|
||||
func MakeCondition(q interface{}) func(db *gorm.DB) *gorm.DB {
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package tools
|
||||
|
||||
import (
|
||||
"log"
|
||||
"runtime"
|
||||
"strconv"
|
||||
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
@@ -50,6 +52,8 @@ func HasError(err error, msg string, code ...int) {
|
||||
if msg == "" {
|
||||
msg = err.Error()
|
||||
}
|
||||
_, file, line, _ := runtime.Caller(1)
|
||||
log.Printf("%s:%v",file, line)
|
||||
panic("CustomError#" + strconv.Itoa(statusCode) + "#" + msg)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user