123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- package product
- import (
- "context"
- "sghgogs.com/micro/shopping-service/domain/service"
- pb "sghgogs.com/micro/shopping-service/proto"
- )
- type Product struct {
- Service service.IService
- }
- func (svc *Product) GetProductList(ctx context.Context, query *pb.GetProductListRequest, rsp *pb.GetProductListResponse) error {
- if list, i, err := svc.Service.GetProductList(query); err != nil {
- return err
- } else {
- rsp.TotalCount = i
- rsp.Items = list
- }
- return nil
- }
- func (svc *Product) GetProduct(ctx context.Context, query *pb.GetProductRequest, rsp *pb.GetProductResponse) error {
- if product, err := svc.Service.GetProduct(query); err != nil {
- return err
- } else {
- rsp.Data = product
- }
- return nil
- }
- func (svc *Product) CreateProduct(ctx context.Context, add *pb.CreateProductRequest, rsp *pb.CreateProductResponse) error {
- if err := svc.Service.CreateMultipleProducts(add); err != nil {
- return err
- }
- return nil
- }
- func (svc *Product) UpdateProduct(ctx context.Context, product *pb.UpdateProductRequest, rsp *pb.UpdateProductResponse) error {
- if err := svc.Service.UpdateProduct(product); err != nil {
- return err
- }
- return nil
- }
- func (svc *Product) DeleteProduct(ctx context.Context, query *pb.DeleteProductRequest, rsp *pb.DeleteProductResponse) error {
- if err := svc.Service.DeleteProduct(query); err != nil {
- return err
- }
- return nil
- }
|