-
-
Notifications
You must be signed in to change notification settings - Fork 263
/
get_department_by_id_logic.go
57 lines (49 loc) · 1.38 KB
/
get_department_by_id_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
package department
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 GetDepartmentByIdLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewGetDepartmentByIdLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetDepartmentByIdLogic {
return &GetDepartmentByIdLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *GetDepartmentByIdLogic) GetDepartmentById(req *types.IDReq) (resp *types.DepartmentInfoResp, err error) {
data, err := l.svcCtx.CoreRpc.GetDepartmentById(l.ctx, &core.IDReq{Id: req.Id})
if err != nil {
return nil, err
}
return &types.DepartmentInfoResp{
BaseDataInfo: types.BaseDataInfo{
Code: 0,
Msg: l.svcCtx.Trans.Trans(l.ctx, i18n.Success),
},
Data: types.DepartmentInfo{
BaseIDInfo: types.BaseIDInfo{
Id: data.Id,
CreatedAt: data.CreatedAt,
UpdatedAt: data.UpdatedAt,
},
Status: data.Status,
Sort: data.Sort,
Name: data.Name,
Ancestors: data.Ancestors,
Leader: data.Leader,
Phone: data.Phone,
Email: data.Email,
Remark: data.Remark,
ParentId: data.ParentId,
},
}, nil
}