github.com/erda-project/erda-infra@v1.0.10-0.20240327085753-f3a249292aeb/examples/service/protocol/pb/user.form.pb.go (about) 1 // Code generated by protoc-gen-form. DO NOT EDIT. 2 // Source: user.proto 3 4 package pb 5 6 import ( 7 url "net/url" 8 strconv "strconv" 9 10 urlenc "github.com/erda-project/erda-infra/pkg/urlenc" 11 ) 12 13 // This is a compile-time assertion to ensure that this generated file 14 // is compatible with the "github.com/erda-project/erda-infra/pkg/urlenc" package it is being compiled against. 15 var _ urlenc.URLValuesUnmarshaler = (*User)(nil) 16 var _ urlenc.URLValuesUnmarshaler = (*GetUserRequest)(nil) 17 var _ urlenc.URLValuesUnmarshaler = (*GetUserResponse)(nil) 18 var _ urlenc.URLValuesUnmarshaler = (*UpdateUserRequest)(nil) 19 var _ urlenc.URLValuesUnmarshaler = (*UpdateUserResponse)(nil) 20 21 // User implement urlenc.URLValuesUnmarshaler. 22 func (m *User) UnmarshalURLValues(prefix string, values url.Values) error { 23 for key, vals := range values { 24 if len(vals) > 0 { 25 switch prefix + key { 26 case "id": 27 val, err := strconv.ParseInt(vals[0], 10, 64) 28 if err != nil { 29 return err 30 } 31 m.Id = val 32 case "name": 33 m.Name = vals[0] 34 case "age": 35 val, err := strconv.ParseInt(vals[0], 10, 32) 36 if err != nil { 37 return err 38 } 39 m.Age = int32(val) 40 case "books": 41 list := make([]int64, 0, len(vals)) 42 for _, text := range vals { 43 val, err := strconv.ParseInt(text, 10, 64) 44 if err != nil { 45 return err 46 } 47 list = append(list, val) 48 } 49 m.Books = list 50 } 51 } 52 } 53 return nil 54 } 55 56 // GetUserRequest implement urlenc.URLValuesUnmarshaler. 57 func (m *GetUserRequest) UnmarshalURLValues(prefix string, values url.Values) error { 58 for key, vals := range values { 59 if len(vals) > 0 { 60 switch prefix + key { 61 case "id": 62 m.Id = vals[0] 63 } 64 } 65 } 66 return nil 67 } 68 69 // GetUserResponse implement urlenc.URLValuesUnmarshaler. 70 func (m *GetUserResponse) UnmarshalURLValues(prefix string, values url.Values) error { 71 for key, vals := range values { 72 if len(vals) > 0 { 73 switch prefix + key { 74 case "success": 75 val, err := strconv.ParseBool(vals[0]) 76 if err != nil { 77 return err 78 } 79 m.Success = val 80 case "data": 81 if m.Data == nil { 82 m.Data = &User{} 83 } 84 case "data.id": 85 if m.Data == nil { 86 m.Data = &User{} 87 } 88 val, err := strconv.ParseInt(vals[0], 10, 64) 89 if err != nil { 90 return err 91 } 92 m.Data.Id = val 93 case "data.name": 94 if m.Data == nil { 95 m.Data = &User{} 96 } 97 m.Data.Name = vals[0] 98 case "data.age": 99 if m.Data == nil { 100 m.Data = &User{} 101 } 102 val, err := strconv.ParseInt(vals[0], 10, 32) 103 if err != nil { 104 return err 105 } 106 m.Data.Age = int32(val) 107 case "data.books": 108 if m.Data == nil { 109 m.Data = &User{} 110 } 111 list := make([]int64, 0, len(vals)) 112 for _, text := range vals { 113 val, err := strconv.ParseInt(text, 10, 64) 114 if err != nil { 115 return err 116 } 117 list = append(list, val) 118 } 119 m.Data.Books = list 120 } 121 } 122 } 123 return nil 124 } 125 126 // UpdateUserRequest implement urlenc.URLValuesUnmarshaler. 127 func (m *UpdateUserRequest) UnmarshalURLValues(prefix string, values url.Values) error { 128 for key, vals := range values { 129 if len(vals) > 0 { 130 switch prefix + key { 131 case "user": 132 if m.User == nil { 133 m.User = &User{} 134 } 135 case "user.id": 136 if m.User == nil { 137 m.User = &User{} 138 } 139 val, err := strconv.ParseInt(vals[0], 10, 64) 140 if err != nil { 141 return err 142 } 143 m.User.Id = val 144 case "user.name": 145 if m.User == nil { 146 m.User = &User{} 147 } 148 m.User.Name = vals[0] 149 case "user.age": 150 if m.User == nil { 151 m.User = &User{} 152 } 153 val, err := strconv.ParseInt(vals[0], 10, 32) 154 if err != nil { 155 return err 156 } 157 m.User.Age = int32(val) 158 case "user.books": 159 if m.User == nil { 160 m.User = &User{} 161 } 162 list := make([]int64, 0, len(vals)) 163 for _, text := range vals { 164 val, err := strconv.ParseInt(text, 10, 64) 165 if err != nil { 166 return err 167 } 168 list = append(list, val) 169 } 170 m.User.Books = list 171 } 172 } 173 } 174 return nil 175 } 176 177 // UpdateUserResponse implement urlenc.URLValuesUnmarshaler. 178 func (m *UpdateUserResponse) UnmarshalURLValues(prefix string, values url.Values) error { 179 for key, vals := range values { 180 if len(vals) > 0 { 181 switch prefix + key { 182 case "success": 183 val, err := strconv.ParseBool(vals[0]) 184 if err != nil { 185 return err 186 } 187 m.Success = val 188 } 189 } 190 } 191 return nil 192 }