Просмотр исходного кода

Merge branch 'master' of http://192.168.3.207:8080/ApplicationCenter/medicalField into master

zhangxinlei1996 2 лет назад
Родитель
Сommit
1a8dd0863a

+ 1 - 1
Makefile

@@ -31,7 +31,7 @@ check:
 
 #跑静态分析
 lint:
-	golangcli-lint run --enable-all
+	golangci-lint run
 
 #定义变量
 API_LINUX_FILE=./.output/medical_field_api_linux

+ 1 - 1
api/medical/etc/medical-api.yaml

@@ -1,7 +1,7 @@
 Name: medical-api
 Host: 0.0.0.0
 Port: 8881
-WebRpcPort: 8016
+WebRpcPort: 8017
 Timeout: 10000
 Medical:
   Etcd:

+ 1 - 3
api/medical/internal/logic/distributor/claimdistributorlogic.go

@@ -34,8 +34,7 @@ func (l *ClaimDistributorLogic) ClaimDistributor(req *types.ClaimDistributorReq)
 		PageSize: int64(req.PageSize),
 	})
 
-	var result interface{}
-	result = map[string]interface{}{
+	result := map[string]interface{}{
 		"list":  rs.Data.List,
 		"total": rs.Data.Total,
 	}
@@ -51,5 +50,4 @@ func (l *ClaimDistributorLogic) ClaimDistributor(req *types.ClaimDistributorReq)
 		Error_code: int(rs.ErrorCode),
 		Data:       result,
 	}, nil
-
 }

+ 1 - 3
api/medical/internal/logic/institution/claiminstitutionlogic.go

@@ -31,9 +31,8 @@ func (l *ClaimInstitutionLogic) ClaimInstitution(req *types.ClaimInstitutionReq)
 		Page:     int64(req.Page),
 		PageSize: int64(req.PageSize),
 	})
-	var result interface{}
 
-	result = map[string]interface{}{
+	result := map[string]interface{}{
 		"list":  rs.Data.List,
 		"total": rs.Data.Total,
 	}
@@ -49,5 +48,4 @@ func (l *ClaimInstitutionLogic) ClaimInstitution(req *types.ClaimInstitutionReq)
 		Error_code: int(rs.ErrorCode),
 		Data:       result,
 	}, nil
-
 }

+ 20 - 4
api/medical/internal/logic/public/distributorclaimlogic.go

