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();
}
}
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);
});
}
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);
}
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);
}
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;
}
Aggregations