src/main/java/com/moral/controller/ScreenController.java | ●●●●● patch | view | raw | blame | history | |
src/main/java/com/moral/mapper/AccountMapper.java | ●●●●● patch | view | raw | blame | history | |
src/main/java/com/moral/service/AccountService.java | ●●●●● patch | view | raw | blame | history | |
src/main/java/com/moral/service/impl/AccountServiceImpl.java | ●●●●● patch | view | raw | blame | history | |
src/main/resources/mapper/AccountMapper.xml | ●●●●● patch | view | raw | blame | history |
src/main/java/com/moral/controller/ScreenController.java
@@ -247,6 +247,58 @@ return resultMap; } @GetMapping("loginNew") public Map<String, Object> screenLoginNew(HttpServletRequest request) { Map<String, Object> resultMap = new HashMap<String, Object>(); Map<String, Object> parameters = getParametersStartingWith(request, null); if (!(parameters.containsKey("account") && parameters.containsKey("password"))) { resultMap.put("msg", "用户名及密码不允许为空!"); resultMap.put("accountId", -1); } else { resultMap = accountService.screenLoginNew(parameters); // 添加返回行政区信息字符串操作 Object orgId = resultMap.get("orgId"); if (resultMap.get("orgId") != null && resultMap.get("orgId") instanceof Integer) { StringBuilder areaNamesBuilder = new StringBuilder("中国"); if (!((Integer) orgId).equals(dictionaryDataService.querySupperOrgId())) { Organization organization = organizationService.getOrganizationById((Integer) orgId); if (organization.getAreaNames() != null) { Map<String, String> areaNameMap = BeanUtils.beanToMap(organization.getAreaNames()); List<String> names = areaNameMap.entrySet().stream().filter(item -> { return item.getValue() != null; }).map(item -> { return item.getValue(); }).collect(Collectors.toList()); AreaNames areaNames = organization.getAreaNames(); areaNamesBuilder.append("/"); areaNamesBuilder.append(String.join("/", names)); } // 企业用户 if (organization.getRank() != null && organization.getRank() == 0) { resultMap.put("type", "enterprise"); } else { resultMap.put("type", "government"); } Number mapAreaCode = null; if (organization.getVillageCode() != null) { mapAreaCode = organization.getVillageCode(); } else if (organization.getTownCode() != null) { mapAreaCode = organization.getTownCode(); } else if (organization.getAreaCode() != null) { mapAreaCode = organization.getAreaCode(); } else if (organization.getCityCode() != null) { mapAreaCode = organization.getCityCode(); } else if (organization.getProvinceCode() != null) { mapAreaCode = organization.getProvinceCode(); } resultMap.put("mapAreaCode", mapAreaCode.toString()); } resultMap.put("mapPath", areaNamesBuilder.toString()); } } return resultMap; } /** * Gets the equipment states. 获取该账号下所有设备的状态 * src/main/java/com/moral/mapper/AccountMapper.java
@@ -28,4 +28,8 @@ List<Menu> getChildMenuIdsByAccountName(@Param("accountName") String accountName, @Param("id") Integer id); List<Menu> getScreenMenuListsByAccountName(@Param("accountName") String accountName); Integer getScreenRoleByAccountName(@Param("accountName") String accountName); } src/main/java/com/moral/service/AccountService.java
@@ -12,6 +12,8 @@ Map<String, Object> screenLogin(Map<String, Object> parameters); Map<String, Object> screenLoginNew(Map<String, Object> parameters); Account getAccountByAccountName(String account); Account getAccountById(Integer id); src/main/java/com/moral/service/impl/AccountServiceImpl.java
@@ -82,6 +82,37 @@ } @Override public Map<String, Object> screenLoginNew(Map<String, Object> parameters) { Map<String, Object> result = new HashMap<String, Object>(); Account account = new Account(); account.setAccountName((String) parameters.get("account")); String rawPassword = (String) parameters.get("password"); // account.setPassword(encoder.encode((String) parameters.get("password"))); account = accountMapper.selectOne(account); Integer existRole=accountMapper.getScreenRoleByAccountName(account.getAccountName()); List<Menu> menuList = accountMapper.getScreenMenuListsByAccountName(account.getAccountName()); boolean isValid = account == null ? false : encoder.matches(rawPassword, account.getPassword()); if (!isValid) { result.put("msg", "用户名及密码输入错误!"); } else { if (IS_DELETE_FALSE.equals(account.getIsDelete())) { if(existRole!=null) { result.put("msg", "登录成功!"); result.put("accountId", account.getId()); result.put("orgId", account.getOrganizationId()); result.put("data",menuList); setOrgIdsByAccount(result); }else{ result.put("msg", "账户没有权限!"); } } else { result.put("msg", "您的账号已禁用,请联系管理员!"); } } return result; } @Override public Account getAccountByAccountName(String accountName) { Account account = new Account(); account.setAccountName(accountName); src/main/resources/mapper/AccountMapper.xml
@@ -88,6 +88,19 @@ a.account_name = #{accountName} and r.id is not null </select> <select id="getScreenRoleByAccountName" resultType="int"> SELECT channel_id from (select DISTINCT channel_id FROM role_menu WHERE role_id in ( select r.id from role r right join account_role ar on ar.role_id = r.id right join account a on a.id = ar.account_id where a.account_name = #{accountName} and r.id is not null)) s where s.channel_id=1; </select> <select id="getParentMenuListsByAccountName" resultMap="MenuResultMap" parameterType="java.lang.String"> select DISTINCT @@ -143,4 +156,28 @@ where account_name = #{accountName} </select> <select id="getScreenMenuListsByAccountName" resultMap="MenuResultMap" parameterType="java.lang.String"> select DISTINCT m.id,m.menu_name,m.menu_icon,m.menu_url,m.menu_order,m.menu_parent_id from menu m right join role_menu rm on rm.channel_id = m.channel_id and rm.menu_id=m.id and m.channel_id=1 right join role on rm.role_id in ( select r.id from role r right join account_role ar on ar.role_id = r.id right join account a on a.id = ar.account_id where a.account_name = #{accountName} and r.is_delete=0 and r.id is not null ) where m.menu_parent_id=0 and m.is_delete=0 order by m.menu_order </select> </mapper>