Java Code Examples for org.beetl.sql.core.engine.PageQuery

The following examples show how to use org.beetl.sql.core.engine.PageQuery. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
public List<UserExcelExportData> queryExcel(PageQuery<CoreUser> query) {
	PageQuery<CoreUser> ret = userDao.queryByCondtion(query);
	List<CoreUser> list = ret.getList();
	OrgItem orgRoot = platformService.buildOrg();
	List<UserExcelExportData> items = new ArrayList<>();
	for(CoreUser user:list) {
		UserExcelExportData userItem = new UserExcelExportData();
		userItem.setCode(user.getCode());
		userItem.setId(user.getId());
		userItem.setName(user.getName());
		CoreDict dict = dictService.findCoreDict(CoreDictType.USER_STATE,user.getState());
		userItem.setStateText(dict.getName());
		
		if(StringUtils.isNotEmpty(user.getJobType1())){
			dict = dictService.findCoreDict("job_type",user.getJobType1());
			userItem.setJobType1Text(dict.getName());
		}
		
		String orgName = orgRoot.findChild(user.getOrgId()).getName();
		userItem.setOrgText(orgName);
		items.add(userItem);
		
	}
	return items;
	
}
 
Example 2
public PageQuery<CoreUser> queryRoleUser(PageQuery query) {
	OrgItem root = platformService.buildOrg();
	PageQuery<CoreUser>  ret = roleDao.queryUser(query);
	List<CoreUser> list = ret.getList();
	//从缓存里取出组织机构名称
	for(CoreUser user:list) {
		Long orgId = user.getOrgId();
		Integer orgId1 = (Integer)user.get("orgId1");
		user.set("orgIdText", root.findChild(orgId).getName());
		user.set("orgId1Text", root.findChild((long)orgId1).getName());
		
	}
	//再次处理数据字典
	this.queryListAfter(list);
	return ret;
	 
}
 
Example 3
public void queryByCondtion(PageQuery<CoreFunction> query) {
	functionDao.queryByCondtion(query);
	List<CoreFunction> list = query.getList();
	this.queryListAfter(list);
	//处理父功能名称显示
	FunctionItem root = platformService.buildFunction();
       for(CoreFunction function:list) {
       	Long parentId = function.getParentId();
       	String name = "";
       	if(parentId != 0) {
       		FunctionItem item = root.findChild(parentId);
           	name = item!=null?item.getName():"";
       	}
       	function.set("parentFunctionText", name);
       }
	
}
 
Example 4
@Override
public void serialize(JsonResult value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
	gen.writeStartObject();
	if(value.getCode().equals("200")) {
		gen.writeObjectField("code", 0);
	}else {
		gen.writeObjectField("code", Integer.parseInt(value.getCode()));
	}
	gen.writeStringField("msg", value.getMsg());
	Object data = value.getData();
	if(data instanceof PageQuery ) {
		PageQuery query = (PageQuery)(data);
		gen.writeObjectField("count", query.getTotalRow());
		gen.writeObjectField("data", query.getList());
	}else {
		
		gen.writeObjectField("data", data);
	}
	gen.writeEndObject();
}
 
Example 5
Source Project: spring-boot-demo   Source File: UserServiceTest.java    License: MIT License 5 votes vote down vote up
@Test
public void getUserByPage() {
    List<User> userList = userService.getUserList();
    PageQuery<User> userByPage = userService.getUserByPage(1, 5);
    Assert.assertEquals(5, userByPage.getList().size());
    Assert.assertEquals(userList.size(), userByPage.getTotalRow());
    log.debug("【userByPage】= {}", JSONUtil.toJsonStr(userByPage));
}
 
Example 6
/**
 * 列表页、 分页数据
 * 
 * @param condtion
 * @return
 */
@PostMapping(MODEL + "/list.json")
@Function("role.query")
@ResponseBody
public JsonResult<PageQuery> list(RoleQuery condtion) {
    PageQuery page = condtion.getPageQuery();
    roleConsoleService.queryByCondtion(page);
    return JsonResult.success(page);
}
 
Example 7
/**
 * 查询角色下授权用户列表
 * 
 * @param queryCondtion
 *            查询条件
 * @return
 */
@PostMapping(MODEL + "/user/list.json")
@Function("role.user.query")
@ResponseBody
public JsonResult<PageQuery<CoreUser>> userList(RoleUserQuery query) {
    PageQuery page = query.getPageQuery();
    PageQuery<CoreUser> pageQuery = roleConsoleService.queryRoleUser(page);
    return JsonResult.success(page);
}
 
