From b41f303340d8c21dad9e1b2fd798a0957e7fd7d1 Mon Sep 17 00:00:00 2001 From: xufenglei <xufenglei> Date: Fri, 01 Dec 2017 09:32:32 +0800 Subject: [PATCH] 大屏 接口 --- src/main/java/com/moral/service/impl/AccountServiceImpl.java | 52 ++++++++++++++++++++++++++++++++++++++++------------ 1 files changed, 40 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/moral/service/impl/AccountServiceImpl.java b/src/main/java/com/moral/service/impl/AccountServiceImpl.java index 06808ff..aee503f 100644 --- a/src/main/java/com/moral/service/impl/AccountServiceImpl.java +++ b/src/main/java/com/moral/service/impl/AccountServiceImpl.java @@ -1,23 +1,28 @@ package com.moral.service.impl; +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.Crypto.md5; +import static com.moral.common.util.ResourceUtil.getValue; +import static org.apache.commons.lang3.StringUtils.isNumeric; +import static org.springframework.util.ObjectUtils.isEmpty; + import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; -import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import org.springframework.util.ObjectUtils; +import com.moral.common.bean.ResultBean; +import com.moral.common.exception.BusinessException; +import com.moral.common.util.Crypto; import com.moral.entity.Account; import com.moral.entity.AccountExample; import com.moral.mapper.AccountMapper; import com.moral.service.AccountService; import com.moral.service.OrganizationService; -import com.moral.util.BusinessException; -import com.moral.util.Crypto; -import com.moral.util.ResourceUtil; @Service public class AccountServiceImpl implements AccountService { @@ -31,14 +36,14 @@ public Map<String, Object> screenLogin(Map<String, Object> parameters) { Map<String, Object> result = new HashMap<String, Object>(); AccountExample example = new AccountExample(); - String password = Crypto.md5((String) parameters.get("account")); + String password = md5((String) parameters.get("account")); example.or().andAccountNameEqualTo((String) parameters.get("account")).andPasswordEqualTo(password); List<Account> accounts = accountMapper.selectByExample(example); - if (ObjectUtils.isEmpty(accounts) || accounts.size() != 1) { + if (isEmpty(accounts) || accounts.size() != 1) { result.put("msg", "���������������������������������"); } else { Account account = accounts.get(0); - if ("1".equals(account.getIsDelete())) { + if (IS_DELETE_FALSE.equals(account.getIsDelete())) { result.put("msg", "���������������"); result.put("accountId", account.getId()); } else { @@ -48,6 +53,29 @@ return result; } + @Override + public ResultBean<Account> screenLogin1(Map<String, Object> parameters) { + ResultBean<Account> resultBean = new ResultBean<Account>(); + AccountExample example = new AccountExample(); + String password = Crypto.md5((String) parameters.get("password")); + example.or().andAccountNameEqualTo((String) parameters.get("account")).andPasswordEqualTo(password); + List<Account> accounts = accountMapper.selectByExample(example); + if (isEmpty(accounts) || accounts.size() != 1) { + resultBean.setMsg("���������������������������������"); + resultBean.setCode(ResultBean.FAIL); + } else { + Account account = accounts.get(0); + if (IS_DELETE_FALSE.equals(account.getIsDelete())) { + resultBean.setData(account); + } else { + resultBean.setCode(ResultBean.NO_PERMISSION); + resultBean.setMsg("���������������������������������������������"); + } + } + return resultBean; + } + + @Override public List<Account> getAccountLists(String accountName, String password) { AccountExample example = new AccountExample(); @@ -66,18 +94,18 @@ public void setOrgIdsByAccount(Map<String, Object> parameters) { String accountId = (String) parameters.get("accountId"); accountId = accountId.replaceFirst("-", ""); - if (!StringUtils.isNumeric((String) parameters.get("accountId"))) { + if (!isNumeric((String) parameters.get("accountId"))) { throw new BusinessException("accountId ������������������"); } Account account = accountMapper.selectByPrimaryKey((Integer.valueOf(accountId))); - if (ObjectUtils.isEmpty(account) || "1".equals(account.getIsDelete())) { - throw new BusinessException(accountId + "���������������������"); + if (isEmpty(account) || IS_DELETE_TRUE.equals(account.getIsDelete())) { + throw new BusinessException(accountId + ":���������������������"); } Integer orgId = account.getOrganizationId(); // ��������������������������������������������������������������� - if (!("-1".equals(orgId) || ResourceUtil.getValue("orgId").equals(orgId))) { + if (!(-1 == orgId || getValue("orgId").equals(orgId))) { Set<Integer> orgIds = organizationService.getChildOrganizationIds(orgId); parameters.put("orgIds", orgIds); } -- Gitblit v1.8.0