user_entity.go 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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 uint64 `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 uint `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. DeptId uint64 `orm:"dept_id" json:"dept_id"` // 部门id
  25. Remark string `orm:"remark" json:"remark"` // 备注
  26. IsAdmin int `orm:"is_admin" json:"is_admin"` // 是否后台管理员 1 是 0 否
  27. }
  28. // OmitEmpty sets OPTION_OMITEMPTY option for the model, which automatically filers
  29. // the data and where attributes for empty values.
  30. func (r *Entity) OmitEmpty() *arModel {
  31. return Model.Data(r).OmitEmpty()
  32. }
  33. // Inserts does "INSERT...INTO..." statement for inserting current object into table.
  34. func (r *Entity) Insert() (result sql.Result, err error) {
  35. return Model.Data(r).Insert()
  36. }
  37. // InsertIgnore does "INSERT IGNORE INTO ..." statement for inserting current object into table.
  38. func (r *Entity) InsertIgnore() (result sql.Result, err error) {
  39. return Model.Data(r).InsertIgnore()
  40. }
  41. // Replace does "REPLACE...INTO..." statement for inserting current object into table.
  42. // If there's already another same record in the table (it checks using primary key or unique index),
  43. // it deletes it and insert this one.
  44. func (r *Entity) Replace() (result sql.Result, err error) {
  45. return Model.Data(r).Replace()
  46. }
  47. // Save does "INSERT...INTO..." statement for inserting/updating current object into table.
  48. // It updates the record if there's already another same record in the table
  49. // (it checks using primary key or unique index).
  50. func (r *Entity) Save() (result sql.Result, err error) {
  51. return Model.Data(r).Save()
  52. }
  53. // Update does "UPDATE...WHERE..." statement for updating current object from table.
  54. // It updates the record if there's already another same record in the table
  55. // (it checks using primary key or unique index).
  56. func (r *Entity) Update() (result sql.Result, err error) {
  57. return Model.Data(r).Where(gdb.GetWhereConditionOfStruct(r)).Update()
  58. }
  59. // Delete does "DELETE FROM...WHERE..." statement for deleting current object from table.
  60. func (r *Entity) Delete() (result sql.Result, err error) {
  61. return Model.Where(gdb.GetWhereConditionOfStruct(r)).Delete()
  62. }