Exemple #1
0
  /**
   * 修改直播课
   *
   * @param activityId
   * @param currUser
   * @param live
   * @return
   */
  public Live update(String liveId, User currUser, Live live, String image, String group)
      throws XueWenServiceException {
    Live liveResult = liveRepo.findOne(liveId);
    if (liveResult == null) {
      throw new XueWenServiceException(Config.STATUS_201, Config.MSG_NODATA_201, null);
    }
    if (!StringUtil.isBlank(image)) { // 如果图片不为空
      List<Images> imageList = JSON2ObjUtil.getDTOList(image, Images.class);
      liveResult.setImages(imageList);
    }
    // 去掉的群组
    List<JSONObject> removeGroup = new ArrayList<JSONObject>(); // 去掉的群组列表
    List<JSONObject> addGroup = new ArrayList<JSONObject>(); // 新增的群组列表

    if (!StringUtil.isBlank(group)) { // 如果分享的群不为空
      List<JSONObject> groupList = JSON2ObjUtil.getDTOList(group, JSONObject.class);
      List<JSONObject> oldGroupList = liveResult.getGroup(); // 原有的群组列表

      addGroup.addAll(groupList); // 修改后的群组列表
      addGroup.removeAll(oldGroupList); // 新增的群组
      removeGroup.addAll(oldGroupList); // 以前有的群组列表
      removeGroup.removeAll(groupList); // 删除的群组列表

      liveResult.setGroup(groupList);
    }
    if (!StringUtil.isBlank(live.getIntro())) {
      liveResult.setIntro(live.getIntro());
    }
    if (!StringUtil.isBlank(live.getTitle())) {
      liveResult.setTitle(live.getTitle());
    }
    if (live.getLiveEndTime() != 0) {
      liveResult.setLiveEndTime(live.getLiveEndTime());
    }
    if (live.getLiveStartTime() != 0) {
      liveResult.setLiveStartTime(live.getLiveStartTime());
    }
    live = liveRepo.save(liveResult);
    /** 新增的群组添加动态 */
    for (JSONObject obj : addGroup) {
      try {
        // 创建群组动态
        this.createGroupDynamic(liveResult, obj.getString("groupId"));
      } catch (Exception e) {
        l.error("======创建活动群组动态失败:========" + e);
      }
    }
    // 删除去掉的群组动态
    for (JSONObject obj : removeGroup) {
      try {
        // 创建群组动态
        this.deleteByGroupIdAndSourceId(obj.getString("groupId"), liveResult.getId());
      } catch (Exception e) {
        l.error("======创建活动群组动态失败:========" + e);
      }
    }
    return live;
  }
Exemple #2
0
  /**
   * 分享直播
   *
   * @param liveId
   * @param group
   * @param currUser
   * @return
   * @throws XueWenServiceException
   */
  public boolean share(String liveId, String source, User currUser) throws XueWenServiceException {
    Live liveResult = liveRepo.findOne(liveId);
    if (liveResult == null) {
      throw new XueWenServiceException(Config.STATUS_201, Config.MSG_NODATA_201, null);
    }
    List<JSONObject> newAddGroups = new ArrayList<JSONObject>();
    if (!StringUtil.isBlank(source)) {
      List<JSONObject> groupList = JSON2ObjUtil.getDTOList(source, JSONObject.class);
      newAddGroups.addAll(groupList);
      List<JSONObject> oldGroup = liveResult.getGroup();
      // 取新增的群组
      newAddGroups.removeAll(oldGroup);
      liveResult.getGroup().addAll(newAddGroups);
    }

    liveRepo.save(liveResult);
    for (JSONObject obj : newAddGroups) {
      try {
        // 创建群组动态
        this.createGroupDynamic(liveResult, obj.getString("groupId"));
      } catch (Exception e) {
        l.error("======创建活动群组动态失败:========" + e);
      }
    }
    return true;
  }