WH01243 3 years ago
parent
commit
0901cbbb29
45 changed files with 2519 additions and 351 deletions
  1. 8 1
      README.md
  2. 1 0
      api/medical/etc/medical-api.yaml
  3. 28 0
      api/medical/internal/handler/institution/getnewmsglisthandler.go
  4. 10 5
      api/medical/internal/handler/routes.go
  5. 19 2
      api/medical/internal/logic/distributor/claimdistributorlogic.go
  6. 21 5
      api/medical/internal/logic/institution/claiminstitutionlogic.go
  7. 47 0
      api/medical/internal/logic/institution/getnewmsglistlogic.go
  8. 32 1
      api/medical/internal/logic/institution/portraitinstitutionlogic.go
  9. 14 2
      api/medical/internal/logic/public/claimlogic.go
  10. 16 2
      api/medical/internal/logic/public/isclaimedlogic.go
  11. 12 2
      api/medical/internal/logic/public/unclaimedlogic.go
  12. 28 18
      api/medical/internal/types/types.go
  13. 34 20
      api/medical/medical.api
  14. 2 2
      entity/code.go
  15. 1 0
      entity/coverage
  16. 7 4
      entity/db.go
  17. 9 13
      entity/model.go
  18. 51 0
      entity/portrait.go
  19. 1 0
      go.sum
  20. 11 2
      rpc/medical/etc/medical.yaml
  21. 15 5
      rpc/medical/init/init.go
  22. 4 3
      rpc/medical/internal/config/config.go
  23. 52 26
      rpc/medical/internal/logic/claimeddistributorlistlogic.go
  24. 56 3
      rpc/medical/internal/logic/claimedinstitutionlistlogic.go
  25. 23 15
      rpc/medical/internal/logic/claimlogic.go
  26. 56 0
      rpc/medical/internal/logic/getnewmsglogic.go
  27. 11 5
      rpc/medical/internal/logic/isclaimedlogic.go
  28. 33 1
      rpc/medical/internal/logic/portraitlogic.go
  29. 13 4
      rpc/medical/internal/logic/unclaimedlogic.go
  30. 12 6
      rpc/medical/internal/server/medicalserver.go
  31. 1 3
      rpc/medical/internal/svc/servicecontext.go
  32. 79 14
      rpc/medical/medical.proto
  33. 14 6
      rpc/medical/medical/medical.go
  34. 736 114
      rpc/medical/medical/medical.pb.go
  35. 53 15
      rpc/medical/medical/medical_grpc.pb.go
  36. 2 2
      service/InstitutionService_test.go
  37. 25 3
      service/claim.go
  38. 62 13
      service/claim_test.go
  39. 64 0
      service/coverage
  40. 365 30
      service/coverage.html
  41. 195 0
      service/portrait.go
  42. 157 0
      service/portrait_test.go
  43. 17 1
      service/test_cover.out
  44. 81 0
      test/api_test.http
  45. 41 3
      test/rpc_test.http

+ 8 - 1
README.md

@@ -1 +1,8 @@
-# 领域化产品
+# 领域化产品
+
+
+
+
+
+## 注意事项 
+- github.com/zeromicro/go-zero  与旧版本(github.com/tal-tech/go-zero)不兼容  需使用新版goctl生成代码。

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

@@ -13,3 +13,4 @@ Gateway:
   ServerCode: medical
   ServerCode: medical
   Etcd:
   Etcd:
     - 127.0.0.1:2379
     - 127.0.0.1:2379
+Timeout:  5000

+ 28 - 0
api/medical/internal/handler/institution/getnewmsglisthandler.go

@@ -0,0 +1,28 @@
+package institution
+
+import (
+	"net/http"
+
+	"bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/api/medical/internal/logic/institution"
+	"bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/api/medical/internal/svc"
+	"bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/api/medical/internal/types"
+	"github.com/zeromicro/go-zero/rest/httpx"
+)
+
+func GetNewMsgListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
+	return func(w http.ResponseWriter, r *http.Request) {
+		var req types.GetNewMsgListReq
+		if err := httpx.Parse(r, &req); err != nil {
+			httpx.Error(w, err)
+			return
+		}
+
+		l := institution.NewGetNewMsgListLogic(r.Context(), svcCtx)
+		resp, err := l.GetNewMsgList(&req)
+		if err != nil {
+			httpx.Error(w, err)
+		} else {
+			httpx.OkJson(w, resp)
+		}
+	}
+}

+ 10 - 5
api/medical/internal/handler/routes.go

@@ -4,11 +4,11 @@ package handler
 import (
 import (
 	"net/http"
 	"net/http"
 
 
-	auth "bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/api/medical/internal/handler/auth"
-	distributor "bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/api/medical/internal/handler/distributor"
-	institution "bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/api/medical/internal/handler/institution"
-	public "bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/api/medical/internal/handler/public"
-	"bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/api/medical/internal/svc"
+	auth "medical/internal/handler/auth"
+	distributor "medical/internal/handler/distributor"
+	institution "medical/internal/handler/institution"
+	public "medical/internal/handler/public"
+	"medical/internal/svc"
 
 
 	"github.com/zeromicro/go-zero/rest"
 	"github.com/zeromicro/go-zero/rest"
 )
 )
@@ -36,6 +36,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
 				Path:    "/claim/institution",
 				Path:    "/claim/institution",
 				Handler: institution.ClaimInstitutionHandler(serverCtx),
 				Handler: institution.ClaimInstitutionHandler(serverCtx),
 			},
 			},
+			{
+				Method:  http.MethodPost,
+				Path:    "/portrait/getNewMsgList",
+				Handler: institution.GetNewMsgListHandler(serverCtx),
+			},
 		},
 		},
 		rest.WithPrefix("/domain"),
 		rest.WithPrefix("/domain"),
 	)
 	)

+ 19 - 2
api/medical/internal/logic/distributor/claimdistributorlogic.go

@@ -1,6 +1,7 @@
 package distributor
 package distributor
 
 
 import (
 import (
+	"bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/rpc/medical/medical"
 	"context"
 	"context"
 
 
 	"bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/api/medical/internal/svc"
 	"bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/api/medical/internal/svc"
@@ -23,8 +24,24 @@ func NewClaimDistributorLogic(ctx context.Context, svcCtx *svc.ServiceContext) *
 	}
 	}
 }
 }
 
 
+// ClaimDistributor 我认领的经销商列表
 func (l *ClaimDistributorLogic) ClaimDistributor(req *types.ClaimDistributorReq) (resp *types.CommonRes, err error) {
 func (l *ClaimDistributorLogic) ClaimDistributor(req *types.ClaimDistributorReq) (resp *types.CommonRes, err error) {
-	// todo: add your logic here and delete this line
+	rs, _ := l.svcCtx.Medical.ClaimedDistributorList(l.ctx, &medical.ClaimedReq{
+		AppId:    req.AppId,
+		UserId:   int64(req.UserId),
+		Page:     int64(req.Page),
+		PageSize: int64(req.PageSize),
+	})
+	var result interface{}
+	result = map[string]interface{}{
+		"list":  rs.Data.List,
+		"total": rs.Data.Total,
+	}
+
+	return &types.CommonRes{
+		Error_msg:  rs.ErrorMsg,
+		Error_code: int(rs.ErrorCode),
+		Data:       result,
+	}, nil
 
 
-	return
 }
 }

+ 21 - 5
api/medical/internal/logic/institution/claiminstitutionlogic.go

@@ -1,11 +1,10 @@
 package institution
 package institution
 
 
 import (
 import (
-	"context"
-
 	"bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/api/medical/internal/svc"
 	"bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/api/medical/internal/svc"
 	"bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/api/medical/internal/types"
 	"bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/api/medical/internal/types"
-
+	"bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/rpc/medical/medical"
+	"context"
 	"github.com/zeromicro/go-zero/core/logx"
 	"github.com/zeromicro/go-zero/core/logx"
 )
 )
 
 
@@ -23,8 +22,25 @@ func NewClaimInstitutionLogic(ctx context.Context, svcCtx *svc.ServiceContext) *
 	}
 	}
 }
 }
 
 
+// ClaimInstitution 我认领的医疗机构列表
 func (l *ClaimInstitutionLogic) ClaimInstitution(req *types.ClaimInstitutionReq) (resp *types.CommonRes, err error) {
 func (l *ClaimInstitutionLogic) ClaimInstitution(req *types.ClaimInstitutionReq) (resp *types.CommonRes, err error) {
-	// todo: add your logic here and delete this line
+	rs, _ := l.svcCtx.Medical.ClaimedInstitutionList(l.ctx, &medical.ClaimedReq{
+		AppId:    req.AppId,
+		UserId:   int64(req.UserId),
+		Page:     int64(req.Page),
+		PageSize: int64(req.PageSize),
+	})
+	var result interface{}
+
+	result = map[string]interface{}{
+		"list":  rs.Data.List,
+		"total": rs.Data.Total,
+	}
+
+	return &types.CommonRes{
+		Error_msg:  rs.ErrorMsg,
+		Error_code: int(rs.ErrorCode),
+		Data:       result,
+	}, nil
 
 
-	return
 }
 }

+ 47 - 0
api/medical/internal/logic/institution/getnewmsglistlogic.go

@@ -0,0 +1,47 @@
+package institution
+
+import (
+	"context"
+	"fmt"
+
+	"bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/rpc/medical/medical"
+
+	"bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/api/medical/internal/svc"
+	"bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/api/medical/internal/types"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type GetNewMsgListLogic struct {
+	logx.Logger
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+}
+
+func NewGetNewMsgListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetNewMsgListLogic {
+	return &GetNewMsgListLogic{
+		Logger: logx.WithContext(ctx),
+		ctx:    ctx,
+		svcCtx: svcCtx,
+	}
+}
+
+func (l *GetNewMsgListLogic) GetNewMsgList(req *types.GetNewMsgListReq) (resp *types.CommonRes, err error) {
+	// todo: add your logic here and delete this line
+	resp = &types.CommonRes{}
+	ret, err := l.svcCtx.Medical.GetNewMsg(l.ctx, &medical.GetNewMsgReq{
+		CompanyName: req.CompanyName,
+		PageNum:     req.PageNum,
+		PageSize:    req.PageSize,
+	})
+	if err != nil || ret == nil {
+		l.Error(fmt.Sprintf("%+v", req), resp.Error_msg)
+		resp.Error_code, resp.Error_msg = -1, "查看失败"
+	} else {
+		resp.Data = map[string]interface{}{
+			"count": ret.Count,
+			"list":  ret.List,
+		}
+	}
+	return
+}

+ 32 - 1
api/medical/internal/logic/institution/portraitinstitutionlogic.go

@@ -2,9 +2,11 @@ package institution
 
 
 import (
 import (
 	"context"
 	"context"
+	"fmt"
 
 
 	"bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/api/medical/internal/svc"
 	"bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/api/medical/internal/svc"
 	"bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/api/medical/internal/types"
 	"bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/api/medical/internal/types"
+	"bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/rpc/medical/medical"
 
 
 	"github.com/zeromicro/go-zero/core/logx"
 	"github.com/zeromicro/go-zero/core/logx"
 )
 )
@@ -23,8 +25,37 @@ func NewPortraitInstitutionLogic(ctx context.Context, svcCtx *svc.ServiceContext
 	}
 	}
 }
 }
 
 
+// 医疗机构画像-医院信息
 func (l *PortraitInstitutionLogic) PortraitInstitution(req *types.PortraitReq) (resp *types.CommonRes, err error) {
 func (l *PortraitInstitutionLogic) PortraitInstitution(req *types.PortraitReq) (resp *types.CommonRes, err error) {
 	// todo: add your logic here and delete this line
 	// todo: add your logic here and delete this line
-
+	resp = &types.CommonRes{}
+	ret, err := l.svcCtx.Medical.Portrait(l.ctx, &medical.PortraitReq{
+		AppId:     req.AppId,
+		CompanyId: req.CompanyId,
+		UserId:    int64(req.UserId),
+	})
+	if err != nil || ret == nil {
+		l.Error(fmt.Sprintf("%+v", req), resp.Error_msg)
+		resp.Error_code, resp.Error_msg = -1, "查看失败"
+	} else {
+		resp.Data = map[string]interface{}{
+			"beds":           ret.Beds,
+			"visit_perday":   ret.VisitPerday,
+			"doctorsnum":     ret.Doctorsnum,
+			"address":        ret.Address,
+			"website":        ret.Website,
+			"area":           ret.Area,
+			"city":           ret.City,
+			"district":       ret.District,
+			"business_type":  ret.BusinessType,
+			"level":          ret.Level,
+			"mi_type":        ret.MiType,
+			"equipment":      ret.Equipment,
+			"departnames":    ret.Departnames,
+			"follow":         ret.Follow,
+			"company_name":   ret.CompanyName,
+			"establish_date": ret.EstablishDate,
+		}
+	}
 	return
 	return
 }
 }

+ 14 - 2
api/medical/internal/logic/public/claimlogic.go

@@ -1,6 +1,8 @@
 package public
 package public
 
 
 import (
 import (
+	"app.yhyue.com/moapp/jybase/encrypt"
+	"bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/rpc/medical/medical"
 	"context"
 	"context"
 
 
 	"bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/api/medical/internal/svc"
 	"bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/api/medical/internal/svc"
@@ -23,8 +25,18 @@ func NewClaimLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ClaimLogic
 	}
 	}
 }
 }
 
 
+// Claim 认领
 func (l *ClaimLogic) Claim(req *types.ClaimReq) (resp *types.CommonRes, err error) {
 func (l *ClaimLogic) Claim(req *types.ClaimReq) (resp *types.CommonRes, err error) {
-	// todo: add your logic here and delete this line
 
 
-	return
+	rs, _ := l.svcCtx.Medical.Claim(l.ctx, &medical.ClaimReq{
+		UserId: int64(req.UserId),
+		EntId:  encrypt.SE.Decode4Hex(req.EntId),
+		Type:   int64(req.Type),
+		AppId:  req.AppId,
+	})
+
+	return &types.CommonRes{
+		Error_msg:  rs.ErrorMsg,
+		Error_code: int(rs.ErrorCode),
+	}, nil
 }
 }

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

@@ -1,6 +1,8 @@
 package public
 package public
 
 
 import (
 import (
+	"app.yhyue.com/moapp/jybase/encrypt"
+	"bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/rpc/medical/medical"
 	"context"
 	"context"
 
 
 	"bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/api/medical/internal/svc"
 	"bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/api/medical/internal/svc"
@@ -23,8 +25,20 @@ func NewIsClaimedLogic(ctx context.Context, svcCtx *svc.ServiceContext) *IsClaim
 	}
 	}
 }
 }
 
 
+// IsClaimed 是否认领
 func (l *IsClaimedLogic) IsClaimed(req *types.IsClaimedReq) (resp *types.CommonRes, err error) {
 func (l *IsClaimedLogic) IsClaimed(req *types.IsClaimedReq) (resp *types.CommonRes, err error) {
-	// todo: add your logic here and delete this line
 
 
-	return
+	rs, _ := l.svcCtx.Medical.IsClaimed(l.ctx, &medical.IsClaimedReq{
+		UserId: int64(req.UserId),
+		EntId:  encrypt.SE.Decode4Hex(req.CompanyId),
+		Type:   int64(req.Type),
+	})
+	return &types.CommonRes{
+		Error_msg:  rs.ErrorMsg,
+		Error_code: int(rs.ErrorCode),
+		Data: map[string]interface{}{
+			"status": rs.Data.Status,
+		},
+	}, nil
+
 }
 }

+ 12 - 2
api/medical/internal/logic/public/unclaimedlogic.go

@@ -1,6 +1,9 @@
 package public
 package public
 
 
 import (
 import (
+	"app.yhyue.com/moapp/jybase/common"
+	"app.yhyue.com/moapp/jybase/encrypt"
+	"bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/rpc/medical/medical"
 	"context"
 	"context"
 
 
 	"bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/api/medical/internal/svc"
 	"bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/api/medical/internal/svc"
@@ -23,8 +26,15 @@ func NewUnclaimedLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Unclaim
 	}
 	}
 }
 }
 
 
+// Unclaimed 取消认领
 func (l *UnclaimedLogic) Unclaimed(req *types.UnclaimedReq) (resp *types.CommonRes, err error) {
 func (l *UnclaimedLogic) Unclaimed(req *types.UnclaimedReq) (resp *types.CommonRes, err error) {
-	// todo: add your logic here and delete this line
+	rs, _ := l.svcCtx.Medical.UnClaimed(l.ctx, &medical.UnclaimedReq{
+		UserId: int64(req.UserId),
+		Id:     common.Int64All(encrypt.SE.Decode4Hex(req.Id)),
+	})
 
 
-	return
+	return &types.CommonRes{
+		Error_msg:  rs.ErrorMsg,
+		Error_code: int(rs.ErrorCode),
+	}, nil
 }
 }

+ 28 - 18
api/medical/internal/types/types.go

