feat(subscribe): add Language field to subscription models and update query logic
This commit is contained in:
@@ -8,7 +8,7 @@ import (
|
||||
)
|
||||
|
||||
type customSubscribeLogicModel interface {
|
||||
QuerySubscribeListByPage(ctx context.Context, page, size int, group int64, search string) (total int64, list []*Subscribe, err error)
|
||||
QuerySubscribeListByPage(ctx context.Context, page, size int, lang string, search string) (total int64, list []*Subscribe, err error)
|
||||
QuerySubscribeList(ctx context.Context) ([]*Subscribe, error)
|
||||
QuerySubscribeListByShow(ctx context.Context) ([]*Subscribe, error)
|
||||
QuerySubscribeIdsByNodeIdAndNodeTag(ctx context.Context, node []int64, tags []string) ([]*Subscribe, error)
|
||||
@@ -25,7 +25,7 @@ func NewModel(conn *gorm.DB, c *redis.Client) Model {
|
||||
}
|
||||
|
||||
// QuerySubscribeListByPage Get Subscribe List
|
||||
func (m *customSubscribeModel) QuerySubscribeListByPage(ctx context.Context, page, size int, group int64, search string) (total int64, list []*Subscribe, err error) {
|
||||
func (m *customSubscribeModel) QuerySubscribeListByPage(ctx context.Context, page, size int, lang string, search string) (total int64, list []*Subscribe, err error) {
|
||||
err = m.QueryNoCacheCtx(ctx, &list, func(conn *gorm.DB, v interface{}) error {
|
||||
// About to be abandoned
|
||||
_ = conn.Model(&Subscribe{}).
|
||||
@@ -33,13 +33,14 @@ func (m *customSubscribeModel) QuerySubscribeListByPage(ctx context.Context, pag
|
||||
Update("sort", gorm.Expr("id"))
|
||||
|
||||
conn = conn.Model(&Subscribe{})
|
||||
if group > 0 {
|
||||
conn = conn.Where("group_id = ?", group)
|
||||
if lang != "" {
|
||||
conn = conn.Where("`language` = ?", lang)
|
||||
}
|
||||
if search != "" {
|
||||
conn = conn.Where("`name` like ? or `description` like ?", "%"+search+"%", "%"+search+"%")
|
||||
}
|
||||
return conn.Count(&total).Order("sort ASC").Limit(size).Offset((page - 1) * size).Find(v).Error
|
||||
err = conn.Count(&total).Order("sort ASC").Limit(size).Offset((page - 1) * size).Find(v).Error
|
||||
return nil
|
||||
})
|
||||
return total, list, err
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
type Subscribe struct {
|
||||
Id int64 `gorm:"primaryKey"`
|
||||
Name string `gorm:"type:varchar(255);not null;default:'';comment:Subscribe Name"`
|
||||
Language string `gorm:"type:varchar(255);not null;default:'';comment:Language"`
|
||||
Description string `gorm:"type:text;comment:Subscribe Description"`
|
||||
UnitPrice int64 `gorm:"type:int;not null;default:0;comment:Unit Price"`
|
||||
UnitTime string `gorm:"type:varchar(255);not null;default:'';comment:Unit Time"`
|
||||
@@ -19,7 +20,6 @@ type Subscribe struct {
|
||||
SpeedLimit int64 `gorm:"type:int;not null;default:0;comment:Speed Limit"`
|
||||
DeviceLimit int64 `gorm:"type:int;not null;default:0;comment:Device Limit"`
|
||||
Quota int64 `gorm:"type:int;not null;default:0;comment:Quota"`
|
||||
GroupId int64 `gorm:"type:bigint;comment:Group Id"`
|
||||
Nodes string `gorm:"type:varchar(255);comment:Node Ids"`
|
||||
NodeTags string `gorm:"type:varchar(255);comment:Node Tags"`
|
||||
Show *bool `gorm:"type:tinyint(1);not null;default:0;comment:Show portal page"`
|
||||
|
||||
Reference in New Issue
Block a user