-
-
Notifications
You must be signed in to change notification settings - Fork 263
/
create_department_logic.go
48 lines (42 loc) · 1.2 KB
/
create_department_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
package department
import (
"context"
"net/http"
"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"
)
type CreateDepartmentLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
lang string
}
func NewCreateDepartmentLogic(r *http.Request, svcCtx *svc.ServiceContext) *CreateDepartmentLogic {
return &CreateDepartmentLogic{
Logger: logx.WithContext(r.Context()),
ctx: r.Context(),
svcCtx: svcCtx,
lang: r.Header.Get("Accept-Language"),
}
}
func (l *CreateDepartmentLogic) CreateDepartment(req *types.DepartmentInfo) (resp *types.BaseMsgResp, err error) {
data, err := l.svcCtx.CoreRpc.CreateDepartment(l.ctx,
&core.DepartmentInfo{
Id: req.Id,
Status: req.Status,
Sort: req.Sort,
Name: req.Name,
Ancestors: req.Ancestors,
Leader: req.Leader,
Phone: req.Phone,
Email: req.Email,
Remark: req.Remark,
ParentId: req.ParentId,
})
if err != nil {
return nil, err
}
return &types.BaseMsgResp{Msg: l.svcCtx.Trans.Trans(l.lang, data.Msg)}, nil
}