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

44 lines
1.9 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. package models
  2. import (
  3. "time"
  4. "github.com/ouxuanserver/osmanthuswine/src/core"
  5. )
  6. const AreaStoreTableName = TableNamePrefix + "area_store"
  7. //店铺地区
  8. type AreaStore struct {
  9. Id int64 `json:"id" xorm:"not null pk autoincr INT(11)"`
  10. Name string `json:"name" xorm:"not null default('') comment('名字') VARCHAR(255)"`
  11. Type string `json:"type" xorm:"not null default('') comment('地区类型') VARCHAR(255)"`
  12. Address string `json:"address" xorm:"not null default('') comment('地址') VARCHAR(255)"`
  13. ActivityId int64 `json:"activity_id" xorm:"not null comment('主活动id') BIGINT(20)"`
  14. CustomerId int64 `json:"customer_id" xorm:"not null default 0 comment('客户id') INT(11)"`
  15. IsMainArea bool `json:"is_main_area" xorm:"not null default(0) comment('是否主地区1是') TINYINT(1)"`
  16. IsDelete bool `json:"is_delete" xorm:"not null default(0) comment('软删除') TINYINT(1)"`
  17. CreatedAt time.Time `json:"created_at" xorm:"not null created comment('创建时间') DATETIME"`
  18. UpdatedAt time.Time `json:"updated_at" xorm:"not null updated comment('更新时间') DATETIME"`
  19. }
  20. func (t *AreaStore) TableName() string {
  21. return AreaStoreTableName
  22. }
  23. func (t *AreaStore) GetByCustomerId(customerId, activityId interface{}) (bool, error) {
  24. return core.GetXormAuto().Where("is_delete=0 and customer_id=? and activity_id=?", customerId, activityId).Get(t)
  25. }
  26. func (t *AreaStore) GetAreaStoreById(id int64) (bool, error) {
  27. return core.GetXormAuto().Where("id=? and is_delete=0", id).Get(t)
  28. }
  29. func (t *AreaStore) GetMainAreaById(aid int64) (bool, error) {
  30. return core.GetXormAuto().Where("activity_id=? and is_main_area=1 and is_delete=0", aid).Get(t)
  31. }
  32. func GetAreaStoresByActivityId(aid int64) ([]*AreaStore, error) {
  33. list := make([]*AreaStore, 0)
  34. err := core.GetXormAuto().Where("is_delete=0 and activity_id=?", aid).Find(&list)
  35. return list, err
  36. }