feat: dbms新增支持工单流程审批

This commit is contained in:
meilin.huang
2024-02-29 22:12:50 +08:00
parent bf75483a3c
commit f93231da61
115 changed files with 3280 additions and 553 deletions

View File

@@ -635,3 +635,26 @@ func Case2Camel(name string) string {
name = strings.Title(name)
return strings.Replace(name, " ", "", -1)
}
// 结构体转为map
func ToMap(input any) map[string]any {
result := make(map[string]any)
v := Indirect(reflect.ValueOf(input))
if v.Kind() != reflect.Struct {
return result
}
for i := 0; i < v.NumField(); i++ {
field := v.Field(i)
zeroValue := reflect.Zero(field.Type()).Interface()
fieldValue := field.Interface()
if !reflect.DeepEqual(fieldValue, zeroValue) {
result[v.Type().Field(i).Name] = fieldValue
} else {
result[v.Type().Field(i).Name] = zeroValue
}
}
return result
}

View File

@@ -11,10 +11,10 @@ import (
)
type Src struct {
Id *int64 `json:"id"`
Id int64 `json:"id"`
Username string `json:"username"`
CreateTime time.Time `json:"time"`
UpdateTime time.Time
UpdateTime *time.Time
Inner *SrcInner
}
@@ -194,3 +194,12 @@ func TestTemplateResolve(t *testing.T) {
fmt.Println(resolve)
}
func TestToMap(t *testing.T) {
mapRes := ToMap(&Src{
Id: 0,
Username: "哈哈哈",
CreateTime: time.Now(),
})
fmt.Println(mapRes)
}