于紫祥_1901
2020-08-12 f718fb9c06fa75b65870a3f5ef2fea10054009aa
src/main/java/com/moral/service/impl/AccountServiceImpl.java
@@ -10,12 +10,6 @@
import java.util.Optional;
import java.util.Set;
import static com.moral.common.bean.Constants.IS_DELETE_FALSE;
import static com.moral.common.bean.Constants.IS_DELETE_TRUE;
import static com.moral.common.util.ResourceUtil.getValue;
import static org.apache.commons.lang3.StringUtils.isNumeric;
import static org.springframework.util.ObjectUtils.isEmpty;
import javax.annotation.Resource;
import org.apache.commons.lang3.StringUtils;
@@ -42,6 +36,12 @@
import tk.mybatis.mapper.entity.Example;
import tk.mybatis.mapper.entity.Example.Criteria;
import static com.moral.common.bean.Constants.IS_DELETE_FALSE;
import static com.moral.common.bean.Constants.IS_DELETE_TRUE;
import static com.moral.common.util.ResourceUtil.getValue;
import static org.apache.commons.lang3.StringUtils.isNumeric;
import static org.springframework.util.ObjectUtils.isEmpty;
@Service
public class AccountServiceImpl implements AccountService {
@@ -74,6 +74,41 @@
                result.put("accountId", account.getId());
                result.put("orgId", account.getOrganizationId());
                setOrgIdsByAccount(result);
            } else {
                result.put("msg", "您的账号已禁用,请联系管理员!");
            }
        }
        return result;
    }
    @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 = null;
        List<Menu> menuList = new ArrayList<>();
        if (account != null) {
            existRole = accountMapper.getScreenRoleByAccountName(account.getAccountName());
            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", "您的账号已禁用,请联系管理员!");
            }
@@ -229,12 +264,16 @@
    @Override
    public Map<String, Object> getMenuListsByAccountName(String accountName) {
        List<Menu> menuList = accountMapper.getParentMenuListsByAccountName(accountName);
        Integer organizationId = accountMapper.getByAccountName(accountName).getOrganizationId();
        Map<String, Object> organizationMap = new LinkedHashMap<>();
        organizationMap.put("organizationId", organizationId);
        String email = accountMapper.getEmailByAccountName(accountName);
        Map<String, Object> mapList = new LinkedHashMap<>();
        Map<String, Object> appMap = new LinkedHashMap<>();
        appMap.put("name", "七星瓢虫环境监测");
        appMap.put("description", "七星瓢虫环境监测后台配置中心");
        mapList.put("app", appMap);
        mapList.put("organization", organizationMap);
        Map<String, Object> userMap = new LinkedHashMap<>();
        userMap.put("name", accountName);
        userMap.put("avatar", "./assets/img/zorro.svg");