Copy摞动位置

This commit is contained in:
xiangheng
2024-07-01 22:39:42 +08:00
parent a3ee34aa66
commit c0ad048170
2 changed files with 16 additions and 11 deletions

View File

@@ -1,9 +1,24 @@
package response
//PageResp 分页返回值
import (
"x_admin/core"
"github.com/jinzhu/copier"
)
// PageResp 分页返回值
type PageResp struct {
Count int64 `json:"count"` // 总数
PageNo int `json:"pageNo"` // 每页数量
PageSize int `json:"pageSize"` // 每页Size
Lists interface{} `json:"lists"` // 数据
}
// Copy 拷贝结构体
func Copy(toValue interface{}, fromValue interface{}) interface{} {
if err := copier.Copy(toValue, fromValue); err != nil {
core.Logger.Errorf("Copy err: err=[%+v]", err)
panic(SystemError)
}
return toValue
}

View File

@@ -8,7 +8,6 @@ import (
"github.com/gin-gonic/gin"
"github.com/go-sql-driver/mysql"
"github.com/jinzhu/copier"
"go.uber.org/zap"
"gorm.io/gorm"
)
@@ -95,15 +94,6 @@ func Result(c *gin.Context, resp RespType, data interface{}) {
})
}
// Copy 拷贝结构体
func Copy(toValue interface{}, fromValue interface{}) interface{} {
if err := copier.Copy(toValue, fromValue); err != nil {
core.Logger.Errorf("Copy err: err=[%+v]", err)
panic(SystemError)
}
return toValue
}
// Ok 正常响应
func Ok(c *gin.Context) {
Result(c, Success, nil)