Example 8
@PostMapping(MODEL + "/list.json")
@Function("menu.query")
@ResponseBody
public JsonResult<PageQuery> list(MenuQuery condtion) {
    PageQuery page = condtion.getPageQuery();
    menuService.queryByCondtion(page);
    return JsonResult.success(page);
}
 
Example 9
@RequestMapping(MODEL + "/list.json")
@Function("audit.query")
@ResponseBody
public JsonResult<PageQuery<CoreAudit>> list(AuditQuery condtion) {
   
    PageQuery<CoreAudit> page = condtion.getPageQuery();
    auditConsoleService.queryByCondtion(page);
    return JsonResult.success(page);
}
 
Example 10
@PostMapping(MODEL + "/list.json")
@Function("dict.query")
@ResponseBody
public JsonResult<PageQuery> list(CoreDictQuery condtion)
{
    PageQuery page = condtion.getPageQuery();
    dictService.queryByCondition(page);
    return JsonResult.success(page);
}
 
Example 11
@PostMapping(MODEL + "/excel/export.json")
@Function("dict.export")
@ResponseBody
public JsonResult<String> export(HttpServletResponse response,UserQuery condtion) {
    String excelTemplate ="excelTemplates/admin/dict/dict_collection_template.xls";
    PageQuery<CoreUser> page = condtion.getPageQuery();
    //取出全部符合条件的
    page.setPageSize(Integer.MAX_VALUE);
    page.setPageNumber(1);
    page.setTotalRow(Integer.MAX_VALUE);
    List<CoreDict> dicts =dictService.queryExcel(page);
    try(InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(excelTemplate)) {
        if(is==null) {
            throw new PlatformException("模板资源不存在:"+excelTemplate);
        }
        FileItem item = fileService.createFileTemp("dict_collection.xls");
        OutputStream os = item.openOutpuStream();
        Context context = new Context();
        context.putVar("dicts", dicts);
        JxlsHelper.getInstance().processTemplate(is, os, context);
        os.close();
        //下载参考FileSystemContorller
        return  JsonResult.success(item.getPath());
    } catch (IOException e) {
        throw new PlatformException(e.getMessage());
    }
    
}
 
Example 12
/**
 * 字典列表  分页
 *
 * @param condtion
 * @return
 */
@RequestMapping(MODEL + "/list.json")
@Function("function.query")
@ResponseBody
public JsonResult<PageQuery<CoreFunction>> list(FunctionQuery condtion) {
 
    PageQuery page = condtion.getPageQuery();
    functionConsoleService.queryByCondtion(page);
    return JsonResult.success(page);
 
}
 
Example 13
@PostMapping(MODEL + "/list.json")
@Function("user.query")
@ResponseBody
public JsonResult<PageQuery<CoreUser>> index(UserQuery condtion) {

	PageQuery<CoreUser> page = condtion.getPageQuery();
	userConsoleService.queryByCondtion(page);
	return JsonResult.success(page);
}
 
Example 14
@PostMapping(MODEL + "/excel/export.json")
@Function("user.export")
@ResponseBody
public JsonResult<String> export(HttpServletResponse response,UserQuery condtion) {
	String excelTemplate ="excelTemplates/admin/user/user_collection_template.xls";
	PageQuery<CoreUser> page = condtion.getPageQuery();
	//取出全部符合条件的
	page.setPageSize(Integer.MAX_VALUE);
	page.setPageNumber(1);
	page.setTotalRow(Integer.MAX_VALUE);
	List<UserExcelExportData> users =userConsoleService.queryExcel(page);
	try(InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(excelTemplate)) {
        if(is==null) {
        	throw new PlatformException("模板资源不存在:"+excelTemplate);
        }
        FileItem item = fileService.createFileTemp("user_collection.xls");
        OutputStream os = item.openOutpuStream();
        Context context = new Context();
           context.putVar("users", users);
           JxlsHelper.getInstance().processTemplate(is, os, context);
           //下载参考FileSystemContorller
           return  JsonResult.success(item.getPath());
    } catch (IOException e) {
		throw new PlatformException(e.getMessage());
	}
	
}
 
Example 15
/**
 * 组织机构列表  分页
 * @param condtion 查询条件
 * @return
 */
@PostMapping(MODEL + "/list.json")
@Function("org.query")
@ResponseBody
public JsonResult<PageQuery<CoreOrg>> list(OrgQuery condtion) {
    PageQuery page = condtion.getPageQuery();
    orgConsoleService.queryByCondtion(page);
    return JsonResult.success(page);
}
 
