shao преди 1 ден
родител
ревизия
31c07a957a
променени са 6 файла, в които са добавени 34 реда и са изтрити 4 реда
  1. 0 1
      api/v1/protocol.go
  2. 11 0
      api/v1/resource.go
  3. 1 0
      router/router.go
  4. 1 1
      rpc_idl
  5. 2 2
      service/pb_protocol_client.go
  6. 19 0
      service/pb_resource_client.go

+ 0 - 1
api/v1/protocol.go

@@ -19,7 +19,6 @@ func GetPatientTypeList(c *gin.Context) {
 }
 
 func GetBodyPartList(c *gin.Context) {
-
 	res, err := service.ProtocolClient.GetBodyPartList(common.GC2GM(c),
 		common.GetQueryString(c, "patient_type"),
 		common.GetQueryString(c, "modality"),

+ 11 - 0
api/v1/config.go → api/v1/resource.go

@@ -10,6 +10,17 @@ import (
 	"auth-server/service"
 )
 
+func GetProtocolOptions(c *gin.Context) {
+	res, err := service.ResourceClient.GetOptions(common.GC2GM(c),
+		common.GetQueryString(c, "group"),
+		common.GetQueryString(c, "flag"))
+	if err != nil {
+		common.HttpErr(c, err)
+		return
+	}
+	common.HttpSuccess(c, res)
+}
+
 //func GetConfigs(c *gin.Context) {
 //	res, err := service.GetConfigList()
 //	if err != nil {

+ 1 - 0
router/router.go

@@ -33,6 +33,7 @@ func InitRouter() *gin.Engine {
 		}
 		protocolV1 := authV1.Group("/protocol")
 		{
+			protocolV1.GET("options", apiv1.GetProtocolOptions)
 			protocolV1.GET("patient_type", apiv1.GetPatientTypeList)
 			protocolV1.GET("body_part", apiv1.GetBodyPartList)
 			protocolV1.GET("procedure", apiv1.GetProcedureList)

+ 1 - 1
rpc_idl

@@ -1 +1 @@
-Subproject commit 69c0d69921d9a11c2a185993cf91496f2588c3e2
+Subproject commit 095f02566cb5f696ff572ab67b21c5fe2437a33c

+ 2 - 2
service/pb_protocol_client.go

@@ -30,7 +30,7 @@ type Protocol struct {
 func (s *Protocol) Setup() {
 	conn, err := grpc.NewClient(common.ServerConfig.Protocol, grpc.WithTransportCredentials(insecure.NewCredentials()))
 	if err != nil {
-		slog.Error("NewClient failed:", err)
+		slog.Error("NewClient failed", "err", err)
 		panic(err)
 	}
 	slog.Info("protocol conn success", "conn", conn.GetState())
@@ -65,7 +65,7 @@ func (s *Protocol) GetPatientTypeList(ctx context.Context, isEnabled *bool) (*pb
 	if err != nil {
 		slog.Error("[rpc]GetPatientType failed", "err", err)
 	}
-	slog.Info("[rpc]GetPatientTypeList result:", "rows", len(r.PatientTypeList))
+	slog.Info("[rpc]GetPatientTypeList result", "rows", len(r.PatientTypeList))
 	return r, err
 }
 

+ 19 - 0
service/pb_resource_client.go

@@ -2,6 +2,7 @@ package service
 
 import (
 	"context"
+	"errors"
 	"log/slog"
 	"time"
 )
@@ -55,6 +56,24 @@ func (s *Resource) GetSoftwareInfo() *pb.SoftwareInfoReply {
 	return r
 }
 
+func (s *Resource) GetOptions(ctx context.Context, group, flag *string) (*pb.OptionReply, error) {
+	if group == nil {
+		return nil, errors.New("group is nil")
+	}
+	if flag == nil {
+		return nil, errors.New("flag is nil")
+	}
+	r, err := s.configClient.GetOptions(ctx, &pb.OptionRequest{
+		Group: *group,
+		Flag:  *flag,
+	})
+	if err != nil {
+		slog.Error("[rpc]GetOptions failed", "err", err)
+	}
+	slog.Info("[rpc]GetOptions result", "rows", len(r.Option))
+	return r, err
+}
+
 func (s *Resource) GetConfigOptionList(ctx context.Context, flag string, enable bool) ([]*pb.ConfigOption, error) {
 	slog.Info("[rpc]GetConfigOptionList...")
 	r, err := s.configClient.ConfigOptionList(ctx, &pb.ConfigOptionListRequest{