mirror of
https://gitee.com/xiangheng/x_admin.git
synced 2025-10-08 09:31:26 +08:00
api增加ts
This commit is contained in:
@@ -69,6 +69,34 @@ func (tu toolsUtil) Contains(src interface{}, elem interface{}) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: Go类型转TS类型
|
||||
*/
|
||||
func (tu toolsUtil) GoToTsType(s string) string {
|
||||
if s == "int" || s == "int8" || s == "int16" || s == "int32" || s == "int64" {
|
||||
return "number"
|
||||
} else if s == "float" || s == "float32" || s == "float64" {
|
||||
return "number"
|
||||
} else if s == "string" {
|
||||
return "string"
|
||||
} else if s == "bool" {
|
||||
return "boolean"
|
||||
} else if s == "time.Time" {
|
||||
return "Date"
|
||||
} else if s == "[]byte" {
|
||||
return "string"
|
||||
} else if s == "[]string" {
|
||||
return "string[]"
|
||||
} else if s == "[]int" {
|
||||
return "number[]"
|
||||
} else if s == "[]float" {
|
||||
return "number[]"
|
||||
} else if s == "core.TsTime" {
|
||||
return "string"
|
||||
}
|
||||
return "string"
|
||||
}
|
||||
|
||||
// Round float四舍五入
|
||||
func (tu toolsUtil) Round(val float64, n int) float64 {
|
||||
base := math.Pow(10, float64(n))
|
||||
|
Reference in New Issue
Block a user