**简要描述：** 

- 接口调用说明

 **添加jar包依赖** 
- 		<dependency>
			<groupId>com.weaver</groupId>
			<artifactId>weaver-mc-api</artifactId>
		</dependency>
		


**在java代码中添加spring依赖** 

```
	@Autowired
	private AsyncSystemMessageRest systemMessageRest;
	
	各模块根据业务需要应用对应的消息中心接口
	
	
**发送消息接口demo** 

	@Autowired
	private AsyncSystemMessageRest asyncSystemMessageRest;
	
	private static final long EMPLOYEE_ID = 3905800511444409505L;
	private static final String TENANT_KEY = "ty0tu018gk";

	private static final UserEntity DEFAULT_RECIVER = new UserEntity(EMPLOYEE_ID).setTenantKey(TENANT_KEY);

	private static final Entity getEntity() {
		Entity e = new Entity();
		e.setId("1565729750462339802");
		e.setModule("task");
		e.setName("测试任务未读提醒");
//		e.setH5Url("/mobile/task/123456789");
//		e.setH5LinkeType(1);
//		e.setPcUrl("/detailspage/:targetId:/:module:");
//		e.setPcLinkeType(1);

		return e;
	}

	/**
	 * 基本消息
	 * 
	 * @returnxit
	 */
	private SendMessageEntity getBaseMsg() {
		SendMessageEntity smg = new SendMessageEntity();
//		smg.setMessageSource(MessageSource.TIMECARD_NOTIFY);
		smg.setModule(MessageModule.TASK);
		smg.setEvent(MessageEvent.NOTIFY);
		smg.setSender(UserEntity.SYSTEM_USER);
		smg.setReceivers(Collections.singletonList(DEFAULT_RECIVER));
		smg.setText("任务提醒");
		smg.setPcUrl(" 云桥pc打开事项地址");//可以为空
		smg.setAppUrl("云桥app打开事项地址");//可以为空
		smg.setTitle("云桥任务提醒标题");
		smg.setContent("云桥消息内容");
		return smg;
	}

	/**
	 * 国际化消息
	 * 
	 * @return
	 */
	private SendMessageEntity getI18nMsg() {
		SendMessageEntity smg = new SendMessageEntity();
		smg.setSender(UserEntity.SYSTEM_USER);
		smg.setReceivers(Collections.singletonList(DEFAULT_RECIVER));
		smg.setModule(MessageModule.WORK_REPORT);
		smg.setEvent(MessageEvent.NOTIFY);
		smg.setText("请记得提交2021年第9周工作报告");
		I18nEntity i18n = new I18nEntity();
		i18n.setI18nId("r12345678");  //12345678= 请记得提交%Y%年第%W%周工作报告
		Map<String, String> i18nParam = new HashMap<>();
		i18nParam.put("%Y%", "2021");
		i18nParam.put("%W%", "9");
		i18n.setI18nParams(i18nParam);
		smg.setI18n(i18n);
		smg.setPcUrl(" 云桥pc打开事项地址");//可以为空
		smg.setAppUrl("云桥app打开事项地址");//可以为空
		smg.setTitle("云桥任务提醒标题");
		smg.setContent("云桥消息内容");
		return smg;
	}

	/**
	 * 事项消息
	 * 
	 * @return
	 */
	private SendMessageEntity getEnityMsg() {
		SendMessageEntity smg = new SendMessageEntity();
		// 任务未读事项
		smg.setModule(MessageModule.TASK);
		smg.setEvent(MessageEvent.CREATE);
		smg.setSender(UserEntity.SYSTEM_USER);
		smg.setReceivers(Collections.singletonList(DEFAULT_RECIVER));
		smg.setText("你有一条任务未读事项");
		smg.setEntity(getEntity());
		smg.setPcUrl(" 云桥pc打开事项地址");//可以为空
		smg.setAppUrl("云桥app打开事项地址");//可以为空
		smg.setTitle("云桥任务提醒标题");
		smg.setContent("云桥消息内容");
		return smg;
	}

	/**
	 * 获取@ 消息
	 * 
	 * @return
	 */
	private SendMessageEntity getAtMsg() {
		SendMessageEntity smg = new SendMessageEntity();
		// 任务 @ 新反馈
		smg.setModule(MessageModule.TASK);
		smg.setEvent(MessageEvent.AT);
		smg.setSender(UserEntity.SYSTEM_USER);
		smg.setReceivers(Collections.singletonList(DEFAULT_RECIVER));
		smg.setText(":@3905800511444409505;  测试@消息:@3905800511444409505; "); // @格式 :@{id};{空格}
		AtUserEntity at = new AtUserEntity();
		at.setId("3905800511444409505");
		at.setName("陈二");
		smg.setTpl(0);// 0是现实事项反馈，1用于未读事项，完成事项
		smg.setEntity(getEntity());// 事项
		smg.setAtUsers(Collections.singletonList(at));
		smg.setPcUrl(" 云桥pc打开事项地址");//可以为空
		smg.setAppUrl("云桥app打开事项地址");//可以为空
		smg.setTitle("云桥任务提醒标题");
		smg.setContent("云桥消息内容");
		return smg;
	}

	private SendMessageEntity getApplyMsg() {
		SendMessageEntity smg = new SendMessageEntity();
		// 任务共享申请

		smg.setModule(MessageModule.TASK);
		smg.setEvent(MessageEvent.SHARE_APPLY);
		smg.setSender(UserEntity.SYSTEM_USER);
		smg.setReceivers(Collections.singletonList(DEFAULT_RECIVER));
		smg.setText("你有一条任务共享申请");
		smg.setEntity(getEntity());
		smg.setPcUrl(" 云桥pc打开事项地址");//可以为空
		smg.setAppUrl("云桥app打开事项地址");//可以为空
		smg.setTitle("云桥任务提醒标题");
		smg.setContent("云桥消息内容");
		return smg;
	}

	/**
	 * 短信消息
	 * 
	 * @returnxit
	 */
	private SendMessageEntity getSmsMsg() {
		SendMessageEntity smg = new SendMessageEntity();
		smg.setModule(MessageModule.INVOICE_CLOUD);
		smg.setEvent(MessageEvent.WARN_NOTIFY);
		smg.setSender(UserEntity.SYSTEM_USER);
		//  发送短信时的模块，事件以及模板常量参数，请找李晓龙 沟通
		Map<String, String> params = new HashMap<>();
		params.put("content", "发票云提醒短信"); //短信模板常量
		smg.setDynamicParams(params);
		smg.setReceivers(Collections
				.singletonList(new UserEntity().setPhone("18621746291").setTenantKey('xxxx').setEmployeeId(12345).setEmail("lkclkc88@sina.com").setLanguage(6)));
		Set<MessageChannelEnum> set = new HashSet<>();
		set.add(MessageChannelEnum.SMS);
		smg.setChannels(set);
		return smg;
	}

	
	@GetMapping("/sendBaseMsg")
	@ApiOperation("发送基本的文本消息")
	public WeaResult<Long> sendBaseMsg() {
		SendMessageEntity smg = getBaseMsg();
		WeaResult<Long> result = systemMessageRest.sendMsg(smg);
		return result;
	}
	
```
**demo代码**
[demo代码下载](https://im.yunteams.cn:433/config/weaver-mc-demo.zip "demo代码")
