mini_business_logic.go
1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package message
import (
"context"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
"github.com/zeromicro/go-zero/core/logx"
)
type MiniBusinessLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewMiniBusinessLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniBusinessLogic {
return &MiniBusinessLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *MiniBusinessLogic) MiniBusiness(req *types.MessageBusinessRequest) (resp *types.MessageBusinessResponse, err error) {
queryOptions := domain.NewQueryOptions().WithOffsetLimit(req.Page, req.Size)
total, list, err := l.svcCtx.MessageBusinessRepository.Find(l.ctx, l.svcCtx.DefaultDBConn(), queryOptions)
if err != nil {
return nil, err
}
if err != nil {
return nil, err
}
resp = &types.MessageBusinessResponse{}
resp.Total = total
resp.List = make([]types.MessageBusinessItem, 0)
for _, item := range list {
to := types.MessageBusinessItem{
Id: item.Id,
Type: item.Type,
//Title: item.Title,
Content: item.Content,
CreatedAt: item.CreatedAt,
}
resp.List = append(resp.List, to)
}
return resp, nil
}