Search in sources :

Example 1 with Resource

use of com.cas.sim.tis.entity.Resource in project TeachingInSimulation by ScOrPiOzzy.

the class ResourceList method loadResources.

/**
 * 加载资源
 */
private void loadResources(Integer pageIndex) {
    int curr = pageIndex + 1;
    int pageSize = 10;
    String keyword = search.getText();
    String orderByClause = order.getSelectedToggle().getUserData().toString();
    PageInfo<Resource> page = null;
    // 取出用户所选资源的类型
    List<Integer> types = new ArrayList<>();
    if (picCheck.isSelected()) {
        types.add(ResourceType.IMAGE.getType());
    }
    if (swfCheck.isSelected()) {
        types.add(ResourceType.SWF.getType());
    }
    if (videoCheck.isSelected()) {
        types.add(ResourceType.VIDEO.getType());
    }
    if (txtCheck.isSelected()) {
        types.add(ResourceType.TXT.getType());
    }
    if (wordCheck.isSelected()) {
        types.add(ResourceType.WORD.getType());
    }
    if (pptCheck.isSelected()) {
        types.add(ResourceType.PPT.getType());
    }
    if (excelCheck.isSelected()) {
        types.add(ResourceType.EXCEL.getType());
    }
    if (pdfCheck.isSelected()) {
        types.add(ResourceType.PDF.getType());
    }
    page = action.findResources(type, curr, pageSize, types, keyword, orderByClause, creator);
    if (page == null) {
        pagination.setPageCount(0);
        table.setItems(null);
        table.build();
    } else {
        pagination.setPageCount((int) page.getPages());
        JSONArray array = new JSONArray();
        array.addAll(page.getList());
        table.setItems(array);
        table.build();
    }
}
Also used : Resource(com.cas.sim.tis.entity.Resource) ArrayList(java.util.ArrayList) JSONArray(com.alibaba.fastjson.JSONArray)

Example 2 with Resource

use of com.cas.sim.tis.entity.Resource in project TeachingInSimulation by ScOrPiOzzy.

the class DrawingController method initialize.

@Override
public void initialize(URL location, ResourceBundle resources) {
    utils = SpringUtil.getBean(HTTPUtils.class);
    handle.setOnMouseDragged(e -> {
        stage.setX(e.getScreenX() + xOffset);
        stage.setY(e.getScreenY() + yOffset);
    });
    handle.setOnMousePressed(e -> {
        // 按下鼠标后,记录当前鼠标的坐标
        xOffset = stage.getX() - e.getScreenX();
        yOffset = stage.getY() - e.getScreenY();
    });
    group.selectedToggleProperty().addListener((b, o, n) -> {
        if (n == null) {
            group.selectToggle(o);
            return;
        }
        index = group.getToggles().indexOf(n);
        prev.setDisable(false);
        next.setDisable(false);
        if (index <= 0) {
            prev.setDisable(true);
        }
        if (index >= drawings.size() - 1) {
            next.setDisable(true);
        }
        Resource resource = (Resource) n.getUserData();
        String url = utils.getFullPath(ResourceConsts.FTP_RES_PATH + resource.getPath());
        loadDrawing(resource.getName(), url);
    });
}
Also used : Resource(com.cas.sim.tis.entity.Resource) HTTPUtils(com.cas.sim.tis.util.HTTPUtils)

Example 3 with Resource

use of com.cas.sim.tis.entity.Resource in project TeachingInSimulation by ScOrPiOzzy.

the class PreparationDetail method openResource.

private void openResource(Integer id) {
    ResourceAction action = SpringUtil.getBean(ResourceAction.class);
    action.browsed(id);
    Resource resource = action.findResourceByID(id);
    // 跳转到查看页面
    PageController controller = SpringUtil.getBean(PageController.class);
    controller.loadContent(new ResourceViewer(resource), PageLevel.Level2);
}
Also used : PageController(com.cas.sim.tis.view.controller.PageController) PreparationResource(com.cas.sim.tis.entity.PreparationResource) Resource(com.cas.sim.tis.entity.Resource) ResourceViewer(com.cas.sim.tis.view.control.imp.ResourceViewer) ResourceAction(com.cas.sim.tis.action.ResourceAction) PreparationResourceAction(com.cas.sim.tis.action.PreparationResourceAction)

