From 788489c7e95352a11cf5ec40a7a9c7277e5cc0f3 Mon Sep 17 00:00:00 2001 From: fengxiang <110431245@qq.com> Date: Fri, 02 Feb 2018 09:19:53 +0800 Subject: [PATCH] 安全跨域设置 --- src/main/java/com/moral/service/impl/AccountServiceImpl.java | 21 ++++++++++++--------- 1 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/moral/service/impl/AccountServiceImpl.java b/src/main/java/com/moral/service/impl/AccountServiceImpl.java index be7b39a..d441f1f 100644 --- a/src/main/java/com/moral/service/impl/AccountServiceImpl.java +++ b/src/main/java/com/moral/service/impl/AccountServiceImpl.java @@ -7,15 +7,11 @@ import static org.apache.commons.lang3.StringUtils.isNumeric; import static org.springframework.util.ObjectUtils.isEmpty; -import java.util.Date; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; +import java.util.*; import javax.annotation.Resource; +import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.ObjectUtils; @@ -38,7 +34,8 @@ @Service public class AccountServiceImpl implements AccountService { - + @Resource + private BCryptPasswordEncoder encoder; @Resource private AccountMapper accountMapper; @@ -47,7 +44,7 @@ @Resource private OrganizationMapper organizationMapper; - + @Override public Map<String, Object> screenLogin(Map<String, Object> parameters) { Map<String, Object> result = new HashMap<String, Object>(); @@ -147,7 +144,7 @@ if (ObjectUtils.isEmpty(account.getId())) { account.setIsDelete(Constants.IS_DELETE_FALSE); account.setCreateTime(new Date()); - account.setPassword(Crypto.md5(ResourceUtil.getValue("password"))); + account.setPassword(encoder.encode(ResourceUtil.getValue("password"))); return accountMapper.insertSelective(account); } else { return accountMapper.updateByPrimaryKeySelective(account); @@ -171,4 +168,10 @@ return accountMapper.selectCount(account); } + @Override + public Optional<Account> queryAccountByName(String accountName) { + Account account = new Account(); + account.setAccountName(accountName); + return Optional.ofNullable(accountMapper.selectOne(account)); + } } -- Gitblit v1.8.0