合并冲突

This commit is contained in:
momo
2023-11-14 11:50:41 +08:00
20 changed files with 99 additions and 648 deletions

View File

@@ -1,62 +0,0 @@
package logic
import (
"errors"
"fusenapi/model/gmodel"
"fusenapi/utils/auth"
"fusenapi/utils/basic"
"context"
"fusenapi/server/ldap-admin/internal/svc"
"fusenapi/server/ldap-admin/internal/types"
"github.com/zeromicro/go-zero/core/logx"
"gorm.io/gorm"
)
type AddDepartmentLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewAddDepartmentLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AddDepartmentLogic {
return &AddDepartmentLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
// 处理进入前逻辑w,r
// func (l *AddDepartmentLogic) BeforeLogic(w http.ResponseWriter, r *http.Request) {
// }
func (l *AddDepartmentLogic) AddDepartment(req *types.AddDepartmentReq, userinfo *auth.UserInfo) (resp *basic.Response) {
// 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data)
// userinfo 传入值时, 一定不为null
if req.ParentId > 0 {
_, err := l.svcCtx.AllModels.LdapDepartment.GetOneById(l.ctx, req.ParentId)
if err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
basic.CodeServiceErr.Message = "查询不到上级"
} else {
basic.CodeServiceErr.Message = "系统出错"
}
return resp.SetStatus(basic.CodeServiceErr)
}
}
err := l.svcCtx.AllModels.LdapDepartment.InsertOne(l.ctx, gmodel.LdapDepartment{
Name: &req.Name,
})
if err != nil {
return resp.SetStatus(basic.CodeServiceErr)
}
return resp.SetStatus(basic.CodeOK)
}
// 处理逻辑后 w,r 如:重定向, resp 必须重新处理
// func (l *AddDepartmentLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) {
// // httpx.OkJsonCtx(r.Context(), w, resp)
// }

View File

