浏览代码

Merge remote-tracking branch 'origin/master' into test

limin 7 年之前
父节点
当前提交
0ea1d8b73f

+ 1 - 1
GeneratorConfig.xml

@@ -13,4 +13,4 @@
    <table schema="aft" tableName="jt_message_producer"/>
    <table schema="aft" tableName="jt_message_consumer"/>
   </context>
-</generatorConfiguration>
+</generatorConfiguration>

+ 7 - 2
src/main/java/com/goafanti/message/controller/AdminMessageController.java

@@ -403,12 +403,17 @@ public class AdminMessageController extends CertifyApiController{
 			messageProducer.setCreateTime(null);
 		}
 		Result res = checkMessage(messageProducer);
-		if(StringUtils.isBlank(TokenManager.getUserId())){
+		
+		if(StringUtils.isBlank(TokenManager.getUserId()) && StringUtils.isBlank(TokenManager.getAdminId())){
 			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"", "登录数据失效"));
 		}
 		if (res.getError().isEmpty()) {
 			//新增消息
-			res.setData(jtMessageProducerService.addMessage(messageProducer));
+			int err = jtMessageProducerService.addMessage(messageProducer);
+			if(err == -1){
+				res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"", "没有找到您的用户信息,不能创建消息"));
+			}
+			res.setData(err);
 		}
 		return res;
 	}

+ 10 - 1
src/main/java/com/goafanti/message/service/impl/JtMessageProducerServiceImpl.java

@@ -11,6 +11,7 @@ import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import com.goafanti.common.dao.AdminMapper;
 import com.goafanti.common.dao.JtMessageConsumerMapper;
 import com.goafanti.common.dao.JtMessageProducerMapper;
 import com.goafanti.common.dao.UserMapper;
@@ -28,6 +29,8 @@ public class JtMessageProducerServiceImpl  extends BaseMybatisDao<JtMessageProdu
 	@Autowired
 	private UserMapper userMapper;
 	@Autowired
+	private AdminMapper adminMapper;
+	@Autowired
 	private JtMessageConsumerMapper jtMessageConsumerMapper;
 	
 
@@ -36,7 +39,13 @@ public class JtMessageProducerServiceImpl  extends BaseMybatisDao<JtMessageProdu
 		//处理消息内容
 		messageProducer.setId(UUID.randomUUID().toString());
 		//获得当前登录用户名字
-		String create = userMapper.selectByPrimaryKey(TokenManager.getUserId()).getUsername();
+		String create = adminMapper.selectByPrimaryKey(TokenManager.getAdminId()).getName();
+		if(StringUtils.isBlank(create)){
+			create = userMapper.selectByPrimaryKey(TokenManager.getUserId()).getUsername();
+		}
+		if(StringUtils.isBlank(create)){
+			return -1;
+		}
 		messageProducer.setCreater(create);
 		if(null != messageProducer.getCreateTime()){
 			messageProducer.setCreateTime(new Date());