互动
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.

49 lines
1.9 KiB

5 years ago
5 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. "github.com/ouxuanserver/osmanthuswine/src/core"
  5. )
  6. const OrderEntryPersonTableName = TableNamePrefix + "order_entry_person"
  7. type OrderEntryPerson struct {
  8. Model `xorm:"extends"`
  9. //Id int `json:"id" xorm:"pk autoincr BIGINT(20)"`
  10. //IsDelete bool `json:"-" xorm:"not null default(0) comment('软删除') TINYINT(1)"`
  11. //CreatedAt time.Time `json:"-" xorm:"not null created comment('创建时间') DATETIME"`
  12. //UpdatedAt time.Time `json:"-" xorm:"not null updated comment('更新时间') DATETIME"`
  13. Name string `json:"name" xorm:"not null default('') comment('名字') VARCHAR(255)"`
  14. Account string `json:"account" xorm:"not null default('') comment('账号') VARCHAR(255)"`
  15. Password string `json:"password" xorm:"not null default('') comment('密码') VARCHAR(255)"`
  16. Pid int `json:"pid" xorm:"not null default 0 comment('主账号') VARCHAR(255)"`
  17. AreaId int `json:"area_id" xorm:"not null default 0 comment('地区id') BIGINT(20)"`
  18. ActivityId int `json:"activity_id" xorm:"not null default 0 comment('主活动id') BIGINT(20)"`
  19. Token string `json:"token" xorm:"not null default '' comment('token') VARCHAR(255)"`
  20. // 展示字段
  21. AreaName string `json:"area_name" xorm:"-"`
  22. ActivityName string `json:"activity_name" xorm:"-"`
  23. IsSpecial int `json:"is_special" xorm:"-"`
  24. }
  25. func (t *OrderEntryPerson) TableName() string {
  26. return OrderEntryPersonTableName
  27. }
  28. func (t *OrderEntryPerson) Auth(account, password, activityId interface{}) (bool, error) {
  29. return core.GetXormAuto().Where("is_delete=0 and account = ? and password = ? and activity_id = ?",
  30. account, password, activityId).Get(t)
  31. }
  32. func (t *OrderEntryPerson) GetByToken(token string) error {
  33. exist, err := core.GetXormAuto().Where("is_delete=0 and token=?", token).Get(t)
  34. if err != nil {
  35. return err
  36. }
  37. if !exist {
  38. return errors.New("录入人员信息异常")
  39. }
  40. return nil
  41. }