Search in sources :

Example 1 with App

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

the class AppClientController method loadImg.

/**
 * 根据主键id和类型返回相对应的图片信息
 * @param type 1 代表应用管理 2 代表增值应用
 * @param id
 * @param response
 * @return
 */
@RequestMapping(value = "/getImage/{id}/{type}")
public String loadImg(@PathVariable("type") Long type, @PathVariable("id") Long id, HttpServletResponse response, Model uiModel) {
    String img = null;
    Long n = 1l;
    OutputStream os = null;
    FileInputStream fis = null;
    try {
        if (n.equals(type)) {
            App app = sqlSession.selectOne("com.itrus.portal.db.AppMapper.selectByPrimaryKey", id);
            if (null == app) {
                return "status403";
            }
            response.setHeader("Pragma", "no-cache");
            response.setHeader("Cache-Control", "no-cache");
            response.setDateHeader("Expires", 0);
            img = app.getAppIcon();
            if (img == null) {
                return "status403";
            }
            File filePath = appService.getFilePathById(app.getId());
            if (!filePath.exists()) {
                filePath.mkdir();
            }
            File file = new File(filePath, img);
            fis = new FileInputStream(file);
        } else {
            ExtraProduct extraProduct = extraProductService.selectByPrimaryKey(id);
            if (null == extraProduct) {
                uiModel.addAttribute("errorMsg", "增值产品不存在");
                return ComNames.CLIENTFW_ERRORPAGE;
            }
            img = extraProduct.getAppLogo();
            if (img == null) {
                uiModel.addAttribute("errorMsg", "图片不存");
                return null;
            }
            File filePath = extraProductService.getFilePathById(id);
            if (!filePath.exists()) {
                filePath.mkdir();
            }
            File file = new File(filePath, img);
            fis = new FileInputStream(file);
        }
        byte[] bb = IOUtils.toByteArray(fis);
        os = response.getOutputStream();
        os.write(bb);
        os.flush();
    } catch (IOException e) {
        // 未找到
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        // 关闭流!
        try {
            if (null != fis) {
                fis.close();
            }
            if (null != os) {
                os.close();
            }
        } catch (IOException e) {
        }
    }
    return null;
}
Also used : App(com.itrus.portal.db.App) ExtraProduct(com.itrus.portal.db.ExtraProduct) OutputStream(java.io.OutputStream) IOException(java.io.IOException) File(java.io.File) FileInputStream(java.io.FileInputStream) IOException(java.io.IOException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with App

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

the class AppController method show.

/**
 * 显示应用详情
 * @return
 */
@RequestMapping(value = "/show/{id}")
public String show(@PathVariable("id") Long id, Model uiModel) {
    App app = sqlSession.selectOne("com.itrus.portal.db.AppMapper.selectByPrimaryKey", id);
    Project project = sqlSession.selectOne("com.itrus.portal.db.ProjectMapper.selectByPrimaryKey", app.getProject());
    uiModel.addAttribute("project", project);
    uiModel.addAttribute("app", app);
    return "apps/show";
}
Also used : App(com.itrus.portal.db.App) Project(com.itrus.portal.db.Project) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with App

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

the class AppController method loadImg.

/**
 * 根据主键id和类型返回相对应的图片信息
 * @param type 1 代表应用管理 2 代表增值应用
 * @param id
 * @param response
 * @return
 */
@RequestMapping(value = "/getImage/{id}/{type}")
public String loadImg(@PathVariable(value = "type") Long type, @PathVariable(value = "id") Long id, HttpServletResponse response, Model uiModel) {
    String img = null;
    Long n = 1l;
    OutputStream os = null;
    FileInputStream fis = null;
    try {
        if (n.equals(type)) {
            App app = sqlSession.selectOne("com.itrus.portal.db.AppMapper.selectByPrimaryKey", id);
            if (null == app) {
                return "status403";
            }
            response.setHeader("Pragma", "no-cache");
            response.setHeader("Cache-Control", "no-cache");
            response.setDateHeader("Expires", 0);
            img = app.getAppIcon();
            if (img == null) {
                return "status403";
            }
            File filePath = appService.getFilePathById(app.getId());
            if (!filePath.exists()) {
                filePath.mkdir();
            }
            File file = new File(filePath, img);
            fis = new FileInputStream(file);
        } else {
            ExtraProduct extraProduct = extraProductService.selectByPrimaryKey(id);
            if (null == extraProduct) {
                uiModel.addAttribute("errorMsg", "增值产品不存在");
                return "client/errorpage";
            }
            img = extraProduct.getAppLogo();
            if (img == null) {
                uiModel.addAttribute("errorMsg", "图片不存");
                return null;
            }
            File filePath = extraProductService.getFilePathById(id);
            if (!filePath.exists()) {
                filePath.mkdir();
            }
            File file = new File(filePath, img);
            fis = new FileInputStream(file);
        }
        byte[] bb = IOUtils.toByteArray(fis);
        os = response.getOutputStream();
        os.write(bb);
        os.flush();
    } catch (IOException e) {
        // 未找到
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        // 关闭流!
        try {
            if (null != fis) {
                fis.close();
            }
            if (null != os) {
                os.close();
            }
        } catch (IOException e) {
        }
    }
    return null;
}
Also used : App(com.itrus.portal.db.App) ExtraProduct(com.itrus.portal.db.ExtraProduct) OutputStream(java.io.OutputStream) IOException(java.io.IOException) File(java.io.File) MultipartFile(org.springframework.web.multipart.MultipartFile) FileInputStream(java.io.FileInputStream) IOException(java.io.IOException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 4 with App

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

the class AppController method list.

@RequestMapping(produces = "text/html")
public String list(Model uiModel, @RequestParam(value = "page", required = false) Integer page, @RequestParam(value = "size", required = false) Integer size, HttpSession session) {
    Map<Long, Project> projectmap = getProjectMapOfAdmin();
    if (page == null || page < 1) {
        page = 1;
    }
    if (size == null || size < 1) {
        size = 10;
    }
    AppExample appex = new AppExample();
    Integer count = sqlSession.selectOne("com.itrus.portal.db.AppMapper.countByExample", appex);
    if (page > 1 && size * (page - 1) >= count) {
        page = (count + size - 1) / size;
    }
    Integer offset = size * (page - 1);
    appex.setOffset(offset);
    appex.setLimit(size);
    List<App> appList = sqlSession.selectList("com.itrus.portal.db.AppMapper.selectByExample", appex);
    uiModel.addAttribute("page", page);
    uiModel.addAttribute("size", size);
    uiModel.addAttribute("count", count);
    uiModel.addAttribute("pages", (count + size - 1) / size);
    uiModel.addAttribute("projectmap", projectmap);
    uiModel.addAttribute("appList", appList);
    String delMsg = (String) session.getAttribute(APP_DEL_MSG);
    if (StringUtils.isNotBlank(delMsg)) {
        uiModel.addAttribute("message", delMsg);
        session.removeAttribute(APP_DEL_MSG);
    }
    return "apps/list";
}
Also used : App(com.itrus.portal.db.App) Project(com.itrus.portal.db.Project) AppExample(com.itrus.portal.db.AppExample) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 5 with App

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

the class AppController method updateForm.

/**
 * 前往修改页面
 * @param id
 * @param request
 * @param uiModel
 * @return
 */
@RequestMapping(value = "/{id}", params = "form", produces = "text/html")
public String updateForm(@PathVariable("id") Long id, HttpServletRequest request, Model uiModel) {
    App app = sqlSession.selectOne("com.itrus.portal.db.AppMapper.selectByPrimaryKey", id);
    uiModel.addAttribute("app", app);
    uiModel.addAttribute("projects", getProjectMapOfAdmin().values());
    return "apps/update";
}
Also used : App(com.itrus.portal.db.App) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

App (com.itrus.portal.db.App)9 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)8 Project (com.itrus.portal.db.Project)4 File (java.io.File)4 ExtraProduct (com.itrus.portal.db.ExtraProduct)3 FileInputStream (java.io.FileInputStream)3 IOException (java.io.IOException)3 OutputStream (java.io.OutputStream)3 MultipartFile (org.springframework.web.multipart.MultipartFile)3 AppExample (com.itrus.portal.db.AppExample)2 ExtraProductRelease (com.itrus.portal.db.ExtraProductRelease)1 AppBean (com.itrus.portal.entity.AppBean)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1