All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cn.ipokerface.admin.service.AdminServiceImpl Maven / Gradle / Ivy

There is a newer version: 2.7.2
Show newest version
package cn.ipokerface.admin.service;

import cn.ipokerface.admin.AdminCacheService;
import cn.ipokerface.admin.entity.AdminAccount;
import cn.ipokerface.admin.enums.AccountStatus;
import cn.ipokerface.admin.exception.AccountForbiddenException;
import cn.ipokerface.admin.exception.AccountWrongException;
import cn.ipokerface.admin.exception.PasswordRequireException;
import cn.ipokerface.admin.exception.PasswordWrongException;
import cn.ipokerface.admin.mapper.AdminAccountMapper;
import cn.ipokerface.admin.model.AccountModel;
import cn.ipokerface.common.utils.DigestUtils;
import cn.ipokerface.common.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by       PokerFace
 * Create Date      2019-12-26.
 * Email:           [email protected]
 * Version          1.0.0
 * 

* Description: */ @Service public class AdminServiceImpl implements AdminService { @Autowired private AdminAccountMapper adminAccountMapper; @Autowired private AdminCacheService adminCacheService; @Override public AdminAccount login(String username, String password, String ip) { AdminAccount adminAccount = adminAccountMapper.selectByUsername(username); if (adminAccount == null) { throw new AccountWrongException(); } if (AccountStatus.AccountStatus_Forbidden.equals(adminAccount.getStatus())) { throw new AccountForbiddenException(); } if (!DigestUtils.md5Hex(password + adminAccount.getSalt()).equals(adminAccount.getPassword())) { throw new PasswordWrongException(); } return adminAccount; } @Override public void resetPassword(Long accountId, String password, String newPassword) { if (StringUtils.isEmpty(password) || StringUtils.isEmpty(newPassword)) { throw new PasswordRequireException(); } AdminAccount systemAccount = adminAccountMapper.selectByPrimaryKey(accountId); if (systemAccount == null) { throw new AccountWrongException(); } // 验证密码 String md5password = DigestUtils.md5Hex(password + systemAccount.getSalt()); if (!md5password.equals(systemAccount.getPassword())) throw new PasswordWrongException(); adminAccountMapper.updatePassword(accountId,DigestUtils.md5Hex(newPassword + systemAccount.getSalt())); } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy