🎨 新增vip模块

This commit is contained in:
2025-05-09 11:49:44 +08:00
parent 7903175c91
commit bf220076dd
12 changed files with 226 additions and 0 deletions

View File

@@ -7,6 +7,7 @@ import (
"git.echol.cn/loser/lckt/service/example"
"git.echol.cn/loser/lckt/service/system"
"git.echol.cn/loser/lckt/service/user"
"git.echol.cn/loser/lckt/service/vip"
)
var ServiceGroupApp = new(ServiceGroup)
@@ -18,4 +19,5 @@ type ServiceGroup struct {
BotServiceGroup bot.ServiceGroup
ArticleGroup article.ServiceGroup
UserServiceGroup user.ServiceGroup
VipServiceGroup vip.ServiceGroup
}

3
service/vip/enter.go Normal file
View File

@@ -0,0 +1,3 @@
package vip
type ServiceGroup struct{ VipService }

70
service/vip/vip.go Normal file
View File

@@ -0,0 +1,70 @@
package vip
import (
"git.echol.cn/loser/lckt/global"
"git.echol.cn/loser/lckt/model/common/request"
"git.echol.cn/loser/lckt/model/vip"
"go.uber.org/zap"
)
type VipService struct{}
// GetVipList 获取会员列表
func (v *VipService) GetVipList(p request.PageInfo) (vipList []vip.Vip, total int64, err error) {
limit := p.PageSize
offset := p.PageSize * (p.Page - 1)
// 创建db
db := global.GVA_DB.Model(&vip.Vip{})
err = db.Count(&total).Error
if err != nil {
global.GVA_LOG.Error("获取会员列表失败", zap.Error(err))
return
}
if limit != 0 {
db = db.Limit(limit).Offset(offset)
}
err = db.Find(&vipList).Error
if err != nil {
global.GVA_LOG.Error("获取会员列表失败", zap.Error(err))
return
}
return
}
// CreateVip 创建会员
func (v *VipService) CreateVip(vip vip.Vip) (err error) {
err = global.GVA_DB.Create(&vip).Error
if err != nil {
return
}
return
}
// UpdateVip 更新会员
func (v *VipService) UpdateVip(vip vip.Vip) (err error) {
err = global.GVA_DB.Save(&vip).Error
if err != nil {
return
}
return
}
// DeleteVip 删除会员
func (v *VipService) DeleteVip(vip vip.Vip) (err error) {
err = global.GVA_DB.Delete(&vip).Error
if err != nil {
return
}
return
}
// GetVipById 获取会员详情
func (v *VipService) GetVipById(id string) (vip vip.Vip, err error) {
err = global.GVA_DB.Where("id = ?", id).First(&vip).Error
if err != nil {
return
}
return
}