2023-11-15 07:50:18 +00:00
|
|
|
package logic
|
|
|
|
|
|
|
|
import (
|
2023-11-15 08:32:07 +00:00
|
|
|
"errors"
|
2023-11-15 07:50:18 +00:00
|
|
|
"fusenapi/utils/auth"
|
|
|
|
"fusenapi/utils/basic"
|
2023-11-16 08:35:22 +00:00
|
|
|
|
2023-11-15 08:32:07 +00:00
|
|
|
"gorm.io/gorm"
|
2023-11-15 07:50:18 +00:00
|
|
|
|
|
|
|
"context"
|
|
|
|
|
|
|
|
"fusenapi/server/ldap-admin/internal/svc"
|
|
|
|
"fusenapi/server/ldap-admin/internal/types"
|
|
|
|
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
|
|
)
|
|
|
|
|
|
|
|
type GetMenuDetailLogic struct {
|
|
|
|
logx.Logger
|
|
|
|
ctx context.Context
|
|
|
|
svcCtx *svc.ServiceContext
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewGetMenuDetailLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetMenuDetailLogic {
|
|
|
|
return &GetMenuDetailLogic{
|
|
|
|
Logger: logx.WithContext(ctx),
|
|
|
|
ctx: ctx,
|
|
|
|
svcCtx: svcCtx,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// 处理进入前逻辑w,r
|
|
|
|
// func (l *GetMenuDetailLogic) BeforeLogic(w http.ResponseWriter, r *http.Request) {
|
|
|
|
// }
|
|
|
|
|
|
|
|
func (l *GetMenuDetailLogic) GetMenuDetail(req *types.GetMenuDetailReq, userinfo *auth.UserInfo) (resp *basic.Response) {
|
2023-11-15 08:32:07 +00:00
|
|
|
if req.Id <= 0 {
|
|
|
|
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "参数id无效")
|
|
|
|
}
|
|
|
|
menu, err := l.svcCtx.AllModels.LdapMenus.FindOne(l.ctx, req.Id)
|
|
|
|
if err != nil {
|
|
|
|
if errors.Is(err, gorm.ErrRecordNotFound) {
|
|
|
|
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "该菜单信息不存在")
|
|
|
|
}
|
|
|
|
logx.Error(err)
|
|
|
|
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "查询菜单详情失败")
|
|
|
|
}
|
|
|
|
return resp.SetStatusWithMessage(basic.CodeOK, "success", types.GetMenuDetailRsp{
|
|
|
|
Id: menu.Id,
|
|
|
|
Name: *menu.Name,
|
|
|
|
Title: *menu.Title,
|
|
|
|
Icon: *menu.Icon,
|
|
|
|
Path: *menu.Path,
|
|
|
|
Sort: *menu.Sort,
|
|
|
|
ParentId: *menu.ParentId,
|
|
|
|
Status: *menu.Status,
|
|
|
|
})
|
2023-11-15 07:50:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// 处理逻辑后 w,r 如:重定向, resp 必须重新处理
|
|
|
|
// func (l *GetMenuDetailLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) {
|
|
|
|
// // httpx.OkJsonCtx(r.Context(), w, resp)
|
|
|
|
// }
|