lucas
2 months ago
7 changed files with 197 additions and 36 deletions
@ -0,0 +1,44 @@ |
|||
package HTTP_PRPXY |
|||
|
|||
type ABStatus struct { |
|||
Values ABStatusValues `json:"values"` |
|||
Secret string `json:"secret"` |
|||
Type string `json:"type"` |
|||
} |
|||
|
|||
type ABStatusValues struct { |
|||
CreateTime int64 `json:"createTime"` |
|||
Updater string `json:"updater"` |
|||
Deleted bool `json:"deleted"` |
|||
Id string `json:"id"` |
|||
WorkId string `json:"workId"` |
|||
UcId string `json:"ucId"` |
|||
DeviceCode string `json:"deviceCode"` |
|||
UserId string `json:"userId"` |
|||
UserName string `json:"userName"` |
|||
DataTime int64 `json:"dataTime"` |
|||
BeltStatus string `json:"beltStatus"` |
|||
DeviceStatus string `json:"deviceStatus"` |
|||
StartDate int64 `json:"startDate"` |
|||
EndDate int64 `json:"endDate"` |
|||
MainVol int `json:"mainVol"` |
|||
AscendWorkCertificate string `json:"ascend_work_certificate"` |
|||
BeltPoseLeft string `json:"beltPoseLeft"` |
|||
BeltPoseRight string `json:"beltPoseRight"` |
|||
BeltStatusLeft string `json:"beltStatusLeft"` |
|||
BeltStatusRight string `json:"beltStatusRight"` |
|||
TickbVol int `json:"tickbVol"` |
|||
//Avatar interface{} `json:"avatar"`
|
|||
//AlarmType interface{} `json:"alarmType"`
|
|||
//Identity interface{} `json:"identity"`
|
|||
//IdentityImg interface{} `json:"identityImg"`
|
|||
//IdentityImgF interface{} `json:"identityImgF"`
|
|||
//Phone interface{} `json:"phone"`
|
|||
Versions int `json:"versions"` |
|||
//Team interface{} `json:"team"`
|
|||
Longitude string `json:"longitude"` |
|||
Latitude string `json:"latitude"` |
|||
Outsource string `json:"outsource"` |
|||
LocTime int64 `json:"locTime"` |
|||
//WorkLen interface{} `json:"workLen"`
|
|||
} |
@ -0,0 +1,38 @@ |
|||
package testUnit |
|||
|
|||
import ( |
|||
"fmt" |
|||
"goInOut/utils" |
|||
"testing" |
|||
) |
|||
|
|||
// 定义一个结构体,包含嵌套的结构体字段
|
|||
type Person struct { |
|||
Name Name `json:"name"` |
|||
} |
|||
|
|||
type Name struct { |
|||
First string `json:"first"` |
|||
Last string `json:"last"` |
|||
} |
|||
|
|||
func Test_httpProxy(t *testing.T) { |
|||
|
|||
} |
|||
|
|||
func Test_template(t *testing.T) { |
|||
// 创建一个Person实例
|
|||
person := Person{ |
|||
Name: Name{ |
|||
First: "John", |
|||
Last: "Doe", |
|||
}, |
|||
} |
|||
|
|||
templateStr := "Hello, {{.Name.First}} !" |
|||
sbs, err := utils.TextTemplateMatch(person, templateStr) |
|||
println(sbs) |
|||
if err != nil { |
|||
fmt.Println(err.Error()) |
|||
} |
|||
} |
@ -0,0 +1,22 @@ |
|||
package utils |
|||
|
|||
import ( |
|||
"strings" |
|||
"text/template" |
|||
) |
|||
|
|||
func TextTemplateMatch(obj any, textTemplate string) (string, error) { |
|||
// 定义模板字符串
|
|||
tmpl, err := template.New("template").Parse(textTemplate) |
|||
if err != nil { |
|||
panic(err) |
|||
} |
|||
|
|||
sb := strings.Builder{} |
|||
err = tmpl.Execute(&sb, obj) |
|||
if err != nil { |
|||
return "", err |
|||
} |
|||
sbs := sb.String() |
|||
return sbs, err |
|||
} |
Loading…
Reference in new issue