Files
slogan/server/styleagent/controller/cps_product_controller.go
T
admin a6de9ebd12 Add 'server/' from commit 'e64421295fff83acbb6d6ab3d3b27f3ef8368f00'
git-subtree-dir: server
git-subtree-mainline: c4e617ada7
git-subtree-split: e64421295f
2026-08-04 15:02:35 +08:00

36 lines
1.1 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package controller
import (
"context"
"slogan-agent/common"
"slogan-agent/styleagent/model/dto"
"slogan-agent/styleagent/service"
"github.com/gogf/gf/v2/frame/g"
)
// cps 共享 struct/cps/* 簇的 6 个 handler 分文件挂在同一个类型上(组前缀路由零变更)
type cps struct{}
var Cps = new(cps)
// ProductList 选品池分页列表
func (c *cps) ProductList(ctx context.Context, req *dto.CpsProductListReq) (res *dto.CpsProductListRes, err error) {
list, hasMore, err := service.CpsProductService.ListByCategory(ctx, req.Source, req.CategoryCode, req.City, req.Page, 0)
if err != nil {
return nil, err
}
return &dto.CpsProductListRes{List: list, HasMore: hasMore}, nil
}
// ProductLink 商品转链(记录点击日志)
func (c *cps) ProductLink(ctx context.Context, req *dto.CpsProductLinkReq) (res *dto.CpsProductLinkRes, err error) {
r := g.RequestFromCtx(ctx)
link, err := service.CpsProductService.ClickLink(ctx, common.GetUserId(r), req.ProductId, req.Scene, req.PlanId, r.GetClientIp())
if err != nil {
return nil, err
}
return &dto.CpsProductLinkRes{Deeplink: link}, nil
}