沈斌
2018-06-09 6e9c3733135fa96360c8c76e76b431efa5d7f52d
src/main/java/com/moral/service/impl/AccountServiceImpl.java
@@ -2,7 +2,6 @@
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;
@@ -11,6 +10,7 @@
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;
@@ -50,9 +50,11 @@
      Map<String, Object> result = new HashMap<String, Object>();
      Account account = new Account();
      account.setAccountName((String) parameters.get("account"));
      account.setPassword(encoder.encode((String) parameters.get("password")));
      String rawPassword = (String) parameters.get("password");
//      account.setPassword(encoder.encode((String) parameters.get("password")));
      account = accountMapper.selectOne(account);
      if (isEmpty(account)) {
      boolean isValid = account == null ? false:encoder.matches(rawPassword,account.getPassword());
      if (!isValid) {
         result.put("msg", "用户名及密码输入错误!");
      } else {
         if (IS_DELETE_FALSE.equals(account.getIsDelete())) {
@@ -141,6 +143,10 @@
   @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());