package product import ( "context" "perms-system-server/internal/response" "perms-system-server/internal/svc" "perms-system-server/internal/types" "github.com/zeromicro/go-zero/core/logx" ) type ProductDetailLogic struct { logx.Logger ctx context.Context svcCtx *svc.ServiceContext } func NewProductDetailLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ProductDetailLogic { return &ProductDetailLogic{ Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx, } } func (l *ProductDetailLogic) ProductDetail(req *types.ProductDetailReq) (resp *types.ProductItem, err error) { product, err := l.svcCtx.SysProductModel.FindOne(l.ctx, req.Id) if err != nil { return nil, response.ErrNotFound("产品不存在") } return &types.ProductItem{ Id: product.Id, Code: product.Code, Name: product.Name, AppKey: product.AppKey, Remark: product.Remark, Status: product.Status, CreateTime: product.CreateTime, }, nil }