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

40 lines
1.6 KiB

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. IsMainArea bool `json:"is_main_area" xorm:"not null default(0) comment('是否主地区1是') TINYINT(1)"`
  15. IsDelete bool `json:"is_delete" xorm:"not null default(0) comment('软删除') TINYINT(1)"`
  16. CreatedAt time.Time `json:"created_at" xorm:"not null created comment('创建时间') DATETIME"`
  17. UpdatedAt time.Time `json:"updated_at" xorm:"not null updated comment('更新时间') DATETIME"`
  18. }
  19. func (t *AreaStore) TableName() string {
  20. return AreaStoreTableName
  21. }
  22. func (t *AreaStore) GetAreaStoreById(id int64) (bool, error) {
  23. return core.GetXormAuto().Where("id=? and is_delete=0", id).Get(t)
  24. }
  25. func (t *AreaStore) GetMainAreaById(aid int64) (bool, error) {
  26. return core.GetXormAuto().Where("activity_id=? and is_main_area=1 and is_delete=0", aid).Get(t)
  27. }
  28. func GetAreaStoresByActivityId(aid int64) ([]*AreaStore, error) {
  29. list := make([]*AreaStore, 0)
  30. err := core.GetXormAuto().Where("is_delete=0 and activity_id=?", aid).Find(&list)
  31. return list, err
  32. }