Ver código fonte

Merge branch 'test' of ssh://git@git.jishutao.com:55555/jishutao/jitao-server.git into test

limin 7 anos atrás
pai
commit
127b5cf147

+ 26 - 5
src/main/java/com/goafanti/app/controller/AppUserController.java

@@ -28,13 +28,9 @@ import com.goafanti.common.bo.Result;
 import com.goafanti.common.constant.AFTConstants;
 import com.goafanti.common.constant.ErrorConstants;
 import com.goafanti.common.constant.PageConstants;
-import com.goafanti.common.controller.BaseApiController;
 import com.goafanti.common.controller.CertifyApiController;
-import com.goafanti.common.enums.AchievementAuditStatus;
 import com.goafanti.common.enums.AchievementFields;
 import com.goafanti.common.enums.AttachmentType;
-import com.goafanti.common.enums.DemandAuditStatus;
-import com.goafanti.common.enums.DemandDataCategory;
 import com.goafanti.common.enums.DemandFields;
 import com.goafanti.common.model.Achievement;
 import com.goafanti.common.model.Demand;
@@ -824,5 +820,30 @@ public class AppUserController extends CertifyApiController {
 			result.setData(userIdentityService.appMyInterestedExpert(type,pageNo,pageSize));
 		return result;
 	}
-	
+	/**
+	 * 消息列表
+	 */
+	@RequestMapping(value="/applistMessage",method=RequestMethod.GET)
+	public Result applistMessage(Integer pageNo,Integer pageSize){
+		Result result=new Result();
+		if(StringUtils.isBlank(TokenManager.getUserId())) {
+			result.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "", "当前用户未登陆"));
+			return result;
+		}
+		result.setData(messageService.applistMessage(pageNo,pageSize));
+		return result;
+	}
+	/**
+	 * 读取消息
+	 */
+	@RequestMapping(value="/appReadMessage",method=RequestMethod.GET)
+	public Result updateAppReadMessage(String id){
+		Result result=new Result();
+		if(StringUtils.isBlank(id)) {
+			result.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "消息ID错误"));
+			return result;
+		}
+		result.setData(messageService.updateAppReadMessage(id));
+		return result;
+	}
 }

+ 1 - 1
src/main/java/com/goafanti/common/controller/PublicController.java

