From 3d76bad0a7562441d75768f7e4e677f686037582 Mon Sep 17 00:00:00 2001
From: jinpengyong <jpy123456>
Date: Tue, 01 Dec 2020 13:16:09 +0800
Subject: [PATCH] 实施页面hour-aqi更新

---
 src/main/java/com/moral/service/impl/AccountServiceImpl.java |  165 ++++++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 150 insertions(+), 15 deletions(-)

diff --git a/src/main/java/com/moral/service/impl/AccountServiceImpl.java b/src/main/java/com/moral/service/impl/AccountServiceImpl.java
index 5b671e4..7bbcbe8 100644
--- a/src/main/java/com/moral/service/impl/AccountServiceImpl.java
+++ b/src/main/java/com/moral/service/impl/AccountServiceImpl.java
@@ -12,6 +12,9 @@
 
 import javax.annotation.Resource;
 
+import com.moral.entity.*;
+import com.moral.mapper.DictionaryDataMapper;
+
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
 import org.springframework.stereotype.Service;
@@ -25,10 +28,6 @@
 import com.moral.common.exception.BusinessException;
 import com.moral.common.util.ResourceUtil;
 import com.moral.common.util.ValidateUtil;
-import com.moral.entity.Account;
-import com.moral.entity.Menu;
-import com.moral.entity.Organization;
-import com.moral.entity.Role;
 import com.moral.mapper.AccountMapper;
 import com.moral.mapper.OrganizationMapper;
 import com.moral.service.AccountService;
@@ -57,29 +56,51 @@
     @Resource
     private OrganizationMapper organizationMapper;
 
+
     @Override
