Search in sources :

Example 1 with FileConfigExample

use of com.itrus.portal.db.FileConfigExample in project portal by ixinportal.

the class DownloadConfigController method createForm.

// 返回新建页面
@RequestMapping(params = "form", produces = "text/html")
public String createForm(@RequestParam(value = "status", required = false) Integer status, Model uiModel) {
    if (status == 2) {
        // 管理员项目权限
        Long[] projectsOfAdmin = getProjectLongIdsOfAdmin();
        // param.put("hasProjects", Arrays.asList(projectsOfAdmin));
        List<Map<String, Object>> projectIds = configServiceImpl.getProjects();
        List<Long> pids = new ArrayList<>();
        for (Map<String, Object> p : projectIds) {
            pids.add((Long) p.get("project"));
        }
        uiModel.addAttribute("pids", pids);
        // 获取所有项目信息
        ProjectExample projectExample = new ProjectExample();
        ProjectExample.Criteria pec = projectExample.createCriteria();
        pec.andIdIn(Arrays.asList(projectsOfAdmin));
        List<Project> projects = projectServiceImpl.getProjectByExample(projectExample);
        uiModel.addAttribute("projects", projects);
        // 获取所有文件信息
        List<FileConfig> fileConfigs = configServiceImpl.getList(new FileConfigExample());
        uiModel.addAttribute("fileConfigs", fileConfigs);
        try {
            uiModel.addAttribute("jsonFile", jsonTool.writeValueAsString(fileConfigs));
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return "downloadconfig/create2";
    } else {
        if (status == 3) {
            uiModel.addAttribute("message", "创建文件信息失败!");
        }
        return "downloadconfig/create1";
    }
}
Also used : FileConfig(com.itrus.portal.db.FileConfig) ProjectExample(com.itrus.portal.db.ProjectExample) ArrayList(java.util.ArrayList) Project(com.itrus.portal.db.Project) FileConfigExample(com.itrus.portal.db.FileConfigExample) HashMap(java.util.HashMap) Map(java.util.Map) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with FileConfigExample

use of com.itrus.portal.db.FileConfigExample in project portal by ixinportal.

the class DownloadConfigController method list.

// 列表所有信息
@RequestMapping(produces = "text/html")
public String list(@RequestParam(value = "status", required = false) Integer status, @RequestParam(value = "page", required = false) Integer page, @RequestParam(value = "size", required = false) Integer size, @RequestParam(value = "page2", required = false) Integer page2, @RequestParam(value = "size2", required = false) Integer size2, @RequestParam(value = "name", required = false) String name, @RequestParam(value = "description", required = false) String description, @RequestParam(value = "queryDate1", required = false) Date queryDate1, @RequestParam(value = "queryDate2", required = false) Date queryDate2, @RequestParam(value = "projectId1", required = false) Long projectId1, @RequestParam(value = "name1", required = false) String name1, @RequestParam(value = "description1", required = false) String description1, @RequestParam(value = "queryDate3", required = false) Date queryDate3, @RequestParam(value = "queryDate4", required = false) Date queryDate4, Model uiModel) {
    if (queryDate1 == null && queryDate2 == null) {
        Calendar calendar = Calendar.getInstance();
        calendar.add(Calendar.DATE, 1);
        calendar.set(Calendar.HOUR_OF_DAY, 0);
        calendar.set(Calendar.MINUTE, 0);
        calendar.set(Calendar.SECOND, 0);
        calendar.set(Calendar.MILLISECOND, 0);
        calendar.add(Calendar.MILLISECOND, -1);
        queryDate2 = calendar.getTime();
        calendar.add(Calendar.MILLISECOND, 1);
        calendar.add(Calendar.MONTH, -1);
        queryDate1 = calendar.getTime();
    }
    if (queryDate3 == null && queryDate4 == null) {
        Calendar calendar = Calendar.getInstance();
        calendar.add(Calendar.DATE, 1);
        calendar.set(Calendar.HOUR_OF_DAY, 0);
        calendar.set(Calendar.MINUTE, 0);
        calendar.set(Calendar.SECOND, 0);
        calendar.set(Calendar.MILLISECOND, 0);
        calendar.add(Calendar.MILLISECOND, -1);
        queryDate4 = calendar.getTime();
        calendar.add(Calendar.MILLISECOND, 1);
        calendar.add(Calendar.MONTH, -1);
        queryDate3 = calendar.getTime();
    }
    // page,size
    if (page == null || page < 1)
        page = 1;
    if (size == null || size < 1)
        size = 10;
    Integer offset = size * (page - 1);
    // 筛选对应 fileConfig 表的信息
    FileConfigExample fileConfigExample = new FileConfigExample();
    FileConfigExample.Criteria cec = fileConfigExample.createCriteria();
    if (StringUtils.isNotEmpty(name))
        cec.andNameLike("%" + name + "%");
    if (StringUtils.isNotEmpty(description))
        cec.andDescriptionLike("%" + description + "%");
    if (queryDate1 != null && queryDate2 != null)
        cec.andCreateTimeBetween(queryDate1, queryDate2);
    else if (queryDate1 != null && queryDate2 == null)
        cec.andCreateTimeGreaterThanOrEqualTo(queryDate1);
    else if (queryDate1 == null && queryDate2 != null)
        cec.andCreateTimeLessThan(queryDate2);
    fileConfigExample.setOffset(offset);
    fileConfigExample.setLimit(size);
    fileConfigExample.setOrderByClause("create_time desc");
    List<FileConfig> fileConfigs = configServiceImpl.getList(fileConfigExample);
    uiModel.addAttribute("fileConfigs", fileConfigs);
    // count,pages
    Integer count = configServiceImpl.getCount(fileConfigExample);
    uiModel.addAttribute("count", count);
    uiModel.addAttribute("pages", (count + size - 1) / size);
    if (page > 1 && size * (page - 1) >= count) {
        page = (count + size - 1) / size;
    }
    uiModel.addAttribute("page", page);
    uiModel.addAttribute("size", size);
    // page,size
    if (page2 == null || page2 < 1)
        page2 = 1;
    if (size2 == null || size2 < 1)
        size2 = 10;
    Integer offset2 = size2 * (page2 - 1);
    // 筛选对应 FileIssue 表的信息
    Map<String, Object> param = new HashMap<>();
    // 管理员项目权限
    Long[] projectsOfAdmin = getProjectLongIdsOfAdmin();
    param.put("hasProjects", Arrays.asList(projectsOfAdmin));
    param.put("offset", offset2);
    param.put("limit", size2);
    param.put("queryDate3", queryDate3);
    param.put("queryDate4", queryDate4);
    if (StringUtils.isNotEmpty(name1)) {
        param.put("name1", "%" + name1 + "%");
    }
    if (StringUtils.isNotEmpty(description1)) {
        param.put("description1", "%" + description1 + "%");
    }
    if (projectId1 != null && projectId1 != 0) {
        param.put("projectId1", projectId1);
    }
    List<Map<String, Object>> fileIssues = configServiceImpl.getList(param);
    uiModel.addAttribute("fileIssues", fileIssues);
    Integer count2 = configServiceImpl.getCount(param);
    uiModel.addAttribute("count2", count2);
    // 获取所有项目信息
    ProjectExample projectExample = new ProjectExample();
    ProjectExample.Criteria pec = projectExample.createCriteria();
    pec.andIdIn(Arrays.asList(projectsOfAdmin));
    List<Project> projects = projectServiceImpl.getProjectByExample(projectExample);
    uiModel.addAttribute("pages2", (count2 + size2 - 1) / size2);
    if (page2 > 1 && size2 * (page2 - 1) >= count2) {
        page2 = (count2 + size2 - 1) / size2;
    }
    uiModel.addAttribute("page2", page2);
    uiModel.addAttribute("size2", size2);
    // 返回搜索条件参数
    uiModel.addAttribute("status", status);
    uiModel.addAttribute("projects", projects);
    uiModel.addAttribute("name", name);
    uiModel.addAttribute("name1", name1);
    uiModel.addAttribute("description", description);
    uiModel.addAttribute("description1", description1);
    uiModel.addAttribute("projectId1", projectId1);
    uiModel.addAttribute("queryDate1", queryDate1);
    uiModel.addAttribute("queryDate2", queryDate2);
    uiModel.addAttribute("queryDate3", queryDate3);
    uiModel.addAttribute("queryDate4", queryDate4);
    return "downloadconfig/list";
}
Also used : FileConfig(com.itrus.portal.db.FileConfig) HashMap(java.util.HashMap) ProjectExample(com.itrus.portal.db.ProjectExample) Calendar(java.util.Calendar) Project(com.itrus.portal.db.Project) FileConfigExample(com.itrus.portal.db.FileConfigExample) HashMap(java.util.HashMap) Map(java.util.Map) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with FileConfigExample

use of com.itrus.portal.db.FileConfigExample in project portal by ixinportal.

the class DownloadConfigController method updateForm.

// 返回修改页面
@RequestMapping(value = "/{id}/{status}", params = "form", produces = "text/html")
public String updateForm(@PathVariable("id") Long id, @PathVariable("status") Integer status, Model uiModel) {
    if (status == 1) {
        FileConfig fileConfig = configServiceImpl.getFileConfigById(id);
        uiModel.addAttribute("fileConfig", fileConfig);
        return "downloadconfig/update1";
    } else if (status == 2) {
        FileIssue fileIssue = configServiceImpl.getFileIssueById(id);
        // uiModel.addAttribute("fileIssue", fileIssue);
        // 获取对应项目信息
        Project project = projectServiceImpl.selectByPrimaryKey(fileIssue.getProject());
        uiModel.addAttribute("project", project);
        // Map<String, Object> param = new HashMap<>();
        // param.put("projectId1", fileIssue.getProject());
        // List<Map<String, Object>> fileIssues = configServiceImpl.getList(param);
        // 获取所有文件信息
        List<FileConfig> fileConfigs = configServiceImpl.getList(new FileConfigExample());
        uiModel.addAttribute("fileConfigs", fileConfigs);
        try {
            uiModel.addAttribute("jsonFile", jsonTool.writeValueAsString(fileConfigs));
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        // 获取对应项目下的所有发布文件
        FileIssueExample issueExample = new FileIssueExample();
        FileIssueExample.Criteria fec = issueExample.createCriteria();
        fec.andProjectEqualTo(fileIssue.getProject());
        issueExample.setOrderByClause("priority asc");
        List<FileIssue> fileIssues = configServiceImpl.getList(issueExample);
        try {
            uiModel.addAttribute("jsonFileIssues", jsonTool.writeValueAsString(fileIssues));
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        uiModel.addAttribute("fileIssues", fileIssues);
        return "downloadconfig/update2";
    } else {
        FileConfig fileConfig = configServiceImpl.getFileConfigById(id);
        uiModel.addAttribute("fileConfig", fileConfig);
        uiModel.addAttribute("message", "修改文件管理信息失败!");
        return "downloadconfig/update1";
    }
}
Also used : FileConfig(com.itrus.portal.db.FileConfig) Project(com.itrus.portal.db.Project) FileConfigExample(com.itrus.portal.db.FileConfigExample) ArrayList(java.util.ArrayList) List(java.util.List) FileIssue(com.itrus.portal.db.FileIssue) FileIssueExample(com.itrus.portal.db.FileIssueExample) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

FileConfig (com.itrus.portal.db.FileConfig)3 FileConfigExample (com.itrus.portal.db.FileConfigExample)3 Project (com.itrus.portal.db.Project)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 ProjectExample (com.itrus.portal.db.ProjectExample)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 FileIssue (com.itrus.portal.db.FileIssue)1 FileIssueExample (com.itrus.portal.db.FileIssueExample)1 Calendar (java.util.Calendar)1 List (java.util.List)1