110 lines
2.4 KiB
Go
110 lines
2.4 KiB
Go
package appInfoSer
|
|
|
|
import (
|
|
"context"
|
|
"stat/api/proto"
|
|
"stat/common/genId"
|
|
"stat/common/stdLog"
|
|
"stat/common/utils"
|
|
|
|
"stat/models/landingPage"
|
|
"time"
|
|
)
|
|
|
|
// 获取LandingPage列表
|
|
func GetLandingPageList(ctx context.Context, param proto.FindLandingPageReq) (code stdLog.CodeType, data interface{}, err error) {
|
|
resp := proto.LandingPageListRes{
|
|
Total: 0,
|
|
List: make([]proto.LandingPageInfo, 0),
|
|
}
|
|
|
|
skip, limit := utils.ToDBPage(param.PageNum, param.PageSize)
|
|
|
|
total, aList, err := landingPage.FindLandingPageList(ctx, param.AppId, skip, limit)
|
|
if err != nil {
|
|
code = stdLog.Failure
|
|
return
|
|
}
|
|
|
|
for _, v := range aList {
|
|
tmp := proto.LandingPageInfo{
|
|
ID: v.ID,
|
|
AppId: v.AppId,
|
|
Url: v.Url,
|
|
Status: v.Status,
|
|
Type: v.Type,
|
|
ChannelCode: v.ChannelCode,
|
|
Remark: v.Remark,
|
|
}
|
|
|
|
resp.List = append(resp.List, tmp)
|
|
}
|
|
|
|
resp.Total = total
|
|
|
|
data = resp
|
|
code = stdLog.Success
|
|
return
|
|
}
|
|
|
|
// 添加LandingPage
|
|
func AddLandingPage(ctx context.Context, param proto.AddLandingPageReq) (code stdLog.CodeType, data interface{}, err error) {
|
|
now := time.Now()
|
|
doc := landingPage.LandingPage{
|
|
ID: genId.GetNextLandingpageId(),
|
|
AppId: *param.AppId,
|
|
Url: *param.Url,
|
|
Status: *param.Status,
|
|
Type: *param.Type,
|
|
CreatedAt: now,
|
|
UpdatedAt: now,
|
|
}
|
|
if param.ChannelCode != nil {
|
|
doc.ChannelCode = *param.ChannelCode
|
|
}
|
|
|
|
if param.Remark != nil {
|
|
doc.Remark = *param.Remark
|
|
}
|
|
|
|
if _, err = landingPage.AddLandingPage(ctx, &doc); err != nil {
|
|
code = stdLog.Failure
|
|
return
|
|
}
|
|
|
|
code = stdLog.Success
|
|
return
|
|
}
|
|
|
|
// 更新LandingPage
|
|
func UpdateLandingPage(ctx context.Context, param proto.UpdateLandingPageReq) (code stdLog.CodeType, data interface{}, err error) {
|
|
now := time.Now()
|
|
doc := landingPage.UpdateDoc{
|
|
Url: param.Url,
|
|
Status: param.Status,
|
|
Remark: param.Remark,
|
|
ChannelCode: param.ChannelCode,
|
|
Type: param.Type,
|
|
UpdatedAt: &now,
|
|
}
|
|
|
|
if err = landingPage.UpdateLandingPage(ctx, param.ID, doc); err != nil {
|
|
code = stdLog.Failure
|
|
return
|
|
}
|
|
|
|
code = stdLog.Success
|
|
return
|
|
}
|
|
|
|
// 删除LandingPage
|
|
func DelLandingPage(ctx context.Context, param proto.DelLandingPageReq) (code stdLog.CodeType, data interface{}, err error) {
|
|
if err = landingPage.DelLandingPage(ctx, param.ID); err != nil {
|
|
code = stdLog.Failure
|
|
return
|
|
}
|
|
|
|
code = stdLog.Success
|
|
return
|
|
}
|