Example 4 with Resource

use of com.cas.sim.tis.entity.Resource in project TeachingInSimulation by ScOrPiOzzy.

the class ResourceServiceImpl method deteleResource.

@Override
public void deteleResource(Integer id) {
    Resource resource = findById(id);
    resource.setDel(true);
    update(resource);
}
Also used : Resource(com.cas.sim.tis.entity.Resource)

Example 5 with Resource

use of com.cas.sim.tis.entity.Resource in project TeachingInSimulation by ScOrPiOzzy.

the class ResourceServiceImpl method findResourcesByCreator.

@Override
public PageInfo<Resource> findResourcesByCreator(int pagination, int pageSize, List<Integer> resourceTypes, String keyword, String orderByClause, Integer creator) {
    // 获取当前登陆者身份信息
    Condition condition = new Condition(Resource.class);
    // 条件1、查找用户指定的几种资源类型
    if (resourceTypes.size() == 0) {
        return new PageInfo<Resource>(new ArrayList<Resource>());
    } else {
        Criteria criteria = condition.createCriteria();
        criteria.andIn("type", resourceTypes);
    }
    // 条件2、关键字搜索
    if (keyword != null && !"".equals(keyword)) {
        Criteria criteria = condition.createCriteria();
        List<String> words = StringUtil.split(keyword, ' ');
        for (String word : words) {
            criteria.orLike("keyword", "%" + word + "%");
        }
        condition.and(criteria);
    }
    Criteria criteria = condition.createCriteria();
    criteria.andEqualTo("creator", creator);
    condition.and(criteria);
    // 开始分页查询
    PageHelper.startPage(pagination, pageSize, orderByClause);
    List<Resource> result = findByCondition(condition);
    PageInfo<Resource> page = new PageInfo<Resource>(result);
    // 查到的总记录数
    // 解释一下:这个page.getTotal(),是所有符合条件的记录数。
    // result.size():是当前页中的数据量 <= pageSize
    LOG.info("成功查找到{}条资源,当前页码{},每页{}条资源,共{}页", result.size(), pagination, pageSize, page.getPages());
    return page;
}
Also used : Condition(tk.mybatis.mapper.entity.Condition) PageInfo(com.github.pagehelper.PageInfo) Resource(com.cas.sim.tis.entity.Resource) Criteria(tk.mybatis.mapper.entity.Example.Criteria)

Aggregations

Resource (com.cas.sim.tis.entity.Resource)15 ResourceAction (com.cas.sim.tis.action.ResourceAction)6 JSONArray (com.alibaba.fastjson.JSONArray)4 PageInfo (com.github.pagehelper.PageInfo)4 FTPUtils (com.cas.sim.tis.util.FTPUtils)3 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 Button (javafx.scene.control.Button)3 ResourceMapper (com.cas.sim.tis.mapper.ResourceMapper)2 ResourceViewer (com.cas.sim.tis.view.control.imp.ResourceViewer)2 PageController (com.cas.sim.tis.view.controller.PageController)2 FXML (javafx.fxml.FXML)2 PreparationResourceAction (com.cas.sim.tis.action.PreparationResourceAction)1 ResourceConsts (com.cas.sim.tis.consts.ResourceConsts)1 ResourceType (com.cas.sim.tis.consts.ResourceType)1 PreparationResource (com.cas.sim.tis.entity.PreparationResource)1 TypicalCase (com.cas.sim.tis.entity.TypicalCase)1 ResourceService (com.cas.sim.tis.services.ResourceService)1 SVGGlyph (com.cas.sim.tis.svg.SVGGlyph)1 AlertUtil (com.cas.sim.tis.util.AlertUtil)1