互动
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.6 KiB

5 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
4 years ago
  1. package models
  2. import (
  3. "errors"
  4. "git.ouxuan.net/tommy/osmanthuswine/src/core"
  5. )
  6. const OrderEntryPersonTableName = TableNamePrefix + "order_entry_person"
  7. type OrderEntryPerson struct {
  8. Model `xorm:"extends"`
  9. Name string `json:"name" xorm:"not null default('') comment('名字') VARCHAR(255)"`
  10. Account string `json:"account" xorm:"not null default('') comment('账号') VARCHAR(255)"`
  11. Password string `json:"password" xorm:"not null default('') comment('密码') VARCHAR(255)"`
  12. Pid int `json:"pid" xorm:"not null default 0 comment('主账号') VARCHAR(255)"`
  13. AreaId int `json:"area_id" xorm:"not null default 0 comment('地区id') BIGINT(20)"`
  14. ActivityId int `json:"activity_id" xorm:"not null default 0 comment('主活动id') BIGINT(20)"`
  15. Token string `json:"token" xorm:"not null default '' comment('token') VARCHAR(255)"`
  16. // 展示字段
  17. AreaName string `json:"area_name" xorm:"-"`
  18. ActivityName string `json:"activity_name" xorm:"-"`
  19. IsSpecial int `json:"is_special" xorm:"-"`
  20. }
  21. func (t *OrderEntryPerson) TableName() string {
  22. return OrderEntryPersonTableName
  23. }
  24. func (t *OrderEntryPerson) Auth(account, password, activityId interface{}) (bool, error) {
  25. return core.GetXormAuto().Where("is_delete=0 and account = ? and password = ? and activity_id = ?",
  26. account, password, activityId).Get(t)
  27. }
  28. func (t *OrderEntryPerson) GetByToken(token string) error {
  29. exist, err := core.GetXormAuto().Where("is_delete=0 and token=?", token).Get(t)
  30. if err != nil {
  31. return err
  32. }
  33. if !exist {
  34. return errors.New("录入人员信息异常")
  35. }
  36. return nil
  37. }