Просмотр исходного кода

修改消息列表与消息详情

anderx лет назад: 7
Родитель
Сommit
105ef3c884

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

@@ -841,13 +841,13 @@ public class AppUserController extends CertifyApiController {
 	 * 读取消息
 	 */
 	@RequestMapping(value="/appReadMessage",method=RequestMethod.GET)
-	public Result appReadMessage(String id){
+	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.appReadMessage(id));
+		result.setData(messageService.updateAppReadMessage(id));
 		return result;
 	}
 }

+ 6 - 5
src/main/java/com/goafanti/common/mapper/MessageFromSystemMapper.xml

@@ -693,19 +693,20 @@
 				and b.resource_type = #{resourceType,jdbcType=INTEGER}
 			</if>
    </select>
-   <select id="appMessageList" resultType="com.goafanti.message.bo.MessageListBo">
-   select a.id as cid,b.title,b.create_time as createTime from jt_message_consumer a
+   <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 !=''">
-	where a.aid=#{uid,jdbcType=VARCHAR}
+	and a.aid=#{uid,jdbcType=VARCHAR}
 	</if>
+	group by a.is_read ,b.create_time desc
    <if test="page_sql!=null">
 				${page_sql}
-			</if>
+	</if>
    </select>
    <select id="appMessageCount" resultType="java.lang.Integer">
    select count(*) from jt_message_consumer a
-	left join jt_message_producer b on a.message_id=b.id
 	<if test="uid !=null and uid !=''">
 	where a.aid=#{uid,jdbcType=VARCHAR}
 	</if>

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

@@ -0,0 +1,35 @@
+package com.goafanti.message.bo;
+
+import java.util.Date;
+
+public class AppMessageBo {
+	private String id;
+	private String title;
+	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;
+	}
+	
+}

+ 4 - 2
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,8 +162,8 @@ public interface MessageService {
 	 * @return
 	 */
 	JpushEasemobAccount selectSynAccByUid(String uid);
-	 Pagination<MessageListBo> applistMessage(Integer pageNo, Integer pageSize);
-	MessageListBo appReadMessage(String id);
+	 Pagination<AppMessageBo> applistMessage(Integer pageNo, Integer pageSize);
+	 JtMessageConsumer updateAppReadMessage(String id);
 		
 	/**
 	 * 新增系统消息

+ 11 - 8
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;
@@ -32,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;
@@ -440,23 +443,23 @@ public class MessageServiceImpl  extends BaseMybatisDao<MessageFromSystemMapper>
 
 	@SuppressWarnings("unchecked")
 	@Override
-	public Pagination<MessageListBo> applistMessage(Integer pageNo, Integer pageSize) {
+	public Pagination<AppMessageBo> applistMessage(Integer pageNo, Integer pageSize) {
 		Map<String,Object> params = new HashMap<String,Object>();
-		if(null==pageNo||pageNo<0)pageNo=1;
-		if(null==pageSize||pageSize<0)pageNo=10;
+		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<MessageListBo>)findPage("appMessageList", "appMessageCount", params, pageNo, pageSize);
+		//params.put("uid", "2160baeb-8ea4-4192-a6f4-fccf8738e248");
+		return (Pagination<AppMessageBo>)findPage("appMessageList", "appMessageCount", params, pageNo, pageSize);
 	}
 
 	@Override
-	public MessageListBo appReadMessage(String id) {
+	public JtMessageConsumer updateAppReadMessage(String id) {
 		JtMessageConsumer mc=new JtMessageConsumer();
 		mc.setId(id);
 		mc.setIsRead(true);
 		jtMessageConsumerMapper.updateByPrimaryKeySelective(mc);
-		
-		return null;
+		mc=jtMessageConsumerMapper.selectByPrimaryKey(id);
+		return mc;
 	}
 
 	@Override