|  | @@ -1,35 +1,26 @@
 | 
	
		
			
				|  |  |  package com.ym.mec.teacher.controller;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  import com.alibaba.fastjson.JSON;
 | 
	
		
			
				|  |  | -import com.alibaba.fastjson.JSONArray;
 | 
	
		
			
				|  |  | +import com.ym.mec.auth.api.entity.SysUser;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.enums.MessageSendMode;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.page.SysMessageQueryInfo;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.service.SysMessageService;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.service.SysUserService;
 | 
	
		
			
				|  |  | +import com.ym.mec.common.controller.BaseController;
 | 
	
		
			
				|  |  | +import com.ym.mec.common.exception.BizException;
 | 
	
		
			
				|  |  | +import com.ym.mec.thirdparty.message.MessageSenderPluginContext.MessageSender;
 | 
	
		
			
				|  |  | +import com.ym.mec.util.validator.CommonValidator;
 | 
	
		
			
				|  |  |  import io.swagger.annotations.Api;
 | 
	
		
			
				|  |  |  import io.swagger.annotations.ApiOperation;
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -import java.io.IOException;
 | 
	
		
			
				|  |  | -import java.util.HashMap;
 | 
	
		
			
				|  |  | -import java.util.LinkedHashMap;
 | 
	
		
			
				|  |  | -import java.util.Map;
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |  import org.apache.commons.lang3.StringUtils;
 | 
	
		
			
				|  |  | -import org.json.JSONObject;
 | 
	
		
			
				|  |  |  import org.springframework.beans.factory.annotation.Autowired;
 | 
	
		
			
				|  |  | -import org.springframework.http.HttpStatus;
 | 
	
		
			
				|  |  |  import org.springframework.web.bind.annotation.GetMapping;
 | 
	
		
			
				|  |  |  import org.springframework.web.bind.annotation.PostMapping;
 | 
	
		
			
				|  |  |  import org.springframework.web.bind.annotation.RequestMapping;
 | 
	
		
			
				|  |  |  import org.springframework.web.bind.annotation.RestController;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -import com.ym.mec.auth.api.client.SysUserFeignService;
 | 
	
		
			
				|  |  | -import com.ym.mec.auth.api.entity.SysUser;
 | 
	
		
			
				|  |  | -import com.ym.mec.biz.dal.entity.SysMessage;
 | 
	
		
			
				|  |  | -import com.ym.mec.biz.dal.enums.MessageSendMode;
 | 
	
		
			
				|  |  | -import com.ym.mec.biz.dal.page.SysMessageQueryInfo;
 | 
	
		
			
				|  |  | -import com.ym.mec.biz.service.SysMessageService;
 | 
	
		
			
				|  |  | -import com.ym.mec.common.controller.BaseController;
 | 
	
		
			
				|  |  | -import com.ym.mec.common.exception.BizException;
 | 
	
		
			
				|  |  | -import com.ym.mec.common.page.PageInfo;
 | 
	
		
			
				|  |  | -import com.ym.mec.thirdparty.message.MessageSenderPluginContext.MessageSender;
 | 
	
		
			
				|  |  | -import com.ym.mec.util.validator.CommonValidator;
 | 
	
		
			
				|  |  | +import java.io.IOException;
 | 
	
		
			
				|  |  | +import java.util.Map;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  @RestController
 | 
	
		
			
				|  |  |  @Api(tags = "消息服务")
 | 
	
	
		
			
				|  | @@ -40,16 +31,12 @@ public class SysMessageController extends BaseController {
 | 
	
		
			
				|  |  |  	private SysMessageService sysMessageService;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  	@Autowired
 | 
	
		
			
				|  |  | -	private SysUserFeignService sysUserFeignService;
 | 
	
		
			
				|  |  | +	private SysUserService sysUserService;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  	@ApiOperation("获取所有消息列表")
 | 
	
		
			
				|  |  |  	@GetMapping(value = "list")
 | 
	
		
			
				|  |  |  	public Object list(SysMessageQueryInfo queryInfo) throws IOException {
 | 
	
		
			
				|  |  | -		SysUser sysUser = sysUserFeignService.queryUserInfo();
 | 
	
		
			
				|  |  | -		if (sysUser == null) {
 | 
	
		
			
				|  |  | -			return failed(HttpStatus.FORBIDDEN, "请登录");
 | 
	
		
			
				|  |  | -		}
 | 
	
		
			
				|  |  | -		queryInfo.setUserId(sysUser.getId());
 | 
	
		
			
				|  |  | +		queryInfo.setUserId(sysUserService.getUserId());
 | 
	
		
			
				|  |  |  		queryInfo.setType(3);
 | 
	
		
			
				|  |  |  		queryInfo.setJpushType("TEACHER");
 | 
	
		
			
				|  |  |  		return succeed(sysMessageService.queryPage(queryInfo));
 | 
	
	
		
			
				|  | @@ -68,34 +55,21 @@ public class SysMessageController extends BaseController {
 | 
	
		
			
				|  |  |  	@ApiOperation("一键已读")
 | 
	
		
			
				|  |  |  	@PostMapping("batchSetRead")
 | 
	
		
			
				|  |  |  	public Object batchSetRead() {
 | 
	
		
			
				|  |  | -		int status = 1;
 | 
	
		
			
				|  |  | -		SysUser sysUser = sysUserFeignService.queryUserInfo();
 | 
	
		
			
				|  |  | -		if (sysUser == null) {
 | 
	
		
			
				|  |  | -			return failed(HttpStatus.FORBIDDEN, "请登录");
 | 
	
		
			
				|  |  | -		}
 | 
	
		
			
				|  |  | -		return sysMessageService.updateStatus(sysUser.getId(), status,"TEACHER") > 0 ? succeed() : failed();
 | 
	
		
			
				|  |  | +		return sysMessageService.updateStatus(sysUserService.getUserId(), 1,"TEACHER") > 0 ? succeed() : failed();
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  	@ApiOperation("设置已读")
 | 
	
		
			
				|  |  |  	@PostMapping("setRead")
 | 
	
		
			
				|  |  |  	public Object setRead(Long id) {
 | 
	
		
			
				|  |  | -		int status = 1;
 | 
	
		
			
				|  |  | -		SysUser sysUser = sysUserFeignService.queryUserInfo();
 | 
	
		
			
				|  |  | -		if (sysUser == null) {
 | 
	
		
			
				|  |  | -			return failed(HttpStatus.FORBIDDEN, "请登录");
 | 
	
		
			
				|  |  | -		}
 | 
	
		
			
				|  |  | -		return sysMessageService.updateOneStatus(id, status) > 0 ? succeed() : failed();
 | 
	
		
			
				|  |  | +		return sysMessageService.updateOneStatus(id, 1) > 0 ? succeed() : failed();
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  	@ApiOperation(value = "查询用户未读消息条数")
 | 
	
		
			
				|  |  |  	@GetMapping("/queryCountOfUnread")
 | 
	
		
			
				|  |  |  	public Object queryCountOfUnread() {
 | 
	
		
			
				|  |  | -		SysUser sysUser = sysUserFeignService.queryUserInfo();
 | 
	
		
			
				|  |  | -		if (sysUser == null) {
 | 
	
		
			
				|  |  | -			return failed("请重新登录");
 | 
	
		
			
				|  |  | -		}
 | 
	
		
			
				|  |  | -		Map<String, Integer> map = sysMessageService.queryCountOfUnread(MessageSendMode.PUSH, sysUser.getId(),"TEACHER", sysUser.getTenantId());
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | +		SysUser sysUser = sysUserService.getUser();
 | 
	
		
			
				|  |  | +		Map<String, Integer> map = sysMessageService.
 | 
	
		
			
				|  |  | +				queryCountOfUnread(MessageSendMode.PUSH, sysUser.getId(),"TEACHER", sysUser.getTenantId());
 | 
	
		
			
				|  |  |  		if (map == null || map.size() == 0) {
 | 
	
		
			
				|  |  |  			return succeed();
 | 
	
		
			
				|  |  |  		}
 | 
	
	
		
			
				|  | @@ -105,17 +79,12 @@ public class SysMessageController extends BaseController {
 | 
	
		
			
				|  |  |  	@ApiOperation(value = "发送消息")
 | 
	
		
			
				|  |  |  	@PostMapping("/sendMessage")
 | 
	
		
			
				|  |  |  	public Object sendMessage(MessageSender messageSender, String content, String receiver, int readStatus, String url, String group) {
 | 
	
		
			
				|  |  | -		SysUser sysUser = sysUserFeignService.queryUserInfo();
 | 
	
		
			
				|  |  | -		if (sysUser == null) {
 | 
	
		
			
				|  |  | -			return failed(HttpStatus.FORBIDDEN, "请登录");
 | 
	
		
			
				|  |  | -		}
 | 
	
		
			
				|  |  | -		Integer userId = sysUser.getId();
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | +		SysUser sysUser = sysUserService.getUser();
 | 
	
		
			
				|  |  |  		String mobileNo = sysUser.getPhone();
 | 
	
		
			
				|  |  |  		if (StringUtils.isBlank(mobileNo) || !CommonValidator.isMobileNo(mobileNo)) {
 | 
	
		
			
				|  |  |  			throw new BizException("请输入正确的手机号");
 | 
	
		
			
				|  |  |  		}
 | 
	
		
			
				|  |  | -		sysMessageService.sendMessage(messageSender, userId, "", content, receiver, null, readStatus, url, group,"TEACHER");
 | 
	
		
			
				|  |  | +		sysMessageService.sendMessage(messageSender, sysUser.getId(), "", content, receiver, null, readStatus, url, group,"TEACHER");
 | 
	
		
			
				|  |  |  		return succeed();
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  |  }
 |