use of com.cas.sim.tis.services.exception.ServerException in project TeachingInSimulation by ScOrPiOzzy.
the class UserServiceImpl method login.
@Override
public User login(String usercode, String password) {
Condition condition = new Condition(User.class);
Criteria criteria = condition.createCriteria();
criteria.andEqualTo("code", usercode);
criteria.andEqualTo("password", password);
criteria.andEqualTo("del", 0);
List<User> user = null;
try {
user = mapper.selectByCondition(condition);
} catch (Exception e) {
throw new ServerException("服务器异常", e);
}
if (user.size() == 1) {
return user.get(0);
} else if (user.size() == 0) {
throw new ServiceException("用户名或密码错误!");
} else {
throw new TooManyResultsException();
}
}
Aggregations