Pull latest changes from upstream/main (GitHub) including: - Purchase RPC service (proto, server, logic, models) - Gateway route updates for purchase endpoints - SQL migration and config updates Excludes deploy/bin/ pre-compiled arm64 binaries (builds use multi-stage Dockerfiles targeting amd64).
39 lines
950 B
Go
39 lines
950 B
Go
package logic
|
|
|
|
import (
|
|
"context"
|
|
"database/sql"
|
|
|
|
"muyu-apiserver/rpc/purchase/internal/svc"
|
|
"muyu-apiserver/rpc/purchase/pb"
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
)
|
|
|
|
type UpdateSupplierLogic struct {
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
logx.Logger
|
|
}
|
|
|
|
func NewUpdateSupplierLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateSupplierLogic {
|
|
return &UpdateSupplierLogic{ctx: ctx, svcCtx: svcCtx, Logger: logx.WithContext(ctx)}
|
|
}
|
|
|
|
func (l *UpdateSupplierLogic) UpdateSupplier(in *pb.UpdateSupplierReq) (*pb.Empty, error) {
|
|
s, err := l.svcCtx.SupplierModel.FindOneBySupplierId(l.ctx, in.SupplierId)
|
|
if err != nil {
|
|
return nil, ErrSupplierNotFound
|
|
}
|
|
|
|
s.SupplierName = in.SupplierName
|
|
s.Phone = in.Phone
|
|
s.Status = in.Status
|
|
s.Remark = sql.NullString{String: in.Remark, Valid: in.Remark != ""}
|
|
|
|
if err := l.svcCtx.SupplierModel.Update(l.ctx, s); err != nil {
|
|
return nil, err
|
|
}
|
|
return &pb.Empty{}, nil
|
|
}
|