@@ -30,20 +30,23 @@ type SearchDistributorReq struct {
 }
 }
 
 
 type PortraitReq struct {
 type PortraitReq struct {
-	CompanyId string `json:"company_id"` // 机构唯一标识
+	CompanyId string `json:"company_id"`           // 机构唯一标识
+	UserId    int    `header:"newUserId,optional"` //session中的用户base_user_id
+	AppId     string `header:"appId,default=10000"`
 }
 }
 
 
 type ClaimInstitutionReq struct {
 type ClaimInstitutionReq struct {
-	UserId      string `header:"newUserId"`           // 用户id
-	CompanyName string `json:"company_name,optional"` // 要搜索的医疗机构
-	Page        int    `json:"page,optional"`         // 页码
-	PageSize    int    `json:"page_size,optional"`    // 每页条数
+	UserId   int    `header:"newUserId"`          // 用户id
+	Page     int    `json:"page,default=0"`       // 页码
+	PageSize int    `json:"page_size,default=10"` // 每页条数
+	AppId    string `header:"appId"`              // appid
 }
 }
 
 
 type ClaimDistributorReq struct {
 type ClaimDistributorReq struct {
-	UserId   string `header:"newUserId"`        // 用户id
-	Page     int    `json:"page,optional"`      // 页码
-	PageSize int    `json:"page_size,optional"` // 每页条数
+	UserId   int    `header:"newUserId"`          // 用户id
+	Page     int    `json:"page,default=0"`       // 页码
+	PageSize int    `json:"page_size,default=10"` // 每页条数
+	AppId    string `header:"appId"`              // appid
 }
 }
 
 
 type DistributorProductsReq struct {
 type DistributorProductsReq struct {
@@ -53,22 +56,29 @@ type DistributorProductsReq struct {
 }
 }
 
 
 type ClaimReq struct {
 type ClaimReq struct {
-	Type    int    `json:"type"`        // 1 医疗机构 2 经销商
-	EntId   string `json:"entid"`       // 企业标识
-	EntName string `json:"ent_name"`    // 企业名称
-	Address string `json:"address"`     // 所在地
-	UserId  string `header:"newUserId"` // 用户id
+	Type   int    `json:"type,options=1|2"` // 1 医疗机构 2 经销商
+	EntId  string `json:"ent_id"`           // 企业标识
+	UserId int    `header:"newUserId"`      // 用户id
+	AppId  string `header:"appId"`          // appid
 }
 }
 
 
 type UnclaimedReq struct {
 type UnclaimedReq struct {
-	UserId string `header:"newUserId"` // 用户id
-	Id     int    `json:"id"`
+	UserId int    `header:"newUserId"` // 用户id
+	Id     string `json:"id"`
 }
 }
 
 
 type IsClaimedReq struct {
 type IsClaimedReq struct {
-	UserId    string `header:"newUserId"` // 用户id
-	CompanyId string `json:"company_id"`  // 机构id
-	Type      int    `json:"type"`        // 1 医疗机构 2 经销商
+	UserId    int    `header:"newUserId"`      // 用户id
+	CompanyId string `json:"company_id"`       // 机构id
+	Type      int    `json:"type,options=1|2"` // 1 医疗机构 2 经销商
+}
+
+type GetNewMsgListReq struct {
+	CompanyName string `json:"companyName"`          // 机构唯一标识
+	UserId      int    `header:"newUserId,optional"` //session中的用户base_user_id
+	AppId       string `header:"appId,default=10000"`
+	PageSize    int64  `json:"pageSize"`
+	PageNum     int64  `json:"pageNum"`
 }
 }
 
 
 type UserInfoReq struct {
 type UserInfoReq struct {

+ 34 - 20
api/medical/medical.api

@@ -30,21 +30,26 @@ type SearchDistributorReq {
 
 
 // 获取机构信息请求
 // 获取机构信息请求
 type PortraitReq {
 type PortraitReq {
-	CompanyId string `json:"company_id"` // 机构唯一标识
+	CompanyId string `json:"company_id"`           // 机构唯一标识
+	UserId    int    `header:"newUserId,optional"` //session中的用户base_user_id
+	AppId     string `header:"appId,default=10000"`
 }
 }
 // 我认领的医疗机构请求
 // 我认领的医疗机构请求
 type ClaimInstitutionReq {
 type ClaimInstitutionReq {
-	UserId      string `header:"newUserId"`           // 用户id
-	CompanyName string `json:"company_name,optional"` // 要搜索的医疗机构
-	Page        int    `json:"page,optional"`         // 页码
-	PageSize    int    `json:"page_size,optional"`    // 每页条数
+	UserId   int    `header:"newUserId"`          // 用户id
+	Page     int    `json:"page,default=0"`       // 页码
+	PageSize int    `json:"page_size,default=10"` // 每页条数
+	AppId    string `header:"appId"`              // appid
+
 }
 }
 
 
 // 我认领的经销商请求
 // 我认领的经销商请求
 type ClaimDistributorReq {
 type ClaimDistributorReq {
-	UserId   string `header:"newUserId"`        // 用户id
-	Page     int    `json:"page,optional"`      // 页码
-	PageSize int    `json:"page_size,optional"` // 每页条数
+	UserId   int    `header:"newUserId"`          // 用户id
+	Page     int    `json:"page,default=0"`       // 页码
+	PageSize int    `json:"page_size,default=10"` // 每页条数
+	AppId    string `header:"appId"`              // appid
+
 }
 }
 
 
 // 获取经销商医械信息请求
 // 获取经销商医械信息请求
@@ -55,25 +60,32 @@ type DistributorProductsReq {
 }
 }
 // 认领
 // 认领
 type ClaimReq {
 type ClaimReq {
-	Type    int    `json:"type"`        // 1 医疗机构 2 经销商
-	EntId   string `json:"entid"`       // 企业标识
-	EntName string `json:"ent_name"`    // 企业名称
-	Address string `json:"address"`     // 所在地
-	UserId  string `header:"newUserId"` // 用户id
-
+	Type   int    `json:"type,options=1|2"` // 1 医疗机构 2 经销商
+	EntId  string `json:"ent_id"`           // 企业标识
+	UserId int    `header:"newUserId"`      // 用户id
+	AppId  string `header:"appId"`          // appid
 }
 }
 
 
 // 取消认领
 // 取消认领
 type UnclaimedReq {
 type UnclaimedReq {
-	UserId string `header:"newUserId"` // 用户id
-	Id     int    `json:"id"`
+	UserId int    `header:"newUserId"` // 用户id
+	Id     string `json:"id"`
 }
 }
 
 
 // 是否是认领过的
 // 是否是认领过的
 type IsClaimedReq {
 type IsClaimedReq {
-	UserId    string `header:"newUserId"` // 用户id
-	CompanyId string `json:"company_id"`  // 机构id
-	Type      int    `json:"type"`        // 1 医疗机构 2 经销商
+	UserId    int    `header:"newUserId"`      // 用户id
+	CompanyId string `json:"company_id"`       // 机构id
+	Type      int    `json:"type,options=1|2"` // 1 医疗机构 2 经销商
+}
+
+// 获取机构信息请求
+type GetNewMsgListReq {
+	CompanyName string `json:"companyName"`          // 机构唯一标识
+	UserId      int    `header:"newUserId,optional"` //session中的用户base_user_id
+	AppId       string `header:"appId,default=10000"`
+	PageSize    int64  `json:"pageSize"`
+	PageNum     int64  `json:"pageNum"`
 }
 }
 // 医疗机构
 // 医疗机构
 @server(
 @server(
@@ -84,11 +96,13 @@ service medical-api {
 	@handler searchInstitution
 	@handler searchInstitution
 	post /search/institution (SearchInstitutionReq) returns (CommonRes); 	    // 搜索医疗机构
 	post /search/institution (SearchInstitutionReq) returns (CommonRes); 	    // 搜索医疗机构
 	@handler getFilterItem
 	@handler getFilterItem
-	post /getFilterItem () returns (CommonRes); 	                            // 获取医疗机构筛选条件
+	post /getFilterItem  returns (CommonRes); 	                            // 获取医疗机构筛选条件
 	@handler portraitInstitution
 	@handler portraitInstitution
 	post /portrait/institution (PortraitReq) returns (CommonRes); 	// 医疗机构画像-医院信息 不确定是否需要
 	post /portrait/institution (PortraitReq) returns (CommonRes); 	// 医疗机构画像-医院信息 不确定是否需要
 	@handler claimInstitution
 	@handler claimInstitution
 	post /claim/institution (ClaimInstitutionReq) returns (CommonRes); 	    // 我关注的医疗机构
 	post /claim/institution (ClaimInstitutionReq) returns (CommonRes); 	    // 我关注的医疗机构
+	@handler getNewMsgList
+	post /portrait/getNewMsgList(GetNewMsgListReq)returns(CommonRes);	//医疗机构画像标讯信息
 }
 }
 
 
 // 经销商
 // 经销商

+ 2 - 2
entity/code.go

@@ -4,9 +4,9 @@ package entity
 const (
 const (
 	CODE_MEDICAL_INSTITUTION_LEVEL = "code_level"
 	CODE_MEDICAL_INSTITUTION_LEVEL = "code_level"
 	CODE_MEDICAL_INSTITUTION_TYPE  = "code_type"
 	CODE_MEDICAL_INSTITUTION_TYPE  = "code_type"
-	DOMAIN_ENT_FOLLOW              = "domain_ent_follow"
 	DOMAIN_CAPITAL_RETENTION       = "domain_capital_retention"
 	DOMAIN_CAPITAL_RETENTION       = "domain_capital_retention"
-	TableDomainEntClaim            = "domain_ent_claim"
+	TableDomainEntClaim            = "domain_ent_claim" // 认领表
+	TableCompanyBasInfo            = "company_baseinfo" // 企业信息表
 )
 )
 
 
 //返回状态
 //返回状态

+ 1 - 0
entity/coverage

@@ -0,0 +1 @@
+mode: set

+ 7 - 4
entity/db.go

@@ -12,17 +12,20 @@ type MysqlMainStruct struct {
 	MaxOpenConns int    `json:"maxOpenConns"`
 	MaxOpenConns int    `json:"maxOpenConns"`
 	MaxIdleConns int    `json:"maxIdleConns"`
 	MaxIdleConns int    `json:"maxIdleConns"`
 }
 }
+
 type EsStruct struct {
 type EsStruct struct {
 	Addr string `json:"addr"`
 	Addr string `json:"addr"`
 	Size int    `json:"size"`
 	Size int    `json:"size"`
 }
 }
 
 
 var (
 var (
-	Mysql     *mysql.Mysql
-	BaseMysql *mysql.Mysql
+	Mysql            *mysql.Mysql
+	BaseMysql        *mysql.Mysql
+	GlobalCommonData *mysql.Mysql
 )
 )
 
 
 type Conn struct {
 type Conn struct {
-	Mysql     *mysql.Mysql
-	BaseMysql *mysql.Mysql
+	Mysql            *mysql.Mysql
+	BaseMysql        *mysql.Mysql
+	GlobalCommonData *mysql.Mysql
 }
 }

+ 9 - 13
entity/model.go

@@ -1,17 +1,13 @@
 package entity
 package entity
 
 
 type EntClaim struct {
 type EntClaim struct {
-	Id              string `json:"id,omitempty"`          // id
-	AppId           string `json:"appid"`                 // appid
-	UserId          int    `json:"user_id"`               // 用户id
-	EntId           string `json:"ent_id"`                // 企业id
-	EntName         string `json:"ent_name"`              // 企业名称
-	Status          int    `json:"status"`                // '状态;-1:取消认领 1:认领'
-	Type            int    `json:"type"`                  // '类型;1:医疗机构 2:经销商'
-	Address         string `json:"address"`               // 企业地址
-	EstablishDate   string `json:"establish_date"`        // 成立日期
-	RegisterCapital string `json:"regist_capital"`        // 注册资本
-	Phone           string `json:"phone"`                 // 联系方式
-	UpdateTime      string `json:"update_time,omitempty"` // 修改时间
-	CreateTime      string `json:"create_time"`           // 创建时间
+	Id         string `json:"id,omitempty"`          // id
+	AppId      string `json:"appid"`                 // appid
+	UserId     int    `json:"user_id"`               // 用户id
+	EntId      string `json:"ent_id"`                // 企业id
+	EntName    string `json:"ent_name"`              // 企业名称
+	Status     int    `json:"status"`                // '状态;-1:取消认领 1:认领'
+	Type       int    `json:"type"`                  // '类型;1:医疗机构 2:经销商'
+	UpdateTime string `json:"update_time,omitempty"` // 修改时间
+	CreateTime string `json:"create_time"`           // 创建时间
 }
 }

+ 51 - 0
entity/portrait.go

@@ -0,0 +1,51 @@
+package entity
+
+const (
+	Institution_baseinfo   = "institution_baseinfo"   //机构信息表
+	Institution_department = "institution_department" //机构科室表
+	Code_level             = "code_level"             //医院等级表
+	Code_type              = "code_type"              //医疗类型表
+	Code_sdleveltypeequip  = "code_sdleveltypeequip"  //医疗器械表
+	Code_area              = "code_area"              //地区表
+	Domain_ent_claim       = "domain_ent_claim"
+
+	BidField = "0101"
+
+	NO_DATA_ERROR_MSG = "暂无数据"
+
+	NewMustSearch   = `{"query":{"bool":{"must":[%s]}}%s}`
+	ListSearchLimit = `,"_source":[%s],"sort":[{"%s":{"order":"desc"}}],"from":%d,"size":%d`
+
+	BiddingIndex, BiddingType        = "bidding", "bidding"
+	TableShowNumLimit                = 40
+	DataExportBatchSearchLimit int64 = 500
+)
+
+//医疗机构画像
+type PortraitInfo struct {
+	Beds          int64  //床位数
+	VisitPerday   int64  // 门诊量/日
+	Doctorsnum    int64  //医生人数
+	Address       string //医疗机构地址
+	Website       string //医疗机构网站
+	Area          string //区域省份
+	City          string //城市
+	District      string //区县
+	BusinessType  int64  //医疗机构经营方式(0:公立、1:民营、2:其它)
+	Level         string //医疗机构等级
+	MiType        string //医疗机构类型
+	Equipment     string //医院设备
+	Departnames   string //医院科室
+	Follow        int64  //是否关注 0-未关注 1已关注
+	CompanyName   string //医疗机构名称
+	EstablishDate string //成立日期
+}
+
+//医疗画像-招标动态
+type GetNewMsgList struct {
+	Area      string //地区
+	Bidstatus string //信息类型
+	Firsttime int64  //时间
+	Id        string //加密信息id
+	Title     string //标题
+}

+ 1 - 0
go.sum

@@ -329,6 +329,7 @@ github.com/mattn/go-sqlite3 v1.9.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOq
 github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
 github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
 github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 h1:I0XW9+e1XWDxdcEniV4rQAIOPUGDq67JSCiRCgGCZLI=
 github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 h1:I0XW9+e1XWDxdcEniV4rQAIOPUGDq67JSCiRCgGCZLI=
 github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4=
 github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4=
+github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE=
 github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
 github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
 github.com/mkevac/debugcharts v0.0.0-20191222103121-ae1c48aa8615/go.mod h1:Ad7oeElCZqA1Ufj0U9/liOF4BtVepxRcTvr2ey7zTvM=
 github.com/mkevac/debugcharts v0.0.0-20191222103121-ae1c48aa8615/go.mod h1:Ad7oeElCZqA1Ufj0U9/liOF4BtVepxRcTvr2ey7zTvM=
 github.com/moby/spdystream v0.2.0/go.mod h1:f7i0iNDQJ059oMTcWxx8MA/zKFIuD/lY+0GqbN2Wy8c=
 github.com/moby/spdystream v0.2.0/go.mod h1:f7i0iNDQJ059oMTcWxx8MA/zKFIuD/lY+0GqbN2Wy8c=

+ 11 - 2
rpc/medical/etc/medical.yaml

@@ -9,16 +9,25 @@ MysqlMain:
   dbName: medical_fileld_data
   dbName: medical_fileld_data
   address: 192.168.3.217:4000
   address: 192.168.3.217:4000
   userName: root
   userName: root
-  passWord: =PDT49#80Z!RVv52_z
+  passWord: '=PDT49#80Z!RVv52_z'
   maxOpenConns: 5
   maxOpenConns: 5
   maxIdleConns: 5
   maxIdleConns: 5
 BaseMysqlMain:
 BaseMysqlMain:
   dbName: base_service
   dbName: base_service
   address: 192.168.3.217:4000
   address: 192.168.3.217:4000
   userName: root
   userName: root
-  passWord: =PDT49#80Z!RVv52_z
+  passWord: '=PDT49#80Z!RVv52_z'
   maxOpenConns: 5
   maxOpenConns: 5
   maxIdleConns: 5
   maxIdleConns: 5
 Es:
 Es:
   addr: http://192.168.3.206:9800
   addr: http://192.168.3.206:9800
   size: 5
   size: 5
+  index: bidding
+  type: bidding
+GlobalCommonData:
+  dbName: global_common_data
+  address: 192.168.3.217:4000
+  userName: root
+  passWord: =PDT49#80Z!RVv52_z
+  maxOpenConns: 5
+  maxIdleConns: 5

+ 15 - 5
rpc/medical/init/init.go

@@ -1,16 +1,15 @@
 package init
 package init
 
 
 import (
 import (
+	"flag"
+	"log"
 	elastic "app.yhyue.com/moapp/jybase/esv1"
 	elastic "app.yhyue.com/moapp/jybase/esv1"
 	"app.yhyue.com/moapp/jybase/mysql"
 	"app.yhyue.com/moapp/jybase/mysql"
 	"bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/entity"
 	"bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/entity"
 	"bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/rpc/medical/internal/config"
 	"bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/rpc/medical/internal/config"
-	"flag"
-	"fmt"
 	_ "github.com/go-sql-driver/mysql"
 	_ "github.com/go-sql-driver/mysql"
 	"github.com/zeromicro/go-zero/core/conf"
 	"github.com/zeromicro/go-zero/core/conf"
 	"github.com/zeromicro/go-zero/core/logx"
 	"github.com/zeromicro/go-zero/core/logx"
-	"log"
 )
 )
 
 
 var configF = flag.String("ff", "etc/medical.yaml", "the config file")
 var configF = flag.String("ff", "etc/medical.yaml", "the config file")
@@ -48,8 +47,19 @@ func init() {
 		}
 		}
 		entity.BaseMysql.Init()
 		entity.BaseMysql.Init()
 	}
 	}
