').after('
').closest(".ace-spinner").spinner(c).wrapInner("
");a(this).on("mousewheel DOMMouseScroll",function(k){var l=k.originalEvent.detail<0||k.originalEvent.wheelDelta>0?1:-1;j.spinner("step",l>0);j.spinner("triggerChangedEvent");return false});var h=a(this);j.on("changed",function(){h.trigger("change")})});return this}})(window.jQuery);(function(a,b){a.fn.ace_wizard=function(c){this.each(function(){var h=a(this);var d=h.find("li");var e=d.length;var f=parseFloat((100/e).toFixed(1))+"%";d.css({"min-width":f,"max-width":f});h.show().wizard();var g=h.siblings(".wizard-actions").eq(0);var i=h.data("wizard");i.$prevBtn.remove();i.$nextBtn.remove();i.$prevBtn=g.find(".btn-prev").eq(0).on(ace.click_event,function(){h.wizard("previous")}).attr("disabled","disabled");i.$nextBtn=g.find(".btn-next").eq(0).on(ace.click_event,function(){h.wizard("next")}).removeAttr("disabled");i.nextText=i.$nextBtn.text()});return this}})(window.jQuery);(function(a,b){a.fn.ace_colorpicker=function(c){var d=a.extend({pull_right:false,caret:true},c);this.each(function(){var g=a(this);var e="";var f="";a(this).hide().find("option").each(function(){var h="colorpick-btn";if(this.selected){h+=" selected";f=this.value}e+='
'}).end().on("change.ace_inner_call",function(){a(this).next().find(".btn-colorpicker").css("background-color",this.value)}).after('
").next().find(".dropdown-menu").on(ace.click_event,function(j){var h=a(j.target);if(!h.is(".colorpick-btn")){return false}h.closest("ul").find(".selected").removeClass("selected");h.addClass("selected");var i=h.data("color");g.val(i).change();j.preventDefault();return true})});return this}})(window.jQuery);(function(a,b){a.fn.ace_tree=function(d){var c={"open-icon":"icon-folder-open","close-icon":"icon-folder-close",selectable:true,"selected-icon":"icon-ok","unselected-icon":"tree-dot"};c=a.extend({},c,d);this.each(function(){var e=a(this);e.html('
'+(c["unselected-icon"]==null?"":'
')+'
');e.addClass(c.selectable==true?"tree-selectable":"tree-unselectable");e.tree(c)});return this}})(window.jQuery);(function(a,b){a.fn.ace_wysiwyg=function(c,h){var d=a.extend({speech_button:true,wysiwyg:{}},c);var e=["#ac725e","#d06b64","#f83a22","#fa573c","#ff7537","#ffad46","#42d692","#16a765","#7bd148","#b3dc6c","#fbe983","#fad165","#92e1c0","#9fe1e7","#9fc6e7","#4986e7","#9a9cff","#b99aff","#c2c2c2","#cabdbf","#cca6ac","#f691b2","#cd74e6","#a47ae2","#444444"];var g={font:{values:["Arial","Courier","Comic Sans MS","Helvetica","Open Sans","Tahoma","Verdana"],icon:"icon-font",title:"Font"},fontSize:{values:{5:"Huge",3:"Normal",1:"Small"},icon:"icon-text-height",title:"Font Size"},bold:{icon:"icon-bold",title:"Bold (Ctrl/Cmd+B)"},italic:{icon:"icon-italic",title:"Italic (Ctrl/Cmd+I)"},strikethrough:{icon:"icon-strikethrough",title:"Strikethrough"},underline:{icon:"icon-underline",title:"Underline"},insertunorderedlist:{icon:"icon-list-ul",title:"Bullet list"},insertorderedlist:{icon:"icon-list-ol",title:"Number list"},outdent:{icon:"icon-indent-left",title:"Reduce indent (Shift+Tab)"},indent:{icon:"icon-indent-right",title:"Indent (Tab)"},justifyleft:{icon:"icon-align-left",title:"Align Left (Ctrl/Cmd+L)"},justifycenter:{icon:"icon-align-center",title:"Center (Ctrl/Cmd+E)"},justifyright:{icon:"icon-align-right",title:"Align Right (Ctrl/Cmd+R)"},justifyfull:{icon:"icon-align-justify",title:"Justify (Ctrl/Cmd+J)"},createLink:{icon:"icon-link",title:"Hyperlink",button_text:"Add",placeholder:"URL"},unlink:{icon:"icon-unlink",title:"Remove Hyperlink"},insertImage:{icon:"icon-picture",title:"Insert picture",button_text:'
Choose Image …',placeholder:"Image URL"},foreColor:{values:e,title:"Change Color"},backColor:{values:e,title:"Change Background Color"},undo:{icon:"icon-undo",title:"Undo (Ctrl/Cmd+Z)"},redo:{icon:"icon-repeat",title:"Redo (Ctrl/Cmd+Y)"}};var f=d.toolbar||["font",null,"fontSize",null,"bold","italic","strikethrough","underline",null,"insertunorderedlist","insertorderedlist","outdent","indent",null,"justifyleft","justifycenter","justifyright","justifyfull",null,"createLink","unlink",null,"insertImage",null,"foreColor",null,"undo","redo"];this.each(function(){var q='
";if(d.toolbar_place){q=d.toolbar_place.call(this,q)}else{q=a(this).before(q).prev()}q.find("a[title]").tooltip({animation:false});q.find(".dropdown-menu input:not([type=file])").on(ace.click_event,function(){return false}).on("change",function(){a(this).closest(".dropdown-menu").siblings(".dropdown-toggle").dropdown("toggle")}).on("keydown",function(s){if(s.which==27){this.value="";a(this).change()}});q.find("input[type=file]").prev().on(ace.click_event,function(s){a(this).next().click()});q.find(".wysiwyg_colorpicker").each(function(){a(this).ace_colorpicker({pull_right:true,caret:false}).change(function(){a(this).nextAll("input").eq(0).val(this.value).change()}).next().find(".btn-colorpicker").tooltip({title:this.title,animation:false})});var k;if(d.speech_button&&"onwebkitspeechchange" in (k=document.createElement("input"))){var i=a(this).offset();q.append(k);a(k).attr({type:"text","data-edit":"inserttext","x-webkit-speech":""}).addClass("wysiwyg-speech-input").css({position:"absolute"}).offset({top:i.top,left:i.left+a(this).innerWidth()-35})}else{k=null}var n=a.extend({},{activeToolbarClass:"active",toolbarSelector:q},d.wysiwyg||{});a(this).wysiwyg(n)});return this}})(window.jQuery);
--------------------------------------------------------------------------------
/WebContent/assets/js/ace.min.js:
--------------------------------------------------------------------------------
1 | jQuery(function(){handle_side_menu();enable_search_ahead();general_things();widget_boxes()});function handle_side_menu(){$("#menu-toggler").on(ace.click_event,function(){$("#sidebar").toggleClass("display");$(this).toggleClass("display");return false});var b=$("#sidebar").hasClass("menu-min");$("#sidebar-collapse").on(ace.click_event,function(){$("#sidebar").toggleClass("menu-min");$(this).find('[class*="icon-"]:eq(0)').toggleClass("icon-double-angle-right");b=$("#sidebar").hasClass("menu-min");if(b){$(".open > .submenu").removeClass("open")}});var a="ontouchend" in document;$(".nav-list").on(ace.click_event,function(g){var f=$(g.target).closest("a");if(!f||f.length==0){return}if(!f.hasClass("dropdown-toggle")){if(b&&ace.click_event=="tap"&&f.get(0).parentNode.parentNode==this){var h=f.find(".menu-text").get(0);if(g.target!=h&&!$.contains(h,g.target)){return false}}return}var d=f.next().get(0);if(!$(d).is(":visible")){var c=$(d.parentNode).closest("ul");if(b&&c.hasClass("nav-list")){return}c.find("> .open > .submenu").each(function(){if(this!=d&&!$(this.parentNode).hasClass("active")){$(this).slideUp(200).parent().removeClass("open")}})}else{}if(b&&$(d.parentNode.parentNode).hasClass("nav-list")){return false}$(d).slideToggle(200).parent().toggleClass("open");return false})}function enable_search_ahead(){$("#nav-search-input").typeahead({source:["Alabama","Alaska","Arizona","Arkansas","California","Colorado","Connecticut","Delaware","Florida","Georgia","Hawaii","Idaho","Illinois","Indiana","Iowa","Kansas","Kentucky","Louisiana","Maine","Maryland","Massachusetts","Michigan","Minnesota","Mississippi","Missouri","Montana","Nebraska","Nevada","New Hampshire","New Jersey","New Mexico","New York","North Dakota","North Carolina","Ohio","Oklahoma","Oregon","Pennsylvania","Rhode Island","South Carolina","South Dakota","Tennessee","Texas","Utah","Vermont","Virginia","Washington","West Virginia","Wisconsin","Wyoming"],updater:function(a){$("#nav-search-input").focus();return a}})}function general_things(){$('.ace-nav [class*="icon-animated-"]').closest("a").on("click",function(){var b=$(this).find('[class*="icon-animated-"]').eq(0);var a=b.attr("class").match(/icon\-animated\-([\d\w]+)/);b.removeClass(a[0]);$(this).off("click")});$(".nav-list .badge[title],.nav-list .label[title]").tooltip({placement:"right"});$("#ace-settings-btn").on(ace.click_event,function(){$(this).toggleClass("open");$("#ace-settings-box").toggleClass("open")});$("#ace-settings-header").removeAttr("checked").on("click",function(){if(!this.checked){if($("#ace-settings-sidebar").get(0).checked){$("#ace-settings-sidebar").click()}}$(".navbar").toggleClass("navbar-fixed-top");$(document.body).toggleClass("navbar-fixed")});$("#ace-settings-sidebar").removeAttr("checked").on("click",function(){if(this.checked){if(!$("#ace-settings-header").get(0).checked){$("#ace-settings-header").click()}}else{if($("#ace-settings-breadcrumbs").get(0).checked){$("#ace-settings-breadcrumbs").click()}}$("#sidebar").toggleClass("fixed")});$("#ace-settings-breadcrumbs").removeAttr("checked").on("click",function(){if(this.checked){if(!$("#ace-settings-sidebar").get(0).checked){$("#ace-settings-sidebar").click()}}$("#breadcrumbs").toggleClass("fixed");$(document.body).toggleClass("breadcrumbs-fixed")});$("#ace-settings-rtl").removeAttr("checked").on("click",function(){switch_direction()});$("#btn-scroll-up").on(ace.click_event,function(){var a=Math.max(100,parseInt($("html").scrollTop()/3));$("html,body").animate({scrollTop:0},a);return false});$("#skin-colorpicker").ace_colorpicker().on("change",function(){var b=$(this).find("option:selected").data("class");var a=$(document.body);a.removeClass("skin-1 skin-2 skin-3");if(b!="default"){a.addClass(b)}if(b=="skin-1"){$(".ace-nav > li.grey").addClass("dark")}else{$(".ace-nav > li.grey").removeClass("dark")}if(b=="skin-2"){$(".ace-nav > li").addClass("no-border margin-1");$(".ace-nav > li:not(:last-child)").addClass("light-pink").find('> a > [class*="icon-"]').addClass("pink").end().eq(0).find(".badge").addClass("badge-warning")}else{$(".ace-nav > li").removeClass("no-border margin-1");$(".ace-nav > li:not(:last-child)").removeClass("light-pink").find('> a > [class*="icon-"]').removeClass("pink").end().eq(0).find(".badge").removeClass("badge-warning")}if(b=="skin-3"){$(".ace-nav > li.grey").addClass("red").find(".badge").addClass("badge-yellow")}else{$(".ace-nav > li.grey").removeClass("red").find(".badge").removeClass("badge-yellow")}})}function widget_boxes(){$(".page-content").delegate(".widget-toolbar > [data-action]","click",function(k){k.preventDefault();var j=$(this);var l=j.data("action");var a=j.closest(".widget-box");if(a.hasClass("ui-sortable-helper")){return}if(l=="collapse"){var d=a.find(".widget-body");var i=j.find("[class*=icon-]").eq(0);var e=i.attr("class").match(/icon\-(.*)\-(up|down)/);var b="icon-"+e[1]+"-down";var f="icon-"+e[1]+"-up";var h=d.find(".widget-body-inner");if(h.length==0){d=d.wrapInner('
').find(":first-child").eq(0)}else{d=h.eq(0)}var c=300;var g=200;if(a.hasClass("collapsed")){if(i){i.addClass(f).removeClass(b)}a.removeClass("collapsed");d.slideUp(0,function(){d.slideDown(c)})}else{if(i){i.addClass(b).removeClass(f)}d.slideUp(g,function(){a.addClass("collapsed")})}}else{if(l=="close"){var n=parseInt(j.data("close-speed"))||300;a.hide(n,function(){a.remove()})}else{if(l=="reload"){j.blur();var m=false;if(a.css("position")=="static"){m=true;a.addClass("position-relative")}a.append('
');setTimeout(function(){a.find(".widget-box-layer").remove();if(m){a.removeClass("position-relative")}},parseInt(Math.random()*1000+1000))}else{if(l=="settings"){}}}}})}function switch_direction(){var c=$(document.body);c.toggleClass("rtl").find(".dropdown-menu:not(.datepicker-dropdown,.colorpicker)").toggleClass("pull-right").end().find('.pull-right:not(.dropdown-menu,blockquote,.dropdown-submenu,.profile-skills .pull-right,.control-group .controls > [class*="span"]:first-child)').removeClass("pull-right").addClass("tmp-rtl-pull-right").end().find(".pull-left:not(.dropdown-submenu,.profile-skills .pull-left)").removeClass("pull-left").addClass("pull-right").end().find(".tmp-rtl-pull-right").removeClass("tmp-rtl-pull-right").addClass("pull-left").end().find(".chzn-container").toggleClass("chzn-rtl").end().find('.control-group .controls > [class*="span"]:first-child').toggleClass("pull-right").end();function a(g,f){c.find("."+g).removeClass(g).addClass("tmp-rtl-"+g).end().find("."+f).removeClass(f).addClass(g).end().find(".tmp-rtl-"+g).removeClass("tmp-rtl-"+g).addClass(f)}function b(g,f,h){h.each(function(){var j=$(this);var i=j.css(f);j.css(f,j.css(g));j.css(g,i)})}a("align-left","align-right");a("arrowed","arrowed-right");a("arrowed-in","arrowed-in-right");var d=$("#piechart-placeholder");if(d.size()>0){var e=$(document.body).hasClass("rtl")?"nw":"ne";d.data("draw").call(d.get(0),d,d.data("chart"),e)}};
--------------------------------------------------------------------------------
/WebContent/assets/js/jquery.mobile.custom.min.js:
--------------------------------------------------------------------------------
1 | /*! jQuery Mobile v1.3.1 | Copyright 2010, 2013 jQuery Foundation, Inc. | jquery.org/license */
2 |
3 | (function(e,t,n){typeof define=="function"&&define.amd?define(["jquery"],function(r){return n(r,e,t),r.mobile}):n(e.jQuery,e,t)})(this,document,function(e,t,n,r){(function(e,t,n,r){function x(e){while(e&&typeof e.originalEvent!="undefined")e=e.originalEvent;return e}function T(t,n){var i=t.type,s,o,a,l,c,h,p,d,v;t=e.Event(t),t.type=n,s=t.originalEvent,o=e.event.props,i.search(/^(mouse|click)/)>-1&&(o=f);if(s)for(p=o.length,l;p;)l=o[--p],t[l]=s[l];i.search(/mouse(down|up)|click/)>-1&&!t.which&&(t.which=1);if(i.search(/^touch/)!==-1){a=x(s),i=a.touches,c=a.changedTouches,h=i&&i.length?i[0]:c&&c.length?c[0]:r;if(h)for(d=0,v=u.length;d
i||Math.abs(n.pageY-p)>i,d&&!r&&D("vmousecancel",t,s),D("vmousemove",t,s),M()}function F(e){if(g)return;L();var t=N(e.target),n;D("vmouseup",e,t);if(!d){var r=D("vclick",e,t);r&&r.isDefaultPrevented()&&(n=x(e).changedTouches[0],v.push({touchID:E,x:n.clientX,y:n.clientY}),m=!0)}D("vmouseout",e,t),d=!1,M()}function I(t){var n=e.data(t,i),r;if(n)for(r in n)if(n[r])return!0;return!1}function q(){}function R(t){var n=t.substr(1);return{setup:function(r,s){I(this)||e.data(this,i,{});var o=e.data(this,i);o[t]=!0,l[t]=(l[t]||0)+1,l[t]===1&&b.bind(n,P),e(this).bind(n,q),y&&(l.touchstart=(l.touchstart||0)+1,l.touchstart===1&&b.bind("touchstart",H).bind("touchend",F).bind("touchmove",j).bind("scroll",B))},teardown:function(r,s){--l[t],l[t]||b.unbind(n,P),y&&(--l.touchstart,l.touchstart||b.unbind("touchstart",H).unbind("touchmove",j).unbind("touchend",F).unbind("scroll",B));var o=e(this),u=e.data(this,i);u&&(u[t]=!1),o.unbind(n,q),I(this)||o.removeData(i)}}}var i="virtualMouseBindings",s="virtualTouchID",o="vmouseover vmousedown vmousemove vmouseup vclick vmouseout vmousecancel".split(" "),u="clientX clientY pageX pageY screenX screenY".split(" "),a=e.event.mouseHooks?e.event.mouseHooks.props:[],f=e.event.props.concat(a),l={},c=0,h=0,p=0,d=!1,v=[],m=!1,g=!1,y="addEventListener"in n,b=e(n),w=1,E=0,S;e.vmouse={moveDistanceThreshold:10,clickDistanceThreshold:10,resetTimerDuration:1500};for(var U=0;Ue.event.special.swipe.horizontalDistanceThreshold&&Math.abs(t.coords[1]-n.coords[1])n.coords[0]?"swipeleft":"swiperight")},setup:function(){var t=this,n=e(t);n.bind(u,function(t){function o(t){if(!i)return;s=e.event.special.swipe.stop(t),Math.abs(i.coords[0]-s.coords[0])>e.event.special.swipe.scrollSupressionThreshold&&t.preventDefault()}var i=e.event.special.swipe.start(t),s;n.bind(f,o).one(a,function(){n.unbind(f,o),i&&s&&e.event.special.swipe.handleSwipe(i,s),i=s=r})})}},e.each({scrollstop:"scrollstart",taphold:"tap",swipeleft:"swipe",swiperight:"swipe"},function(t,n){e.event.special[t]={setup:function(){e(this).bind(n,e.noop)}}})}(e,this),function(e,t,r){var i={};e.mobile=e.extend(e.mobile,{version:"1.3.1",ns:"",subPageUrlKey:"ui-page",activePageClass:"ui-page-active",activeBtnClass:"ui-btn-active",focusClass:"ui-focus",ajaxEnabled:!0,hashListeningEnabled:!0,linkBindingEnabled:!0,defaultPageTransition:"fade",maxTransitionWidth:!1,minScrollBack:250,touchOverflowEnabled:!1,defaultDialogTransition:"pop",pageLoadErrorMessage:"Error Loading Page",pageLoadErrorMessageTheme:"e",phonegapNavigationEnabled:!1,autoInitializePage:!0,pushStateEnabled:!0,ignoreContentEnabled:!1,orientationChangeEnabled:!0,buttonMarkup:{hoverDelay:200},window:e(t),document:e(n),keyCode:{ALT:18,BACKSPACE:8,CAPS_LOCK:20,COMMA:188,COMMAND:91,COMMAND_LEFT:91,COMMAND_RIGHT:93,CONTROL:17,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,INSERT:45,LEFT:37,MENU:93,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SHIFT:16,SPACE:32,TAB:9,UP:38,WINDOWS:91},behaviors:{},silentScroll:function(n){e.type(n)!=="number"&&(n=e.mobile.defaultHomeScroll),e.event.special.scrollstart.enabled=!1,setTimeout(function(){t.scrollTo(0,n),e.mobile.document.trigger("silentscroll",{x:0,y:n})},20),setTimeout(function(){e.event.special.scrollstart.enabled=!0},150)},nsNormalizeDict:i,nsNormalize:function(t){if(!t)return;return i[t]||(i[t]=e.camelCase(e.mobile.ns+t))},getInheritedTheme:function(e,t){var n=e[0],r="",i=/ui-(bar|body|overlay)-([a-z])\b/,s,o;while(n){s=n.className||"";if(s&&(o=i.exec(s))&&(r=o[2]))break;n=n.parentNode}return r||t||"a"},closestPageData:function(e){return e.closest(':jqmData(role="page"), :jqmData(role="dialog")').data("mobile-page")},enhanceable:function(e){return this.haveParents(e,"enhance")},hijackable:function(e){return this.haveParents(e,"ajax")},haveParents:function(t,n){if(!e.mobile.ignoreContentEnabled)return t;var r=t.length,i=e(),s,o,u;for(var a=0;a").text(e(this).text()).html()},e.fn.jqmEnhanceable=function(){return e.mobile.enhanceable(this)},e.fn.jqmHijackable=function(){return e.mobile.hijackable(this)};var s=e.find,o=/:jqmData\(([^)]*)\)/g;e.find=function(t,n,r,i){return t=t.replace(o,"[data-"+(e.mobile.ns||"")+"$1]"),s.call(this,t,n,r,i)},e.extend(e.find,s),e.find.matches=function(t,n){return e.find(t,null,null,n)},e.find.matchesSelector=function(t,n){return e.find(n,null,null,[t]).length>0}}(e,this)});
--------------------------------------------------------------------------------
/app_aixuexiao.sql:
--------------------------------------------------------------------------------
1 | --
2 | -- 表的结构 `class`
3 | --
4 | CREATE TABLE IF NOT EXISTS `class` (
5 | `id` smallint(5) unsigned NOT NULL COMMENT '班级编号,302表示三年级二班',
6 | `name` char(16) NOT NULL COMMENT '班级名称,三年级二班',
7 | `headteacher` char(8) NOT NULL COMMENT '班主任姓名',
8 | `studentcount` tinyint(4) NOT NULL COMMENT '学生数量',
9 | PRIMARY KEY (`id`)
10 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
11 |
12 | --
13 | -- 转存表中的数据 `class`
14 | --
15 | INSERT INTO `class` (`id`, `name`, `headteacher`, `studentcount`) VALUES
16 | (302, '三年级二班', '赖导', 7),
17 | (301, '三年级一班', '曾近荣', 7);
18 |
19 | -- --------------------------------------------------------
20 |
21 | --
22 | -- 表的结构 `class_news`
23 | --
24 | CREATE TABLE IF NOT EXISTS `class_news` (
25 | `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '公告编号',
26 | `classid` int(10) unsigned NOT NULL COMMENT '考试班级',
27 | `content` varchar(128) NOT NULL,
28 | `inserttime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
29 | PRIMARY KEY (`id`),
30 | KEY `index_class_news` (`classid`,`inserttime`)
31 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ;
32 | --
33 | -- 转存表中的数据 `class_news`
34 | --
35 |
36 | INSERT INTO `class_news` (`id`, `classid`, `content`, `inserttime`) VALUES
37 | (1, 302, '大家好,三年级二班将于本周六举行家长会,届时请各位学生家长准时到达开会,谢谢!', '2013-08-21 10:42:04'),
38 | (2, 301, '各位学生家长注意了,最近有不少同学出现逃学的情况,还号称“逃学威龙”。', '2013-08-21 10:48:20');
39 |
40 | -- --------------------------------------------------------
41 |
42 | --
43 | -- 表的结构 `exam`
44 | --
45 |
46 | CREATE TABLE IF NOT EXISTS `exam` (
47 | `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '考试编号',
48 | `classid` int(10) unsigned NOT NULL COMMENT '考试班级',
49 | `course` char(8) NOT NULL COMMENT '科目',
50 | `examtime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '考试时间',
51 | `fullmarks` decimal(4,1) NOT NULL COMMENT '满分',
52 | `average` decimal(4,1) DEFAULT NULL COMMENT '平均分',
53 | `topmark` decimal(4,1) DEFAULT NULL COMMENT '最高分',
54 | `lowestmark` decimal(4,1) DEFAULT NULL COMMENT '最低分',
55 | `remark` varchar(32) NOT NULL COMMENT '考试说明',
56 | PRIMARY KEY (`id`),
57 | KEY `index_exams` (`id`),
58 | KEY `index_classes` (`classid`,`course`)
59 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ;
60 |
61 | --
62 | -- 转存表中的数据 `exam`
63 | --
64 |
65 | INSERT INTO `exam` (`id`, `classid`, `course`, `examtime`, `fullmarks`, `average`, `topmark`, `lowestmark`, `remark`) VALUES
66 | (1, 301, '英语', '2013-08-21 10:56:07', 100.0, 84.1, 100.0, 59.0, '精诚中学三年级二班下学期英语单元测验'),
67 | (2, 302, '数学', '2013-08-22 11:02:20', 100.0, 88.3, 100.0, 78.0, '数学单元测验');
68 |
69 | -- --------------------------------------------------------
70 |
71 | --
72 | -- 表的结构 `exam_mark`
73 | --
74 |
75 | CREATE TABLE IF NOT EXISTS `exam_mark` (
76 | `classid` int(10) unsigned NOT NULL COMMENT '考试班级',
77 | `studentid` int(10) unsigned NOT NULL COMMENT '学生编号',
78 | `studentname` char(8) NOT NULL COMMENT '学生姓名',
79 | `examid` int(10) unsigned NOT NULL COMMENT '考试编号',
80 | `mark` decimal(4,1) NOT NULL COMMENT '分数',
81 | `examtime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '考试时间',
82 | `rank` tinyint(4) DEFAULT NULL COMMENT '班级排名',
83 | `remark` varchar(32) DEFAULT NULL COMMENT '备注',
84 | PRIMARY KEY (`classid`,`studentid`,`examid`),
85 | KEY `index_exam_mark` (`classid`,`studentid`,`studentname`,`examid`,`mark`)
86 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
87 |
88 | --
89 | -- 转存表中的数据 `exam_mark`
90 | --
91 |
92 | INSERT INTO `exam_mark` (`classid`, `studentid`, `studentname`, `examid`, `mark`, `examtime`, `rank`, `remark`) VALUES
93 | (301, 3011, '周星星', 1, 59.0, '2013-08-21 10:56:07', 7, '逃课就是这个下场'),
94 | (301, 3013, '大飞', 1, 60.0, '2013-08-21 10:56:07', 6, '这次给你及格了'),
95 | (301, 3014, '黄小龟', 1, 84.0, '2013-08-21 10:56:07', 5, '好好学习天天向上'),
96 | (301, 3017, '林大岳', 1, 91.0, '2013-08-21 10:56:07', 4, '继续努力'),
97 | (301, 3012, '曹达华', 1, 97.0, '2013-08-21 10:56:07', 3, '不错,有进步'),
98 | (301, 3016, '汤朱迪', 1, 98.0, '2013-08-21 10:56:07', 2, '这次发挥有点小失常哟'),
99 | (301, 3015, '仙蒂', 1, 100.0, '2013-08-21 10:56:07', 1, '满分不错,值得表扬'),
100 | (302, 3027, '许博淳', 2, 78.0, '2013-08-22 11:02:20', 7, '要加油了'),
101 | (302, 3022, '柯景腾', 2, 80.0, '2013-08-22 11:02:20', 6, '上课认真听讲'),
102 | (302, 3024, '谢明和', 2, 87.0, '2013-08-22 11:02:20', 5, '好好学习天天向上'),
103 | (302, 3026, '胡家玮', 2, 88.0, '2013-08-22 11:02:20', 4, '继续努力'),
104 | (302, 3023, '曹国胜', 2, 90.0, '2013-08-22 11:02:20', 3, '有进步'),
105 | (302, 3025, '廖英宏', 2, 95.0, '2013-08-22 11:02:20', 2, '非常好'),
106 | (302, 3021, '沈佳宜', 2, 100.0, '2013-08-22 11:02:20', 1, '非常不错,好好保持');
107 |
108 | -- --------------------------------------------------------
109 |
110 | --
111 | -- 表的结构 `message`
112 | --
113 |
114 | CREATE TABLE IF NOT EXISTS `message` (
115 | `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
116 | `tousername` char(32) NOT NULL,
117 | `fromusername` char(32) NOT NULL,
118 | `msgtype` enum('TEXT','IMAGE','LOCATION','LINK','EVENT') NOT NULL,
119 | `createtime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
120 | `msgId` char(64) NOT NULL,
121 | `content` varchar(128) DEFAULT NULL,
122 | `picurl` varchar(128) DEFAULT NULL,
123 | `title` varchar(32) DEFAULT NULL,
124 | `description` varchar(128) DEFAULT NULL,
125 | `url` varchar(128) DEFAULT NULL,
126 | `locationx` char(10) DEFAULT NULL,
127 | `locationy` char(10) DEFAULT NULL,
128 | `scale` char(8) DEFAULT NULL,
129 | `label` varchar(32) DEFAULT NULL,
130 | `event` varchar(16) DEFAULT NULL,
131 | `eventkey` varchar(16) DEFAULT NULL,
132 | PRIMARY KEY (`id`),
133 | KEY `index_user` (`msgtype`,`tousername`,`fromusername`,`createtime`)
134 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
135 |
136 |
137 | -- --------------------------------------------------------
138 |
139 | --
140 | -- 表的结构 `reply`
141 | --
142 |
143 | CREATE TABLE IF NOT EXISTS `reply` (
144 | `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
145 | `tousername` char(32) NOT NULL,
146 | `fromusername` char(32) NOT NULL,
147 | `msgtype` enum('TEXT','MUSIC','NEWS') NOT NULL,
148 | `createtime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
149 | `content` varchar(512) NOT NULL COMMENT '回复消息内容',
150 | `musicurl` varchar(128) DEFAULT NULL,
151 | `hqmusicurl` varchar(128) DEFAULT NULL,
152 | `articlecount` tinyint(4) DEFAULT NULL,
153 | PRIMARY KEY (`id`),
154 | KEY `index_user` (`msgtype`,`tousername`,`fromusername`,`createtime`)
155 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
156 |
157 | --
158 | -- 表的结构 `reply_article`
159 | --
160 | CREATE TABLE IF NOT EXISTS `reply_article` (
161 | `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
162 | `replyid` int(10) unsigned NOT NULL,
163 | `title` varchar(32) NOT NULL,
164 | `description` varchar(64) NOT NULL,
165 | `picurl` varchar(128) NOT NULL,
166 | `url` varchar(128) NOT NULL,
167 | PRIMARY KEY (`id`),
168 | KEY `index_replyid` (`replyid`)
169 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=5 ;
170 |
171 |
172 |
173 | --
174 | -- 表的结构 `student`
175 | --
176 | CREATE TABLE IF NOT EXISTS `student` (
177 | `id` int(10) unsigned NOT NULL COMMENT '学生学号,通常为班级编号加上序号,如3021',
178 | `classid` int(10) unsigned NOT NULL COMMENT '所属班级编号',
179 | `name` char(8) NOT NULL COMMENT '学生姓名',
180 | `remark` varchar(32) DEFAULT NULL,
181 | PRIMARY KEY (`id`),
182 | KEY `index_classes` (`classid`,`name`)
183 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
184 |
185 | --
186 | -- 转存表中的数据 `student`
187 | --
188 | INSERT INTO `student` (`id`, `classid`, `name`, `remark`) VALUES
189 | (3021, 302, '沈佳宜', '佳宜(女主角)'),
190 | (3022, 302, '柯景腾', '柯腾(男主角)'),
191 | (3023, 302, '曹国胜', '老曹(柯腾的挚友)'),
192 | (3024, 302, '谢明和', '阿和(柯腾的挚友)'),
193 | (3025, 302, '廖英宏', '该边(柯腾的挚友)'),
194 | (3026, 302, '胡家玮', '弯弯(沈佳宜的好友)'),
195 | (3027, 302, '许博淳', '勃起(柯腾的挚友)'),
196 | (3011, 301, '周星星', '周星驰'),
197 | (3012, 301, '曹达华', '吴孟达'),
198 | (3013, 301, '大飞', '张耀扬'),
199 | (3014, 301, '黄小龟', '黄一山'),
200 | (3015, 301, '仙蒂', '朱茵'),
201 | (3016, 301, '汤朱迪', '梅艳芳'),
202 | (3017, 301, '林大岳', '黄秋生');
203 |
204 | -- --------------------------------------------------------
205 |
206 | --
207 | -- 表的结构 `student_message`
208 | --
209 | CREATE TABLE IF NOT EXISTS `student_message` (
210 | `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '消息编号',
211 | `studentid` int(10) unsigned NOT NULL COMMENT '学生编号',
212 | `inserttime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
213 | `content` varchar(128) NOT NULL,
214 | PRIMARY KEY (`id`),
215 | KEY `index_student_message` (`studentid`,`inserttime`)
216 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ;
217 |
218 | --
219 | -- 转存表中的数据 `student_message`
220 | --
221 |
222 | INSERT INTO `student_message` (`id`, `studentid`, `inserttime`, `content`) VALUES
223 | (1, 3011, '2013-08-21 11:09:44', '不准逃课'),
224 | (2, 3021, '2013-08-22 10:56:15', '好好学习天天向上哈');
225 |
--------------------------------------------------------------------------------
/src/com/aixuexiao/dao/BaseDao.java:
--------------------------------------------------------------------------------
1 | package com.aixuexiao.dao;
2 |
3 | import javax.annotation.Resource;
4 |
5 | import org.mybatis.spring.SqlSessionTemplate;
6 |
7 | public class BaseDao {
8 |
9 | @Resource(name="readSqlSession")
10 | public SqlSessionTemplate readSqlSession;
11 |
12 | @Resource(name="writerSqlSession")
13 | public SqlSessionTemplate writerSqlSession;
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/src/com/aixuexiao/dao/ClassesDao.java:
--------------------------------------------------------------------------------
1 | package com.aixuexiao.dao;
2 |
3 | import java.util.HashMap;
4 | import java.util.List;
5 | import java.util.Map;
6 |
7 | import org.springframework.stereotype.Component;
8 |
9 | import com.aixuexiao.model.Classes;
10 |
11 | @Component("classesDao")
12 | public class ClassesDao extends BaseDao {
13 |
14 |
15 | public List findAllClasses() {
16 | return this.readSqlSession.selectList("com.aixuexiao.dao.ClassesDao.selectAllClasses");
17 | }
18 |
19 | public List findClasses(int start,int size,Classes classes) {
20 | Map map = new HashMap();
21 | map.put("start", start);
22 | map.put("size", size);
23 | map.put("classes", classes);
24 | return this.readSqlSession.selectList("com.aixuexiao.dao.ClassesDao.selectClasses",map);
25 | }
26 |
27 | public void addClasses(Classes classes){
28 | writerSqlSession.insert("com.aixuexiao.dao.ClassesDao.addClasses", classes);
29 | }
30 |
31 | public Classes findClassesById(int id){
32 | return readSqlSession.selectOne("com.aixuexiao.dao.ClassesDao.selectClassesById", id);
33 | }
34 |
35 | public void updateClassStudentCount(int classid){
36 | writerSqlSession.update("com.aixuexiao.dao.ClassesDao.updateClassStudentCount", classid);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/com/aixuexiao/dao/ClassesNewsDao.java:
--------------------------------------------------------------------------------
1 | package com.aixuexiao.dao;
2 |
3 | import java.util.HashMap;
4 | import java.util.List;
5 | import java.util.Map;
6 |
7 | import org.springframework.stereotype.Component;
8 |
9 | import com.aixuexiao.model.Classes;
10 | import com.aixuexiao.model.ClassesNews;
11 |
12 | @Component("classesNewsDao")
13 | public class ClassesNewsDao extends BaseDao {
14 |
15 |
16 | public List findClassesNewsByClassId(int classid,int limit) {
17 | Map map = new HashMap();
18 | map.put("classid", classid);
19 | map.put("limit", limit);
20 | return this.readSqlSession.selectList("com.aixuexiao.dao.ClassesNewsDao.selectClassesNewsByClassId",map);
21 | }
22 |
23 |
24 | public void addClassesNews(ClassesNews classesNews){
25 | writerSqlSession.insert("com.aixuexiao.dao.ClassesNewsDao.addClassesNews", classesNews);
26 | }
27 |
28 | public void deleteClassesNewsById(int id){
29 | writerSqlSession.delete("com.aixuexiao.dao.ClassesNewsDao.deleteClassesNewsById", id);
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/src/com/aixuexiao/dao/ExamDao.java:
--------------------------------------------------------------------------------
1 | package com.aixuexiao.dao;
2 |
3 | import java.util.HashMap;
4 | import java.util.List;
5 | import java.util.Map;
6 |
7 | import org.springframework.stereotype.Component;
8 |
9 | import com.aixuexiao.model.Classes;
10 | import com.aixuexiao.model.Exam;
11 | import com.aixuexiao.model.ExamMark;
12 |
13 | @Component("examDao")
14 | public class ExamDao extends BaseDao {
15 |
16 |
17 | public List findExamMarkByStudentId(int studentid,int limit) {
18 | Map map = new HashMap();
19 | map.put("studentid", studentid);
20 | map.put("limit", limit);
21 | return this.readSqlSession.selectList("com.aixuexiao.dao.ExamDao.selectExamMarkByStudentId",map);
22 | }
23 |
24 | public List findExam(int start,int size,Exam exam){
25 | Map map = new HashMap();
26 | map.put("start", start);
27 | map.put("size", size);
28 | map.put("exam", exam);
29 | return this.readSqlSession.selectList("com.aixuexiao.dao.ExamDao.selectExam",map);
30 | }
31 |
32 | public void addExam(Exam exam){
33 | writerSqlSession.insert("com.aixuexiao.dao.ExamDao.addExam", exam);
34 | }
35 |
36 | public void addExamMark(ExamMark examMark){
37 | writerSqlSession.insert("com.aixuexiao.dao.ExamDao.addExamMark", examMark);
38 | }
39 |
40 | public Exam findExamById(int id){
41 | return this.readSqlSession.selectOne("com.aixuexiao.dao.ExamDao.selectExamById",id);
42 | }
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/src/com/aixuexiao/dao/MessageDao.java:
--------------------------------------------------------------------------------
1 | package com.aixuexiao.dao;
2 |
3 | import java.util.HashMap;
4 | import java.util.List;
5 | import java.util.Map;
6 |
7 | import org.springframework.stereotype.Component;
8 |
9 | import com.aixuexiao.model.Message;
10 |
11 | @Component("messageDao")
12 | public class MessageDao extends BaseDao {
13 |
14 | public int addMessage(Message message) {
15 | return this.writerSqlSession.insert("com.aixuexiao.dao.MessageDao.addMessage", message);
16 | }
17 |
18 | public List findMessage(int start,int size) {
19 | Map map = new HashMap();
20 | map.put("start", start);
21 | map.put("size", size);
22 | return this.readSqlSession.selectList("com.aixuexiao.dao.MessageDao.selectMessage",map);
23 | }
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/src/com/aixuexiao/dao/ReplyDao.java:
--------------------------------------------------------------------------------
1 | package com.aixuexiao.dao;
2 |
3 | import java.util.HashMap;
4 | import java.util.List;
5 | import java.util.Map;
6 |
7 | import org.springframework.stereotype.Component;
8 |
9 | import com.aixuexiao.model.Article;
10 | import com.aixuexiao.model.Reply;
11 |
12 | @Component("replyDao")
13 | public class ReplyDao extends BaseDao {
14 |
15 | public void addReply(Reply reply) {
16 | this.writerSqlSession.insert("com.aixuexiao.dao.ReplyDao.addReply", reply);
17 | }
18 |
19 | public void addArticle(Article article){
20 | this.writerSqlSession.insert("com.aixuexiao.dao.ReplyDao.addArticle", article);
21 | }
22 |
23 | public List findReply(int start,int size) {
24 | Map map = new HashMap();
25 | map.put("start", start);
26 | map.put("size", size);
27 | return this.readSqlSession.selectList("com.aixuexiao.dao.ReplyDao.selectReply",map);
28 | }
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/src/com/aixuexiao/dao/StudentDao.java:
--------------------------------------------------------------------------------
1 | package com.aixuexiao.dao;
2 |
3 | import java.util.HashMap;
4 | import java.util.List;
5 | import java.util.Map;
6 |
7 | import org.springframework.stereotype.Component;
8 |
9 | import com.aixuexiao.model.Student;
10 |
11 | @Component("studentDao")
12 | public class StudentDao extends BaseDao {
13 |
14 |
15 | public Student findStudentById(int id) {
16 | return this.readSqlSession.selectOne("com.aixuexiao.dao.StudentDao.selectStudentById",id);
17 | }
18 |
19 | public List findStudent(int start,int size,Student student) {
20 | Map map = new HashMap();
21 | map.put("start", start);
22 | map.put("size", size);
23 | map.put("student", student);
24 | return this.readSqlSession.selectList("com.aixuexiao.dao.StudentDao.selectStudent",map);
25 | }
26 |
27 | public List findStudentByClassesId(int classesid) {
28 | return this.readSqlSession.selectList("com.aixuexiao.dao.StudentDao.selectStudentByClassesId",classesid);
29 | }
30 |
31 | public int addStudent(Student student) {
32 | return this.writerSqlSession.insert("com.aixuexiao.dao.StudentDao.addStudent", student);
33 | }
34 |
35 | public int deleteStudentById(int studentid) {
36 | return this.writerSqlSession.delete("com.aixuexiao.dao.StudentDao.deleteStudentById", studentid);
37 | }
38 |
39 | public int updateStudent(Student student) {
40 | return this.writerSqlSession.update("com.aixuexiao.dao.StudentDao.updateStudent", student);
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/com/aixuexiao/dao/StudentMessageDao.java:
--------------------------------------------------------------------------------
1 | package com.aixuexiao.dao;
2 |
3 | import java.util.HashMap;
4 | import java.util.List;
5 | import java.util.Map;
6 |
7 | import org.springframework.stereotype.Component;
8 |
9 | import com.aixuexiao.model.Message;
10 | import com.aixuexiao.model.StudentMessage;
11 |
12 | @Component("studentMessageDao")
13 | public class StudentMessageDao extends BaseDao {
14 |
15 |
16 | public List findStudentMessageByStudentId(int studentid,int limit) {
17 | Map map = new HashMap();
18 | map.put("studentid", studentid);
19 | map.put("limit", limit);
20 | return this.readSqlSession.selectList("com.aixuexiao.dao.StudentMessageDao.selectStudentMessageByStudentId",map);
21 | }
22 |
23 | public int addStudentMessage(StudentMessage studentMessage) {
24 | return this.writerSqlSession.insert("com.aixuexiao.dao.StudentMessageDao.addStudentMessage", studentMessage);
25 | }
26 |
27 | public int deleteStudentMessageById(int id) {
28 | return this.writerSqlSession.delete("com.aixuexiao.dao.StudentMessageDao.deleteStudentMessageById", id);
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/src/com/aixuexiao/dao/sqlmap/ClassesMapper.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
11 |
12 |
17 |
18 |
19 | update class set studentcount = (select count(id) from student where classid = #{id})
20 | where id = #{id}
21 |
22 |
23 |
24 |
35 |
36 |
37 | insert into class (id,name,headteacher,studentcount)
38 | values(#{id},#{name},#{headteacher},#{studentcount})
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/src/com/aixuexiao/dao/sqlmap/ClassesNewsMapper.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
14 |
15 |
16 | insert into class_news (classid,content,inserttime )
17 | values(#{classid},#{content},#{inserttime})
18 |
19 |
20 |
21 | delete from class_news where id = #{id}
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/src/com/aixuexiao/dao/sqlmap/ExamMapper.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
17 |
18 |
23 |
24 |
31 |
32 |
37 |
38 |
39 |
40 | SELECT LAST_INSERT_ID() AS id
41 |
42 | insert into exam (classid,course,examtime,fullmarks,average,topmark,lowestmark,remark)
43 | values(#{classid},#{course},#{examtime},#{fullmarks},#{average},#{topmark},#{lowestmark},#{remark})
44 |
45 |
46 |
47 | insert into exam_mark (examid,classid,studentid,studentname,examtime,mark,rank,remark)
48 | values(#{examid},#{classid},#{studentid},#{studentname},#{examtime},#{mark},#{rank},#{remark})
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
--------------------------------------------------------------------------------
/src/com/aixuexiao/dao/sqlmap/MessageMapper.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | insert into message (tousername,fromusername,msgtype,createtime,msgid,content,picurl,title,description,url,locationx,locationy,scale,label,event,eventkey)
8 | values(#{toUserName},#{fromUserName},#{msgType},#{createTime},#{msgId},#{content},#{picUrl},#{title},#{description},#{url},#{locationX},#{locationY},#{scale},#{label},#{event},#{eventKey})
9 |
10 |
11 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/src/com/aixuexiao/dao/sqlmap/ReplyMapper.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | SELECT LAST_INSERT_ID() AS id
9 |
10 | insert into reply(tousername,fromusername,msgtype,createtime,content,musicurl,hqmusicurl,articlecount)
11 | values (#{toUserName},#{fromUserName},#{msgType},#{createTime},#{content},#{musicUrl},#{hQMusicUrl},#{articleCount})
12 |
13 |
14 |
15 | INSERT INTO reply_article (replyid,title,description,picurl,url )
16 | VALUES(#{replyId},#{title},#{description},#{picUrl},#{url})
17 |
18 |
19 |
25 |
26 |
31 |
32 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
--------------------------------------------------------------------------------
/src/com/aixuexiao/dao/sqlmap/StudentMapper.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
11 |
12 |
17 |
18 |
28 |
29 |
30 | update student
31 | set classid=#{classid},name=#{name},remark=#{remark}
32 | where id = #{id}
33 |
34 |
35 |
36 | insert into student (id,classid,name,remark )
37 | values(#{id},#{classid},#{name},#{remark})
38 |
39 |
40 |
41 | delete from student where id = #{id}
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/src/com/aixuexiao/dao/sqlmap/StudentMessageMapper.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
14 |
15 |
16 | insert into student_message (studentid,content,inserttime )
17 | values(#{studentid},#{content},#{inserttime})
18 |
19 |
20 |
21 | delete from student_message where id = #{id}
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/src/com/aixuexiao/model/Article.java:
--------------------------------------------------------------------------------
1 | package com.aixuexiao.model;
2 |
3 | import com.thoughtworks.xstream.annotations.XStreamAlias;
4 | import com.thoughtworks.xstream.annotations.XStreamOmitField;
5 |
6 | /**
7 | * 图文消息
8 | * @author lizy
9 | */
10 | public class Article {
11 |
12 | @XStreamOmitField
13 | private int id;//数据库存储的id
14 |
15 | // 图文消息名称
16 | @XStreamAlias("Title")
17 | private String title;
18 | // 图文消息描述
19 | @XStreamAlias("Description")
20 | private String description;
21 | // 图片链接,支持JPG、PNG格式,较好的效果为大图640*320,小图80*80,限制图片链接的域名需要与开发者填写的基本资料中的Url一致
22 | @XStreamAlias("PicUrl")
23 | private String picUrl;
24 | // 点击图文消息跳转链接
25 | @XStreamAlias("Url")
26 | private String url;
27 |
28 | @XStreamOmitField
29 | private int replyId;
30 |
31 | private Reply reply;
32 |
33 | public Article() {}
34 |
35 | public Article(String title, String description, String picUrl, String url) {
36 | this.title = title;
37 | this.description = description;
38 | this.picUrl = picUrl;
39 | this.url = url;
40 | }
41 |
42 |
43 |
44 | public int getId() {
45 | return id;
46 | }
47 |
48 | public void setId(int id) {
49 | this.id = id;
50 | }
51 |
52 | public String getTitle() {
53 | return title;
54 | }
55 | public void setTitle(String title) {
56 | this.title = title;
57 | }
58 | public String getDescription() {
59 | return description;
60 | }
61 | public void setDescription(String description) {
62 | this.description = description;
63 | }
64 | public String getPicUrl() {
65 | return picUrl;
66 | }
67 | public void setPicUrl(String picUrl) {
68 | this.picUrl = picUrl;
69 | }
70 | public String getUrl() {
71 | return url;
72 | }
73 | public void setUrl(String url) {
74 | this.url = url;
75 | }
76 |
77 | public int getReplyId() {
78 | return replyId;
79 | }
80 |
81 | public void setReplyId(int replyId) {
82 | this.replyId = replyId;
83 | }
84 |
85 | public Reply getReply() {
86 | return reply;
87 | }
88 |
89 | public void setReply(Reply reply) {
90 | this.reply = reply;
91 | }
92 |
93 |
94 |
95 | }
96 |
--------------------------------------------------------------------------------
/src/com/aixuexiao/model/Classes.java:
--------------------------------------------------------------------------------
1 | package com.aixuexiao.model;
2 |
3 | import java.io.Serializable;
4 |
5 | /**
6 | * 班级实体
7 | */
8 | public class Classes implements Serializable {
9 |
10 | /**
11 | * 班级编号
12 | */
13 | private int id;
14 |
15 | /**
16 | * 班级名称 如: 三年级二班
17 | */
18 | private String name;
19 |
20 | /**
21 | * 班主任
22 | */
23 | private String headteacher;
24 |
25 | /**
26 | * 学生数量
27 | */
28 | private int studentcount;
29 |
30 |
31 |
32 | public int getId() {
33 | return id;
34 | }
35 |
36 | public void setId(int id) {
37 | this.id = id;
38 | }
39 |
40 | public String getName() {
41 | return name;
42 | }
43 |
44 | public void setName(String name) {
45 | this.name = name;
46 | }
47 |
48 | public String getHeadteacher() {
49 | return headteacher;
50 | }
51 |
52 | public void setHeadteacher(String headteacher) {
53 | this.headteacher = headteacher;
54 | }
55 |
56 | public int getStudentcount() {
57 | return studentcount;
58 | }
59 |
60 | public void setStudentcount(int studentcount) {
61 | this.studentcount = studentcount;
62 | }
63 |
64 |
65 | }
66 |
--------------------------------------------------------------------------------
/src/com/aixuexiao/model/ClassesNews.java:
--------------------------------------------------------------------------------
1 | package com.aixuexiao.model;
2 |
3 | import java.io.Serializable;
4 | import java.util.Date;
5 |
6 | /**
7 | * 班级动态
8 | */
9 | public class ClassesNews implements Serializable {
10 |
11 | /**
12 | * 公告编号
13 | */
14 | private int id;
15 |
16 | /**
17 | * 班级编号
18 | */
19 | private int classid;
20 |
21 | /**
22 | * 公告内容
23 | */
24 | private String content;
25 |
26 | /**
27 | * 发布时间
28 | */
29 | private Date inserttime;
30 |
31 | public int getId() {
32 | return id;
33 | }
34 |
35 | public void setId(int id) {
36 | this.id = id;
37 | }
38 |
39 | public int getClassid() {
40 | return classid;
41 | }
42 |
43 | public void setClassid(int classid) {
44 | this.classid = classid;
45 | }
46 |
47 |
48 | public String getContent() {
49 | return content;
50 | }
51 |
52 | public void setContent(String content) {
53 | this.content = content;
54 | }
55 |
56 | public Date getInserttime() {
57 | return inserttime;
58 | }
59 |
60 | public void setInserttime(Date inserttime) {
61 | this.inserttime = inserttime;
62 | }
63 |
64 |
65 | }
66 |
--------------------------------------------------------------------------------
/src/com/aixuexiao/model/Exam.java:
--------------------------------------------------------------------------------
1 | package com.aixuexiao.model;
2 |
3 | import java.io.Serializable;
4 | import java.math.BigDecimal;
5 | import java.util.Date;
6 | import java.util.List;
7 |
8 | /**
9 | * 考试实体
10 | */
11 | public class Exam implements Serializable {
12 |
13 | /**
14 | * 考试编号
15 | */
16 | private int id;
17 |
18 | /**
19 | * 班级编号
20 | */
21 | private int classid;
22 |
23 | /**
24 | * 考试科目
25 | */
26 | private String course;
27 |
28 | /**
29 | * 考试时间
30 | */
31 | private Date examtime;
32 |
33 | /**
34 | * 考试满分
35 | */
36 | private BigDecimal fullmarks;
37 |
38 | /**
39 | * 平均分
40 | */
41 | private BigDecimal average;
42 |
43 | /**
44 | * 最高分
45 | */
46 | private BigDecimal topmark;
47 |
48 | /**
49 | * 最低分
50 | */
51 | private BigDecimal lowestmark;
52 |
53 | /**
54 | * 考试备注
55 | */
56 | private String remark;
57 |
58 | /**
59 | * 考试的成绩列表
60 | */
61 | private List examMarks;
62 |
63 | public int getId() {
64 | return id;
65 | }
66 |
67 | public void setId(int id) {
68 | this.id = id;
69 | }
70 |
71 | public int getClassid() {
72 | return classid;
73 | }
74 |
75 | public void setClassid(int classid) {
76 | this.classid = classid;
77 | }
78 |
79 | public String getCourse() {
80 | return course;
81 | }
82 |
83 | public void setCourse(String course) {
84 | this.course = course;
85 | }
86 |
87 | public Date getExamtime() {
88 | return examtime;
89 | }
90 |
91 | public void setExamtime(Date examtime) {
92 | this.examtime = examtime;
93 | }
94 |
95 |
96 | public BigDecimal getFullmarks() {
97 | return fullmarks;
98 | }
99 |
100 | public void setFullmarks(BigDecimal fullmarks) {
101 | this.fullmarks = fullmarks;
102 | }
103 |
104 | public BigDecimal getAverage() {
105 | return average;
106 | }
107 |
108 | public void setAverage(BigDecimal average) {
109 | this.average = average;
110 | }
111 |
112 | public BigDecimal getTopmark() {
113 | return topmark;
114 | }
115 |
116 | public void setTopmark(BigDecimal topmark) {
117 | this.topmark = topmark;
118 | }
119 |
120 | public BigDecimal getLowestmark() {
121 | return lowestmark;
122 | }
123 |
124 | public void setLowestmark(BigDecimal lowestmark) {
125 | this.lowestmark = lowestmark;
126 | }
127 |
128 | public String getRemark() {
129 | return remark;
130 | }
131 |
132 | public void setRemark(String remark) {
133 | this.remark = remark;
134 | }
135 |
136 | public List getExamMarks() {
137 | return examMarks;
138 | }
139 |
140 | public void setExamMarks(List examMarks) {
141 | this.examMarks = examMarks;
142 | }
143 |
144 | }
145 |
--------------------------------------------------------------------------------
/src/com/aixuexiao/model/ExamMark.java:
--------------------------------------------------------------------------------
1 | package com.aixuexiao.model;
2 |
3 | import java.io.Serializable;
4 | import java.math.BigDecimal;
5 | import java.util.Date;
6 |
7 | /**
8 | * 考试分数
9 | */
10 | public class ExamMark implements Serializable,Comparable {
11 |
12 | /**
13 | * 考试编号
14 | */
15 | private int examid;
16 |
17 | /**
18 | * 班级编号
19 | */
20 | private int classid;
21 |
22 | /**
23 | * 学生编号
24 | */
25 | private int studentid;
26 |
27 | /**
28 | * 学生姓名
29 | */
30 | private String studentname;
31 |
32 | /**
33 | * 考试时间
34 | */
35 | private Date examtime;
36 |
37 | /**
38 | * 分数
39 | */
40 | private BigDecimal mark;
41 |
42 | /**
43 | * 排名
44 | */
45 | private int rank;
46 |
47 | /**
48 | * 考试备注
49 | */
50 | private String remark;
51 |
52 | /**
53 | * 所属考试实体
54 | */
55 | private Exam exam;
56 |
57 | public int getExamid() {
58 | return examid;
59 | }
60 |
61 | public void setExamid(int examid) {
62 | this.examid = examid;
63 | }
64 |
65 | public int getClassid() {
66 | return classid;
67 | }
68 |
69 | public void setClassid(int classid) {
70 | this.classid = classid;
71 | }
72 |
73 | public int getStudentid() {
74 | return studentid;
75 | }
76 |
77 | public void setStudentid(int studentid) {
78 | this.studentid = studentid;
79 | }
80 |
81 | public Date getExamtime() {
82 | return examtime;
83 | }
84 |
85 | public void setExamtime(Date examtime) {
86 | this.examtime = examtime;
87 | }
88 |
89 | public BigDecimal getMark() {
90 | return mark;
91 | }
92 |
93 | public void setMark(BigDecimal mark) {
94 | this.mark = mark;
95 | }
96 |
97 | public int getRank() {
98 | return rank;
99 | }
100 |
101 | public void setRank(int rank) {
102 | this.rank = rank;
103 | }
104 |
105 | public String getRemark() {
106 | return remark;
107 | }
108 |
109 | public void setRemark(String remark) {
110 | this.remark = remark;
111 | }
112 |
113 | public Exam getExam() {
114 | return exam;
115 | }
116 |
117 | public void setExam(Exam exam) {
118 | this.exam = exam;
119 | }
120 |
121 |
122 | public String getStudentname() {
123 | return studentname;
124 | }
125 |
126 | public void setStudentname(String studentname) {
127 | this.studentname = studentname;
128 | }
129 |
130 | @Override
131 | public int compareTo(ExamMark em) {
132 | return this.mark.compareTo(em.mark);
133 | }
134 |
135 | @Override
136 | public String toString() {
137 | return "ExamMark [examid=" + examid + ", classid=" + classid
138 | + ", studentid=" + studentid + ", examtime=" + examtime
139 | + ", mark=" + mark + ", rank=" + rank + ", remark=" + remark
140 | + ", exam=" + exam + "]";
141 | }
142 |
143 |
144 |
145 |
146 | }
147 |
--------------------------------------------------------------------------------
/src/com/aixuexiao/model/Message.java:
--------------------------------------------------------------------------------
1 | package com.aixuexiao.model;
2 |
3 | import java.io.Serializable;
4 | import java.util.Date;
5 |
6 | import com.thoughtworks.xstream.annotations.XStreamOmitField;
7 |
8 | /**
9 | * 微信消息(服务端接收到的)
10 | * @author lizy
11 | */
12 | public class Message implements Serializable{
13 |
14 | public static final String TEXT = "text";
15 | public static final String IMAGE = "image";
16 | public static final String LOCATION = "location";
17 | public static final String LINK = "link";
18 | public static final String EVENT = "event";
19 |
20 | @XStreamOmitField
21 | private int id;//数据库存储的id
22 |
23 | // 开发者微信号
24 | private String toUserName;
25 | // 发送方帐号(一个OpenID)
26 | private String fromUserName;
27 | // 消息创建时间
28 | private Date createTime;
29 | // 消息类型(text/image/location/link)
30 | private String msgType;
31 | // 消息id,64位整型
32 | private String msgId;
33 |
34 | // 消息内容 (文本消息专有)
35 | private String content;
36 |
37 | //图片链接 (图片消息专有)
38 | private String picUrl;
39 |
40 | // 消息标题 (链接消息专有)
41 | private String title;
42 | // 消息描述 (链接消息专有)
43 | private String description;
44 | // 消息链接 (链接消息专有)
45 | private String url;
46 |
47 |
48 | //地理位置纬度 Location_X(地理位置专有)
49 | private String locationX;
50 | //地理位置经度 Location_Y(地理位置专有)
51 | private String locationY;
52 | // 地图缩放大小 (地理位置专有)
53 | private String scale;
54 | // 地理位置信息 (地理位置专有)
55 | private String label;
56 |
57 |
58 | //事件类型,subscribe(订阅)、unsubscribe(取消订阅)、CLICK(自定义菜单点击事件) (事件推送专有)
59 | private String event;
60 | //事件KEY值,与自定义菜单接口中KEY值对应(事件推送专有)
61 | private String eventKey;
62 |
63 |
64 | public int getId() {
65 | return id;
66 | }
67 | public void setId(int id) {
68 | this.id = id;
69 | }
70 | public String getToUserName() {
71 | return toUserName;
72 | }
73 | public void setToUserName(String toUserName) {
74 | this.toUserName = toUserName;
75 | }
76 | public String getFromUserName() {
77 | return fromUserName;
78 | }
79 | public void setFromUserName(String fromUserName) {
80 | this.fromUserName = fromUserName;
81 | }
82 | public Date getCreateTime() {
83 | return createTime;
84 | }
85 | public void setCreateTime(Date createTime) {
86 | this.createTime = createTime;
87 | }
88 | public String getMsgType() {
89 | return msgType;
90 | }
91 | public void setMsgType(String msgType) {
92 | this.msgType = msgType;
93 | }
94 | public String getMsgId() {
95 | return msgId;
96 | }
97 | public void setMsgId(String msgId) {
98 | this.msgId = msgId;
99 | }
100 | public String getContent() {
101 | return content;
102 | }
103 | public void setContent(String content) {
104 | this.content = content;
105 | }
106 | public String getPicUrl() {
107 | return picUrl;
108 | }
109 | public void setPicUrl(String picUrl) {
110 | this.picUrl = picUrl;
111 | }
112 | public String getTitle() {
113 | return title;
114 | }
115 | public void setTitle(String title) {
116 | this.title = title;
117 | }
118 | public String getDescription() {
119 | return description;
120 | }
121 | public void setDescription(String description) {
122 | this.description = description;
123 | }
124 | public String getUrl() {
125 | return url;
126 | }
127 | public void setUrl(String url) {
128 | this.url = url;
129 | }
130 | public String getLocationX() {
131 | return locationX;
132 | }
133 | public void setLocationX(String locationX) {
134 | this.locationX = locationX;
135 | }
136 | public String getLocationY() {
137 | return locationY;
138 | }
139 | public void setLocationY(String locationY) {
140 | this.locationY = locationY;
141 | }
142 | public String getScale() {
143 | return scale;
144 | }
145 | public void setScale(String scale) {
146 | this.scale = scale;
147 | }
148 | public String getLabel() {
149 | return label;
150 | }
151 | public void setLabel(String label) {
152 | this.label = label;
153 | }
154 | public String getEvent() {
155 | return event;
156 | }
157 | public void setEvent(String event) {
158 | this.event = event;
159 | }
160 | public String getEventKey() {
161 | return eventKey;
162 | }
163 | public void setEventKey(String eventKey) {
164 | this.eventKey = eventKey;
165 | }
166 |
167 | }
168 |
--------------------------------------------------------------------------------
/src/com/aixuexiao/model/Reply.java:
--------------------------------------------------------------------------------
1 | package com.aixuexiao.model;
2 |
3 | import java.io.Serializable;
4 | import java.util.Date;
5 | import java.util.List;
6 |
7 | import com.thoughtworks.xstream.annotations.XStreamAlias;
8 | import com.thoughtworks.xstream.annotations.XStreamOmitField;
9 |
10 | /**
11 | * 回复用户的消息
12 | * @author lizy
13 | */
14 | public class Reply implements Serializable {
15 |
16 | public static final String TEXT = "text";
17 | public static final String MUSIC = "music";
18 | public static final String NEWS = "news";
19 |
20 | public static final String ERROR_CONTENT = "查询失败,请检查你的回复是否正确。\n查询最近考试情况请回复:学号_考试(如:3021_考试)\n 查询最近最近10次考试情况请回复:学号_考试历史(如:3021_考试历史)\n 查询老师留言情况请回复:学号_留言(如:3021_留言)\n查询老师留言记录(最近10次)情况请回复:学号_留言历史(如:3021_留言历史)\n\n 查询班级动态情况请回复:学号_动态(如:3021_动态)\n查询班级动态记录(最近10次)情况请回复:学号_动态历史(如:3021_动态历史)\n";
21 | public static final String WELCOME_CONTENT = "欢迎订阅爱学校,你可以回复指定内容来了解学生考试情况,老师留言和班级动态。\n查询最近考试情况请回复:学号_考试(如:3021_考试)\n 查询最近最近10次考试情况请回复:学号_考试历史(如:3021_考试历史)\n 查询老师留言情况请回复:学号_留言(如:3021_留言)\n查询老师留言记录(最近10次)情况请回复:学号_留言历史(如:3021_留言历史)\n\n 查询班级动态情况请回复:学号_动态(如:3021_动态)\n查询班级动态记录(最近10次)情况请回复:学号_动态历史(如:3021_动态历史)\n";
22 |
23 | @XStreamOmitField
24 | private int id;//数据库存储id
25 |
26 | // 开发者微信号
27 | @XStreamAlias("ToUserName")
28 | private String toUserName;
29 | // 发送方帐号(一个OpenID)
30 | @XStreamAlias("FromUserName")
31 | private String fromUserName;
32 | // 消息创建时间
33 | @XStreamAlias("CreateTime")
34 | private Date createTime;
35 | // 消息类型(text/music/news)
36 | @XStreamAlias("MsgType")
37 | private String msgType;
38 |
39 | //回复的消息内容,长度不超过2048字节 (文本消息专有)
40 | @XStreamAlias("Content")
41 | private String content;
42 |
43 | //音乐链接 (音乐消息专有)
44 | @XStreamAlias("MusicUrl")
45 | private String musicUrl;
46 | //高质量音乐链接,WIFI环境优先使用该链接播放音乐 (音乐消息专有)
47 | @XStreamAlias("HQMusicUrl")
48 | private String hQMusicUrl;
49 |
50 | //图文消息个数,限制为10条以内 (图文消息专有)
51 | @XStreamAlias("ArticleCount")
52 | private int articleCount;
53 |
54 | //多条图文消息信息,默认第一个item为大图
55 | @XStreamAlias("Articles")
56 | private List articles;
57 |
58 | public static void main(String[] args) {
59 | System.out.println("http://mmsns.qpic.cn/mmsns/UKMLIAeREF9IyZGhfvF8f0CAKDzEvXwCibLKUM4kmsfGnZvFM7EJlrg/0".length());
60 | }
61 |
62 | public int getId() {
63 | return id;
64 | }
65 |
66 | public void setId(int id) {
67 | this.id = id;
68 | }
69 |
70 | public String getToUserName() {
71 | return toUserName;
72 | }
73 |
74 | public void setToUserName(String toUserName) {
75 | this.toUserName = toUserName;
76 | }
77 |
78 | public String getFromUserName() {
79 | return fromUserName;
80 | }
81 |
82 | public void setFromUserName(String fromUserName) {
83 | this.fromUserName = fromUserName;
84 | }
85 |
86 | public Date getCreateTime() {
87 | return createTime;
88 | }
89 |
90 | public void setCreateTime(Date createTime) {
91 | this.createTime = createTime;
92 | }
93 |
94 | public String getMsgType() {
95 | return msgType;
96 | }
97 |
98 | public void setMsgType(String msgType) {
99 | this.msgType = msgType;
100 | }
101 |
102 |
103 | public String getContent() {
104 | return content;
105 | }
106 |
107 | public void setContent(String content) {
108 | this.content = content;
109 | }
110 |
111 | public String getMusicUrl() {
112 | return musicUrl;
113 | }
114 |
115 | public void setMusicUrl(String musicUrl) {
116 | this.musicUrl = musicUrl;
117 | }
118 |
119 | public String gethQMusicUrl() {
120 | return hQMusicUrl;
121 | }
122 |
123 | public void sethQMusicUrl(String hQMusicUrl) {
124 | this.hQMusicUrl = hQMusicUrl;
125 | }
126 |
127 | public int getArticleCount() {
128 | return articleCount;
129 | }
130 |
131 | public void setArticleCount(int articleCount) {
132 | this.articleCount = articleCount;
133 | }
134 |
135 | public List getArticles() {
136 | return articles;
137 | }
138 |
139 | public void setArticles(List articles) {
140 | this.articles = articles;
141 | }
142 |
143 |
144 |
145 |
146 | }
147 |
--------------------------------------------------------------------------------
/src/com/aixuexiao/model/Student.java:
--------------------------------------------------------------------------------
1 | package com.aixuexiao.model;
2 |
3 | import java.io.Serializable;
4 |
5 | /**
6 | * 学生实体
7 | */
8 | public class Student implements Serializable {
9 |
10 | /**
11 | * 学生编号
12 | */
13 | private int id;
14 |
15 | /**
16 | * 班级编号
17 | */
18 | private int classid;
19 |
20 | /**
21 | * 学生姓名
22 | */
23 | private String name;
24 |
25 | /**
26 | * 备注
27 | */
28 | private String remark;
29 |
30 | public int getId() {
31 | return id;
32 | }
33 |
34 | public void setId(int id) {
35 | this.id = id;
36 | }
37 |
38 | public int getClassid() {
39 | return classid;
40 | }
41 |
42 | public void setClassid(int classid) {
43 | this.classid = classid;
44 | }
45 |
46 | public String getName() {
47 | return name;
48 | }
49 |
50 | public void setName(String name) {
51 | this.name = name;
52 | }
53 |
54 | public String getRemark() {
55 | return remark;
56 | }
57 |
58 | public void setRemark(String remark) {
59 | this.remark = remark;
60 | }
61 |
62 |
63 |
64 | }
65 |
--------------------------------------------------------------------------------
/src/com/aixuexiao/model/StudentMessage.java:
--------------------------------------------------------------------------------
1 | package com.aixuexiao.model;
2 |
3 | import java.io.Serializable;
4 | import java.util.Date;
5 |
6 | /**
7 | * 给学生的留言
8 | */
9 | public class StudentMessage implements Serializable {
10 |
11 | /**
12 | * 留言编号
13 | */
14 | private int id;
15 |
16 | /**
17 | * 学生编号
18 | */
19 | private int studentid;
20 |
21 | /**
22 | * 公告内容
23 | */
24 | private String content;
25 |
26 | /**
27 | * 发布时间
28 | */
29 | private Date inserttime;
30 |
31 | public int getId() {
32 | return id;
33 | }
34 |
35 | public void setId(int id) {
36 | this.id = id;
37 | }
38 |
39 | public int getStudentid() {
40 | return studentid;
41 | }
42 |
43 | public void setStudentid(int studentid) {
44 | this.studentid = studentid;
45 | }
46 |
47 |
48 |
49 | public String getContent() {
50 | return content;
51 | }
52 |
53 | public void setContent(String content) {
54 | this.content = content;
55 | }
56 |
57 | public Date getInserttime() {
58 | return inserttime;
59 | }
60 |
61 | public void setInserttime(Date inserttime) {
62 | this.inserttime = inserttime;
63 | }
64 |
65 |
66 | }
67 |
--------------------------------------------------------------------------------
/src/com/aixuexiao/service/ClassesService.java:
--------------------------------------------------------------------------------
1 | package com.aixuexiao.service;
2 |
3 | import java.util.List;
4 |
5 | import javax.annotation.Resource;
6 |
7 | import org.springframework.stereotype.Service;
8 |
9 | import com.aixuexiao.dao.ClassesDao;
10 | import com.aixuexiao.dao.ClassesNewsDao;
11 | import com.aixuexiao.dao.StudentDao;
12 | import com.aixuexiao.model.Classes;
13 | import com.aixuexiao.model.ClassesNews;
14 | import com.aixuexiao.model.Student;
15 |
16 | @Service("classesService")
17 | public class ClassesService {
18 |
19 | @Resource(name="studentDao")
20 | private StudentDao studentDao;
21 |
22 | @Resource(name="classesDao")
23 | private ClassesDao classesDao;
24 |
25 | @Resource(name="classesNewsDao")
26 | private ClassesNewsDao classesNewsDao;
27 |
28 | /**
29 | * 将数据库中Classes数据分页查出
30 | * @param start 其实数据条数
31 | * @param size 展示数据每页的大小
32 | */
33 | public List listClasses(int start,int size,Classes classes){
34 | return classesDao.findClasses(start, size,classes);
35 | }
36 |
37 | public void deleteClassesNewsById(int id){
38 | classesNewsDao.deleteClassesNewsById(id);
39 | }
40 |
41 | /**
42 | * 添加班级动态到数据库
43 | * @param classesNews
44 | */
45 | public void addClassesNews(ClassesNews classesNews){
46 | classesNewsDao.addClassesNews(classesNews);
47 | }
48 |
49 | /**
50 | * 获取指定班级的班级动态(钱1000个)
51 | * @param classid 班级id
52 | * @return
53 | */
54 | public List findClassesNewsByClassId(int classid){
55 | return classesNewsDao.findClassesNewsByClassId(classid, 1000);
56 | }
57 |
58 | /**
59 | * 添加班级到数据库中
60 | * @param classes 班级对象
61 | */
62 | public void addClasses(Classes classes){
63 | classesDao.addClasses(classes);
64 | }
65 |
66 | /**
67 | * 根据id查找对应的Classes对象
68 | * @param id 班级编号
69 | * @return
70 | */
71 | public Classes findClassesById(int id){
72 | return classesDao.findClassesById(id);
73 | }
74 |
75 | /**
76 | * 根据学生编号查找对应的学生
77 | * @param studentid 学生编号
78 | * @return 学生数据
79 | */
80 | public Student findStudentById(int studentid){
81 | return studentDao.findStudentById(studentid);
82 | }
83 |
84 | /**
85 | * 根据班级id查找对应班级所有学生
86 | * @param classesid 班级id
87 | * @return
88 | */
89 | public List findStudentByClassesId(int classesid){
90 | return studentDao.findStudentByClassesId(classesid);
91 | }
92 |
93 | /**
94 | * 添加学生信息至数据库中
95 | * @param student 学生对象
96 | */
97 | public void addStudent(Student student){
98 | studentDao.addStudent(student);
99 | }
100 |
101 |
102 | /**
103 | * 删除数据库中对应id的学生信息
104 | * @param student 学生对象
105 | */
106 | public void deleteStudentById(int studentid){
107 | studentDao.deleteStudentById(studentid);
108 | }
109 |
110 | /**
111 | * 自动更新指定班级的学生数量
112 | * @param classid 班级id
113 | */
114 | public void updateClassStudentCount(int classid){
115 | classesDao.updateClassStudentCount(classid);
116 | }
117 |
118 | public void updateStudentBy(Student student) {
119 | studentDao.updateStudent(student);
120 | }
121 |
122 | }
123 |
--------------------------------------------------------------------------------
/src/com/aixuexiao/service/ExamService.java:
--------------------------------------------------------------------------------
1 | package com.aixuexiao.service;
2 |
3 | import java.util.List;
4 |
5 | import javax.annotation.Resource;
6 |
7 | import org.springframework.stereotype.Service;
8 |
9 | import com.aixuexiao.dao.ClassesDao;
10 | import com.aixuexiao.dao.ExamDao;
11 | import com.aixuexiao.dao.StudentDao;
12 | import com.aixuexiao.model.Classes;
13 | import com.aixuexiao.model.Exam;
14 | import com.aixuexiao.model.ExamMark;
15 | import com.aixuexiao.model.Student;
16 |
17 | @Service("examService")
18 | public class ExamService {
19 |
20 | @Resource(name="studentDao")
21 | private StudentDao studentDao;
22 |
23 | @Resource(name="classesDao")
24 | private ClassesDao classesDao;
25 |
26 | @Resource(name="examDao")
27 | private ExamDao examDao;
28 |
29 | /**
30 | * 保存考试信息
31 | * @param exam
32 | */
33 | public void addExam(Exam exam){
34 | examDao.addExam(exam);
35 | for(ExamMark em:exam.getExamMarks()){
36 | em.setExamid(exam.getId());
37 | examDao.addExamMark(em);
38 | }
39 | }
40 |
41 | /**
42 | * 根据考试id查找数据库中考试信息
43 | * @param id
44 | * @return
45 | */
46 | public Exam findExamById(int id){
47 | return examDao.findExamById(id);
48 | }
49 |
50 | /**
51 | * 将数据库中Student数据分页查出
52 | * @param start 其实数据条数
53 | * @param size 展示数据每页的大小
54 | */
55 | public List listExam(int start,int size,Exam exam){
56 | return examDao.findExam(start,size,exam);
57 | }
58 |
59 | public List findStudentByClassesId(int classesid) {
60 | return studentDao.findStudentByClassesId(classesid);
61 | }
62 |
63 | /**
64 | * 根据学生编号查找对应的学生
65 | * @param studentid 学生编号
66 | * @return 学生数据
67 | */
68 | public Student findStudentById(int studentid){
69 | return studentDao.findStudentById(studentid);
70 | }
71 |
72 | /**
73 | * 将数据库中Classes数据全部查出
74 | */
75 | public List findAllClasses(){
76 | return classesDao.findAllClasses();
77 | }
78 |
79 | }
80 |
--------------------------------------------------------------------------------
/src/com/aixuexiao/service/StudentService.java:
--------------------------------------------------------------------------------
1 | package com.aixuexiao.service;
2 |
3 | import java.util.List;
4 |
5 | import javax.annotation.Resource;
6 |
7 | import org.springframework.stereotype.Service;
8 |
9 | import com.aixuexiao.dao.ClassesDao;
10 | import com.aixuexiao.dao.ExamDao;
11 | import com.aixuexiao.dao.StudentDao;
12 | import com.aixuexiao.dao.StudentMessageDao;
13 | import com.aixuexiao.model.Classes;
14 | import com.aixuexiao.model.ExamMark;
15 | import com.aixuexiao.model.Student;
16 | import com.aixuexiao.model.StudentMessage;
17 |
18 | @Service("studentService")
19 | public class StudentService {
20 |
21 | @Resource(name="studentDao")
22 | private StudentDao studentDao;
23 |
24 | @Resource(name="classesDao")
25 | private ClassesDao classesDao;
26 |
27 | @Resource(name="studentMessageDao")
28 | private StudentMessageDao studentMessageDao;
29 |
30 | @Resource(name="examDao")
31 | private ExamDao examDao;
32 |
33 | /**
34 | * 根据学生编号查找对应的考试信息
35 | * @param id 学生编号
36 | * @param limit
37 | * @return
38 | */
39 | public List findExamMarkByStudentId(int id ,int limit){
40 | return examDao.findExamMarkByStudentId(id, limit);
41 | }
42 |
43 |
44 | /**
45 | * 将数据库中Student数据分页查出
46 | * @param start 其实数据条数
47 | * @param size 展示数据每页的大小
48 | */
49 | public List listStudent(int start,int size,Student student){
50 | return studentDao.findStudent(start,size,student);
51 | }
52 |
53 | /**
54 | * 根据学生编号查找对应的学生
55 | * @param studentid 学生编号
56 | * @return 学生数据
57 | */
58 | public Student findStudentById(int studentid){
59 | return studentDao.findStudentById(studentid);
60 | }
61 |
62 | /**
63 | * 添加老师给学生的微信留言到数据库
64 | * @param studentMessage
65 | */
66 | public void addStudentMessage(StudentMessage studentMessage){
67 | studentMessageDao.addStudentMessage(studentMessage);
68 | }
69 |
70 | /**
71 | * 根据id删除老师给学生的微信留言
72 | * @param id
73 | */
74 | public void deleteStudentMessageById(int id){
75 | studentMessageDao.deleteStudentMessageById(id);
76 | }
77 |
78 | /**
79 | * 将数据库中Classes数据全部查出
80 | */
81 | public List findAllClasses(){
82 | return classesDao.findAllClasses();
83 | }
84 |
85 | /**
86 | * 根据学生id查询对应学生的留言记录
87 | * @param studentid 学生id
88 | * @param limit 展示数据每页的大小
89 | */
90 | public List listMessageByStudentId(int studentid,int limit){
91 | return studentMessageDao.findStudentMessageByStudentId(studentid, limit);
92 | }
93 |
94 |
95 | }
96 |
--------------------------------------------------------------------------------
/src/com/aixuexiao/service/WeixinService.java:
--------------------------------------------------------------------------------
1 | package com.aixuexiao.service;
2 |
3 | import java.text.DateFormat;
4 | import java.text.SimpleDateFormat;
5 | import java.util.List;
6 |
7 | import javax.annotation.Resource;
8 |
9 | import org.springframework.stereotype.Service;
10 |
11 | import com.aixuexiao.dao.ClassesNewsDao;
12 | import com.aixuexiao.dao.ExamDao;
13 | import com.aixuexiao.dao.MessageDao;
14 | import com.aixuexiao.dao.ReplyDao;
15 | import com.aixuexiao.dao.StudentDao;
16 | import com.aixuexiao.dao.StudentMessageDao;
17 | import com.aixuexiao.model.Article;
18 | import com.aixuexiao.model.ClassesNews;
19 | import com.aixuexiao.model.Exam;
20 | import com.aixuexiao.model.ExamMark;
21 | import com.aixuexiao.model.Message;
22 | import com.aixuexiao.model.Reply;
23 | import com.aixuexiao.model.Student;
24 | import com.aixuexiao.model.StudentMessage;
25 |
26 | @Service("weixinService")
27 | public class WeixinService {
28 |
29 | @Resource(name="messageDao")
30 | private MessageDao messageDao;
31 |
32 | @Resource(name="replyDao")
33 | private ReplyDao replyDao;
34 |
35 | @Resource(name="examDao")
36 | private ExamDao examDao;
37 |
38 | @Resource(name="studentDao")
39 | private StudentDao studentDao;
40 |
41 | @Resource(name="studentMessageDao")
42 | private StudentMessageDao studentMessageDao;
43 |
44 | @Resource(name="classesNewsDao")
45 | private ClassesNewsDao classesNewsDao;
46 |
47 |
48 | /**
49 | * 查询学生最近一次考试情况
50 | * @param studentid 学生编号
51 | * @return 返回考试情况字符串
52 | */
53 | public String getSingleExamMarkStringByStudentId(int studentid){
54 | StringBuilder sb = new StringBuilder();
55 | Student student = studentDao.findStudentById(studentid);
56 | if(student == null){
57 | sb.append("您好,未找到编号为").append(studentid).append("的学生!");
58 | }else{
59 | List list = examDao.findExamMarkByStudentId(studentid, 1);
60 | sb.append("您好,编号为").append(studentid).append("的学生(").append(student.getName());
61 | if(list == null || list.size()<1 || list.get(0).getExam()==null){
62 | sb.append(")无考试记录!");
63 | }else{
64 | ExamMark em = list.get(0);
65 | Exam e = em.getExam();
66 | DateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
67 | sb.append(")最近一次考试记录如下:\n").append("科目:").append(e.getCourse())
68 | .append("\n分数:").append(em.getMark())
69 | .append("\n班级排名:").append(em.getRank())
70 | .append("\n考试时间:").append(sf.format(em.getExamtime()))
71 | .append("\n老师备注:").append(em.getRemark())
72 | .append("\n试卷满分:").append(e.getFullmarks())
73 | .append("\n班级均分:").append(e.getAverage())
74 | .append("\n班级最高分:").append(e.getTopmark())
75 | .append("\n班级最低分:").append(e.getLowestmark())
76 | .append("\n考试说明:").append(e.getRemark());
77 | }
78 | }
79 | return sb.toString();
80 | }
81 |
82 | /**
83 | * 查询学生历次考试情况(最近10次)
84 | * @param studentid 学生编号
85 | * @return 返回考试情况字符串
86 | */
87 | public String getExamMarkHistoryStringByStudentId(int studentid){
88 | StringBuilder sb = new StringBuilder();
89 | Student student = studentDao.findStudentById(studentid);
90 | if(student == null){
91 | sb.append("您好,未找到编号为").append(studentid).append("的学生!");
92 | }else{
93 | sb.append("您好,编号为").append(studentid).append("的学生(").append(student.getName());
94 | List list = examDao.findExamMarkByStudentId(studentid, 10);
95 | if(list == null || list.size()<1 || list.get(0).getExam()==null){
96 | sb.append(")无考试记录!");
97 | }else{
98 | DateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
99 | Exam e = null;
100 | sb.append(")最近10次考试情况如下:");
101 | for(ExamMark em : list){
102 | e = em.getExam();
103 | sb.append("\n考试时间:").append(sf.format(em.getExamtime()))
104 | .append("\n科目:").append(e.getCourse())
105 | .append("\n分数:").append(em.getMark())
106 | .append("\n班级排名:").append(em.getRank())
107 | .append("\n老师备注:").append(em.getRemark())
108 | .append("\n试卷满分:").append(e.getFullmarks())
109 | .append("\n班级均分:").append(e.getAverage())
110 | .append("\n班级最高分:").append(e.getTopmark())
111 | .append("\n班级最低分:").append(e.getLowestmark())
112 | .append("\n考试说明:").append(e.getRemark())
113 | .append("\n------分割线-------");
114 | }
115 | }
116 | }
117 | return sb.toString();
118 | }
119 |
120 | /**
121 | * 根据学生编号查询学生最近的老师留言信息
122 | * @param studentid 学生编号
123 | * @return 以字符串形式返回老师留言信息
124 | */
125 | public String getSingleStudentMessageByStudentId(int studentid){
126 | StringBuilder sb = new StringBuilder();
127 | Student student = studentDao.findStudentById(studentid);
128 | if(student == null){
129 | sb.append("您好,未找到编号为").append(studentid).append("的学生!");
130 | }else{
131 | sb.append("您好,编号为").append(studentid).append("的学生(").append(student.getName());
132 | List list = studentMessageDao.findStudentMessageByStudentId(studentid, 1);
133 | if(list == null || list.size()<1 ){
134 | sb.append(")无老师留言!");
135 | }else{
136 | sb.append(")最近老师留言如下:");
137 | DateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
138 | StudentMessage sm = list.get(0);
139 | sb.append("\n留言时间:").append(sf.format(sm.getInserttime()))
140 | .append("\n留言内容:").append(sm.getContent());
141 | }
142 | }
143 | return sb.toString();
144 | }
145 |
146 | /**
147 | * 根据学生编号查询学生的老师留言信息记录(最近10次)
148 | * @param studentid 学生编号
149 | * @return 以字符串形式返回老师留言信息
150 | */
151 | public String getStudentMessageHistoryByStudentId(int studentid){
152 | StringBuilder sb = new StringBuilder();
153 | Student student = studentDao.findStudentById(studentid);
154 | if(student == null){
155 | sb.append("您好,未找到编号为").append(studentid).append("的学生!");
156 | }else{
157 | sb.append("您好,编号为").append(studentid).append("的学生(").append(student.getName());
158 | List list = studentMessageDao.findStudentMessageByStudentId(studentid, 10);
159 | if(list == null || list.size()<1 ){
160 | sb.append(")无老师留言!");
161 | }else{
162 | sb.append(")最近(10次)老师留言如下:");
163 | DateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
164 | for(StudentMessage sm : list){
165 | sb.append("\n留言时间:").append(sf.format(sm.getInserttime()))
166 | .append("\n留言内容:").append(sm.getContent())
167 | .append("\n------分割线-------");
168 | }
169 | }
170 | }
171 | return sb.toString();
172 | }
173 |
174 | /**
175 | * 根据学生编号查询学生所在班级的班级动态
176 | * @param studentid 学生编号
177 | * @return 以字符串形式返回学生所在班级的班级动态
178 | */
179 | public String getSingleClassesNewsByStudentId(int studentid){
180 | StringBuilder sb = new StringBuilder();
181 | Student student = studentDao.findStudentById(studentid);
182 | if(student == null){
183 | sb.append("您好,未找到编号为").append(studentid).append("的学生!");
184 | }else{
185 | sb.append("您好,编号为").append(studentid).append("的学生(").append(student.getName());
186 | List list = classesNewsDao.findClassesNewsByClassId(student.getClassid(), 1);
187 | if(list == null || list.size()<1 ){
188 | sb.append(")所在班级无班级动态!");
189 | }else{
190 | sb.append(")最近班级动态如下:");
191 | DateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
192 | ClassesNews cn = list.get(0);
193 | sb.append("\n动态时间:").append(sf.format(cn.getInserttime()))
194 | .append("\n动态内容:").append(cn.getContent());
195 | }
196 | }
197 | return sb.toString();
198 | }
199 |
200 | /**
201 | * 根据学生编号查询学生所在班级的班级动态
202 | * @param studentid 学生编号
203 | * @return 以字符串形式返回学生所在班级的班级动态
204 | */
205 | public String getClassesNewsHistoryByStudentId(int studentid){
206 | StringBuilder sb = new StringBuilder();
207 | Student student = studentDao.findStudentById(studentid);
208 | if(student == null){
209 | sb.append("您好,未找到编号为").append(studentid).append("的学生!");
210 | }else{
211 | sb.append("您好,编号为").append(studentid).append("的学生(").append(student.getName());
212 | List list = classesNewsDao.findClassesNewsByClassId(student.getClassid(), 10);
213 | if(list == null || list.size()<1 ){
214 | sb.append(")所在班级无班级动态!");
215 | }else{
216 | sb.append(")最近班级动态如下:");
217 | DateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
218 | for(ClassesNews cn:list){
219 | sb.append("\n动态时间:").append(sf.format(cn.getInserttime()))
220 | .append("\n动态内容:").append(cn.getContent())
221 | .append("\n------分割线-------");
222 | }
223 | }
224 | }
225 | return sb.toString();
226 | }
227 |
228 | /**
229 | * 新增Message对象到数据库中
230 | */
231 | public void addMessage(Message message) {
232 | messageDao.addMessage(message);
233 | }
234 |
235 |
236 | /**
237 | * 将数据库中Message数据分页查出
238 | * @param start 其实数据条数
239 | * @param size 展示数据每页的大小
240 | */
241 | public List listMessage(int start,int size){
242 | return messageDao.findMessage(start,size);
243 | }
244 |
245 | /**
246 | * 将数据库中Message数据分页查出
247 | * @param start 其实数据条数
248 | * @param size 展示数据每页的大小
249 | */
250 | public List listReply(int start,int size){
251 | return replyDao.findReply(start,size);
252 | }
253 |
254 |
255 | /**
256 | * 保存回复消息至数据库中,如果为news类型消息将article一并保存
257 | */
258 | public void addReply(Reply reply){
259 | replyDao.addReply(reply);
260 | if(Reply.NEWS.equals(reply.getMsgType())&&null != reply.getArticles()){
261 | List articles = reply.getArticles();
262 | for(Article a: articles){
263 | a.setReplyId(reply.getId());
264 | replyDao.addArticle(a);
265 | }
266 | }
267 | }
268 |
269 | }
270 |
--------------------------------------------------------------------------------
/src/com/aixuexiao/util/ExamUtil.java:
--------------------------------------------------------------------------------
1 | package com.aixuexiao.util;
2 |
3 | import java.math.BigDecimal;
4 | import java.util.ArrayList;
5 | import java.util.Collections;
6 | import java.util.List;
7 |
8 | import com.aixuexiao.model.Exam;
9 | import com.aixuexiao.model.ExamMark;
10 |
11 | /**
12 | * 考试相关工具类
13 | */
14 | public class ExamUtil {
15 |
16 | /**
17 | * 为考试成绩排序 并计算平均分/最高分/最低发
18 | * @param exam 考试对象
19 | * @return
20 | */
21 | public static Exam sortExamMark(Exam exam){
22 | List ems = exam.getExamMarks();
23 | Collections.sort(ems);//对分数进行排序
24 | BigDecimal topmark = null,lowestmark = null,total = new BigDecimal(0);
25 | int rank = ems.size();
26 | for(int i = 0;i");
56 | } else {
57 | writer.write(text);
58 | }
59 | }
60 | };
61 | }
62 | });
63 |
64 | /**
65 | * 将回复消息对象转换成xml字符串
66 | * @param reply 回复消息对象
67 | * @return 返回符合微信接口的xml字符串
68 | */
69 | public static String replyToXml(Reply reply){
70 | String type = reply.getMsgType();
71 | if(Reply.TEXT.equals(type)){
72 | xstream.omitField(Reply.class, "articles");
73 | xstream.omitField(Reply.class, "articleCount");
74 | xstream.omitField(Reply.class, "musicUrl");
75 | xstream.omitField(Reply.class, "hQMusicUrl");
76 | }else if(Reply.MUSIC.equals(type)){
77 | xstream.omitField(Reply.class, "articles");
78 | xstream.omitField(Reply.class, "articleCount");
79 | xstream.omitField(Reply.class, "content");
80 | }else if(Reply.NEWS.equals(type)){
81 | xstream.omitField(Reply.class, "content");
82 | xstream.omitField(Reply.class, "musicUrl");
83 | xstream.omitField(Reply.class, "hQMusicUrl");
84 | }
85 | xstream.autodetectAnnotations(true);
86 | xstream.alias("xml", reply.getClass());
87 | xstream.alias("item", new Article().getClass());
88 | return xstream.toXML(reply);
89 | }
90 |
91 |
92 | /**
93 | * 存储数据的Map转换为对应的Message对象
94 | * @param map 存储数据的map
95 | * @return 返回对应Message对象
96 | */
97 | public static Message mapToMessage(Map map){
98 | if(map == null) return null;
99 | String msgType = map.get("MsgType");
100 | Message message = new Message();
101 | message.setToUserName(map.get("ToUserName"));
102 | message.setFromUserName(map.get("FromUserName"));
103 | message.setCreateTime(new Date(Long.parseLong(map.get("CreateTime"))));
104 | message.setMsgType(msgType);
105 | message.setMsgId(map.get("MsgId"));
106 | if(msgType.equals(Message.TEXT)){
107 | message.setContent(map.get("Content"));
108 | }else if(msgType.equals(Message.IMAGE)){
109 | message.setPicUrl(map.get("PicUrl"));
110 | }else if(msgType.equals(Message.LINK)){
111 | message.setTitle(map.get("Title"));
112 | message.setDescription(map.get("Description"));
113 | message.setUrl(map.get("Url"));
114 | }else if(msgType.equals(Message.LOCATION)){
115 | message.setLocationX(map.get("Location_X"));
116 | message.setLocationY(map.get("Location_Y"));
117 | message.setScale(map.get("Scale"));
118 | message.setLabel(map.get("Label"));
119 | }else if(msgType.equals(Message.EVENT)){
120 | message.setEvent(map.get("Event"));
121 | message.setEventKey(map.get("EventKey"));
122 | }
123 | return message;
124 | }
125 |
126 | /**
127 | * 解析request中的xml 并将数据存储到一个Map中返回
128 | * @param request
129 | */
130 | public static Map parseXml(HttpServletRequest request){
131 | Map map = new HashMap();
132 | try {
133 | InputStream inputStream = request.getInputStream();
134 | SAXReader reader = new SAXReader();
135 | Document document = reader.read(inputStream);
136 | Element root = document.getRootElement();
137 | List elementList = root.elements();
138 | for (Element e : elementList)
139 | //遍历xml将数据写入map
140 | map.put(e.getName(), e.getText());
141 | inputStream.close();
142 | inputStream = null;
143 | } catch (Exception e) {
144 | e.printStackTrace();
145 | }
146 | return map;
147 | }
148 |
149 |
150 | /**
151 | * sha1加密算法
152 | * @param key需要加密的字符串
153 | * @return 加密后的结果
154 | */
155 | public static String sha1(String key) {
156 | try {
157 | MessageDigest md = MessageDigest.getInstance("SHA1");
158 | md.update(key.getBytes());
159 | String pwd = new BigInteger(1, md.digest()).toString(16);
160 | return pwd;
161 | } catch (Exception e) {
162 | e.printStackTrace();
163 | return key;
164 | }
165 | }
166 |
167 | }
168 |
--------------------------------------------------------------------------------
/src/com/aixuexiao/web/controller/ClassesController.java:
--------------------------------------------------------------------------------
1 | package com.aixuexiao.web.controller;
2 |
3 |
4 | import java.util.Date;
5 | import java.util.List;
6 |
7 | import javax.annotation.Resource;
8 |
9 | import org.springframework.stereotype.Controller;
10 | import org.springframework.web.bind.annotation.RequestMapping;
11 | import org.springframework.web.bind.annotation.RequestMethod;
12 | import org.springframework.web.servlet.ModelAndView;
13 |
14 | import com.aixuexiao.model.Classes;
15 | import com.aixuexiao.model.ClassesNews;
16 | import com.aixuexiao.model.Student;
17 | import com.aixuexiao.service.ClassesService;
18 |
19 | /**
20 | * 包含班级列表菜单内的所有操作
21 | */
22 | @Controller
23 | public class ClassesController {
24 |
25 |
26 | public static int pagesize = 10;
27 |
28 | @Resource(name="classesService")
29 | private ClassesService classesService;
30 |
31 |
32 | @RequestMapping(value="/manager/classes",method=RequestMethod.GET)
33 | public ModelAndView listStudent(String pagenum,Classes classes){
34 | ModelAndView mv=new ModelAndView();
35 | mv.setViewName("classes");
36 | mv.addObject("sidebar","classes");
37 | int num = 1;
38 | if(null!=pagenum){
39 | num = Integer.parseInt(pagenum);
40 | }
41 | List list = classesService.listClasses((num-1)*pagesize, pagesize,classes);
42 | mv.addObject("classesList", list);
43 | mv.addObject("length", list.size());
44 | mv.addObject("pagenum", num);
45 | mv.addObject("classes", classes);
46 | return mv;
47 | }
48 |
49 |
50 | @RequestMapping(value="/manager/addclassespage",method=RequestMethod.GET)
51 | public ModelAndView addClassesPage(){
52 | ModelAndView mv=new ModelAndView();
53 | mv.setViewName("addclasses");
54 | mv.addObject("sidebar","classes");
55 | return mv;
56 | }
57 |
58 | @RequestMapping(value="/manager/addclasses",method=RequestMethod.POST)
59 | public ModelAndView addClasses(Classes classes){
60 | ModelAndView mv=new ModelAndView();
61 | Classes cls = classesService.findClassesById(classes.getId());
62 | if(null==cls){
63 | mv.setViewName("redirect:/manager/classes");
64 | classes.setStudentcount(0);
65 | classesService.addClasses(classes);
66 | }else{
67 | mv.setViewName("redirect:/manager/addclassespage");
68 | mv.addObject("name", classes.getName());
69 | mv.addObject("headteacher", classes.getHeadteacher());
70 | mv.addObject("notice","已存在编号为"+classes.getId()+"的班级");
71 | }
72 | return mv;
73 | }
74 |
75 | @RequestMapping(value="/manager/managerstudentpage",method=RequestMethod.GET)
76 | public ModelAndView studentPage(int classesid){
77 | ModelAndView mv=new ModelAndView();
78 | Classes cls = classesService.findClassesById(classesid);
79 | List stlist = classesService.findStudentByClassesId(classesid);
80 | mv.setViewName("addstudents");
81 | mv.addObject("sidebar","classes");
82 | mv.addObject("cls",cls);
83 | mv.addObject("stlist",stlist);
84 | mv.addObject("length", stlist.size());
85 | return mv;
86 | }
87 |
88 | @RequestMapping(value="/manager/classesnewspage",method=RequestMethod.GET)
89 | public ModelAndView classesnewsPage(int classesid){
90 | ModelAndView mv=new ModelAndView();
91 | Classes cls = classesService.findClassesById(classesid);
92 | List cnlist= classesService.findClassesNewsByClassId(classesid);
93 | mv.setViewName("addclassesnews");
94 | mv.addObject("sidebar","classes");
95 | mv.addObject("cls",cls);
96 | mv.addObject("cnlist",cnlist);
97 | return mv;
98 | }
99 |
100 | @RequestMapping(value="/manager/addclassesnews",method=RequestMethod.POST)
101 | public ModelAndView addClassesNews(ClassesNews classesNews){
102 | ModelAndView mv=new ModelAndView();
103 | classesNews.setInserttime(new Date());
104 | classesService.addClassesNews(classesNews);
105 | mv.addObject("notice","添加班级动态成功");
106 | mv.addObject("classesid",classesNews.getClassid());
107 | mv.setViewName("redirect:/manager/classesnewspage");
108 | return mv;
109 | }
110 |
111 |
112 | @RequestMapping(value="/manager/deleteclassesnews",method=RequestMethod.GET)
113 | public ModelAndView deleteClassesNews(int classesid,int id){
114 | ModelAndView mv=new ModelAndView();
115 | mv.setViewName("redirect:/manager/classesnewspage");
116 | mv.addObject("classesid",classesid);
117 | classesService.deleteClassesNewsById(id);
118 | mv.addObject("notice","删除动态成功");
119 | return mv;
120 | }
121 |
122 |
123 | @RequestMapping(value="/manager/addstudent",method=RequestMethod.POST)
124 | public ModelAndView addStudent(Student student){
125 | ModelAndView mv=new ModelAndView();
126 | Student stu = classesService.findStudentById(student.getId());
127 | if(stu==null){
128 | classesService.addStudent(student);
129 | classesService.updateClassStudentCount(student.getClassid());
130 | mv.addObject("notice","添加学生成功");
131 | }else{
132 | mv.addObject("notice","已经存在编号为"+student.getId()+"的学生("+stu.getName()+")!");
133 | }
134 | mv.addObject("classesid",student.getClassid());
135 | mv.setViewName("redirect:/manager/managerstudentpage");
136 | return mv;
137 | }
138 |
139 | @RequestMapping(value="/manager/deletestudent",method=RequestMethod.GET)
140 | public ModelAndView deleteStudent(int studentid,int classid){
141 | ModelAndView mv=new ModelAndView();
142 | classesService.deleteStudentById(studentid);
143 | classesService.updateClassStudentCount(classid);
144 | mv.addObject("classesid",classid);
145 | mv.addObject("notice","删除学生信息成功");
146 | mv.setViewName("redirect:/manager/managerstudentpage");
147 | return mv;
148 | }
149 |
150 | @RequestMapping(value="/manager/updatestudent",method=RequestMethod.POST)
151 | public ModelAndView updateStudent(Student student){
152 | ModelAndView mv=new ModelAndView();
153 | classesService.updateStudentBy(student);
154 | mv.addObject("classesid",student.getClassid());
155 | mv.addObject("notice","编辑学生信息成功");
156 | mv.setViewName("redirect:/manager/managerstudentpage");
157 | return mv;
158 | }
159 |
160 | }
161 |
--------------------------------------------------------------------------------
/src/com/aixuexiao/web/controller/ExamController.java:
--------------------------------------------------------------------------------
1 | package com.aixuexiao.web.controller;
2 |
3 |
4 | import java.util.Date;
5 | import java.util.List;
6 |
7 | import javax.annotation.Resource;
8 |
9 | import org.springframework.stereotype.Controller;
10 | import org.springframework.web.bind.annotation.RequestMapping;
11 | import org.springframework.web.bind.annotation.RequestMethod;
12 | import org.springframework.web.servlet.ModelAndView;
13 |
14 | import com.aixuexiao.model.Classes;
15 | import com.aixuexiao.model.Exam;
16 | import com.aixuexiao.model.Student;
17 | import com.aixuexiao.service.ExamService;
18 | import com.aixuexiao.util.ExamUtil;
19 |
20 | /**
21 | * 包含考试列表菜单内的所有操作
22 | */
23 | @Controller
24 | public class ExamController {
25 |
26 | public static final int pagesize = 10;
27 |
28 | @Resource(name="examService")
29 | private ExamService examService;
30 |
31 | @RequestMapping(value="/manager/exams",method=RequestMethod.GET)
32 | public ModelAndView listStudent(String pagenum,Exam exam){
33 | ModelAndView mv=new ModelAndView();
34 | mv.setViewName("exams");
35 | mv.addObject("sidebar","exams");
36 | int num = 1;
37 | if(null!=pagenum){
38 | num = Integer.parseInt(pagenum);
39 | }
40 | List list = examService.listExam((num-1)*pagesize, pagesize,exam);
41 | List clslist = examService.findAllClasses();
42 | mv.addObject("examList", list);
43 | mv.addObject("clsList", clslist);
44 | mv.addObject("length", list.size());
45 | mv.addObject("pagenum", num);
46 | mv.addObject("exam", exam);
47 | return mv;
48 | }
49 |
50 |
51 | @RequestMapping(value="/manager/addexam",method=RequestMethod.POST)
52 | public ModelAndView addExam(Exam exam){
53 | ModelAndView mv=new ModelAndView();
54 | mv.setViewName("addexam");
55 | mv.addObject("sidebar","exams");
56 | List stlist = examService.findStudentByClassesId(exam.getClassid());
57 | mv.addObject("exam",exam);
58 | mv.addObject("stlist",stlist);
59 | return mv;
60 | }
61 |
62 | @RequestMapping(value="/manager/viewexam",method=RequestMethod.GET)
63 | public ModelAndView viewExam(int id){
64 | ModelAndView mv=new ModelAndView();
65 | mv.setViewName("viewexam");
66 | mv.addObject("sidebar","exams");
67 | Exam exam = examService.findExamById(id);
68 | mv.addObject("exam",exam);
69 | return mv;
70 | }
71 |
72 | @RequestMapping(value="/manager/addexammark",method=RequestMethod.POST)
73 | public ModelAndView addExamMark(Exam exam){
74 | ModelAndView mv=new ModelAndView();
75 | mv.addObject("sidebar","exams");
76 | mv.setViewName("redirect:/manager/exams");
77 | exam.setExamtime(new Date());
78 | exam = ExamUtil.sortExamMark(exam);//为分数排序
79 | examService.addExam(exam);
80 | return mv;
81 | }
82 |
83 | }
84 |
--------------------------------------------------------------------------------
/src/com/aixuexiao/web/controller/LoginController.java:
--------------------------------------------------------------------------------
1 | package com.aixuexiao.web.controller;
2 |
3 |
4 | import javax.servlet.http.HttpServletRequest;
5 |
6 | import org.springframework.stereotype.Controller;
7 | import org.springframework.web.bind.annotation.RequestMapping;
8 | import org.springframework.web.bind.annotation.RequestMethod;
9 | import org.springframework.web.servlet.ModelAndView;
10 |
11 | @Controller()
12 | public class LoginController {
13 |
14 | private static final String USERNAME = "zhiyun";
15 | private static final String PASSWORD = "123456";
16 |
17 | @RequestMapping("/")
18 | public String index(){
19 | return "login";
20 | }
21 |
22 |
23 | @RequestMapping(value="/login",method=RequestMethod.POST)
24 | public ModelAndView login(String username,String password,HttpServletRequest request){
25 | ModelAndView mv=new ModelAndView("");
26 | if( USERNAME.equals(username)&& PASSWORD.equals(password)){
27 | request.getSession().setAttribute("user", username);
28 | mv.setViewName("redirect:/manager/students");
29 | }else{
30 | mv.setViewName("forward:/");
31 | mv.addObject("username",username);
32 | mv.addObject("message", "username or password error ");
33 | }
34 | return mv;
35 | }
36 |
37 |
38 | @RequestMapping(value="/loginout",method=RequestMethod.POST)
39 | public ModelAndView loginOut(HttpServletRequest request){
40 | ModelAndView mv=new ModelAndView();
41 | mv.setViewName("/");
42 | request.getSession().removeAttribute("user");
43 | return mv;
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/src/com/aixuexiao/web/controller/StudentController.java:
--------------------------------------------------------------------------------
1 | package com.aixuexiao.web.controller;
2 |
3 |
4 | import java.util.Date;
5 | import java.util.List;
6 |
7 | import javax.annotation.Resource;
8 |
9 | import org.springframework.stereotype.Controller;
10 | import org.springframework.web.bind.annotation.RequestMapping;
11 | import org.springframework.web.bind.annotation.RequestMethod;
12 | import org.springframework.web.servlet.ModelAndView;
13 |
14 | import com.aixuexiao.model.Classes;
15 | import com.aixuexiao.model.ExamMark;
16 | import com.aixuexiao.model.Student;
17 | import com.aixuexiao.model.StudentMessage;
18 | import com.aixuexiao.service.StudentService;
19 |
20 | /**
21 | * 包含学生列表菜单内的所有操作
22 | */
23 | @Controller
24 | public class StudentController {
25 |
26 | public static final int pagesize = 8;
27 |
28 | @Resource(name="studentService")
29 | private StudentService studentService;
30 |
31 | @RequestMapping(value="/manager/students",method=RequestMethod.GET)
32 | public ModelAndView listStudent(String pagenum,Student student){
33 | ModelAndView mv=new ModelAndView();
34 | mv.setViewName("students");
35 | mv.addObject("sidebar","students");
36 | int num = 1;
37 | if(null!=pagenum){
38 | num = Integer.parseInt(pagenum);
39 | }
40 | List list = studentService.listStudent((num-1)*pagesize, pagesize,student);
41 | List clslist = studentService.findAllClasses();
42 | mv.addObject("studentList", list);
43 | mv.addObject("clsList", clslist);
44 | mv.addObject("length", list.size());
45 | mv.addObject("pagenum", num);
46 | mv.addObject("student", student);
47 | return mv;
48 | }
49 |
50 |
51 | @RequestMapping(value="/manager/leavemessage",method=RequestMethod.GET)
52 | public ModelAndView leavemessage(int studentid){
53 | ModelAndView mv=new ModelAndView();
54 | Student student = studentService.findStudentById(studentid);
55 | if(null == student){
56 | mv.setViewName("redirect:/manager/students");
57 | }else{
58 | mv.setViewName("addstudentmessage");
59 | mv.addObject("sidebar","students");
60 | mv.addObject("student",student);
61 | List list = studentService.listMessageByStudentId(studentid, 100);
62 | mv.addObject("studentMessageList", list);
63 | }
64 | return mv;
65 | }
66 |
67 | @RequestMapping(value="/manager/examdetail",method=RequestMethod.GET)
68 | public ModelAndView examdetail(int studentid){
69 | ModelAndView mv=new ModelAndView();
70 | Student student = studentService.findStudentById(studentid);
71 | if(null == student){
72 | mv.setViewName("redirect:/manager/students");
73 | }else{
74 | mv.setViewName("examdetail");
75 | mv.addObject("sidebar","students");
76 | mv.addObject("student",student);
77 | List list = studentService.findExamMarkByStudentId(studentid, 100);
78 | mv.addObject("emlist", list);
79 | }
80 | return mv;
81 | }
82 |
83 | @RequestMapping(value="/manager/addmessage",method=RequestMethod.POST)
84 | public ModelAndView addmessage(StudentMessage studentMessage){
85 | ModelAndView mv=new ModelAndView();
86 | mv.setViewName("redirect:/manager/leavemessage");
87 | mv.addObject("studentid",studentMessage.getStudentid());
88 | studentMessage.setInserttime(new Date());
89 | studentService.addStudentMessage(studentMessage);
90 | mv.addObject("notice","留言成功");
91 | return mv;
92 | }
93 |
94 | @RequestMapping(value="/manager/deletemessage",method=RequestMethod.GET)
95 | public ModelAndView deletemessage(int studentid,int messageid){
96 | ModelAndView mv=new ModelAndView();
97 | mv.setViewName("redirect:/manager/leavemessage");
98 | mv.addObject("studentid",studentid);
99 | studentService.deleteStudentMessageById(messageid);
100 | mv.addObject("notice","删除成功");
101 | return mv;
102 | }
103 |
104 |
105 | }
106 |
--------------------------------------------------------------------------------
/src/com/aixuexiao/web/controller/WeixinController.java:
--------------------------------------------------------------------------------
1 | package com.aixuexiao.web.controller;
2 |
3 |
4 | import java.util.Date;
5 | import java.util.List;
6 | import java.util.Map;
7 |
8 | import javax.annotation.Resource;
9 | import javax.servlet.http.HttpServletRequest;
10 |
11 | import org.springframework.stereotype.Controller;
12 | import org.springframework.web.bind.annotation.RequestMapping;
13 | import org.springframework.web.bind.annotation.RequestMethod;
14 | import org.springframework.web.bind.annotation.ResponseBody;
15 | import org.springframework.web.servlet.ModelAndView;
16 |
17 | import com.aixuexiao.model.ExamMark;
18 | import com.aixuexiao.model.Message;
19 | import com.aixuexiao.model.Reply;
20 | import com.aixuexiao.service.WeixinService;
21 | import com.aixuexiao.util.WeixinUtil;
22 |
23 | @Controller()
24 | public class WeixinController {
25 |
26 | private static final String TOKEN = "aixuexiao";
27 |
28 | public static int pagesize = 10;
29 |
30 | @Resource(name="weixinService")
31 | private WeixinService weixinService;
32 |
33 | @RequestMapping(value="/test",method=RequestMethod.GET,produces="text/html;charset=UTF-8")
34 | @ResponseBody
35 | public String test(HttpServletRequest request){
36 | return weixinService.getStudentMessageHistoryByStudentId(30202);
37 | }
38 |
39 |
40 | //接收微信公众号接收的消息,处理后再做相应的回复
41 | @RequestMapping(value="/weixin",method=RequestMethod.POST,produces="text/html;charset=UTF-8")
42 | @ResponseBody
43 | public String replyMessage(HttpServletRequest request){
44 | //仅处理微信服务端发的请求
45 | if (checkWeixinReques(request)) {
46 | Map requestMap = WeixinUtil.parseXml(request);
47 | Message message = WeixinUtil.mapToMessage(requestMap);
48 | weixinService.addMessage(message);//保存接受消息到数据库
49 | String replyContent = Reply.WELCOME_CONTENT;
50 | String type = message.getMsgType();
51 | if (type.equals(Message.TEXT)) {//仅处理文本回复内容
52 | String content = message.getContent();//消息内容
53 | String [] cs = content.split("_");//消息内容都以下划线_分隔
54 | if(cs.length == 2){
55 | int studentid ;//学生编号
56 | String process = cs[1];//操作
57 | try {
58 | studentid = Integer.parseInt(cs[0]);
59 | if("考试".equals(process)){
60 | replyContent = weixinService.getSingleExamMarkStringByStudentId(studentid);
61 | }else if("考试历史".equals(process)){
62 | replyContent = weixinService.getExamMarkHistoryStringByStudentId(studentid);
63 | }else if("留言".equals(process)){
64 | replyContent = weixinService.getSingleStudentMessageByStudentId(studentid);
65 | }else if("留言历史".equals(process)){
66 | replyContent = weixinService.getStudentMessageHistoryByStudentId(studentid);
67 | }else if("动态".equals(process)){
68 | replyContent = weixinService.getSingleClassesNewsByStudentId(studentid);
69 | }else if("动态历史".equals(process)){
70 | replyContent = weixinService.getClassesNewsHistoryByStudentId(studentid);
71 | }
72 | } catch (NumberFormatException e) {
73 | replyContent = Reply.ERROR_CONTENT;
74 | }
75 | }
76 | }
77 | //拼装回复消息
78 | Reply reply = new Reply();
79 | reply.setToUserName(message.getFromUserName());
80 | reply.setFromUserName(message.getToUserName());
81 | reply.setCreateTime(new Date());
82 | reply.setMsgType(Reply.TEXT);
83 | reply.setContent(replyContent);
84 | weixinService.addReply(reply);//保存回复消息到数据库
85 | //将回复消息序列化为xml形式
86 | String back = WeixinUtil.replyToXml(reply);
87 | System.out.println(back);
88 | return back;
89 | }else{
90 | return "error";
91 | }
92 | }
93 |
94 |
95 | //微信公众平台验证url是否有效使用的接口
96 | @RequestMapping(value="/weixin",method=RequestMethod.GET,produces="text/html;charset=UTF-8")
97 | @ResponseBody
98 | public String initWeixinURL(HttpServletRequest request){
99 | String echostr = request.getParameter("echostr");
100 | if (checkWeixinReques(request) && echostr != null) {
101 | return echostr;
102 | }else{
103 | return "error";
104 | }
105 | }
106 |
107 |
108 | /**
109 | * 根据token计算signature验证是否为weixin服务端发送的消息
110 | */
111 | private static boolean checkWeixinReques(HttpServletRequest request){
112 | String signature = request.getParameter("signature");
113 | String timestamp = request.getParameter("timestamp");
114 | String nonce = request.getParameter("nonce");
115 | if (signature != null && timestamp != null && nonce != null ) {
116 | String[] strSet = new String[] { TOKEN, timestamp, nonce };
117 | java.util.Arrays.sort(strSet);
118 | String key = "";
119 | for (String string : strSet) {
120 | key = key + string;
121 | }
122 | String pwd = WeixinUtil.sha1(key);
123 | return pwd.equals(signature);
124 | }else {
125 | return false;
126 | }
127 | }
128 |
129 | /**
130 | * 收到消息列表页面
131 | */
132 | @RequestMapping(value="/manager/messages",method=RequestMethod.GET)
133 | public ModelAndView listMessage(String pagenum){
134 | ModelAndView mv=new ModelAndView();
135 | mv.addObject("sidebar","messages");
136 | mv.setViewName("messages");
137 | int num = 1;
138 | if(null!=pagenum){
139 | num = Integer.parseInt(pagenum);
140 | }
141 | List list = weixinService.listMessage((num-1)*pagesize, pagesize);
142 | mv.addObject("messageList", list);
143 | mv.addObject("pagenum", num);
144 | mv.addObject("length", list.size());
145 | return mv;
146 | }
147 |
148 |
149 | /**
150 | * 回复消息列表页面
151 | */
152 | @RequestMapping(value="/manager/replys",method=RequestMethod.GET)
153 | public ModelAndView listReply(String pagenum){
154 | ModelAndView mv=new ModelAndView();
155 | mv.addObject("sidebar","replys");
156 | mv.setViewName("replys");
157 | int num = 1;
158 | if(null!=pagenum){
159 | num = Integer.parseInt(pagenum);
160 | }
161 | List list = weixinService.listReply((num-1)*pagesize, pagesize);
162 | mv.addObject("replyList", list);
163 | mv.addObject("pagenum", num);
164 | mv.addObject("length", list.size());
165 | return mv;
166 | }
167 |
168 |
169 |
170 | }
171 |
--------------------------------------------------------------------------------
/src/com/aixuexiao/web/interceptor/ManagerInterceptor.java:
--------------------------------------------------------------------------------
1 | package com.aixuexiao.web.interceptor;
2 |
3 | import javax.servlet.http.HttpServletRequest;
4 | import javax.servlet.http.HttpServletResponse;
5 |
6 | import org.springframework.web.servlet.HandlerInterceptor;
7 | import org.springframework.web.servlet.ModelAndView;
8 |
9 | /**
10 | * 用于过滤未登陆用户访问管理内容的拦截器
11 | * @author lizy
12 | */
13 | public class ManagerInterceptor implements HandlerInterceptor{
14 |
15 | @Override
16 | public void afterCompletion(HttpServletRequest request,
17 | HttpServletResponse response, Object obj, Exception e)
18 | throws Exception {
19 | }
20 |
21 | @Override
22 | public void postHandle(HttpServletRequest request, HttpServletResponse response,
23 | Object obj, ModelAndView mav) throws Exception {
24 | }
25 |
26 | @Override
27 | public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object obj) throws Exception {
28 | request.setCharacterEncoding("UTF-8");
29 | if(request.getSession().getAttribute("user")!=null){
30 | return true;
31 | }else{
32 | response.sendRedirect(request.getContextPath()+"/");
33 | //System.out.println("request.getSession().getAttribute(\"user\")"+request.getSession().getAttribute("user"));
34 | return false;
35 | }
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/src/db.properties:
--------------------------------------------------------------------------------
1 | db.read.database=app_aixuexiao
2 | db.read.host=r.rdc.sae.sina.com.cn
3 | db.read.port=3307
4 | db.read.userName=ak
5 | db.read.password=sk
6 |
7 |
8 | db.write.database=app_aixuexiao
9 | db.write.host=w.rdc.sae.sina.com.cn
10 | db.write.port=3307
11 | db.write.userName=ak
12 | db.write.password=sk
13 |
14 |
15 |
--------------------------------------------------------------------------------
/src/log4j.properties:
--------------------------------------------------------------------------------
1 | log4j.rootLogger=INFO,console
2 | log4j.appender.console=org.apache.log4j.ConsoleAppender
3 | log4j.appender.console.layout=org.apache.log4j.PatternLayout
4 | log4j.appender.console.layout.ConversionPattern=%d{yyyy-MM-dd HH\:mm\:ss,SSS} %5p %c\:(%F\:%L) %n - %m%n
5 |
6 |
7 |
--------------------------------------------------------------------------------
/src/spring.xml:
--------------------------------------------------------------------------------
1 |
2 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
22 |
23 |
24 | classpath:db.properties
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
--------------------------------------------------------------------------------
/src/sqlMapConfig.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
--------------------------------------------------------------------------------