🎨 新增vip模块
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
"git.echol.cn/loser/lckt/api/v1/example"
|
||||
"git.echol.cn/loser/lckt/api/v1/system"
|
||||
"git.echol.cn/loser/lckt/api/v1/user"
|
||||
"git.echol.cn/loser/lckt/api/v1/vip"
|
||||
)
|
||||
|
||||
var ApiGroupApp = new(ApiGroup)
|
||||
@@ -18,4 +19,5 @@ type ApiGroup struct {
|
||||
BotApiGroup bot.ApiGroup
|
||||
ArticleApiGroup article.ApiGroup
|
||||
UserApiGroup user.APPUserApi
|
||||
VipApiGroup vip.ApiGroup
|
||||
}
|
||||
|
7
api/v1/vip/enter.go
Normal file
7
api/v1/vip/enter.go
Normal file
@@ -0,0 +1,7 @@
|
||||
package vip
|
||||
|
||||
import "git.echol.cn/loser/lckt/service"
|
||||
|
||||
type ApiGroup struct{ VipApi }
|
||||
|
||||
var vipService = service.ServiceGroupApp.VipServiceGroup.VipService
|
88
api/v1/vip/vip.go
Normal file
88
api/v1/vip/vip.go
Normal file
@@ -0,0 +1,88 @@
|
||||
package vip
|
||||
|
||||
import (
|
||||
"git.echol.cn/loser/lckt/model/common/request"
|
||||
"git.echol.cn/loser/lckt/model/common/response"
|
||||
"git.echol.cn/loser/lckt/model/vip"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type VipApi struct{}
|
||||
|
||||
// GetVipList 获取会员列表
|
||||
func (v *VipApi) GetVipList(ctx *gin.Context) {
|
||||
var p request.PageInfo
|
||||
if err := ctx.ShouldBind(&p); err != nil {
|
||||
response.FailWithMessage("参数有误", ctx)
|
||||
return
|
||||
}
|
||||
|
||||
vipList, total, err := vipService.GetVipList(p)
|
||||
if err != nil {
|
||||
response.FailWithMessage("获取VIP列表失败", ctx)
|
||||
return
|
||||
}
|
||||
response.OkWithDetailed(
|
||||
response.PageResult{
|
||||
List: vipList,
|
||||
Total: total,
|
||||
Page: p.Page,
|
||||
PageSize: p.PageSize,
|
||||
},
|
||||
"获取VIP列表成功",
|
||||
ctx,
|
||||
)
|
||||
}
|
||||
|
||||
// Create 创建会员
|
||||
func (v *VipApi) Create(ctx *gin.Context) {
|
||||
var p vip.Vip
|
||||
if err := ctx.ShouldBind(&p); err != nil {
|
||||
response.FailWithMessage("参数有误", ctx)
|
||||
return
|
||||
}
|
||||
if err := vipService.CreateVip(p); err != nil {
|
||||
response.FailWithMessage("创建会员失败", ctx)
|
||||
return
|
||||
}
|
||||
response.OkWithMessage("创建会员成功", ctx)
|
||||
}
|
||||
|
||||
// Update 更新会员
|
||||
func (v *VipApi) Update(ctx *gin.Context) {
|
||||
var p vip.Vip
|
||||
if err := ctx.ShouldBind(&p); err != nil {
|
||||
response.FailWithMessage("参数有误", ctx)
|
||||
return
|
||||
}
|
||||
if err := vipService.UpdateVip(p); err != nil {
|
||||
response.FailWithMessage("更新会员失败", ctx)
|
||||
return
|
||||
}
|
||||
response.OkWithMessage("更新会员成功", ctx)
|
||||
}
|
||||
|
||||
// Delete 删除会员
|
||||
func (v *VipApi) Delete(ctx *gin.Context) {
|
||||
var p vip.Vip
|
||||
if err := ctx.ShouldBind(&p); err != nil {
|
||||
response.FailWithMessage("参数有误", ctx)
|
||||
return
|
||||
}
|
||||
if err := vipService.DeleteVip(p); err != nil {
|
||||
response.FailWithMessage("删除会员失败", ctx)
|
||||
return
|
||||
}
|
||||
response.OkWithMessage("删除会员成功", ctx)
|
||||
}
|
||||
|
||||
// GetVipById 获取会员详情
|
||||
func (v *VipApi) GetVipById(ctx *gin.Context) {
|
||||
id := ctx.Param("id")
|
||||
vip, err := vipService.GetVipById(id)
|
||||
if err != nil {
|
||||
response.FailWithMessage("获取会员详情失败", ctx)
|
||||
return
|
||||
}
|
||||
response.OkWithDetailed(vip, "获取会员详情成功", ctx)
|
||||
}
|
Reference in New Issue
Block a user