mirror of
https://github.com/zeromicro/go-zero.git
synced 2025-01-23 09:00:20 +08:00
refactor: simplify the code (#1670)
This commit is contained in:
parent
93d524b797
commit
f060a226bc
@ -41,26 +41,21 @@ func RawFieldNames(in interface{}, postgresSql ...bool) []string {
|
|||||||
out = append(out, fmt.Sprintf("`%s`", fi.Name))
|
out = append(out, fmt.Sprintf("`%s`", fi.Name))
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
//get tag name with the tag opton, e.g.:
|
// get tag name with the tag opton, e.g.:
|
||||||
//`db:"id"`
|
// `db:"id"`
|
||||||
//`db:"id,type=char,length=16"`
|
// `db:"id,type=char,length=16"`
|
||||||
//`db:",type=char,length=16"`
|
// `db:",type=char,length=16"`
|
||||||
if strings.Contains(tagv, ",") {
|
if strings.Contains(tagv, ",") {
|
||||||
tagv = strings.TrimSpace(strings.Split(tagv, ",")[0])
|
tagv = strings.TrimSpace(strings.Split(tagv, ",")[0])
|
||||||
}
|
}
|
||||||
if tagv != "" {
|
if len(tagv) == 0 {
|
||||||
|
tagv = fi.Name
|
||||||
|
}
|
||||||
if pg {
|
if pg {
|
||||||
out = append(out, tagv)
|
out = append(out, tagv)
|
||||||
} else {
|
} else {
|
||||||
out = append(out, fmt.Sprintf("`%s`", tagv))
|
out = append(out, fmt.Sprintf("`%s`", tagv))
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
if pg {
|
|
||||||
out = append(out, fi.Name)
|
|
||||||
} else {
|
|
||||||
out = append(out, fmt.Sprintf("`%s`", fi.Name))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user