prpnameasslogic.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package logic
  2. import (
  3. . "app.yhyue.com/moapp/jybase/es"
  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. findfields = `"project_name", "id"`
  11. )
  12. type PrPnameAssLogic struct {
  13. logx.Logger
  14. ctx context.Context
  15. svcCtx *svc.ServiceContext
  16. }
  17. func NewPrPnameAssLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PrPnameAssLogic {
  18. return &PrPnameAssLogic{
  19. Logger: logx.WithContext(ctx),
  20. ctx: ctx,
  21. svcCtx: svcCtx,
  22. }
  23. }
  24. func (l *PrPnameAssLogic) PrPnameAss(req *types.PnameAssReq) (resp *types.Reply, err error) {
  25. resp = &types.Reply{}
  26. if req.ProjectName != "" {
  27. esq := `{"query": {"bool": {"must": [{"match": {"project_name.pname": "` + req.ProjectName + `" }}]}}}`
  28. binfo := GetAllByNgram("transaction_info", "transaction_info", esq, "", "", findfields, 0, 10, 0, false)
  29. if binfo != nil && len(*binfo) > 0 {
  30. resp.Error_code = 0
  31. resp.Data = *binfo
  32. }
  33. } else {
  34. resp.Error_code = -1
  35. resp.Error_msg = "项目名称不能为空"
  36. }
  37. return
  38. }