prpnameasslogic.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. "fmt"
  8. "github.com/zeromicro/go-zero/core/logx"
  9. )
  10. var (
  11. findfields = `"project_name", "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. logx.Info(fmt.Sprintf("%+v", req))
  27. resp = &types.Reply{}
  28. if req.ProjectName != "" {
  29. esq := `{"query": {"bool": {"must": [{"match": {"project_name.pname": "` + req.ProjectName + `" }}]}}}`
  30. binfo := GetAllByNgram("transaction_info", "transaction_info", esq, "", "", findfields, 0, 10, 0, false)
  31. if binfo != nil && len(*binfo) > 0 {
  32. resp.Error_code = 0
  33. resp.Data = *binfo
  34. }
  35. } else {
  36. resp.Error_code = -1
  37. resp.Error_msg = "项目名称不能为空"
  38. }
  39. return
  40. }