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

45 lines
2.3 KiB

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 ModuleServiceHistoryTableName = TableNamePrefix + "module_service_history"
  7. type ModuleServiceHistory struct {
  8. Id int64 `json:"id" xorm:"not null pk autoincr INT(11)"`
  9. ServiceModuleId int64 `json:"service_module_id" xorm:"not null comment('服务模块的id') INT(11)" description:"服务模块的id"`
  10. Name string `json:"name" xorm:"not null comment('模块名字') VARCHAR(255)" description:"模块的名称"`
  11. Price float64 `json:"price" xorm:"not null default(0.0) comment('模块价格') DECIMAL(10) " description:"模块价格"`
  12. Free string `json:"free" xorm:"not null comment('模块是否收费[收费|免费]') VARCHAR(255)" description:"模块是否收费[收费|免费]"`
  13. Description string `json:"description" xorm:"not null comment('描述或者简介') VARCHAR(128)"`
  14. UseTimes int `json:"use_times" xorm:"not null default(0) comment('模块服务使用次数') INT(11)"`
  15. IsDelete bool `json:"is_delete" xorm:"not null default(0) comment('软删除') TINYINT(1)"`
  16. CreatedAt time.Time `json:"-" xorm:"not null created comment('创建时间') DATETIME" description:"创建时间"`
  17. UpdatedAt time.Time `json:"-" xorm:"not null updated comment('更新时间') DATETIME" description:"更新时间"`
  18. }
  19. func (t *ModuleServiceHistory) TableName() string {
  20. return ModuleServiceHistoryTableName
  21. }
  22. func (t *ModuleServiceHistory) Alias(name string) string {
  23. return AliasTableName(t, name)
  24. }
  25. func (t *ModuleServiceHistory) GetByModuleIdAndName(id int64, name string) (bool, error) {
  26. return core.GetXormAuto().Where("is_delete=0 and service_module_id=? and name=?", id, name).Get(t)
  27. }
  28. func (t *ModuleServiceHistory) ExistSignModule(ids []interface{}) (bool, error) {
  29. return core.GetXormAuto().Where("is_delete=0 and name=?", "签到").In("id", ids...).Exist(t)
  30. }
  31. func GetModuleServiceHistoryIdsByIdAndName(serviceId, serviceName interface{}) ([]int64, error) {
  32. historyIds := make([]int64, 0)
  33. err := core.GetXormAuto().Table(new(ModuleServiceHistory)).Select("id").
  34. Where("is_delete=0 and service_module_id=? and name=?", serviceId, serviceName).Find(&historyIds)
  35. return historyIds, err
  36. }