| | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * Created by johnny on 17/11/18. |
| | |
| | | } |
| | | |
| | | @Transactional(propagation = Propagation.REQUIRED) |
| | | public BaseRole getBaseRole(String id) { |
| | | public BaseRole getBaseRole(Long id) { |
| | | try { |
| | | BaseRole baseRole = this.baseRoleDao.getBaseRole(id); |
| | | List<BaseRolePage> baseRolePageList = this.baseRolePageService.getBaseRolePageList(id, null); |
| | | if (baseRolePageList != null && baseRolePageList.size() > 0) { |
| | | List<String> pageIdList = new ArrayList<String>(); |
| | | List<Long> pageIdList = new ArrayList<Long>(); |
| | | for (BaseRolePage baseRolePage : baseRolePageList) { |
| | | pageIdList.add(baseRolePage.getPageId()); |
| | | } |
| | |
| | | } |
| | | |
| | | @Transactional(propagation = Propagation.REQUIRED) |
| | | public boolean isBaseRoleExist(String name, String editId) { |
| | | public boolean isBaseRoleExist(String name, Long editId) { |
| | | try { |
| | | Map<String, Object> params = new HashMap<String, Object>(); |
| | | if (StringUtils.isNotBlank(name)) { |
| | | params.put("name", name); |
| | | } |
| | | if (StringUtils.isNotBlank(editId)) { |
| | | if (editId!=null) { |
| | | params.put("editId", editId); |
| | | } |
| | | int count = this.baseRoleDao.getBaseRoleTotalCount(params); |
| | |
| | | @Transactional(propagation = Propagation.REQUIRED) |
| | | public BaseRole insertBaseRole(BaseRole baseRole) { |
| | | try { |
| | | if (baseRole.getId() == null) { |
| | | baseRole.setId(IDUtils.uuid()); |
| | | } |
| | | this.baseRoleDao.insertBaseRole(baseRole); |
| | | if (baseRole.getPageIdList() != null) { |
| | | BaseRolePage baseRolePage = null; |
| | | for (String pageId : baseRole.getPageIdList()) { |
| | | baseRolePage = new BaseRolePage(); |
| | | baseRolePage.setId(IDUtils.uuid()); |
| | | List<Long> pageIdList=baseRole.getPageIdList(); |
| | | List<BaseRolePage> baseRolePages=new ArrayList<>(); |
| | | for(int i=0;i<pageIdList.size();i++){ |
| | | //前端id被处理成了字符串,映射到后台变成了char,进行数据强转 |
| | | Long pageId = Long.valueOf(((Object) pageIdList.get(i)).toString()); |
| | | BaseRolePage baseRolePage = new BaseRolePage(); |
| | | baseRolePage.setRoleId(baseRole.getId()); |
| | | baseRolePage.setPageId(pageId); |
| | | this.baseRolePageService.insertBaseRolePage(baseRolePage); |
| | | baseRolePages.add(baseRolePage); |
| | | } |
| | | this.baseRolePageService.batchInsertBaseRolePage(baseRolePages); |
| | | } |
| | | |
| | | return baseRole; |
| | | } catch (DuplicateKeyException ex) { |
| | | logger.warn(ex.getMessage(), ex); |
| | |
| | | int row = this.baseRoleDao.updateBaseRole(baseRole); |
| | | this.baseRolePageService.deleteBaseRolePage(baseRole.getId()); |
| | | if (baseRole.getPageIdList() != null) { |
| | | BaseRolePage baseRolePage = null; |
| | | for (String pageId : baseRole.getPageIdList()) { |
| | | baseRolePage = new BaseRolePage(); |
| | | baseRolePage.setId(IDUtils.uuid()); |
| | | List<Long> pageIdList=baseRole.getPageIdList(); |
| | | List<BaseRolePage> baseRolePages=new ArrayList<>(); |
| | | for(int i=0;i<pageIdList.size();i++){ |
| | | //前端id被处理成了字符串,映射到后台变成了char,进行数据强转 |
| | | Long pageId = Long.valueOf(((Object) pageIdList.get(i)).toString()); |
| | | BaseRolePage baseRolePage = new BaseRolePage(); |
| | | baseRolePage.setRoleId(baseRole.getId()); |
| | | baseRolePage.setPageId(pageId); |
| | | this.baseRolePageService.insertBaseRolePage(baseRolePage); |
| | | baseRolePages.add(baseRolePage); |
| | | } |
| | | this.baseRolePageService.batchInsertBaseRolePage(baseRolePages); |
| | | } |
| | | |
| | | if (row == 0) { |
| | |
| | | return false; |
| | | } |
| | | |
| | | List<String> ids = new ArrayList<String>(); |
| | | List<Long> ids = new ArrayList<Long>(); |
| | | for (BaseRole baseRole : baseRoleList) { |
| | | ids.add(baseRole.getId()); |
| | | } |
| | |
| | | } |
| | | |
| | | @Override |
| | | public BaseRole getRoleByUserId(String id) { |
| | | public BaseRole getRoleByUserId(Long id) { |
| | | return baseRoleDao.getBaseRoleByUser(id); |
| | | } |
| | | } |