| | |
| | | import com.sinata.common.exception.ServiceException; |
| | | import com.sinata.common.utils.BeanUtils; |
| | | import com.sinata.common.utils.CollUtils; |
| | | import com.sinata.common.utils.DateUtils; |
| | | import com.sinata.common.utils.SecurityUtils; |
| | | import com.sinata.common.utils.StringUtils; |
| | | import com.sinata.common.utils.spring.SpringUtils; |
| | |
| | | @Override |
| | | public void saveRole(SysRoleDTO dto) { |
| | | SysRole sysRole = BeanUtils.copyBean(dto, SysRole.class); |
| | | |
| | | if (!this.checkRoleNameUnique(sysRole)) { |
| | | throw new ServiceException("保存角色'" + sysRole.getRoleName() + "'失败,角色名称已存在"); |
| | | } |
| | | if (Objects.isNull(sysRole.getRoleId())) { |
| | | sysRole.setCreateBy(SecurityUtils.getUserId().toString()); |
| | | sysRole.setCreateTime(DateUtils.getNowDate()); |
| | | baseMapper.insert(sysRole); |
| | | } else { |
| | | // 删除角色与菜单关联 |
| | | roleMenuMapper.deleteRoleMenuByRoleId(sysRole.getRoleId()); |
| | | sysRole.setUpdateBy(SecurityUtils.getUserId().toString()); |
| | | sysRole.setUpdateTime(DateUtils.getNowDate()); |
| | | baseMapper.updateById(sysRole); |
| | | } |
| | | insertRoleMenu(sysRole); |