fix
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"fusenapi/model/gmodel"
|
||||
"fusenapi/utils/auth"
|
||||
"fusenapi/utils/basic"
|
||||
"time"
|
||||
|
||||
"context"
|
||||
|
||||
@@ -31,11 +33,30 @@ func NewSaveDepartmentLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Sa
|
||||
// }
|
||||
|
||||
func (l *SaveDepartmentLogic) SaveDepartment(req *types.SaveDepartmentReq, userinfo *auth.UserInfo) (resp *basic.Response) {
|
||||
|
||||
if req.Id > 0{//更新
|
||||
|
||||
now := time.Now().UTC()
|
||||
data := &gmodel.LdapDepartment{
|
||||
Name: &req.Name,
|
||||
Remark: &req.Remark,
|
||||
Type: &req.Type,
|
||||
ParentId: &req.ParentId,
|
||||
Dn: &req.Dn,
|
||||
Sort: &req.Sort,
|
||||
Utime: &now,
|
||||
}
|
||||
return resp.SetStatus(basic.CodeOK)
|
||||
if req.Id > 0{//更新
|
||||
if err := l.svcCtx.AllModels.LdapDepartment.Update(l.ctx,req.Id,data);err != nil{
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeDbSqlErr,"更新失败")
|
||||
}
|
||||
return resp.SetStatusWithMessage(basic.CodeOK,"更新成功")
|
||||
}
|
||||
//添加
|
||||
data.Ctime = &now
|
||||
if err := l.svcCtx.AllModels.LdapDepartment.Create(l.ctx,data);err != nil{
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeDbSqlErr,"添加失败")
|
||||
}
|
||||
return resp.SetStatusWithMessage(basic.CodeOK,"添加成功")
|
||||
}
|
||||
|
||||
// 处理逻辑后 w,r 如:重定向, resp 必须重新处理
|
||||
|
||||
@@ -22,14 +22,13 @@ type DepartmentsItem struct {
|
||||
}
|
||||
|
||||
type SaveDepartmentReq struct {
|
||||
Id int64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Remark string `json:"remark"`
|
||||
Type string `json:"type"`
|
||||
ParentId int64 `json:"parent_id"`
|
||||
Dn string `json:"dn"`
|
||||
SyncState int64 `json:"sync_state"`
|
||||
Sort int64 `json:"sort"`
|
||||
Id int64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Remark string `json:"remark"`
|
||||
Type string `json:"type"`
|
||||
ParentId int64 `json:"parent_id"`
|
||||
Dn string `json:"dn"`
|
||||
Sort int64 `json:"sort"`
|
||||
}
|
||||
|
||||
type Request struct {
|
||||
|
||||
Reference in New Issue
Block a user