user_entity.go 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. // ==========================================================================
  2. // This is auto-generated by gf cli tool. You may not really want to edit it.
  3. // ==========================================================================
  4. package user
  5. import (
  6. "database/sql"
  7. "github.com/gogf/gf/database/gdb"
  8. )
  9. // Entity is the golang structure for table user.
  10. type Entity struct {
  11. Id int `orm:"id,primary" json:"id"` //
  12. UserName string `orm:"user_name,unique" json:"user_name"` // 用户名
  13. Mobile string `orm:"mobile,unique" json:"mobile"` // 中国手机不带国家代码,国际手机号格式为:国家代码-手机号
  14. UserNickname string `orm:"user_nickname" json:"user_nickname"` // 用户昵称
  15. Birthday int `orm:"birthday" json:"birthday"` // 生日
  16. CreateTime int `orm:"create_time" json:"create_time"` // 注册时间
  17. UserPassword string `orm:"user_password" json:"user_password"` // 登录密码;cmf_password加密
  18. UserStatus int `orm:"user_status" json:"user_status"` // 用户状态;0:禁用,1:正常,2:未验证
  19. UserEmail string `orm:"user_email" json:"user_email"` // 用户登录邮箱
  20. Sex int `orm:"sex" json:"sex"` // 性别;0:保密,1:男,2:女
  21. Avatar string `orm:"avatar" json:"avatar"` // 用户头像
  22. LastLoginTime int `orm:"last_login_time" json:"last_login_time"` // 最后登录时间
  23. LastLoginIp string `orm:"last_login_ip" json:"last_login_ip"` // 最后登录ip
  24. }
  25. // User is alias of Entity, which some developers say they just want.
  26. type User = Entity
  27. // OmitEmpty sets OPTION_OMITEMPTY option for the model, which automatically filers
  28. // the data and where attributes for empty values.
  29. func (r *Entity) OmitEmpty() *arModel {
  30. return Model.Data(r).OmitEmpty()
  31. }
  32. // Inserts does "INSERT...INTO..." statement for inserting current object into table.
  33. func (r *Entity) Insert() (result sql.Result, err error) {
  34. return Model.Data(r).Insert()
  35. }
  36. // Replace does "REPLACE...INTO..." statement for inserting current object into table.
  37. // If there's already another same record in the table (it checks using primary key or unique index),
  38. // it deletes it and insert this one.
  39. func (r *Entity) Replace() (result sql.Result, err error) {
  40. return Model.Data(r).Replace()
  41. }
  42. // Save does "INSERT...INTO..." statement for inserting/updating current object into table.
  43. // It updates the record if there's already another same record in the table
  44. // (it checks using primary key or unique index).
  45. func (r *Entity) Save() (result sql.Result, err error) {
  46. return Model.Data(r).Save()
  47. }
  48. // Update does "UPDATE...WHERE..." statement for updating current object from table.
  49. // It updates the record if there's already another same record in the table
  50. // (it checks using primary key or unique index).
  51. func (r *Entity) Update() (result sql.Result, err error) {
  52. return Model.Data(r).Where(gdb.GetWhereConditionOfStruct(r)).Update()
  53. }
  54. // Delete does "DELETE FROM...WHERE..." statement for deleting current object from table.
  55. func (r *Entity) Delete() (result sql.Result, err error) {
  56. return Model.Where(gdb.GetWhereConditionOfStruct(r)).Delete()
  57. }