赞助模块
This commit is contained in:
parent
87b857528e
commit
35f0243616
|
@ -31,3 +31,7 @@ type ILinkV1 interface {
|
||||||
type IUserV1 interface {
|
type IUserV1 interface {
|
||||||
GetUserCurrent(ctx context.Context, req *request.GetUserReq) (res *request.GetUserRes, err error)
|
GetUserCurrent(ctx context.Context, req *request.GetUserReq) (res *request.GetUserRes, err error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ISponsorV1 interface {
|
||||||
|
GetSponsor(context.Context, *request.GetSponsorReq) (*request.GetSponsorRes, error)
|
||||||
|
}
|
||||||
|
|
9
api/request/sponsorApi.go
Normal file
9
api/request/sponsorApi.go
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
package request
|
||||||
|
|
||||||
|
import "github.com/gogf/gf/v2/frame/g"
|
||||||
|
|
||||||
|
type GetSponsorReq struct {
|
||||||
|
g.Meta `path:"/list" tags:"获取赞助" method:"get" summary:"获取赞助"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type GetSponsorRes struct{}
|
|
@ -2,6 +2,7 @@ package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"PersonalMain/internal/controller/auth/link/custom/friend"
|
"PersonalMain/internal/controller/auth/link/custom/friend"
|
||||||
|
"PersonalMain/internal/controller/auth/link/custom/sponsor"
|
||||||
"PersonalMain/internal/controller/auth/token"
|
"PersonalMain/internal/controller/auth/token"
|
||||||
authUser "PersonalMain/internal/controller/auth/user"
|
authUser "PersonalMain/internal/controller/auth/user"
|
||||||
"PersonalMain/internal/controller/user"
|
"PersonalMain/internal/controller/user"
|
||||||
|
@ -51,6 +52,11 @@ var (
|
||||||
friend.NewLinkCustomFriendV1(),
|
friend.NewLinkCustomFriendV1(),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
group.Group("/sponsor", func(group *ghttp.RouterGroup) {
|
||||||
|
group.Bind(
|
||||||
|
sponsor.NewSponsorV1(),
|
||||||
|
)
|
||||||
|
})
|
||||||
group.Group("/location", func(group *ghttp.RouterGroup) {
|
group.Group("/location", func(group *ghttp.RouterGroup) {
|
||||||
//location.NewLinkCustomLocationV1()
|
//location.NewLinkCustomLocationV1()
|
||||||
})
|
})
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
package sponsor
|
||||||
|
|
||||||
|
import (
|
||||||
|
"PersonalMain/api"
|
||||||
|
"PersonalMain/api/request"
|
||||||
|
"PersonalMain/internal/service/SponsorService"
|
||||||
|
"context"
|
||||||
|
"github.com/gogf/gf/v2/net/ghttp"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ControllerV1 struct{}
|
||||||
|
|
||||||
|
func NewSponsorV1() api.ISponsorV1 {
|
||||||
|
return &ControllerV1{}
|
||||||
|
}
|
||||||
|
|
||||||
|
func sponorService() SponsorService.SponsorService {
|
||||||
|
return SponsorService.NewSponsorService()
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetSponsor
|
||||||
|
//
|
||||||
|
// 获取赞助
|
||||||
|
func (*ControllerV1) GetSponsor(ctx context.Context, _ *request.GetSponsorReq) (res *request.GetSponsorRes, err error) {
|
||||||
|
req := ghttp.RequestFromCtx(ctx)
|
||||||
|
// 获取业务
|
||||||
|
sponorService().GetSponsor(req)
|
||||||
|
return res, err
|
||||||
|
}
|
29
internal/dao/sponsorDAO/sponsorDAO.go
Normal file
29
internal/dao/sponsorDAO/sponsorDAO.go
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
package sponsorDAO
|
||||||
|
|
||||||
|
import (
|
||||||
|
"PersonalMain/internal/model/do"
|
||||||
|
"context"
|
||||||
|
"github.com/gogf/gf/v2/frame/g"
|
||||||
|
)
|
||||||
|
|
||||||
|
// GetSponsor
|
||||||
|
//
|
||||||
|
// 获取赞助
|
||||||
|
func GetSponsor() *[]do.SponsorDO {
|
||||||
|
// 获取数据表全部数据
|
||||||
|
var getSponorDO []do.SponsorDO
|
||||||
|
result, err := g.Model("xf_sponsor").OrderDesc("created_at").All()
|
||||||
|
if err == nil {
|
||||||
|
if !result.IsEmpty() {
|
||||||
|
_ = result.Structs(&getSponorDO)
|
||||||
|
g.Log().Cat("Database").Cat("Sponor").Notice(context.Background(), "xf_sponor 数据表数据提取成功")
|
||||||
|
return &getSponorDO
|
||||||
|
} else {
|
||||||
|
g.Log().Cat("Database").Cat("Sponor").Notice(context.Background(), "xf_sponor 数据表中没有赞助相关信息")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
g.Log().Cat("Database").Cat("Sponor").Error(context.Background(), err.Error())
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
23
internal/logic/SponsorServiceImpl/sponsorServiceImpl.go
Normal file
23
internal/logic/SponsorServiceImpl/sponsorServiceImpl.go
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
package SponsorServiceImpl
|
||||||
|
|
||||||
|
import (
|
||||||
|
"PersonalMain/internal/dao/sponsorDAO"
|
||||||
|
"PersonalMain/utility/ErrorCode"
|
||||||
|
"PersonalMain/utility/ResultUtil"
|
||||||
|
"github.com/gogf/gf/v2/net/ghttp"
|
||||||
|
)
|
||||||
|
|
||||||
|
type SponsorServiceImpl struct{}
|
||||||
|
|
||||||
|
// GetSponsor
|
||||||
|
//
|
||||||
|
// 获取赞助
|
||||||
|
func (*SponsorServiceImpl) GetSponsor(req *ghttp.Request) {
|
||||||
|
// 获取赞助
|
||||||
|
getSponorDO := sponsorDAO.GetSponsor()
|
||||||
|
if getSponorDO != nil {
|
||||||
|
ResultUtil.Success(req, "Success", getSponorDO)
|
||||||
|
} else {
|
||||||
|
ResultUtil.ErrorNoData(req, ErrorCode.NoSponsor)
|
||||||
|
}
|
||||||
|
}
|
14
internal/model/do/sponsorDO.go
Normal file
14
internal/model/do/sponsorDO.go
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
package do
|
||||||
|
|
||||||
|
import "time"
|
||||||
|
|
||||||
|
type SponsorDO struct {
|
||||||
|
Id *uint64 `json:"id"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
UserId *uint64 `json:"user_id"`
|
||||||
|
Url *string `json:"url"`
|
||||||
|
Type uint8 `json:"type"`
|
||||||
|
Amount uint64 `json:"amount"`
|
||||||
|
CreatedAt time.Time `json:"created_at"`
|
||||||
|
Check uint8 `json:"check"`
|
||||||
|
}
|
14
internal/service/SponsorService/sponsorService.go
Normal file
14
internal/service/SponsorService/sponsorService.go
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
package SponsorService
|
||||||
|
|
||||||
|
import (
|
||||||
|
"PersonalMain/internal/logic/SponsorServiceImpl"
|
||||||
|
"github.com/gogf/gf/v2/net/ghttp"
|
||||||
|
)
|
||||||
|
|
||||||
|
func NewSponsorService() SponsorService {
|
||||||
|
return &SponsorServiceImpl.SponsorServiceImpl{}
|
||||||
|
}
|
||||||
|
|
||||||
|
type SponsorService interface {
|
||||||
|
GetSponsor(*ghttp.Request)
|
||||||
|
}
|
|
@ -30,6 +30,7 @@ var (
|
||||||
LikeLinkAlreadyExists = ErrorCode{output: "LikeLinkAlreadyExists", code: 40304, message: "链接已存在"}
|
LikeLinkAlreadyExists = ErrorCode{output: "LikeLinkAlreadyExists", code: 40304, message: "链接已存在"}
|
||||||
LinkAcceptDenied = ErrorCode{output: "LinkAcceptDenied", code: 40305, message: "链接接受协议拒绝"}
|
LinkAcceptDenied = ErrorCode{output: "LinkAcceptDenied", code: 40305, message: "链接接受协议拒绝"}
|
||||||
FriendLinkDoesNotExist = ErrorCode{output: "FriendLinkDoesNotExist", code: 40306, message: "友链不存在"}
|
FriendLinkDoesNotExist = ErrorCode{output: "FriendLinkDoesNotExist", code: 40306, message: "友链不存在"}
|
||||||
|
NoSponsor = ErrorCode{output: "NoSponsor", code: 40307, message: "没有赞助"}
|
||||||
ServerUnknownError = ErrorCode{output: "ServerUnknownError", code: 50000, message: "服务器未知错误"}
|
ServerUnknownError = ErrorCode{output: "ServerUnknownError", code: 50000, message: "服务器未知错误"}
|
||||||
ServerDatabaseInteriorError = ErrorCode{output: "ServerDatabaseInteriorError", code: 50001, message: "服务器数据库内部错误"}
|
ServerDatabaseInteriorError = ErrorCode{output: "ServerDatabaseInteriorError", code: 50001, message: "服务器数据库内部错误"}
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user