ソースを参照

Merge branch 'zx_online_0910' of http://git.dayaedu.com/yonge/cooleshow into develop-new

zouxuan 9 ヶ月 前
コミット
8fe266474d

+ 4 - 2
cooleshow-app/src/main/java/com/yonge/cooleshow/teacher/controller/ImGroupNoticeController.java

@@ -34,8 +34,9 @@ public class ImGroupNoticeController extends BaseController {
 
     @ApiOperation("新增群公告")
     @PostMapping(value = "/create")
-    public HttpResponseResult<Object> create(@Valid @RequestBody ImGroupNotice imGroupNotice, BindingResult bindingResult){
+    public HttpResponseResult<Object> create(@Valid @RequestBody ImGroupNoticeDto imGroupNotice, BindingResult bindingResult){
         ValidationKit.ignoreFields(bindingResult,"id");
+        imGroupNotice.setClientType("TEACHER");
         imGroupNoticeService.create(imGroupNotice);
         return succeed();
     }
@@ -55,7 +56,8 @@ public class ImGroupNoticeController extends BaseController {
 
     @ApiOperation("修改群公告")
     @PostMapping(value = "/update")
-    public HttpResponseResult<Object> modify(@Valid @RequestBody ImGroupNotice imGroupNotice){
+    public HttpResponseResult<Object> modify(@Valid @RequestBody ImGroupNoticeDto imGroupNotice){
+        imGroupNotice.setClientType("TEACHER");
         imGroupNoticeService.modify(imGroupNotice);
         return succeed();
     }

+ 11 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/dto/ImGroupNoticeDto.java

@@ -11,6 +11,17 @@ public class ImGroupNoticeDto extends ImGroupNotice {
     @ApiModelProperty(value = "用户头像", required = true)
     private String avatar;
 
+    @ApiModelProperty(value = "客户端类型", required = true)
+    private String clientType;
+
+    public String getClientType() {
+        return clientType;
+    }
+
+    public void setClientType(String clientType) {
+        this.clientType = clientType;
+    }
+
     public String getUsername() {
         return username;
     }

+ 2 - 2
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/ImGroupNoticeService.java

@@ -25,9 +25,9 @@ public interface ImGroupNoticeService extends IService<ImGroupNotice> {
     * @author zx
     * @date 2022/3/24 10:57
     */
-    void create(ImGroupNotice imGroupNotice);
+    void create(ImGroupNoticeDto imGroupNotice);
 
-    void modify(ImGroupNotice imGroupNotice);
+    void modify(ImGroupNoticeDto imGroupNotice);
 
     void del(Long noticeId);
 

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

@@ -16,6 +16,7 @@ import com.yonge.cooleshow.biz.dal.dto.ImGroupNoticeDto;
 import com.yonge.cooleshow.biz.dal.entity.ImGroup;
 import com.yonge.cooleshow.biz.dal.entity.ImGroupNotice;
 import com.yonge.cooleshow.biz.dal.service.ImGroupNoticeService;
+import com.yonge.cooleshow.biz.dal.service.ImGroupService;
 import com.yonge.cooleshow.biz.dal.wrapper.im.ImGroupNoticeWrapper;
 import com.yonge.toolset.base.exception.BizException;
 import com.yonge.toolset.base.page.PageInfo;
@@ -45,7 +46,7 @@ public class ImGroupNoticeServiceImpl extends ServiceImpl<ImGroupNoticeDao, ImGr
     @Resource
     private SysUserFeignService sysUserFeignService;
     @Resource
-    private ImGroupDao imGroupDao;
+    private ImGroupService imGroupService;
     @Resource
     private ImPluginContext imPluginContext;
 
@@ -56,7 +57,7 @@ public class ImGroupNoticeServiceImpl extends ServiceImpl<ImGroupNoticeDao, ImGr
 
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public void create(ImGroupNotice imGroupNotice) {
+    public void create(ImGroupNoticeDto imGroupNotice) {
         Long userId = this.checkAdmin(imGroupNotice.getGroupId());
         Date date = new Date();
         imGroupNotice.setOperatorId(userId);
@@ -77,13 +78,14 @@ public class ImGroupNoticeServiceImpl extends ServiceImpl<ImGroupNoticeDao, ImGr
         }
     }
 
-    public ImGroupNoticeWrapper.ImGroupNotice convertToImGroupNotice(ImGroupNotice imGroupNotice) {
+    public ImGroupNoticeWrapper.ImGroupNotice convertToImGroupNotice(ImGroupNoticeDto imGroupNotice) {
         ImGroupNoticeWrapper.ImGroupNotice notice = ImGroupNoticeWrapper.ImGroupNotice.builder()
                 .id(imGroupNotice.getId())
                 .groupId(imGroupNotice.getGroupId())
                 .title(imGroupNotice.getTitle())
                 .content(imGroupNotice.getContent())
                 .topFlag(imGroupNotice.getTopFlag())
+                .clientType(imGroupNotice.getClientType())
                 .sentToNewMemberFlag(imGroupNotice.getSentToNewMemberFlag())
                 .operatorId(imGroupNotice.getOperatorId())
                 .delFlag(imGroupNotice.getDelFlag())
@@ -125,7 +127,7 @@ public class ImGroupNoticeServiceImpl extends ServiceImpl<ImGroupNoticeDao, ImGr
 
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public void modify(ImGroupNotice imGroupNotice) {
+    public void modify(ImGroupNoticeDto imGroupNotice) {
         if(Objects.isNull(baseMapper.selectById(imGroupNotice.getId()))){
             throw new BizException("群公告不存在");
         }
@@ -144,7 +146,9 @@ public class ImGroupNoticeServiceImpl extends ServiceImpl<ImGroupNoticeDao, ImGr
         ImGroupNotice notice = baseMapper.selectById(imGroupNotice.getId());
         revokeImGroupNoticeMessage(notice);
         // 发送群公告消息
-        String messageSeqId = sendGroupCustomNoticeMessage(convertToImGroupNotice(notice));
+        ImGroupNoticeDto dto = JSON.parseObject(JSON.toJSONString(notice), ImGroupNoticeDto.class);
+        dto.setClientType(imGroupNotice.getClientType());
+        String messageSeqId = sendGroupCustomNoticeMessage(convertToImGroupNotice(dto));
 
         // 更新群公告消息ID
         if (StringUtils.isNotBlank(messageSeqId)) {
@@ -154,7 +158,7 @@ public class ImGroupNoticeServiceImpl extends ServiceImpl<ImGroupNoticeDao, ImGr
     }
 
     public Long checkAdmin(String groupId){
-        ImGroup imGroup = imGroupDao.selectById(groupId);
+        ImGroup imGroup = imGroupService.getById(groupId);
         if(Objects.isNull(imGroup)){
             throw new BizException("群信息不存在");
         }
@@ -192,7 +196,7 @@ public class ImGroupNoticeServiceImpl extends ServiceImpl<ImGroupNoticeDao, ImGr
         try {
             // 发送群公告消息
             messageSeqId = imPluginContext.getPluginService().sendGroupMessage(MessageWrapper.GroupMessage.builder()
-                    .senderId(notice.getOperatorId().toString())
+                    .senderId(imGroupService.getImUserId(notice.getOperatorId().toString(), notice.getClientType()))
                     .groupId(notice.getGroupId())
                     .tencentMessage(messageBody)
                     .build());