-
-	fmt.Println()
+	commonConfig := C.GlobalCommonData
+	if nn.Address != "" {
+		log.Println("--初始化 mysql--")
+		entity.GlobalCommonData = &mysql.Mysql{
+			Address:      commonConfig.Address,
+			UserName:     commonConfig.UserName,
+			PassWord:     commonConfig.PassWord,
+			DBName:       commonConfig.DbName,
+			MaxOpenConns: commonConfig.MaxOpenConns,
+			MaxIdleConns: commonConfig.MaxIdleConns,
+		}
+		entity.GlobalCommonData.Init()
+	}
 	//初始化 elasticsearch
 	//初始化 elasticsearch
 	es := C.Es
 	es := C.Es
 	if es.Addr != "" {
 	if es.Addr != "" {

+ 4 - 3
rpc/medical/internal/config/config.go

@@ -7,7 +7,8 @@ import (
 
 
 type Config struct {
 type Config struct {
 	zrpc.RpcServerConf
 	zrpc.RpcServerConf
-	MysqlMain     entity.MysqlMainStruct
-	BaseMysqlMain entity.MysqlMainStruct
-	Es            entity.EsStruct
+	MysqlMain        entity.MysqlMainStruct
+	BaseMysqlMain    entity.MysqlMainStruct
+	Es               entity.EsStruct
+	GlobalCommonData entity.MysqlMainStruct
 }
 }

+ 52 - 26
rpc/medical/internal/logic/claimeddistributorlistlogic.go

@@ -1,10 +1,13 @@
 package logic
 package logic
 
 
 import (
 import (
+	"app.yhyue.com/moapp/jybase/common"
+	"app.yhyue.com/moapp/jybase/encrypt"
 	"bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/entity"
 	"bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/entity"
 	"bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/rpc/medical/internal/svc"
 	"bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/rpc/medical/internal/svc"
 	"bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/rpc/medical/medical"
 	"bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/rpc/medical/medical"
 	"context"
 	"context"
+	"fmt"
 	"github.com/zeromicro/go-zero/core/logx"
 	"github.com/zeromicro/go-zero/core/logx"
 )
 )
 
 
@@ -23,32 +26,55 @@ func NewClaimedDistributorListLogic(ctx context.Context, svcCtx *svc.ServiceCont
 }
 }
 
 
 // ClaimedDistributorList 我认领的经销商列表
 // ClaimedDistributorList 我认领的经销商列表
-func (l *ClaimedDistributorListLogic) ClaimedDistributorList(in *medical.ClaimedReq) (*medical.CommonResp, error) {
-	//rs, total := l.svcCtx.EntClaimSrv.DistributorList(int(in.UserId), in.AppId, int(in.Page), int(in.PageSize))
-	//resultList := []medical.ClaimReq{}
-	//if rs!=nil{
-	//	//for i:=0;i<len(*rs);i++{
-	//	//	resultList = append(resultList,
-	//	//		medical.ClaimReq{
-	//	//		Id: common.Int64All((*rs)[i]["id"]),
-	//	//		AppId: (*rs)[i]["appid"],
-	//	//		Id: common.Int64All((*rs)[i]["ent_id"]),
-	//	//		Id: common.Int64All((*rs)[i]["ent_name"]),
-	//	//		Id: common.Int64All((*rs)[i]["address"]),
-	//	//		Id: common.Int64All((*rs)[i]["establish_date"]),
-	//	//		Id: common.Int64All((*rs)[i]["regist_capital"]),
-	//	//		Id: common.Int64All((*rs)[i]["phone"]),
-	//	//		Id: common.Int64All((*rs)[i]["update_time"]),
-	//	//		: common.Int64All((*rs)[i]["create_time"]),
-	//	//
-	//	//		}
-	//	//		)
-	//	//}
-	//}
-
-	return &medical.CommonResp{
+func (l *ClaimedDistributorListLogic) ClaimedDistributorList(in *medical.ClaimedReq) (*medical.EntClaimListResp, error) {
+	rs, total := l.svcCtx.EntClaimSrv.DistributorList(int(in.UserId), in.AppId, int(in.Page), int(in.PageSize))
+	resultList := medical.EntClaimListStruct{}
+	if rs != nil {
+		// 补充信息
+		// 获取id  构造查询条件
+		var entIds []interface{}
+		for i := 0; i < len(*rs); i++ {
+			entIds = append(entIds, common.ObjToString((*rs)[i]["ent_id"]))
+		}
+		// 查询信息
+		entRs := l.svcCtx.EntClaimSrv.GetInstitutionByIds(entIds)
+		//处理成map
+		entInfos := map[string]map[string]interface{}{}
+		if entRs != nil {
+			for i := 0; i < len(*entRs); i++ {
+				idTmp := common.ObjToString((*entRs)[i]["company_id"])
+				entInfos[idTmp] = (*entRs)[i]
+			}
+		}
+		// 拼接信息
+		for i := 0; i < len(*rs); i++ {
+			entId := common.ObjToString((*rs)[i]["ent_id"])
+			info := map[string]interface{}{}
+			if tmp, ok := entInfos[entId]; ok {
+				info = tmp
+			}
+			resultList.List = append(resultList.List,
+				&medical.EntClaim{
+					Id:            encrypt.SE.Encode2Hex(fmt.Sprintf("%v", (*rs)[i]["id"])),
+					AppId:         common.ObjToString((*rs)[i]["appid"]),
+					EntId:         encrypt.SE.Encode2Hex(entId),
+					EntName:       common.ObjToString((*rs)[i]["ent_name"]),
+					Address:       common.ObjToString(info["company_address"]),
+					EstablishDate: common.ObjToString(info["establish_date"]),
+					Capital:       common.ObjToString(info["capital"]),
+					CompanyPhone:  common.ObjToString(info["company_phone"]),
+					UpdateTime:    common.ObjToString((*rs)[i]["update_time"]),
+					CreateTime:    common.ObjToString((*rs)[i]["create_time"])},
+			)
+		}
+		resultList.Total = int64(total)
+	} else {
+		resultList.List = []*medical.EntClaim{}
+		resultList.Total = 0
+	}
+	return &medical.EntClaimListResp{
 		ErrorMsg:  "",
 		ErrorMsg:  "",
-		ErrorCode: entity.ERRORCODE,
-		Data:      nil,
+		ErrorCode: entity.SUCCESSCODE,
+		Data:      &resultList,
 	}, nil
 	}, nil
 }
 }

+ 56 - 3
rpc/medical/internal/logic/claimedinstitutionlistlogic.go

@@ -1,7 +1,11 @@
 package logic
 package logic
 
 
 import (
 import (
+	"app.yhyue.com/moapp/jybase/common"
+	"app.yhyue.com/moapp/jybase/encrypt"
+	"bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/entity"
 	"context"
 	"context"
+	"fmt"
 
 
 	"bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/rpc/medical/internal/svc"
 	"bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/rpc/medical/internal/svc"
 	"bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/rpc/medical/medical"
 	"bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/rpc/medical/medical"
@@ -24,8 +28,57 @@ func NewClaimedInstitutionListLogic(ctx context.Context, svcCtx *svc.ServiceCont
 }
 }
 
 
 // ClaimedInstitutionList 我认领的医疗机构列表
 // ClaimedInstitutionList 我认领的医疗机构列表
-func (l *ClaimedInstitutionListLogic) ClaimedInstitutionList(in *medical.ClaimedReq) (*medical.CommonResp, error) {
-	// todo: add your logic here and delete this line
+func (l *ClaimedInstitutionListLogic) ClaimedInstitutionList(in *medical.ClaimedReq) (*medical.EntClaimListResp, error) {
+	rs, total := l.svcCtx.EntClaimSrv.InstitutionList(int(in.UserId), in.AppId, int(in.Page), int(in.PageSize))
+	resultList := medical.EntClaimListStruct{}
 
 
-	return &medical.CommonResp{}, nil
+	if rs != nil {
+		// 补充信息
+		// 获取id  构造查询条件
+		var entIds []interface{}
+		for i := 0; i < len(*rs); i++ {
+			entIds = append(entIds, common.ObjToString((*rs)[i]["ent_id"]))
+		}
+		// 查询信息
+		entRs := l.svcCtx.EntClaimSrv.GetInstitutionByIds(entIds)
+		//处理成map
+		entInfos := map[string]map[string]interface{}{}
+		if entRs != nil {
+			for i := 0; i < len(*entRs); i++ {
+				idTmp := common.ObjToString((*entRs)[i]["company_id"])
+				entInfos[idTmp] = (*entRs)[i]
+			}
+		}
+		// 拼接信息
+		for i := 0; i < len(*rs); i++ {
+			entId := common.ObjToString((*rs)[i]["ent_id"])
+			info := map[string]interface{}{}
+			if tmp, ok := entInfos[entId]; ok {
+				info = tmp
+			}
+
+			resultList.List = append(resultList.List,
+				&medical.EntClaim{
+					Id:            encrypt.SE.Encode2Hex(fmt.Sprintf("%v", (*rs)[i]["id"])),
+					AppId:         common.ObjToString((*rs)[i]["appid"]),
+					EntId:         encrypt.SE.Encode2Hex(entId),
+					EntName:       common.ObjToString((*rs)[i]["ent_name"]),
+					Address:       common.ObjToString(info["company_address"]),
+					EstablishDate: common.ObjToString(info["establish_date"]),
+					Capital:       common.ObjToString(info["capital"]),
+					CompanyPhone:  common.ObjToString(info["company_phone"]),
+					UpdateTime:    common.ObjToString((*rs)[i]["update_time"]),
+					CreateTime:    common.ObjToString((*rs)[i]["create_time"])},
+			)
+		}
+		resultList.Total = int64(total)
+	} else {
+		resultList.List = []*medical.EntClaim{}
+		resultList.Total = 0
+	}
+	return &medical.EntClaimListResp{
+		ErrorMsg:  "",
+		ErrorCode: entity.SUCCESSCODE,
+		Data:      &resultList,
+	}, nil
 }
 }

+ 23 - 15
rpc/medical/internal/logic/claimlogic.go

@@ -3,11 +3,10 @@ package logic
 import (
 import (
 	"app.yhyue.com/moapp/jybase/date"
 	"app.yhyue.com/moapp/jybase/date"
 	"bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/entity"
 	"bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/entity"
-	"context"
-
 	"bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/rpc/medical/internal/svc"
 	"bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/rpc/medical/internal/svc"
 	"bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/rpc/medical/medical"
 	"bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/rpc/medical/medical"
-
+	"context"
+	"github.com/mitchellh/mapstructure"
 	"github.com/zeromicro/go-zero/core/logx"
 	"github.com/zeromicro/go-zero/core/logx"
 )
 )
 
 
@@ -27,19 +26,28 @@ func NewClaimLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ClaimLogic
 
 
 // Claim 认领(经销商/医疗机构)
 // Claim 认领(经销商/医疗机构)
 func (l *ClaimLogic) Claim(in *medical.ClaimReq) (*medical.CommonResp, error) {
 func (l *ClaimLogic) Claim(in *medical.ClaimReq) (*medical.CommonResp, error) {
+	tmp := struct {
+		CompanyName    string `mapstructure:"company_name,omitempty"`
+		EstablishDate  string `mapstructure:"establish_date,omitempty"`
+		CompanyAddress string `mapstructure:"company_address,omitempty"`
+		CompanyPhone   string `mapstructure:"company_phone,omitempty"`
+		Capital        string `mapstructure:"capital,omitempty"`
+	}{}
+	// 查询基本信息
+	baseInfo := l.svcCtx.EntClaimSrv.GetInstitution(in.EntId)
+	err := mapstructure.Decode(*baseInfo, &tmp)
+	if err != nil {
+		return nil, err
+	}
 
 
 	rs := l.svcCtx.EntClaimSrv.Claim(&entity.EntClaim{
 	rs := l.svcCtx.EntClaimSrv.Claim(&entity.EntClaim{
-		AppId:           in.AppId,
-		UserId:          int(in.UserId),
-		EntId:           in.EntId,
-		EntName:         in.EntName,
-		Status:          entity.StatusClaimed,
-		Type:            int(in.Type),
-		Address:         in.Address,
-		EstablishDate:   in.EstablishDate,
-		RegisterCapital: in.RegisterCapital,
-		Phone:           in.Phone,
-		CreateTime:      date.NowFormat(date.Date_Full_Layout),
+		AppId:      in.AppId,
+		UserId:     int(in.UserId),
+		EntId:      in.EntId,
+		EntName:    tmp.CompanyName,
+		Status:     entity.StatusClaimed,
+		Type:       int(in.Type),
+		CreateTime: date.NowFormat(date.Date_Full_Layout),
 	})
 	})
 	if !rs {
 	if !rs {
 		return &medical.CommonResp{
 		return &medical.CommonResp{
@@ -49,6 +57,6 @@ func (l *ClaimLogic) Claim(in *medical.ClaimReq) (*medical.CommonResp, error) {
 	}
 	}
 	return &medical.CommonResp{
 	return &medical.CommonResp{
 		ErrorMsg:  "",
 		ErrorMsg:  "",
-		ErrorCode: entity.ERRORCODE,
+		ErrorCode: entity.SUCCESSCODE,
 	}, nil
 	}, nil
 }
 }

+ 56 - 0
rpc/medical/internal/logic/getnewmsglogic.go

@@ -0,0 +1,56 @@
+package logic
+
+import (
+	"context"
+	"fmt"
+
+	"bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/entity"
+	"bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/rpc/medical/internal/svc"
+	"bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/rpc/medical/medical"
+	"bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type GetNewMsgLogic struct {
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+	logx.Logger
+}
+
+func NewGetNewMsgLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetNewMsgLogic {
+	return &GetNewMsgLogic{
+		ctx:    ctx,
+		svcCtx: svcCtx,
+		Logger: logx.WithContext(ctx),
+	}
+}
+
+//  招标动态
+func (l *GetNewMsgLogic) GetNewMsg(in *medical.GetNewMsgReq) (*medical.GetNewMsgResp, error) {
+	resp := &medical.GetNewMsgResp{}
+	portrait := service.NewPortrait(&entity.Conn{
+		Mysql:            entity.Mysql,
+		BaseMysql:        entity.BaseMysql,
+		GlobalCommonData: entity.GlobalCommonData,
+	})
+	info, count, err := portrait.List(in.CompanyName, in.PageSize, in.PageNum)
+	if err != nil || info == nil {
+		l.Error(fmt.Sprintf("%+v", in), err.Error())
+		resp.ErrorMsg = err.Error()
+		resp.ErrorCode = -1
+	} else {
+		resp.Count = count
+		for _, v := range *info {
+			resp.List = append(resp.List, &medical.NewMsgList{
+				Area:      v.Area,
+				Bidstatus: v.Bidstatus,
+				Firsttime: v.Firsttime,
+				Id:        v.Id,
+				Title:     v.Title,
+			})
+		}
+	}
+
+	return resp, nil
+}

+ 11 - 5
rpc/medical/internal/logic/isclaimedlogic.go

@@ -1,6 +1,7 @@
 package logic
 package logic
 
 
 import (
 import (
+	"bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/entity"
 	"context"
 	"context"
 
 
 	"bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/rpc/medical/internal/svc"
 	"bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/rpc/medical/internal/svc"
@@ -23,9 +24,14 @@ func NewIsClaimedLogic(ctx context.Context, svcCtx *svc.ServiceContext) *IsClaim
 	}
 	}
 }
 }
 
 
-//  是否认领(经销商/医疗机构)
-func (l *IsClaimedLogic) IsClaimed(in *medical.IsClaimedReq) (*medical.CommonResp, error) {
-	// todo: add your logic here and delete this line
-
-	return &medical.CommonResp{}, nil
+// IsClaimed 是否认领(经销商/医疗机构)
+func (l *IsClaimedLogic) IsClaimed(in *medical.IsClaimedReq) (*medical.IsClaimedResp, error) {
+	rs := l.svcCtx.EntClaimSrv.IsClaimed(int(in.UserId), in.AppId, in.EntId, int(in.Type))
+	return &medical.IsClaimedResp{
+		ErrorCode: entity.SUCCESSCODE,
+		ErrorMsg:  "",
+		Data: &medical.IsClaimedResp_StatusRes{
+			Status: rs,
+		},
+	}, nil
 }
 }

+ 33 - 1
rpc/medical/internal/logic/portraitlogic.go

@@ -2,9 +2,12 @@ package logic
 
 
 import (
 import (
 	"context"
 	"context"
+	"fmt"
 
 
+	"bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/entity"
 	"bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/rpc/medical/internal/svc"
 	"bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/rpc/medical/internal/svc"
 	"bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/rpc/medical/medical"
 	"bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/rpc/medical/medical"
+	"bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service"
 
 
 	"github.com/zeromicro/go-zero/core/logx"
 	"github.com/zeromicro/go-zero/core/logx"
 )
 )
@@ -26,6 +29,35 @@ func NewPortraitLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Portrait
 // 医疗机构画像
 // 医疗机构画像
 func (l *PortraitLogic) Portrait(in *medical.PortraitReq) (*medical.PortraitResp, error) {
 func (l *PortraitLogic) Portrait(in *medical.PortraitReq) (*medical.PortraitResp, error) {
 	// todo: add your logic here and delete this line
 	// todo: add your logic here and delete this line
+	resp := &medical.PortraitResp{}
+	portrait := service.NewPortrait(&entity.Conn{
+		Mysql:            entity.Mysql,
+		BaseMysql:        entity.BaseMysql,
+		GlobalCommonData: entity.GlobalCommonData,
+	})
+	info, err := portrait.Info(in.CompanyId, in.UserId)
+	if err != nil || info == nil {
+		l.Error(fmt.Sprintf("%+v", in), err.Error())
+		resp.ErrorMsg = err.Error()
+		resp.ErrorCode = -1
+	} else {
+		resp.Address = info.Address
+		resp.Area = info.Area
+		resp.Beds = info.Beds
+		resp.BusinessType = info.BusinessType
+		resp.CompanyName = info.CompanyName
+		resp.Departnames = info.Departnames
+		resp.Doctorsnum = info.Doctorsnum
+		resp.Equipment = info.Equipment
+		resp.EstablishDate = info.EstablishDate
+		resp.Follow = info.Follow
+		resp.Level = info.Level
+		resp.MiType = info.MiType
+		resp.VisitPerday = info.VisitPerday
+		resp.Website = info.Website
+		resp.City = info.City
+		resp.District = info.District
+	}
 
 
-	return &medical.PortraitResp{}, nil
+	return resp, nil
 }
 }

+ 13 - 4
rpc/medical/internal/logic/unclaimedlogic.go

@@ -1,6 +1,7 @@
 package logic
 package logic
 
 
 import (
 import (
+	"bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/entity"
 	"context"
 	"context"
 
 
 	"bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/rpc/medical/internal/svc"
 	"bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/rpc/medical/internal/svc"
@@ -23,9 +24,17 @@ func NewUnClaimedLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UnClaim
 	}
 	}
 }
 }
 
 
-//  取消认领(经销商/医疗机构)
+// UnClaimed 取消认领(经销商/医疗机构)
 func (l *UnClaimedLogic) UnClaimed(in *medical.UnclaimedReq) (*medical.CommonResp, error) {
 func (l *UnClaimedLogic) UnClaimed(in *medical.UnclaimedReq) (*medical.CommonResp, error) {
-	// todo: add your logic here and delete this line
-
-	return &medical.CommonResp{}, nil
+	rs := l.svcCtx.EntClaimSrv.Unclaimed(int(in.Id), int(in.UserId))
+	if !rs {
+		return &medical.CommonResp{
+			ErrorMsg:  "操作失败",
+			ErrorCode: entity.ERRORCODE,
+		}, nil
+	}
+	return &medical.CommonResp{
+		ErrorMsg:  "",
+		ErrorCode: entity.SUCCESSCODE,
+	}, nil
 }
 }

+ 12 - 6
rpc/medical/internal/server/medicalserver.go

@@ -6,9 +6,9 @@ package server
 import (
 import (
 	"context"
 	"context"
 
 
-	"bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/rpc/medical/internal/logic"
-	"bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/rpc/medical/internal/svc"
-	"bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/rpc/medical/medical"
+	"medical/internal/logic"
+	"medical/internal/svc"
+	"medical/medical"
 )
 )
 
 
 type MedicalServer struct {
 type MedicalServer struct {
@@ -71,19 +71,25 @@ func (s *MedicalServer) UnClaimed(ctx context.Context, in *medical.UnclaimedReq)
 }
 }
 
 
 //  是否认领(经销商/医疗机构)
 //  是否认领(经销商/医疗机构)
-func (s *MedicalServer) IsClaimed(ctx context.Context, in *medical.IsClaimedReq) (*medical.CommonResp, error) {
+func (s *MedicalServer) IsClaimed(ctx context.Context, in *medical.IsClaimedReq) (*medical.IsClaimedResp, error) {
 	l := logic.NewIsClaimedLogic(ctx, s.svcCtx)
 	l := logic.NewIsClaimedLogic(ctx, s.svcCtx)
 	return l.IsClaimed(in)
 	return l.IsClaimed(in)
 }
 }
 
 
 //  我认领的经销商列表
 //  我认领的经销商列表
-func (s *MedicalServer) ClaimedDistributorList(ctx context.Context, in *medical.ClaimedReq) (*medical.CommonResp, error) {
+func (s *MedicalServer) ClaimedDistributorList(ctx context.Context, in *medical.ClaimedReq) (*medical.EntClaimListResp, error) {
 	l := logic.NewClaimedDistributorListLogic(ctx, s.svcCtx)
 	l := logic.NewClaimedDistributorListLogic(ctx, s.svcCtx)
 	return l.ClaimedDistributorList(in)
 	return l.ClaimedDistributorList(in)
 }
 }
 
 
 //  我认领的医疗机构列表
 //  我认领的医疗机构列表
-func (s *MedicalServer) ClaimedInstitutionList(ctx context.Context, in *medical.ClaimedReq) (*medical.CommonResp, error) {
+func (s *MedicalServer) ClaimedInstitutionList(ctx context.Context, in *medical.ClaimedReq) (*medical.EntClaimListResp, error) {
 	l := logic.NewClaimedInstitutionListLogic(ctx, s.svcCtx)
 	l := logic.NewClaimedInstitutionListLogic(ctx, s.svcCtx)
 	return l.ClaimedInstitutionList(in)
 	return l.ClaimedInstitutionList(in)
 }
 }
+
+//  招标动态
+func (s *MedicalServer) GetNewMsg(ctx context.Context, in *medical.GetNewMsgReq) (*medical.GetNewMsgResp, error) {
+	l := logic.NewGetNewMsgLogic(ctx, s.svcCtx)
+	return l.GetNewMsg(in)
+}

+ 1 - 3
rpc/medical/internal/svc/servicecontext.go

@@ -4,7 +4,6 @@ import (
 	"bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/entity"
 	"bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/entity"
 	"bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/rpc/medical/internal/config"
 	"bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/rpc/medical/internal/config"
 	"bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service"
 	"bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service"
-	"fmt"
 )
 )
 
 
 type ServiceContext struct {
 type ServiceContext struct {
@@ -13,9 +12,8 @@ type ServiceContext struct {
 }
 }
 
 
 func NewServiceContext(c config.Config) *ServiceContext {
 func NewServiceContext(c config.Config) *ServiceContext {
-	fmt.Println(entity.BaseMysql, entity.BaseMysql == nil)
 	return &ServiceContext{
 	return &ServiceContext{
 		Config:      c,
 		Config:      c,
-		EntClaimSrv: service.NewEntClaimSrv(&entity.Conn{Mysql: entity.Mysql, BaseMysql: entity.BaseMysql}), // 手动添加 认领相关
+		EntClaimSrv: service.NewEntClaimSrv(&entity.Conn{Mysql: entity.Mysql, BaseMysql: entity.BaseMysql, GlobalCommonData: entity.GlobalCommonData}), // 手动添加 认领相关
 	}
 	}
 }
 }

+ 79 - 14
rpc/medical/medical.proto

@@ -15,7 +15,7 @@ message Response {
 message CommonResp{
 message CommonResp{
   int64           ErrorCode = 1;  // 响应代码
   int64           ErrorCode = 1;  // 响应代码
   string          ErrorMsg = 2;   // 响应信息
   string          ErrorMsg = 2;   // 响应信息
-  google.protobuf.Any Data = 3;   // 响应数据
+  bytes           Data = 3;   // 响应数据
 }
 }
 message CommonReq {
 message CommonReq {
     int64           userId  =1;
     int64           userId  =1;
@@ -106,6 +106,7 @@ message UserInfoResp{
 message PortraitReq{
 message PortraitReq{
 	string appId =1;
 	string appId =1;
 	string companyId =2;
 	string companyId =2;
+	int64 userId=3;
 }
 }
 //医疗机构画像出参
 //医疗机构画像出参
 message PortraitResp{
 message PortraitResp{
@@ -114,7 +115,7 @@ message PortraitResp{
 	int64 doctorsnum=3;//医生人数
 	int64 doctorsnum=3;//医生人数
 	string address=4; //医疗机构地址
 	string address=4; //医疗机构地址
 	string website=5; //医疗机构网站
 	string website=5; //医疗机构网站
-	string area=6; //区域
+	string area=6; //
 	int64 business_type=7; //医疗机构经营方式(0:公立、1:民营、2:其它)
 	int64 business_type=7; //医疗机构经营方式(0:公立、1:民营、2:其它)
 	string level=8; //医疗机构等级
 	string level=8; //医疗机构等级
 	string miType=9; //医疗机构类型
 	string miType=9; //医疗机构类型
@@ -123,20 +124,19 @@ message PortraitResp{
 	int64 follow=12; //是否关注 0-未关注 1已关注
 	int64 follow=12; //是否关注 0-未关注 1已关注
 	string companyName=13;//医疗机构名称
 	string companyName=13;//医疗机构名称
 	string establish_date=14;//成立日期
 	string establish_date=14;//成立日期
+	string error_msg =15;
+	int64 error_code=16;
+	string city=17;//城市
+	string district=18;//区县
 }
 }
 // 认领
 // 认领
 message ClaimReq{
 message ClaimReq{
-  int64 Id = 10;
   int64 UserId = 1 ;// 用户id
   int64 UserId = 1 ;// 用户id
   string EntId = 2 ;// 公司id
   string EntId = 2 ;// 公司id
-  string EntName = 3 ;// 公司名称
-  int64 Type = 4 ;// 类型;1:医疗机构 2:经销商'
-  string Address = 5 ;// 企业地址
-  string EstablishDate = 6 ;// 成立日期
-  string RegisterCapital = 7 ;// 注册资本
-  string Phone = 8 ;// 联系方式
-  string AppId = 9 ;//appid
+  int64 Type = 3 ;// 类型;1:医疗机构 2:经销商'
+  string AppId = 4 ;//appid
 }
 }
+
 // 取消认领
 // 取消认领
 message UnclaimedReq{
 message UnclaimedReq{
   int64  UserId = 1 ;// 用户id
   int64  UserId = 1 ;// 用户id
@@ -146,8 +146,18 @@ message UnclaimedReq{
 // 是否是认领的
 // 是否是认领的
 message IsClaimedReq{
 message IsClaimedReq{
   int64  UserId = 1 ;// 用户id
   int64  UserId = 1 ;// 用户id
-  int64  Id = 2; // 认领记录id
+  string  EntId = 2; // 认领记录id
   string AppId = 3 ;//appid
   string AppId = 3 ;//appid
+  int64  Type = 4;// 1-医疗机构 2-经销商
+}
+message IsClaimedResp{
+  int64  ErrorCode = 1;  // 响应代码
+  string ErrorMsg = 2;   // 响应信息
+  message StatusRes{
+    bool status = 1;
+  }
+  StatusRes Data =3;
+
 }
 }
 // 我认领的
 // 我认领的
 message ClaimedReq{
 message ClaimedReq{
@@ -156,6 +166,59 @@ message ClaimedReq{
   int64  Page = 3; // 认领记录id
   int64  Page = 3; // 认领记录id
   int64 PageSize = 4 ;//appid
   int64 PageSize = 4 ;//appid
 }
 }
+
+//医疗机构画像招标动态入参
+message GetNewMsgReq{
+	string companyName =1;//机构名称
+	int64 pageNum=2;//页码
+	int64 pageSize=3;//条数
+}
+
+//医疗机构画像招标动态出参数
+message GetNewMsgResp{
+	repeated NewMsgList list=1; //招标动态
+	int64 count =2;//招标动态数量
+	string error_msg =3;
+	int64 error_code=4;
+}
+
+//招标动态列表
+message NewMsgList{
+	string area =1;//地区
+	string bidstatus =2;//信息类型
+	string bidamount=3;//金额
+	int64 firsttime=4;//时间
+	string id =5;//加密信息id
+	string title=6;//标题
+	repeated string winner=7;//中标单位
+}
+
+message  EntClaim{
+  string  id = 10;
+  int64  user_id = 1 ;// 用户id
+  string ent_id = 2 ;// 公司id
+  string ent_name = 3 ;// 公司名称
+  int64  type = 4 ;// 类型;1:医疗机构 2:经销商'
+  string address = 5 ;// 企业地址
+  string establish_date = 6 ;// 成立日期
+  string capital = 7 ;// 注册资本
+  string company_phone = 8 ;// 联系方式
+  string appId = 9 ;//appid
+  string create_time = 11 ;//创建时间
+  string update_time = 12 ;//更新时间
+}
+// 列表
+message  EntClaimListStruct{
+  repeated EntClaim list =1;
+  int64    total = 2;
+}
+// 关注列表响应
+message  EntClaimListResp{
+  int64           ErrorCode = 1;  // 响应代码
+  string          ErrorMsg = 2;   // 响应信息
+  EntClaimListStruct Data =3;
+}
+
 service Medical {
 service Medical {
       //搜索医疗机构
       //搜索医疗机构
       rpc Institution(SearchInstitutionReq) returns(CompanyResp);
       rpc Institution(SearchInstitutionReq) returns(CompanyResp);
@@ -174,9 +237,11 @@ service Medical {
       // 取消认领(经销商/医疗机构)
       // 取消认领(经销商/医疗机构)
       rpc UnClaimed(UnclaimedReq) returns(CommonResp);
       rpc UnClaimed(UnclaimedReq) returns(CommonResp);
       // 是否认领(经销商/医疗机构)
       // 是否认领(经销商/医疗机构)
-      rpc IsClaimed(IsClaimedReq) returns(CommonResp);
+      rpc IsClaimed(IsClaimedReq) returns(IsClaimedResp);
       // 我认领的经销商列表
       // 我认领的经销商列表
-      rpc ClaimedDistributorList(ClaimedReq) returns(CommonResp);
+      rpc ClaimedDistributorList(ClaimedReq) returns(EntClaimListResp);
       // 我认领的医疗机构列表
       // 我认领的医疗机构列表
-      rpc ClaimedInstitutionList(ClaimedReq) returns(CommonResp);
+      rpc ClaimedInstitutionList(ClaimedReq) returns(EntClaimListResp);
+      // 招标动态
+      rpc GetNewMsg(GetNewMsgReq) returns (GetNewMsgResp);
 }
 }

+ 14 - 6
rpc/medical/medical/medical.go

@@ -29,11 +29,13 @@ type (
 		//  取消认领(经销商/医疗机构)
 		//  取消认领(经销商/医疗机构)
 		UnClaimed(ctx context.Context, in *UnclaimedReq, opts ...grpc.CallOption) (*CommonResp, error)
 		UnClaimed(ctx context.Context, in *UnclaimedReq, opts ...grpc.CallOption) (*CommonResp, error)
 		//  是否认领(经销商/医疗机构)
 		//  是否认领(经销商/医疗机构)
-		IsClaimed(ctx context.Context, in *IsClaimedReq, opts ...grpc.CallOption) (*CommonResp, error)
+		IsClaimed(ctx context.Context, in *IsClaimedReq, opts ...grpc.CallOption) (*IsClaimedResp, error)
 		//  我认领的经销商列表
 		//  我认领的经销商列表
-		ClaimedDistributorList(ctx context.Context, in *ClaimedReq, opts ...grpc.CallOption) (*CommonResp, error)
+		ClaimedDistributorList(ctx context.Context, in *ClaimedReq, opts ...grpc.CallOption) (*EntClaimListResp, error)
 		//  我认领的医疗机构列表
 		//  我认领的医疗机构列表
-		ClaimedInstitutionList(ctx context.Context, in *ClaimedReq, opts ...grpc.CallOption) (*CommonResp, error)
+		ClaimedInstitutionList(ctx context.Context, in *ClaimedReq, opts ...grpc.CallOption) (*EntClaimListResp, error)
+		//  招标动态
+		GetNewMsg(ctx context.Context, in *GetNewMsgReq, opts ...grpc.CallOption) (*GetNewMsgResp, error)
 	}
 	}
 
 
 	defaultMedical struct {
 	defaultMedical struct {
@@ -96,19 +98,25 @@ func (m *defaultMedical) UnClaimed(ctx context.Context, in *UnclaimedReq, opts .
 }
 }
 
 
 //  是否认领(经销商/医疗机构)
 //  是否认领(经销商/医疗机构)
-func (m *defaultMedical) IsClaimed(ctx context.Context, in *IsClaimedReq, opts ...grpc.CallOption) (*CommonResp, error) {
+func (m *defaultMedical) IsClaimed(ctx context.Context, in *IsClaimedReq, opts ...grpc.CallOption) (*IsClaimedResp, error) {
 	client := NewMedicalClient(m.cli.Conn())
 	client := NewMedicalClient(m.cli.Conn())
 	return client.IsClaimed(ctx, in, opts...)
 	return client.IsClaimed(ctx, in, opts...)
 }
 }
 
 
 //  我认领的经销商列表
 //  我认领的经销商列表
-func (m *defaultMedical) ClaimedDistributorList(ctx context.Context, in *ClaimedReq, opts ...grpc.CallOption) (*CommonResp, error) {
+func (m *defaultMedical) ClaimedDistributorList(ctx context.Context, in *ClaimedReq, opts ...grpc.CallOption) (*EntClaimListResp, error) {
 	client := NewMedicalClient(m.cli.Conn())
 	client := NewMedicalClient(m.cli.Conn())
 	return client.ClaimedDistributorList(ctx, in, opts...)
 	return client.ClaimedDistributorList(ctx, in, opts...)
 }
 }
 
 
 //  我认领的医疗机构列表
 //  我认领的医疗机构列表
-func (m *defaultMedical) ClaimedInstitutionList(ctx context.Context, in *ClaimedReq, opts ...grpc.CallOption) (*CommonResp, error) {
+func (m *defaultMedical) ClaimedInstitutionList(ctx context.Context, in *ClaimedReq, opts ...grpc.CallOption) (*EntClaimListResp, error) {
 	client := NewMedicalClient(m.cli.Conn())
 	client := NewMedicalClient(m.cli.Conn())
 	return client.ClaimedInstitutionList(ctx, in, opts...)
 	return client.ClaimedInstitutionList(ctx, in, opts...)
 }
 }
+
+//  招标动态
+func (m *defaultMedical) GetNewMsg(ctx context.Context, in *GetNewMsgReq, opts ...grpc.CallOption) (*GetNewMsgResp, error) {
+	client := NewMedicalClient(m.cli.Conn())
+	return client.GetNewMsg(ctx, in, opts...)
+}

File diff suppressed because it is too large
+ 736 - 114
rpc/medical/medical/medical.pb.go


+ 53 - 15
rpc/medical/medical/medical_grpc.pb.go

@@ -39,11 +39,13 @@ type MedicalClient interface {
 	// 取消认领(经销商/医疗机构)
 	// 取消认领(经销商/医疗机构)
 	UnClaimed(ctx context.Context, in *UnclaimedReq, opts ...grpc.CallOption) (*CommonResp, error)
 	UnClaimed(ctx context.Context, in *UnclaimedReq, opts ...grpc.CallOption) (*CommonResp, error)
 	// 是否认领(经销商/医疗机构)
 	// 是否认领(经销商/医疗机构)
-	IsClaimed(ctx context.Context, in *IsClaimedReq, opts ...grpc.CallOption) (*CommonResp, error)
+	IsClaimed(ctx context.Context, in *IsClaimedReq, opts ...grpc.CallOption) (*IsClaimedResp, error)
 	// 我认领的经销商列表
 	// 我认领的经销商列表
-	ClaimedDistributorList(ctx context.Context, in *ClaimedReq, opts ...grpc.CallOption) (*CommonResp, error)
+	ClaimedDistributorList(ctx context.Context, in *ClaimedReq, opts ...grpc.CallOption) (*EntClaimListResp, error)
 	// 我认领的医疗机构列表
 	// 我认领的医疗机构列表
-	ClaimedInstitutionList(ctx context.Context, in *ClaimedReq, opts ...grpc.CallOption) (*CommonResp, error)
+	ClaimedInstitutionList(ctx context.Context, in *ClaimedReq, opts ...grpc.CallOption) (*EntClaimListResp, error)
+	// 招标动态
+	GetNewMsg(ctx context.Context, in *GetNewMsgReq, opts ...grpc.CallOption) (*GetNewMsgResp, error)
 }
 }
 
 
 type medicalClient struct {
 type medicalClient struct {
@@ -126,8 +128,8 @@ func (c *medicalClient) UnClaimed(ctx context.Context, in *UnclaimedReq, opts ..
 	return out, nil
 	return out, nil
 }
 }
 
 
-func (c *medicalClient) IsClaimed(ctx context.Context, in *IsClaimedReq, opts ...grpc.CallOption) (*CommonResp, error) {
-	out := new(CommonResp)
+func (c *medicalClient) IsClaimed(ctx context.Context, in *IsClaimedReq, opts ...grpc.CallOption) (*IsClaimedResp, error) {
+	out := new(IsClaimedResp)
 	err := c.cc.Invoke(ctx, "/medical.Medical/IsClaimed", in, out, opts...)
 	err := c.cc.Invoke(ctx, "/medical.Medical/IsClaimed", in, out, opts...)
 	if err != nil {
 	if err != nil {
 		return nil, err
 		return nil, err
@@ -135,8 +137,8 @@ func (c *medicalClient) IsClaimed(ctx context.Context, in *IsClaimedReq, opts ..
 	return out, nil
 	return out, nil
 }
 }
 
 
-func (c *medicalClient) ClaimedDistributorList(ctx context.Context, in *ClaimedReq, opts ...grpc.CallOption) (*CommonResp, error) {
-	out := new(CommonResp)
+func (c *medicalClient) ClaimedDistributorList(ctx context.Context, in *ClaimedReq, opts ...grpc.CallOption) (*EntClaimListResp, error) {
+	out := new(EntClaimListResp)
 	err := c.cc.Invoke(ctx, "/medical.Medical/ClaimedDistributorList", in, out, opts...)
 	err := c.cc.Invoke(ctx, "/medical.Medical/ClaimedDistributorList", in, out, opts...)
 	if err != nil {
 	if err != nil {
 		return nil, err
 		return nil, err
@@ -144,8 +146,8 @@ func (c *medicalClient) ClaimedDistributorList(ctx context.Context, in *ClaimedR
 	return out, nil
 	return out, nil
 }
 }
 
 
-func (c *medicalClient) ClaimedInstitutionList(ctx context.Context, in *ClaimedReq, opts ...grpc.CallOption) (*CommonResp, error) {
-	out := new(CommonResp)
+func (c *medicalClient) ClaimedInstitutionList(ctx context.Context, in *ClaimedReq, opts ...grpc.CallOption) (*EntClaimListResp, error) {
+	out := new(EntClaimListResp)
 	err := c.cc.Invoke(ctx, "/medical.Medical/ClaimedInstitutionList", in, out, opts...)
 	err := c.cc.Invoke(ctx, "/medical.Medical/ClaimedInstitutionList", in, out, opts...)
 	if err != nil {
 	if err != nil {
 		return nil, err
 		return nil, err
@@ -153,6 +155,15 @@ func (c *medicalClient) ClaimedInstitutionList(ctx context.Context, in *ClaimedR
 	return out, nil
 	return out, nil
 }
 }
 
 
+func (c *medicalClient) GetNewMsg(ctx context.Context, in *GetNewMsgReq, opts ...grpc.CallOption) (*GetNewMsgResp, error) {
+	out := new(GetNewMsgResp)
+	err := c.cc.Invoke(ctx, "/medical.Medical/GetNewMsg", in, out, opts...)
+	if err != nil {
+		return nil, err
+	}
+	return out, nil
+}
+
 // MedicalServer is the server API for Medical service.
 // MedicalServer is the server API for Medical service.
 // All implementations must embed UnimplementedMedicalServer
 // All implementations must embed UnimplementedMedicalServer
 // for forward compatibility
 // for forward compatibility
@@ -174,11 +185,13 @@ type MedicalServer interface {
 	// 取消认领(经销商/医疗机构)
 	// 取消认领(经销商/医疗机构)
 	UnClaimed(context.Context, *UnclaimedReq) (*CommonResp, error)
 	UnClaimed(context.Context, *UnclaimedReq) (*CommonResp, error)
 	// 是否认领(经销商/医疗机构)
 	// 是否认领(经销商/医疗机构)
-	IsClaimed(context.Context, *IsClaimedReq) (*CommonResp, error)
+	IsClaimed(context.Context, *IsClaimedReq) (*IsClaimedResp, error)
 	// 我认领的经销商列表
 	// 我认领的经销商列表
-	ClaimedDistributorList(context.Context, *ClaimedReq) (*CommonResp, error)
+	ClaimedDistributorList(context.Context, *ClaimedReq) (*EntClaimListResp, error)
 	// 我认领的医疗机构列表
 	// 我认领的医疗机构列表
-	ClaimedInstitutionList(context.Context, *ClaimedReq) (*CommonResp, error)
+	ClaimedInstitutionList(context.Context, *ClaimedReq) (*EntClaimListResp, error)
+	// 招标动态
+	GetNewMsg(context.Context, *GetNewMsgReq) (*GetNewMsgResp, error)
 	mustEmbedUnimplementedMedicalServer()
 	mustEmbedUnimplementedMedicalServer()
 }
 }
 
 
@@ -210,15 +223,18 @@ func (UnimplementedMedicalServer) Claim(context.Context, *ClaimReq) (*CommonResp
 func (UnimplementedMedicalServer) UnClaimed(context.Context, *UnclaimedReq) (*CommonResp, error) {
 func (UnimplementedMedicalServer) UnClaimed(context.Context, *UnclaimedReq) (*CommonResp, error) {
 	return nil, status.Errorf(codes.Unimplemented, "method UnClaimed not implemented")
 	return nil, status.Errorf(codes.Unimplemented, "method UnClaimed not implemented")
 }
 }
-func (UnimplementedMedicalServer) IsClaimed(context.Context, *IsClaimedReq) (*CommonResp, error) {
+func (UnimplementedMedicalServer) IsClaimed(context.Context, *IsClaimedReq) (*IsClaimedResp, error) {
 	return nil, status.Errorf(codes.Unimplemented, "method IsClaimed not implemented")
 	return nil, status.Errorf(codes.Unimplemented, "method IsClaimed not implemented")
 }
 }
-func (UnimplementedMedicalServer) ClaimedDistributorList(context.Context, *ClaimedReq) (*CommonResp, error) {
+func (UnimplementedMedicalServer) ClaimedDistributorList(context.Context, *ClaimedReq) (*EntClaimListResp, error) {
 	return nil, status.Errorf(codes.Unimplemented, "method ClaimedDistributorList not implemented")
 	return nil, status.Errorf(codes.Unimplemented, "method ClaimedDistributorList not implemented")
 }
 }
-func (UnimplementedMedicalServer) ClaimedInstitutionList(context.Context, *ClaimedReq) (*CommonResp, error) {
+func (UnimplementedMedicalServer) ClaimedInstitutionList(context.Context, *ClaimedReq) (*EntClaimListResp, error) {
 	return nil, status.Errorf(codes.Unimplemented, "method ClaimedInstitutionList not implemented")
 	return nil, status.Errorf(codes.Unimplemented, "method ClaimedInstitutionList not implemented")
 }
 }
+func (UnimplementedMedicalServer) GetNewMsg(context.Context, *GetNewMsgReq) (*GetNewMsgResp, error) {
+	return nil, status.Errorf(codes.Unimplemented, "method GetNewMsg not implemented")
+}
 func (UnimplementedMedicalServer) mustEmbedUnimplementedMedicalServer() {}
 func (UnimplementedMedicalServer) mustEmbedUnimplementedMedicalServer() {}
 
 
 // UnsafeMedicalServer may be embedded to opt out of forward compatibility for this service.
 // UnsafeMedicalServer may be embedded to opt out of forward compatibility for this service.
@@ -430,6 +446,24 @@ func _Medical_ClaimedInstitutionList_Handler(srv interface{}, ctx context.Contex
 	return interceptor(ctx, in, info, handler)
 	return interceptor(ctx, in, info, handler)
 }
 }
 
 
+func _Medical_GetNewMsg_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+	in := new(GetNewMsgReq)
+	if err := dec(in); err != nil {
+		return nil, err
+	}
+	if interceptor == nil {
+		return srv.(MedicalServer).GetNewMsg(ctx, in)
+	}
+	info := &grpc.UnaryServerInfo{
+		Server:     srv,
+		FullMethod: "/medical.Medical/GetNewMsg",
+	}
+	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+		return srv.(MedicalServer).GetNewMsg(ctx, req.(*GetNewMsgReq))
+	}
+	return interceptor(ctx, in, info, handler)
+}
+
 // Medical_ServiceDesc is the grpc.ServiceDesc for Medical service.
 // Medical_ServiceDesc is the grpc.ServiceDesc for Medical service.
 // It's only intended for direct use with grpc.RegisterService,
 // It's only intended for direct use with grpc.RegisterService,
 // and not to be introspected or modified (even as a copy)
 // and not to be introspected or modified (even as a copy)
@@ -481,6 +515,10 @@ var Medical_ServiceDesc = grpc.ServiceDesc{
 			MethodName: "ClaimedInstitutionList",
 			MethodName: "ClaimedInstitutionList",
 			Handler:    _Medical_ClaimedInstitutionList_Handler,
 			Handler:    _Medical_ClaimedInstitutionList_Handler,
 		},
 		},
+		{
+			MethodName: "GetNewMsg",
+			Handler:    _Medical_GetNewMsg_Handler,
+		},
 	},
 	},
 	Streams:  []grpc.StreamDesc{},
 	Streams:  []grpc.StreamDesc{},
 	Metadata: "medical.proto",
 	Metadata: "medical.proto",

+ 2 - 2
service/InstitutionService_test.go

@@ -13,7 +13,7 @@ var EntClaimSrv EntClaimService
 
 
 func init() {
 func init() {
 	entity.Mysql = &mysql.Mysql{
 	entity.Mysql = &mysql.Mysql{
-		Address:      "192.168.3.217:4000",
+		Address:      "192.168.3.14:4000",
 		UserName:     "root",
 		UserName:     "root",
 		PassWord:     "=PDT49#80Z!RVv52_z",
 		PassWord:     "=PDT49#80Z!RVv52_z",
 		DBName:       "medical_fileld_data",
 		DBName:       "medical_fileld_data",
@@ -22,7 +22,7 @@ func init() {
 	}
 	}
 	entity.Mysql.Init()
 	entity.Mysql.Init()
 	BaseMysqlConn := &mysql.Mysql{
 	BaseMysqlConn := &mysql.Mysql{
-		Address:      "192.168.3.217:4000",
+		Address:      "192.168.3.14:4000",
 		UserName:     "root",
 		UserName:     "root",
 		PassWord:     "=PDT49#80Z!RVv52_z",
 		PassWord:     "=PDT49#80Z!RVv52_z",
 		DBName:       "base_service",
 		DBName:       "base_service",

+ 25 - 3
service/claim.go

@@ -21,6 +21,9 @@ func NewEntClaimSrv(conn *entity.Conn) *EntClaimService {
 
 
 // Claim 认领
 // Claim 认领
 func (e *EntClaimService) Claim(data *entity.EntClaim) bool {
 func (e *EntClaimService) Claim(data *entity.EntClaim) bool {
+	if e.IsClaimed(data.UserId, data.AppId, data.EntId, data.Type) {
+		return true
+	}
 	return e.BaseMysql.Insert(entity.TableDomainEntClaim, common.StructToMapMore(data)) > 0
 	return e.BaseMysql.Insert(entity.TableDomainEntClaim, common.StructToMapMore(data)) > 0
 }
 }
 
 
@@ -50,7 +53,7 @@ func (e *EntClaimService) Unclaimed(id, userId int) bool {
 }
 }
 
 
 // IsClaimed 是否认领
 // IsClaimed 是否认领
-func (e *EntClaimService) IsClaimed(userId int, appId string, entId int, typeCode int) bool {
+func (e *EntClaimService) IsClaimed(userId int, appId string, entId string, typeCode int) bool {
 	query := map[string]interface{}{
 	query := map[string]interface{}{
 		"user_id": userId,
 		"user_id": userId,
 		"type":    typeCode,
 		"type":    typeCode,
@@ -69,7 +72,7 @@ func (e *EntClaimService) DistributorList(userId int, appId string, page int, pa
 		"type":    entity.TypeDistributor,
 		"type":    entity.TypeDistributor,
 		"status":  entity.StatusClaimed,
 		"status":  entity.StatusClaimed,
 	}
 	}
-	field := "id,appid,user_id,ent_id,ent_name,address,create_time"
+	field := "id,appid,user_id,ent_id,ent_name,create_time"
 	order := "create_time desc"
 	order := "create_time desc"
 	total := e.BaseMysql.Count(entity.TableDomainEntClaim, query)
 	total := e.BaseMysql.Count(entity.TableDomainEntClaim, query)
 	if total == 0 {
 	if total == 0 {
@@ -86,7 +89,7 @@ func (e *EntClaimService) InstitutionList(userId int, appId string, page int, pa
 		"type":    entity.TypeInstitution,
 		"type":    entity.TypeInstitution,
 		"status":  entity.StatusClaimed,
 		"status":  entity.StatusClaimed,
 	}
 	}
-	field := "id,appid,user_id,ent_id,ent_name,address,create_time"
+	field := "id,appid,user_id,ent_id,ent_name,create_time"
 	order := "create_time desc"
 	order := "create_time desc"
 	total := e.BaseMysql.Count(entity.TableDomainEntClaim, query)
 	total := e.BaseMysql.Count(entity.TableDomainEntClaim, query)
 	if total == 0 {
 	if total == 0 {
@@ -94,3 +97,22 @@ func (e *EntClaimService) InstitutionList(userId int, appId string, page int, pa
 	}
 	}
 	return e.BaseMysql.Find(entity.TableDomainEntClaim, query, field, order, (page-1)*pageSize, pageSize), int(total)
 	return e.BaseMysql.Find(entity.TableDomainEntClaim, query, field, order, (page-1)*pageSize, pageSize), int(total)
 }
 }
+
+// GetInstitution 获取机构信息
+func (e EntClaimService) GetInstitution(id string) *map[string]interface{} {
+	query := map[string]interface{}{
+		"company_id": id,
+	}
+	field := "company_name,establish_date,company_address,capital,company_phone"
+	return e.GlobalCommonData.FindOne(entity.TableCompanyBasInfo, query, field, "")
+}
+
+// GetInstitutionByIds GetInstitution 获取机构信息
+func (e EntClaimService) GetInstitutionByIds(ids []interface{}) *[]map[string]interface{} {
+	query := map[string]interface{}{
+
+		"company_id": map[string]interface{}{"in": ids},
+	}
+	field := "company_id,company_name,establish_date,company_address,capital,company_phone"
+	return e.GlobalCommonData.Find(entity.TableCompanyBasInfo, query, field, "", 0, 0)
+}

+ 62 - 13
service/claim_test.go

@@ -1,8 +1,10 @@
 package service
 package service
 
 
 import (
 import (
+	"app.yhyue.com/moapp/jybase/common"
+	"app.yhyue.com/moapp/jybase/encrypt"
 	"bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/entity"
 	"bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/entity"
-	"reflect"
+	"fmt"
 	"testing"
 	"testing"
 )
 )
 
 
@@ -18,7 +20,11 @@ func TestEntClaimService_Claim(t *testing.T) {
 		want bool
 		want bool
 	}{
 	}{
 		{"认领医疗机构", args{
 		{"认领医疗机构", args{
-			data: &entity.EntClaim{UserId: 1, AppId: "10000", EntId: "11", EntName: "877", Status: entity.StatusClaimed, Type: entity.TypeInstitution, Address: "2223", EstablishDate: "2022", RegisterCapital: "dd", Phone: "18238182402", CreateTime: "2022-08-19 15:08:00"},
+			data: &entity.EntClaim{UserId: 1, AppId: "10000", EntId: "1122", EntName: "877", Status: entity.StatusClaimed, Type: entity.TypeInstitution, CreateTime: "2022-08-19 15:08:00"},
+		}, 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"},
 		}, true,
 		}, true,
 		},
 		},
 	}
 	}
@@ -30,6 +36,7 @@ func TestEntClaimService_Claim(t *testing.T) {
 			}
 			}
 		})
 		})
 	}
 	}
+
 }
 }
 
 
 // 我认领的经销商的列表
 // 我认领的经销商的列表
@@ -46,14 +53,17 @@ func TestEntClaimService_DistributorList(t *testing.T) {
 		want *[]map[string]interface{}
 		want *[]map[string]interface{}
 	}{
 	}{
 		{
 		{
-			name: "我认领的医疗机构", args: args{userId: 1, appId: "10000", page: 1, pageSize: 10}, want: nil,
+			name: "我认领的经销商", args: args{userId: 1, appId: "10000", page: 0, pageSize: 10}, want: nil,
+		},
+		{
+			name: "我认领的经销商-2", args: args{userId: 8, appId: "10000", page: 0, pageSize: 10}, want: nil,
 		},
 		},
 	}
 	}
 	for _, tt := range tests {
 	for _, tt := range tests {
 		t.Run(tt.name, func(t *testing.T) {
 		t.Run(tt.name, func(t *testing.T) {
-			if got, _ := EntClaimSrv.DistributorList(tt.args.userId, tt.args.appId, tt.args.page, tt.args.pageSize); !reflect.DeepEqual(got, tt.want) {
-				t.Errorf("DistributorList() = %v, want %v", got, tt.want)
-			}
+			got, total := EntClaimSrv.DistributorList(tt.args.userId, tt.args.appId, tt.args.page, tt.args.pageSize)
+			fmt.Println(got, total)
+			t.Log(got, total)
 		})
 		})
 	}
 	}
 }
 }
@@ -71,13 +81,17 @@ func TestEntClaimService_InstitutionList(t *testing.T) {
 		args args
 		args args
 		want *[]map[string]interface{}
 		want *[]map[string]interface{}
 	}{
 	}{
-		// TODO: Add test cases.
+		{
+			name: "我认领的医疗机构", args: args{userId: 22, appId: "10000", page: 0, pageSize: 10}, want: nil,
+		},
+		{
+			name: "我认领的医疗机构-2", args: args{userId: 3, appId: "10000", page: 0, pageSize: 10}, want: nil,
+		},
 	}
 	}
 	for _, tt := range tests {
 	for _, tt := range tests {
 		t.Run(tt.name, func(t *testing.T) {
 		t.Run(tt.name, func(t *testing.T) {
-			if got, _ := EntClaimSrv.InstitutionList(tt.args.userId, tt.args.appId, tt.args.page, tt.args.pageSize); !reflect.DeepEqual(got, tt.want) {
-				t.Errorf("InstitutionList() = %v, want %v", got, tt.want)
-			}
+			got, total := EntClaimSrv.InstitutionList(tt.args.userId, tt.args.appId, tt.args.page, tt.args.pageSize)
+			t.Log(got, total)
 		})
 		})
 	}
 	}
 }
 }
@@ -87,7 +101,7 @@ func TestEntClaimService_IsClaimed(t *testing.T) {
 	type args struct {
 	type args struct {
 		userId   int
 		userId   int
 		appId    string
 		appId    string
-		entId    int
+		entId    string
 		typeCode int
 		typeCode int
 	}
 	}
 	tests := []struct {
 	tests := []struct {
@@ -95,7 +109,7 @@ func TestEntClaimService_IsClaimed(t *testing.T) {
 		args args
 		args args
 		want bool
 		want bool
 	}{
 	}{
-		// TODO: Add test cases.
+		{"是否认领", args{userId: 1, typeCode: 1, entId: "1", appId: "10000"}, true},
 	}
 	}
 	for _, tt := range tests {
 	for _, tt := range tests {
 		t.Run(tt.name, func(t *testing.T) {
 		t.Run(tt.name, func(t *testing.T) {
@@ -117,7 +131,15 @@ func TestEntClaimService_Unclaimed(t *testing.T) {
 		args args
 		args args
 		want bool
 		want bool
 	}{
 	}{
-		// TODO: Add test cases.
+		{
+			"取消认领", args{userId: 1, id: 2}, true,
+		},
+		{
+			"取消认领-2", args{userId: 100, id: 2}, false,
+		},
+		{
+			"取消认领-3", args{userId: 100, id: 900009}, false,
+		},
 	}
 	}
 	for _, tt := range tests {
 	for _, tt := range tests {
 		t.Run(tt.name, func(t *testing.T) {
 		t.Run(tt.name, func(t *testing.T) {
@@ -127,3 +149,30 @@ func TestEntClaimService_Unclaimed(t *testing.T) {
 		})
 		})
 	}
 	}
 }
 }
+
+// 获取企业基本信息
+func TestEntClaimService_GetInstitution(t *testing.T) {
+	type args struct {
+		id string
+	}
+	tests := []struct {
+		name string
+		args args
+		want *map[string]interface{}
+	}{
+		{
+			"获取企业基本信息", args{id: ""}, nil,
+		},
+	}
+	for _, tt := range tests {
+		t.Run(tt.name, func(t *testing.T) {
+			got := EntClaimSrv.GetInstitution(tt.args.id)
+			t.Log(got)
+
+		})
+	}
+}
+func TestName(t *testing.T) {
+	s := encrypt.SE.Encode2Hex(common.ObjToString("90009"))
+	fmt.Print(s)
+}

+ 64 - 0
service/coverage

@@ -0,0 +1,64 @@
+mode: set
+bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/AuthService.go:14.76,19.17 2 1
+bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/AuthService.go:29.2,29.34 1 1
+bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/AuthService.go:19.17,20.32 1 1
+bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/AuthService.go:20.32,22.4 1 1
+bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/AuthService.go:23.8,24.35 1 1
+bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/AuthService.go:24.35,26.4 1 1
+bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/AuthService.go:29.34,41.10 3 1
+bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/AuthService.go:41.10,43.4 1 1
+bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/AuthService.go:43.9,46.4 2 0
+bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/AuthService.go:47.8,62.13 3 1
+bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/AuthService.go:62.13,64.4 1 1
+bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/AuthService.go:64.9,67.4 2 0
+bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/AuthService.go:72.82,78.2 2 1
+bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/InstitutionService.go:10.93,16.2 3 1
+bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/claim.go:16.57,20.2 1 1
+bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/claim.go:23.61,25.2 1 1
+bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/claim.go:28.58,34.32 3 0
+bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/claim.go:39.2,40.23 2 0
+bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/claim.go:45.2,49.70 2 0
+bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/claim.go:34.32,37.3 2 0
+bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/claim.go:40.23,43.3 2 0
+bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/claim.go:53.93,61.2 2 0
+bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/claim.go:64.126,75.16 5 1
+bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/claim.go:78.2,78.115 1 0
+bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/claim.go:75.16,77.3 1 1
+bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/claim.go:82.126,92.16 5 0
+bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/claim.go:95.2,95.115 1 0
+bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/claim.go:92.16,94.3 1 0
+bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/portrait.go:28.54,32.2 1 1
+bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/portrait.go:38.83,40.21 1 1
+bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/portrait.go:44.2,50.36 2 1
+bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/portrait.go:54.2,57.37 4 1
+bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/portrait.go:63.2,65.47 3 1
+bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/portrait.go:69.2,88.26 3 1
+bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/portrait.go:40.21,42.3 1 1
+bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/portrait.go:50.36,52.3 1 1
+bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/portrait.go:57.37,61.3 3 1
+bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/portrait.go:65.47,67.3 1 1
+bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/portrait.go:98.119,100.21 1 1
+bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/portrait.go:103.2,107.18 4 1
+bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/portrait.go:113.2,117.48 4 1
+bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/portrait.go:148.2,148.53 1 0
+bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/portrait.go:100.21,102.3 1 0
+bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/portrait.go:107.18,109.17 2 1
+bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/portrait.go:109.17,111.4 1 0
+bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/portrait.go:117.48,121.43 4 1
+bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/portrait.go:124.3,125.30 2 1
+bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/portrait.go:146.3,146.26 1 1
+bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/portrait.go:121.43,123.4 1 0
+bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/portrait.go:125.30,126.18 1 1
+bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/portrait.go:137.4,144.32 2 1
+bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/portrait.go:126.18,127.24 1 1
+bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/portrait.go:131.5,132.20 2 1
+bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/portrait.go:135.5,135.67 1 1
+bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/portrait.go:127.24,130.6 2 1
+bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/portrait.go:132.20,134.6 1 0
+bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/portrait.go:152.83,160.2 4 1
+bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/portrait.go:163.66,170.25 6 1
+bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/portrait.go:173.2,173.31 1 1
+bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/portrait.go:170.25,172.3 1 1
+bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/portrait.go:175.34,176.29 1 0
+bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/portrait.go:179.2,179.45 1 0
+bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/portrait.go:176.29,178.3 1 0

+ 365 - 30
service/coverage.html

@@ -59,22 +59,21 @@
 				
 				
 				<option value="file1">bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/InstitutionService.go (100.0%)</option>
 				<option value="file1">bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/InstitutionService.go (100.0%)</option>
 				
 				
+<<<<<<< HEAD
+				<option value="file2">bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/claim.go (27.6%)</option>
+				
+				<option value="file3">bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/portrait.go (88.1%)</option>
+=======
+				<option value="file2">bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/claim.go (93.5%)</option>
+>>>>>>> 10627a5dbc739e87e4aa15f75c91adb5de38af2d
+				
 				</select>
 				</select>
 			</div>
 			</div>
 			<div id="legend">
 			<div id="legend">
 				<span>not tracked</span>
 				<span>not tracked</span>
 			
 			
-				<span class="cov0">no coverage</span>
-				<span class="cov1">low coverage</span>
-				<span class="cov2">*</span>
-				<span class="cov3">*</span>
-				<span class="cov4">*</span>
-				<span class="cov5">*</span>
-				<span class="cov6">*</span>
-				<span class="cov7">*</span>
-				<span class="cov8">*</span>
-				<span class="cov9">*</span>
-				<span class="cov10">high coverage</span>
+				<span class="cov0">not covered</span>
+				<span class="cov8">covered</span>
 			
 			
 			</div>
 			</div>
 		</div>
 		</div>
@@ -93,55 +92,59 @@ import (
 type AuthService struct{}
 type AuthService struct{}
 
 
 //认证信息保存
 //认证信息保存
-func (b AuthService) UserAuthInfoSave(in *medical.UserInfo) (bool, string) <span class="cov10" title="4">{
+func (b AuthService) UserAuthInfoSave(in *medical.UserInfo) (bool, string) <span class="cov8" title="1">{
         //先判断用户是否存在
         //先判断用户是否存在
         user := entity.BaseMysql.FindOne(entity.DOMAIN_CAPITAL_RETENTION, map[string]interface{}{
         user := entity.BaseMysql.FindOne(entity.DOMAIN_CAPITAL_RETENTION, map[string]interface{}{
-                "user_id": in.UserId,"appid":in.Appid,
+                "user_id": in.UserId, "appid": in.Appid,
         }, "id", "")
         }, "id", "")
-        if user != nil </span><span class="cov5" title="2">{
-                if in.OperationType == "add" </span><span class="cov1" title="1">{
+        if user != nil </span><span class="cov8" title="1">{
+                if in.OperationType == "add" </span><span class="cov8" title="1">{
                         return false, "用户已验证"
                         return false, "用户已验证"
                 }</span>
                 }</span>
-        } else<span class="cov5" title="2"> {
-                if in.OperationType == "update" </span><span class="cov1" title="1">{
+        } else<span class="cov8" title="1"> {
+                if in.OperationType == "update" </span><span class="cov8" title="1">{
                         return false, "用户未认证,不可修改"
                         return false, "用户未认证,不可修改"
                 }</span>
                 }</span>
         }
         }
 
 
-        <span class="cov5" title="2">if in.OperationType == "update" </span><span class="cov1" title="1">{
+        <span class="cov8" title="1">if in.OperationType == "update" </span><span class="cov8" title="1">{
                 //修改处理
                 //修改处理
                 data := map[string]interface{}{
                 data := map[string]interface{}{
-                        "name":  in.Name,
-                        "phone": in.Phone,
+                        "name":       in.Name,
+                        "phone":      in.Phone,
                         "position":   in.Position,
                         "position":   in.Position,
                         "department": in.Department,
                         "department": in.Department,
-                        "mail":  in.Mail,
+                        "mail":       in.Mail,
                         "ent_code":   in.EntCode,
                         "ent_code":   in.EntCode,
                         "ent_name":   in.EntName,
                         "ent_name":   in.EntName,
                 }
                 }
-                ok1 := entity.BaseMysql.Update(entity.DOMAIN_CAPITAL_RETENTION, map[string]interface{}{"user_id": in.UserId,"appid":in.Appid}, data)
+                ok1 := entity.BaseMysql.Update(entity.DOMAIN_CAPITAL_RETENTION, map[string]interface{}{"user_id": in.UserId, "appid": in.Appid}, data)
+<<<<<<< HEAD
+                if ok1 </span><span class="cov8" title="1">{
+=======
                 if ok1 </span><span class="cov1" title="1">{
                 if ok1 </span><span class="cov1" title="1">{
+>>>>>>> 10627a5dbc739e87e4aa15f75c91adb5de38af2d
                         return true, ""
                         return true, ""
                 }</span> else<span class="cov0" title="0"> {
                 }</span> else<span class="cov0" title="0"> {
                         log.Println(fmt.Sprintf("认证修改失败:入参:%v:%v,", in.UserId, data))
                         log.Println(fmt.Sprintf("认证修改失败:入参:%v:%v,", in.UserId, data))
                         return false, "修改失败"
                         return false, "修改失败"
                 }</span>
                 }</span>
-        } else<span class="cov1" title="1"> {
+        } else<span class="cov8" title="1"> {
                 //新增处理
                 //新增处理
                 data := map[string]interface{}{
                 data := map[string]interface{}{
-                        "name":   in.Name,
-                        "phone":  in.Phone,
+                        "name":        in.Name,
+                        "phone":       in.Phone,
                         "position":    in.Position,
                         "position":    in.Position,
                         "department":  in.Department,
                         "department":  in.Department,
-                        "mail":   in.Mail,
+                        "mail":        in.Mail,
                         "ent_code":    in.EntCode,
                         "ent_code":    in.EntCode,
                         "ent_name":    in.EntName,
                         "ent_name":    in.EntName,
                         "user_id":     in.UserId,
                         "user_id":     in.UserId,
                         "create_time": time.Now().Local(),
                         "create_time": time.Now().Local(),
-                        "appid":in.Appid,
+                        "appid":       in.Appid,
                 }
                 }
                 ok := entity.BaseMysql.Insert(entity.DOMAIN_CAPITAL_RETENTION, data)
                 ok := entity.BaseMysql.Insert(entity.DOMAIN_CAPITAL_RETENTION, data)
-                if ok &gt; 0 </span><span class="cov1" title="1">{
+                if ok &gt; 0 </span><span class="cov8" title="1">{
                         return true, ""
                         return true, ""
                 }</span> else<span class="cov0" title="0"> {
                 }</span> else<span class="cov0" title="0"> {
                         log.Println(fmt.Sprintf("认证失败:参数:%v", data))
                         log.Println(fmt.Sprintf("认证失败:参数:%v", data))
@@ -151,10 +154,10 @@ func (b AuthService) UserAuthInfoSave(in *medical.UserInfo) (bool, string) <span
 }
 }
 
 
 //认证信息查询
 //认证信息查询
-func (b AuthService) UserAuthInfo(in *medical.CommonReq) *map[string]interface{} <span class="cov5" title="2">{
+func (b AuthService) UserAuthInfo(in *medical.CommonReq) *map[string]interface{} <span class="cov8" title="1">{
         //先判断用户是否存在
         //先判断用户是否存在
         user := entity.BaseMysql.FindOne(entity.DOMAIN_CAPITAL_RETENTION, map[string]interface{}{
         user := entity.BaseMysql.FindOne(entity.DOMAIN_CAPITAL_RETENTION, map[string]interface{}{
-                "user_id": in.UserId,"appid":in.Appid,
+                "user_id": in.UserId, "appid": in.Appid,
         }, "id", "")
         }, "id", "")
         return user
         return user
 }</span>
 }</span>
@@ -176,6 +179,338 @@ func (b InstitutionService) GetFilterItem() (levelList, typeList *[]map[string]i
         typeList = entity.Mysql.Find(entity.CODE_MEDICAL_INSTITUTION_TYPE, nil, "*", "", -1, -1)
         typeList = entity.Mysql.Find(entity.CODE_MEDICAL_INSTITUTION_TYPE, nil, "*", "", -1, -1)
         return
         return
 }</span>
 }</span>
+</pre>
+		
+		<pre class="file" id="file2" style="display: none">package service
+
+import (
+        "app.yhyue.com/moapp/jybase/common"
+        "app.yhyue.com/moapp/jybase/date"
+        "bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/entity"
+        "github.com/zeromicro/go-zero/core/logx"
+)
+
+// EntClaimService 企业认领
+type EntClaimService struct {
+        *entity.Conn
+}
+
+// NewEntClaimSrv 创建一个EntClaimSrv实例
+<<<<<<< HEAD
+func NewEntClaimSrv(conn *entity.Conn) *EntClaimService <span class="cov8" title="1">{
+=======
+func NewEntClaimSrv(conn *entity.Conn) *EntClaimService <span class="cov1" title="1">{
+>>>>>>> 10627a5dbc739e87e4aa15f75c91adb5de38af2d
+        return &amp;EntClaimService{
+                conn,
+        }
+}</span>
+
+// Claim 认领
+<<<<<<< HEAD
+func (e *EntClaimService) Claim(data *entity.EntClaim) bool <span class="cov8" title="1">{
+        return e.BaseMysql.Insert(entity.TableDomainEntClaim, common.StructToMapMore(data)) &gt; 0
+}</span>
+
+// Unclaimed // 取消认领
+func (e *EntClaimService) Unclaimed(id, userId int) bool <span class="cov0" title="0">{
+=======
+func (e *EntClaimService) Claim(data *entity.EntClaim) bool <span class="cov6" title="2">{
+        if e.IsClaimed(data.UserId, data.AppId, data.EntId, data.Type) </span><span class="cov0" title="0">{
+                return true
+        }</span>
+        <span class="cov6" title="2">return e.BaseMysql.Insert(entity.TableDomainEntClaim, common.StructToMapMore(data)) &gt; 0</span>
+}
+
+// Unclaimed // 取消认领
+func (e *EntClaimService) Unclaimed(id, userId int) bool <span class="cov10" title="3">{
+>>>>>>> 10627a5dbc739e87e4aa15f75c91adb5de38af2d
+        query := map[string]interface{}{
+                "id": id,
+        }
+        // 1. 查询该条数据
+        rs := e.BaseMysql.FindOne(entity.TableDomainEntClaim, query, "user_id", "")
+<<<<<<< HEAD
+        if rs == nil || len(*rs) == 0 </span><span class="cov0" title="0">{
+=======
+        if rs == nil || len(*rs) == 0 </span><span class="cov1" title="1">{
+>>>>>>> 10627a5dbc739e87e4aa15f75c91adb5de38af2d
+                logx.Errorf("取消认领:无效的id %v", id)
+                return false
+        }</span>
+        // 2. 存在则判断是否是该用户的
+<<<<<<< HEAD
+        <span class="cov0" title="0">rsUerId := common.IntAll((*rs)["user_id"])
+        if rsUerId != userId </span><span class="cov0" title="0">{
+=======
+        <span class="cov6" title="2">rsUerId := common.IntAll((*rs)["user_id"])
+        if rsUerId != userId </span><span class="cov1" title="1">{
+>>>>>>> 10627a5dbc739e87e4aa15f75c91adb5de38af2d
+                logx.Errorf("取消认领:id[%v]与用户id[%v]不匹配 ", id, userId)
+                return false
+        }</span>
+        // 3. 取消认领
+<<<<<<< HEAD
+        <span class="cov0" title="0">update := map[string]interface{}{
+=======
+        <span class="cov1" title="1">update := map[string]interface{}{
+>>>>>>> 10627a5dbc739e87e4aa15f75c91adb5de38af2d
+                "status":      entity.StatusUnClaimed,
+                "update_time": date.NowFormat(date.Date_Full_Layout),
+        }
+        return e.BaseMysql.Update(entity.TableDomainEntClaim, query, update)</span>
+}
+
+// IsClaimed 是否认领
+<<<<<<< HEAD
+func (e *EntClaimService) IsClaimed(userId int, appId string, entId int, typeCode int) bool <span class="cov0" title="0">{
+=======
+func (e *EntClaimService) IsClaimed(userId int, appId string, entId string, typeCode int) bool <span class="cov10" title="3">{
+>>>>>>> 10627a5dbc739e87e4aa15f75c91adb5de38af2d
+        query := map[string]interface{}{
+                "user_id": userId,
+                "type":    typeCode,
+                "ent_id":  entId,
+                "status":  entity.StatusClaimed,
+        }
+        return e.BaseMysql.Count(entity.TableDomainEntClaim, query) &gt; 0
+}</span>
+
+// DistributorList 关注的经销商列表
+<<<<<<< HEAD
+func (e *EntClaimService) DistributorList(userId int, appId string, page int, pageSize int) (*[]map[string]interface{}, int) <span class="cov8" title="1">{
+=======
+func (e *EntClaimService) DistributorList(userId int, appId string, page int, pageSize int) (*[]map[string]interface{}, int) <span class="cov6" title="2">{
+>>>>>>> 10627a5dbc739e87e4aa15f75c91adb5de38af2d
+
+        query := map[string]interface{}{
+                "user_id": userId,
+                "appid":   appId,
+                "type":    entity.TypeDistributor,
+                "status":  entity.StatusClaimed,
+        }
+        field := "id,appid,user_id,ent_id,ent_name,address,create_time"
+        order := "create_time desc"
+        total := e.BaseMysql.Count(entity.TableDomainEntClaim, query)
+<<<<<<< HEAD
+        if total == 0 </span><span class="cov8" title="1">{
+=======
+        if total == 0 </span><span class="cov6" title="2">{
+>>>>>>> 10627a5dbc739e87e4aa15f75c91adb5de38af2d
+                return nil, 0
+        }</span>
+        <span class="cov0" title="0">return e.BaseMysql.Find(entity.TableDomainEntClaim, query, field, order, (page-1)*pageSize, pageSize), int(total)</span>
+}
+
+// InstitutionList  我关注的医疗机构列表
+<<<<<<< HEAD
+func (e *EntClaimService) InstitutionList(userId int, appId string, page int, pageSize int) (*[]map[string]interface{}, int) <span class="cov0" title="0">{
+=======
+func (e *EntClaimService) InstitutionList(userId int, appId string, page int, pageSize int) (*[]map[string]interface{}, int) <span class="cov6" title="2">{
+>>>>>>> 10627a5dbc739e87e4aa15f75c91adb5de38af2d
+        query := map[string]interface{}{
+                "user_id": userId,
+                "appid":   appId,
+                "type":    entity.TypeInstitution,
+                "status":  entity.StatusClaimed,
+        }
+        field := "id,appid,user_id,ent_id,ent_name,address,create_time"
+        order := "create_time desc"
+        total := e.BaseMysql.Count(entity.TableDomainEntClaim, query)
+<<<<<<< HEAD
+        if total == 0 </span><span class="cov0" title="0">{
+                return nil, 0
+        }</span>
+        <span class="cov0" title="0">return e.BaseMysql.Find(entity.TableDomainEntClaim, query, field, order, (page-1)*pageSize, pageSize), int(total)</span>
+}
+</pre>
+		
+		<pre class="file" id="file3" style="display: none">// @Description   画像相关
+package service
+
+import (
+        "errors"
+        "fmt"
+        "log"
+        "regexp"
+        "strings"
+        "time"
+
+        . "app.yhyue.com/moapp/jybase/common"
+        "app.yhyue.com/moapp/jybase/encrypt"
+        elastic "app.yhyue.com/moapp/jybase/esv1"
+        "bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/entity"
+)
+
+//画像
+type PortraitService struct {
+        *entity.Conn
+}
+
+var ClearHtml = regexp.MustCompile("&lt;[^&gt;]*&gt;")
+
+// @description           生成结构体
+// @param                     conn 数据库实例
+// @return                    Portrait 画像实例
+func NewPortrait(conn *entity.Conn) *PortraitService <span class="cov8" title="1">{
+        return &amp;PortraitService{
+                conn,
+        }
+}</span>
+
+// @description           获取画像内容
+// @param                     companyId 机构id
+// @return                    PortraitInfo 画像信息
+// @return                    error 错误信息
+func (this *PortraitService) Info(companyId string) (*entity.PortraitInfo, error) <span class="cov8" title="1">{
+        //判断是否存在companyid
+        if companyId == "" </span><span class="cov8" title="1">{
+                return nil, errors.New(entity.NO_DATA_ERROR_MSG)
+        }</span>
+        //获取信息
+        <span class="cov8" title="1">data := this.Mysql.SelectBySql(fmt.Sprintf(`SELECT a.sdequipment_code,a.area_code,a.beds,a.visit_perday,a.doctorsnum,a.address,a.website,a.business_type,a.equipment, e.equipment sdleveltypeequip ,a.mi_name,a.establish_date,b.name LEVEL,c.name miType,d.class FROM %s a 
+                                                                                                        LEFT JOIN %s b ON a.level_code=b.code 
+                                                                                                        LEFT JOIN %s c ON c.code =a.mi_type_code
+                                                                                                        LEFT JOIN (SELECT GROUP_CONCAT(DISTINCT departname_class1 SEPARATOR  '、') class,company_id FROM %s WHERE company_id=?)  AS d ON d.company_id =a.company_id
+                                                                                                        left join %s e on e.code =a.sdequipment_code
+                                                                                                        WHERE  a.company_id=?`, entity.Institution_baseinfo, entity.Code_level, entity.Code_type, entity.Institution_department, entity.Code_sdleveltypeequip), companyId, companyId)
+        if data == nil || len(*data) == 0 </span><span class="cov8" title="1">{
+                return nil, errors.New(entity.NO_DATA_ERROR_MSG)
+        }</span>
+        //获取area_code 省份,城市,区县
+        <span class="cov8" title="1">area, city, district := "", "", ""
+        rdata := (*data)[0]
+        adata := this.CommonMysql.SelectBySql(fmt.Sprintf(`select area,city,district from %s where code =? limit 1`, entity.Code_area), ObjToString(rdata["area_code"]))
+        if adata != nil &amp;&amp; len(*adata) &gt; 0 </span><span class="cov8" title="1">{
+                area = ObjToString((*adata)[0]["area"])
+                city = ObjToString((*adata)[0]["city"])
+                district = ObjToString((*adata)[0]["district"])
+        }</span>
+        //医疗设备如果基本信息表中没有,则根据sdequipment_code、code联合查询得到equipment
+        <span class="cov8" title="1">equipment := ObjToString(rdata["equipment"])
+        sdleveltypeequip := ObjToString(rdata["sdleveltypeequip"])
+        if equipment == "" &amp;&amp; sdleveltypeequip != "" </span><span class="cov8" title="1">{
+                equipment = ObjToString(rdata["sdleveltypeequip"])
+        }</span>
+        //TODO 是否关注还没搞呢
+        <span class="cov8" title="1">isFollow := 0
+        portraitInfo := &amp;entity.PortraitInfo{
+                Beds:          Int64All(rdata["beds"]),
+                VisitPerday:   Int64All(rdata["visit_perday"]),      // 门诊量/日
+                Doctorsnum:    Int64All(rdata["doctorsnum"]),        //医生人数
+                Address:       ObjToString(rdata["address"]),        //医疗机构地址
+                Website:       ObjToString(rdata["website"]),        //医疗机构网站
+                Area:          area,                                 //省
+                City:          city,                                 //市
+                District:      district,                             //区
+                BusinessType:  Int64All(rdata["business_type"]),     //医疗机构经营方式(0:公立、1:民营、2:其它)
+                Level:         ObjToString(rdata["level"]),          //医疗机构等级
+                MiType:        ObjToString(rdata["miType"]),         //医疗机构类型
+                Equipment:     equipment,                            //医院设备
+                Departnames:   ObjToString(rdata["class"]),          //医院科室
+                Follow:        int64(isFollow),                      //是否关注 0-未关注 1已关注
+                CompanyName:   ObjToString(rdata["mi_name"]),        //医疗机构名称
+                EstablishDate: ObjToString(rdata["establish_date"]), //成立日期
+        }
+        return portraitInfo, nil</span>
+}
+
+// @description           获取医疗机构画像相关招标动态
+// @param                     companyId 机构id
+// @param                     pageSize 条数
+// @param                     pageNum 页码
+// @return                    GetNewMsgList 招标动态
+// @return                    count 招标数量
+// @return                    error 错误信息
+func (this *PortraitService) List(companyId string, pageSize, pageNum int64) (*[]*entity.GetNewMsgList, int64, error) <span class="cov8" title="1">{
+        //判断是否存在companyid
+        if companyId == "" </span><span class="cov0" title="0">{
+                return nil, 0, errors.New(entity.NO_DATA_ERROR_MSG)
+        }</span>
+        <span class="cov8" title="1">var total int64
+        mustQueryArr := this.CommonPare(companyId)
+        log.Println("~~~~,", mustQueryArr)
+        //仅第一页查询总量(非数据导出)
+        if pageNum == 1 </span><span class="cov8" title="1">{
+                total = elastic.Count(entity.BiddingIndex, entity.BiddingIndex, fmt.Sprintf(entity.NewMustSearch, strings.Join(mustQueryArr, ","), ""))
+                if total &lt;= 0 </span><span class="cov0" title="0">{
+                        return nil, 0, errors.New(entity.NO_DATA_ERROR_MSG)
+                }</span>
+        }
+        <span class="cov8" title="1">start, limit := (pageNum-1)*pageSize, pageSize
+        fields := `"title","area","subtype","_id","projectname","publishtime"`
+        list := &amp;[]*entity.GetNewMsgList{}
+        //列表查询
+        if total &lt;= entity.DataExportBatchSearchLimit </span><span class="cov8" title="1">{
+                listQuery := fmt.Sprintf(entity.NewMustSearch, strings.Join(mustQueryArr, ","), fmt.Sprintf(entity.ListSearchLimit, fields, "publishtime", start, limit))
+                log.Printf("PortraitWinnerProject GetList Sql %s\n", listQuery)
+                newData := elastic.Get(entity.BiddingIndex, entity.BiddingType, listQuery)
+                if newData == nil || len(*newData) == 0 </span><span class="cov0" title="0">{
+                        return nil, 0, errors.New(entity.NO_DATA_ERROR_MSG)
+                }</span>
+                <span class="cov8" title="1">log.Println("newdata:", newData)
+                for k, v := range *newData </span><span class="cov8" title="1">{
+                        if len(v) &gt; 0 </span><span class="cov8" title="1">{
+                                if v["_id"] != nil </span><span class="cov8" title="1">{
+                                        (*newData)[k]["id"] = encrypt.EncodeArticleId2ByCheck(v["_id"].(string))
+                                        delete((*newData)[k], "_id") //删除未加密id
+                                }</span>
+                                <span class="cov8" title="1">title := ObjToString(ObjToString(v["title"]))
+                                if title == "" </span><span class="cov0" title="0">{
+                                        title = ObjToString(v["projectname"])
+                                }</span>
+                                <span class="cov8" title="1">(*newData)[k]["title"] = ClearHtml.ReplaceAllString(title, "")</span>
+                        }
+                        <span class="cov8" title="1">*list = append(*list, &amp;entity.GetNewMsgList{
+                                Area:      ObjToString(v["area"]),
+                                Bidstatus: ObjToString(v["subtype"]),           //信息类型
+                                Firsttime: Int64All(v["publishtime"]),          //时间
+                                Id:        ObjToString((*newData)[k]["id"]),    //加密信息id
+                                Title:     ObjToString((*newData)[k]["title"]), //标题
+                        })
+                        log.Println("~~list:", list)</span>
+                }
+                <span class="cov8" title="1">return list, total, nil</span>
+        }
+        <span class="cov0" title="0">return nil, 0, errors.New(entity.NO_DATA_ERROR_MSG)</span>
+}
+
+//医疗机构画像查询语句拼接
+func (this *PortraitService) CommonPare(companyId string) (mustQueryArr []string) <span class="cov8" title="1">{
+        //按照当前年份,往前推4年,共5个年份可选
+        sTime, eTime := this.PareTimeSelect() //采购单位不校验权限
+
+        mustQueryArr = append(mustQueryArr, fmt.Sprintf(`{"term":{"buyer":"%s"}}`, companyId))
+        mustQueryArr = append(mustQueryArr, fmt.Sprintf(`{"range":{"publishtime":{"gte":"%d","lte":"%d"}}}`, sTime.Unix(), eTime.Unix()))
+
+        return
+}</span>
+
+//PareTimeSelect 格式筛选时间,默认2年
+func (this *PortraitService) PareTimeSelect() (st, et time.Time) <span class="cov8" title="1">{
+        now := time.Now()
+        sYear := now.Year() - 4
+        eYear := now.Year()
+        //返回默认时间
+        sTimeStamp := time.Date(sYear, 1, 1, 0, 0, 0, 0, time.Local)
+        eTimeStamp := time.Date(eYear+1, 1, 1, 0, 0, -1, 0, time.Local)
+        if eYear == now.Year() </span><span class="cov8" title="1">{
+                eTimeStamp = time.Date(eYear, now.Month(), now.Day(), now.Hour(), now.Minute(), 0, 0, time.Local)
+        }</span>
+        <span class="cov8" title="1">return sTimeStamp, eTimeStamp</span>
+}
+func EncodeId(sid string) string <span class="cov0" title="0">{
+        if sid == "" || sid == "-" </span><span class="cov0" title="0">{ //不存在的id为-
+                return ""
+        }</span>
+        <span class="cov0" title="0">return encrypt.EncodeArticleId2ByCheck(sid)</span>
+=======
+        if total == 0 </span><span class="cov1" title="1">{
+                return nil, 0
+        }</span>
+        <span class="cov1" title="1">return e.BaseMysql.Find(entity.TableDomainEntClaim, query, field, order, (page-1)*pageSize, pageSize), int(total)</span>
+>>>>>>> 10627a5dbc739e87e4aa15f75c91adb5de38af2d
+}
 </pre>
 </pre>
 		
 		
 		</div>
 		</div>

+ 195 - 0
service/portrait.go

@@ -0,0 +1,195 @@
+// @Description   画像相关
+package service
+
+import (
+	"errors"
+	"fmt"
+	"log"
+	"regexp"
+	"strings"
+	"time"
+
+	. "app.yhyue.com/moapp/jybase/common"
+	"app.yhyue.com/moapp/jybase/encrypt"
+	elastic "app.yhyue.com/moapp/jybase/esv1"
+	"bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/entity"
+)
+
+//画像
+type PortraitService struct {
+	*entity.Conn
+}
+
+var ClearHtml = regexp.MustCompile("<[^>]*>")
+
+// @description   	生成结构体
+// @param     		conn 数据库实例
+// @return    		Portrait 画像实例
+func NewPortrait(conn *entity.Conn) *PortraitService {
+	return &PortraitService{
+		conn,
+	}
+}
+
+// @description   	获取画像内容
+// @param     		companyId 机构id
+// @param     		user_id   base_user_id
+// @return    		PortraitInfo 画像信息
+// @return    		error 错误信息
+func (this *PortraitService) Info(companyId string, user_id int64) (*entity.PortraitInfo, error) {
+	//判断是否存在companyid
+	// if companyId == "" || user_id == 0 {
+	// 	return nil, errors.New(entity.NO_DATA_ERROR_MSG)
+	// }
+	//获取信息
+	data := this.Mysql.SelectBySql(fmt.Sprintf(`SELECT a.sdequipment_code,a.area_code,a.beds,a.visit_perday,a.doctorsnum,a.address,a.website,a.business_type,replace(a.equipment,",","、") equipment, replace(e.equipment,",","、") sdleveltypeequip ,a.mi_name,a.establish_date,b.name LEVEL,c.name miType,d.class FROM %s a 
+													LEFT JOIN %s b ON a.level_code=b.code 
+													LEFT JOIN %s c ON c.code =a.mi_type_code
+													LEFT JOIN (SELECT GROUP_CONCAT(DISTINCT departname_class1 SEPARATOR  '、') class,company_id FROM %s WHERE company_id=?)  AS d ON d.company_id =a.company_id
+													left join %s e on e.code =a.sdequipment_code
+													WHERE  a.company_id=?`, entity.Institution_baseinfo, entity.Code_level, entity.Code_type, entity.Institution_department, entity.Code_sdleveltypeequip), companyId, companyId)
+	if data == nil || len(*data) == 0 {
+		return nil, errors.New(entity.NO_DATA_ERROR_MSG)
+	}
+	//获取area_code 省份,城市,区县
+	area, city, district := "", "", ""
+	rdata := (*data)[0]
+	adata := this.GlobalCommonData.SelectBySql(fmt.Sprintf(`select area,city,district from %s where code =? limit 1`, entity.Code_area), ObjToString(rdata["area_code"]))
+	if adata != nil && len(*adata) > 0 {
+		area = ObjToString((*adata)[0]["area"])
+		city = ObjToString((*adata)[0]["city"])
+		district = ObjToString((*adata)[0]["district"])
+	}
+	//医疗设备如果基本信息表中没有,则根据sdequipment_code、code联合查询得到equipment
+	equipment := ObjToString(rdata["equipment"])
+	sdleveltypeequip := ObjToString(rdata["sdleveltypeequip"])
+	if equipment == "" && sdleveltypeequip != "" {
+		equipment = ObjToString(rdata["sdleveltypeequip"])
+	}
+	//判断用户是否关注该机构
+	portraitInfo := &entity.PortraitInfo{
+		Beds:          Int64All(rdata["beds"]),
+		VisitPerday:   Int64All(rdata["visit_perday"]),      // 门诊量/日
+		Doctorsnum:    Int64All(rdata["doctorsnum"]),        //医生人数
+		Address:       ObjToString(rdata["address"]),        //医疗机构地址
+		Website:       ObjToString(rdata["website"]),        //医疗机构网站
+		Area:          area,                                 //省
+		City:          city,                                 //市
+		District:      district,                             //区
+		BusinessType:  Int64All(rdata["business_type"]),     //医疗机构经营方式(0:公立、1:民营、2:其它)
+		Level:         ObjToString(rdata["level"]),          //医疗机构等级
+		MiType:        ObjToString(rdata["miType"]),         //医疗机构类型
+		Equipment:     equipment,                            //医院设备
+		Departnames:   ObjToString(rdata["class"]),          //医院科室
+		Follow:        this.IsFollow(companyId, user_id, 1), //是否关注 0-未关注 1已关注
+		CompanyName:   ObjToString(rdata["mi_name"]),        //医疗机构名称
+		EstablishDate: ObjToString(rdata["establish_date"]), //成立日期
+	}
+	return portraitInfo, nil
+}
+
+// @description   	获取医疗机构画像相关招标动态
+// @param     		companyName 机构名称
+// @param     		pageSize 条数
+// @param     		pageNum 页码
+// @return    		GetNewMsgList 招标动态
+// @return    		count 招标数量
+// @return    		error 错误信息
+func (this *PortraitService) List(companyName string, pageSize, pageNum int64) (*[]*entity.GetNewMsgList, int64, error) {
+	//判断是否存在companyid
+	if companyName == "" {
+		return nil, 0, errors.New(entity.NO_DATA_ERROR_MSG)
+	}
+	var total int64
+	mustQueryArr := this.CommonPare(companyName)
+	log.Println("~~~~,", mustQueryArr)
+	//仅第一页查询总量(非数据导出)
+	if pageNum == 1 {
+		total = elastic.Count(entity.BiddingIndex, entity.BiddingIndex, fmt.Sprintf(entity.NewMustSearch, strings.Join(mustQueryArr, ","), ""))
+		if total <= 0 {
+			return nil, 0, errors.New(entity.NO_DATA_ERROR_MSG)
+		}
+	}
+	start, limit := (pageNum-1)*pageSize, pageSize
+	fields := `"title","area","subtype","_id","projectname","publishtime"`
+	list := &[]*entity.GetNewMsgList{}
+	//列表查询
+	if total <= entity.DataExportBatchSearchLimit {
+		listQuery := fmt.Sprintf(entity.NewMustSearch, strings.Join(mustQueryArr, ","), fmt.Sprintf(entity.ListSearchLimit, fields, "publishtime", start, limit))
+		log.Printf("PortraitWinnerProject GetList Sql %s\n", listQuery)
+		newData := elastic.Get(entity.BiddingIndex, entity.BiddingType, listQuery)
+		if newData == nil || len(*newData) == 0 {
+			return nil, 0, errors.New(entity.NO_DATA_ERROR_MSG)
+		}
+		log.Println("newdata:", newData)
+		for k, v := range *newData {
+			if len(v) > 0 {
+				if v["_id"] != nil {
+					(*newData)[k]["id"] = encrypt.EncodeArticleId2ByCheck(v["_id"].(string))
+					delete((*newData)[k], "_id") //删除未加密id
+				}
+				title := ObjToString(ObjToString(v["title"]))
+				if title == "" {
+					title = ObjToString(v["projectname"])
+				}
+				(*newData)[k]["title"] = ClearHtml.ReplaceAllString(title, "")
+			}
+			*list = append(*list, &entity.GetNewMsgList{
+				Area:      ObjToString(v["area"]),
+				Bidstatus: ObjToString(v["subtype"]),           //信息类型
+				Firsttime: Int64All(v["publishtime"]),          //时间
+				Id:        ObjToString((*newData)[k]["id"]),    //加密信息id
+				Title:     ObjToString((*newData)[k]["title"]), //标题
+			})
+			log.Println("~~list:", list)
+		}
+		return list, total, nil
+	}
+	return nil, 0, errors.New(entity.NO_DATA_ERROR_MSG)
+}
+
+//医疗机构画像查询语句拼接
+func (this *PortraitService) CommonPare(companyName string) (mustQueryArr []string) {
+	//按照当前年份,往前推4年,共5个年份可选
+	sTime, eTime := this.PareTimeSelect() //采购单位不校验权限
+
+	mustQueryArr = append(mustQueryArr, fmt.Sprintf(`{"term":{"buyer":"%s"}}`, companyName))
+	mustQueryArr = append(mustQueryArr, fmt.Sprintf(`{"term":{"bid_field":"%s"}}`, entity.BidField))
+	mustQueryArr = append(mustQueryArr, fmt.Sprintf(`{"range":{"publishtime":{"gte":"%d","lte":"%d"}}}`, sTime.Unix(), eTime.Unix()))
+
+	return
+}
+
+//PareTimeSelect 格式筛选时间,默认5年
+func (this *PortraitService) PareTimeSelect() (st, et time.Time) {
+	now := time.Now()
+	sYear := now.Year() - 4
+	eYear := now.Year()
+	//返回默认时间
+	sTimeStamp := time.Date(sYear, 1, 1, 0, 0, 0, 0, time.Local)
+	eTimeStamp := time.Date(eYear+1, 1, 1, 0, 0, -1, 0, time.Local)
+	if eYear == now.Year() {
+		eTimeStamp = time.Date(eYear, now.Month(), now.Day(), now.Hour(), now.Minute(), 0, 0, time.Local)
+	}
+	return sTimeStamp, eTimeStamp
+}
+
+//短地址加密
+func EncodeId(sid string) string {
+	if sid == "" || sid == "-" { //不存在的id为-
+		return ""
+	}
+	return encrypt.EncodeArticleId2ByCheck(sid)
+}
+
+// @description   	判断用户是否关注该项目
+// @param     		companyId 机构id
+// @param     		user_id base_user_id
+// @param     		types 类型 1医疗机构 2经销商
+// @return    		int64 是否关注 1关注 0未关注
+func (this *PortraitService) IsFollow(companyId string, user_id, types int64) int64 {
+	if this.BaseMysql.CountBySql(fmt.Sprintf(`select count(1) from %s where user_id =? and ent_id =? and type =?`, entity.Domain_ent_claim), user_id, companyId, types) > 0 {
+		return 1
+	}
+	return 0
+}

+ 157 - 0
service/portrait_test.go

@@ -0,0 +1,157 @@
+package service
+
+import (
+	"reflect"
+	"testing"
+
+	elastic "app.yhyue.com/moapp/jybase/esv1"
+	"app.yhyue.com/moapp/jybase/mysql"
+	"bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/entity"
+)
+
+var PortService PortraitService
+var MyConn *entity.Conn
+
+func init() {
+	entity.Mysql = &mysql.Mysql{
+		Address:      "192.168.3.217:4000",
+		UserName:     "root",
+		PassWord:     "=PDT49#80Z!RVv52_z",
+		DBName:       "medical_fileld_data",
+		MaxOpenConns: 5,
+		MaxIdleConns: 5,
+	}
+	entity.Mysql.Init()
+	BaseMysqlConn := &mysql.Mysql{
+		Address:      "192.168.3.217:4000",
+		UserName:     "root",
+		PassWord:     "=PDT49#80Z!RVv52_z",
+		DBName:       "base_service",
+		MaxOpenConns: 5,
+		MaxIdleConns: 5,
+	}
+	BaseMysqlConn.Init()
+	CommonMysql := &mysql.Mysql{
+		Address:      "192.168.3.217:4000",
+		UserName:     "root",
+		PassWord:     "=PDT49#80Z!RVv52_z",
+		DBName:       "global_common_data",
+		MaxOpenConns: 5,
+		MaxIdleConns: 5,
+	}
+	CommonMysql.Init()
+	MyConn = &entity.Conn{
+		Mysql:       entity.Mysql,
+		BaseMysql:   BaseMysqlConn,
+		CommonMysql: CommonMysql,
+	}
+	elastic.InitElasticSize("http://192.168.3.206:9800", 30)
+
+	PortService = *NewPortrait(MyConn)
+}
+
+func TestPortraitService_Info(t *testing.T) {
+	type fields struct {
+		Conn *entity.Conn
+	}
+	type args struct {
+		companyId string
+	}
+	tests := []struct {
+		name    string
+		fields  fields
+		args    args
+		want    *entity.PortraitInfo
+		wantErr bool
+	}{
+		// TODO: Add test cases.
+		{
+			name: "查询画像",
+			fields: fields{
+				Conn: MyConn,
+			},
+			args: args{
+				companyId: "25caa43ce64036dfd1f55635e06394a6",
+			},
+		},
+		{
+			name: "无参数查看画像",
+			fields: fields{
+				Conn: MyConn,
+			},
+			args: args{
+				companyId: "",
+			},
+		},
+		{
+			name: "错误参数查看画像",
+			fields: fields{
+				Conn: MyConn,
+			},
+			args: args{
+				companyId: "错的",
+			},
+		},
+	}
+	for _, tt := range tests {
+		t.Run(tt.name, func(t *testing.T) {
+			this := &PortraitService{
+				Conn: tt.fields.Conn,
+			}
+			got, err := this.Info(tt.args.companyId)
+			if (err != nil) != tt.wantErr {
+				t.Errorf("Info() error = %v, wantErr %v", err, tt.wantErr)
+				return
+			}
+			if !reflect.DeepEqual(got, tt.want) {
+				t.Errorf("Info() got = %v, want %v", got, tt.want)
+			}
+		})
+	}
+}
+
+func TestPortraitService_List(t *testing.T) {
+	type fields struct {
+		Conn *entity.Conn
+	}
+	type args struct {
+		companyId string
+		pagesize  int64
+		pagenum   int64
+	}
+	tests := []struct {
+		name    string
+		fields  fields
+		args    args
+		want    *entity.PortraitInfo
+		wantErr bool
+	}{
+		// TODO: Add test cases.
+		{
+			name: "招标动态",
+			fields: fields{
+				Conn: MyConn,
+			},
+			args: args{
+				companyId: "张家港市凤凰镇人民政府",
+				pagesize:  5,
+				pagenum:   1,
+			},
+		},
+	}
+	for _, tt := range tests {
+		t.Run(tt.name, func(t *testing.T) {
+			this := &PortraitService{
+				Conn: tt.fields.Conn,
+			}
+			got, _, err := this.List(tt.args.companyId, tt.args.pagesize, tt.args.pagenum)
+			if (err != nil) != tt.wantErr {
+				t.Errorf("Info() error = %v, wantErr %v", err, tt.wantErr)
+				return
+			}
+			if !reflect.DeepEqual(got, tt.want) {
+				t.Errorf("Info() got = %v, want %v", got, tt.want)
+			}
+		})
+	}
+}

+ 17 - 1
service/test_cover.out

@@ -1,5 +1,4 @@
 mode: count
 mode: count
-bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/InstitutionService.go:10.93,16.2 3 1
 bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/AuthService.go:14.76,19.17 2 4
 bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/AuthService.go:14.76,19.17 2 4
 bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/AuthService.go:29.2,29.34 1 2
 bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/AuthService.go:29.2,29.34 1 2
 bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/AuthService.go:19.17,20.32 1 2
 bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/AuthService.go:19.17,20.32 1 2
@@ -13,3 +12,20 @@ bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/AuthService.go:47.8
 bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/AuthService.go:62.13,64.4 1 1
 bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/AuthService.go:62.13,64.4 1 1
 bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/AuthService.go:64.9,67.4 2 0
 bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/AuthService.go:64.9,67.4 2 0
 bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/AuthService.go:72.82,78.2 2 2
 bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/AuthService.go:72.82,78.2 2 2
+bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/InstitutionService.go:10.93,16.2 3 1
+bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/claim.go:16.57,20.2 1 1
+bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/claim.go:23.61,24.65 1 2
+bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/claim.go:27.2,27.89 1 2
+bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/claim.go:24.65,26.3 1 0
+bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/claim.go:31.58,37.32 3 3
+bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/claim.go:42.2,43.23 2 2
+bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/claim.go:48.2,52.70 2 1
+bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/claim.go:37.32,40.3 2 1
+bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/claim.go:43.23,46.3 2 1
+bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/claim.go:56.96,64.2 2 3
+bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/claim.go:67.126,78.16 5 2
+bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/claim.go:81.2,81.115 1 0
+bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/claim.go:78.16,80.3 1 2
+bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/claim.go:85.126,95.16 5 2
+bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/claim.go:98.2,98.115 1 1
+bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/claim.go:95.16,97.3 1 1

+ 81 - 0
test/api_test.http

@@ -0,0 +1,81 @@
+### 认领
+POST http://{{host}}:8888/domain/claim
+Content-Type: application/json
+#Cookie:
+newUserId:22
+appId:10000
+
+{
+"ent_id": "1057165a5d1556510256475a470a554c030255534557480d0645065555004658",
+"type": 1
+}
+> {%
+client.test("Request executed successfully", function() {
+  client.assert(response.status === 200, "Response status is not 200");
+});
+%}
+
+### 取消认领
+POST http://{{host}}:8888/domain/unclaimed
+Content-Type: application/json
+#Cookie:
+newUserId:22
+appId:10000
+
+{
+  "id":"4d5f405e5c" ,
+  "type": 1
+}
+> {%
+client.test("Request executed successfully", function() {
+  client.assert(response.status === 200, "Response status is not 200");
+});
+%}
+
+### 是否认领过
+POST http://{{host}}:8888/domain/isClaimed
+Content-Type: application/json
+#Cookie:
+newUserId:22
+appId:10000
+
+{
+  "company_id": "1057165a5d1556510256475a470a554c030255534557480d0645065555004658",
+  "type": 1
+}
+> {%
+client.test("Request executed successfully", function() {
+  client.assert(response.status === 200, "Response status is not 200");
+});
+%}
+
+
+### 我认领的经销商
+POST http://{{host}}:8888/domain/claim/distributor
+Content-Type: application/json
+#Cookie:
+newUserId:22
+appId:10000
+
+> {%
+client.test("Request executed successfully", function() {
+  client.assert(response.status === 200, "Response status is not 200");
+});
+%}
+
+
+
+### 我认领的医疗机构
+POST http://{{host}}:8888/domain/claim/institution
+Content-Type: application/json
+#Cookie:
+newUserId:22
+appId:10000
+
+
+> {%
+client.test("Request executed successfully", function() {
+  client.assert(response.status === 200, "Response status is not 200");
+});
+%}
+

+ 41 - 3
test/rpc_test.http

@@ -1,8 +1,46 @@
+### 我认领的经销商列表
 GRPC {{host}}:8080/medical.Medical/ClaimedDistributorList
 GRPC {{host}}:8080/medical.Medical/ClaimedDistributorList
 
 
 {
 {
-  "AppId": "1000",
-  "UserId": 1,
+  "AppId": "10000",
+  "UserId": 22,
+  "Page": 0,
+  "PageSize": 10
+}
+
+### 我认领的医疗机构列表
+GRPC {{host}}:8080/medical.Medical/ClaimedInstitutionList
+
+{
+  "AppId": "10000",
+  "UserId": 22,
   "Page": 0,
   "Page": 0,
   "PageSize": 10
   "PageSize": 10
-}
+}
+
+### 认领
+GRPC {{host}}:8080/medical.Medical/Claim
+
+{
+  "AppId": "10000",
+  "UserId": 1,
+  "EntId": "30d041422855fda867a356b3994a67ea",
+  "Type": 1
+}
+### 取消认领
+GRPC {{host}}:8080/medical.Medical/UnClaimed
+
+{
+  "UserId": 1,
+  "Id": 1,
+  "AppId": "10000"
+}
+### 是否认领
+GRPC {{host}}:8080/medical.Medical/IsClaimed
+
+{
+  "AppId": "10000",
+  "UserId": 1,
+  "Type": 1,
+  "EntId": "1"
+}

Some files were not shown because too many files changed in this diff