123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- package logic
- import (
- elastic "app.yhyue.com/moapp/jybase/esv7"
- "bp.jydev.jianyu360.cn/CRM/application/api/internal/svc"
- "bp.jydev.jianyu360.cn/CRM/application/api/internal/types"
- "context"
- "github.com/zeromicro/go-zero/core/logx"
- )
- var (
- INDEX = "bidding"
- findfields = `"projectp_name", "project_id"`
- )
- type PrPnameAssLogic struct {
- logx.Logger
- ctx context.Context
- svcCtx *svc.ServiceContext
- }
- func NewPrPnameAssLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PrPnameAssLogic {
- return &PrPnameAssLogic{
- Logger: logx.WithContext(ctx),
- ctx: ctx,
- svcCtx: svcCtx,
- }
- }
- func (l *PrPnameAssLogic) PrPnameAss(req *types.PnameAssReq) (resp *types.Reply, err error) {
- resp = &types.Reply{}
- if req.ProjectName != "" {
- esq := `{"query": {"bool": {"must": [{"match": {"projectname.pname": [` + req.ProjectName + ` ]}}]}}}`
- binfo := elastic.GetAllByNgram(INDEX, INDEX, esq, findfields, "", "", 0, 10, 0, false)
- if binfo != nil && len(*binfo) > 0 {
- resp.Error_code = 0
- resp.Data = *binfo
- }
- } else {
- resp.Error_code = -1
- resp.Error_msg = "项目名称不能为空"
- }
- return
- }
|