2
3

user.go 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. package models
  2. // "errors"
  3. // "strconv"
  4. // "time"
  5. var (
  6. UserList map[string]*User
  7. )
  8. func init() {
  9. // UserList = make(map[string]*User)
  10. // u := User{"user_11111", "astaxie", Profile{"male", 20, "Singapore", "astaxie@gmail.com"}}
  11. // UserList["user_11111"] = &u
  12. }
  13. //type UserResult struct {
  14. // UserInfo User `json:"user"`
  15. //}
  16. type User struct {
  17. Id string
  18. Username string `json:"name"`
  19. Profile Profile
  20. }
  21. type Profile struct {
  22. Gender string
  23. Age int
  24. Address string
  25. Email string
  26. Realname string
  27. Roleid int
  28. Mobile string
  29. Telephone string
  30. CompanyCode string
  31. Photo string
  32. Manager string //联系人
  33. Description string //备注
  34. Host string //域名
  35. AccCode string //客户企业编号
  36. DepartmentId string
  37. IsCompanyUser int
  38. Id int
  39. }
  40. //func AddUser(u User) string {
  41. // u.Id = "user_" + strconv.FormatInt(time.Now().UnixNano(), 10)
  42. // UserList[u.Id] = &u
  43. // return u.Id
  44. //}
  45. //func GetUser(uid string) (u *User, err error) {
  46. // if u, ok := UserList[uid]; ok {
  47. // return u, nil
  48. // }
  49. // return nil, errors.New("User not exists")
  50. //}
  51. //func GetAllUsers() map[string]*User {
  52. // return UserList
  53. //}
  54. //func UpdateUser(uid string, uu *User) (a *User, err error) {
  55. // if u, ok := UserList[uid]; ok {
  56. // if uu.Username != "" {
  57. // u.Username = uu.Username
  58. // }
  59. // if uu.Password != "" {
  60. // u.Password = uu.Password
  61. // }
  62. // if uu.Profile.Age != 0 {
  63. // u.Profile.Age = uu.Profile.Age
  64. // }
  65. // if uu.Profile.Address != "" {
  66. // u.Profile.Address = uu.Profile.Address
  67. // }
  68. // if uu.Profile.Gender != "" {
  69. // u.Profile.Gender = uu.Profile.Gender
  70. // }
  71. // if uu.Profile.Email != "" {
  72. // u.Profile.Email = uu.Profile.Email
  73. // }
  74. // return u, nil
  75. // }
  76. // return nil, errors.New("User Not Exist")
  77. //}
  78. //func Login(username, password string) bool {
  79. // for _, u := range UserList {
  80. // if u.Username == username && u.Password == password {
  81. // return true
  82. // }
  83. // }
  84. // return false
  85. //}
  86. //func DeleteUser(uid string) {
  87. // delete(UserList, uid)
  88. //}