2 Star 2 Fork 0

lzz/users

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
createhistorylogic.go 1.06 KB
一键复制 编辑 原始数据 按行查看 历史
liangzhenchao 提交于 5个月前 . push etc
package userlogic
import (
"context"
"gitee.com/lzzandlyx/users/model/history"
"github.com/jinzhu/copier"
"gitee.com/lzzandlyx/users/internal/svc"
"gitee.com/lzzandlyx/users/user"
"github.com/zeromicro/go-zero/core/logx"
)
type CreateHistoryLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewCreateHistoryLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateHistoryLogic {
return &CreateHistoryLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
func (l *CreateHistoryLogic) CreateHistory(in *user.CreateHistoryRequest) (*user.CreateHistoryResponse, error) {
res, err := l.svcCtx.ModelHistory.CreateHistory(l.ctx, &history.BrowseHistory{
UserId: in.Info.UserId,
GoodsId: in.Info.GoodsId,
Title: in.Info.Title,
Price: in.Info.Price,
Cover: in.Info.Cover,
BrowseDate: in.Info.BrowseDate,
})
var resInfo user.HistoryInfo
err = copier.Copy(&resInfo, res)
if err != nil {
return nil, err
}
return &user.CreateHistoryResponse{
Info: &resInfo,
}, nil
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/lzzandlyx/users.git
git@gitee.com:lzzandlyx/users.git
lzzandlyx
users
users
1f6533e23511

搜索帮助