user_entity.go 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. DeptId int64 `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. // User is alias of Entity, which some developers say they just want.
  29. type User = Entity
  30. // OmitEmpty sets OPTION_OMITEMPTY option for the model, which automatically filers
  31. // the data and where attributes for empty values.
  32. func (r *Entity) OmitEmpty() *arModel {
  33. return Model.Data(r).OmitEmpty()
  34. }
  35. // Inserts does "INSERT...INTO..." statement for inserting current object into table.
  36. func (r *Entity) Insert() (result sql.Result, err error) {
  37. return Model.Data(r).Insert()
  38. }
  39. // Replace does "REPLACE...INTO..." statement for inserting current object into table.
  40. // If there's already another same record in the table (it checks using primary key or unique index),
  41. // it deletes it and insert this one.
  42. func (r *Entity) Replace() (result sql.Result, err error) {
  43. return Model.Data(r).Replace()
  44. }
  45. // Save does "INSERT...INTO..." statement for inserting/updating current object into table.
  46. // It updates the record if there's already another same record in the table
  47. // (it checks using primary key or unique index).
  48. func (r *Entity) Save() (result sql.Result, err error) {
  49. return Model.Data(r).Save()
  50. }
  51. // Update does "UPDATE...WHERE..." statement for updating current object from table.
  52. // It updates the record if there's already another same record in the table
  53. // (it checks using primary key or unique index).
  54. func (r *Entity) Update() (result sql.Result, err error) {
  55. return Model.Data(r).Where(gdb.GetWhereConditionOfStruct(r)).Update()
  56. }
  57. // Delete does "DELETE FROM...WHERE..." statement for deleting current object from table.
  58. func (r *Entity) Delete() (result sql.Result, err error) {
  59. return Model.Where(gdb.GetWhereConditionOfStruct(r)).Delete()
  60. }