entity.go 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. package user
  2. import (
  3. "git.sxidc.com/go-framework/baize/framework/core/domain"
  4. "git.sxidc.com/go-framework/baize/framework/core/domain/entity"
  5. "time"
  6. )
  7. const (
  8. FieldUserName = "UserName"
  9. FieldPassword = "Password"
  10. FieldName = "Name"
  11. FieldPhone = "Phone"
  12. FieldEmail = "Email"
  13. FieldToken = "Token"
  14. FieldLastLoginTime = "LastLoginTime"
  15. )
  16. var (
  17. ColumnUserName = domain.ColumnName(FieldUserName)
  18. ColumnPassword = domain.ColumnName(FieldPassword)
  19. ColumnName = domain.ColumnName(FieldName)
  20. ColumnPhone = domain.ColumnName(FieldPhone)
  21. ColumnEmail = domain.ColumnName(FieldEmail)
  22. ColumnToken = domain.ColumnName(FieldToken)
  23. ColumnLastLoginTime = domain.ColumnName(FieldLastLoginTime)
  24. )
  25. var fieldMap = map[string]string{
  26. FieldUserName: "用户名",
  27. FieldPassword: "密码",
  28. FieldName: "姓名",
  29. FieldPhone: "手机号",
  30. FieldEmail: "邮箱",
  31. FieldToken: "token",
  32. FieldLastLoginTime: "最近登录时间",
  33. }
  34. type Entity struct {
  35. entity.Base
  36. UserName string `sqlmapping:"column:user_name;notUpdate" sqlresult:"column:user_name" check:"required,lte=256,when=create"`
  37. Password string `sqlmapping:"column:password" sqlresult:"column:password" check:"required,lte=256,when=create/update"`
  38. Name string `sqlmapping:"column:name;updateClear" sqlresult:"column:name" check:"lte=256,when=create/update"`
  39. Phone string `sqlmapping:"column:phone;updateClear" sqlresult:"column:phone" check:"lte=128,when=create/update"`
  40. Email string `sqlmapping:"column:email;updateClear" sqlresult:"column:email" check:"lte=512,when=create/update"`
  41. Token string `sqlmapping:"column:token;notUpdate" sqlresult:"column:token"`
  42. LastLoginTime time.Time `sqlmapping:"column:last_login_time;notUpdate" sqlresult:"column:last_login_time" check:"required,timezero"`
  43. RoleIDs []string `sqlmapping:"-" sqlresult:"-"`
  44. entity.TimeFields
  45. }
  46. func (e *Entity) DomainCNName() string {
  47. return "用户"
  48. }
  49. func (e *Entity) DomainCamelName() string {
  50. return "User"
  51. }
  52. func (e *Entity) GetFieldMap() map[string]string {
  53. return fieldMap
  54. }