-
-
Notifications
You must be signed in to change notification settings - Fork 249
/
get_dictionary_list_logic.go
59 lines (51 loc) · 1.43 KB
/
get_dictionary_list_logic.go
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
51
52
53
54
55
56
57
58
59
package dictionary
import (
"context"
"github.com/suyuan32/simple-admin-core/api/internal/svc"
"github.com/suyuan32/simple-admin-core/api/internal/types"
"github.com/suyuan32/simple-admin-core/rpc/types/core"
"github.com/zeromicro/go-zero/core/logx"
"github.com/suyuan32/simple-admin-common/i18n"
)
type GetDictionaryListLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewGetDictionaryListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetDictionaryListLogic {
return &GetDictionaryListLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *GetDictionaryListLogic) GetDictionaryList(req *types.DictionaryListReq) (resp *types.DictionaryListResp, err error) {
data, err := l.svcCtx.CoreRpc.GetDictionaryList(l.ctx,
&core.DictionaryListReq{
Page: req.Page,
PageSize: req.PageSize,
Name: req.Name,
})
if err != nil {
return nil, err
}
resp = &types.DictionaryListResp{}
resp.Msg = l.svcCtx.Trans.Trans(l.ctx, i18n.Success)
resp.Data.Total = data.GetTotal()
for _, v := range data.Data {
resp.Data.Data = append(resp.Data.Data,
types.DictionaryInfo{
BaseIDInfo: types.BaseIDInfo{
Id: v.Id,
CreatedAt: v.CreatedAt,
UpdatedAt: v.UpdatedAt,
},
Trans: l.svcCtx.Trans.Trans(l.ctx, *v.Title),
Title: v.Title,
Name: v.Name,
Status: v.Status,
Desc: v.Desc,
})
}
return resp, nil
}