@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 List<AdminUser> queryAll(String orderByClause) {
   AdminUserCriteria criteria = new AdminUserCriteria();
   criteria.setOrderByClause(orderByClause);
   return adminUserMapper.selectByExample(criteria);
 }