| @@ -3,10 +3,16 @@ package com.ruoyi.web.controller.system; | |||
| import com.ruoyi.common.annotation.Log; | |||
| import com.ruoyi.common.core.controller.BaseController; | |||
| import com.ruoyi.common.core.domain.AjaxResult; | |||
| import com.ruoyi.common.core.domain.entity.SysDictData; | |||
| import com.ruoyi.common.core.domain.entity.SysUser; | |||
| import com.ruoyi.common.core.domain.model.LoginUser; | |||
| import com.ruoyi.common.core.page.TableDataInfo; | |||
| import com.ruoyi.common.enums.BusinessType; | |||
| import com.ruoyi.common.utils.DictUtils; | |||
| import com.ruoyi.common.utils.ServletUtils; | |||
| import com.ruoyi.common.utils.poi.ExcelUtil; | |||
| import com.ruoyi.common.utils.translation.TranslateUtils; | |||
| import com.ruoyi.framework.web.service.TokenService; | |||
| import com.ruoyi.system.domain.SysMenuapp; | |||
| import com.ruoyi.system.service.ISysMenuappService; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| @@ -15,7 +21,11 @@ import org.springframework.web.bind.annotation.*; | |||
| import org.springframework.web.multipart.MultipartFile; | |||
| import javax.servlet.http.HttpServletResponse; | |||
| import java.util.ArrayList; | |||
| import java.util.Comparator; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| import java.util.stream.Collectors; | |||
| /** | |||
| * 手机菜单Controller | |||
| @@ -25,18 +35,20 @@ import java.util.List; | |||
| */ | |||
| @RestController | |||
| @RequestMapping("/system/menuapp") | |||
| public class SysMenuappController extends BaseController | |||
| { | |||
| public class SysMenuappController extends BaseController { | |||
| @Autowired | |||
| private ISysMenuappService sysMenuappService; | |||
| @Autowired | |||
| private TokenService tokenService; | |||
| /** | |||
| * 查询手机菜单列表 | |||
| */ | |||
| @PreAuthorize("@ss.hasPermi('system:menuapp:list')") | |||
| @GetMapping("/list") | |||
| public TableDataInfo list(SysMenuapp sysMenuapp) | |||
| { | |||
| public TableDataInfo list(SysMenuapp sysMenuapp) { | |||
| startPage(); | |||
| List<SysMenuapp> list = sysMenuappService.selectSysMenuappList(sysMenuapp); | |||
| return getDataTable(list); | |||
| @@ -49,8 +61,7 @@ public class SysMenuappController extends BaseController | |||
| @PreAuthorize("@ss.hasPermi('system:menuapp:export')") | |||
| @Log(title = "手机菜单", businessType = BusinessType.EXPORT) | |||
| @PostMapping("/export") | |||
| public void export(HttpServletResponse response, SysMenuapp sysMenuapp) | |||
| { | |||
| public void export(HttpServletResponse response, SysMenuapp sysMenuapp) { | |||
| List<SysMenuapp> list = sysMenuappService.selectSysMenuappList(sysMenuapp); | |||
| ExcelUtil<SysMenuapp> util = new ExcelUtil<SysMenuapp>(SysMenuapp.class); | |||
| util.exportExcel(response, list, "手机菜单数据"); | |||
| @@ -83,8 +94,7 @@ public class SysMenuappController extends BaseController | |||
| */ | |||
| @PreAuthorize("@ss.hasPermi('system:menuapp:query')") | |||
| @GetMapping(value = "/{id}") | |||
| public AjaxResult getInfo(@PathVariable("id") Long id) | |||
| { | |||
| public AjaxResult getInfo(@PathVariable("id") Long id) { | |||
| SysMenuapp detail = sysMenuappService.selectSysMenuappById(id); | |||
| TranslateUtils.translate(detail, false); | |||
| return success(detail); | |||
| @@ -96,8 +106,7 @@ public class SysMenuappController extends BaseController | |||
| @PreAuthorize("@ss.hasPermi('system:menuapp:add')") | |||
| @Log(title = "手机菜单", businessType = BusinessType.INSERT) | |||
| @PostMapping | |||
| public AjaxResult add(@RequestBody SysMenuapp sysMenuapp) | |||
| { | |||
| public AjaxResult add(@RequestBody SysMenuapp sysMenuapp) { | |||
| return toAjax(sysMenuappService.insertSysMenuapp(sysMenuapp)); | |||
| } | |||
| @@ -107,8 +116,7 @@ public class SysMenuappController extends BaseController | |||
| @PreAuthorize("@ss.hasPermi('system:menuapp:edit')") | |||
| @Log(title = "手机菜单", businessType = BusinessType.UPDATE) | |||
| @PutMapping | |||
| public AjaxResult edit(@RequestBody SysMenuapp sysMenuapp) | |||
| { | |||
| public AjaxResult edit(@RequestBody SysMenuapp sysMenuapp) { | |||
| return toAjax(sysMenuappService.updateSysMenuapp(sysMenuapp)); | |||
| } | |||
| @@ -117,11 +125,43 @@ public class SysMenuappController extends BaseController | |||
| */ | |||
| @PreAuthorize("@ss.hasPermi('system:menuapp:remove')") | |||
| @Log(title = "手机菜单", businessType = BusinessType.DELETE) | |||
| @DeleteMapping("/{ids}") | |||
| public AjaxResult remove(@PathVariable Long[] ids) | |||
| { | |||
| @DeleteMapping("/{ids}") | |||
| public AjaxResult remove(@PathVariable Long[] ids) { | |||
| return toAjax(sysMenuappService.deleteSysMenuappByIds(ids)); | |||
| } | |||
| /** | |||
| * 手机端菜单渲染 | |||
| */ | |||
| @GetMapping("/menus") | |||
| public AjaxResult menus() { | |||
| SysMenuapp mp = new SysMenuapp(); | |||
| mp.setMenuStatus("0"); | |||
| LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest()); | |||
| SysUser user = loginUser.getUser(); | |||
| List<SysMenuapp> list = sysMenuappService.selectSysMobileListByUserId(user.getUserId(), mp); | |||
| return respMenus(list); | |||
| } | |||
| private AjaxResult respMenus(List<SysMenuapp> list) { | |||
| int size = list.size(); | |||
| List<SysDictData> modle_name = DictUtils.getDictCache("modle_type"); | |||
| Map<String, Long> modleNameOrderMap = modle_name.stream().collect(Collectors.toMap(SysDictData::getDictValue, SysDictData::getDictSort)); | |||
| Map<String, List<SysMenuapp>> groups = list.stream() | |||
| .sorted(Comparator.comparing((x) -> modleNameOrderMap.get(((SysMenuapp) x).getModelType())) | |||
| .thenComparing((x) -> ((SysMenuapp) x).getMenuNum())) | |||
| .collect(Collectors.groupingBy(SysMenuapp::getModelType)); | |||
| List<SysMenuapp> res = new ArrayList<>(); | |||
| modle_name.forEach((x) -> { | |||
| if(!groups.containsKey(x.getDictValue())) | |||
| return; | |||
| List<SysMenuapp> sysMobiles = groups.get(x.getDictValue()); | |||
| SysMenuapp item = new SysMenuapp(); | |||
| item.setModelType(x.getDictLabel()).setMenus(sysMobiles); | |||
| res.add(item); | |||
| }); | |||
| return AjaxResult.success(res).set("count", size); | |||
| } | |||
| } | |||
| @@ -1,18 +1,5 @@ | |||
| package com.ruoyi.web.controller.system; | |||
| import java.util.List; | |||
| import javax.servlet.http.HttpServletResponse; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.security.access.prepost.PreAuthorize; | |||
| import org.springframework.validation.annotation.Validated; | |||
| import org.springframework.web.bind.annotation.DeleteMapping; | |||
| import org.springframework.web.bind.annotation.GetMapping; | |||
| import org.springframework.web.bind.annotation.PathVariable; | |||
| import org.springframework.web.bind.annotation.PostMapping; | |||
| import org.springframework.web.bind.annotation.PutMapping; | |||
| import org.springframework.web.bind.annotation.RequestBody; | |||
| import org.springframework.web.bind.annotation.RequestMapping; | |||
| import org.springframework.web.bind.annotation.RestController; | |||
| import com.ruoyi.common.annotation.Log; | |||
| import com.ruoyi.common.core.controller.BaseController; | |||
| import com.ruoyi.common.core.domain.AjaxResult; | |||
| @@ -26,20 +13,26 @@ import com.ruoyi.common.utils.StringUtils; | |||
| import com.ruoyi.common.utils.poi.ExcelUtil; | |||
| import com.ruoyi.framework.web.service.SysPermissionService; | |||
| import com.ruoyi.framework.web.service.TokenService; | |||
| import com.ruoyi.system.domain.SysMenuapp; | |||
| import com.ruoyi.system.domain.SysRoleMenuapp; | |||
| import com.ruoyi.system.domain.SysUserRole; | |||
| import com.ruoyi.system.service.ISysDeptService; | |||
| import com.ruoyi.system.service.ISysRoleService; | |||
| import com.ruoyi.system.service.ISysUserService; | |||
| import com.ruoyi.system.service.*; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.security.access.prepost.PreAuthorize; | |||
| import org.springframework.validation.annotation.Validated; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import javax.servlet.http.HttpServletResponse; | |||
| import java.util.List; | |||
| /** | |||
| * 角色信息 | |||
| * | |||
| * | |||
| * @author ruoyi | |||
| */ | |||
| @RestController | |||
| @RequestMapping("/system/role") | |||
| public class SysRoleController extends BaseController | |||
| { | |||
| public class SysRoleController extends BaseController { | |||
| @Autowired | |||
| private ISysRoleService roleService; | |||
| @@ -55,10 +48,17 @@ public class SysRoleController extends BaseController | |||
| @Autowired | |||
| private ISysDeptService deptService; | |||
| @Autowired | |||
| private ISysRoleMenuappService roleMobileService; | |||
| @Autowired | |||
| private ISysMenuappService sysMenuappService; | |||
| @PreAuthorize("@ss.hasPermi('system:role:list')") | |||
| @GetMapping("/list") | |||
| public TableDataInfo list(SysRole role) | |||
| { | |||
| public TableDataInfo list(SysRole role) { | |||
| startPage(); | |||
| List<SysRole> list = roleService.selectRoleList(role); | |||
| return getDataTable(list); | |||
| @@ -67,8 +67,7 @@ public class SysRoleController extends BaseController | |||
| @Log(title = "角色管理", businessType = BusinessType.EXPORT) | |||
| @PreAuthorize("@ss.hasPermi('system:role:export')") | |||
| @PostMapping("/export") | |||
| public void export(HttpServletResponse response, SysRole role) | |||
| { | |||
| public void export(HttpServletResponse response, SysRole role) { | |||
| List<SysRole> list = roleService.selectRoleList(role); | |||
| ExcelUtil<SysRole> util = new ExcelUtil<SysRole>(SysRole.class); | |||
| util.exportExcel(response, list, "角色数据"); | |||
| @@ -79,8 +78,7 @@ public class SysRoleController extends BaseController | |||
| */ | |||
| @PreAuthorize("@ss.hasPermi('system:role:query')") | |||
| @GetMapping(value = "/{roleId}") | |||
| public AjaxResult getInfo(@PathVariable Long roleId) | |||
| { | |||
| public AjaxResult getInfo(@PathVariable Long roleId) { | |||
| roleService.checkRoleDataScope(roleId); | |||
| return success(roleService.selectRoleById(roleId)); | |||
| } | |||
| @@ -91,14 +89,10 @@ public class SysRoleController extends BaseController | |||
| @PreAuthorize("@ss.hasPermi('system:role:add')") | |||
| @Log(title = "角色管理", businessType = BusinessType.INSERT) | |||
| @PostMapping | |||
| public AjaxResult add(@Validated @RequestBody SysRole role) | |||
| { | |||
| if (!roleService.checkRoleNameUnique(role)) | |||
| { | |||
| public AjaxResult add(@Validated @RequestBody SysRole role) { | |||
| if (!roleService.checkRoleNameUnique(role)) { | |||
| return error("新增角色'" + role.getRoleName() + "'失败,角色名称已存在"); | |||
| } | |||
| else if (!roleService.checkRoleKeyUnique(role)) | |||
| { | |||
| } else if (!roleService.checkRoleKeyUnique(role)) { | |||
| return error("新增角色'" + role.getRoleName() + "'失败,角色权限已存在"); | |||
| } | |||
| role.setCreateBy(getUsername()); | |||
| @@ -112,26 +106,20 @@ public class SysRoleController extends BaseController | |||
| @PreAuthorize("@ss.hasPermi('system:role:edit')") | |||
| @Log(title = "角色管理", businessType = BusinessType.UPDATE) | |||
| @PutMapping | |||
| public AjaxResult edit(@Validated @RequestBody SysRole role) | |||
| { | |||
| public AjaxResult edit(@Validated @RequestBody SysRole role) { | |||
| roleService.checkRoleAllowed(role); | |||
| roleService.checkRoleDataScope(role.getRoleId()); | |||
| if (!roleService.checkRoleNameUnique(role)) | |||
| { | |||
| if (!roleService.checkRoleNameUnique(role)) { | |||
| return error("修改角色'" + role.getRoleName() + "'失败,角色名称已存在"); | |||
| } | |||
| else if (!roleService.checkRoleKeyUnique(role)) | |||
| { | |||
| } else if (!roleService.checkRoleKeyUnique(role)) { | |||
| return error("修改角色'" + role.getRoleName() + "'失败,角色权限已存在"); | |||
| } | |||
| role.setUpdateBy(getUsername()); | |||
| if (roleService.updateRole(role) > 0) | |||
| { | |||
| if (roleService.updateRole(role) > 0) { | |||
| // 更新缓存用户权限 | |||
| LoginUser loginUser = getLoginUser(); | |||
| if (StringUtils.isNotNull(loginUser.getUser()) && !loginUser.getUser().isAdmin()) | |||
| { | |||
| if (StringUtils.isNotNull(loginUser.getUser()) && !loginUser.getUser().isAdmin()) { | |||
| loginUser.setUser(userService.selectUserByUserName(loginUser.getUser().getUserName())); | |||
| loginUser.setPermissions(permissionService.getMenuPermission(loginUser.getUser())); | |||
| tokenService.setLoginUser(loginUser); | |||
| @@ -147,8 +135,7 @@ public class SysRoleController extends BaseController | |||
| @PreAuthorize("@ss.hasPermi('system:role:edit')") | |||
| @Log(title = "角色管理", businessType = BusinessType.UPDATE) | |||
| @PutMapping("/dataScope") | |||
| public AjaxResult dataScope(@RequestBody SysRole role) | |||
| { | |||
| public AjaxResult dataScope(@RequestBody SysRole role) { | |||
| roleService.checkRoleAllowed(role); | |||
| roleService.checkRoleDataScope(role.getRoleId()); | |||
| return toAjax(roleService.authDataScope(role)); | |||
| @@ -160,8 +147,7 @@ public class SysRoleController extends BaseController | |||
| @PreAuthorize("@ss.hasPermi('system:role:edit')") | |||
| @Log(title = "角色管理", businessType = BusinessType.UPDATE) | |||
| @PutMapping("/changeStatus") | |||
| public AjaxResult changeStatus(@RequestBody SysRole role) | |||
| { | |||
| public AjaxResult changeStatus(@RequestBody SysRole role) { | |||
| roleService.checkRoleAllowed(role); | |||
| roleService.checkRoleDataScope(role.getRoleId()); | |||
| role.setUpdateBy(getUsername()); | |||
| @@ -174,8 +160,7 @@ public class SysRoleController extends BaseController | |||
| @PreAuthorize("@ss.hasPermi('system:role:remove')") | |||
| @Log(title = "角色管理", businessType = BusinessType.DELETE) | |||
| @DeleteMapping("/{roleIds}") | |||
| public AjaxResult remove(@PathVariable Long[] roleIds) | |||
| { | |||
| public AjaxResult remove(@PathVariable Long[] roleIds) { | |||
| return toAjax(roleService.deleteRoleByIds(roleIds)); | |||
| } | |||
| @@ -184,8 +169,7 @@ public class SysRoleController extends BaseController | |||
| */ | |||
| @PreAuthorize("@ss.hasPermi('system:role:query')") | |||
| @GetMapping("/optionselect") | |||
| public AjaxResult optionselect() | |||
| { | |||
| public AjaxResult optionselect() { | |||
| return success(roleService.selectRoleAll()); | |||
| } | |||
| @@ -194,8 +178,7 @@ public class SysRoleController extends BaseController | |||
| */ | |||
| @PreAuthorize("@ss.hasPermi('system:role:list')") | |||
| @GetMapping("/authUser/allocatedList") | |||
| public TableDataInfo allocatedList(SysUser user) | |||
| { | |||
| public TableDataInfo allocatedList(SysUser user) { | |||
| startPage(); | |||
| List<SysUser> list = userService.selectAllocatedList(user); | |||
| return getDataTable(list); | |||
| @@ -206,8 +189,7 @@ public class SysRoleController extends BaseController | |||
| */ | |||
| @PreAuthorize("@ss.hasPermi('system:role:list')") | |||
| @GetMapping("/authUser/unallocatedList") | |||
| public TableDataInfo unallocatedList(SysUser user) | |||
| { | |||
| public TableDataInfo unallocatedList(SysUser user) { | |||
| startPage(); | |||
| List<SysUser> list = userService.selectUnallocatedList(user); | |||
| return getDataTable(list); | |||
| @@ -219,8 +201,7 @@ public class SysRoleController extends BaseController | |||
| @PreAuthorize("@ss.hasPermi('system:role:edit')") | |||
| @Log(title = "角色管理", businessType = BusinessType.GRANT) | |||
| @PutMapping("/authUser/cancel") | |||
| public AjaxResult cancelAuthUser(@RequestBody SysUserRole userRole) | |||
| { | |||
| public AjaxResult cancelAuthUser(@RequestBody SysUserRole userRole) { | |||
| return toAjax(roleService.deleteAuthUser(userRole)); | |||
| } | |||
| @@ -230,8 +211,7 @@ public class SysRoleController extends BaseController | |||
| @PreAuthorize("@ss.hasPermi('system:role:edit')") | |||
| @Log(title = "角色管理", businessType = BusinessType.GRANT) | |||
| @PutMapping("/authUser/cancelAll") | |||
| public AjaxResult cancelAuthUserAll(Long roleId, Long[] userIds) | |||
| { | |||
| public AjaxResult cancelAuthUserAll(Long roleId, Long[] userIds) { | |||
| return toAjax(roleService.deleteAuthUsers(roleId, userIds)); | |||
| } | |||
| @@ -241,8 +221,7 @@ public class SysRoleController extends BaseController | |||
| @PreAuthorize("@ss.hasPermi('system:role:edit')") | |||
| @Log(title = "角色管理", businessType = BusinessType.GRANT) | |||
| @PutMapping("/authUser/selectAll") | |||
| public AjaxResult selectAuthUserAll(Long roleId, Long[] userIds) | |||
| { | |||
| public AjaxResult selectAuthUserAll(Long roleId, Long[] userIds) { | |||
| roleService.checkRoleDataScope(roleId); | |||
| return toAjax(roleService.insertAuthUsers(roleId, userIds)); | |||
| } | |||
| @@ -252,11 +231,64 @@ public class SysRoleController extends BaseController | |||
| */ | |||
| @PreAuthorize("@ss.hasPermi('system:role:query')") | |||
| @GetMapping(value = "/deptTree/{roleId}") | |||
| public AjaxResult deptTree(@PathVariable("roleId") Long roleId) | |||
| { | |||
| public AjaxResult deptTree(@PathVariable("roleId") Long roleId) { | |||
| AjaxResult ajax = AjaxResult.success(); | |||
| ajax.put("checkedKeys", deptService.selectDeptListByRoleId(roleId)); | |||
| ajax.put("depts", deptService.selectDeptTreeList(new SysDept())); | |||
| return ajax; | |||
| } | |||
| /** | |||
| * 查询已分配手机菜单角色列表 | |||
| */ | |||
| //@PreAuthorize("@ss.hasPermi('system:role:list')") | |||
| @GetMapping("/authApp/allocatedList") | |||
| public TableDataInfo allocatedAppList(SysMenuapp app) { | |||
| startPage(); | |||
| List<SysMenuapp> list = sysMenuappService.selectAllocatedList(app); | |||
| return getDataTable(list); | |||
| } | |||
| /** | |||
| * 查询未分配手机菜单角色列表 | |||
| */ | |||
| //@PreAuthorize("@ss.hasPermi('system:role:list')") | |||
| @GetMapping("/authApp/unallocatedList") | |||
| public TableDataInfo unallocatedAppList(SysMenuapp app) { | |||
| startPage(); | |||
| List<SysMenuapp> list = sysMenuappService.selectUnallocatedList(app); | |||
| return getDataTable(list); | |||
| } | |||
| /** | |||
| * 取消授权手机菜单 | |||
| */ | |||
| //@PreAuthorize("@ss.hasPermi('system:role:edit')") | |||
| @Log(title = "角色管理", businessType = BusinessType.GRANT) | |||
| @PutMapping("/authApp/cancel") | |||
| public AjaxResult cancelAuthApp(@RequestBody SysRoleMenuapp sysRoleMenuapp) { | |||
| return toAjax(roleMobileService.deleteAuthApp(sysRoleMenuapp)); | |||
| } | |||
| /** | |||
| * 批量取消授权手机菜单 | |||
| */ | |||
| //@PreAuthorize("@ss.hasPermi('system:role:edit')") | |||
| @Log(title = "角色管理", businessType = BusinessType.GRANT) | |||
| @PutMapping("/authApp/cancelAll") | |||
| public AjaxResult cancelAuthAppAll(Long roleId, Long[] appIds) { | |||
| return toAjax(roleMobileService.deleteAuthApps(roleId, appIds)); | |||
| } | |||
| /** | |||
| * 批量选择手机菜单授权 | |||
| */ | |||
| //@PreAuthorize("@ss.hasPermi('system:role:edit')") | |||
| @Log(title = "角色管理", businessType = BusinessType.GRANT) | |||
| @PutMapping("/authApp/selectAll") | |||
| public AjaxResult selectAuthAppAll(Long roleId, Long[] appIds) { | |||
| return toAjax(roleMobileService.insertAuthApps(roleId, appIds)); | |||
| } | |||
| } | |||
| @@ -1,104 +1,107 @@ | |||
| package com.ruoyi.common.core.domain; | |||
| import java.util.HashMap; | |||
| import java.util.Objects; | |||
| import com.ruoyi.common.constant.HttpStatus; | |||
| import com.ruoyi.common.utils.StringUtils; | |||
| import java.util.HashMap; | |||
| import java.util.Objects; | |||
| /** | |||
| * 操作消息提醒 | |||
| * | |||
| * | |||
| * @author ruoyi | |||
| */ | |||
| public class AjaxResult extends HashMap<String, Object> | |||
| { | |||
| public class AjaxResult extends HashMap<String, Object> { | |||
| private static final long serialVersionUID = 1L; | |||
| /** 状态码 */ | |||
| /** | |||
| * 状态码 | |||
| */ | |||
| public static final String CODE_TAG = "code"; | |||
| /** 返回内容 */ | |||
| /** | |||
| * 返回内容 | |||
| */ | |||
| public static final String MSG_TAG = "msg"; | |||
| /** 数据对象 */ | |||
| /** | |||
| * 数据对象 | |||
| */ | |||
| public static final String DATA_TAG = "data"; | |||
| /** | |||
| * 初始化一个新创建的 AjaxResult 对象,使其表示一个空消息。 | |||
| */ | |||
| public AjaxResult() | |||
| { | |||
| public AjaxResult() { | |||
| } | |||
| /** | |||
| * 初始化一个新创建的 AjaxResult 对象 | |||
| * | |||
| * | |||
| * @param code 状态码 | |||
| * @param msg 返回内容 | |||
| * @param msg 返回内容 | |||
| */ | |||
| public AjaxResult(int code, String msg) | |||
| { | |||
| public AjaxResult(int code, String msg) { | |||
| super.put(CODE_TAG, code); | |||
| super.put(MSG_TAG, msg); | |||
| } | |||
| /** | |||
| * 初始化一个新创建的 AjaxResult 对象 | |||
| * | |||
| * | |||
| * @param code 状态码 | |||
| * @param msg 返回内容 | |||
| * @param msg 返回内容 | |||
| * @param data 数据对象 | |||
| */ | |||
| public AjaxResult(int code, String msg, Object data) | |||
| { | |||
| public AjaxResult(int code, String msg, Object data) { | |||
| super.put(CODE_TAG, code); | |||
| super.put(MSG_TAG, msg); | |||
| if (StringUtils.isNotNull(data)) | |||
| { | |||
| if (StringUtils.isNotNull(data)) { | |||
| super.put(DATA_TAG, data); | |||
| } | |||
| } | |||
| public AjaxResult set(String name, Object val) { | |||
| put(name, val); | |||
| return this; | |||
| } | |||
| /** | |||
| * 返回成功消息 | |||
| * | |||
| * | |||
| * @return 成功消息 | |||
| */ | |||
| public static AjaxResult success() | |||
| { | |||
| public static AjaxResult success() { | |||
| return AjaxResult.success("操作成功"); | |||
| } | |||
| /** | |||
| * 返回成功数据 | |||
| * | |||
| * | |||
| * @return 成功消息 | |||
| */ | |||
| public static AjaxResult success(Object data) | |||
| { | |||
| public static AjaxResult success(Object data) { | |||
| return AjaxResult.success("操作成功", data); | |||
| } | |||
| /** | |||
| * 返回成功消息 | |||
| * | |||
| * | |||
| * @param msg 返回内容 | |||
| * @return 成功消息 | |||
| */ | |||
| public static AjaxResult success(String msg) | |||
| { | |||
| public static AjaxResult success(String msg) { | |||
| return AjaxResult.success(msg, null); | |||
| } | |||
| /** | |||
| * 返回成功消息 | |||
| * | |||
| * @param msg 返回内容 | |||
| * | |||
| * @param msg 返回内容 | |||
| * @param data 数据对象 | |||
| * @return 成功消息 | |||
| */ | |||
| public static AjaxResult success(String msg, Object data) | |||
| { | |||
| public static AjaxResult success(String msg, Object data) { | |||
| return new AjaxResult(HttpStatus.SUCCESS, msg, data); | |||
| } | |||
| @@ -108,65 +111,59 @@ public class AjaxResult extends HashMap<String, Object> | |||
| * @param msg 返回内容 | |||
| * @return 警告消息 | |||
| */ | |||
| public static AjaxResult warn(String msg) | |||
| { | |||
| public static AjaxResult warn(String msg) { | |||
| return AjaxResult.warn(msg, null); | |||
| } | |||
| /** | |||
| * 返回警告消息 | |||
| * | |||
| * @param msg 返回内容 | |||
| * @param msg 返回内容 | |||
| * @param data 数据对象 | |||
| * @return 警告消息 | |||
| */ | |||
| public static AjaxResult warn(String msg, Object data) | |||
| { | |||
| public static AjaxResult warn(String msg, Object data) { | |||
| return new AjaxResult(HttpStatus.WARN, msg, data); | |||
| } | |||
| /** | |||
| * 返回错误消息 | |||
| * | |||
| * | |||
| * @return 错误消息 | |||
| */ | |||
| public static AjaxResult error() | |||
| { | |||
| public static AjaxResult error() { | |||
| return AjaxResult.error("操作失败"); | |||
| } | |||
| /** | |||
| * 返回错误消息 | |||
| * | |||
| * | |||
| * @param msg 返回内容 | |||
| * @return 错误消息 | |||
| */ | |||
| public static AjaxResult error(String msg) | |||
| { | |||
| public static AjaxResult error(String msg) { | |||
| return AjaxResult.error(msg, null); | |||
| } | |||
| /** | |||
| * 返回错误消息 | |||
| * | |||
| * @param msg 返回内容 | |||
| * | |||
| * @param msg 返回内容 | |||
| * @param data 数据对象 | |||
| * @return 错误消息 | |||
| */ | |||
| public static AjaxResult error(String msg, Object data) | |||
| { | |||
| public static AjaxResult error(String msg, Object data) { | |||
| return new AjaxResult(HttpStatus.ERROR, msg, data); | |||
| } | |||
| /** | |||
| * 返回错误消息 | |||
| * | |||
| * | |||
| * @param code 状态码 | |||
| * @param msg 返回内容 | |||
| * @param msg 返回内容 | |||
| * @return 错误消息 | |||
| */ | |||
| public static AjaxResult error(int code, String msg) | |||
| { | |||
| public static AjaxResult error(int code, String msg) { | |||
| return new AjaxResult(code, msg, null); | |||
| } | |||
| @@ -175,8 +172,7 @@ public class AjaxResult extends HashMap<String, Object> | |||
| * | |||
| * @return 结果 | |||
| */ | |||
| public boolean isSuccess() | |||
| { | |||
| public boolean isSuccess() { | |||
| return Objects.equals(HttpStatus.SUCCESS, this.get(CODE_TAG)); | |||
| } | |||
| @@ -185,8 +181,7 @@ public class AjaxResult extends HashMap<String, Object> | |||
| * | |||
| * @return 结果 | |||
| */ | |||
| public boolean isWarn() | |||
| { | |||
| public boolean isWarn() { | |||
| return Objects.equals(HttpStatus.WARN, this.get(CODE_TAG)); | |||
| } | |||
| @@ -195,21 +190,19 @@ public class AjaxResult extends HashMap<String, Object> | |||
| * | |||
| * @return 结果 | |||
| */ | |||
| public boolean isError() | |||
| { | |||
| public boolean isError() { | |||
| return Objects.equals(HttpStatus.ERROR, this.get(CODE_TAG)); | |||
| } | |||
| /** | |||
| * 方便链式调用 | |||
| * | |||
| * @param key 键 | |||
| * @param key 键 | |||
| * @param value 值 | |||
| * @return 数据对象 | |||
| */ | |||
| @Override | |||
| public AjaxResult put(String key, Object value) | |||
| { | |||
| public AjaxResult put(String key, Object value) { | |||
| super.put(key, value); | |||
| return this; | |||
| } | |||
| @@ -1,9 +1,11 @@ | |||
| package com.ruoyi.system.domain; | |||
| import org.apache.commons.lang3.builder.ToStringBuilder; | |||
| import org.apache.commons.lang3.builder.ToStringStyle; | |||
| import com.ruoyi.common.annotation.Excel; | |||
| import com.ruoyi.common.core.domain.BaseEntity; | |||
| import lombok.Data; | |||
| import lombok.experimental.Accessors; | |||
| import java.util.List; | |||
| /** | |||
| * 手机菜单对象 sys_menuapp | |||
| @@ -11,6 +13,8 @@ import com.ruoyi.common.core.domain.BaseEntity; | |||
| * @author rongxin | |||
| * @date 2025-09-02 | |||
| */ | |||
| @Data | |||
| @Accessors(chain = true) | |||
| public class SysMenuapp extends BaseEntity | |||
| { | |||
| private static final long serialVersionUID = 1L; | |||
| @@ -42,91 +46,13 @@ public class SysMenuapp extends BaseEntity | |||
| @Excel(name = "菜单状态", dictType = "sys_normal_disable") | |||
| private String menuStatus; | |||
| public void setId(Long id) | |||
| { | |||
| this.id = id; | |||
| } | |||
| public Long getId() | |||
| { | |||
| return id; | |||
| } | |||
| public void setModelType(String modelType) | |||
| { | |||
| this.modelType = modelType; | |||
| } | |||
| public String getModelType() | |||
| { | |||
| return modelType; | |||
| } | |||
| public void setMenuName(String menuName) | |||
| { | |||
| this.menuName = menuName; | |||
| } | |||
| public String getMenuName() | |||
| { | |||
| return menuName; | |||
| } | |||
| public void setMenuUrl(String menuUrl) | |||
| { | |||
| this.menuUrl = menuUrl; | |||
| } | |||
| public String getMenuUrl() | |||
| { | |||
| return menuUrl; | |||
| } | |||
| public void setMenuIcon(String menuIcon) | |||
| { | |||
| this.menuIcon = menuIcon; | |||
| } | |||
| public String getMenuIcon() | |||
| { | |||
| return menuIcon; | |||
| } | |||
| public void setMenuNum(Integer menuNum) | |||
| { | |||
| this.menuNum = menuNum; | |||
| } | |||
| public Integer getMenuNum() | |||
| { | |||
| return menuNum; | |||
| } | |||
| public void setMenuStatus(String menuStatus) | |||
| { | |||
| this.menuStatus = menuStatus; | |||
| } | |||
| public String getMenuStatus() | |||
| { | |||
| return menuStatus; | |||
| } | |||
| @Override | |||
| public String toString() { | |||
| return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) | |||
| .append("id", getId()) | |||
| .append("modelType", getModelType()) | |||
| .append("menuName", getMenuName()) | |||
| .append("menuUrl", getMenuUrl()) | |||
| .append("menuIcon", getMenuIcon()) | |||
| .append("menuNum", getMenuNum()) | |||
| .append("menuStatus", getMenuStatus()) | |||
| .append("remark", getRemark()) | |||
| .append("createBy", getCreateBy()) | |||
| .append("createTime", getCreateTime()) | |||
| .append("updateBy", getUpdateBy()) | |||
| .append("updateTime", getUpdateTime()) | |||
| .toString(); | |||
| } | |||
| /** 菜单分组列表 */ | |||
| private List<SysMenuapp> menus; | |||
| /** 角色ID */ | |||
| private Long roleId; | |||
| } | |||
| @@ -0,0 +1,25 @@ | |||
| package com.ruoyi.system.domain; | |||
| import com.ruoyi.common.core.domain.BaseEntity; | |||
| import lombok.Data; | |||
| import lombok.experimental.Accessors; | |||
| /** | |||
| * 角色和手机菜单关联对象 sys_role_menuapp | |||
| * | |||
| * @author rongxin | |||
| * @date 2025-09-02 | |||
| */ | |||
| @Data | |||
| @Accessors(chain = true) | |||
| public class SysRoleMenuapp extends BaseEntity { | |||
| /** 角色ID */ | |||
| private Long roleId; | |||
| /** 菜单ID */ | |||
| private Long appId; | |||
| } | |||
| @@ -1,6 +1,7 @@ | |||
| package com.ruoyi.system.mapper; | |||
| import com.ruoyi.system.domain.SysMenuapp; | |||
| import org.apache.ibatis.annotations.Param; | |||
| import java.util.List; | |||
| @@ -28,6 +29,10 @@ public interface SysMenuappMapper | |||
| */ | |||
| public List<SysMenuapp> selectSysMenuappList(SysMenuapp sysMenuapp); | |||
| public List<SysMenuapp> selectAllocatedList(SysMenuapp sysMenuapp); | |||
| public List<SysMenuapp> selectUnallocatedList(SysMenuapp sysMenuapp); | |||
| /** | |||
| * 新增手机菜单 | |||
| * | |||
| @@ -75,4 +80,6 @@ public interface SysMenuappMapper | |||
| * @return 结果 | |||
| */ | |||
| public int deleteSysMenuappByIds(Long[] ids); | |||
| public List<SysMenuapp> selectSysMobileListByUserId(@Param("userId") Long userId, @Param("query") SysMenuapp query); | |||
| } | |||
| @@ -0,0 +1,84 @@ | |||
| package com.ruoyi.system.mapper; | |||
| import com.ruoyi.system.domain.SysRoleMenuapp; | |||
| import org.apache.ibatis.annotations.Param; | |||
| import java.util.List; | |||
| /** | |||
| * 角色和手机菜单关联Mapper接口 | |||
| * | |||
| * @author rongxin | |||
| * @date 2025-09-02 | |||
| */ | |||
| public interface SysRoleMenuappMapper | |||
| { | |||
| /** | |||
| * 查询角色和手机菜单关联 | |||
| * | |||
| * @param roleId 角色和手机菜单关联主键 | |||
| * @return 角色和手机菜单关联 | |||
| */ | |||
| public SysRoleMenuapp selectSysRoleMenuappByRoleId(Long roleId); | |||
| /** | |||
| * 查询角色和手机菜单关联列表 | |||
| * | |||
| * @param sysRoleMenuapp 角色和手机菜单关联 | |||
| * @return 角色和手机菜单关联集合 | |||
| */ | |||
| public List<SysRoleMenuapp> selectSysRoleMenuappList(SysRoleMenuapp sysRoleMenuapp); | |||
| /** | |||
| * 新增角色和手机菜单关联 | |||
| * | |||
| * @param sysRoleMenuapp 角色和手机菜单关联 | |||
| * @return 结果 | |||
| */ | |||
| public int insertSysRoleMenuapp(SysRoleMenuapp sysRoleMenuapp); | |||
| /** | |||
| * 批量新增角色和手机菜单关联 | |||
| * | |||
| * @param list 角色和手机菜单关联 | |||
| * @return 结果 | |||
| */ | |||
| public int insertSysRoleMenuappBatch(List<SysRoleMenuapp> list); | |||
| /** | |||
| * 修改角色和手机菜单关联 | |||
| * | |||
| * @param sysRoleMenuapp 角色和手机菜单关联 | |||
| * @return 结果 | |||
| */ | |||
| public int updateSysRoleMenuapp(SysRoleMenuapp sysRoleMenuapp); | |||
| /** | |||
| * 批量修改 角色和手机菜单关联 | |||
| * | |||
| * @param list 角色和手机菜单关联 | |||
| * @return 结果 | |||
| */ | |||
| public int updateSysRoleMenuappBatch(List<SysRoleMenuapp> list); | |||
| /** | |||
| * 删除角色和手机菜单关联 | |||
| * | |||
| * @param roleId 角色和手机菜单关联主键 | |||
| * @return 结果 | |||
| */ | |||
| public int deleteSysRoleMenuappByRoleId(Long roleId); | |||
| /** | |||
| * 批量删除角色和手机菜单关联 | |||
| * | |||
| * @param roleIds 需要删除的数据主键集合 | |||
| * @return 结果 | |||
| */ | |||
| public int deleteSysRoleMenuappByRoleIds(Long[] roleIds); | |||
| public int deleteAuthApp(SysRoleMenuapp sysRoleMenuapp); | |||
| public int deleteAuthApps(@Param("roleId") Long roleId, @Param("appIds") Long[] appIds); | |||
| } | |||
| @@ -28,6 +28,10 @@ public interface ISysMenuappService | |||
| */ | |||
| public List<SysMenuapp> selectSysMenuappList(SysMenuapp sysMenuapp); | |||
| public List<SysMenuapp> selectAllocatedList(SysMenuapp sysMenuapp); | |||
| public List<SysMenuapp> selectUnallocatedList(SysMenuapp sysMenuapp); | |||
| /** | |||
| * 导入手机菜单数据 | |||
| * | |||
| @@ -85,4 +89,6 @@ public interface ISysMenuappService | |||
| * @return 结果 | |||
| */ | |||
| public int deleteSysMenuappById(Long id); | |||
| public List<SysMenuapp> selectSysMobileListByUserId(Long userId, SysMenuapp query); | |||
| } | |||
| @@ -0,0 +1,87 @@ | |||
| package com.ruoyi.system.service; | |||
| import com.ruoyi.system.domain.SysRoleMenuapp; | |||
| import java.util.List; | |||
| /** | |||
| * 角色和手机菜单关联Service接口 | |||
| * | |||
| * @author rongxin | |||
| * @date 2025-09-02 | |||
| */ | |||
| public interface ISysRoleMenuappService | |||
| { | |||
| /** | |||
| * 查询角色和手机菜单关联 | |||
| * | |||
| * @param roleId 角色和手机菜单关联主键 | |||
| * @return 角色和手机菜单关联 | |||
| */ | |||
| public SysRoleMenuapp selectSysRoleMenuappByRoleId(Long roleId); | |||
| /** | |||
| * 查询角色和手机菜单关联列表 | |||
| * | |||
| * @param sysRoleMenuapp 角色和手机菜单关联 | |||
| * @return 角色和手机菜单关联集合 | |||
| */ | |||
| public List<SysRoleMenuapp> selectSysRoleMenuappList(SysRoleMenuapp sysRoleMenuapp); | |||
| /** | |||
| * 新增角色和手机菜单关联 | |||
| * | |||
| * @param sysRoleMenuapp 角色和手机菜单关联 | |||
| * @return 结果 | |||
| */ | |||
| public int insertSysRoleMenuapp(SysRoleMenuapp sysRoleMenuapp); | |||
| /** | |||
| * 批量新增角色和手机菜单关联 | |||
| * | |||
| * @param list 角色和手机菜单关联 | |||
| * @return 结果 | |||
| */ | |||
| public int insertSysRoleMenuappBatch(List<SysRoleMenuapp> list); | |||
| /** | |||
| * 修改角色和手机菜单关联 | |||
| * | |||
| * @param sysRoleMenuapp 角色和手机菜单关联 | |||
| * @return 结果 | |||
| */ | |||
| public int updateSysRoleMenuapp(SysRoleMenuapp sysRoleMenuapp); | |||
| /** | |||
| * 批量修改 角色和手机菜单关联 | |||
| * | |||
| * @param list 角色和手机菜单关联 | |||
| * @return 结果 | |||
| */ | |||
| public int updateSysRoleMenuappBatch(List<SysRoleMenuapp> list); | |||
| /** | |||
| * 批量删除角色和手机菜单关联 | |||
| * | |||
| * @param roleIds 需要删除的角色和手机菜单关联主键集合 | |||
| * @return 结果 | |||
| */ | |||
| public int deleteSysRoleMenuappByRoleIds(Long[] roleIds); | |||
| /** | |||
| * 删除角色和手机菜单关联信息 | |||
| * | |||
| * @param roleId 角色和手机菜单关联主键 | |||
| * @return 结果 | |||
| */ | |||
| public int deleteSysRoleMenuappByRoleId(Long roleId); | |||
| public int setupRoleMobiles(Long roleId, List<Long> mobileIds); | |||
| public int deleteAuthApp(SysRoleMenuapp sysRoleMenuapp); | |||
| public int deleteAuthApps(Long roleId, Long[] appIds); | |||
| public int insertAuthApps(Long roleId, Long[] appIds); | |||
| } | |||
| @@ -51,6 +51,16 @@ public class SysMenuappServiceImpl implements ISysMenuappService | |||
| return sysMenuappMapper.selectSysMenuappList(sysMenuapp); | |||
| } | |||
| @Override | |||
| public List<SysMenuapp> selectAllocatedList(SysMenuapp sysMenuapp) { | |||
| return sysMenuappMapper.selectAllocatedList(sysMenuapp); | |||
| } | |||
| @Override | |||
| public List<SysMenuapp> selectUnallocatedList(SysMenuapp sysMenuapp) { | |||
| return sysMenuappMapper.selectUnallocatedList(sysMenuapp); | |||
| } | |||
| /** | |||
| * 导入手机菜单数据 | |||
| * | |||
| @@ -194,4 +204,9 @@ public class SysMenuappServiceImpl implements ISysMenuappService | |||
| { | |||
| return sysMenuappMapper.deleteSysMenuappById(id); | |||
| } | |||
| @Override | |||
| public List<SysMenuapp> selectSysMobileListByUserId(Long userId, SysMenuapp query) { | |||
| return sysMenuappMapper.selectSysMobileListByUserId(userId, query); | |||
| } | |||
| } | |||
| @@ -0,0 +1,164 @@ | |||
| package com.ruoyi.system.service.impl; | |||
| import cn.hutool.core.collection.CollectionUtil; | |||
| import cn.hutool.core.collection.ListUtil; | |||
| import com.ruoyi.system.domain.SysRoleMenuapp; | |||
| import com.ruoyi.system.mapper.SysRoleMenuappMapper; | |||
| import com.ruoyi.system.service.ISysRoleMenuappService; | |||
| import org.apache.commons.collections4.ListUtils; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.stereotype.Service; | |||
| import org.springframework.transaction.annotation.Transactional; | |||
| import java.util.ArrayList; | |||
| import java.util.List; | |||
| import java.util.stream.Collectors; | |||
| /** | |||
| * 角色和手机菜单关联Service业务层处理 | |||
| * | |||
| * @author rongxin | |||
| * @date 2025-09-02 | |||
| */ | |||
| @Service | |||
| public class SysRoleMenuappServiceImpl implements ISysRoleMenuappService { | |||
| @Autowired | |||
| private SysRoleMenuappMapper sysRoleMenuappMapper; | |||
| /** | |||
| * 查询角色和手机菜单关联 | |||
| * | |||
| * @param roleId 角色和手机菜单关联主键 | |||
| * @return 角色和手机菜单关联 | |||
| */ | |||
| @Override | |||
| public SysRoleMenuapp selectSysRoleMenuappByRoleId(Long roleId) { | |||
| return sysRoleMenuappMapper.selectSysRoleMenuappByRoleId(roleId); | |||
| } | |||
| /** | |||
| * 查询角色和手机菜单关联列表 | |||
| * | |||
| * @param sysRoleMenuapp 角色和手机菜单关联 | |||
| * @return 角色和手机菜单关联 | |||
| */ | |||
| @Override | |||
| public List<SysRoleMenuapp> selectSysRoleMenuappList(SysRoleMenuapp sysRoleMenuapp) { | |||
| return sysRoleMenuappMapper.selectSysRoleMenuappList(sysRoleMenuapp); | |||
| } | |||
| /** | |||
| * 新增角色和手机菜单关联 | |||
| * | |||
| * @param sysRoleMenuapp 角色和手机菜单关联 | |||
| * @return 结果 | |||
| */ | |||
| @Override | |||
| public int insertSysRoleMenuapp(SysRoleMenuapp sysRoleMenuapp) { | |||
| return sysRoleMenuappMapper.insertSysRoleMenuapp(sysRoleMenuapp); | |||
| } | |||
| /** | |||
| * 批量新增角色和手机菜单关联 | |||
| * | |||
| * @param list 角色和手机菜单关联 | |||
| * @return 结果 | |||
| */ | |||
| @Override | |||
| @Transactional | |||
| public int insertSysRoleMenuappBatch(List<SysRoleMenuapp> list) { | |||
| List<List<SysRoleMenuapp>> splists = ListUtils.partition(list, 50); | |||
| splists.forEach(splist -> { | |||
| sysRoleMenuappMapper.insertSysRoleMenuappBatch(splist); | |||
| }); | |||
| return 1; | |||
| } | |||
| /** | |||
| * 修改角色和手机菜单关联 | |||
| * | |||
| * @param sysRoleMenuapp 角色和手机菜单关联 | |||
| * @return 结果 | |||
| */ | |||
| @Override | |||
| public int updateSysRoleMenuapp(SysRoleMenuapp sysRoleMenuapp) { | |||
| return sysRoleMenuappMapper.updateSysRoleMenuapp(sysRoleMenuapp); | |||
| } | |||
| /** | |||
| * 批量修改 角色和手机菜单关联 | |||
| * | |||
| * @param list 角色和手机菜单关联 | |||
| * @return 结果 | |||
| */ | |||
| @Override | |||
| @Transactional | |||
| public int updateSysRoleMenuappBatch(List<SysRoleMenuapp> list) { | |||
| List<List<SysRoleMenuapp>> splists = ListUtils.partition(list, 30); | |||
| splists.forEach(splist -> { | |||
| sysRoleMenuappMapper.updateSysRoleMenuappBatch(splist); | |||
| }); | |||
| return 1; | |||
| } | |||
| /** | |||
| * 批量删除角色和手机菜单关联 | |||
| * | |||
| * @param roleIds 需要删除的角色和手机菜单关联主键 | |||
| * @return 结果 | |||
| */ | |||
| @Override | |||
| public int deleteSysRoleMenuappByRoleIds(Long[] roleIds) { | |||
| return sysRoleMenuappMapper.deleteSysRoleMenuappByRoleIds(roleIds); | |||
| } | |||
| /** | |||
| * 删除角色和手机菜单关联信息 | |||
| * | |||
| * @param roleId 角色和手机菜单关联主键 | |||
| * @return 结果 | |||
| */ | |||
| @Override | |||
| public int deleteSysRoleMenuappByRoleId(Long roleId) { | |||
| return sysRoleMenuappMapper.deleteSysRoleMenuappByRoleId(roleId); | |||
| } | |||
| @Override | |||
| @Transactional(rollbackFor = Exception.class) | |||
| public int setupRoleMobiles(Long roleId, List<Long> mobileIds) { | |||
| sysRoleMenuappMapper.deleteSysRoleMenuappByRoleId(roleId); | |||
| if (CollectionUtil.isNotEmpty(mobileIds)) { | |||
| List<SysRoleMenuapp> roles = mobileIds.stream().map((x) -> new SysRoleMenuapp().setRoleId(roleId).setAppId(x)).collect(Collectors.toList()); | |||
| ListUtil.split(roles, 50).forEach(sysRoleMenuappMapper::insertSysRoleMenuappBatch); | |||
| } | |||
| return 1; | |||
| } | |||
| @Override | |||
| public int deleteAuthApp(SysRoleMenuapp sysRoleMenuapp) { | |||
| return sysRoleMenuappMapper.deleteAuthApp(sysRoleMenuapp); | |||
| } | |||
| @Override | |||
| public int deleteAuthApps(Long roleId, Long[] appIds) { | |||
| return sysRoleMenuappMapper.deleteAuthApps(roleId, appIds); | |||
| } | |||
| @Override | |||
| public int insertAuthApps(Long roleId, Long[] appIds) | |||
| { | |||
| // 新增用户与角色管理 | |||
| List<SysRoleMenuapp> list = new ArrayList<SysRoleMenuapp>(); | |||
| for (Long appId : appIds) | |||
| { | |||
| SysRoleMenuapp ur = new SysRoleMenuapp(); | |||
| ur.setAppId(appId); | |||
| ur.setRoleId(roleId); | |||
| list.add(ur); | |||
| } | |||
| return sysRoleMenuappMapper.insertSysRoleMenuappBatch(list); | |||
| } | |||
| } | |||
| @@ -149,4 +149,40 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | |||
| #{id} | |||
| </foreach> | |||
| </delete> | |||
| <select id="selectAllocatedList" parameterType="SysMenuapp" resultMap="SysMenuappResult"> | |||
| select u.id, u.model_type, u.menu_name, u.menu_url, u.menu_icon, u.menu_num, u.menu_status, u.remark | |||
| from sys_menuapp u | |||
| left join sys_role_menuapp ur on u.id = ur.app_id | |||
| left join sys_role r on r.role_id = ur.role_id | |||
| where r.role_id = #{roleId} | |||
| </select> | |||
| <select id="selectUnallocatedList" parameterType="SysMenuapp" resultMap="SysMenuappResult"> | |||
| select u.id, u.model_type, u.menu_name, u.menu_url, u.menu_icon, u.menu_num, u.menu_status, u.remark | |||
| from sys_menuapp u | |||
| left join sys_role_menuapp ur on u.id = ur.app_id | |||
| left join sys_role r on r.role_id = ur.role_id | |||
| where u.id not in (select u.id from sys_menuapp u inner join sys_role_menuapp ur on u.id = ur.app_id and ur.role_id = #{roleId}) | |||
| </select> | |||
| <select id="selectSysMobileListByUserId" resultMap="SysMenuappResult"> | |||
| SELECT t.id, t.identity_type, t.modle_name, t.menu_name, t.order_num, t.menu_icon, t.menu_url, t.url_para, t.sys_normal_disable, t.remark, t.create_by, t.create_time, t.update_by, t.update_time FROM sys_mobile t | |||
| JOIN sys_role_mobile rm ON rm.mobile_id = t.id | |||
| JOIN sys_user_role ur ON ur.role_id = rm.role_id | |||
| JOIN sys_user u ON u.user_id = ur.user_id | |||
| JOIN sys_role r ON r.role_id = ur.role_id | |||
| <where> | |||
| u.user_id = #{userId} | |||
| AND t.sys_normal_disable = '0' | |||
| AND r.status = '0' | |||
| <if test="query != null"> | |||
| <if test="query.identityType != null and query.identityType != ''"> and t.identity_type = #{query.identityType}</if> | |||
| <if test="query.modleName != null and query.modleName != ''"> and t.modle_name = #{query.modleName}</if> | |||
| <if test="query.menuName != null and query.menuName != ''"> and t.menu_name like concat('%', #{query.menuName}, '%')</if> | |||
| </if> | |||
| </where> | |||
| </select> | |||
| </mapper> | |||
| @@ -0,0 +1,98 @@ | |||
| <?xml version="1.0" encoding="UTF-8" ?> | |||
| <!DOCTYPE mapper | |||
| PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | |||
| "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |||
| <mapper namespace="com.ruoyi.system.mapper.SysRoleMenuappMapper"> | |||
| <resultMap type="SysRoleMenuapp" id="SysRoleMenuappResult"> | |||
| <result property="roleId" column="role_id" /> | |||
| <result property="appId" column="app_id" /> | |||
| </resultMap> | |||
| <sql id="selectSysRoleMenuappVo"> | |||
| select role_id, app_id from sys_role_menuapp | |||
| </sql> | |||
| <select id="selectSysRoleMenuappList" parameterType="SysRoleMenuapp" resultMap="SysRoleMenuappResult"> | |||
| <include refid="selectSysRoleMenuappVo"/> | |||
| <where> | |||
| <if test="appId != null">and app_id = #{appId}</if> | |||
| <if test="roleId != null">and role_id = #{roleId}</if> | |||
| </where> | |||
| </select> | |||
| <select id="selectSysRoleMenuappByRoleId" parameterType="Long" resultMap="SysRoleMenuappResult"> | |||
| <include refid="selectSysRoleMenuappVo"/> | |||
| where role_id = #{roleId} | |||
| </select> | |||
| <insert id="insertSysRoleMenuapp" parameterType="SysRoleMenuapp"> | |||
| insert into sys_role_menuapp | |||
| <trim prefix="(" suffix=")" suffixOverrides=","> | |||
| <if test="roleId != null">role_id,</if> | |||
| <if test="appId != null">app_id,</if> | |||
| </trim> | |||
| <trim prefix="values (" suffix=")" suffixOverrides=","> | |||
| <if test="roleId != null">#{roleId},</if> | |||
| <if test="appId != null">#{appId},</if> | |||
| </trim> | |||
| </insert> | |||
| <insert id="insertSysRoleMenuappBatch" parameterType="list" > | |||
| insert into sys_role_menuapp | |||
| <trim prefix="(" suffix=")" suffixOverrides=","> | |||
| role_id, | |||
| app_id, | |||
| </trim> | |||
| values | |||
| <foreach item="item" collection="list" separator="," > | |||
| <trim prefix="(" suffix=")" suffixOverrides=","> | |||
| #{item.roleId}, | |||
| #{item.appId}, | |||
| </trim> | |||
| </foreach> | |||
| </insert> | |||
| <update id="updateSysRoleMenuapp" parameterType="SysRoleMenuapp"> | |||
| update sys_role_menuapp | |||
| <trim prefix="SET" suffixOverrides=","> | |||
| <if test="appId != null">app_id = #{appId},</if> | |||
| </trim> | |||
| where role_id = #{roleId} | |||
| </update> | |||
| <!--批量更新--> | |||
| <update id="updateSysRoleMenuappBatch" parameterType="list" > | |||
| <foreach collection="list" item="item" index="index" open="" close="" separator=";"> | |||
| update sys_role_menuapp | |||
| <set> | |||
| <if test="item.appId != null">app_id = #{item.appId},</if> | |||
| </set> | |||
| where role_id = #{item.roleId} | |||
| </foreach> | |||
| </update> | |||
| <delete id="deleteSysRoleMenuappByRoleId" parameterType="Long"> | |||
| delete from sys_role_menuapp where role_id = #{roleId} | |||
| </delete> | |||
| <delete id="deleteSysRoleMenuappByRoleIds" parameterType="String"> | |||
| delete from sys_role_menuapp where role_id in | |||
| <foreach item="roleId" collection="array" open="(" separator="," close=")"> | |||
| #{roleId} | |||
| </foreach> | |||
| </delete> | |||
| <delete id="deleteAuthApp" parameterType="SysRoleMenuapp"> | |||
| delete from sys_role_menuapp where app_id = #{appId} and role_id = #{roleId} | |||
| </delete> | |||
| <delete id="deleteAuthApps"> | |||
| delete from sys_role_menuapp where role_id = #{roleId} and app_id in | |||
| <foreach collection="appIds" item="appId" open="(" separator="," close=")"> | |||
| #{appId} | |||
| </foreach> | |||
| </delete> | |||
| </mapper> | |||