@@ -1,43 +0,0 @@
package logic
import (
"fusenapi/utils/auth"
"fusenapi/utils/basic"
"context"
"fusenapi/server/ldap-admin/internal/svc"
"fusenapi/server/ldap-admin/internal/types"
"github.com/zeromicro/go-zero/core/logx"
)
type AddMenuLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewAddMenuLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AddMenuLogic {
return &AddMenuLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
// 处理进入前逻辑w,r
// func (l *AddMenuLogic) BeforeLogic(w http.ResponseWriter, r *http.Request) {
// }
func (l *AddMenuLogic) AddMenu(req *types.AddMenuHandler, userinfo *auth.UserInfo) (resp *basic.Response) {
// 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data)
// userinfo 传入值时, 一定不为null
return resp.SetStatus(basic.CodeOK)
}
// 处理逻辑后 w,r 如:重定向, resp 必须重新处理
// func (l *AddMenuLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) {
// // httpx.OkJsonCtx(r.Context(), w, resp)
// }

View File

@@ -1,43 +0,0 @@
package logic
import (
"fusenapi/utils/auth"
"fusenapi/utils/basic"
"context"
"fusenapi/server/ldap-admin/internal/svc"
"fusenapi/server/ldap-admin/internal/types"
"github.com/zeromicro/go-zero/core/logx"
)
type DeleteDepartmentLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewDeleteDepartmentLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteDepartmentLogic {
return &DeleteDepartmentLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
// 处理进入前逻辑w,r
// func (l *DeleteDepartmentLogic) BeforeLogic(w http.ResponseWriter, r *http.Request) {
// }
func (l *DeleteDepartmentLogic) DeleteDepartment(req *types.DeleteDepartmentReq, userinfo *auth.UserInfo) (resp *basic.Response) {
// 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data)
// userinfo 传入值时, 一定不为null
return resp.SetStatus(basic.CodeOK)
}
// 处理逻辑后 w,r 如:重定向, resp 必须重新处理
// func (l *DeleteDepartmentLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) {
// // httpx.OkJsonCtx(r.Context(), w, resp)
// }

View File

@@ -1,43 +0,0 @@
package logic
import (
"fusenapi/utils/auth"
"fusenapi/utils/basic"
"context"
"fusenapi/server/ldap-admin/internal/svc"
"fusenapi/server/ldap-admin/internal/types"
"github.com/zeromicro/go-zero/core/logx"
)
type EditMenuLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewEditMenuLogic(ctx context.Context, svcCtx *svc.ServiceContext) *EditMenuLogic {
return &EditMenuLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
// 处理进入前逻辑w,r
// func (l *EditMenuLogic) BeforeLogic(w http.ResponseWriter, r *http.Request) {
// }
func (l *EditMenuLogic) EditMenu(req *types.EditMenuHandler, userinfo *auth.UserInfo) (resp *basic.Response) {
// 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data)
// userinfo 传入值时, 一定不为null
return resp.SetStatus(basic.CodeOK)
}
// 处理逻辑后 w,r 如:重定向, resp 必须重新处理
// func (l *EditMenuLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) {
// // httpx.OkJsonCtx(r.Context(), w, resp)
// }

View File

@@ -1,10 +1,8 @@
package logic
import (
"fusenapi/constants"
"fusenapi/utils/auth"
"fusenapi/utils/basic"
"math"
"context"
@@ -32,35 +30,11 @@ func NewGetDepartmentsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Ge
// func (l *GetDepartmentsLogic) BeforeLogic(w http.ResponseWriter, r *http.Request) {
// }
func (l *GetDepartmentsLogic) GetDepartments(req *types.GetDepartmentsReq, userinfo *auth.UserInfo) (resp *basic.Response) {
if req.CurrentPage <= 0 {
req.CurrentPage = constants.DEFAULT_PAGE
}
if req.PageSize <= 0 {
req.PageSize = constants.DEFAULT_PAGE_SIZE
}
resList, resTotal, err := l.svcCtx.AllModels.LdapDepartment.GetList(l.ctx, req.CurrentPage, req.PageSize, "")
if err != nil {
logx.Error(err)
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "获取部门列表失败")
}
var pageCount int64 = 1
if resTotal > int64(req.PageSize) {
var float64Count = float64(resTotal)
var float64PerPage = float64(req.PageSize)
pageCountFloat := math.Ceil(float64Count / float64PerPage)
pageCount = int64(pageCountFloat)
}
func (l *GetDepartmentsLogic) GetDepartments(req *types.Request, userinfo *auth.UserInfo) (resp *basic.Response) {
// 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data)
// userinfo 传入值时, 一定不为null
return resp.SetStatus(basic.CodeOK, map[string]interface{}{
"list": resList,
"meta": map[string]int64{
"total_count": resTotal,
"page_count": pageCount,
"current_page": int64(req.CurrentPage),
"per_page": int64(req.PageSize),
},
})
return resp.SetStatus(basic.CodeOK)
}
// 处理逻辑后 w,r 如:重定向, resp 必须重新处理

View File

@@ -1,43 +0,0 @@
package logic
import (
"fusenapi/utils/auth"
"fusenapi/utils/basic"
"context"
"fusenapi/server/ldap-admin/internal/svc"
"fusenapi/server/ldap-admin/internal/types"
"github.com/zeromicro/go-zero/core/logx"
)
type GetMenusTreeLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewGetMenusTreeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetMenusTreeLogic {
return &GetMenusTreeLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
// 处理进入前逻辑w,r
// func (l *GetMenusTreeLogic) BeforeLogic(w http.ResponseWriter, r *http.Request) {
// }
func (l *GetMenusTreeLogic) GetMenusTree(req *types.GetMenusTreeReq, userinfo *auth.UserInfo) (resp *basic.Response) {
// 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data)
// userinfo 传入值时, 一定不为null
return resp.SetStatus(basic.CodeOK)
}
// 处理逻辑后 w,r 如:重定向, resp 必须重新处理
// func (l *GetMenusTreeLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) {
// // httpx.OkJsonCtx(r.Context(), w, resp)
// }

View File

@@ -12,14 +12,14 @@ import (
"github.com/zeromicro/go-zero/core/logx"
)
type EditDepartmentLogic struct {
type SaveDepartmentLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewEditDepartmentLogic(ctx context.Context, svcCtx *svc.ServiceContext) *EditDepartmentLogic {
return &EditDepartmentLogic{
func NewSaveDepartmentLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SaveDepartmentLogic {
return &SaveDepartmentLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
@@ -27,17 +27,15 @@ func NewEditDepartmentLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Ed
}
// 处理进入前逻辑w,r
// func (l *EditDepartmentLogic) BeforeLogic(w http.ResponseWriter, r *http.Request) {
// func (l *SaveDepartmentLogic) BeforeLogic(w http.ResponseWriter, r *http.Request) {
// }
func (l *EditDepartmentLogic) EditDepartment(req *types.EditDepartmentReq, userinfo *auth.UserInfo) (resp *basic.Response) {
// 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data)
// userinfo 传入值时, 一定不为null
func (l *SaveDepartmentLogic) SaveDepartment(req *types.SaveDepartmentReq, userinfo *auth.UserInfo) (resp *basic.Response) {
//todo 鉴权。。。
return resp.SetStatus(basic.CodeOK)
}
// 处理逻辑后 w,r 如:重定向, resp 必须重新处理
// func (l *EditDepartmentLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) {
// func (l *SaveDepartmentLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) {
// // httpx.OkJsonCtx(r.Context(), w, resp)
// }