Commit 2b8996d1 authored by 刘可心's avatar 刘可心

选中的消息标记为已读

parent d3226cf6
...@@ -117,7 +117,7 @@ public class MessageController extends Controller { ...@@ -117,7 +117,7 @@ public class MessageController extends Controller {
} }
/** /**
* LiuKexin 20210402 批量标记为已读,且将通知性消息标为已读,下载或跳转的消息不批量已读 * LiuKexin 20210402 全部标记为已读
*/ */
public void allMsgReaded() { public void allMsgReaded() {
String username = this.getAttr("username"); String username = this.getAttr("username");
...@@ -125,4 +125,17 @@ public class MessageController extends Controller { ...@@ -125,4 +125,17 @@ public class MessageController extends Controller {
renderJson(allMsgReaded); renderJson(allMsgReaded);
} }
/**
* LiuKexin 20210409 选中的消息标记为已读
*/
public void handleReadedByIds() {
String ids = this.getPara("ids");
if (ids.length() == 0) {
this.allMsgReaded();
return;
}
Ret handleReadedByIds = messageService.handleReadedByIds(ids.split(","));
renderJson(handleReadedByIds);
}
} }
package com.archser.aserver.service; package com.archser.aserver.service;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import javax.enterprise.inject.New;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import com.archser.aserver.model.Message; import com.archser.aserver.model.Message;
...@@ -196,6 +199,32 @@ public class MessageService { ...@@ -196,6 +199,32 @@ public class MessageService {
} }
} }
/**
* LiuKexin 20210409 选中的消息标记为已读
* @param ids 选中的消息
* @return
*/
public Ret handleReadedByIds(String[] ids) {
try {
List<Record> findMessageByIds = Db.find(Db.getSqlPara("message.getMessageByIds", Kv.by("ids", ids)));
List<Record> updateReadMessage = new ArrayList<Record>();
for (Record message : findMessageByIds) {
if(!"Y".equals(message.getStr("read"))) {
message.set("read", "Y");
updateReadMessage.add(message);
}
}
if(updateReadMessage.size() == 0) {
return Ret.ok("msg", "已将选中的消息标记为已读");
}
Db.batchUpdate("AS_MESSAGE", updateReadMessage, updateReadMessage.size());
return Ret.ok("msg", "已将选中的消息标记为已读");
} catch (Exception e) {
logger.error("标记为已读出错", e);
return Ret.fail("msg", "批量标为已读失败");
}
}
} }
...@@ -55,6 +55,14 @@ ...@@ -55,6 +55,14 @@
#end #end
) )
#end #end
#sql("getMessageByIds")
select * from as_message
where id in (
#for(item : ids)
#(for.index==0 ? "" : ",") #(item)
#end
)
#end
#sql("getCountByRead") #sql("getCountByRead")
select count(t.id) as count select count(t.id) as count
from as_message t from as_message t
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment