@EipkRequest("/s/article/man") public String articleMan(Model m) { String search_where = ""; if (SysUtil.StrToInt(m.getPar("clear")) == 0) { search_where = m.getSessionPar("search_where") != null ? (String) m.getSessionPar("search_where") : ""; } else { int search_section = SysUtil.StrToInt(m.getPar("search_section")); String search_article_title = m.getPar("search_article_title"); if (search_section != 0) { search_where += " and sectionId=" + search_section; } if (!search_article_title.equals("")) { search_where += " and title like '%" + search_article_title + "%'"; } } m.setSessionPar("search_where", search_where); String sql = ""; DB db = new DB(); sql = "select id,sectionName from t_section order by id"; List<Map<String, Object>> section_list = db.query(sql); sql = "select count(*) as num from t_article a,t_section s where a.sectionId=s.id " + search_where; int total = SysUtil.StrToInt("" + db.querySingle(sql).get("num")); int pagth = SysUtil.StrToInt(m.getPar("pagth")); int start = SysUtil.getSplitPageStartId(total, SysUtil.PAGE_SIZE, pagth); sql = "select a.id,a.pubDate,s.sectionName,a.title,a.hits from t_article a,t_section s where a.sectionId=s.id " + search_where + " order by pubDate desc limit ?,?"; List<Map<String, Object>> article_list = db.query(sql, start, SysUtil.PAGE_SIZE); db.close(); m.setAttr( "split_page_str", SysUtil.getSplitPageStr(m.getRequest(), total, SysUtil.PAGE_SIZE, pagth)); m.setAttr("section_list", section_list); m.setAttr("article_list", article_list); return ""; }
@EipkRequest("/s/article/show") public String articleShowGet(Model m) { int article_id = SysUtil.StrToInt(m.getPar("article_id")); if (article_id != 0) { DB db = new DB(); String sql = "select s.sectionName,a.pubUnit,a.pubDate,a.docId,a.title,a.content from t_article a,t_section s where a.sectionId=s.id and a.id=?"; Map<String, Object> article = db.querySingle(sql, article_id); sql = "select f.id,f.fileName,f.fileSize from t_appendix a,t_file f where a.fileId=f.id and a.articleId=? order by a.id"; List<Map<String, Object>> file_list = db.query(sql, article_id); db.close(); m.setAttr("article", article); m.setAttr("file_list", file_list); } else { m.setAttr("sectionName", ""); m.setAttr("pubUnit", ""); m.setAttr("pubDate", ""); m.setAttr("docId", ""); m.setAttr("title", ""); m.setAttr("content", ""); } m.setAttr("article_id", article_id); return ""; }
@EipkRequest("/s/article/edit") public String articleEditGet(Model m) { int article_id = SysUtil.StrToInt(m.getPar("article_id")); DB db = new DB(); String sql = "select id as section_id,sectionName from t_section order by id"; List<Map<String, Object>> section_list = db.query(sql); if (article_id > 0) { sql = "select id,pubUnit,pubDate,docId,sectionId,title,content from t_article where id=?"; Map<String, Object> article = db.querySingle(sql, article_id); m.setAttr("article", article); } else { m.setAttr("id", 0); m.setAttr("pubUnit", ""); m.setAttr("pubDate", new Date()); m.setAttr("docId", ""); m.setAttr("sectionId", 0); m.setAttr("title", ""); m.setAttr("content", ""); } db.close(); m.setAttr("section_list", section_list); return ""; }