本文整理汇总了Java中com.baomidou.mybatisplus.plugins.Page类的典型用法代码示例。如果您正苦于以下问题:Java Page类的具体用法?Java Page怎么用?Java Page使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Page类属于com.baomidou.mybatisplus.plugins包,在下文中一共展示了Page类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: main
import com.baomidou.mybatisplus.plugins.Page; //导入依赖的package包/类
/**
* 循环标签 测试
*/
public static void main(String[] args) {
// 加载配置文件
InputStream in = CircularLabelsTest.class.getClassLoader().getResourceAsStream("mysql-config.xml");
MybatisSessionFactoryBuilder mf = new MybatisSessionFactoryBuilder();
SqlSessionFactory sessionFactory = mf.build(in);
SqlSession session = sessionFactory.openSession();
UserMapper userMapper = session.getMapper(UserMapper.class);
Page<User> page = new Page<>(1, 6);
List<User> users = userMapper.forSelect(page, Arrays.asList("1", "2", "3"));
System.out.println(users.toString());
System.out.println(page);
User user = new User();
user.setId(1L);
User users1 = userMapper.selectOne(user);
System.out.println(users1);
TestMapper mapper = session.getMapper(TestMapper.class);
Test test = new Test();
test.setCreateTime(new Date());
test.setType("11111");
mapper.insert(test);
session.rollback();
}
开发者ID:Caratacus,项目名称:mybatis-plus-mini,代码行数:27,代码来源:CircularLabelsTest.java
示例2: main
import com.baomidou.mybatisplus.plugins.Page; //导入依赖的package包/类
public static void main(String[] args) {
/*
* 加载配置文件
*/
InputStream in = NoXMLTest.class.getClassLoader().getResourceAsStream("mysql-config.xml");
MybatisSessionFactoryBuilder mf = new MybatisSessionFactoryBuilder();
SqlSessionFactory sessionFactory = mf.build(in);
SqlSession sqlSession = sessionFactory.openSession();
/**
* 查询是否有结果
*/
TestMapper testMapper = sqlSession.getMapper(TestMapper.class);
testMapper.insert(new Test(IdWorker.getId(), "Caratacus"));
List<Map<String, Object>> list = testMapper.selectMaps(null);
List<Map<String, Object>> list1 = testMapper.selectMapsPage(RowBounds.DEFAULT, null);
List<Map<String, Object>> list2 = testMapper.selectMapsPage(new Page<>(1, 5), null);
System.out.println(list);
System.out.println(list1);
System.out.println(list2);
testMapper.delete(null);
}
开发者ID:Caratacus,项目名称:mybatis-plus-mini,代码行数:23,代码来源:NoXMLTest.java
示例3: query
import com.baomidou.mybatisplus.plugins.Page; //导入依赖的package包/类
public Page<SysUser> query(Map<String, Object> params) {
Map<String, String> userTypeMap = sysDicService.queryDicByType("USERTYPE");
Page<SysUser> pageInfo = super.query(params);
for (SysUser userBean : pageInfo.getRecords()) {
if (userBean.getUserType() != null) {
userBean.setUserTypeText(userTypeMap.get(userBean.getUserType()));
}
List<String> permissions = sysAuthorizeService.queryUserPermission(userBean.getId());
for (String permission : permissions) {
if (StringUtils.isBlank(userBean.getPermission())) {
userBean.setPermission(permission);
} else {
userBean.setPermission(userBean.getPermission() + ";" + permission);
}
}
}
return pageInfo;
}
开发者ID:youngMen1,项目名称:JAVA-,代码行数:19,代码来源:SysUserService.java
示例4: Parameter
import com.baomidou.mybatisplus.plugins.Page; //导入依赖的package包/类
public Parameter(Object result) {
if (result instanceof Long) {
this.id = (Long) result;
} else if (result instanceof BaseModel) {
this.model = (BaseModel) result;
} else if (result instanceof Page) {
this.page = (Page<?>) result;
} else if (result instanceof Map<?, ?>) {
this.map = (Map<?, ?>) result;
} else if (result instanceof List<?>) {
this.list = (List<?>) result;
} else if (result instanceof Object[]) {
this.param = (Object[]) result;
} else {
this.result = result;
}
}
开发者ID:guokezheng,项目名称:automat,代码行数:18,代码来源:Parameter.java
示例5: query
import com.baomidou.mybatisplus.plugins.Page; //导入依赖的package包/类
public Page<SysEvent> query(Map<String, Object> params) {
Page<SysEvent> page = super.query(params);
for (SysEvent sysEvent : page.getRecords()) {
if (sysEvent != null) {
Long createBy = sysEvent.getCreateBy();
if (createBy != null) {
SysUser sysUser = sysUserService.queryById(createBy);
if (sysUser != null) {
sysEvent.setUserName(sysUser.getUserName());
} else {
sysEvent.setUserName(createBy.toString());
}
}
}
}
return page;
}
开发者ID:guokezheng,项目名称:automat,代码行数:18,代码来源:SysEventService.java
示例6: query
import com.baomidou.mybatisplus.plugins.Page; //导入依赖的package包/类
public Page<SysRole> query(Map<String, Object> params) {
Page<SysRole> pageInfo = super.query(params);
// 权限信息
for (SysRole bean : pageInfo.getRecords()) {
if (bean.getDeptId() != null) {
SysDept sysDept = sysDeptService.queryById(bean.getDeptId());
if (sysDept != null) {
bean.setDeptName(sysDept.getDeptName());
}
}
List<String> permissions = sysAuthorizeService.queryRolePermission(bean.getId());
for (String permission : permissions) {
if (StringUtils.isBlank(bean.getPermission())) {
bean.setPermission(permission);
} else {
bean.setPermission(bean.getPermission() + ";" + permission);
}
}
}
return pageInfo;
}
开发者ID:guokezheng,项目名称:automat,代码行数:22,代码来源:SysRoleService.java
示例7: selectPage
import com.baomidou.mybatisplus.plugins.Page; //导入依赖的package包/类
/**
* 初始化文章列表
*
* @param pages 分页对象
* @param typeId 搜索条件 分类id
* @param tagIds 搜索条件 tag集合
* @param title 搜索条件 文章标题
* @param model
* @return
*/
@RequestMapping("/list")
public String selectPage(Page pages, String typeId, String tagIds, String title, Model model) {
//封装查询条件
Map<String, Object> param = new HashMap<>();
if (tagIds != null && !"".equals(tagIds)) {
param.put("tags", tagIds.split(","));
} else {
param.put("tags", null);
}
param.put("typeId", typeId);
param.put("title", title);
//获取文章列表
Page<Article> page;
page = iArticleService.selectArticlePage(pages, param);
model.addAttribute("page", page);
return "admin/article/articleTable";
}
开发者ID:MIYAOW,项目名称:MI-S,代码行数:31,代码来源:AdminArticleController.java
示例8: selectArticleList
import com.baomidou.mybatisplus.plugins.Page; //导入依赖的package包/类
/**
* 加载分页列表数据
*
* @param model
* @return
*/
@RequestMapping("/article/list")
public String selectArticleList(Page pages, Model model) {
Page<ArticleVo> page;
page = iArticleService.selectArticleList(new Page(pages.getCurrent(), 5));
model.addAttribute("page", page);
return "blog/main";
}
开发者ID:MIYAOW,项目名称:MI-S,代码行数:15,代码来源:MenuController.java
示例9: query
import com.baomidou.mybatisplus.plugins.Page; //导入依赖的package包/类
public Page<SysRole> query(Map<String, Object> params) {
Page<SysRole> pageInfo = super.query(params);
// 权限信息
for (SysRole bean : pageInfo.getRecords()) {
if (bean.getDeptId() != null) {
SysDept sysDept = sysDeptService.queryById(bean.getDeptId());
bean.setDeptName(sysDept.getDeptName());
}
List<String> permissions = sysRoleMenuMapper.queryPermission(bean.getId());
for (String permission : permissions) {
if (StringUtils.isBlank(bean.getPermission())) {
bean.setPermission(permission);
} else {
bean.setPermission(bean.getPermission() + ";" + permission);
}
}
}
return pageInfo;
}
开发者ID:tb544731152,项目名称:iBase4J,代码行数:20,代码来源:SysRoleService.java
示例10: query
import com.baomidou.mybatisplus.plugins.Page; //导入依赖的package包/类
public Page<SysUser> query(Map<String, Object> params) {
Map<String, String> userTypeMap = sysDicService.queryDicByType("USERTYPE");
Page<SysUser> pageInfo = super.query(params);
for (SysUser userBean : pageInfo.getRecords()) {
if (userBean.getUserType() != null) {
userBean.setUserTypeText(userTypeMap.get(userBean.getUserType().toString()));
}
if (userBean.getDeptId() != null) {
userBean.setDeptName(sysDeptService.queryById(userBean.getDeptId()).getDeptName());
}
List<String> permissions = sysUserMenuMapper.queryPermission(userBean.getId());
for (String permission : permissions) {
if (StringUtils.isBlank(userBean.getPermission())) {
userBean.setPermission(permission);
} else {
userBean.setPermission(userBean.getPermission() + ";" + permission);
}
}
}
return pageInfo;
}
开发者ID:tb544731152,项目名称:iBase4J,代码行数:22,代码来源:SysUserService.java
示例11: getPage
import com.baomidou.mybatisplus.plugins.Page; //导入依赖的package包/类
/** 分页查询 */
public static Page<Long> getPage(Map<String, Object> params) {
Integer current = 1;
Integer size = 10;
String orderBy = "id_";
if (DataUtil.isNotEmpty(params.get("pageNum"))) {
current = Integer.valueOf(params.get("pageNum").toString());
}
if (DataUtil.isNotEmpty(params.get("pageSize"))) {
size = Integer.valueOf(params.get("pageSize").toString());
}
if (DataUtil.isNotEmpty(params.get("orderBy"))) {
orderBy = (String) params.get("orderBy");
}
if (size == -1) {
return new Page<Long>();
}
Page<Long> page = new Page<Long>(current, size, orderBy);
page.setAsc(false);
return page;
}
开发者ID:tb544731152,项目名称:iBase4J,代码行数:22,代码来源:BaseService.java
示例12: fillWrapper
import com.baomidou.mybatisplus.plugins.Page; //导入依赖的package包/类
/**
* 填充Wrapper
*
* @param page
* @param wrapper
*/
public static void fillWrapper(Page<?> page, Wrapper wrapper) {
if (null == page) {
return;
}
if (isNotEmptyOfWrapper(wrapper)) {
if (page.isOpenSort()) {
wrapper.orderBy(page.getOrderByField() + (page.isAsc() ? " ASC " : " DESC "));
}
}
}
开发者ID:Caratacus,项目名称:mybatis-plus-mini,代码行数:17,代码来源:SqlHelper.java
示例13: pageSimpleTest
import com.baomidou.mybatisplus.plugins.Page; //导入依赖的package包/类
@Test
public void pageSimpleTest() {
// 最基础分页
Page<PageUser> page1 = new Page<>(current, size);
Page<PageUser> result1 = pageUserService.selectPage(page1);
Assert.assertTrue(!result1.getRecords().isEmpty());
}
开发者ID:Caratacus,项目名称:mybatis-plus-mini,代码行数:9,代码来源:PaginationInterceptorTest.java
示例14: pageOrderByTest
import com.baomidou.mybatisplus.plugins.Page; //导入依赖的package包/类
@Test
public void pageOrderByTest() {
// 带OrderBy
Page<PageUser> page2 = new Page<>(current, size);
Page<PageUser> result2 = pageUserService.selectPage(page2);
Assert.assertTrue(!result2.getRecords().isEmpty());
// 没有orderby但是设置了倒叙
Page<PageUser> page3 = new Page<>(current, size);
Page<PageUser> result3 = pageUserService.selectPage(page3);
Assert.assertTrue(!result3.getRecords().isEmpty());
// 有orderby设置了倒叙
Page<PageUser> page4 = new Page<>(current, size);
Page<PageUser> result4 = pageUserService.selectPage(page4);
Assert.assertTrue(!result4.getRecords().isEmpty());
}
开发者ID:Caratacus,项目名称:mybatis-plus-mini,代码行数:16,代码来源:PaginationInterceptorTest.java
示例15: pageCountTest
import com.baomidou.mybatisplus.plugins.Page; //导入依赖的package包/类
@Test
public void pageCountTest() {
// 设置不count
Page<PageUser> page = new Page<>(current, size);
page.setSearchCount(false);
Page<PageUser> result = pageUserService.selectPage(page);
Assert.assertTrue(result.getTotal() == 0);
}
开发者ID:Caratacus,项目名称:mybatis-plus-mini,代码行数:9,代码来源:PaginationInterceptorTest.java
示例16: setModelMap
import com.baomidou.mybatisplus.plugins.Page; //导入依赖的package包/类
/** 设置响应代码 */
protected ResponseEntity<ModelMap> setModelMap(ModelMap modelMap, HttpCode code, Object data) {
Map<String, Object> map = InstanceUtil.newLinkedHashMap();
map.putAll(modelMap);
modelMap.clear();
for (Iterator<String> iterator = map.keySet().iterator(); iterator.hasNext();) {
String key = iterator.next();
if (!key.startsWith("org.springframework.validation.BindingResult") && !key.equals("void")) {
modelMap.put(key, map.get(key));
}
}
if (data != null) {
if (data instanceof Page) {
Page<?> page = (Page<?>)data;
modelMap.put("rows", page.getRecords());
modelMap.put("current", page.getCurrent());
modelMap.put("size", page.getSize());
modelMap.put("pages", page.getPages());
modelMap.put("total", page.getTotal());
} else if (data instanceof List<?>) {
modelMap.put("rows", data);
modelMap.put("total", ((List<?>)data).size());
} else {
modelMap.put("data", data);
}
}
modelMap.put("code", code.value().toString());
modelMap.put("msg", code.msg());
modelMap.put("timestamp", System.currentTimeMillis());
logger.info("RESPONSE : " + JSON.toJSONString(modelMap));
return ResponseEntity.ok(modelMap);
}
开发者ID:iBase4J,项目名称:iBase4J-Common,代码行数:33,代码来源:BaseController.java
示例17: query
import com.baomidou.mybatisplus.plugins.Page; //导入依赖的package包/类
public Object query(ModelMap modelMap, Map<String, Object> param) {
if (param.get("keyword") == null && param.get("search") != null) {
param.put("keyword", param.get("search"));
param.remove("search");
}
Parameter parameter = new Parameter(getService(), "query", param);
logger.info("{} execute query start...", parameter.getNo());
Page<?> list = provider.execute(parameter).getResultPage();
logger.info("{} execute query end.", parameter.getNo());
return setSuccessModelMap(modelMap, list);
}
开发者ID:iBase4J,项目名称:iBase4J-Common,代码行数:12,代码来源:AbstractController.java
示例18: getPageMap
import com.baomidou.mybatisplus.plugins.Page; //导入依赖的package包/类
/**
* 根据Id查询(默认类型T)
* @param ids
* @return
*/
public Page<Map<String, Object>> getPageMap(final Page<Long> ids) {
if (ids != null) {
Page<Map<String, Object>> page = new Page<Map<String, Object>>(ids.getCurrent(), ids.getSize());
page.setTotal(ids.getTotal());
final List<Map<String, Object>> records = InstanceUtil.newArrayList();
for (int i = 0; i < ids.getRecords().size(); i++) {
records.add(null);
}
final Map<Integer, Object> thread = InstanceUtil.newConcurrentHashMap();
for (int i = 0; i < ids.getRecords().size(); i++) {
final int index = i;
executorService.execute(new Runnable() {
public void run() {
try {
records.set(index, InstanceUtil.transBean2Map(queryById(ids.getRecords().get(index))));
} finally {
thread.put(index, 0);
}
}
});
}
while (thread.size() < records.size()) {
try {
Thread.sleep(threadSleep);
} catch (InterruptedException e) {
logger.error("", e);
}
}
page.setRecords(records);
return page;
}
return new Page<Map<String, Object>>();
}
开发者ID:iBase4J,项目名称:iBase4J-Common,代码行数:39,代码来源:BaseService.java
示例19: getPage
import com.baomidou.mybatisplus.plugins.Page; //导入依赖的package包/类
/** 根据Id查询(默认类型T) */
private Page<T> getPage(final Page<Long> ids) {
if (ids != null) {
Page<T> page = new Page<T>(ids.getCurrent(), ids.getSize());
page.setTotal(ids.getTotal());
final List<T> records = InstanceUtil.newArrayList();
for (int i = 0; i < ids.getRecords().size(); i++) {
records.add(null);
}
final Map<Integer, Object> thread = InstanceUtil.newConcurrentHashMap();
for (int i = 0; i < ids.getRecords().size(); i++) {
final int index = i;
executorService.execute(new Runnable() {
public void run() {
try {
records.set(index, queryById(ids.getRecords().get(index)));
} finally {
thread.put(index, 0);
}
}
});
}
while (thread.size() < records.size()) {
try {
Thread.sleep(threadSleep);
} catch (InterruptedException e) {
logger.error("", e);
}
}
page.setRecords(records);
return page;
}
return new Page<T>();
}
开发者ID:iBase4J,项目名称:iBase4J-Common,代码行数:35,代码来源:BaseService.java
示例20: queryLog
import com.baomidou.mybatisplus.plugins.Page; //导入依赖的package包/类
public Page<TaskFireLog> queryLog(Map<String, Object> params) {
Page<Long> ids = BaseService.getPage(params);
ids.setRecords(logMapper.selectIdByMap(ids, params));
Page<TaskFireLog> page = new Page<TaskFireLog>(ids.getCurrent(), ids.getSize());
page.setTotal(ids.getTotal());
if (ids != null) {
List<TaskFireLog> records = InstanceUtil.newArrayList();
for (Long id : ids.getRecords()) {
records.add(applicationContext.getBean(getClass()).getFireLogById(id));
}
page.setRecords(records);
}
return page;
}
开发者ID:iBase4J,项目名称:iBase4J-Common,代码行数:15,代码来源:SchedulerService.java
注:本文中的com.baomidou.mybatisplus.plugins.Page类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论