This commit is contained in:
laodaming 2023-11-14 11:57:41 +08:00
commit 76e534ef0b
5 changed files with 42 additions and 22 deletions

View File

@ -1,8 +1,9 @@
package gmodel
import (
"gorm.io/gorm"
"time"
"gorm.io/gorm"
)
// ldap_department 部门表

View File

@ -3,6 +3,7 @@ package gmodel
import (
"context"
"errors"
"gorm.io/gorm"
)
@ -23,10 +24,12 @@ func (d *LdapDepartmentModel)FindOne(ctx context.Context,id int64)(resp *LdapDep
err = d.db.WithContext(ctx).Model(&LdapDepartment{}).Where("id = ?", id).Take(&resp).Error
return resp, err
}
// 更新
func (d *LdapDepartmentModel) Update(ctx context.Context, id int64, data *LdapDepartment) error {
return d.db.WithContext(ctx).Model(&LdapDepartment{}).Where("id = ?", id).Updates(&data).Error
}
// 创建
func (d *LdapDepartmentModel) Create(ctx context.Context, data *LdapDepartment) error {
return d.db.WithContext(ctx).Model(&LdapDepartment{}).Create(&data).Error

View File

@ -1,2 +1,15 @@
package gmodel
import "context"
// TODO: 使用model的属性做你想做的
// 获取全部菜单
func (d *LdapMenusModel) GetAll(ctx context.Context) (resp []LdapMenus, err error) {
var menus []LdapMenus
result := d.db.Model(&LdapMenus{}).Where("status = ?", 1).Find(&menus)
if result.Error != nil {
return nil, result.Error
}
return menus, nil
}

View File

@ -2,6 +2,7 @@ package config
import (
"fusenapi/server/ldap-admin/internal/types"
"github.com/zeromicro/go-zero/rest"
)

View File

@ -1,10 +1,11 @@
package logic
import (
"context"
"fusenapi/utils/auth"
"fusenapi/utils/basic"
"context"
"fusenapi/server/ldap-admin/internal/svc"
"fusenapi/server/ldap-admin/internal/types"
@ -30,6 +31,7 @@ func NewGetDepartmentsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Ge
// }
func (l *GetDepartmentsLogic) GetDepartments(req *types.Request, userinfo *auth.UserInfo) (resp *basic.Response) {
<<<<<<< HEAD
//todo 鉴权 。。。。
departList, _, err := l.svcCtx.AllModels.LdapDepartment.GetAll(l.ctx, "sort ASC")
if err != nil {