| | |
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.apache.commons.lang3.StringUtils;
|
| | | import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | |
| | | import com.moral.common.exception.BusinessException;
|
| | | import com.moral.common.util.Crypto;
|
| | | import com.moral.common.util.ResourceUtil;
|
| | | import com.moral.common.util.ValidateUtil;
|
| | | import com.moral.entity.Account;
|
| | | import com.moral.entity.Organization;
|
| | | import com.moral.mapper.AccountMapper;
|
| | |
| | | result.put("msg", "登录成功!");
|
| | | result.put("accountId", account.getId());
|
| | | result.put("orgId", account.getOrganizationId());
|
| | | setOrgIdsByAccount(result);
|
| | | } else {
|
| | | result.put("msg","您的账号已禁用,请联系管理员!");
|
| | | }
|
| | |
| | | }
|
| | | @Override
|
| | | public void setOrgIdsByAccount(Map<String, Object> parameters) {
|
| | | String accountId = (String) parameters.get("accountId");
|
| | | String accountId = parameters.get("accountId").toString();
|
| | | accountId = accountId.replaceFirst("-", "");
|
| | | if (!isNumeric((String) parameters.get("accountId"))) {
|
| | | if (!isNumeric(accountId)) {
|
| | | throw new BusinessException("accountId 参数不合法!");
|
| | | }
|
| | |
|
| | |
| | | @Override
|
| | | @Transactional
|
| | | public Integer saveOrUpdateAccount(Account account) {
|
| | | // 重置密码
|
| | | if(!StringUtils.isBlank(account.getPassword())){
|
| | | account.setPassword(encoder.encode(account.getPassword()));
|
| | | }
|
| | | if (ObjectUtils.isEmpty(account.getId())) {
|
| | | account.setIsDelete(Constants.IS_DELETE_FALSE);
|
| | | account.setCreateTime(new Date());
|
| | |
| | | Account account = accountMapper.getByAccountName(accountName);
|
| | | return Optional.ofNullable(account);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public Account companyLogin(Map<String, Object> parameters) {
|
| | | ValidateUtil.notNull(parameters.get("account"), "param.is.null");
|
| | | ValidateUtil.notNull(parameters.get("password"), "param.is.null");
|
| | | Account account = new Account();
|
| | | account.setIsDelete(Constants.IS_DELETE_FALSE);
|
| | | account.setAccountName(parameters.get("account").toString());
|
| | | account = accountMapper.selectOne(account);
|
| | | if (ObjectUtils.isEmpty(account)) {
|
| | | throw new BusinessException("账户不存在,请联系管理员!");
|
| | | }
|
| | | if (!encoder.matches(parameters.get("password").toString(), account.getPassword())) {
|
| | | throw new BusinessException("密码错误,请重新输入!");
|
| | | }
|
| | | account.setPassword(parameters.get("password").toString());
|
| | | return account;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public Map<String, Object> getOrganizationIdByAccountId(String id) {
|
| | | Integer accountId = Integer.parseInt(id);
|
| | | Map<String, Object> map = accountMapper.getOrganizationIdByAccountId(accountId);
|
| | | return map;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<Account> getAccountList(String accountName) {
|
| | | List<Account> accountList = accountMapper.getAccountList(accountName);
|
| | | return accountList;
|
| | | }
|
| | | }
|