| | |
| | | import com.qxueyou.scc.teach.subject.model.SubjectChapter; |
| | | |
| | | /** |
| | | * 文章实现类 |
| | | * 文章实现类 |
| | | * |
| | | * @author zhiyong |
| | | * |
| | |
| | | @Autowired |
| | | private ICourseWareService courseWareService; |
| | | |
| | | // 缓存 |
| | | // 缓存 |
| | | @SuppressWarnings("unused") |
| | | private static final String CACHE_MSG_IMGS = "CACHE_MSG_IMGS_"; |
| | | @SuppressWarnings("unused") |
| | |
| | | private static final int ONE_DAY = 60 * 60 * 24; |
| | | |
| | | /** |
| | | * 查询列表数据 |
| | | * 查询列表数据 |
| | | * |
| | | * @param type |
| | | * @return |
| | |
| | | } |
| | | |
| | | /** |
| | | * 新增或更新列表数据 |
| | | * 新增或更新列表数据 |
| | | * |
| | | * @param articleId |
| | | * @param name |
| | |
| | | public Result updateArticle(SchArticle article) { |
| | | |
| | | String articleId = article.getArticleId(); |
| | | if (StringUtils.isBlank(articleId)) {// 新增 |
| | | if (StringUtils.isBlank(articleId)) {// 新增 |
| | | article.setArticleId(null); |
| | | article.setClassId(ClientUtils.getClassId()); |
| | | article.setOrgId(ClientUtils.getOrgId()); |
| | | article.setDeleteFlag(false); |
| | | TraceUtils.setCreateTrace(article); |
| | | |
| | | // 序号 |
| | | // 序号 |
| | | String hql = "select MAX(c.orderNum) from SchArticle c where c.deleteFlag is false and c.classId= ? "; |
| | | Integer iMax = this.findUnique(hql, CollectionUtils.newList(ClientUtils.getClassId()), Integer.class); |
| | | |
| | |
| | | this.saveArticle(article); |
| | | |
| | | articleId = article.getArticleId(); |
| | | } else {// 更新 |
| | | } else {// 更新 |
| | | |
| | | SchArticle articleNew = this.read(SchArticle.class, articleId); |
| | | |
| | | // 原上传的文件url |
| | | // 原上传的文件url |
| | | String originUrl = articleNew.getUrl(); |
| | | |
| | | articleNew.setCoverPageUrl(article.getCoverPageUrl()); |
| | |
| | | |
| | | this.saveArticle(articleNew); |
| | | |
| | | // // 删除原上传的文件 |
| | | // // 删除原上传的文件 |
| | | // if(StringUtils.isNotBlank(originUrl)){ |
| | | // ossService.deleteOSSFile(originUrl.substring(1)); |
| | | // } |
| | | } |
| | | |
| | | // 保存OrgText —— 文章内容 |
| | | // 保存OrgText —— 文章内容 |
| | | orgTextService.doSaveOrgText(articleId, OrgText.TABLE_NAME_ARTICLE, article.getContent()); |
| | | |
| | | // 删除该班级所有缓存 |
| | | // 删除该班级所有缓存 |
| | | // new CacheUtils().deleteWBProjectCacheData(); |
| | | |
| | | return new Result(true, "操作成功", articleId); |
| | | return new Result(true, "操作成功", articleId); |
| | | } |
| | | |
| | | /** |
| | | * 新增或更新列表数据 机构 |
| | | * 新增或更新列表数据 机构 |
| | | * |
| | | * @return |
| | | */ |
| | |
| | | public Result updateOrgArticle(SchArticle article, String collegeCourseId) { |
| | | |
| | | String articleId = article.getArticleId(); |
| | | // jgw 直接将文章修改为已发布 |
| | | // jgw 直接将文章修改为已发布 |
| | | article.setStatus(SchArticle.STATUS_PUBLISHED); |
| | | |
| | | if (StringUtils.isBlank(articleId)) {// 新增 |
| | | if (StringUtils.isBlank(articleId)) {// 新增 |
| | | article.setArticleId(null); |
| | | article.setOrgId(ClientUtils.getOrgId()); |
| | | article.setDeleteFlag(false); |
| | |
| | | this.saveArticle(article); |
| | | |
| | | articleId = article.getArticleId(); |
| | | // 保存文章课程关联关系 |
| | | // 保存文章课程关联关系 |
| | | saveSchArticleReCourse(collegeCourseId, article.getArticleId()); |
| | | } else {// 更新 |
| | | } else {// 更新 |
| | | |
| | | SchArticle articleNew = this.read(SchArticle.class, articleId); |
| | | // 原上传的文件url |
| | | // 原上传的文件url |
| | | String originUrl = articleNew.getUrl(); |
| | | |
| | | articleNew.setCoverPageUrl(article.getCoverPageUrl()); |
| | |
| | | |
| | | this.saveArticle(articleNew); |
| | | |
| | | // // 删除原上传的文件 |
| | | // // 删除原上传的文件 |
| | | // if(StringUtils.isNotBlank(originUrl)){ |
| | | // ossService.deleteOSSFile(originUrl.substring(1)); |
| | | // } |
| | | } |
| | | |
| | | // 保存OrgText —— 文章内容 |
| | | // 保存OrgText —— 文章内容 |
| | | orgTextService.doSaveOrgText(articleId, OrgText.TABLE_NAME_ARTICLE, article.getContent()); |
| | | |
| | | // 删除该班级所有缓存 |
| | | // 删除该班级所有缓存 |
| | | // new CacheUtils().deleteWBProjectCacheData(); |
| | | |
| | | return new Result(true, "操作成功", articleId); |
| | | return new Result(true, "操作成功", articleId); |
| | | } |
| | | |
| | | /** |
| | | * 保存文章课程关联关系 |
| | | * 保存文章课程关联关系 |
| | | * |
| | | * @param collegeCourseId |
| | | * @param articleId |
| | |
| | | course.setOrgId(ClientUtils.getOrgId()); |
| | | TraceUtils.setCreateTrace(course); |
| | | |
| | | // 序号 |
| | | // 序号 |
| | | String hql = "select MAX(c.orderNum) from SchArticleReCourse c where c.deleteFlag is false and c.collegeCourseId = ? and orgId = ? "; |
| | | Integer iMax = this.findUnique(hql, CollectionUtils.newList(collegeCourseId, ClientUtils.getOrgId()), |
| | | Integer.class); |
| | |
| | | } |
| | | |
| | | /** |
| | | * 删除文章 |
| | | * 删除文章 |
| | | * |
| | | * @param articleIds |
| | | * @return |
| | |
| | | public Result deleteArticle(String articleIds) { |
| | | |
| | | if (StringUtils.isBlank(articleIds)) { |
| | | return new Result(false, "提交数据异常"); |
| | | return new Result(false, "提交数据异常"); |
| | | } |
| | | |
| | | String[] aIds = articleIds.split(","); |
| | |
| | | this.bulkUpdateInLoop("update SchArticle set deleteFlag=1 where articleId=?", aIds); |
| | | this.bulkUpdateInLoop("update SchCourseware set deleteFlag=1 where id=?", aIds); |
| | | |
| | | // 删除微商项目所有缓存 |
| | | // 删除微商项目所有缓存 |
| | | // new CacheUtils().deleteWBProjectCacheData(); |
| | | |
| | | return new Result(true, "操作功能"); |
| | | return new Result(true, "操作功能"); |
| | | } |
| | | |
| | | /** |
| | | * |
| | | * 查询基本信息 |
| | | * 查询基本信息 |
| | | * |
| | | * @param articleId |
| | | * @return |
| | |
| | | article.setCommentCount(this.findCount("from Comment where deleteFlag is false and commentObjectId = ?", |
| | | CollectionUtils.newList(articleId))); |
| | | article.setContent(content); |
| | | return new Result(true, "查询成功", article); |
| | | return new Result(true, "查询成功", article); |
| | | } |
| | | |
| | | /** |
| | | * 查询科目文章list |
| | | * 查询科目文章list |
| | | * |
| | | * @param collegeCourseId |
| | | * @return |
| | |
| | | |
| | | List<Object> args = new ArrayList<Object>(); |
| | | String hql = ""; |
| | | // 其他 |
| | | // 其他 |
| | | if (("-" + collegeCourseId).equals(subjectId)) { |
| | | hql = "select v.articleId,v.name,'','','',0,'' from SchArticle v,SchArticleReCourse r where v.collegeCourseId = ? and r.deleteFlag is false and r.articleId = v.articleId and v.deleteFlag is false and r.orgId = ? " |
| | | + "and not EXISTS (select 1 from SchSubject t where t.deleteFlag is false and t.subjectId = v.subjectId)"; |
| | |
| | | } |
| | | |
| | | /** |
| | | * 排序 |
| | | * 排序 |
| | | */ |
| | | @Override |
| | | public Result doitemOrder(List<String> ids, List<Integer> index) { |
| | | // 循环修改order |
| | | // 循环修改order |
| | | for (int i = 0; i < ids.size(); i++) { |
| | | String id = ids.get(i); |
| | | if (UserInfoWrapper.ROLE_TEACHER.equals(ClientUtils.getCurrentRole()) |
| | |
| | | new Object[] { id }); |
| | | } |
| | | |
| | | // 删除微商项目所有缓存 |
| | | // 删除微商项目所有缓存 |
| | | // new CacheUtils().deleteWBProjectCacheData(); |
| | | |
| | | return new Result(true, "修改成功"); |
| | | return new Result(true, "修改成功"); |
| | | } |
| | | |
| | | /** |
| | | * 删除机构文章信息 |
| | | * 删除机构文章信息 |
| | | * |
| | | * @param articleIds |
| | | * @param delAll |
| | |
| | | for (String articleId : articleIds) { |
| | | |
| | | if ((orgIds != null && orgIds.length != 0) || (classIds != null && classIds.length != 0)) { |
| | | // 删除需要回撤的讲义 |
| | | // 删除需要回撤的讲义 |
| | | deleteAppoint(articleId, orgIds, classIds); |
| | | } else { |
| | | // 删除讲义 |
| | | // 删除讲义 |
| | | String hql = " from SchArticleReCourse where articleId = ? and deleteFlag is false and orgId = ?"; |
| | | SchArticleReCourse shr = findUnique(hql, CollectionUtils.newList(articleId, ClientUtils.getOrgId()), |
| | | SchArticleReCourse.class); |
| | |
| | | * null){ TraceUtils.setUpdateTrace(article); article.setDeleteFlag(true); |
| | | * this.saveArticle(article); } |
| | | */ |
| | | // 用户选择同时删除下级讲义 |
| | | // 用户选择同时删除下级讲义 |
| | | if (delAll == 1) { |
| | | deleteSub(articleId, ClientUtils.getOrgId()); |
| | | } |
| | |
| | | |
| | | } |
| | | |
| | | return new Result(true, "删除成功"); |
| | | return new Result(true, "删除成功"); |
| | | } |
| | | |
| | | private Result deleteAppoint(String articleId, String orgIds[], String classIds[]) { |
| | | Map<String, Object> args = new HashMap<String, Object>(); |
| | | // 删除需要回撤的机构讲义 |
| | | // 删除需要回撤的机构讲义 |
| | | if (orgIds.length != 0) { |
| | | |
| | | String hql = " from SchArticleReCourse where articleId = :articleId and deleteFlag is false and orgId in (:orgIds) and orgId != :currOrgId"; |
| | |
| | | } |
| | | } |
| | | |
| | | // 删除需要回撤的班主任讲义 |
| | | // 删除需要回撤的班主任讲义 |
| | | if (classIds.length != 0) { |
| | | args = new HashMap<String, Object>(); |
| | | args.put("articleId", articleId); |
| | |
| | | |
| | | @SuppressWarnings("unchecked") |
| | | private void deleteSub(String articleId, String currOrgId) { |
| | | // 机构层级视频是没有重新new ,查询出机构下级ID再删关联表 |
| | | // 机构层级视频是没有重新new ,查询出机构下级ID再删关联表 |
| | | String sql = " select oa.organization_id from organization as oa,organization ob " + " where " |
| | | + " ob.ORGANIZATION_ID = ? " + " and " + " oa.org_code like CONCAT(ob.org_code,'%' ) " |
| | | + " and oa.delete_flag is false and ob.delete_flag is false " + " order by oa.level,oa.org_code asc "; |
| | |
| | | save(artCourse); |
| | | } |
| | | |
| | | // 班主任层面视频指定过后都是new 出来的,通过originVideoId 可以查出所有指定过去的视频 |
| | | // 班主任层面视频指定过后都是new 出来的,通过originVideoId 可以查出所有指定过去的视频 |
| | | hql = "select classId from ClsClass where orgId in (:orgIds) and deleteFlag is false"; |
| | | map = new HashMap<String, Object>(); |
| | | map.put("orgIds", orgIds.toArray()); |
| | |
| | | } |
| | | |
| | | /** |
| | | * 下发机构文件 |
| | | * 下发机构文件 |
| | | * |
| | | * @param articleId |
| | | * @param orgId |
| | |
| | | public Result insertAppointArticle(String[] articleIds, String[] orgIds, String[] classIds, |
| | | String collegeCourseId) { |
| | | if (null == articleIds || articleIds.length == 0) { |
| | | return new Result(false, "参数错误"); |
| | | return new Result(false, "参数错误"); |
| | | } |
| | | // 一次性查询classId对应的orgId |
| | | // 一次性查询classId对应的orgId |
| | | Map<String, Object> argsMap = new HashMap<String, Object>(); |
| | | Map<String, String> classMap = new HashMap<String, String>(); |
| | | if (classIds.length > 0) { |
| | |
| | | argsMap.put("classIds", classIds); |
| | | List<ClsClass> classList = findByComplexHql(hql, argsMap, ClsClass.class); |
| | | |
| | | // 放入map中 KEY:classId VALUE:orgId |
| | | // 放入map中 KEY:classId VALUE:orgId |
| | | |
| | | for (ClsClass orgClass : classList) { |
| | | classMap.put(orgClass.getClassId(), orgClass.getOrgId()); |
| | | } |
| | | } |
| | | |
| | | // 一次性查出handoutId对应的handoutOrder |
| | | // 一次性查出handoutId对应的handoutOrder |
| | | Map<String, Integer> orderMap = new HashMap<String, Integer>(); |
| | | String hql = " from SchArticleReCourse where articleId in (:articleIds) and deleteFlag is false and orgId = :currOrgId"; |
| | | argsMap = new HashMap<String, Object>(); |
| | |
| | | } |
| | | |
| | | for (String articleId : articleIds) { |
| | | if (orgIds.length > 0) { // 指定给机构 |
| | | if (orgIds.length > 0) { // 指定给机构 |
| | | insertAppointOrg(orgIds, articleId, collegeCourseId, orderMap); |
| | | } |
| | | if (classIds.length > 0) { // 指定给班级 |
| | | if (classIds.length > 0) { // 指定给班级 |
| | | insertAppointClass(classIds, articleId, collegeCourseId, orderMap); |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | /** |
| | | * 指定给机构 |
| | | * 指定给机构 |
| | | * |
| | | * @param orgIds |
| | | * @param handoutId |
| | |
| | | for (String orgId : orgIds) { |
| | | orgList.add(orgId); |
| | | } |
| | | // 剔除掉不符合条件的orgId |
| | | // 剔除掉不符合条件的orgId |
| | | orgList.removeAll(strings); |
| | | if (orgList.isEmpty()) { |
| | | return; |
| | |
| | | } |
| | | |
| | | /** |
| | | * 指定给班级 |
| | | * 指定给班级 |
| | | * |
| | | * @param classIds |
| | | * @param handoutId |
| | |
| | | */ |
| | | private void insertAppointClass(String classIds[], String articleId, String collegeCourseId, |
| | | Map<String, Integer> orderMap) { |
| | | // 章节id |
| | | // 章节id |
| | | Map<String, SubjectChapter> origChapterMap = new HashMap<String, SubjectChapter>(); |
| | | SchArticle article = read(SchArticle.class, articleId); |
| | | |
| | |
| | | if (classList.isEmpty()) { |
| | | return; |
| | | } |
| | | // 一次性查询班级ID对应的classSubjectId |
| | | // 一次性查询班级ID对应的classSubjectId |
| | | hql = " from SchClassSubject where classId in(:classIds) and origSubjectId = :subjectId and deleteFlag is false"; |
| | | args = new HashMap<String, Object>(); |
| | | args.put("classIds", classList.toArray()); |
| | |
| | | TraceUtils.setCreateTrace(sh); |
| | | this.saveArticle(sh); |
| | | |
| | | // 插入OrgText |
| | | // 插入OrgText |
| | | orgTextService.doInsertOrgText(sh.getArticleId(), OrgText.TABLE_NAME_ARTICLE, |
| | | oldOrgText == null ? "" : oldOrgText.getContent()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取朋友圈 |
| | | * 获取朋友圈 |
| | | * |
| | | * @param pager |
| | | * @return |
| | |
| | | } |
| | | |
| | | /** |
| | | * 获取消息的评论图片和文件 |
| | | * 获取消息的评论图片和文件 |
| | | * |
| | | * @param objSchClassCircleMsg |
| | | * @return |
| | |
| | | } |
| | | |
| | | /** |
| | | * 点赞 |
| | | * 点赞 |
| | | * |
| | | * @param commentId |
| | | * @return |
| | |
| | | } |
| | | |
| | | /** |
| | | * 评论 |
| | | * 评论 |
| | | * |
| | | * @param msgId |
| | | * @param content |
| | |
| | | */ |
| | | public Result addComment(String articleId, String content, String parentCommentId) { |
| | | |
| | | // 评论表 |
| | | // 评论表 |
| | | Comment comment = new Comment(); |
| | | comment.setCommentterId(ClientUtils.getUserId()); |
| | | comment.setCommentter(ClientUtils.getUserName()); |
| | |
| | | } |
| | | |
| | | /** |
| | | * 删除评论 |
| | | * 删除评论 |
| | | * |
| | | * @param msgId |
| | | * @param commentId |
| | |
| | | } |
| | | |
| | | /** |
| | | * 缓存获取评论 |
| | | * 缓存获取评论 |
| | | * |
| | | * @param articleId |
| | | * @param isUpdate |
| | |
| | | } |
| | | |
| | | /** |
| | | * 评论列表 |
| | | * 评论列表 |
| | | * |
| | | * @param articleId |
| | | * @return |
| | |
| | | } |
| | | |
| | | /** |
| | | * 观看进度 |
| | | * 观看进度 |
| | | * |
| | | * @param articleId |
| | | * @param compDegree |
| | |
| | | } |
| | | |
| | | /** |
| | | * 保存文章接口 |
| | | * 保存文章接口 |
| | | * |
| | | * @param article |
| | | * @return |
| | |
| | | this.bulkUpdate("update SchCourseware set name = ? where id = ?", |
| | | new Object[] { article.getName(), article.getArticleId() }); |
| | | } |
| | | // 同步课件表 |
| | | // 同步课件表 |
| | | if (courseware == null) { |
| | | courseware = new SchCourseware(); |
| | | courseware.setChapterId(article.getChapterId()); |