mirror of
https://github.com/quarkcloudio/quark-go.git
synced 2025-10-09 18:00:32 +08:00
fix: 修复bug
This commit is contained in:
@@ -19,7 +19,7 @@ const (
|
|||||||
AppName = "QuarkGo"
|
AppName = "QuarkGo"
|
||||||
|
|
||||||
// Version of current package
|
// Version of current package
|
||||||
Version = "1.1.19"
|
Version = "1.1.20"
|
||||||
|
|
||||||
// 静态文件URL
|
// 静态文件URL
|
||||||
RespositoryURL = "https://github.com/quarkcms/quark-go/tree/main/website/"
|
RespositoryURL = "https://github.com/quarkcms/quark-go/tree/main/website/"
|
||||||
|
@@ -86,14 +86,23 @@ func (p *UpdateRequest) Handle(ctx *builder.Context) interface{} {
|
|||||||
if value, ok := formValue.(float64); ok {
|
if value, ok := formValue.(float64); ok {
|
||||||
reflectValue = reflect.ValueOf(int(value))
|
reflectValue = reflect.ValueOf(int(value))
|
||||||
}
|
}
|
||||||
|
if reflectValue.IsZero() {
|
||||||
|
zeroValues[fieldName] = 0
|
||||||
|
}
|
||||||
case "float64":
|
case "float64":
|
||||||
if value, ok := formValue.(float64); ok {
|
if value, ok := formValue.(float64); ok {
|
||||||
reflectValue = reflect.ValueOf(float64(value))
|
reflectValue = reflect.ValueOf(float64(value))
|
||||||
}
|
}
|
||||||
|
if reflectValue.IsZero() {
|
||||||
|
zeroValues[fieldName] = 0
|
||||||
|
}
|
||||||
case "float32":
|
case "float32":
|
||||||
if value, ok := formValue.(float64); ok {
|
if value, ok := formValue.(float64); ok {
|
||||||
reflectValue = reflect.ValueOf(float32(value))
|
reflectValue = reflect.ValueOf(float32(value))
|
||||||
}
|
}
|
||||||
|
if reflectValue.IsZero() {
|
||||||
|
zeroValues[fieldName] = 0
|
||||||
|
}
|
||||||
case "time.Time":
|
case "time.Time":
|
||||||
getTime, _ := time.ParseInLocation("2006-01-02 15:04:05", formValue.(string), time.Local)
|
getTime, _ := time.ParseInLocation("2006-01-02 15:04:05", formValue.(string), time.Local)
|
||||||
reflectValue = reflect.ValueOf(getTime)
|
reflectValue = reflect.ValueOf(getTime)
|
||||||
@@ -102,17 +111,18 @@ func (p *UpdateRequest) Handle(ctx *builder.Context) interface{} {
|
|||||||
if reflect.ValueOf(formValue).Type().String() == "[]uint8" {
|
if reflect.ValueOf(formValue).Type().String() == "[]uint8" {
|
||||||
reflectValue = reflect.ValueOf(string(formValue.([]uint8)))
|
reflectValue = reflect.ValueOf(string(formValue.([]uint8)))
|
||||||
}
|
}
|
||||||
|
if reflectValue.IsZero() {
|
||||||
|
zeroValues[fieldName] = nil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if reflectFieldName.Type().String() != reflectValue.Type().String() {
|
if reflectValue.IsValid() {
|
||||||
return ctx.JSON(200, msg.Error("结构体类型与传参类型不一致!", ""))
|
if reflectFieldName.Type().String() != reflectValue.Type().String() {
|
||||||
}
|
return ctx.JSON(200, msg.Error("结构体类型与传参类型不一致!", ""))
|
||||||
|
}
|
||||||
|
|
||||||
if reflectValue.IsZero() {
|
reflectFieldName.Set(reflectValue)
|
||||||
zeroValues[fieldName] = 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
reflectFieldName.Set(reflectValue)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user