This commit is contained in:
Captain.B 2020-02-13 17:38:49 +08:00
parent cf28e1013d
commit b7e76ccedc
5 changed files with 62 additions and 3 deletions

View File

@ -1,4 +1,4 @@
package io.metersphere.commons; package io.metersphere.commons.exception;
public class MSException extends RuntimeException{ public class MSException extends RuntimeException{

View File

@ -0,0 +1,17 @@
package io.metersphere.commons.utils;
import com.github.pagehelper.Page;
public class PageUtils {
public static <T> Pager<T> setPageInfo(Page page, T obj) {
try {
Pager<T> pager = new Pager<>();
pager.setListObject(obj);
pager.setPageCount(page.getPages());
pager.setItemCount(page.getTotal());
return pager;
} catch (Exception e) {
throw new RuntimeException("Error saving current page number data");
}
}
}

View File

@ -0,0 +1,42 @@
package io.metersphere.commons.utils;
public class Pager<T> {
private T listObject;
private long itemCount;
private long pageCount;
public Pager() {
}
public Pager(T listObject, long itemCount, long pageCount) {
this.listObject = listObject;
this.itemCount = itemCount;
this.pageCount = pageCount;
}
public long getPageCount() {
return pageCount;
}
public void setPageCount(long pageCount) {
this.pageCount = pageCount;
}
public long getItemCount() {
return itemCount;
}
public void setItemCount(long itemCount) {
this.itemCount = itemCount;
}
public T getListObject() {
return listObject;
}
public void setListObject(T listObject) {
this.listObject = listObject;
}
}

View File

@ -4,7 +4,7 @@ import io.metersphere.base.domain.*;
import io.metersphere.base.mapper.RoleMapper; import io.metersphere.base.mapper.RoleMapper;
import io.metersphere.base.mapper.UserMapper; import io.metersphere.base.mapper.UserMapper;
import io.metersphere.base.mapper.UserRoleMapper; import io.metersphere.base.mapper.UserRoleMapper;
import io.metersphere.commons.MSException; import io.metersphere.commons.exception.MSException;
import io.metersphere.dto.UserDTO; import io.metersphere.dto.UserDTO;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;

View File

@ -2,7 +2,7 @@ package io.metersphere.service;
import io.metersphere.base.domain.Workspace; import io.metersphere.base.domain.Workspace;
import io.metersphere.base.mapper.WorkspaceMapper; import io.metersphere.base.mapper.WorkspaceMapper;
import io.metersphere.commons.MSException; import io.metersphere.commons.exception.MSException;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;