|
|
|
|
@ -1,4 +1,6 @@
|
|
|
|
|
package com.example.service;
|
|
|
|
|
|
|
|
|
|
import com.example.entity.Account;
|
|
|
|
|
import com.example.entity.Admin;
|
|
|
|
|
import com.example.exception.CustomException;
|
|
|
|
|
import com.example.mapper.AdminMapper;
|
|
|
|
|
@ -8,24 +10,25 @@ import javax.annotation.Resource;
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
|
public class AdminService {
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private AdminMapper adminMapper;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 登录
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
public Admin login(Admin admin){
|
|
|
|
|
Admin dbAdmin = adminMapper.selectByUsername(admin.getUsername());
|
|
|
|
|
if(dbAdmin==null){
|
|
|
|
|
//没有用户
|
|
|
|
|
public Account login(Account account) {
|
|
|
|
|
Account dbAdmin = adminMapper.selectByUsername(account.getUsername());
|
|
|
|
|
if (dbAdmin == null) {
|
|
|
|
|
// 没有用户
|
|
|
|
|
throw new CustomException("账号或密码错误");
|
|
|
|
|
}
|
|
|
|
|
//比较密码
|
|
|
|
|
if(!admin.getPassword().equals(dbAdmin.getPassword())){
|
|
|
|
|
// 比较密码
|
|
|
|
|
if (!account.getPassword().equals(dbAdmin.getPassword())) {
|
|
|
|
|
throw new CustomException("账号或密码错误");
|
|
|
|
|
}
|
|
|
|
|
//登录成功
|
|
|
|
|
// 登录成功
|
|
|
|
|
return dbAdmin;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|