-    public Map<String, Object> screenLogin(Map<String, Object> parameters) {
+    public Map<String, Object> getAccountInfoById(String accountId) {
         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.setId(Integer.parseInt(accountId));
         account = accountMapper.selectOne(account);
-        boolean isValid = account == null ? false : encoder.matches(rawPassword, account.getPassword());
-        if (!isValid) {
-            result.put("msg", "���������������������������������");
+        if (ObjectUtils.isEmpty(account)) {
+            result.put("msg", "token������");
+            result.put("accountId", -1);
         } else {
-            if (IS_DELETE_FALSE.equals(account.getIsDelete())) {
-                result.put("msg", "���������������");
+            result = judgeAccountInfo(account);
+            if (!String.valueOf(result.get("accountId")).equals("-1")) {
+                List<Menu> menuList = accountMapper.getScreenMenuListsByAccountName(account.getAccountName());
+                result.put("msg", "���������������");
                 result.put("accountId", account.getId());
                 result.put("orgId", account.getOrganizationId());
+                result.put("data", menuList);
+                String regionCode = getRegionCodeByAccount(account);
+                if (!ObjectUtils.isEmpty(regionCode))
+                    result.put("regionCode", regionCode);
                 setOrgIdsByAccount(result);
-            } else {
-                result.put("msg", "���������������������������������������������");
             }
         }
         return result;
     }
+
+
+    @Override
+    public Map<String, Object> webLogin(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 = accountMapper.selectOne(account);
+        boolean isValid = account == null ? false : encoder.matches(rawPassword, account.getPassword());
+        if (!isValid) {
+            result.put("msg", "���������������������������������");
+            result.put("accountId", -1);
+        } else {
+            result = judgeAccountInfo(account);
+        }
+        return result;
+    }
+
 
     @Override
     public Map<String, Object> screenLoginNew(Map<String, Object> parameters) {
@@ -98,6 +119,7 @@
         boolean isValid = account == null ? false : encoder.matches(rawPassword, account.getPassword());
         if (!isValid) {
             result.put("msg", "���������������������������������");
+            result.put("accountId", -1);
         } else {
             if (IS_DELETE_FALSE.equals(account.getIsDelete())) {
                 if (existRole != null) {
@@ -109,6 +131,30 @@
                 } else {
                     result.put("msg", "���������������������");
                 }
+            } else {
+                result.put("msg", "���������������������������������������������");
+            }
+        }
+        return result;
+    }
+
+    @Override
+    public Map<String, Object> screenLogin(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);
+        boolean isValid = account == null ? false : encoder.matches(rawPassword, account.getPassword());
+        if (!isValid) {
+            result.put("msg", "���������������������������������");
+        } else {
+            if (IS_DELETE_FALSE.equals(account.getIsDelete())) {
+                result.put("msg", "���������������");
+                result.put("accountId", account.getId());
+                result.put("orgId", account.getOrganizationId());
+                setOrgIdsByAccount(result);
             } else {
                 result.put("msg", "���������������������������������������������");
             }
@@ -322,4 +368,93 @@
         return mapList;
     }
 
+    private Map<String, Object> judgeAccountInfo(Account account) {
+        Map<String, Object> result = new HashMap<String, Object>();
+        Integer existRole = accountMapper.getScreenRoleByAccountName(account.getAccountName());
+        if (!IS_DELETE_FALSE.equals(account.getIsDelete())) {
+            result.put("msg", "���������������������������������������������");
+            result.put("accountId", -1);
+        } else if (ObjectUtils.isEmpty(existRole)) {
+            result.put("msg", "���������������������");
+            result.put("accountId", -1);
+        } else {
+            result.put("msg", "���������������");
+            result.put("accountId", account.getId());
+        }
+        return result;
+    }
+
+    @Resource
+    DictionaryDataMapper dictionaryDataMapper;
+
+    @Override
+    public Map<String, Object> bsWebLogin(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 = accountMapper.selectOne(account);
+        boolean isValid = account == null ? false : encoder.matches(rawPassword, account.getPassword());
+        if (!isValid) {
+            result.put("msg", "���������������������������������");
+            result.put("accountId", -1);
+        } else {
+            result = judgeAccountInfo(account);
+
+        }
+        return result;
+    }
+
+    /**
+     * @Description: ������id������������������������������
+     * @Param: [params]
+     * @return: java.util.Map<java.lang.String                               ,                               java.lang.Object>
+     * @Author: ������������
+     * @Date: 2020/11/25
+     */
+    private String getRegionCodeByAccount(Account account) {
+        Organization organization = new Organization();
+        organization.setId(account.getOrganizationId());
+        organization = organizationMapper.selectOne(organization);
+        Map<String, Object> regionCodeAndType = getRegionCodeAndTypeByOrg(organization);
+        if (ObjectUtils.isEmpty(regionCodeAndType))
+            return null;
+        return (String) regionCodeAndType.get("regionCode");
+    }
+
+    public  Map<String, Object> getRegionCodeAndTypeByOrg(Organization organization) {
+        Map<String, Object> result = new HashMap<>();
+        String regionCode = "";
+        String regionType = "";
+        Long villageCode = organization.getVillageCode();
+        Long townCode = organization.getTownCode();
+        Integer areaCode = organization.getAreaCode();
+        Integer cityCode = organization.getCityCode();
+        Integer provinceCode = organization.getProvinceCode();
+
+        if (!ObjectUtils.isEmpty(villageCode)) {
+            regionCode = String.valueOf(villageCode);
+            regionType = "village";
+        } else if (!ObjectUtils.isEmpty(townCode)) {
+            regionCode = String.valueOf(townCode);
+            regionType = "town";
+        } else if (!ObjectUtils.isEmpty(areaCode)) {
+            regionCode = String.valueOf(areaCode);
+            regionType = "area";
+        } else if (!ObjectUtils.isEmpty(cityCode)) {
+            regionCode = String.valueOf(cityCode);
+            regionType = "city";
+        } else if (!ObjectUtils.isEmpty(provinceCode)) {
+            regionCode = String.valueOf(provinceCode);
+            regionType = "province";
+        } else {
+            return null;
+        }
+        result.put("regionCode", regionCode);
+        result.put("regionType", regionType);
+        return result;
+    }
 }
+
+
+

--
Gitblit v1.8.0