protocol.go 941 B

1234567891011121314151617181920212223242526272829303132
  1. package service
  2. import (
  3. "context"
  4. "google.golang.org/grpc/codes"
  5. "google.golang.org/grpc/status"
  6. "protocol-server/common"
  7. "protocol-server/models"
  8. )
  9. import (
  10. pb "protocol-server/rpc_idl/dr_protocol_pb"
  11. )
  12. type ProtocolServer struct {
  13. pb.UnimplementedProtocolServer
  14. }
  15. func (s *ProtocolServer) GetPatientType(ctx context.Context, in *pb.PatientTypeRequest) (*pb.PatientTypeReply, error) {
  16. product, _, _ := common.GetHeader(ctx)
  17. res := pb.PatientTypeReply{}
  18. err := models.DB.Model(&models.PatientType{}).Scopes(
  19. models.String("product = ?", product.ToString()),
  20. ).Order("sort").Find(&res.PatientTypeList).Error
  21. if err != nil {
  22. return nil, status.Errorf(codes.Internal, "patient_type find err %v", err)
  23. }
  24. return &res, nil
  25. }
  26. func (s *ProtocolServer) GetBodyPart(ctx context.Context, in *pb.BodyPartRequest) (*pb.BodyPartReply, error) {
  27. return nil, status.Errorf(codes.Unimplemented, "method GetBodyPart not implemented")
  28. }