Example 16
@PostMapping(MODEL + "/user/list.json")
@Function("org.query")
@ResponseBody
public JsonResult<PageQuery<CoreUser>> getUsers(OrgUserQuery userQuery) {
	 PageQuery<CoreUser> page = userQuery.getPageQuery();
     userConsoleService.queryByCondtion(page);
     return JsonResult.success(page);
}
 
Example 17
/**
 * 根据条件查询
 * @param query
 */
public void queryByCondtion(PageQuery query) {
    orgDao.queryByCondtion(query);
    List<CoreOrg> list = query.getList();
    queryListAfter(list);
    OrgItem root = platformService.buildOrg();
    //处理父机构名称显示,没有用sql查询是考虑到跨数据库
    for(CoreOrg org:list) {
    	Long parentId = org.getParentOrgId();
    	OrgItem item = root.findChild(parentId);
    	String name = item!=null?item.getName():"";
    	org.set("parentOrgText", name);
    }
    
}
 
Example 18
public List<CoreDict> queryExcel(PageQuery<CoreUser> query) {
    //同查询,不需要额外数据
    PageQuery ret =  dictDao.queryByCondition(query);
    queryListAfter(ret.getList());
    return ret.getList();
    
}
 
Example 19
@JsonIgnore
public PageQuery getPageQuery() {
    PageQuery query = new PageQuery();
    query.setParas(this);
    if (page != null) {
        query.setPageNumber(page);
        query.setPageSize(limit);
    }
    return query;
}
 
Example 20
Source Project: spring-boot-demo   Source File: UserServiceTest.java    License: MIT License 5 votes vote down vote up
@Test
public void getUserByPage() {
    List<User> userList = userService.getUserList();
    PageQuery<User> userByPage = userService.getUserByPage(1, 5);
    Assert.assertEquals(5, userByPage.getList().size());
    Assert.assertEquals(userList.size(), userByPage.getTotalRow());
    log.debug("【userByPage】= {}", JSONUtil.toJsonStr(userByPage));
}
 
Example 21
Source Project: spring-boot-demo   Source File: UserServiceTest.java    License: MIT License 5 votes vote down vote up
@Test
public void getUserByPage() {
    List<User> userList = userService.getUserList();
    PageQuery<User> userByPage = userService.getUserByPage(1, 5);
    Assert.assertEquals(5, userByPage.getList().size());
    Assert.assertEquals(userList.size(), userByPage.getTotalRow());
    log.debug("【userByPage】= {}", JSONUtil.toJsonStr(userByPage));
}
 
Example 22
public PageQuery<CoreDict>queryByCondition(PageQuery query){
    PageQuery ret =  dictDao.queryByCondition(query);
    queryListAfter(ret.getList());
    return ret;
}
 
Example 23
/**
 * 根据条件查询
 * @param query
 */
public void queryByCondtion(PageQuery query) {
    roleDao.queryByCondtion(query);
    super.queryListAfter(query.getList());
}
 
Example 24
public void queryByCondtion(PageQuery<CoreMenu> query) {
    menuDao.queryByCondtion(query);
    queryListAfter(query.getList());
}
 
Example 25
@PostMapping(MODEL + "/list.json")
\@Function("${entity.code}.query")
\@ResponseBody
public JsonResult<PageQuery> list(${entity.name}
 
Example 26
queryByCondition(PageQuery query){
    PageQuery ret =  ${entity.code}Dao.queryByCondition(query);
    queryListAfter(ret.getList());
    return ret;
}
 
Example 27
Source Project: spring-boot-demo   Source File: UserService.java    License: MIT License 2 votes vote down vote up
/**
 * 分页查询
 *
 * @param currentPage 当前页
 * @param pageSize    每页条数
 * @return 分页用户列表
 */
PageQuery<User> getUserByPage(Integer currentPage, Integer pageSize);
 
Example 28
Source Project: spring-boot-demo   Source File: UserServiceImpl.java    License: MIT License 2 votes vote down vote up
/**
 * 分页查询
 *
 * @param currentPage 当前页
 * @param pageSize    每页条数
 * @return 分页用户列表
 */
@Override
public PageQuery<User> getUserByPage(Integer currentPage, Integer pageSize) {
    return userDao.createLambdaQuery().page(currentPage, pageSize);
}
 
Example 29
/**
 * 根据条件查询
 *
 * @param query
 */
public void queryByCondtion(PageQuery query);
 
Example 30
/**
 * 根据条件分页查询
 * @param query 查询条件
 */
void queryByCondtion(PageQuery query);