1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- package logic
- import (
- MC "app.yhyue.com/moapp/jybase/common"
- IC "bp.jydev.jianyu360.cn/BaseService/jyMicroservices/jyBXCore/rpc/init"
- "bp.jydev.jianyu360.cn/BaseService/jyMicroservices/jyBXCore/rpc/internal/svc"
- "bp.jydev.jianyu360.cn/BaseService/jyMicroservices/jyBXCore/rpc/service"
- "bp.jydev.jianyu360.cn/BaseService/jyMicroservices/jyBXCore/rpc/type/bxcore"
- "context"
- "fmt"
- "github.com/zeromicro/go-zero/core/logx"
- "log"
- )
- type PurchaseSearchLogic struct {
- ctx context.Context
- svcCtx *svc.ServiceContext
- logx.Logger
- }
- func NewPurchaseSearchLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PurchaseSearchLogic {
- return &PurchaseSearchLogic{
- ctx: ctx,
- svcCtx: svcCtx,
- Logger: logx.WithContext(ctx),
- }
- }
- // 采购信息搜索
- func (l *PurchaseSearchLogic) PurchaseSearch(in *bxcore.PurchaseReq) (*bxcore.PurchaseResp, error) {
- var (
- res = &bxcore.PurchaseResp{
- Data: &bxcore.PurchaseData{
- List: []*bxcore.PurchaseList{},
- },
- }
- )
- ps := service.NewPurchase(in)
- ps.FilterCriteriaFormat()
- //更新历史记录
- go ps.HistoryKeywords()
- if IC.C.NoLoginSearch.Switch && ps.UserId == "" {
- flag := IC.ReqLimitInit.Limit(context.Background())
- if flag == 1 {
- defer IC.ReqLimitInit.Release()
- } else {
- if flag == -2 {
- log.Println("等待队列已满")
- } else if flag == -1 {
- log.Println("等待超时")
- }
- }
- if flag < 0 {
- log.Println("--并发队列--", fmt.Errorf("暂无数据"))
- return &bxcore.PurchaseResp{}, nil
- }
- }
- list, err := ps.GetPurchaseData()
- if err == nil && len(list) > 0 {
- res.Data.List = list
- }
- // 精准模式不足50条的非空标讯查询 匹配模糊查询数
- if ps.Total < IC.C.PaySearchLimit.PrecisionNum && in.SearchMode == 0 && !ps.IsEmptySearch() {
- ps.SearchMode = 1
- ps.FilterCriteriaFormat()
- res.Data.BCount = ps.GetPurchaseCount()
- log.Println("精准查询数据不足 匹配模糊查询数:", res.Data.BCount)
- }
- res.Data.PageNum = ps.PageNum
- res.Data.PageSize = ps.PageSize
- res.Data.TipMsg = ps.TipMsg
- res.Data.HighlightWords = ps.HighlightWords
- res.Data.Total = ps.Total
- res.Data.Count = ps.Count
- res.Data.KeyWords = ps.HighlightWords
- res.Data.InterceptLimit = int64(MC.IntAllDef(IC.C.KeywordsLimit, 35))
- res.Data.InterceptKeywords = ps.InterceptKeyWords
- res.Data.InterceptOtherWords = ps.TipMsg
- return res, err
- }
|