Search in sources :

Example 1 with Criteria

use of com.itrus.portal.db.ExtraProductReleaseExample.Criteria in project portal by ixinportal.

the class ExtraProductReleaseController method list.

// 遍历页面
@RequestMapping(produces = "text/html")
public String list(@RequestParam(value = "project", required = false) Long project, @RequestParam(value = "extraProduct", required = false) Long extraProduct, @RequestParam(value = "appType", required = false) Long appType, @RequestParam(value = "appTypeExt", required = false) Long appTypeExt, @RequestParam(value = "page", required = false) Integer page, @RequestParam(value = "size", required = false) Integer size, Model uiModel) throws Exception {
    if (page == null || page < 1)
        page = 1;
    if (size == null || size < 1)
        size = 10;
    Integer offset = size * (page - 1);
    ExtraProductReleaseExample example = new ExtraProductReleaseExample();
    example.setLimit(size);
    example.setOffset(offset);
    // 所有的项目信息,以id为主键.以便页面显示信息
    Map<Long, Project> projectMap = new HashMap<Long, Project>();
    projectMap = projectService.getProjectMapByExample(null);
    // 所有的增值产品信息,以id为主键.以便页面显示信息
    Map<Long, ExtraProduct> extraProductMap = new HashMap<Long, ExtraProduct>();
    extraProductMap = extraProductService.selectMapByExample(null);
    Criteria criteria = example.createCriteria();
    if (project != null) {
        criteria.andProjectEqualTo(project);
    }
    if (extraProduct != null) {
        criteria.andExtraProductEqualTo(extraProduct);
    }
    criteria.andAppTypeIsNotNull();
    criteria.andAppTypeNotEqualTo("");
    if (appType != null) {
        criteria.andAppTypeLike("%" + appType + "%");
    }
    List<ExtraProductRelease> extraProductReleases = extraProductReleaseService.selectByExample(example);
    // 去除不包含所选 发布平台的记录
    if (appType != null) {
        Iterator<ExtraProductRelease> it = extraProductReleases.iterator();
        while (it.hasNext()) {
            ExtraProductRelease epr = it.next();
            String appTypes = epr.getAppType();
            boolean isHas = false;
            for (String at : appTypes.split(",")) {
                if (appType.toString().equals(at)) {
                    isHas = true;
                    break;
                }
            }
            if (!isHas) {
                it.remove();
            }
        }
    }
    Integer count = extraProductReleases.size();
    uiModel.addAttribute("count", count);
    uiModel.addAttribute("pages", (count + size - 1) / size);
    // page, size
    if (page > 1 && size * (page - 1) >= count) {
        page = (count + size - 1) / size;
    }
    uiModel.addAttribute("page", page);
    uiModel.addAttribute("size", size);
    uiModel.addAttribute("projectCur", project);
    uiModel.addAttribute("extraProductCur", extraProduct);
    uiModel.addAttribute("appTypesCur", appType);
    uiModel.addAttribute("appTypeExt", appTypeExt);
    uiModel.addAttribute("projectMap", projectMap);
    uiModel.addAttribute("extraProductMap", extraProductMap);
    uiModel.addAttribute("extraProductReleases", extraProductReleases);
    return "extraproductrelease/list";
}
Also used : HashMap(java.util.HashMap) ExtraProductRelease(com.itrus.portal.db.ExtraProductRelease) Criteria(com.itrus.portal.db.ExtraProductReleaseExample.Criteria) ExtraProductReleaseExample(com.itrus.portal.db.ExtraProductReleaseExample) Project(com.itrus.portal.db.Project) ExtraProduct(com.itrus.portal.db.ExtraProduct) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

ExtraProduct (com.itrus.portal.db.ExtraProduct)1 ExtraProductRelease (com.itrus.portal.db.ExtraProductRelease)1 ExtraProductReleaseExample (com.itrus.portal.db.ExtraProductReleaseExample)1 Criteria (com.itrus.portal.db.ExtraProductReleaseExample.Criteria)1 Project (com.itrus.portal.db.Project)1 HashMap (java.util.HashMap)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1