派生自 projectDept/qhighschool

yn147
2023-05-10 96286178ee1c257c130cb2ad964a781f36c4eee5
src/main/java/com/qxueyou/scc/teach/res/service/impl/ResService.java
@@ -30,9 +30,9 @@
import com.qxueyou.scc.teach.subject.service.impl.SubjectLectureService;
/**
 * 资源服务
 * 资源服务
 *
 * @author 夏德虎
 * @author 夏德虎
 */
@Service
public class ResService extends CommonAppService implements IResService {
@@ -51,7 +51,7 @@
    private IClassLectureService classLectureService;
    /**
     * 各类型资源服务实现
     * 各类型资源服务实现
     */
    private Map<String, IResItemService> resItemServiceMap = new HashMap<String, IResItemService>(6);
@@ -87,7 +87,7 @@
        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);
@@ -109,7 +109,7 @@
            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);
@@ -129,7 +129,7 @@
        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);
@@ -157,7 +157,7 @@
    }
    /**
     * @param resId 资源id
     * @param resId 资源id
     * @return
     */
    private Result delete(String resId) {
@@ -258,9 +258,9 @@
        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=?");
@@ -276,9 +276,9 @@
    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=?");
@@ -306,13 +306,13 @@
    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));
@@ -360,7 +360,7 @@
    public Result deleteDir(String[] dirIds) {
        for (String dirId : dirIds) {
            deleteFile4Dir(dirId);// 删除对应的文件
            deleteFile4Dir(dirId);// 删除对应的文件
            deleteDir(dirId);
        }
@@ -379,9 +379,9 @@
    }
    /**
     * 删除资源库文件夹对应删除文件
     * 删除资源库文件夹对应删除文件
     *
     * @param dirId 文件夹id
     * @param dirId 文件夹id
     */
    @Override
    public void deleteFile4Dir(String dirId) {
@@ -393,7 +393,7 @@
    @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"));
@@ -411,11 +411,11 @@
    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")));
@@ -454,7 +454,7 @@
        if (lib == null) {
            Result result = addDir(RES_DIR_ROOT, "根目录");
            Result result = addDir(RES_DIR_ROOT, "根目录");
            lib = new ResLib();
@@ -501,7 +501,7 @@
    }
    /**
     * 定时器监控转码完成后设置同步res表的状态
     * 定时器监控转码完成后设置同步res表的状态
     */
    @Scheduled(cron = "0/2 * * * * ?")
    public void doTimer() {