fix
This commit is contained in:
parent
79a6c3fa24
commit
d471c1b43e
@ -1,21 +1,20 @@
|
|||||||
package gmodel
|
package gmodel
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
|
||||||
|
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ldap_department 部门表
|
// ldap_department 部门表
|
||||||
type LdapDepartment struct {
|
type LdapDepartment struct {
|
||||||
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` //
|
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` //
|
||||||
Name *string `gorm:"default:'';" json:"name"` //
|
Name *string `gorm:"unique_key;default:'';" json:"name"` //
|
||||||
Remark *string `gorm:"default:'';" json:"remark"` //
|
Remark *string `gorm:"unique_key;default:'';" json:"remark"` //
|
||||||
Creator *string `gorm:"default:'';" json:"creator"` //
|
Creator *string `gorm:"default:'';" json:"creator"` //
|
||||||
Type *string `gorm:"default:'';" json:"type"` //
|
Type *string `gorm:"default:'';" json:"type"` //
|
||||||
ParentId *int64 `gorm:"default:0;" json:"parent_id"` // 层级如 10/20/30
|
ParentId *int64 `gorm:"default:0;" json:"parent_id"` // 层级如 10/20/30
|
||||||
Dn *string `gorm:"default:'';" json:"dn"` //
|
Dn *string `gorm:"default:'';" json:"dn"` //
|
||||||
SyncState *int64 `gorm:"default:1;" json:"sync_state"` //
|
SyncState *int64 `gorm:"default:1;" json:"sync_state"` // 同步状态:1已同步, 2未同步
|
||||||
Sort *int64 `gorm:"default:999;" json:"sort"` // 排序
|
Sort *int64 `gorm:"default:999;" json:"sort"` // 排序
|
||||||
Ctime *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"ctime"` //
|
Ctime *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"ctime"` //
|
||||||
Utime *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"utime"` //
|
Utime *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"utime"` //
|
||||||
|
@ -12,9 +12,9 @@ type LdapMenus struct {
|
|||||||
Title *string `gorm:"default:'';" json:"title"` //
|
Title *string `gorm:"default:'';" json:"title"` //
|
||||||
Icon *string `gorm:"default:'';" json:"icon"` //
|
Icon *string `gorm:"default:'';" json:"icon"` //
|
||||||
Path *string `gorm:"default:'';" json:"path"` //
|
Path *string `gorm:"default:'';" json:"path"` //
|
||||||
Sort *int64 `gorm:"default:999;" json:"sort"` //
|
Sort *int64 `gorm:"default:999;" json:"sort"` // 菜单顺序(1-999)
|
||||||
Status *int64 `gorm:"default:1;" json:"status"` //
|
Status *int64 `gorm:"default:1;" json:"status"` // 菜单状态(正常/禁用, 默认正常)
|
||||||
ParentId *int64 `gorm:"default:0;" json:"parent_id"` //
|
ParentId *int64 `gorm:"default:0;" json:"parent_id"` // 父菜单编号(编号为0时表示根菜单)
|
||||||
Creator *string `gorm:"default:'';" json:"creator"` //
|
Creator *string `gorm:"default:'';" json:"creator"` //
|
||||||
Ctime *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"ctime"` //
|
Ctime *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"ctime"` //
|
||||||
Utime *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"utime"` //
|
Utime *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"utime"` //
|
||||||
|
@ -11,8 +11,8 @@ type LdapRoles struct {
|
|||||||
Name *string `gorm:"unique_key;default:'';" json:"name"` //
|
Name *string `gorm:"unique_key;default:'';" json:"name"` //
|
||||||
Keyword *string `gorm:"unique_key;default:'';" json:"keyword"` //
|
Keyword *string `gorm:"unique_key;default:'';" json:"keyword"` //
|
||||||
Remark *string `gorm:"default:'';" json:"remark"` //
|
Remark *string `gorm:"default:'';" json:"remark"` //
|
||||||
Status *int64 `gorm:"default:1;" json:"status"` //
|
Status *int64 `gorm:"default:1;" json:"status"` // 1正常, 2禁用
|
||||||
Sort *int64 `gorm:"default:999;" json:"sort"` //
|
Sort *int64 `gorm:"default:999;" json:"sort"` // 角色排序(排序越大权限越低, 不能查看比自己序号小的角色, 不能编辑同序号用户权限, 排序为1表示超级管理员)
|
||||||
Creator *string `gorm:"default:'';" json:"creator"` //
|
Creator *string `gorm:"default:'';" json:"creator"` //
|
||||||
Ctime *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"ctime"` //
|
Ctime *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"ctime"` //
|
||||||
Utime *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"utime"` //
|
Utime *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"utime"` //
|
||||||
|
@ -18,10 +18,10 @@ type LdapUsers struct {
|
|||||||
Avatar *string `gorm:"default:'';" json:"avatar"` //
|
Avatar *string `gorm:"default:'';" json:"avatar"` //
|
||||||
Position *string `gorm:"default:'';" json:"position"` //
|
Position *string `gorm:"default:'';" json:"position"` //
|
||||||
Introduction *string `gorm:"default:'';" json:"introduction"` //
|
Introduction *string `gorm:"default:'';" json:"introduction"` //
|
||||||
Status *int64 `gorm:"default:1;" json:"status"` //
|
Status *int64 `gorm:"default:1;" json:"status"` // 状态:1在职, 2离职
|
||||||
Creator *string `gorm:"default:'';" json:"creator"` //
|
Creator *string `gorm:"default:'';" json:"creator"` //
|
||||||
UserDn *string `gorm:"default:'';" json:"user_dn"` //
|
UserDn *string `gorm:"default:'';" json:"user_dn"` //
|
||||||
SyncState *int64 `gorm:"default:1;" json:"sync_state"` //
|
SyncState *int64 `gorm:"default:1;" json:"sync_state"` // 同步状态:1已同步, 2未同步
|
||||||
Ctime *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"ctime"` //
|
Ctime *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"ctime"` //
|
||||||
Utime *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"utime"` //
|
Utime *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"utime"` //
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
package logic
|
package logic
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fusenapi/model/gmodel"
|
||||||
"fusenapi/utils/auth"
|
"fusenapi/utils/auth"
|
||||||
"fusenapi/utils/basic"
|
"fusenapi/utils/basic"
|
||||||
|
"time"
|
||||||
|
|
||||||
"context"
|
"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) {
|
func (l *SaveDepartmentLogic) SaveDepartment(req *types.SaveDepartmentReq, userinfo *auth.UserInfo) (resp *basic.Response) {
|
||||||
|
now := time.Now().UTC()
|
||||||
if req.Id > 0{//更新
|
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 必须重新处理
|
// 处理逻辑后 w,r 如:重定向, resp 必须重新处理
|
||||||
|
@ -28,7 +28,6 @@ type SaveDepartmentReq struct {
|
|||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
ParentId int64 `json:"parent_id"`
|
ParentId int64 `json:"parent_id"`
|
||||||
Dn string `json:"dn"`
|
Dn string `json:"dn"`
|
||||||
SyncState int64 `json:"sync_state"`
|
|
||||||
Sort int64 `json:"sort"`
|
Sort int64 `json:"sort"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,6 +41,5 @@ type SaveDepartmentReq {
|
|||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
ParentId int64 `json:"parent_id"`
|
ParentId int64 `json:"parent_id"`
|
||||||
Dn string `json:"dn"`
|
Dn string `json:"dn"`
|
||||||
SyncState int64 `json:"sync_state"`
|
|
||||||
Sort int64 `json:"sort"`
|
Sort int64 `json:"sort"`
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user