prpnameasslogic.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package logic
  2. import (
  3. elastic "app.yhyue.com/moapp/jybase/esv7"
  4. "bp.jydev.jianyu360.cn/CRM/application/api/internal/svc"
  5. "bp.jydev.jianyu360.cn/CRM/application/api/internal/types"
  6. "context"
  7. "github.com/zeromicro/go-zero/core/logx"
  8. )
  9. var (
  10. INDEX = "bidding"
  11. findfields = `"projectp_name", "project_id"`
  12. )
  13. type PrPnameAssLogic struct {
  14. logx.Logger
  15. ctx context.Context
  16. svcCtx *svc.ServiceContext
  17. }
  18. func NewPrPnameAssLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PrPnameAssLogic {
  19. return &PrPnameAssLogic{
  20. Logger: logx.WithContext(ctx),
  21. ctx: ctx,
  22. svcCtx: svcCtx,
  23. }
  24. }
  25. func (l *PrPnameAssLogic) PrPnameAss(req *types.PnameAssReq) (resp *types.Reply, err error) {
  26. resp = &types.Reply{}
  27. if req.ProjectName != "" {
  28. esq := `{"query": {"bool": {"must": [{"match": {"projectname.pname": [` + req.ProjectName + ` ]}}]}}}`
  29. binfo := elastic.GetAllByNgram(INDEX, INDEX, esq, findfields, "", "", 0, 10, 0, false)
  30. if binfo != nil && len(*binfo) > 0 {
  31. resp.Error_code = 0
  32. resp.Data = *binfo
  33. }
  34. } else {
  35. resp.Error_code = -1
  36. resp.Error_msg = "项目名称不能为空"
  37. }
  38. return
  39. }