| | |
| | | import com.qxueyou.scc.teach.subject.service.impl.SubjectLectureService; |
| | | |
| | | /** |
| | | * 资源服务 |
| | | * 资源服务 |
| | | * |
| | | * @author 夏德虎 |
| | | * @author 夏德虎 |
| | | */ |
| | | @Service |
| | | public class ResService extends CommonAppService implements IResService { |
| | |
| | | private IClassLectureService classLectureService; |
| | | |
| | | /** |
| | | * 各类型资源服务实现 |
| | | * 各类型资源服务实现 |
| | | */ |
| | | private Map<String, IResItemService> resItemServiceMap = new HashMap<String, IResItemService>(6); |
| | | |
| | |
| | | res.setCoverPageUrl(coverPageUrl); |
| | | res.setItemDestId(resItemId); |
| | | res.setName(name); |
| | | res.setStatus(Res.STATUS_CONVER); |
| | | res.setStatus(Res.STATUS_DRAFT); |
| | | res.setType(type); |
| | | res.setResDirId(dirId); |
| | | res.setRemark(remark); |
| | |
| | | TraceUtils.setCreateTrace(res); |
| | | res.setItemDestId(resItemId); |
| | | res.setName(name); |
| | | res.setStatus(Res.STATUS_CONVER); |
| | | res.setStatus(Res.STATUS_DRAFT); |
| | | res.setType(type); |
| | | res.setLibId(dir.getLibId()); |
| | | res.setResDirId(dirId); |
| | |
| | | |
| | | Res res = read(Res.class, resId); |
| | | |
| | | resItemServiceMap.get(res.getType()).update(res.getItemDestId(), name); |
| | | // resItemServiceMap.get(res.getType()).update(res.getItemDestId(), name); |
| | | |
| | | TraceUtils.setUpdateTrace(res); |
| | | res.setName(name); |
| | |
| | | } |
| | | |
| | | /** |
| | | * @param resId 资源id |
| | | * @param resId 资源id |
| | | * @return |
| | | */ |
| | | private Result delete(String resId) { |
| | |
| | | ResLib lib = this.getResLib(libType, ownerId); |
| | | |
| | | StringBuffer hql = new StringBuffer( |
| | | "from Res where deleteFlag is false and name like ? and libId=? and status=? order by updateTime desc"); |
| | | "from Res where deleteFlag is false and name like ? and libId like ? and status=? order by updateTime desc"); |
| | | |
| | | List<Object> args = CollectionUtils.newList(keyword + "%", lib == null ? null : lib.getLibId(),Res.STATUS_DRAFT); |
| | | List<Object> args = CollectionUtils.newList(keyword + "%", lib == null ? "%" : lib.getLibId() + "%",Res.STATUS_DRAFT); |
| | | |
| | | if (!StringUtils.isEmpty(resType)) { |
| | | hql.append(" and type=?"); |
| | |
| | | public int listResCountByLib(String libType, String ownerId, String text, String resType) { |
| | | ResLib lib = this.getResLib(libType, ownerId); |
| | | |
| | | StringBuffer hql = new StringBuffer("from Res where deleteFlag is false and libId=? order by updateTime desc"); |
| | | StringBuffer hql = new StringBuffer("from Res where deleteFlag is false and libId like ? order by updateTime desc"); |
| | | |
| | | List<Object> args = CollectionUtils.newList(null == lib ? null : lib.getLibId()); |
| | | List<Object> args = CollectionUtils.newList(null == lib ? "%" : lib.getLibId()+"%"); |
| | | |
| | | if (!StringUtils.isEmpty(resType)) { |
| | | hql.append(" and type=?"); |
| | |
| | | public Result readAccessPath(String resId, String attribute) { |
| | | |
| | | Res res = read(Res.class, resId); |
| | | |
| | | String type="0"; |
| | | // Object path = Res.FILE_TYPE_VIDEO.equals(res.getType())? JSONObject.parse(resItemServiceMap.get(res.getType()).readAccessPath(res.getItemDestId(), attribute)):CollectionUtils.newObjectMap("path", resItemServiceMap.get(res.getType()).readAccessPath(res.getItemDestId(), attribute)); |
| | | Object path = Res.FILE_TYPE_VIDEO.equals(res.getType())? resItemServiceMap.get(res.getType()).readAccessPath(res.getItemDestId(), attribute):resItemServiceMap.get(res.getType()).readAccessPath(res.getItemDestId(), attribute); |
| | | Object path = Res.FILE_TYPE_VIDEO.equals(type)? resItemServiceMap.get(type).readAccessPath(res.getItemDestId(), attribute):resItemServiceMap.get(type).readAccessPath(res.getItemDestId(), attribute); |
| | | if(Res.FILE_TYPE_DOC.equals(res.getType())) { |
| | | return new Result(true, "success", |
| | | CollectionUtils.newObjectMap("path", path, "name", res.getName(), "coverPageUrl", res.getCoverPageUrl(), "size", |
| | | this.classLectureService.readDocPageCount(res.getItemDestId())));//文件的页数 |
| | | this.classLectureService.readDocPageCount(res.getItemDestId())));//文件的页数 |
| | | }else { |
| | | return new Result(true, "success", |
| | | CollectionUtils.newObjectMap("path", path, "name", res.getName(), "coverPageUrl", res.getCoverPageUrl(), "size", 0)); |
| | |
| | | public Result deleteDir(String[] dirIds) { |
| | | |
| | | for (String dirId : dirIds) { |
| | | deleteFile4Dir(dirId);// 删除对应的文件 |
| | | deleteFile4Dir(dirId);// 删除对应的文件 |
| | | deleteDir(dirId); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | /** |
| | | * 删除资源库文件夹对应删除文件 |
| | | * 删除资源库文件夹对应删除文件 |
| | | * |
| | | * @param dirId 文件夹id |
| | | * @param dirId 文件夹id |
| | | */ |
| | | @Override |
| | | public void deleteFile4Dir(String dirId) { |
| | |
| | | @Override |
| | | public ResDir doGetRootDir(String type, String ownerId) { |
| | | ResLib lib = getResLib(type, ownerId); |
| | | // 无资源库则初始化,并返回根节点 |
| | | // 无资源库则初始化,并返回根节点 |
| | | if (lib == null) { |
| | | Result result = initResLib(type, ownerId); |
| | | return read(ResDir.class, result.getDataT("rootDirId")); |
| | |
| | | |
| | | private List<ResDir> doGetChildDirsInner(String parentDirId, String type) { |
| | | |
| | | // 根节点的处理 |
| | | // 根节点的处理 |
| | | if (StringUtils.isEmpty(parentDirId)) { |
| | | ResLib lib = getResLib(type, ClientUtils.getUserId()); |
| | | |
| | | // 无资源库则初始化,并返回根节点 |
| | | // 无资源库则初始化,并返回根节点 |
| | | if (lib == null) { |
| | | Result result = initUserLib(); |
| | | return CollectionUtils.newList(ResDir.class, read(ResDir.class, result.getDataT("rootDirId"))); |
| | |
| | | |
| | | if (lib == null) { |
| | | |
| | | Result result = addDir(RES_DIR_ROOT, "根目录"); |
| | | Result result = addDir(RES_DIR_ROOT, "根目录"); |
| | | |
| | | lib = new ResLib(); |
| | | |
| | |
| | | } |
| | | |
| | | /** |
| | | * 定时器监控转码完成后设置同步res表的状态 |
| | | * 定时器监控转码完成后设置同步res表的状态 |
| | | */ |
| | | @Scheduled(cron = "0/2 * * * * ?") |
| | | public void doTimer() { |