github.com/easysoft/zendata@v0.0.0-20240513203326-705bd5a7fd67/cmd/test/others/func/comm/comm.go (about) 1 package comm 2 3 import ( 4 "fmt" 5 "reflect" 6 7 "github.com/easysoft/zendata/cmd/test/others/func/model" 8 9 "github.com/easysoft/zendata/cmd/test/others/func/model" 10 ) 11 12 func GetStructFields(interf interface{}) (fieldNames []string) { 13 retH := reflect.TypeOf(interf) 14 for i := 0; i < retH.NumField(); i++ { 15 f := retH.Field(i) 16 17 name := f.Name 18 19 if name == "DataComm" { 20 name = "Id" 21 } 22 23 if name != "CreatedAt" && name != "UpdatedAt" && name != "Deleted" && name != "Disabled" { 24 fieldNames = append(fieldNames, name) 25 } 26 } 27 28 return 29 } 30 31 func GetExcelColsByTableDef(infos []model.TableInfo) (excelColNameArr, excelColNameHeader []string) { 32 excelColIndex := 'A' 33 34 for _, info := range infos { 35 if info.Field == "created_at" || info.Field == "updated_at" || info.Field == "deleted" || info.Field == "disabled" { 36 continue 37 } 38 39 colName := fmt.Sprintf("%c", excelColIndex) 40 excelColNameArr = append(excelColNameArr, colName) 41 42 excelColNameHeader = append(excelColNameHeader, info.Field) 43 44 excelColIndex += 1 45 } 46 47 return 48 }