@@ -564,7 +564,7 @@ public class PublicController extends BaseController {
 	@ResponseBody
 	public Result getResetMCode(String mobile, Integer type) {
 		Result res = new Result();
-		if (null == userService.selectByMobieAndType(mobile.trim(), type)) {
+		if (userService.selectByMobieAndTypeCount(mobile.trim())<1) {
 			res.getError().add(buildError(ErrorConstants.NON_REGISTER, "", "该用户未注册!"));
 			return res;
 		}

+ 4 - 0
src/main/java/com/goafanti/common/dao/JtMessageConsumerMapper.java

@@ -2,6 +2,8 @@ package com.goafanti.common.dao;
 
 import com.goafanti.common.model.JtMessageConsumer;
 import com.goafanti.common.model.JtMessageConsumerExample;
+import com.goafanti.message.bo.AppMessageBo;
+
 import java.util.List;
 import org.apache.ibatis.annotations.Param;
 
@@ -74,4 +76,6 @@ public interface JtMessageConsumerMapper {
 	 * @mbggenerated  Wed Aug 29 09:46:33 CST 2018
 	 */
 	int updateByPrimaryKey(JtMessageConsumer record);
+
+	AppMessageBo selectById(String id);
 }

+ 2 - 0
src/main/java/com/goafanti/common/dao/UserMapper.java

@@ -108,4 +108,6 @@ public interface UserMapper {
 	
 
 	List<UserPartnerDetailBo> findUserPartner();
+
+	Integer selectByMobieAndTypeCount(String mobile);
 }

+ 6 - 0
src/main/java/com/goafanti/common/mapper/JtMessageConsumerMapper.xml

@@ -292,4 +292,10 @@
      (#{mc.id,jdbcType=VARCHAR}, #{mc.aid,jdbcType=VARCHAR}, #{mc.messageId,jdbcType=VARCHAR})
     </foreach>
   </insert>
+  <select id="selectById" resultType="com.goafanti.message.bo.AppMessageBo">
+  	select a.id ,b.title,b.body,b.create_time as createTime,a.is_read as isRead from jt_message_consumer a
+	left join jt_message_producer b on a.message_id=b.id
+	where a.delete_sign=0 and b.delete_sign=0 and  b.is_draft=0 and b.is_send=1
+	and a.id=#{id,jdbcType=VARCHAR}
+  </select>
 </mapper>

+ 18 - 0
src/main/java/com/goafanti/common/mapper/MessageFromSystemMapper.xml

@@ -693,4 +693,22 @@
 				and b.resource_type = #{resourceType,jdbcType=INTEGER}
 			</if>
    </select>
+   <select id="appMessageList" resultType="com.goafanti.message.bo.AppMessageBo">
+   select a.id ,b.title,b.create_time as createTime,a.is_read as isRead from jt_message_consumer a
+	left join jt_message_producer b on a.message_id=b.id
+	where a.delete_sign=0 and b.delete_sign=0 and  b.is_draft=0 and b.is_send=1
+	<if test="uid !=null and uid !=''">
+	and a.aid=#{uid,jdbcType=VARCHAR}
+	</if>
+	order by a.is_read ,b.create_time desc 
+   <if test="page_sql!=null">
+				${page_sql}
+	</if>
+   </select>
+   <select id="appMessageCount" resultType="java.lang.Integer">
+   select count(*) from jt_message_consumer a
+	<if test="uid !=null and uid !=''">
+	where a.aid=#{uid,jdbcType=VARCHAR}
+	</if>
+   </select>
 </mapper>

+ 7 - 0
src/main/java/com/goafanti/common/mapper/UserMapper.xml

@@ -1174,4 +1174,11 @@
 		u.source =0 and i.expert=1
 		limit 0,50
 	</select>
+	
+	<select id="selectByMobieAndTypeCount" resultType="java.lang.Integer">
+    select
+  count(*)
+    from user
+    where mobile = #{0} and source = 0
+  </select>
 </mapper>

+ 42 - 0
src/main/java/com/goafanti/message/bo/AppMessageBo.java

@@ -0,0 +1,42 @@
+package com.goafanti.message.bo;
+
+import java.util.Date;
+
+public class AppMessageBo {
+	private String id;
+	private String title;
+	private String body;
+	private Date createTime;
+	private Boolean isRead ;
+	public String getId() {
+		return id;
+	}
+	public void setId(String id) {
+		this.id = id;
+	}
+	public String getTitle() {
+		return title;
+	}
+	public void setTitle(String title) {
+		this.title = title;
+	}
+	public Date getCreateTime() {
+		return createTime;
+	}
+	public void setCreateTime(Date createTime) {
+		this.createTime = createTime;
+	}
+	public Boolean getIsRead() {
+		return isRead;
+	}
+	public void setIsRead(Boolean isRead) {
+		this.isRead = isRead;
+	}
+	public String getBody() {
+		return body;
+	}
+	public void setBody(String body) {
+		this.body = body;
+	}
+	
+}

+ 7 - 0
src/main/java/com/goafanti/message/bo/MessageListBo.java

@@ -1,6 +1,7 @@
 package com.goafanti.message.bo;
 
 public class MessageListBo {
+	private String cid;
 	private String messageId;
 	private String title;
 	private String body;
@@ -78,4 +79,10 @@ public class MessageListBo {
 	public void setIsRead(String isRead) {
 		this.isRead = isRead;
 	}
+	public String getCid() {
+		return cid;
+	}
+	public void setCid(String cid) {
+		this.cid = cid;
+	}
 }

+ 5 - 1
src/main/java/com/goafanti/message/service/MessageService.java

@@ -6,11 +6,13 @@ import java.util.Map;
 
 import com.goafanti.app.bo.IndexBo;
 import com.goafanti.common.model.JpushEasemobAccount;
+import com.goafanti.common.model.JtMessageConsumer;
 import com.goafanti.common.model.JtMessageProducer;
 import com.goafanti.common.model.MessageConsumer;
 import com.goafanti.common.model.MessageFromSystem;
 import com.goafanti.common.model.MessageProducer;
 import com.goafanti.core.mybatis.page.Pagination;
+import com.goafanti.message.bo.AppMessageBo;
 import com.goafanti.message.bo.MessageBo;
 import com.goafanti.message.bo.MessageListBo;
 
@@ -160,7 +162,9 @@ public interface MessageService {
 	 * @return
 	 */
 	JpushEasemobAccount selectSynAccByUid(String uid);
-	
+	 Pagination<AppMessageBo> applistMessage(Integer pageNo, Integer pageSize);
+	 AppMessageBo updateAppReadMessage(String id);
+		
 	/**
 	 * 新增系统消息
 	 * @param messageProducer

+ 33 - 10
src/main/java/com/goafanti/message/service/impl/MessageServiceImpl.java

@@ -1,5 +1,6 @@
 package com.goafanti.message.service.impl;
 
+import java.lang.reflect.InvocationTargetException;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Date;
@@ -8,6 +9,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.UUID;
 
+import org.apache.commons.beanutils.BeanUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.shiro.SecurityUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -16,11 +18,13 @@ import org.springframework.transaction.annotation.Transactional;
 
 import com.goafanti.app.bo.IndexBo;
 import com.goafanti.common.dao.JpushEasemobAccountMapper;
+import com.goafanti.common.dao.JtMessageConsumerMapper;
 import com.goafanti.common.dao.JtMessageProducerMapper;
 import com.goafanti.common.dao.MessageFromSystemMapper;
 import com.goafanti.common.dao.MessageProducerMapper;
 import com.goafanti.common.model.Admin;
 import com.goafanti.common.model.JpushEasemobAccount;
+import com.goafanti.common.model.JtMessageConsumer;
 import com.goafanti.common.model.JtMessageProducer;
 import com.goafanti.common.model.MessageConsumer;
 import com.goafanti.common.model.MessageFromSystem;
@@ -30,6 +34,7 @@ import com.goafanti.core.mybatis.BaseMybatisDao;
 import com.goafanti.core.mybatis.page.Pagination;
 import com.goafanti.core.shiro.token.TokenManager;
 import com.goafanti.message.JGMessageHelper;
+import com.goafanti.message.bo.AppMessageBo;
 import com.goafanti.message.bo.MessageBo;
 import com.goafanti.message.bo.MessageListBo;
 import com.goafanti.message.enums.ConsumerType;
@@ -47,8 +52,11 @@ public class MessageServiceImpl  extends BaseMybatisDao<MessageFromSystemMapper>
 	private JpushEasemobAccountMapper jpushEasemobAccountMapper;
 	@Autowired
 	private JGMessageHelper jgMessageHelper;
+	
 	@Autowired
 	private JtMessageProducerMapper jtMessageProducerMapper;
+	@Autowired
+	private JtMessageConsumerMapper	jtMessageConsumerMapper;
 	@Override
 	public String selectSendUser(Map<Integer, String> selectMap,Integer type) {
 		if(selectMap.containsKey(ConsumerType.PERSON_CUSTOMER_RETAIL.getTypeCode())){ //客户散户
@@ -433,23 +441,38 @@ public class MessageServiceImpl  extends BaseMybatisDao<MessageFromSystemMapper>
 		return jpushEasemobAccountMapper.insert(jea);
 	}
 
+	@SuppressWarnings("unchecked")
+	@Override
+	public Pagination<AppMessageBo> applistMessage(Integer pageNo, Integer pageSize) {
+		Map<String,Object> params = new HashMap<String,Object>();
+		if(null==pageNo||pageNo<1)pageNo=1;
+		if(null==pageSize||pageSize<1)pageSize=10;
+		params.put("uid", TokenManager.getUserId());
+		//params.put("uid", "2160baeb-8ea4-4192-a6f4-fccf8738e248");
+		return (Pagination<AppMessageBo>)findPage("appMessageList", "appMessageCount", params, pageNo, pageSize);
+	}
+
+	@Override
+	public AppMessageBo updateAppReadMessage(String id) {
+		JtMessageConsumer mc=new JtMessageConsumer();
+		mc.setId(id);
+		mc.setIsRead(true);
+		jtMessageConsumerMapper.updateByPrimaryKeySelective(mc);
+		return jtMessageConsumerMapper.selectById(id);
+	}
+
 	@Override
 	public int addMessage(JtMessageProducer messageProducer) {
-		//处理消息内容
-		messageProducer.setId(UUID.randomUUID().toString());
-		messageProducer.setCreater(TokenManager.getUserId());
-		if(null != messageProducer.getCreateTime()){
-			messageProducer.setCreateTime(new Date());
-		}
-		return jtMessageProducerMapper.insertSelective(messageProducer);
+		// TODO Auto-generated method stub
+		return 0;
 	}
-	
+
 	@Override
 	public int sendMessage(String messageId) {
-		// 获得所有正常使用的注册用户
-		//List<JtMessageProducer> list = 
+		// TODO Auto-generated method stub
 		return 0;
 	}
 
+	
 
 }

+ 4 - 0
src/main/java/com/goafanti/user/service/UserService.java

@@ -57,6 +57,10 @@ public interface UserService {
 	UserPartnerDetailBo findUserPartnerDetail(String uid);
 	
 	List<UserPartnerDetailBo> findUserPartner();
+
+	Integer selectByMobieAndTypeCount(String trim);
+
+	
 	
 	
 }

+ 5 - 0
src/main/java/com/goafanti/user/service/impl/UserServiceImpl.java

@@ -222,6 +222,11 @@ public class UserServiceImpl extends BaseMybatisDao<UserMapper> implements UserS
 		return userMapper.findUserPartner();
 	}
 
+	@Override
+	public Integer selectByMobieAndTypeCount(String mobile ) {
+		return userMapper.selectByMobieAndTypeCount(mobile);
+	}
+