user.go 960 B

1234567891011121314151617181920212223242526272829
  1. package user
  2. import (
  3. "eta/eta_mini_ht_api/models"
  4. "time"
  5. )
  6. const (
  7. defaultColumn = "id,real_name,id_no,id_end_date,account_status"
  8. )
  9. type User struct {
  10. ID int `gorm:"column:id;primaryKey"`
  11. TemplateUserID int `gorm:"column:template_user_id"`
  12. RealName string `gorm:"column:real_name;size:255"`
  13. IDNo string `gorm:"column:id_no;size:15"`
  14. IDKind int `gorm:"column:id_kind"`
  15. IDBeginDate time.Time `gorm:"column:id_begin_date"`
  16. IDEndDate time.Time `gorm:"column:id_end_date"`
  17. AccountStatus string `gorm:"column:account_status;type:enum('unopen','opening','opened')"`
  18. CreatedTime time.Time `gorm:"column:created_time"`
  19. UpdatedTime time.Time `gorm:"column:updated_time"`
  20. }
  21. func GetUserByTemplateUserId(templateUserId int) (user User, err error) {
  22. db := models.Main()
  23. err = db.Select(defaultColumn).Where("template_user_id=?", templateUserId).First(&user).Error
  24. return
  25. }