api增加ts

This commit is contained in:
xiangheng
2024-06-07 15:45:15 +08:00
parent 3ba60a3d49
commit f8e51648d3
35 changed files with 401 additions and 127 deletions

View File

@@ -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))