Forráskód Böngészése

群公告置顶唯一

liujc 1 éve
szülő
commit
874354d3bf

+ 2 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/dao/ImGroupNoticeDao.java

@@ -21,5 +21,7 @@ public interface ImGroupNoticeDao extends BaseMapper<ImGroupNotice> {
     int insertBatch(@Param("entities") List<ImGroupNotice> entities);
 
     IPage<ImGroupNoticeDto> queryPage(Page<ImGroupNoticeDto> pageInfo, @Param("params") Map<String, Object> params);
+
+    void updateTopFlag(@Param("groupId") String groupId);
 }
 

+ 8 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/ImGroupNoticeServiceImpl.java

@@ -17,6 +17,7 @@ import org.springframework.stereotype.Service;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
 import java.util.Date;
@@ -72,6 +73,7 @@ public class ImGroupNoticeServiceImpl extends ServiceImpl<ImGroupNoticeDao, ImGr
     }
 
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public void modify(ImGroupNotice imGroupNotice) {
         if(Objects.isNull(baseMapper.selectById(imGroupNotice.getId()))){
             throw new BizException("群公告不存在");
@@ -81,6 +83,12 @@ public class ImGroupNoticeServiceImpl extends ServiceImpl<ImGroupNoticeDao, ImGr
         imGroupNotice.setOperatorId(userId);
         imGroupNotice.setCreateTime(date);
         imGroupNotice.setUpdateTime(date);
+
+        // 群公告置顶 只能有一个
+        if(imGroupNotice.getTopFlag() != null && Boolean.TRUE.equals(imGroupNotice.getTopFlag())){
+            baseMapper.updateTopFlag(imGroupNotice.getGroupId());
+        }
+
         baseMapper.updateById(imGroupNotice);
     }
 

+ 1 - 1
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/LiveRoomServiceImpl.java

@@ -1501,7 +1501,7 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
         imLiveRoomVideo.setStartTime(new DateTime(startTime).toDate());
         imLiveRoomVideo.setEndTime(new DateTime(event.getEndTime() * 1000L).toDate());
         imLiveRoomVideo.setUrl(event.getVideoUrl());
-        imLiveRoomVideo.setType(2);
+        imLiveRoomVideo.setType(4);
 
         // 回放记录已存在,直接忽略
         LiveRoomVideo video = liveRoomVideoService.lambdaQuery()

+ 3 - 0
cooleshow-user/user-biz/src/main/resources/config/mybatis/ImGroupNoticeMapper.xml

@@ -38,4 +38,7 @@
         WHERE gn.group_id_ = #{params.groupId}
     </select>
 
+    <update id="updateTopFlag">
+        update im_group_notice set top_flag_ = false where group_id_ = #{groupId}
+    </update>
 </mapper>