public Page<Log> find(Page<Log> page, Map<String, Object> paramMap) { DetachedCriteria dc = logDao.createDetachedCriteria(); Long createById = StringUtils.toLong(paramMap.get("createById")); if (createById > 0) { dc.add(Restrictions.eq("createBy.id", createById)); } String requestUri = ObjectUtils.toString(paramMap.get("requestUri")); if (StringUtils.isNotBlank(requestUri)) { dc.add(Restrictions.like("requestUri", "%" + requestUri + "%")); } String exception = ObjectUtils.toString(paramMap.get("exception")); if (StringUtils.isNotBlank(exception)) { dc.add(Restrictions.eq("type", Log.TYPE_EXCEPTION)); } Date beginDate = DateUtils.parseDate(paramMap.get("beginDate")); if (beginDate == null) { beginDate = DateUtils.setDays(new Date(), 1); paramMap.put("beginDate", DateUtils.formatDate(beginDate, "yyyy-MM-dd")); } Date endDate = DateUtils.parseDate(paramMap.get("endDate")); if (endDate == null) { endDate = DateUtils.addDays(DateUtils.addMonths(beginDate, 1), -1); paramMap.put("endDate", DateUtils.formatDate(endDate, "yyyy-MM-dd")); } dc.add(Restrictions.between("createDate", beginDate, endDate)); dc.addOrder(Order.desc("id")); return logDao.find(page, dc); }
/** * 使用检索标准对象分页查询 * * @param detachedCriteria * @param page * @return */ @SuppressWarnings("unchecked") public Page<T> find(Page<T> page, DetachedCriteria detachedCriteria) { // get count if (!page.isDisabled() && !page.isNotCount()) { page.setCount(count(detachedCriteria)); if (page.getCount() < 1) { return page; } } Criteria criteria = detachedCriteria.getExecutableCriteria(getSession()); criteria.setResultTransformer(Criteria.ROOT_ENTITY); // set page if (!page.isDisabled()) { criteria.setFirstResult(page.getFirstResult()); criteria.setMaxResults(page.getMaxResults()); } // order by if (StringUtils.isNotBlank(page.getOrderBy())) { for (String order : StringUtils.split(page.getOrderBy(), ",")) { String[] o = StringUtils.split(order, " "); if (o.length >= 1) { criteria.addOrder(Order.asc(o[0])); } else if (o.length >= 2) { if ("DESC".equals(o[1].toUpperCase())) { criteria.addOrder(Order.desc(o[0])); } else { criteria.addOrder(Order.asc(o[0])); } } } } page.setList(criteria.list()); return page; }
/** * SQL 分页查询 * * @param page * @param sqlString * @param resultClass * @param parameter * @return */ @SuppressWarnings("unchecked") public <E> Page<E> findBySql( Page<E> page, String sqlString, Parameter parameter, Class<?> resultClass) { // get count if (!page.isDisabled() && !page.isNotCount()) { String countSqlString = "select count(*) " + removeSelect(removeOrders(sqlString)); // page.setCount(Long.valueOf(createSqlQuery(countSqlString, // parameter).uniqueResult().toString())); Query query = createSqlQuery(countSqlString, parameter); List<Object> list = query.list(); if (list.size() > 0) { page.setCount(Long.valueOf(list.get(0).toString())); } else { page.setCount(list.size()); } if (page.getCount() < 1) { return page; } } // order by String sql = sqlString; if (StringUtils.isNotBlank(page.getOrderBy())) { sql += " order by " + page.getOrderBy(); } SQLQuery query = createSqlQuery(sql, parameter); // set page if (!page.isDisabled()) { query.setFirstResult(page.getFirstResult()); query.setMaxResults(page.getMaxResults()); } setResultTransformer(query, resultClass); page.setList(query.list()); return page; }
/** * 获取工程路径 * * @return */ public static String getProjectPath() { // 如果配置了工程路径,则直接返回,否则自动获取。 String projectPath = Global.getConfig("projectPath"); if (StringUtils.isNotBlank(projectPath)) { return projectPath; } try { File file = new DefaultResourceLoader().getResource("").getFile(); if (file != null) { while (true) { File f = new File(file.getPath() + File.separator + "src" + File.separator + "main"); if (f == null || f.exists()) { break; } if (file.getParentFile() != null) { file = file.getParentFile(); } else { break; } } projectPath = file.toString(); } } catch (IOException e) { e.printStackTrace(); } return projectPath; }
/** 流程定义列表 */ public Page<ProcessInstance> runningList( Page<ProcessInstance> page, String procInsId, String procDefKey) { ProcessInstanceQuery processInstanceQuery = runtimeService.createProcessInstanceQuery(); if (StringUtils.isNotBlank(procInsId)) { processInstanceQuery.processInstanceId(procInsId); } if (StringUtils.isNotBlank(procDefKey)) { processInstanceQuery.processDefinitionKey(procDefKey); } page.setCount(processInstanceQuery.count()); page.setList(processInstanceQuery.listPage(page.getFirstResult(), page.getMaxResults())); return page; }
@ModelAttribute public Article get(@RequestParam(required = false) String id) { if (StringUtils.isNotBlank(id)) { return articleService.get(id); } else { return new Article(); } }
@Transactional(readOnly = false) public Page<Link> find(Page<Link> page, Link link, boolean isDataScopeFilter) { // 更新过期的权重,间隔为“6”个小时 Date updateExpiredWeightDate = (Date) CacheUtils.get("updateExpiredWeightDateByLink"); if (updateExpiredWeightDate == null || (updateExpiredWeightDate != null && updateExpiredWeightDate.getTime() < new Date().getTime())) { linkDao.updateExpiredWeight(); CacheUtils.put("updateExpiredWeightDateByLink", DateUtils.addHours(new Date(), 6)); } DetachedCriteria dc = linkDao.createDetachedCriteria(); dc.createAlias("category", "category"); dc.createAlias("category.site", "category.site"); if (link.getCategory() != null && StringUtils.isNotBlank(link.getCategory().getId()) && !Category.isRoot(link.getCategory().getId())) { Category category = categoryDao.get(link.getCategory().getId()); if (category != null) { dc.add( Restrictions.or( Restrictions.eq("category.id", category.getId()), Restrictions.like("category.parentIds", "%," + category.getId() + ",%"))); dc.add(Restrictions.eq("category.site.id", category.getSite().getId())); link.setCategory(category); } else { dc.add(Restrictions.eq("category.site.id", Site.getCurrentSiteId())); } } else { dc.add(Restrictions.eq("category.site.id", Site.getCurrentSiteId())); } if (StringUtils.isNotEmpty(link.getTitle())) { dc.add(Restrictions.like("title", "%" + link.getTitle() + "%")); } if (link.getCreateBy() != null && StringUtils.isNotBlank(link.getCreateBy().getId())) { dc.add(Restrictions.eq("createBy.id", link.getCreateBy().getId())); } if (isDataScopeFilter) { dc.createAlias("category.office", "categoryOffice").createAlias("createBy", "createBy"); dc.add(dataScopeFilter(UserUtils.getUser(), "categoryOffice", "createBy")); } dc.add(Restrictions.eq(Link.FIELD_DEL_FLAG, link.getDelFlag())); dc.addOrder(Order.desc("weight")); dc.addOrder(Order.desc("updateDate")); return linkDao.find(page, dc); }
@ModelAttribute public TradingAccounts get(@RequestParam(required = false) String id) { TradingAccounts entity = null; if (StringUtils.isNotBlank(id)) { entity = tradingAccountsService.get(id); } if (entity == null) { entity = new TradingAccounts(); } return entity; }
@ModelAttribute public RenwuRun get(@RequestParam(required = false) String id) { RenwuRun entity = null; if (StringUtils.isNotBlank(id)) { entity = renwuRunService.get(id); } if (entity == null) { entity = new RenwuRun(); } return entity; }
@ModelAttribute public ZbUser get(@RequestParam(required = false) String id) { ZbUser entity = null; if (StringUtils.isNotBlank(id)) { entity = zbUserService.get(id); } if (entity == null) { entity = new ZbUser(); } return entity; }
@ModelAttribute public WuyeJiben get(@RequestParam(required = false) String id) { WuyeJiben entity = null; if (StringUtils.isNotBlank(id)) { entity = wuyeJibenService.get(id); } if (entity == null) { entity = new WuyeJiben(); } return entity; }
/** * 获取物理数据表列表 * * @param genTable * @return */ public GenTable getTableFormDb(GenTable genTable) { // 如果有表名,则获取物理表 if (StringUtils.isNotBlank(genTable.getName())) { List<GenTable> list = genDataBaseDictDao.findTableList(genTable); if (list.size() > 0) { // 如果是新增,初始化表属性 if (StringUtils.isBlank(genTable.getId())) { genTable = list.get(0); // 设置字段说明 if (StringUtils.isBlank(genTable.getComments())) { genTable.setComments(genTable.getName()); } genTable.setClassName(StringUtils.toCapitalizeCamelCase(genTable.getName())); } // 添加新列 List<GenTableColumn> columnList = genDataBaseDictDao.findTableColumnList(genTable); for (GenTableColumn column : columnList) { boolean b = false; for (GenTableColumn e : genTable.getColumnList()) { if (e.getName().equals(column.getName())) { b = true; } } if (!b) { genTable.getColumnList().add(column); } } // 删除已删除的列 for (GenTableColumn e : genTable.getColumnList()) { boolean b = false; for (GenTableColumn column : columnList) { if (column.getName().equals(e.getName())) { b = true; } } if (!b) { e.setDelFlag(GenTableColumn.DEL_FLAG_DELETE); } } // 获取主键 genTable.setPkList(genDataBaseDictDao.findTablePK(genTable)); // 初始化列属性字段 GenUtils.initColumnField(genTable); } } return genTable; }
/** * 获取全文查询对象 * * @param q 查询关键字 * @param fields 查询字段 * @return 全文查询对象 */ public BooleanQuery getFullTextQuery(String q, String... fields) { Analyzer analyzer = new IKAnalyzer(); BooleanQuery query = new BooleanQuery(); try { if (StringUtils.isNotBlank(q)) { for (String field : fields) { QueryParser parser = new QueryParser(Version.LUCENE_36, field, analyzer); query.add(parser.parse(q), Occur.SHOULD); } } } catch (ParseException e) { e.printStackTrace(); } return query; }
@Transactional(readOnly = false) public void save(Link link) { // 如果没有审核权限,则将当前内容改为待审核状态 if (!SecurityUtils.getSubject().isPermitted("cms:link:audit")) { link.setDelFlag(Link.DEL_FLAG_AUDIT); } // 如果栏目不需要审核,则将该内容设为发布状态 if (link.getCategory() != null && StringUtils.isNotBlank(link.getCategory().getId())) { Category category = categoryDao.get(link.getCategory().getId()); if (!Article.YES.equals(category.getIsAudit())) { link.setDelFlag(Article.DEL_FLAG_NORMAL); } } linkDao.clear(); linkDao.save(link); }
@RequiresPermissions("cms:article:view") @RequestMapping(value = "form") public String form(Article article, Model model) { // 如果当前传参有子节点,则选择取消传参选择 if (article.getCategory() != null && StringUtils.isNotBlank(article.getCategory().getId())) { List<Category> list = categoryService.findByParentId(article.getCategory().getId(), Site.getCurrentSiteId()); if (list.size() > 0) { article.setCategory(null); } else { article.setCategory(categoryService.get(article.getCategory().getId())); } } article.setArticleData(articleDataService.get(article.getId())); // if (article.getCategory()=null && StringUtils.isNotBlank(article.getCategory().getId())){ // Category category = categoryService.get(article.getCategory().getId()); // } model.addAttribute("contentViewList", getTplContent()); model.addAttribute("article_DEFAULT_TEMPLATE", Article.DEFAULT_TEMPLATE); model.addAttribute("article", article); CmsUtils.addViewConfigAttribute(model, article.getCategory()); return "modules/cms/articleForm"; }
/** * QL 分页查询 * * @param page * @param qlString * @param parameter * @return */ @SuppressWarnings("unchecked") public Page<T> find(Page<T> page, String qlString, Object... parameter) { // get count if (!page.isDisabled() && !page.isNotCount()) { String countQlString = "select count(*)" + removeSelect(removeOrders(qlString)); page.setCount((Long) createQuery(countQlString, parameter).getSingleResult()); if (page.getCount() < 1) { return page; } } // order by String ql = qlString; if (StringUtils.isNotBlank(page.getOrderBy())) { ql += " order by " + page.getOrderBy(); } Query query = createQuery(ql, parameter); // set page if (!page.isDisabled()) { query.setFirstResult(page.getFirstResult()); query.setMaxResults(page.getMaxResults()); } page.setList(query.getResultList()); return page; }
@RequiresPermissions("renwu_run:renwuRun:view") @RequestMapping(value = "form") public String form(RenwuRun renwuRun, Model model) { if (renwuRun.getParent() != null && StringUtils.isNotBlank(renwuRun.getParent().getId())) { renwuRun.setParent(renwuRunService.get(renwuRun.getParent().getId())); // 获取排序号,最末节点排序号+30 if (StringUtils.isBlank(renwuRun.getId())) { RenwuRun renwuRunChild = new RenwuRun(); renwuRunChild.setParent(new RenwuRun(renwuRun.getParent().getId())); List<RenwuRun> list = renwuRunService.findList(renwuRun); if (list.size() > 0) { renwuRun.setSort(list.get(list.size() - 1).getSort()); if (renwuRun.getSort() != null) { renwuRun.setSort(renwuRun.getSort() + 30); } } } } if (renwuRun.getSort() == null) { renwuRun.setSort(30); } model.addAttribute("renwuRun", renwuRun); return "modules/renwu_run/renwuRunForm"; }
/** * 是否存在父类 * * @return */ public Boolean getParentExists() { return parent != null && StringUtils.isNotBlank(parentTable) && StringUtils.isNotBlank(parentTableFk); }
public List<TestTree> findList(TestTree testTree) { if (StringUtils.isNotBlank(testTree.getParentIds())) { testTree.setParentIds("," + testTree.getParentIds() + ","); } return super.findList(testTree); }