zouxuan пре 10 месеци
родитељ
комит
98e4d14b5f

+ 1 - 3
mec-application/src/main/java/com/ym/mec/web/controller/education/ImGroupNoticeController.java

@@ -34,7 +34,6 @@ public class ImGroupNoticeController extends BaseController {
     @RequestMapping("/add")
     public HttpResponseResult<Long> add(ImGroupNotice imGroupNotice ) {
         imGroupNotice.setOperatorId(sysUserService.getUserId().longValue());
-        imGroupNotice.setClientType("BACKEND");
         return succeed(imGroupNoticeService.add(imGroupNotice));
     }
 
@@ -43,7 +42,6 @@ public class ImGroupNoticeController extends BaseController {
     public HttpResponseResult<Object> update(ImGroupNotice imGroupNotice ) {
         imGroupNotice.setOperatorId(sysUserService.getUserId().longValue());
         imGroupNotice.setUpdateTime(new Date());
-        imGroupNotice.setClientType("BACKEND");
         imGroupNoticeService.modify(imGroupNotice);
         return succeed();
     }
@@ -63,7 +61,7 @@ public class ImGroupNoticeController extends BaseController {
     @ApiOperation(value = "删除")
     @RequestMapping("/del")
     public HttpResponseResult<Object> del(Long id) {
-        imGroupNoticeService.delete(id);
+        imGroupNoticeService.del(id);
         return succeed();
     }
 }

+ 2 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/ImGroupNoticeService.java

@@ -23,4 +23,6 @@ public interface ImGroupNoticeService extends BaseService<Long, ImGroupNotice> {
 	ImGroupNoticeDao getDao();
 
     Long add(ImGroupNotice imGroupNotice);
+
+	void del(Long id);
 }

+ 20 - 19
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ImGroupNoticeServiceImpl.java

@@ -1,7 +1,6 @@
 package com.ym.mec.biz.service.impl;
 
 import com.google.common.collect.Lists;
-import com.microsvc.toolkit.config.jwt.utils.JwtUserInfo;
 import com.microsvc.toolkit.middleware.im.ImPluginContext;
 import com.microsvc.toolkit.middleware.im.message.ETencentMessage;
 import com.microsvc.toolkit.middleware.im.message.MessageWrapper;
@@ -10,8 +9,6 @@ import com.microsvc.toolkit.middleware.im.properties.ImConfigProperties;
 import com.ym.mec.biz.dal.dao.ImGroupNoticeDao;
 import com.ym.mec.biz.dal.dto.ImGroupNoticeDto;
 import com.ym.mec.biz.dal.entity.ImGroupNotice;
-import com.ym.mec.biz.dal.enums.im.CK;
-import com.ym.mec.biz.dal.enums.im.EClientType;
 import com.ym.mec.biz.dal.page.ImGroupNoticeQueryInfo;
 import com.ym.mec.biz.dal.wrapper.ImGroupNoticeWrapper;
 import com.ym.mec.biz.service.ImGroupNoticeService;
@@ -22,11 +19,10 @@ import com.ym.mec.common.service.impl.BaseServiceImpl;
 import com.ym.mec.util.collection.MapUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
-import java.text.MessageFormat;
+import javax.annotation.Resource;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -36,11 +32,11 @@ import java.util.Map;
 @Slf4j
 public class ImGroupNoticeServiceImpl extends BaseServiceImpl<Long, ImGroupNotice>  implements ImGroupNoticeService {
 	
-	@Autowired
+	@Resource
 	private ImGroupNoticeDao imGroupNoticeDao;
-	@Autowired
+	@Resource
 	private ImPluginContext imPluginContext;
-	@Autowired
+	@Resource
 	private ImConfigProperties imConfig;
 
 	@Override
@@ -93,7 +89,7 @@ public class ImGroupNoticeServiceImpl extends BaseServiceImpl<Long, ImGroupNotic
 		// 更新群公告消息ID
 		if (StringUtils.isNotBlank(messageSeqId)) {
 			imGroupNotice.setMessageSeqId(messageSeqId);
-			this.getDao().update(imGroupNotice);
+			imGroupNoticeDao.update(imGroupNotice);
 		}
 	}
 
@@ -106,19 +102,30 @@ public class ImGroupNoticeServiceImpl extends BaseServiceImpl<Long, ImGroupNotic
     public Long add(ImGroupNotice imGroupNotice) {
 		if(imGroupNotice.isIsTop()){
 			//置顶取消
-			this.getDao().updateTop(imGroupNotice.getImGroupId(),false);
+			imGroupNoticeDao.updateTop(imGroupNotice.getImGroupId(),false);
 		}
-		this.insert(imGroupNotice);
+		imGroupNoticeDao.insert(imGroupNotice);
 		// 发送群公告消息
 		String messageSeqId = sendGroupCustomNoticeMessage(convertToImGroupNotice(imGroupNotice));
 		// 更新群公告消息ID
 		if (StringUtils.isNotBlank(messageSeqId)) {
 			imGroupNotice.setMessageSeqId(messageSeqId);
-			this.getDao().update(imGroupNotice);
+			imGroupNoticeDao.update(imGroupNotice);
 		}
 		return imGroupNotice.getId();
     }
 
+	@Override
+	public void del(Long id) {
+		ImGroupNotice notice = imGroupNoticeDao.get(id);
+		if (notice == null) {
+			throw new BizException("群公告不存在");
+		}
+		imGroupNoticeDao.delete(id);
+		// 撤销群公告消息
+		revokeImGroupNoticeMessage(notice);
+	}
+
 	public ImGroupNoticeWrapper.ImGroupNotice convertToImGroupNotice(ImGroupNotice imGroupNotice) {
 		ImGroupNoticeWrapper.ImGroupNotice notice = ImGroupNoticeWrapper.ImGroupNotice.builder()
 				.id(imGroupNotice.getId())
@@ -128,7 +135,6 @@ public class ImGroupNoticeServiceImpl extends BaseServiceImpl<Long, ImGroupNotic
 				.topFlag(imGroupNotice.isIsTop())
 				.sentToNewMemberFlag(true)
 				.operatorId(imGroupNotice.getOperatorId())
-				.clientType(EClientType.valueOf(imGroupNotice.getClientType()))
 				.delFlag(imGroupNotice.isDelFlag())
 				.build();
 		return notice;
@@ -162,7 +168,7 @@ public class ImGroupNoticeServiceImpl extends BaseServiceImpl<Long, ImGroupNotic
 		try {
 			// 发送群公告消息
 			messageSeqId = imPluginContext.getPluginService().sendGroupMessage(MessageWrapper.GroupMessage.builder()
-					.senderId(getImUserId(notice.getOperatorId(), notice.getClientType()))
+					.senderId(notice.getOperatorId().toString())
 					.groupId(notice.getGroupId())
 					.tencentMessage(messageBody)
 					.build());
@@ -174,11 +180,6 @@ public class ImGroupNoticeServiceImpl extends BaseServiceImpl<Long, ImGroupNotic
 		return messageSeqId;
 	}
 
-	public String getImUserId(Long userId, EClientType clientType) {
-		String imUserId;
-		imUserId = MessageFormat.format(CK.IM_USER_LONG_ID_FORMAT, imConfig.getAppPrefix(), userId.toString(),clientType.name());
-		return imUserId;
-	}
 
 	/**
 	 * 撤销群公告消息