本站源代码
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

44 rindas
1.1KB

  1. // Copyright 2014 The Gogs Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package structs
  5. import (
  6. "encoding/json"
  7. "time"
  8. )
  9. // User represents a user
  10. // swagger:model
  11. type User struct {
  12. // the user's id
  13. ID int64 `json:"id"`
  14. // the user's username
  15. UserName string `json:"login"`
  16. // the user's full name
  17. FullName string `json:"full_name"`
  18. // swagger:strfmt email
  19. Email string `json:"email"`
  20. // URL to the user's avatar
  21. AvatarURL string `json:"avatar_url"`
  22. // User locale
  23. Language string `json:"language"`
  24. // Is the user an administrator
  25. IsAdmin bool `json:"is_admin"`
  26. // swagger:strfmt date-time
  27. LastLogin time.Time `json:"last_login,omitempty"`
  28. // swagger:strfmt date-time
  29. Created time.Time `json:"created,omitempty"`
  30. }
  31. // MarshalJSON implements the json.Marshaler interface for User, adding field(s) for backward compatibility
  32. func (u User) MarshalJSON() ([]byte, error) {
  33. // Re-declaring User to avoid recursion
  34. type shadow User
  35. return json.Marshal(struct {
  36. shadow
  37. CompatUserName string `json:"username"`
  38. }{shadow(u), u.UserName})
  39. }
上海开阖软件有限公司 沪ICP备12045867号-1