@@ -28,11 +28,27 @@ func NewDistributorClaimLogic(ctx context.Context, svcCtx *svc.ServiceContext) *
 
 // DistributorClaim 经销商认领
 func (l *DistributorClaimLogic) DistributorClaim(req *types.ClaimReq) (resp *types.ClaimResp, err error) {
+	// 解密企业id
+	entID := encrypt.SE.DecodeString(req.EntId)
+	if !entity.IsUtf8([]byte(entID)) {
+		// 尝试使用第二种方式解密
+		logx.Infof("解密失败,尝试第二种方式")
+		entID = encrypt.DecodeArticleId2ByCheck(req.EntId)[0]
+	}
+	if entID == "" || req.EntName == "" {
+		return &types.ClaimResp{
+			Error_msg:   "参数有误",
+			Error_code:  entity.ERRORCODE,
+			ResourceNum: 0,
+			ResourceIds: 0,
+		}, nil
+	}
 	rs, err := l.svcCtx.Medical.Claim(l.ctx, &medical.ClaimReq{
-		UserId: int64(req.UserId),
-		EntId:  encrypt.SE.DecodeString(req.EntId),
-		Type:   entity.TypeDistributor,
-		AppId:  req.AppId,
+		UserId:  int64(req.UserId),
+		EntId:   entID,
+		Type:    entity.TypeDistributor,
+		AppId:   req.AppId,
+		EntName: req.EntName,
 	})
 	if err != nil || rs == nil {
 		logx.Errorf("%v: req:%v err:%v ", entity.FunctionDistributorClaim, req, err)

+ 16 - 1
api/medical/internal/logic/public/distributorunclaimedlogic.go

@@ -27,9 +27,24 @@ func NewDistributorUnclaimedLogic(ctx context.Context, svcCtx *svc.ServiceContex
 
 // DistributorUnclaimed 经销商取消认领
 func (l *DistributorUnclaimedLogic) DistributorUnclaimed(req *types.ClaimReq) (resp *types.ClaimResp, err error) {
+	// 解密企业id
+	entID := encrypt.SE.DecodeString(req.EntId)
+	if !entity.IsUtf8([]byte(entID)) {
+		// 尝试使用第二种方式解密
+		logx.Infof("解密失败,尝试第二种方式")
+		entID = encrypt.DecodeArticleId2ByCheck(req.EntId)[0]
+	}
+	if entID == "" {
+		return &types.ClaimResp{
+			Error_msg:   "参数有误",
+			Error_code:  entity.ERRORCODE,
+			ResourceNum: 0,
+			ResourceIds: 0,
+		}, nil
+	}
 	rs, err := l.svcCtx.Medical.UnClaimed(l.ctx, &medical.ClaimReq{
 		UserId: int64(req.UserId),
-		EntId:  encrypt.SE.DecodeString(req.EntId),
+		EntId:  entID,
 		Type:   entity.TypeDistributor,
 		AppId:  req.AppId,
 	})

+ 20 - 4
api/medical/internal/logic/public/institutionclaimlogic.go

@@ -26,11 +26,27 @@ func NewInstitutionclaimLogic(ctx context.Context, svcCtx *svc.ServiceContext) *
 
 // Institutionclaim 机构认领
 func (l *InstitutionclaimLogic) Institutionclaim(req *types.ClaimReq) (resp *types.ClaimResp, err error) {
+	// 解密企业id
+	entID := encrypt.SE.DecodeString(req.EntId)
+	if !entity.IsUtf8([]byte(entID)) {
+		// 尝试使用第二种方式解密
+		logx.Infof("解密失败,尝试第二种方式")
+		entID = encrypt.DecodeArticleId2ByCheck(req.EntId)[0]
+	}
+	if entID == "" || req.EntName == "" {
+		return &types.ClaimResp{
+			Error_msg:   "参数有误",
+			Error_code:  entity.ERRORCODE,
+			ResourceNum: 0,
+			ResourceIds: 0,
+		}, nil
+	}
 	rs, err := l.svcCtx.Medical.Claim(l.ctx, &medical.ClaimReq{
-		UserId: int64(req.UserId),
-		EntId:  encrypt.SE.DecodeString(req.EntId),
-		Type:   entity.TypeInstitution,
-		AppId:  req.AppId,
+		UserId:  int64(req.UserId),
+		EntId:   entID,
+		Type:    entity.TypeInstitution,
+		AppId:   req.AppId,
+		EntName: req.EntName,
 	})
 	if err != nil || rs == nil {
 		logx.Errorf("%v: req:%v err:%v ", entity.FunctionInstitutionClaim, req, err)

+ 16 - 1
api/medical/internal/logic/public/institutionunclaimedlogic.go

@@ -28,9 +28,24 @@ func NewInstitutionUnclaimedLogic(ctx context.Context, svcCtx *svc.ServiceContex
 
 // InstitutionUnclaimed 机构取消认领
 func (l *InstitutionUnclaimedLogic) InstitutionUnclaimed(req *types.ClaimReq) (resp *types.ClaimResp, err error) {
+	// 解密企业id
+	entID := encrypt.SE.DecodeString(req.EntId)
+	if !entity.IsUtf8([]byte(entID)) {
+		// 尝试使用第二种方式解密
+		logx.Infof("解密失败,尝试第二种方式")
+		entID = encrypt.DecodeArticleId2ByCheck(req.EntId)[0]
+	}
+	if entID == "" {
+		return &types.ClaimResp{
+			Error_msg:   "参数有误",
+			Error_code:  entity.ERRORCODE,
+			ResourceNum: 0,
+			ResourceIds: 0,
+		}, nil
+	}
 	rs, err := l.svcCtx.Medical.UnClaimed(l.ctx, &medical.ClaimReq{
 		UserId: int64(req.UserId),
-		EntId:  encrypt.SE.DecodeString(req.EntId),
+		EntId:  entID,
 		Type:   entity.TypeInstitution,
 		AppId:  req.AppId,
 	})

+ 15 - 2
api/medical/internal/logic/public/isclaimedlogic.go

@@ -2,6 +2,7 @@ package public
 
 import (
 	"app.yhyue.com/moapp/jybase/encrypt"
+	"bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/entity"
 	"bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/rpc/medical/medical"
 	"context"
 
@@ -27,10 +28,22 @@ func NewIsClaimedLogic(ctx context.Context, svcCtx *svc.ServiceContext) *IsClaim
 
 // IsClaimed 是否认领
 func (l *IsClaimedLogic) IsClaimed(req *types.IsClaimedReq) (resp *types.CommonRes, err error) {
-
+	// 解密企业id
+	entID := encrypt.SE.DecodeString(req.CompanyId)
+	if !entity.IsUtf8([]byte(entID)) {
+		// 尝试使用第二种方式解密
+		logx.Infof("解密失败,尝试第二种方式")
+		entID = encrypt.DecodeArticleId2ByCheck(req.CompanyId)[0]
+	}
+	if entID == "" {
+		return &types.CommonRes{
+			Error_msg:  "参数有误",
+			Error_code: entity.ERRORCODE,
+		}, nil
+	}
 	rs, _ := l.svcCtx.Medical.IsClaimed(l.ctx, &medical.IsClaimedReq{
 		UserId: int64(req.UserId),
-		EntId:  encrypt.SE.DecodeString(req.CompanyId),
+		EntId:  entID,
 		Type:   int64(req.Type),
 	})
 	return &types.CommonRes{

+ 6 - 5
api/medical/internal/types/types.go

@@ -65,16 +65,17 @@ type DistributorProductsReq struct {
 }
 
 type ClaimReq struct {
-	EntId  string `json:"ent_id"`      // 企业标识
-	UserId int    `header:"newUserId"` // 用户id
-	AppId  string `header:"appId"`     // appid
+	EntId   string `json:"ent_id"`            // 企业标识
+	EntName string `json:"ent_name,optional"` // 企业标识
+	UserId  int    `header:"newUserId"`       // 用户id
+	AppId   string `header:"appId"`           // appid
 }
 
 type ClaimResp struct {
 	Error_code  int    `json:"error_code"`
 	Error_msg   string `json:"error_msg"`
-	ResourceNum int    `json:"resourceNum"`
-	ResourceIds int    `json:"resourceIds"`
+	ResourceNum int    `json:"resourceNum"` // 扣减条数
+	ResourceIds int    `json:"resourceIds"` // 记录id
 }
 
 type IsClaimedReq struct {

+ 7 - 7
api/medical/medical.api

@@ -66,18 +66,18 @@ type DistributorProductsReq {
 	Page      int    `json:"page,optional"`      // 页码
 	PageSize  int    `json:"page_size,optional"` // 每页条数
 }
-// 认领/取消认领
+// 取消认领
 type ClaimReq {
-	EntId  string `json:"ent_id"`      // 企业标识
-	UserId int    `header:"newUserId"` // 用户id
-	AppId  string `header:"appId"`     // appid
+	EntId   string `json:"ent_id"`            // 企业标识
+	EntName string `json:"ent_name,optional"` // 企业标识
+	UserId  int    `header:"newUserId"`       // 用户id
+	AppId   string `header:"appId"`           // appid
 }
-
 type ClaimResp {
 	Error_code  int    `json:"error_code"`
 	Error_msg   string `json:"error_msg"`
-	ResourceNum int    `json:"resourceNum"`
-	ResourceIds int    `json:"resourceIds"`
+	ResourceNum int    `json:"resourceNum"` // 扣减条数
+	ResourceIds int    `json:"resourceIds"` // 记录id
 }
 // 是否是认领过的
 type IsClaimedReq {

+ 44 - 0
entity/util.go

@@ -148,3 +148,47 @@ func ConversionMoeny(i_money interface{}) string {
 func DefectDataHandle() {
 
 }
+func preNUm(data byte) int {
+	var mask byte = 0x80
+	var num int = 0
+	//8bit中首个0bit前有多少个1bits
+	for i := 0; i < 8; i++ {
+		if (data & mask) == mask {
+			num++
+			mask = mask >> 1
+		} else {
+			break
+		}
+	}
+	return num
+}
+
+func IsUtf8(data []byte) bool {
+	i := 0
+	for i < len(data) {
+		if (data[i] & 0x80) == 0x00 {
+			// 0XXX_XXXX
+			i++
+			continue
+		} else if num := preNUm(data[i]); num > 2 {
+			// 110X_XXXX 10XX_XXXX
+			// 1110_XXXX 10XX_XXXX 10XX_XXXX
+			// 1111_0XXX 10XX_XXXX 10XX_XXXX 10XX_XXXX
+			// 1111_10XX 10XX_XXXX 10XX_XXXX 10XX_XXXX 10XX_XXXX
+			// 1111_110X 10XX_XXXX 10XX_XXXX 10XX_XXXX 10XX_XXXX 10XX_XXXX
+			// preNUm() 返回首个字节的8个bits中首个0bit前面1bit的个数,该数量也是该字符所使用的字节数
+			i++
+			for j := 0; j < num-1; j++ {
+				//判断后面的 num - 1 个字节是不是都是10开头
+				if (data[i] & 0xc0) != 0x80 {
+					return false
+				}
+				i++
+			}
+		} else {
+			//其他情况说明不是utf-8
+			return false
+		}
+	}
+	return true
+}

+ 1 - 1
rpc/medical/internal/logic/claimeddistributorlistlogic.go

@@ -38,7 +38,7 @@ func (l *ClaimedDistributorListLogic) ClaimedDistributorList(in *medical.Claimed
 		}
 		// 查询信息
 		entRs := l.svcCtx.EntClaimSrv.GetInstitutionByIds(entIds)
-		//处理成map
+		// 处理成map
 		entInfos := map[string]map[string]interface{}{}
 		if entRs != nil {
 			for i := 0; i < len(*entRs); i++ {

+ 1 - 1
rpc/medical/internal/logic/claimedinstitutionlistlogic.go

@@ -41,7 +41,7 @@ func (l *ClaimedInstitutionListLogic) ClaimedInstitutionList(in *medical.Claimed
 		}
 		// 查询信息
 		entRs := l.svcCtx.EntClaimSrv.GetInstitutionByIds(entIds)
-		//处理成map
+		// 处理成map
 		entInfos := map[string]map[string]interface{}{}
 		if entRs != nil {
 			for i := 0; i < len(*entRs); i++ {

+ 1 - 6
rpc/medical/internal/logic/claimlogic.go

@@ -27,15 +27,11 @@ func NewClaimLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ClaimLogic
 // Claim 认领(经销商/医疗机构)
 func (l *ClaimLogic) Claim(in *medical.ClaimReq) (*medical.ClaimResp, error) {
 	// 查询基本信息
-	baseInfo := l.svcCtx.EntClaimSrv.GetInstitution(in.EntId)
-	if baseInfo == nil || len(*baseInfo) == 0 {
-		return nil, entity.EntNoFoundErr
-	}
 	rs, err := l.svcCtx.EntClaimSrv.Claim(&entity.EntClaim{
 		AppId:      in.AppId,
 		UserId:     int(in.UserId),
 		EntId:      in.EntId,
-		EntName:    common.ObjToString((*baseInfo)["company_name"]),
+		EntName:    in.EntName,
 		Status:     entity.StatusClaimed,
 		Type:       int(in.Type),
 		CreateTime: date.NowFormat(date.Date_Full_Layout),
@@ -45,7 +41,6 @@ func (l *ClaimLogic) Claim(in *medical.ClaimReq) (*medical.ClaimResp, error) {
 	}
 	if err != nil {
 		return nil, entity.RepeatErr
-
 	}
 	return &medical.ClaimResp{
 		ErrorMsg:    "",

+ 2 - 1
rpc/medical/medical.proto

@@ -144,10 +144,11 @@ message ClaimReq{
   string EntId = 2 ;// 公司id
   int64 Type = 3 ;// 类型;1:医疗机构 2:经销商'
   string AppId = 4 ;//appid
+  string EntName = 5 ;//企业名称
 }
 
 
-//
+// 认领响应
 message ClaimResp{
   int64           ErrorCode = 1;  // 响应代码
   string          ErrorMsg = 2;   // 响应信息

+ 174 - 164
rpc/medical/medical/medical.pb.go

@@ -1,7 +1,7 @@
 // Code generated by protoc-gen-go. DO NOT EDIT.
 // versions:
 // 	protoc-gen-go v1.28.0
-// 	protoc        v3.15.1
+// 	protoc        v3.19.4
 // source: medical.proto
 
 package medical
@@ -1430,10 +1430,11 @@ type ClaimReq struct {
 	sizeCache     protoimpl.SizeCache
 	unknownFields protoimpl.UnknownFields
 
-	UserId int64  `protobuf:"varint,1,opt,name=UserId,proto3" json:"UserId,omitempty"` // 用户id
-	EntId  string `protobuf:"bytes,2,opt,name=EntId,proto3" json:"EntId,omitempty"`    // 公司id
-	Type   int64  `protobuf:"varint,3,opt,name=Type,proto3" json:"Type,omitempty"`     // 类型;1:医疗机构 2:经销商'
-	AppId  string `protobuf:"bytes,4,opt,name=AppId,proto3" json:"AppId,omitempty"`    //appid
+	UserId  int64  `protobuf:"varint,1,opt,name=UserId,proto3" json:"UserId,omitempty"`  // 用户id
+	EntId   string `protobuf:"bytes,2,opt,name=EntId,proto3" json:"EntId,omitempty"`     // 公司id
+	Type    int64  `protobuf:"varint,3,opt,name=Type,proto3" json:"Type,omitempty"`      // 类型;1:医疗机构 2:经销商'
+	AppId   string `protobuf:"bytes,4,opt,name=AppId,proto3" json:"AppId,omitempty"`     //appid
+	EntName string `protobuf:"bytes,5,opt,name=EntName,proto3" json:"EntName,omitempty"` //企业名称
 }
 
 func (x *ClaimReq) Reset() {
@@ -1496,7 +1497,14 @@ func (x *ClaimReq) GetAppId() string {
 	return ""
 }
 
-//
+func (x *ClaimReq) GetEntName() string {
+	if x != nil {
+		return x.EntName
+	}
+	return ""
+}
+
+// 认领响应
 type ClaimResp struct {
 	state         protoimpl.MessageState
 	sizeCache     protoimpl.SizeCache
@@ -2619,171 +2627,173 @@ var file_medical_proto_rawDesc = []byte{
 	0x12, 0x12, 0x0a, 0x04, 0x63, 0x69, 0x74, 0x79, 0x18, 0x11, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04,
 	0x63, 0x69, 0x74, 0x79, 0x12, 0x1a, 0x0a, 0x08, 0x64, 0x69, 0x73, 0x74, 0x72, 0x69, 0x63, 0x74,
 	0x18, 0x12, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x64, 0x69, 0x73, 0x74, 0x72, 0x69, 0x63, 0x74,
-	0x22, 0x62, 0x0a, 0x08, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x52, 0x65, 0x71, 0x12, 0x16, 0x0a, 0x06,
+	0x22, 0x7c, 0x0a, 0x08, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x52, 0x65, 0x71, 0x12, 0x16, 0x0a, 0x06,
 	0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x55, 0x73,
 	0x65, 0x72, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x45, 0x6e, 0x74, 0x49, 0x64, 0x18, 0x02, 0x20,
 	0x01, 0x28, 0x09, 0x52, 0x05, 0x45, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x54, 0x79,
 	0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x04, 0x54, 0x79, 0x70, 0x65, 0x12, 0x14,
 	0x0a, 0x05, 0x41, 0x70, 0x70, 0x49, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x41,
-	0x70, 0x70, 0x49, 0x64, 0x22, 0x89, 0x01, 0x0a, 0x09, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x52, 0x65,
-	0x73, 0x70, 0x12, 0x1c, 0x0a, 0x09, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x18,
-	0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65,
-	0x12, 0x1a, 0x0a, 0x08, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x4d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01,
-	0x28, 0x09, 0x52, 0x08, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x4d, 0x73, 0x67, 0x12, 0x20, 0x0a, 0x0b,
-	0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x4e, 0x75, 0x6d, 0x18, 0x03, 0x20, 0x01, 0x28,
-	0x03, 0x52, 0x0b, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x4e, 0x75, 0x6d, 0x12, 0x20,
-	0x0a, 0x0b, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x49, 0x64, 0x73, 0x18, 0x04, 0x20,
-	0x01, 0x28, 0x03, 0x52, 0x0b, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x49, 0x64, 0x73,
-	0x22, 0x66, 0x0a, 0x0c, 0x49, 0x73, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x65, 0x64, 0x52, 0x65, 0x71,
-	0x12, 0x16, 0x0a, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03,
-	0x52, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x45, 0x6e, 0x74, 0x49,
-	0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x45, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x14,
-	0x0a, 0x05, 0x41, 0x70, 0x70, 0x49, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x41,
-	0x70, 0x70, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x54, 0x79, 0x70, 0x65, 0x18, 0x04, 0x20, 0x01,
-	0x28, 0x03, 0x52, 0x04, 0x54, 0x79, 0x70, 0x65, 0x22, 0xa4, 0x01, 0x0a, 0x0d, 0x49, 0x73, 0x43,
-	0x6c, 0x61, 0x69, 0x6d, 0x65, 0x64, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1c, 0x0a, 0x09, 0x45, 0x72,
-	0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x45,
-	0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x45, 0x72, 0x72, 0x6f,
-	0x72, 0x4d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x45, 0x72, 0x72, 0x6f,
-	0x72, 0x4d, 0x73, 0x67, 0x12, 0x34, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x01,
-	0x28, 0x0b, 0x32, 0x20, 0x2e, 0x6d, 0x65, 0x64, 0x69, 0x63, 0x61, 0x6c, 0x2e, 0x49, 0x73, 0x43,
-	0x6c, 0x61, 0x69, 0x6d, 0x65, 0x64, 0x52, 0x65, 0x73, 0x70, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75,
-	0x73, 0x52, 0x65, 0x73, 0x52, 0x04, 0x44, 0x61, 0x74, 0x61, 0x1a, 0x23, 0x0a, 0x09, 0x53, 0x74,
-	0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75,
-	0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22,
-	0x6a, 0x0a, 0x0a, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x65, 0x64, 0x52, 0x65, 0x71, 0x12, 0x16, 0x0a,
-	0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x55,
-	0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x41, 0x70, 0x70, 0x49, 0x64, 0x18, 0x02,
-	0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x41, 0x70, 0x70, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x50,
-	0x61, 0x67, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x04, 0x50, 0x61, 0x67, 0x65, 0x12,
-	0x1a, 0x0a, 0x08, 0x50, 0x61, 0x67, 0x65, 0x53, 0x69, 0x7a, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28,
-	0x03, 0x52, 0x08, 0x50, 0x61, 0x67, 0x65, 0x53, 0x69, 0x7a, 0x65, 0x22, 0x66, 0x0a, 0x0c, 0x47,
-	0x65, 0x74, 0x4e, 0x65, 0x77, 0x4d, 0x73, 0x67, 0x52, 0x65, 0x71, 0x12, 0x20, 0x0a, 0x0b, 0x63,
-	0x6f, 0x6d, 0x70, 0x61, 0x6e, 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,
-	0x52, 0x0b, 0x63, 0x6f, 0x6d, 0x70, 0x61, 0x6e, 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x18, 0x0a,
-	0x07, 0x70, 0x61, 0x67, 0x65, 0x4e, 0x75, 0x6d, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07,
-	0x70, 0x61, 0x67, 0x65, 0x4e, 0x75, 0x6d, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x61, 0x67, 0x65, 0x53,
-	0x69, 0x7a, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x70, 0x61, 0x67, 0x65, 0x53,
-	0x69, 0x7a, 0x65, 0x22, 0x8a, 0x01, 0x0a, 0x0d, 0x47, 0x65, 0x74, 0x4e, 0x65, 0x77, 0x4d, 0x73,
-	0x67, 0x52, 0x65, 0x73, 0x70, 0x12, 0x27, 0x0a, 0x04, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x01, 0x20,
-	0x03, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x6d, 0x65, 0x64, 0x69, 0x63, 0x61, 0x6c, 0x2e, 0x4e, 0x65,
-	0x77, 0x4d, 0x73, 0x67, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x04, 0x6c, 0x69, 0x73, 0x74, 0x12, 0x14,
-	0x0a, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x63,
-	0x6f, 0x75, 0x6e, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x5f, 0x6d, 0x73,
-	0x67, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x4d, 0x73,
-	0x67, 0x12, 0x1d, 0x0a, 0x0a, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18,
-	0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65,
-	0x22, 0xb8, 0x01, 0x0a, 0x0a, 0x4e, 0x65, 0x77, 0x4d, 0x73, 0x67, 0x4c, 0x69, 0x73, 0x74, 0x12,
-	0x12, 0x0a, 0x04, 0x61, 0x72, 0x65, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x61,
-	0x72, 0x65, 0x61, 0x12, 0x1c, 0x0a, 0x09, 0x62, 0x69, 0x64, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73,
-	0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x62, 0x69, 0x64, 0x73, 0x74, 0x61, 0x74, 0x75,
-	0x73, 0x12, 0x1c, 0x0a, 0x09, 0x62, 0x69, 0x64, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x03,
-	0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x62, 0x69, 0x64, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x12,
-	0x1c, 0x0a, 0x09, 0x66, 0x69, 0x72, 0x73, 0x74, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01,
-	0x28, 0x03, 0x52, 0x09, 0x66, 0x69, 0x72, 0x73, 0x74, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x0e, 0x0a,
-	0x02, 0x69, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x14, 0x0a,
-	0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x69,
-	0x74, 0x6c, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x77, 0x69, 0x6e, 0x6e, 0x65, 0x72, 0x18, 0x07, 0x20,
-	0x03, 0x28, 0x09, 0x52, 0x06, 0x77, 0x69, 0x6e, 0x6e, 0x65, 0x72, 0x22, 0xd1, 0x02, 0x0a, 0x08,
-	0x45, 0x6e, 0x74, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x0a,
-	0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72,
-	0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49,
-	0x64, 0x12, 0x15, 0x0a, 0x06, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28,
-	0x09, 0x52, 0x05, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x19, 0x0a, 0x08, 0x65, 0x6e, 0x74, 0x5f,
-	0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x65, 0x6e, 0x74, 0x4e,
-	0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28,
-	0x03, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65,
-	0x73, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73,
-	0x73, 0x12, 0x25, 0x0a, 0x0e, 0x65, 0x73, 0x74, 0x61, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x5f, 0x64,
-	0x61, 0x74, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x65, 0x73, 0x74, 0x61, 0x62,
-	0x6c, 0x69, 0x73, 0x68, 0x44, 0x61, 0x74, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x61, 0x70, 0x69,
-	0x74, 0x61, 0x6c, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x61, 0x70, 0x69, 0x74,
-	0x61, 0x6c, 0x12, 0x23, 0x0a, 0x0d, 0x63, 0x6f, 0x6d, 0x70, 0x61, 0x6e, 0x79, 0x5f, 0x70, 0x68,
-	0x6f, 0x6e, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x63, 0x6f, 0x6d, 0x70, 0x61,
-	0x6e, 0x79, 0x50, 0x68, 0x6f, 0x6e, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x61, 0x70, 0x70, 0x49, 0x64,
-	0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x61, 0x70, 0x70, 0x49, 0x64, 0x12, 0x1f, 0x0a,
-	0x0b, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x0b, 0x20, 0x01,
-	0x28, 0x09, 0x52, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x1f,
-	0x0a, 0x0b, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x0c, 0x20,
-	0x01, 0x28, 0x09, 0x52, 0x0a, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x22,
-	0x51, 0x0a, 0x12, 0x45, 0x6e, 0x74, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x4c, 0x69, 0x73, 0x74, 0x53,
-	0x74, 0x72, 0x75, 0x63, 0x74, 0x12, 0x25, 0x0a, 0x04, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x01, 0x20,
-	0x03, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x6d, 0x65, 0x64, 0x69, 0x63, 0x61, 0x6c, 0x2e, 0x45, 0x6e,
-	0x74, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x52, 0x04, 0x6c, 0x69, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05,
-	0x74, 0x6f, 0x74, 0x61, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x74, 0x6f, 0x74,
-	0x61, 0x6c, 0x22, 0x7d, 0x0a, 0x10, 0x45, 0x6e, 0x74, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x4c, 0x69,
-	0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1c, 0x0a, 0x09, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43,
-	0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x45, 0x72, 0x72, 0x6f, 0x72,
-	0x43, 0x6f, 0x64, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x4d, 0x73, 0x67,
-	0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x4d, 0x73, 0x67,
-	0x12, 0x2f, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b,
-	0x2e, 0x6d, 0x65, 0x64, 0x69, 0x63, 0x61, 0x6c, 0x2e, 0x45, 0x6e, 0x74, 0x43, 0x6c, 0x61, 0x69,
-	0x6d, 0x4c, 0x69, 0x73, 0x74, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x52, 0x04, 0x44, 0x61, 0x74,
-	0x61, 0x22, 0x61, 0x0a, 0x0f, 0x4e, 0x65, 0x77, 0x4d, 0x73, 0x67, 0x45, 0x78, 0x70, 0x6f, 0x72,
-	0x74, 0x52, 0x65, 0x71, 0x12, 0x10, 0x0a, 0x03, 0x69, 0x64, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28,
-	0x09, 0x52, 0x03, 0x69, 0x64, 0x73, 0x12, 0x20, 0x0a, 0x0b, 0x63, 0x6f, 0x6d, 0x70, 0x61, 0x6e,
-	0x79, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x63, 0x6f, 0x6d,
-	0x70, 0x61, 0x6e, 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x6d, 0x6f, 0x6e, 0x67,
-	0x6f, 0x55, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6d, 0x6f, 0x6e, 0x67,
-	0x6f, 0x55, 0x69, 0x64, 0x22, 0x62, 0x0a, 0x10, 0x4e, 0x65, 0x77, 0x4d, 0x73, 0x67, 0x45, 0x78,
-	0x70, 0x6f, 0x72, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61,
-	0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x1b, 0x0a, 0x09,
-	0x65, 0x72, 0x72, 0x6f, 0x72, 0x5f, 0x6d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52,
-	0x08, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x4d, 0x73, 0x67, 0x12, 0x1d, 0x0a, 0x0a, 0x65, 0x72, 0x72,
-	0x6f, 0x72, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x65,
-	0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x32, 0xaf, 0x06, 0x0a, 0x07, 0x4d, 0x65, 0x64,
-	0x69, 0x63, 0x61, 0x6c, 0x12, 0x42, 0x0a, 0x0b, 0x49, 0x6e, 0x73, 0x74, 0x69, 0x74, 0x75, 0x74,
-	0x69, 0x6f, 0x6e, 0x12, 0x1d, 0x2e, 0x6d, 0x65, 0x64, 0x69, 0x63, 0x61, 0x6c, 0x2e, 0x53, 0x65,
-	0x61, 0x72, 0x63, 0x68, 0x49, 0x6e, 0x73, 0x74, 0x69, 0x74, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x52,
-	0x65, 0x71, 0x1a, 0x14, 0x2e, 0x6d, 0x65, 0x64, 0x69, 0x63, 0x61, 0x6c, 0x2e, 0x43, 0x6f, 0x6d,
-	0x70, 0x61, 0x6e, 0x79, 0x52, 0x65, 0x73, 0x70, 0x12, 0x37, 0x0a, 0x0d, 0x47, 0x65, 0x74, 0x46,
-	0x69, 0x6c, 0x74, 0x65, 0x72, 0x49, 0x74, 0x65, 0x6d, 0x12, 0x0d, 0x2e, 0x6d, 0x65, 0x64, 0x69,
-	0x63, 0x61, 0x6c, 0x2e, 0x5a, 0x65, 0x72, 0x6f, 0x1a, 0x17, 0x2e, 0x6d, 0x65, 0x64, 0x69, 0x63,
-	0x61, 0x6c, 0x2e, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x65, 0x73,
-	0x70, 0x12, 0x42, 0x0a, 0x0b, 0x44, 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x6f, 0x72,
-	0x12, 0x1d, 0x2e, 0x6d, 0x65, 0x64, 0x69, 0x63, 0x61, 0x6c, 0x2e, 0x53, 0x65, 0x61, 0x72, 0x63,
-	0x68, 0x44, 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x6f, 0x72, 0x52, 0x65, 0x71, 0x1a,
-	0x14, 0x2e, 0x6d, 0x65, 0x64, 0x69, 0x63, 0x61, 0x6c, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x61, 0x6e,
-	0x79, 0x52, 0x65, 0x73, 0x70, 0x12, 0x3a, 0x0a, 0x10, 0x75, 0x73, 0x65, 0x72, 0x41, 0x75, 0x74,
-	0x68, 0x49, 0x6e, 0x66, 0x6f, 0x53, 0x61, 0x76, 0x65, 0x12, 0x11, 0x2e, 0x6d, 0x65, 0x64, 0x69,
-	0x63, 0x61, 0x6c, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x1a, 0x13, 0x2e, 0x6d,
-	0x65, 0x64, 0x69, 0x63, 0x61, 0x6c, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x52, 0x65, 0x73,
-	0x70, 0x12, 0x39, 0x0a, 0x0c, 0x75, 0x73, 0x65, 0x72, 0x41, 0x75, 0x74, 0x68, 0x49, 0x6e, 0x66,
-	0x6f, 0x12, 0x12, 0x2e, 0x6d, 0x65, 0x64, 0x69, 0x63, 0x61, 0x6c, 0x2e, 0x43, 0x6f, 0x6d, 0x6d,
-	0x6f, 0x6e, 0x52, 0x65, 0x71, 0x1a, 0x15, 0x2e, 0x6d, 0x65, 0x64, 0x69, 0x63, 0x61, 0x6c, 0x2e,
-	0x55, 0x73, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x12, 0x37, 0x0a, 0x08,
-	0x50, 0x6f, 0x72, 0x74, 0x72, 0x61, 0x69, 0x74, 0x12, 0x14, 0x2e, 0x6d, 0x65, 0x64, 0x69, 0x63,
-	0x61, 0x6c, 0x2e, 0x50, 0x6f, 0x72, 0x74, 0x72, 0x61, 0x69, 0x74, 0x52, 0x65, 0x71, 0x1a, 0x15,
-	0x2e, 0x6d, 0x65, 0x64, 0x69, 0x63, 0x61, 0x6c, 0x2e, 0x50, 0x6f, 0x72, 0x74, 0x72, 0x61, 0x69,
-	0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x2e, 0x0a, 0x05, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x12, 0x11,
-	0x2e, 0x6d, 0x65, 0x64, 0x69, 0x63, 0x61, 0x6c, 0x2e, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x52, 0x65,
-	0x71, 0x1a, 0x12, 0x2e, 0x6d, 0x65, 0x64, 0x69, 0x63, 0x61, 0x6c, 0x2e, 0x43, 0x6c, 0x61, 0x69,
-	0x6d, 0x52, 0x65, 0x73, 0x70, 0x12, 0x32, 0x0a, 0x09, 0x55, 0x6e, 0x43, 0x6c, 0x61, 0x69, 0x6d,
-	0x65, 0x64, 0x12, 0x11, 0x2e, 0x6d, 0x65, 0x64, 0x69, 0x63, 0x61, 0x6c, 0x2e, 0x43, 0x6c, 0x61,
-	0x69, 0x6d, 0x52, 0x65, 0x71, 0x1a, 0x12, 0x2e, 0x6d, 0x65, 0x64, 0x69, 0x63, 0x61, 0x6c, 0x2e,
-	0x43, 0x6c, 0x61, 0x69, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x12, 0x3a, 0x0a, 0x09, 0x49, 0x73, 0x43,
-	0x6c, 0x61, 0x69, 0x6d, 0x65, 0x64, 0x12, 0x15, 0x2e, 0x6d, 0x65, 0x64, 0x69, 0x63, 0x61, 0x6c,
-	0x2e, 0x49, 0x73, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x65, 0x64, 0x52, 0x65, 0x71, 0x1a, 0x16, 0x2e,
-	0x6d, 0x65, 0x64, 0x69, 0x63, 0x61, 0x6c, 0x2e, 0x49, 0x73, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x65,
-	0x64, 0x52, 0x65, 0x73, 0x70, 0x12, 0x48, 0x0a, 0x16, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x65, 0x64,
-	0x44, 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x6f, 0x72, 0x4c, 0x69, 0x73, 0x74, 0x12,
-	0x13, 0x2e, 0x6d, 0x65, 0x64, 0x69, 0x63, 0x61, 0x6c, 0x2e, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x65,
-	0x64, 0x52, 0x65, 0x71, 0x1a, 0x19, 0x2e, 0x6d, 0x65, 0x64, 0x69, 0x63, 0x61, 0x6c, 0x2e, 0x45,
-	0x6e, 0x74, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12,
-	0x48, 0x0a, 0x16, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x65, 0x64, 0x49, 0x6e, 0x73, 0x74, 0x69, 0x74,
-	0x75, 0x74, 0x69, 0x6f, 0x6e, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x13, 0x2e, 0x6d, 0x65, 0x64, 0x69,
+	0x70, 0x70, 0x49, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x45, 0x6e, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x18,
+	0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x45, 0x6e, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x22, 0x89,
+	0x01, 0x0a, 0x09, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1c, 0x0a, 0x09,
+	0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52,
+	0x09, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x45, 0x72,
+	0x72, 0x6f, 0x72, 0x4d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x45, 0x72,
+	0x72, 0x6f, 0x72, 0x4d, 0x73, 0x67, 0x12, 0x20, 0x0a, 0x0b, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72,
+	0x63, 0x65, 0x4e, 0x75, 0x6d, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0b, 0x72, 0x65, 0x73,
+	0x6f, 0x75, 0x72, 0x63, 0x65, 0x4e, 0x75, 0x6d, 0x12, 0x20, 0x0a, 0x0b, 0x72, 0x65, 0x73, 0x6f,
+	0x75, 0x72, 0x63, 0x65, 0x49, 0x64, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0b, 0x72,
+	0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x49, 0x64, 0x73, 0x22, 0x66, 0x0a, 0x0c, 0x49, 0x73,
+	0x43, 0x6c, 0x61, 0x69, 0x6d, 0x65, 0x64, 0x52, 0x65, 0x71, 0x12, 0x16, 0x0a, 0x06, 0x55, 0x73,
+	0x65, 0x72, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x55, 0x73, 0x65, 0x72,
+	0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x45, 0x6e, 0x74, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28,
+	0x09, 0x52, 0x05, 0x45, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x41, 0x70, 0x70, 0x49,
+	0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x41, 0x70, 0x70, 0x49, 0x64, 0x12, 0x12,
+	0x0a, 0x04, 0x54, 0x79, 0x70, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x04, 0x54, 0x79,
+	0x70, 0x65, 0x22, 0xa4, 0x01, 0x0a, 0x0d, 0x49, 0x73, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x65, 0x64,
+	0x52, 0x65, 0x73, 0x70, 0x12, 0x1c, 0x0a, 0x09, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64,
+	0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f,
+	0x64, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x4d, 0x73, 0x67, 0x18, 0x02,
+	0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x4d, 0x73, 0x67, 0x12, 0x34,
+	0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x6d,
+	0x65, 0x64, 0x69, 0x63, 0x61, 0x6c, 0x2e, 0x49, 0x73, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x65, 0x64,
+	0x52, 0x65, 0x73, 0x70, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x52, 0x04,
+	0x44, 0x61, 0x74, 0x61, 0x1a, 0x23, 0x0a, 0x09, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65,
+	0x73, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28,
+	0x08, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, 0x6a, 0x0a, 0x0a, 0x43, 0x6c, 0x61,
+	0x69, 0x6d, 0x65, 0x64, 0x52, 0x65, 0x71, 0x12, 0x16, 0x0a, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49,
+	0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12,
+	0x14, 0x0a, 0x05, 0x41, 0x70, 0x70, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05,
+	0x41, 0x70, 0x70, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x50, 0x61, 0x67, 0x65, 0x18, 0x03, 0x20,
+	0x01, 0x28, 0x03, 0x52, 0x04, 0x50, 0x61, 0x67, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x50, 0x61, 0x67,
+	0x65, 0x53, 0x69, 0x7a, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x50, 0x61, 0x67,
+	0x65, 0x53, 0x69, 0x7a, 0x65, 0x22, 0x66, 0x0a, 0x0c, 0x47, 0x65, 0x74, 0x4e, 0x65, 0x77, 0x4d,
+	0x73, 0x67, 0x52, 0x65, 0x71, 0x12, 0x20, 0x0a, 0x0b, 0x63, 0x6f, 0x6d, 0x70, 0x61, 0x6e, 0x79,
+	0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x63, 0x6f, 0x6d, 0x70,
+	0x61, 0x6e, 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x61, 0x67, 0x65, 0x4e,
+	0x75, 0x6d, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x70, 0x61, 0x67, 0x65, 0x4e, 0x75,
+	0x6d, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x61, 0x67, 0x65, 0x53, 0x69, 0x7a, 0x65, 0x18, 0x03, 0x20,
+	0x01, 0x28, 0x03, 0x52, 0x08, 0x70, 0x61, 0x67, 0x65, 0x53, 0x69, 0x7a, 0x65, 0x22, 0x8a, 0x01,
+	0x0a, 0x0d, 0x47, 0x65, 0x74, 0x4e, 0x65, 0x77, 0x4d, 0x73, 0x67, 0x52, 0x65, 0x73, 0x70, 0x12,
+	0x27, 0x0a, 0x04, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x13, 0x2e,
+	0x6d, 0x65, 0x64, 0x69, 0x63, 0x61, 0x6c, 0x2e, 0x4e, 0x65, 0x77, 0x4d, 0x73, 0x67, 0x4c, 0x69,
+	0x73, 0x74, 0x52, 0x04, 0x6c, 0x69, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x6f, 0x75, 0x6e,
+	0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x1b,
+	0x0a, 0x09, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x5f, 0x6d, 0x73, 0x67, 0x18, 0x03, 0x20, 0x01, 0x28,
+	0x09, 0x52, 0x08, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x4d, 0x73, 0x67, 0x12, 0x1d, 0x0a, 0x0a, 0x65,
+	0x72, 0x72, 0x6f, 0x72, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52,
+	0x09, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x22, 0xb8, 0x01, 0x0a, 0x0a, 0x4e,
+	0x65, 0x77, 0x4d, 0x73, 0x67, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x61, 0x72, 0x65,
+	0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x61, 0x72, 0x65, 0x61, 0x12, 0x1c, 0x0a,
+	0x09, 0x62, 0x69, 0x64, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09,
+	0x52, 0x09, 0x62, 0x69, 0x64, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x1c, 0x0a, 0x09, 0x62,
+	0x69, 0x64, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09,
+	0x62, 0x69, 0x64, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x66, 0x69, 0x72,
+	0x73, 0x74, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x66, 0x69,
+	0x72, 0x73, 0x74, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x05, 0x20,
+	0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65,
+	0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x12, 0x16, 0x0a,
+	0x06, 0x77, 0x69, 0x6e, 0x6e, 0x65, 0x72, 0x18, 0x07, 0x20, 0x03, 0x28, 0x09, 0x52, 0x06, 0x77,
+	0x69, 0x6e, 0x6e, 0x65, 0x72, 0x22, 0xd1, 0x02, 0x0a, 0x08, 0x45, 0x6e, 0x74, 0x43, 0x6c, 0x61,
+	0x69, 0x6d, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02,
+	0x69, 0x64, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20,
+	0x01, 0x28, 0x03, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x15, 0x0a, 0x06, 0x65,
+	0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x6e, 0x74,
+	0x49, 0x64, 0x12, 0x19, 0x0a, 0x08, 0x65, 0x6e, 0x74, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03,
+	0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x65, 0x6e, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a,
+	0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x04, 0x74, 0x79, 0x70,
+	0x65, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x05, 0x20, 0x01,
+	0x28, 0x09, 0x52, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x25, 0x0a, 0x0e, 0x65,
+	0x73, 0x74, 0x61, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x5f, 0x64, 0x61, 0x74, 0x65, 0x18, 0x06, 0x20,
+	0x01, 0x28, 0x09, 0x52, 0x0d, 0x65, 0x73, 0x74, 0x61, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x44, 0x61,
+	0x74, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x61, 0x70, 0x69, 0x74, 0x61, 0x6c, 0x18, 0x07, 0x20,
+	0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x61, 0x70, 0x69, 0x74, 0x61, 0x6c, 0x12, 0x23, 0x0a, 0x0d,
+	0x63, 0x6f, 0x6d, 0x70, 0x61, 0x6e, 0x79, 0x5f, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x18, 0x08, 0x20,
+	0x01, 0x28, 0x09, 0x52, 0x0c, 0x63, 0x6f, 0x6d, 0x70, 0x61, 0x6e, 0x79, 0x50, 0x68, 0x6f, 0x6e,
+	0x65, 0x12, 0x14, 0x0a, 0x05, 0x61, 0x70, 0x70, 0x49, 0x64, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09,
+	0x52, 0x05, 0x61, 0x70, 0x70, 0x49, 0x64, 0x12, 0x1f, 0x0a, 0x0b, 0x63, 0x72, 0x65, 0x61, 0x74,
+	0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x63, 0x72,
+	0x65, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x75, 0x70, 0x64, 0x61,
+	0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x75,
+	0x70, 0x64, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x22, 0x51, 0x0a, 0x12, 0x45, 0x6e, 0x74,
+	0x43, 0x6c, 0x61, 0x69, 0x6d, 0x4c, 0x69, 0x73, 0x74, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x12,
+	0x25, 0x0a, 0x04, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x11, 0x2e,
+	0x6d, 0x65, 0x64, 0x69, 0x63, 0x61, 0x6c, 0x2e, 0x45, 0x6e, 0x74, 0x43, 0x6c, 0x61, 0x69, 0x6d,
+	0x52, 0x04, 0x6c, 0x69, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x18,
+	0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x22, 0x7d, 0x0a, 0x10,
+	0x45, 0x6e, 0x74, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70,
+	0x12, 0x1c, 0x0a, 0x09, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20,
+	0x01, 0x28, 0x03, 0x52, 0x09, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x1a,
+	0x0a, 0x08, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x4d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09,
+	0x52, 0x08, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x4d, 0x73, 0x67, 0x12, 0x2f, 0x0a, 0x04, 0x44, 0x61,
+	0x74, 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x6d, 0x65, 0x64, 0x69, 0x63,
+	0x61, 0x6c, 0x2e, 0x45, 0x6e, 0x74, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x4c, 0x69, 0x73, 0x74, 0x53,
+	0x74, 0x72, 0x75, 0x63, 0x74, 0x52, 0x04, 0x44, 0x61, 0x74, 0x61, 0x22, 0x61, 0x0a, 0x0f, 0x4e,
+	0x65, 0x77, 0x4d, 0x73, 0x67, 0x45, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x52, 0x65, 0x71, 0x12, 0x10,
+	0x0a, 0x03, 0x69, 0x64, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x69, 0x64, 0x73,
+	0x12, 0x20, 0x0a, 0x0b, 0x63, 0x6f, 0x6d, 0x70, 0x61, 0x6e, 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x18,
+	0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x63, 0x6f, 0x6d, 0x70, 0x61, 0x6e, 0x79, 0x4e, 0x61,
+	0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x6d, 0x6f, 0x6e, 0x67, 0x6f, 0x55, 0x69, 0x64, 0x18, 0x03,
+	0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6d, 0x6f, 0x6e, 0x67, 0x6f, 0x55, 0x69, 0x64, 0x22, 0x62,
+	0x0a, 0x10, 0x4e, 0x65, 0x77, 0x4d, 0x73, 0x67, 0x45, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x52, 0x65,
+	0x73, 0x70, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,
+	0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x1b, 0x0a, 0x09, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x5f,
+	0x6d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x65, 0x72, 0x72, 0x6f, 0x72,
+	0x4d, 0x73, 0x67, 0x12, 0x1d, 0x0a, 0x0a, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x5f, 0x63, 0x6f, 0x64,
+	0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f,
+	0x64, 0x65, 0x32, 0xaf, 0x06, 0x0a, 0x07, 0x4d, 0x65, 0x64, 0x69, 0x63, 0x61, 0x6c, 0x12, 0x42,
+	0x0a, 0x0b, 0x49, 0x6e, 0x73, 0x74, 0x69, 0x74, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1d, 0x2e,
+	0x6d, 0x65, 0x64, 0x69, 0x63, 0x61, 0x6c, 0x2e, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x49, 0x6e,
+	0x73, 0x74, 0x69, 0x74, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x1a, 0x14, 0x2e, 0x6d,
+	0x65, 0x64, 0x69, 0x63, 0x61, 0x6c, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x61, 0x6e, 0x79, 0x52, 0x65,
+	0x73, 0x70, 0x12, 0x37, 0x0a, 0x0d, 0x47, 0x65, 0x74, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x49,
+	0x74, 0x65, 0x6d, 0x12, 0x0d, 0x2e, 0x6d, 0x65, 0x64, 0x69, 0x63, 0x61, 0x6c, 0x2e, 0x5a, 0x65,
+	0x72, 0x6f, 0x1a, 0x17, 0x2e, 0x6d, 0x65, 0x64, 0x69, 0x63, 0x61, 0x6c, 0x2e, 0x46, 0x69, 0x6c,
+	0x74, 0x65, 0x72, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x12, 0x42, 0x0a, 0x0b, 0x44,
+	0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x6f, 0x72, 0x12, 0x1d, 0x2e, 0x6d, 0x65, 0x64,
+	0x69, 0x63, 0x61, 0x6c, 0x2e, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x44, 0x69, 0x73, 0x74, 0x72,
+	0x69, 0x62, 0x75, 0x74, 0x6f, 0x72, 0x52, 0x65, 0x71, 0x1a, 0x14, 0x2e, 0x6d, 0x65, 0x64, 0x69,
+	0x63, 0x61, 0x6c, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x61, 0x6e, 0x79, 0x52, 0x65, 0x73, 0x70, 0x12,
+	0x3a, 0x0a, 0x10, 0x75, 0x73, 0x65, 0x72, 0x41, 0x75, 0x74, 0x68, 0x49, 0x6e, 0x66, 0x6f, 0x53,
+	0x61, 0x76, 0x65, 0x12, 0x11, 0x2e, 0x6d, 0x65, 0x64, 0x69, 0x63, 0x61, 0x6c, 0x2e, 0x55, 0x73,
+	0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x1a, 0x13, 0x2e, 0x6d, 0x65, 0x64, 0x69, 0x63, 0x61, 0x6c,
+	0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x12, 0x39, 0x0a, 0x0c, 0x75,
+	0x73, 0x65, 0x72, 0x41, 0x75, 0x74, 0x68, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x12, 0x2e, 0x6d, 0x65,
+	0x64, 0x69, 0x63, 0x61, 0x6c, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x1a,
+	0x15, 0x2e, 0x6d, 0x65, 0x64, 0x69, 0x63, 0x61, 0x6c, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x49, 0x6e,
+	0x66, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x12, 0x37, 0x0a, 0x08, 0x50, 0x6f, 0x72, 0x74, 0x72, 0x61,
+	0x69, 0x74, 0x12, 0x14, 0x2e, 0x6d, 0x65, 0x64, 0x69, 0x63, 0x61, 0x6c, 0x2e, 0x50, 0x6f, 0x72,
+	0x74, 0x72, 0x61, 0x69, 0x74, 0x52, 0x65, 0x71, 0x1a, 0x15, 0x2e, 0x6d, 0x65, 0x64, 0x69, 0x63,
+	0x61, 0x6c, 0x2e, 0x50, 0x6f, 0x72, 0x74, 0x72, 0x61, 0x69, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12,
+	0x2e, 0x0a, 0x05, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x12, 0x11, 0x2e, 0x6d, 0x65, 0x64, 0x69, 0x63,
+	0x61, 0x6c, 0x2e, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x52, 0x65, 0x71, 0x1a, 0x12, 0x2e, 0x6d, 0x65,
+	0x64, 0x69, 0x63, 0x61, 0x6c, 0x2e, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x12,
+	0x32, 0x0a, 0x09, 0x55, 0x6e, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x65, 0x64, 0x12, 0x11, 0x2e, 0x6d,
+	0x65, 0x64, 0x69, 0x63, 0x61, 0x6c, 0x2e, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x52, 0x65, 0x71, 0x1a,
+	0x12, 0x2e, 0x6d, 0x65, 0x64, 0x69, 0x63, 0x61, 0x6c, 0x2e, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x52,
+	0x65, 0x73, 0x70, 0x12, 0x3a, 0x0a, 0x09, 0x49, 0x73, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x65, 0x64,
+	0x12, 0x15, 0x2e, 0x6d, 0x65, 0x64, 0x69, 0x63, 0x61, 0x6c, 0x2e, 0x49, 0x73, 0x43, 0x6c, 0x61,
+	0x69, 0x6d, 0x65, 0x64, 0x52, 0x65, 0x71, 0x1a, 0x16, 0x2e, 0x6d, 0x65, 0x64, 0x69, 0x63, 0x61,
+	0x6c, 0x2e, 0x49, 0x73, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x65, 0x64, 0x52, 0x65, 0x73, 0x70, 0x12,
+	0x48, 0x0a, 0x16, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x65, 0x64, 0x44, 0x69, 0x73, 0x74, 0x72, 0x69,
+	0x62, 0x75, 0x74, 0x6f, 0x72, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x13, 0x2e, 0x6d, 0x65, 0x64, 0x69,
 	0x63, 0x61, 0x6c, 0x2e, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x65, 0x64, 0x52, 0x65, 0x71, 0x1a, 0x19,
 	0x2e, 0x6d, 0x65, 0x64, 0x69, 0x63, 0x61, 0x6c, 0x2e, 0x45, 0x6e, 0x74, 0x43, 0x6c, 0x61, 0x69,
-	0x6d, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x3a, 0x0a, 0x09, 0x47, 0x65, 0x74,
-	0x4e, 0x65, 0x77, 0x4d, 0x73, 0x67, 0x12, 0x15, 0x2e, 0x6d, 0x65, 0x64, 0x69, 0x63, 0x61, 0x6c,
-	0x2e, 0x47, 0x65, 0x74, 0x4e, 0x65, 0x77, 0x4d, 0x73, 0x67, 0x52, 0x65, 0x71, 0x1a, 0x16, 0x2e,
-	0x6d, 0x65, 0x64, 0x69, 0x63, 0x61, 0x6c, 0x2e, 0x47, 0x65, 0x74, 0x4e, 0x65, 0x77, 0x4d, 0x73,
-	0x67, 0x52, 0x65, 0x73, 0x70, 0x12, 0x43, 0x0a, 0x0c, 0x4e, 0x65, 0x77, 0x4d, 0x73, 0x67, 0x45,
-	0x78, 0x70, 0x6f, 0x72, 0x74, 0x12, 0x18, 0x2e, 0x6d, 0x65, 0x64, 0x69, 0x63, 0x61, 0x6c, 0x2e,
-	0x4e, 0x65, 0x77, 0x4d, 0x73, 0x67, 0x45, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x52, 0x65, 0x71, 0x1a,
-	0x19, 0x2e, 0x6d, 0x65, 0x64, 0x69, 0x63, 0x61, 0x6c, 0x2e, 0x4e, 0x65, 0x77, 0x4d, 0x73, 0x67,
-	0x45, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x52, 0x65, 0x73, 0x70, 0x42, 0x0b, 0x5a, 0x09, 0x2e, 0x2f,
-	0x6d, 0x65, 0x64, 0x69, 0x63, 0x61, 0x6c, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
+	0x6d, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x48, 0x0a, 0x16, 0x43, 0x6c, 0x61,
+	0x69, 0x6d, 0x65, 0x64, 0x49, 0x6e, 0x73, 0x74, 0x69, 0x74, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x4c,
+	0x69, 0x73, 0x74, 0x12, 0x13, 0x2e, 0x6d, 0x65, 0x64, 0x69, 0x63, 0x61, 0x6c, 0x2e, 0x43, 0x6c,
+	0x61, 0x69, 0x6d, 0x65, 0x64, 0x52, 0x65, 0x71, 0x1a, 0x19, 0x2e, 0x6d, 0x65, 0x64, 0x69, 0x63,
+	0x61, 0x6c, 0x2e, 0x45, 0x6e, 0x74, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x4c, 0x69, 0x73, 0x74, 0x52,
+	0x65, 0x73, 0x70, 0x12, 0x3a, 0x0a, 0x09, 0x47, 0x65, 0x74, 0x4e, 0x65, 0x77, 0x4d, 0x73, 0x67,
+	0x12, 0x15, 0x2e, 0x6d, 0x65, 0x64, 0x69, 0x63, 0x61, 0x6c, 0x2e, 0x47, 0x65, 0x74, 0x4e, 0x65,
+	0x77, 0x4d, 0x73, 0x67, 0x52, 0x65, 0x71, 0x1a, 0x16, 0x2e, 0x6d, 0x65, 0x64, 0x69, 0x63, 0x61,
+	0x6c, 0x2e, 0x47, 0x65, 0x74, 0x4e, 0x65, 0x77, 0x4d, 0x73, 0x67, 0x52, 0x65, 0x73, 0x70, 0x12,
+	0x43, 0x0a, 0x0c, 0x4e, 0x65, 0x77, 0x4d, 0x73, 0x67, 0x45, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x12,
+	0x18, 0x2e, 0x6d, 0x65, 0x64, 0x69, 0x63, 0x61, 0x6c, 0x2e, 0x4e, 0x65, 0x77, 0x4d, 0x73, 0x67,
+	0x45, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x52, 0x65, 0x71, 0x1a, 0x19, 0x2e, 0x6d, 0x65, 0x64, 0x69,
+	0x63, 0x61, 0x6c, 0x2e, 0x4e, 0x65, 0x77, 0x4d, 0x73, 0x67, 0x45, 0x78, 0x70, 0x6f, 0x72, 0x74,
+	0x52, 0x65, 0x73, 0x70, 0x42, 0x0b, 0x5a, 0x09, 0x2e, 0x2f, 0x6d, 0x65, 0x64, 0x69, 0x63, 0x61,
+	0x6c, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
 }
 
 var (

+ 1 - 1
rpc/medical/medical/medical_grpc.pb.go

@@ -1,7 +1,7 @@
 // Code generated by protoc-gen-go-grpc. DO NOT EDIT.
 // versions:
 // - protoc-gen-go-grpc v1.2.0
-// - protoc             v3.15.1
+// - protoc             v3.19.4
 // source: medical.proto
 
 package medical

+ 2 - 2
service/AuthService.go

@@ -1,6 +1,7 @@
 package service
 
 import (
+	"app.yhyue.com/moapp/jybase/date"
 	"app.yhyue.com/moapp/jybase/go-xweb/log"
 	"app.yhyue.com/moapp/jybase/mysql"
 	"bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/entity"
@@ -9,7 +10,6 @@ import (
 	"context"
 	"database/sql"
 	"fmt"
-	"time"
 )
 
 type AuthService struct {
@@ -62,7 +62,7 @@ func (b AuthService) UserAuthInfoSave(in *medical.UserInfo) (bool, string) {
 			"mail":        in.Mail,
 			"ent_name":    in.EntName,
 			"user_id":     in.UserId,
-			"create_time": time.Now(),
+			"create_time": date.NowFormat(date.Date_Full_Layout),
 			"appid":       in.Appid,
 			"source":      entity.MEDICALDOMAIN,
 		}

+ 11 - 7
service/InstitutionService.go

@@ -101,7 +101,7 @@ func (b InstitutionService) Institution(in *medical.SearchInstitutionReq) (dataL
 	companyMap := make(map[string]map[string]interface{})
 	if len(*companyList) > 0 && companyList != nil {
 		//认领数据查询
-		companyIdMap := b.ClaimCompanyData(in.Appid, in.NewUserId, entity.TypeDistributor)
+		companyIdMap := b.ClaimCompanyData(in.Appid, in.NewUserId, entity.TypeInstitution)
 		for key, value := range *companyList {
 			if key > 0 {
 				companyName += `,`
@@ -260,11 +260,14 @@ func (b InstitutionService) Distributor(in *medical.SearchDistributorReq) (dataL
 }
 
 //  ClaimCompanyData 已认领企业查询处理
-// @param  appId 用户标识
-// @param  newUserId 用户标识
-// @param  claimType 数据类型
+//  @Description:
+//  @param appId 用户标识
+//  @param newUserId 用户标识
+//  @param claimType 数据类型
+//  @return map[string]map[string]interface{} 认领的企业信息
+//
 func (b InstitutionService) ClaimCompanyData(appId string, newUserId, claimType int64) map[string]map[string]interface{} {
-	claimList := b.MysqlConn.Find(entity.TableDomainEntClaim, map[string]interface{}{
+	claimList := b.BasesqlCon.Find(entity.TableDomainEntClaim, map[string]interface{}{
 		"user_id": newUserId,
 		"status":  1,
 		"type":    claimType,
@@ -283,12 +286,13 @@ func (b InstitutionService) ClaimCompanyData(appId string, newUserId, claimType
 // BusinessScopehandle 业务范围处理
 func BusinessScopehandle(BusinessScope []*medical.Business_Scope, multi_match, findfields, query_bool_must_and string, bools []string) (int, []string) {
 	boolsNum := 0
-	businessShoulds := []string{}
-	businessMust_not := []string{}
 	if len(BusinessScope) > 0 {
 		boolsNum = 1
+
 		multi_match = fmt.Sprintf(multi_match, "%s", findfields)
 		for _, v := range BusinessScope {
+			businessShoulds := []string{}
+			businessMust_not := []string{}
 			//关键词
 			for _, keyV := range v.Key {
 				businessShoulds = append(businessShoulds, fmt.Sprintf(multi_match, "\""+keyV+"\""))

+ 31 - 8
service/InstitutionService_test.go

@@ -129,11 +129,14 @@ func TestInstitutionService_Institution(t *testing.T) {
 					LevelCode:   "0104,0201,0202",
 					MiTypeCode:  "17,03",
 					SdequipmentCode: []*medical.Business_Scope{
-						{Key: []string{"装置", "电动"},
+						{Key: []string{"装置"},
 							Appendkey: []string{},
 							Notkey:    []string{"1", "2"}},
 					},
-					BusinessTypeCode: "0",
+					BusinessTypeCode: "1",
+					NewUserId:        68819,
+					ResourceUseCount: int64(100),
+					Appid:            "10000",
 				}},
 		},
 	}
@@ -161,16 +164,20 @@ func TestInstitutionService_Distributor(t *testing.T) {
 			args: args{
 				&medical.SearchDistributorReq{
 					CompanyName: "公司",
-					AreaCode:    "{'gaung':['郑州市','开封市'],'北京':[]}",
+					AreaCode:    "{'河南':['郑州市','开封市'],'北京':[]}",
 					BusinessScope: []*medical.Business_Scope{
-						{Key: []string{"降钙素原", "细胞保存液"},
+						{Key: []string{"定制式义齿"},
 							Appendkey: []string{},
 							Notkey:    []string{"1", "2"}},
+						{Key: []string{"细胞保存液"},
+							Appendkey: []string{"释放剂"},
+							Notkey:    []string{"1", "2"}},
 					},
-					Brand:        "",
-					ProductModel: "",
-					Appid:        "10000",
-					NewUserId:    68819,
+					Brand:            "",
+					ProductModel:     "",
+					Appid:            "10000",
+					NewUserId:        68819,
+					ResourceUseCount: int64(100),
 				}},
 		},
 	}
@@ -224,6 +231,22 @@ func TestClaimCompanyData(t *testing.T) {
 		want map[string]map[string]interface{}
 	}{
 		// TODO: Add test cases.
+		{
+			name: "认领医疗机构查询",
+			args: args{
+				appId:     "10000",
+				newUserId: int64(68819),
+				claimType: entity.TypeInstitution,
+			},
+		},
+		{
+			name: "认领经销商查询",
+			args: args{
+				appId:     "10000",
+				newUserId: int64(68819),
+				claimType: entity.TypeInstitution,
+			},
+		},
 	}
 	for _, tt := range tests {
 		t.Run(tt.name, func(t *testing.T) {

+ 3 - 30
service/claim.go

@@ -29,33 +29,7 @@ func (e *EntClaimService) Claim(data *entity.EntClaim) (int64, error) {
 	return e.BaseMysql.Insert(entity.TableDomainEntClaim, common.StructToMapMore(data)), nil
 }
 
-// Unclaimed // 取消认领
-func (e *EntClaimService) Unclaimed(id, userId int) bool {
-
-	query := map[string]interface{}{
-		"id": id,
-	}
-	// 1. 查询该条数据
-	rs := e.BaseMysql.FindOne(entity.TableDomainEntClaim, query, "user_id,status", "")
-	if rs == nil || len(*rs) == 0 || common.IntAll((*rs)["status"]) != entity.StatusClaimed {
-
-		logx.Errorf("取消认领:无效的id %v", id)
-		return false
-	}
-	// 2. 存在则判断是否是该用户的
-	rsUerId := common.IntAll((*rs)["user_id"])
-	if rsUerId != userId {
-		logx.Errorf("取消认领:id[%v]与用户id[%v]不匹配 ", id, userId)
-		return false
-	}
-	// 3. 取消认领
-	update := map[string]interface{}{
-		"status":      entity.StatusUnClaimed,
-		"update_time": date.NowFormat(date.Date_Full_Layout),
-	}
-	return e.BaseMysql.Update(entity.TableDomainEntClaim, query, update)
-}
-
+// UnclaimedByEnt 根据企业id取消认领
 func (e EntClaimService) UnclaimedByEnt(userId int, entId string, type_ int) (bool, int) {
 
 	query := map[string]interface{}{
@@ -67,7 +41,6 @@ func (e EntClaimService) UnclaimedByEnt(userId int, entId string, type_ int) (bo
 	// 1. 查询该条数据
 	rs := e.BaseMysql.FindOne(entity.TableDomainEntClaim, query, "id", "")
 	if rs == nil || len(*rs) == 0 {
-
 		logx.Errorf("取消认领:无效的企业id %v", entId)
 		return false, 0
 	}
@@ -85,6 +58,7 @@ func (e EntClaimService) UnclaimedByEnt(userId int, entId string, type_ int) (bo
 // IsClaimed 是否认领
 func (e *EntClaimService) IsClaimed(userId int, appId string, entId string, typeCode int) bool {
 	query := map[string]interface{}{
+		"appId":   appId,
 		"user_id": userId,
 		"type":    typeCode,
 		"ent_id":  entId,
@@ -137,13 +111,12 @@ func (e EntClaimService) GetInstitution(id string) *map[string]interface{} {
 	return e.GlobalCommonData.FindOne(entity.TableCompanyBasInfo, query, field, "")
 }
 
-// GetInstitutionByIds GetInstitution 获取机构信息
+// GetInstitutionByIds GetInstitution 批量获取机构详细信息
 func (e EntClaimService) GetInstitutionByIds(ids []string) *[]map[string]interface{} {
 	if len(ids) == 0 {
 		return &[]map[string]interface{}{}
 	}
 	q := "select a.company_id,a.company_name,a.establish_date,a.company_address,a.capital,a.company_phone,b.area,b.city from %v a left join %v b on a.area_code=b.code  where a.company_id in (\"%v\")  "
 	query := fmt.Sprintf(q, entity.TableCompanyBasInfo, entity.TableCodeArea, strings.Join(ids, "\" , \""))
-
 	return e.GlobalCommonData.SelectBySql(query)
 }

+ 153 - 45
service/claim_test.go

@@ -4,7 +4,9 @@ import (
 	"app.yhyue.com/moapp/jybase/encrypt"
 	"bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/entity"
 	"fmt"
+	"os"
 	"testing"
+	"time"
 )
 
 // 认领
@@ -14,23 +16,38 @@ func TestEntClaimService_Claim(t *testing.T) {
 		data *entity.EntClaim
 	}
 	tests := []struct {
-		name string
-		args args
+		name    string
+		args    args
+		want    bool // 返回id是否大于0
+		wantErr bool
 	}{
-		{"认领医疗机构", args{
-			data: &entity.EntClaim{UserId: 1, AppId: "10000", EntId: "1122", EntName: "877", Status: entity.StatusClaimed, Type: entity.TypeInstitution, CreateTime: "2022-08-19 15:08:00"},
+		{"认领医疗机构-新增 ", args{
+			data: &entity.EntClaim{UserId: -1, AppId: "10000", EntId: "d8f48ada3c357d0812df188cc14ed527", EntName: "邢台太行医用材料有限公司", Status: entity.StatusClaimed, Type: entity.TypeInstitution, CreateTime: time.Now().Format("2006-01-02 15:04:05")},
+		}, true, false,
 		},
+		{"认领医疗机构-重复认领", args{
+			data: &entity.EntClaim{UserId: -1, AppId: "10000", EntId: "d8f48ada3c357d0812df188cc14ed527", EntName: "邢台太行医用材料有限公司", Status: entity.StatusClaimed, Type: entity.TypeInstitution, CreateTime: time.Now().Format("2006-01-02 15:04:05")},
+		}, false, true,
 		},
-		{"认领医疗机构-2", args{
-			data: &entity.EntClaim{UserId: 2, AppId: "10000", EntId: "7", EntName: "8757", Status: entity.StatusClaimed, Type: entity.TypeDistributor, CreateTime: "2022-08-19 15:08:00"},
+		{"认领经销商-新增 ", args{
+			data: &entity.EntClaim{UserId: -1, AppId: "10000", EntId: "d8f48ada3c357d0812df188cc14ed527", EntName: "邢台太行医用材料有限公司", Status: entity.StatusClaimed, Type: entity.TypeDistributor, CreateTime: time.Now().Format("2006-01-02 15:04:05")},
+		}, true, false,
 		},
+		{"认领经销商-重复认领", args{
+			data: &entity.EntClaim{UserId: -1, AppId: "10000", EntId: "d8f48ada3c357d0812df188cc14ed527", EntName: "邢台太行医用材料有限公司", Status: entity.StatusClaimed, Type: entity.TypeDistributor, CreateTime: time.Now().Format("2006-01-02 15:04:05")},
+		}, false, true,
 		},
 	}
 	for _, tt := range tests {
 		t.Run(tt.name, func(t *testing.T) {
-
 			got, err := EntClaimSrv.Claim(tt.args.data)
-			t.Log(got, err)
+			if (got > 0) != tt.want {
+				t.Errorf("Claim() got = %v, want %v", got > 0, tt.want)
+			}
+			if (err != nil) != tt.wantErr {
+				t.Errorf("Claim() error = %v, wantErr %v", err, tt.wantErr)
+				return
+			}
 		})
 	}
 
@@ -45,22 +62,27 @@ func TestEntClaimService_DistributorList(t *testing.T) {
 		pageSize int
 	}
 	tests := []struct {
-		name string
-		args args
-		want *[]map[string]interface{}
+		name         string
+		args         args
+		wantIsNil    bool
+		wantTotalGt0 bool
 	}{
 		{
-			name: "我认领的经销商", args: args{userId: 1, appId: "10000", page: 0, pageSize: 10}, want: nil,
+			name: "我认领的经销商", args: args{userId: -1, appId: "10000", page: 0, pageSize: 10}, wantIsNil: false, wantTotalGt0: true,
 		},
 		{
-			name: "我认领的经销商-2", args: args{userId: 8, appId: "10000", page: 0, pageSize: 10}, want: nil,
+			name: "我认领的经销商-空列表", args: args{userId: -2, appId: "10000", page: 0, pageSize: 10}, wantIsNil: true, wantTotalGt0: false,
 		},
 	}
 	for _, tt := range tests {
 		t.Run(tt.name, func(t *testing.T) {
 			got, total := EntClaimSrv.DistributorList(tt.args.userId, tt.args.appId, tt.args.page, tt.args.pageSize)
-			fmt.Println(got, total)
-			t.Log(got, total)
+			if (got == nil) != tt.wantIsNil {
+				t.Errorf("DistributorList() got = %v, want %v", got == nil, tt.wantIsNil)
+			}
+			if (total > 0) != tt.wantTotalGt0 {
+				t.Errorf("DistributorList() total = %v, want %v", total > 0, tt.wantTotalGt0)
+			}
 		})
 	}
 }
@@ -74,21 +96,27 @@ func TestEntClaimService_InstitutionList(t *testing.T) {
 		pageSize int
 	}
 	tests := []struct {
-		name string
-		args args
-		want *[]map[string]interface{}
+		name         string
+		args         args
+		wantIsNil    bool
+		wantTotalGt0 bool
 	}{
 		{
-			name: "我认领的医疗机构", args: args{userId: 22, appId: "10000", page: 0, pageSize: 10}, want: nil,
+			name: "我认领的医疗机构", args: args{userId: -1, appId: "10000", page: 0, pageSize: 10}, wantIsNil: false, wantTotalGt0: true,
 		},
 		{
-			name: "我认领的医疗机构-2", args: args{userId: 3, appId: "10000", page: 0, pageSize: 10}, want: nil,
+			name: "我认领的医疗机构-空列表", args: args{userId: -2, appId: "10000", page: 0, pageSize: 10}, wantIsNil: true, wantTotalGt0: false,
 		},
 	}
 	for _, tt := range tests {
 		t.Run(tt.name, func(t *testing.T) {
 			got, total := EntClaimSrv.InstitutionList(tt.args.userId, tt.args.appId, tt.args.page, tt.args.pageSize)
-			t.Log(got, total)
+			if (got == nil) != tt.wantIsNil {
+				t.Errorf("InstitutionList() got = %v, want %v", got == nil, tt.wantIsNil)
+			}
+			if (total > 0) != tt.wantTotalGt0 {
+				t.Errorf("InstitutionList() total = %v, want %v", total > 0, tt.wantTotalGt0)
+			}
 		})
 	}
 }
@@ -106,7 +134,8 @@ func TestEntClaimService_IsClaimed(t *testing.T) {
 		args args
 		want bool
 	}{
-		{"是否认领", args{userId: 1, typeCode: 1, entId: "1", appId: "10000"}, true},
+		{"是否认领", args{userId: -1, typeCode: 1, entId: "b4eb554e9e7368c17761d4f722e7cf5e", appId: "10000"}, true},
+		{"是否认领", args{userId: -1, typeCode: 1, entId: "9999", appId: "10000"}, false},
 	}
 	for _, tt := range tests {
 		t.Run(tt.name, func(t *testing.T) {
@@ -123,73 +152,152 @@ func TestEntClaimService_GetInstitution(t *testing.T) {
 		id string
 	}
 	tests := []struct {
-		name string
-		args args
-		want *map[string]interface{}
+		name    string
+		args    args
+		wantNil bool
 	}{
 		{
-			"获取企业基本信息", args{id: ""}, nil,
+			"获取企业基本信息", args{id: "b4eb554e9e7368c17761d4f722e7cf5e"}, false,
+		},
+		{
+			"获取企业基本信息_2", args{id: "888"}, true,
 		},
 	}
 	for _, tt := range tests {
 		t.Run(tt.name, func(t *testing.T) {
 			got := EntClaimSrv.GetInstitution(tt.args.id)
-			t.Log(got)
-
+			if (got == nil) != tt.wantNil {
+				t.Errorf("GetInstitution() got = %v, want %v", got == nil, tt.wantNil)
+			}
 		})
 	}
 }
+
 func TestName(t *testing.T) {
-	s := encrypt.SE.DecodeString("QgpHCARNUAdXBRVXSF9URFMIAwIRVxIPVExUVlMEQV0=")
-	s1 := encrypt.SE.EncodeString("90058")
-	fmt.Println(s)
-	fmt.Println(s1)
+	// s := encrypt.SE.DecodeString("ABCYHFBdi44OyksAl5mZHUwPiQCSTJgcXR+KygZIC8eZGhkTyw9NBkSM3dhXnEGKFxTDMY=")
+	// s1 := encrypt.SE.EncodeString("90058")
+	QWEQWE := "ABCd3ZrfT04JyY6GXxhcFwsCCc4QTBjdndgPCgFLCEwdGpzB1oiNwksNGNxXnAADlxTDQA="
+	fmt.Println(encrypt.DecodeArticleId2ByCheck(QWEQWE))
+	// fmt.Println(s)
+	// fmt.Println(s1)
 }
 
+// 获取企业的详细信息
 func TestEntClaimService_GetInstitutionByIds(t *testing.T) {
-
 	type args struct {
 		ids []string
 	}
 	tests := []struct {
-		name string
-		args args
+		name    string
+		args    args
+		wantNil bool
 	}{
 		{
-			"获取企业基本信息", args{ids: []string{"6e7fa9b7f0a88110a827e8ba18ffb152"}},
+			"获取企业基本信息根据id批量", args{ids: []string{"6e7fa9b7f0a88110a827e8ba18ffb152", "9205b21e2142e19b1cd200688225fa5a", "eefad51cf48aa3e27c72c41d0ebe8f08"}}, false,
+		},
+		{
+			"获取企业基本信息根据id批量-2", args{ids: []string{"6e7fa9b7f0a88110a827e8ba18ffb152", "eefad51cf48aa3e27c72c41d0ebe8f08"}}, false,
+		},
+		{
+			"获取企业基本信息根据id批量-空id列表", args{ids: []string{}}, true,
 		},
 	}
 	for _, tt := range tests {
 		t.Run(tt.name, func(t *testing.T) {
 			got := EntClaimSrv.GetInstitutionByIds(tt.args.ids)
 			t.Log(got)
+			if (got == nil || len(*got) == 0) != tt.wantNil {
+				t.Errorf("InstitutionList() got = %v, want %v,%v", got == nil, tt.wantNil, got)
+			}
 		})
 	}
 }
 
+// 根据企业取消认领
 func TestEntClaimService_UnclaimedByEnt(t *testing.T) {
-
 	type args struct {
 		userId int
 		entId  string
 		type_  int
 	}
 	tests := []struct {
-		name  string
-		args  args
-		want  bool
-		want1 int
-	}{}
+		name      string
+		args      args
+		want      bool
+		wantIDGt0 bool
+	}{
+		{"根据企业id取消认领-机构", args{userId: -1, entId: "b4eb554e9e7368c17761d4f722e7cf5e", type_: entity.TypeInstitution}, true, true},
+		{"根据企业id取消认领-机构-无效的企业id", args{userId: -1, entId: "aaa", type_: entity.TypeInstitution}, false, false},
+		{"根据企业id取消认领-经销商", args{userId: -1, entId: "b4eb554e9e7368c17761d4f722e7cf5e", type_: entity.TypeDistributor}, true, true},
+		{"根据企业id取消认领-经销商-无效的经销商", args{userId: -1, entId: "aaa", type_: entity.TypeDistributor}, false, false},
+	}
 	for _, tt := range tests {
 		t.Run(tt.name, func(t *testing.T) {
-
 			got, got1 := EntClaimSrv.UnclaimedByEnt(tt.args.userId, tt.args.entId, tt.args.type_)
 			if got != tt.want {
 				t.Errorf("UnclaimedByEnt() got = %v, want %v", got, tt.want)
 			}
-			if got1 != tt.want1 {
-				t.Errorf("UnclaimedByEnt() got1 = %v, want %v", got1, tt.want1)
+			if (got1 > 0) != tt.wantIDGt0 {
+				t.Errorf("UnclaimedByEnt() got1 = %v, want %v", got1 > 0, tt.wantIDGt0)
 			}
 		})
 	}
 }
+
+// 数据准备
+func setupClaim() {
+	fmt.Println("setup ...")
+	// 删除测试用例产生的数据
+	EntClaimSrv.BaseMysql.Delete(entity.TableDomainEntClaim, map[string]interface{}{
+		"user_id": "-1",
+	})
+	fmt.Println("clean over...")
+	// 制造数据
+	field := []string{
+		"appid", "user_id", "ent_id", "ent_name", "status", "type", "create_time",
+	}
+	values := []interface{}{
+		"10000", -1, "b4eb554e9e7368c17761d4f722e7cf5e", "深圳市南科征途有限公司", entity.StatusClaimed, entity.TypeInstitution, time.Now().Format("2006-01-02 15:04:05"),
+		"10000", -1, "1e1b0912a9a76c432278195f4dc31f9c", "常州美杰医疗用品有限公司", entity.StatusClaimed, entity.TypeInstitution, time.Now().Format("2006-01-02 15:04:05"),
+		"10000", -1, "78b9349b7e44267d1f636ad8eeb1d58a", "深圳联开生物医疗科技有限公司", entity.StatusClaimed, entity.TypeInstitution, time.Now().Format("2006-01-02 15:04:05"),
+		"10000", -1, "9205b21e2142e19b1cd200688225fa5a", "湖北温氏中医药科技有限公司", entity.StatusClaimed, entity.TypeInstitution, time.Now().Format("2006-01-02 15:04:05"),
+		"10000", -1, "f07dd989c6a04bac2646c88a3e921e1d", "武汉协卓卫生用品有限公司", entity.StatusClaimed, entity.TypeInstitution, time.Now().Format("2006-01-02 15:04:05"),
+		"10000", -1, "8ee6d4de90526ac7f6407c1fef21d44b", "烟台开发区宝威生物技术有限公司", entity.StatusClaimed, entity.TypeInstitution, time.Now().Format("2006-01-02 15:04:05"),
+		"10000", -1, "b93a9f0faf1481049fd36e3eb484d052", "黄骅市德坤生物科技有限公司", entity.StatusClaimed, entity.TypeInstitution, time.Now().Format("2006-01-02 15:04:05"),
+		"10000", -1, "eefad51cf48aa3e27c72c41d0ebe8f08", "武汉市江汉医疗制药设备有限公司", entity.StatusClaimed, entity.TypeInstitution, time.Now().Format("2006-01-02 15:04:05"),
+		"10000", -1, "be23b68d98c14847d341f84f6c5da4f3", "洪泽县晨光医疗器械有限公司", entity.StatusClaimed, entity.TypeInstitution, time.Now().Format("2006-01-02 15:04:05"),
+		"10000", -1, "b4eb554e9e7368c17761d4f722e7cf5e", "深圳市华晨阳科技有限公司", entity.StatusClaimed, entity.TypeInstitution, time.Now().Format("2006-01-02 15:04:05"),
+		"10000", -1, "b4eb554e9e7368c17761d4f722e7cf5e", "深圳市南科征途有限公司", entity.StatusClaimed, entity.TypeDistributor, time.Now().Format("2006-01-02 15:04:05"),
+		"10000", -1, "1e1b0912a9a76c432278195f4dc31f9c", "常州美杰医疗用品有限公司", entity.StatusClaimed, entity.TypeDistributor, time.Now().Format("2006-01-02 15:04:05"),
+		"10000", -1, "78b9349b7e44267d1f636ad8eeb1d58a", "深圳联开生物医疗科技有限公司", entity.StatusClaimed, entity.TypeDistributor, time.Now().Format("2006-01-02 15:04:05"),
+		"10000", -1, "9205b21e2142e19b1cd200688225fa5a", "湖北温氏中医药科技有限公司", entity.StatusClaimed, entity.TypeDistributor, time.Now().Format("2006-01-02 15:04:05"),
+		"10000", -1, "f07dd989c6a04bac2646c88a3e921e1d", "武汉协卓卫生用品有限公司", entity.StatusClaimed, entity.TypeDistributor, time.Now().Format("2006-01-02 15:04:05"),
+		"10000", -1, "8ee6d4de90526ac7f6407c1fef21d44b", "烟台开发区宝威生物技术有限公司", entity.StatusClaimed, entity.TypeDistributor, time.Now().Format("2006-01-02 15:04:05"),
+		"10000", -1, "b93a9f0faf1481049fd36e3eb484d052", "黄骅市德坤生物科技有限公司", entity.StatusClaimed, entity.TypeDistributor, time.Now().Format("2006-01-02 15:04:05"),
+		"10000", -1, "eefad51cf48aa3e27c72c41d0ebe8f08", "武汉市江汉医疗制药设备有限公司", entity.StatusClaimed, entity.TypeDistributor, time.Now().Format("2006-01-02 15:04:05"),
+		"10000", -1, "be23b68d98c14847d341f84f6c5da4f3", "洪泽县晨光医疗器械有限公司", entity.StatusClaimed, entity.TypeDistributor, time.Now().Format("2006-01-02 15:04:05"),
+		"10000", -1, "b4eb554e9e7368c17761d4f722e7cf5e", "深圳市华晨阳科技有限公司", entity.StatusClaimed, entity.TypeDistributor, time.Now().Format("2006-01-02 15:04:05"),
+	}
+	EntClaimSrv.BaseMysql.InsertBatch(entity.TableDomainEntClaim, field, values)
+	fmt.Println("setup ok...")
+}
+
+// 清理产生的测试数据
+func teardownClaim() {
+	fmt.Println("teardown...")
+	// 删除测试用例产生的数据
+	EntClaimSrv.BaseMysql.Delete(entity.TableDomainEntClaim, map[string]interface{}{
+		"user_id": "-1",
+	})
+	fmt.Println("teardown  ok...")
+}
+
+// 通过testMain 来执行测试用例  可以做全局的准备和清理工作
+func TestMain(m *testing.M) {
+	// setup code...
+	setupClaim()
+	fmt.Println("start init")
+	code := m.Run()
+	teardownClaim()
+	os.Exit(code)
+}

+ 7 - 4
test/api_test.http

@@ -2,11 +2,12 @@
 POST http://{{host}}/domain/institution/claim
 Content-Type: application/json
 Cookie: SESSIONID=8699c0583e3caa719ac2da5a85c560852ff7da33
-newUserId:72896
+newUserId:2022
 appId:10000
 
 {
-"ent_id": "F1tGCFAQAQIFDEMKRA8ETQAJCVESWRJYBxdXVVcEEV0"
+"ent_id": "ABCYHFBdi44OyksAl5mZHUwPiQCSTJgcXR+KygZIC8eZGhkTyw9NBkSM3dhXnEGKFxTDMY=",
+  "ent_name": "付文彩测试企业"
 }
 
 > {%
@@ -22,7 +23,9 @@ newUserId:2022
 appId:10000
 
 {
-  "ent_id": "EV4WD1AVBANQUxVcQ1lWEVYFAA1GXEBZXRFRUQJTQF4="
+  "ent_id": "EV4WD1AVBANQUxVcQ1lWEVYFAA1GXEBZXRFRUQJTQF4=",
+  "ent_name": "付文彩测试企业"
+
 }
 > {%
 client.test("Request executed successfully", function() {
@@ -37,7 +40,7 @@ newUserId:2022
 appId:10000
 
 {
-  "ent_id":"F1tGCFAQAQIFDEMKRA8ETQAJCVESWRJYBxdXVVcEEV0="
+  "ent_id":"ABCYHFBdi44OyksAl5mZHUwPiQCSTJgcXR+KygZIC8eZGhkTyw9NBkSM3dhXnEGKFxTDMY="
 }
 > {%
 client.test("Request executed successfully", function() {