123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- package logic
- import (
- "context"
- "app.yhyue.com/moapp/jy_docs/rpc/stdlib/internal/svc"
- "app.yhyue.com/moapp/jy_docs/rpc/stdlib/stdlib"
- stdlibService "app.yhyue.com/moapp/jy_docs/services/stdlib"
- "app.yhyue.com/moapp/jybase/common"
- "github.com/tal-tech/go-zero/core/logx"
- )
- type DocQueryLogic struct {
- ctx context.Context
- svcCtx *svc.ServiceContext
- logx.Logger
- }
- func NewDocQueryLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DocQueryLogic {
- return &DocQueryLogic{
- ctx: ctx,
- svcCtx: svcCtx,
- Logger: logx.WithContext(ctx),
- }
- }
- func (l *DocQueryLogic) DocQuery(in *stdlib.DocQueryRequest) (*stdlib.DocQueryResponse, error) {
- if in.PageNum <= 0 {
- in.PageNum = 0
- }
- total, list := stdlibService.FindDocumentsByKeyWords(in.KeyWord, in.DocClass, in.DocTag, in.UpdateDateSort, in.DownloadSort, in.ViewSort, in.PageNum, in.PageSize)
- docs := []*stdlib.Doc{}
- if list != nil {
- for _, v := range *list {
- docs = append(docs, &stdlib.Doc{
- DocId: common.ObjToString(v["id"]),
- DocName: common.ObjToString(v["docName"]),
- Price: common.Int64All(v["price"]),
- DocPageSize: common.Int64All(v["docPageSize"]),
- DocFileSize: common.Int64All(v["docFileSize"]),
- DownTimes: common.Int64All(v["downTimes"]),
- UploadDate: common.ObjToString(v["uploadDate"]),
- DocSummary: common.ObjToString(v["docSummary"]),
- })
- }
- }
- return &stdlib.DocQueryResponse{
- Total: total,
- Docs: docs,
- }, nil
- }
|