12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- 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
- }
- 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
- }
|