use of com.hfut.entity.UserExample in project Workload by amoxu.
the class UserServiceImplTest method findByName.
@Test
public void findByName() {
UserExample example = new UserExample();
UserExample.Criteria criteria = example.createCriteria();
criteria.andIdEqualTo(10000);
List<User> userList = userMapper.selectByExample(example);
Assert.assertEquals(userList.get(0).getUserRole().getName(), "超级管理员");
}
use of com.hfut.entity.UserExample in project Workload by amoxu.
the class UserServiceImpl method register.
@Override
public boolean register(User user) throws Exception {
System.out.println("user register:" + user.getUser() + " " + user.getPassword() + " " + user.getMail());
if (StringUtils.isEmpty(user.getUser()) || StringUtils.isEmpty(user.getPassword())) {
throw new CustomException("用户或密码不能为空!");
} else if (StringUtils.isEmpty(user.getMail())) {
throw new CustomException("邮箱不能为空!");
} else if (user.getPassword().length() < 6) {
throw new CustomException("密码过短!");
}
UserExample userExample = new UserExample();
UserExample.Criteria criteria = userExample.createCriteria();
criteria.andUserEqualTo(user.getUser());
List<User> list = userMapper.selectByExample(userExample);
if (list.size() != 0) {
throw new CustomException("账号已存在!");
}
userExample = new UserExample();
criteria = userExample.createCriteria();
criteria.andMailEqualTo(user.getMail());
list = userMapper.selectByExample(userExample);
if (list.size() != 0) {
throw new CustomException("邮箱已存在!");
}
int ret = userMapper.insert(user);
if (ret > 0) {
return true;
} else {
return false;
}
}
use of com.hfut.entity.UserExample in project Workload by amoxu.
the class UserServiceImpl method findByName.
/* private SimpleMailMessage mailMessage;
private JavaMailSender mailSender;*/
@Override
public User findByName(String name) throws Exception {
UserExample userExample = new UserExample();
UserExample.Criteria criteria = userExample.createCriteria();
criteria.andUserEqualTo(name);
List<User> list = userMapper.selectByExample(userExample);
if (list.size() == 0) {
return null;
} else {
return list.get(0);
}
}
use of com.hfut.entity.UserExample in project Workload by amoxu.
the class UserServiceImpl method getList.
@Override
public List<User> getList(Integer page, Integer limit) throws Exception {
UserExample example = new UserExample();
example.setLimit(limit);
if (page != 0) {
page -= 1;
}
example.setOffset(page);
List<User> list = userMapper.selectByExample(example);
for (User user : list) {
user.setPassword("*****");
user.setAnswer("****");
}
return list;
}
use of com.hfut.entity.UserExample in project Workload by amoxu.
the class UserServiceImpl method getList.
@Override
public List<User> getList(int typeId, int page, int limit) throws Exception {
UserExample example = new UserExample();
UserExample.Criteria criteria = example.createCriteria();
criteria.andLevelEqualTo(typeId);
example.setLimit(limit);
if (page != 0) {
page -= 1;
}
example.setOffset(page);
List<User> list = userMapper.selectByExample(example);
for (User user : list) {
user.setPassword("*****");
user.setAnswer("****");
}
return list;
}
Aggregations