Files
hotgo/hotgo-server/app/controller/adminController/role_controller.go
孟帅 8f3d679a57 tt
2022-02-25 17:11:17 +08:00

96 lines
2.1 KiB
Go
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// @Link https://github.com/bufanyun/hotgo
// @Copyright Copyright (c) 2022 HotGo CLI
// @Author  Ms <133814250@qq.com>
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
//
package adminController
import (
"context"
"github.com/bufanyun/hotgo/app/com"
"github.com/bufanyun/hotgo/app/form/adminForm"
"github.com/bufanyun/hotgo/app/form/input"
"github.com/bufanyun/hotgo/app/service/adminService"
"github.com/gogf/gf/v2/util/gconv"
)
var Role = role{}
type role struct{}
//
//  @Title  获取角色下的会员列表
//  @Description
//  @Author  Ms <133814250@qq.com>
//  @Param   ctx
//  @Param   req
//  @Return  res
//  @Return  err
//
func (controller *role) RoleMemberList(ctx context.Context, req *adminForm.RoleMemberListReq) (*adminForm.RoleMemberListRes, error) {
var in input.AdminRoleMemberListInp
if err := gconv.Scan(req, &in); err != nil {
return nil, err
}
list, totalCount, err := adminService.Member.RoleMemberList(ctx, in)
if err != nil {
return nil, err
}
var res adminForm.RoleMemberListRes
res.List = list
res.TotalCount = totalCount
res.Limit = req.Page
res.Limit = req.Limit
return &res, nil
}
//
//  @Title  获取列表
//  @Description
//  @Author  Ms <133814250@qq.com>
//  @Param   ctx
//  @Param   req
//  @Return  res
//  @Return  err
//
func (controller *role) List(ctx context.Context, req *adminForm.RoleListReq) (*adminForm.RoleListRes, error) {
list, totalCount, err := adminService.Role.List(ctx, input.AdminRoleListInp{
Page: req.Page,
Limit: req.Limit,
})
if err != nil {
return nil, err
}
var res adminForm.RoleListRes
res.List = list
res.TotalCount = totalCount
res.Limit = req.Page
res.Limit = req.Limit
return &res, nil
}
//
//  @Title  动态路由
//  @Description
//  @Author  Ms <133814250@qq.com>
//  @Param   ctx
//  @Param   req
//  @Return  res
//  @Return  err
//
func (controller *role) Dynamic(ctx context.Context, req *adminForm.RoleDynamicReq) (res *adminForm.RoleDynamicRes, err error) {
res, err = adminService.Menu.GetMenuList(ctx, com.Context.GetUserId(ctx))
if err != nil {
return nil, err
}
return res, nil
}