@Override public AdminUser loadUserByUsername(String username) { AdminUserCriteria criteria = new AdminUserCriteria(); criteria.createCriteria().andUsernameEqualTo(username); List<AdminUser> adminUserList = adminUserMapper.selectByExample(criteria); return adminUserList != null && adminUserList.size() == 1 ? adminUserList.get(0) : null; }
@Override public int changeUserPassword(int userId, String encryptNewPassword) { AdminUser adminUser = new AdminUser(); adminUser.setPassword(encryptNewPassword); AdminUserCriteria criteria = new AdminUserCriteria(); criteria.createCriteria().andIdEqualTo(userId); return adminUserMapper.updateByExampleSelective(adminUser, criteria); }
@Override public PagingResult<AdminUser> pagingByCriteria( int pageNo, int pageSize, AdminUserCriteria criteria) { pageNo = pageNo <= 0 ? 1 : pageNo; // 确保pageNo合法 pageSize = pageNo <= 0 ? 20 : pageSize; // 确保pageSize合法 int offset = (pageNo - 1) * pageSize; // 构造查询条件 if (criteria == null) { criteria = new AdminUserCriteria(); } criteria.setLimitOffset(offset); criteria.setLimitRows(pageSize); int count = adminUserMapper.countByExample(criteria); List<AdminUser> dataList = adminUserMapper.selectByExample(criteria); // 返回分页数据 return new PagingResult<AdminUser>(pageNo, pageSize, count, dataList); }
@Override public int countByCriteria(AdminUserCriteria criteria) { return adminUserMapper.countByExample(criteria); }
@Override public List<AdminUser> queryByCriteria(AdminUserCriteria criteria) { return adminUserMapper.selectByExample(criteria); }
@Override public List<AdminUser> queryAll(String orderByClause) { AdminUserCriteria criteria = new AdminUserCriteria(); criteria.setOrderByClause(orderByClause); return adminUserMapper.selectByExample(criteria); }
@Override public List<AdminUser> queryAll() { return adminUserMapper.selectByExample(null); }
@Override public AdminUser loadById(Integer id) { return adminUserMapper.selectByPrimaryKey(id); }
@Override public int deleteById(Integer id) { return adminUserMapper.deleteByPrimaryKey(id); }
@Override public int updateByCriteria(AdminUser t, AdminUserCriteria criteria) { return adminUserMapper.updateByExampleSelective(t, criteria); }
@Override public int updateById(AdminUser adminUser) { return adminUserMapper.updateByPrimaryKeySelective(adminUser); }
@Override public int save(AdminUser adminUser) { return adminUserMapper.insert(adminUser); }