mirror of
https://gitee.com/dromara/mayfly-go
synced 2026-02-09 06:15:36 +08:00
refactor: 简化api层相关调用
This commit is contained in:
@@ -21,7 +21,7 @@ type Role struct {
|
||||
func (r *Role) Roles(rc *req.Ctx) {
|
||||
cond, pageParam := req.BindQueryAndPage(rc, new(entity.RoleQuery))
|
||||
|
||||
notIdsStr := rc.F.Query("notIds")
|
||||
notIdsStr := rc.Query("notIds")
|
||||
if notIdsStr != "" {
|
||||
cond.NotIds = collx.ArrayMap[string, uint64](strings.Split(notIdsStr, ","), func(val string) uint64 {
|
||||
return uint64(anyx.ConvInt(val))
|
||||
@@ -44,7 +44,7 @@ func (r *Role) SaveRole(rc *req.Ctx) {
|
||||
|
||||
// 删除角色及其资源关联关系
|
||||
func (r *Role) DelRole(rc *req.Ctx) {
|
||||
idsStr := rc.F.PathParam("id")
|
||||
idsStr := rc.PathParam("id")
|
||||
rc.ReqParam = collx.Kvs("ids", idsStr)
|
||||
ids := strings.Split(idsStr, ",")
|
||||
|
||||
@@ -57,13 +57,13 @@ func (r *Role) DelRole(rc *req.Ctx) {
|
||||
|
||||
// 获取角色关联的资源id数组,用于分配资源时回显已拥有的资源
|
||||
func (r *Role) RoleResourceIds(rc *req.Ctx) {
|
||||
rc.ResData = r.RoleApp.GetRoleResourceIds(uint64(rc.F.PathParamInt("id")))
|
||||
rc.ResData = r.RoleApp.GetRoleResourceIds(uint64(rc.PathParamInt("id")))
|
||||
}
|
||||
|
||||
// 查看角色关联的资源树信息
|
||||
func (r *Role) RoleResource(rc *req.Ctx) {
|
||||
var resources vo.ResourceManageVOList
|
||||
r.RoleApp.GetRoleResources(uint64(rc.F.PathParamInt("id")), &resources)
|
||||
r.RoleApp.GetRoleResources(uint64(rc.PathParamInt("id")), &resources)
|
||||
rc.ResData = resources.ToTrees(0)
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ func (r *Role) SaveResource(rc *req.Ctx) {
|
||||
// 查看角色关联的用户
|
||||
func (r *Role) RoleAccount(rc *req.Ctx) {
|
||||
cond, pageParam := req.BindQueryAndPage[*entity.RoleAccountQuery](rc, new(entity.RoleAccountQuery))
|
||||
cond.RoleId = uint64(rc.F.PathParamInt("id"))
|
||||
cond.RoleId = uint64(rc.PathParamInt("id"))
|
||||
var accounts []*vo.AccountRoleVO
|
||||
res, err := r.RoleApp.GetRoleAccountPage(cond, pageParam, &accounts)
|
||||
biz.ErrIsNil(err)
|
||||
|
||||
Reference in New Issue
Block a user