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.
41 lines
1.7 KiB
41 lines
1.7 KiB
package models
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/ouxuanserver/osmanthuswine/src/core"
|
|
)
|
|
|
|
const AreaStoreTableName = TableNamePrefix + "area_store"
|
|
|
|
//店铺地区
|
|
type AreaStore struct {
|
|
Id int64 `json:"id" xorm:"not null pk autoincr INT(11)"`
|
|
Name string `json:"name" xorm:"not null default('') comment('名字') VARCHAR(255)"`
|
|
Type string `json:"type" xorm:"not null default('') comment('地区类型') VARCHAR(255)"`
|
|
Address string `json:"address" xorm:"not null default('') comment('地址') VARCHAR(255)"`
|
|
ActivityId int64 `json:"activity_id" xorm:"not null comment('主活动id') BIGINT(20)"`
|
|
CustomerId int64 `json:"customer_id" xorm:"not null default 0 comment('客户id') INT(11)"`
|
|
IsMainArea bool `json:"is_main_area" xorm:"not null default(0) comment('是否主地区1是') TINYINT(1)"`
|
|
IsDelete bool `json:"is_delete" xorm:"not null default(0) comment('软删除') TINYINT(1)"`
|
|
CreatedAt time.Time `json:"created_at" xorm:"not null created comment('创建时间') DATETIME"`
|
|
UpdatedAt time.Time `json:"updated_at" xorm:"not null updated comment('更新时间') DATETIME"`
|
|
}
|
|
|
|
func (t *AreaStore) TableName() string {
|
|
return AreaStoreTableName
|
|
}
|
|
|
|
func (t *AreaStore) GetAreaStoreById(id int64) (bool, error) {
|
|
return core.GetXormAuto().Where("id=? and is_delete=0", id).Get(t)
|
|
}
|
|
|
|
func (t *AreaStore) GetMainAreaById(aid int64) (bool, error) {
|
|
return core.GetXormAuto().Where("activity_id=? and is_main_area=1 and is_delete=0", aid).Get(t)
|
|
}
|
|
|
|
func GetAreaStoresByActivityId(aid int64) ([]*AreaStore, error) {
|
|
list := make([]*AreaStore, 0)
|
|
err := core.GetXormAuto().Where("is_delete=0 and activity_id=?", aid).Find(&list)
|
|
return list, err
|
|
}
|