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

55 lines
1.7 KiB

5 years ago
4 years ago
5 years ago
5 years ago
4 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{}) error {
  25. exist, err := core.GetXormAuto().Where("is_delete=0 and account=? and activity_id=?", account, activityId).Get(t)
  26. if err != nil {
  27. return err
  28. }
  29. if exist {
  30. return errors.New("用户名错误")
  31. }
  32. if t.Password != password {
  33. return errors.New("密码错误")
  34. }
  35. return nil
  36. }
  37. func (t *OrderEntryPerson) GetByToken(token string) error {
  38. exist, err := core.GetXormAuto().Where("is_delete=0 and token=?", token).Get(t)
  39. if err != nil {
  40. return err
  41. }
  42. if !exist {
  43. return errors.New("录入人员信息异常")
  44. }
  45. return nil
  46. }