package models import ( "time" "github.com/ouxuanserver/osmanthuswine/src/core" ) const ModuleServiceHistoryTableName = TableNamePrefix + "module_service_history" type ModuleServiceHistory struct { Id int64 `json:"id" xorm:"not null pk autoincr INT(11)"` ServiceModuleId int64 `json:"service_module_id" xorm:"not null comment('服务模块的id') INT(11)" description:"服务模块的id"` Name string `json:"name" xorm:"not null comment('模块名字') VARCHAR(255)" description:"模块的名称"` Price float64 `json:"price" xorm:"not null default(0.0) comment('模块价格') DECIMAL(10) " description:"模块价格"` Free string `json:"free" xorm:"not null comment('模块是否收费[收费|免费]') VARCHAR(255)" description:"模块是否收费[收费|免费]"` Description string `json:"description" xorm:"not null comment('描述或者简介') VARCHAR(128)"` UseTimes int `json:"use_times" xorm:"not null default(0) comment('模块服务使用次数') INT(11)"` IsDelete bool `json:"is_delete" xorm:"not null default(0) comment('软删除') TINYINT(1)"` CreatedAt time.Time `json:"-" xorm:"not null created comment('创建时间') DATETIME" description:"创建时间"` UpdatedAt time.Time `json:"-" xorm:"not null updated comment('更新时间') DATETIME" description:"更新时间"` } func (t *ModuleServiceHistory) TableName() string { return ModuleServiceHistoryTableName } func (t *ModuleServiceHistory) Alias(name string) string { return AliasTableName(t, name) } func (t *ModuleServiceHistory) GetByModuleIdAndName(id int64, name string) (bool, error) { return core.GetXormAuto().Where("is_delete=0 and service_module_id=? and name=?", id, name).Get(t) } func (t *ModuleServiceHistory) ExistSignModule(ids []interface{}) (bool, error) { return core.GetXormAuto().Where("is_delete=0 and name=?", "签到").In("id", ids...).Exist(t) } func GetModuleServiceHistoryIdsByIdAndName(serviceId, serviceName interface{}) ([]int64, error) { historyIds := make([]int64, 0) err := core.GetXormAuto().Table(new(ModuleServiceHistory)).Select("id"). Where("is_delete=0 and service_module_id=? and name=?", serviceId, serviceName).Find(&historyIds) return historyIds, err }