public static Mapx initDetailDialog(Mapx params) { String id = params.getString("ID"); String Type = params.getString("Type"); if (StringUtil.isEmpty(id)) { return null; } DataTable dt = new QueryBuilder("select * from ZCMessage where ID=?", id).executeDataTable(); if ((dt != null) && (dt.getRowCount() > 0)) { params.putAll(dt.getDataRow(0).toMapx()); if ("history".equals(Type)) { params.put("UserType", "收"); params.put("FromUser", ""); } else { params.put("UserType", "发"); params.put("ToUser", ""); int readFlag = Integer.parseInt(dt.getDataRow(0).getString("ReadFlag")); if (readFlag == 0) { new QueryBuilder("update ZCMessage set ReadFlag = 1 where ID=?", id).executeNoQuery(); QueryBuilder qb = new QueryBuilder( "select count(1) from ZCMessage where ReadFlag=0 and ToUser=?", User.getUserName()); CacheManager.set("Message", "Count", User.getUserName(), qb.executeInt()); } } } return params; }
public void setReadFlag() { String ids = $V("IDs"); if (!StringUtil.checkID(ids)) { this.Response.setLogInfo(0, "传入ID时发生错误"); return; } ZCMessageSet set = new ZCMessageSchema().query(new QueryBuilder("where ReadFlag=0 and id in (" + ids + ")")); QueryBuilder qb = new QueryBuilder("update ZCMessage set ReadFlag=1 where id in (" + ids + ")"); qb.executeNoQuery(); this.Response.setLogInfo(1, "标记成功"); MessageCache.removeIDs(set); qb = new QueryBuilder( "select count(1) from ZCMessage where ReadFlag=0 and ToUser=?", User.getUserName()); CacheManager.set("Message", "Count", User.getUserName(), qb.executeInt()); }
public void del() { String ids = $V("IDs"); if (!StringUtil.checkID(ids)) { this.Response.setLogInfo(0, "传入ID时发生错误"); return; } Transaction trans = new Transaction(); ZCMessageSchema message = new ZCMessageSchema(); ZCMessageSet set = message.query(new QueryBuilder("where id in (" + ids + ")")); trans.add(set, 5); if (trans.commit()) { MessageCache.removeIDs(set); QueryBuilder qb = new QueryBuilder( "select count(1) from ZCMessage where ReadFlag=0 and ToUser=?", User.getUserName()); CacheManager.set("Message", "Count", User.getUserName(), qb.executeInt()); this.Response.setLogInfo(1, "删除成功"); } else { this.Response.setLogInfo(0, "删除失败"); } }
public void updateReadFlag() { QueryBuilder qb = new QueryBuilder("update ZCMessage set ReadFlag=1 where ID=?", $V("_Param0")); qb.executeNoQuery(); String count = (String) CacheManager.get("Message", "Count", User.getUserName()); CacheManager.set("Message", "Count", User.getUserName(), Integer.parseInt(count) - 1); }