', { 'class': 'faq-toc' });
152 |
153 | $toc.html (html);
154 |
155 | return $toc;
156 |
157 | }
158 | };
159 | })(jQuery);
--------------------------------------------------------------------------------
/WebRoot/js/index.js:
--------------------------------------------------------------------------------
1 | $(function(){
2 |
3 | //个人信息和用户名之间的间隙~动态变化
4 | var distance=110; //
5 | var width=$('.user').width(); //获取宽度
6 | $('.info').css('right',distance+(width-115));
7 |
8 | var box_height;
9 | var time=null;
10 | function height_change(){
11 | time=setInterval(function(){
12 | box_height=$(document).outerHeight(true);
13 | $('.box').css('height',box_height);
14 | $('.box .box1').css('height',$(window).height());
15 | },100)
16 | }
17 | height_change();
18 |
19 |
20 | //菜单栏
21 | $('.menu p').click(function(){
22 | $(this).parent().find('.second').slideToggle();
23 | $(this).parent().siblings().find('.second').slideUp();
24 | $(this).addClass('active');
25 | $(this).parent().siblings().find('p').removeClass('active');
26 | })
27 |
28 | //点击菜单,显示右边内容
29 | $('.menu li').click(function(){
30 | var id= $(this).attr("id");//获取属性为id的值
31 | if(id!=undefined){
32 | var str=".content_"+id;
33 | $(str).show().siblings().hide();
34 |
35 | }
36 | })
37 |
38 | //用户信息
39 | $('.info ul li:nth-of-type(1)').click(function(e){
40 | e.stopPropagation();
41 | $('.alter').fadeToggle();
42 |
43 | })
44 |
45 | $('div.info ul li.alter').click(function(e){
46 | e.stopPropagation();
47 | })
48 |
49 | $('#alterInfo').click(function(e){
50 | e.stopPropagation();
51 | $('.box').show();
52 | $('.box_alterInfo').show();
53 | box.loaduserinfo();
54 | })
55 | $('#alterPsw').click(function(e){
56 | e.stopPropagation();
57 | $('.box').show();
58 | $('.box_alterPsw').show();
59 | })
60 | $('#showrecords').click(function(e){
61 | e.stopPropagation();
62 | $('.box').show();
63 | $('.box_showrecords').show();
64 | box.loadrecords();
65 | })
66 |
67 | $(document).click(function(e){
68 | var name=e.target.className;
69 | if(name!="box" && name!="box1" &&name!="x_p" && name!="box_alterInfo" && name!="box_alterPsw"
70 | && name!="box_showrecords"){
71 | $('.alter').fadeOut(); //点击其他地方,个人信息菜单收起来
72 | } else {
73 | //重置input内容
74 | $('#oldpsw').val("");
75 | $('#newpsw').val("");
76 | $('#confirmpsw').val("");
77 | $("#username").attr("readonly","readonly");
78 | $("#sex").css("display","block");
79 | $("#radiosex").css("display","none");
80 | $("#email").attr("readonly","readonly");
81 | $("#updateinfo").css("display","block");
82 | $("#confirmupdate").css("display","none");
83 | }
84 | if(name=="box"||name=="box1"){
85 | $('.box').hide();
86 | $('.box_alterInfo').hide();
87 | $('.box_alterPsw').hide();
88 | $('.box_showrecords').hide();
89 | }
90 | })
91 |
92 | $('.x p').click(function(){
93 | $('.box').hide();
94 | $('.box_alterInfo').hide();
95 | $('.box_alterPsw').hide();
96 | $('.box_showrecords').hide();
97 |
98 | })
99 |
100 | $("#updateinfo").click(function(){
101 | $("#username").removeAttr("readonly");
102 | $("#sex").css("display","none");
103 | $("#radiosex").css("display","block");
104 | $("#email").removeAttr("readonly");
105 | $(this).css("display","none");
106 | $("#confirmupdate").css("display","block");
107 | });
108 |
109 | });
110 |
111 | function is_email(email){
112 | reg=/^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((\.[a-zA-Z0-9_-]{2,3}){1,2})$/;
113 | if(email == ""){
114 | return false;
115 | }
116 | else if(! reg.test(email)) {
117 | return false;
118 | }
119 | return true;
120 | };
--------------------------------------------------------------------------------
/WebRoot/js/jquery.flot.orderBars.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Flot plugin to order bars side by side.
3 | *
4 | * Released under the MIT license by Benjamin BUFFET, 20-Sep-2010.
5 | *
6 | * This plugin is an alpha version.
7 | *
8 | * To activate the plugin you must specify the parameter "order" for the specific serie :
9 | *
10 | * $.plot($("#placeholder"), [{ data: [ ... ], bars :{ order = null or integer }])
11 | *
12 | * If 2 series have the same order param, they are ordered by the position in the array;
13 | *
14 | * The plugin adjust the point by adding a value depanding of the barwidth
15 | * Exemple for 3 series (barwidth : 0.1) :
16 | *
17 | * first bar décalage : -0.15
18 | * second bar décalage : -0.05
19 | * third bar décalage : 0.05
20 | *
21 | */
22 |
23 | (function($){
24 | function init(plot){
25 | var orderedBarSeries;
26 | var nbOfBarsToOrder;
27 | var borderWidth;
28 | var borderWidthInXabsWidth;
29 | var pixelInXWidthEquivalent = 1;
30 | var isHorizontal = false;
31 |
32 | /*
33 | * This method add shift to x values
34 | */
35 | function reOrderBars(plot, serie, datapoints){
36 | var shiftedPoints = null;
37 |
38 | if(serieNeedToBeReordered(serie)){
39 | checkIfGraphIsHorizontal(serie);
40 | calculPixel2XWidthConvert(plot);
41 | retrieveBarSeries(plot);
42 | calculBorderAndBarWidth(serie);
43 |
44 | if(nbOfBarsToOrder >= 2){
45 | var position = findPosition(serie);
46 | var decallage = 0;
47 |
48 | var centerBarShift = calculCenterBarShift();
49 |
50 | if (isBarAtLeftOfCenter(position)){
51 | decallage = -1*(sumWidth(orderedBarSeries,position-1,Math.floor(nbOfBarsToOrder / 2)-1)) - centerBarShift;
52 | }else{
53 | decallage = sumWidth(orderedBarSeries,Math.ceil(nbOfBarsToOrder / 2),position-2) + centerBarShift + borderWidthInXabsWidth*2;
54 | }
55 |
56 | shiftedPoints = shiftPoints(datapoints,serie,decallage);
57 | datapoints.points = shiftedPoints;
58 | }
59 | }
60 | return shiftedPoints;
61 | }
62 |
63 | function serieNeedToBeReordered(serie){
64 | return serie.bars != null
65 | && serie.bars.show
66 | && serie.bars.order != null;
67 | }
68 |
69 | function calculPixel2XWidthConvert(plot){
70 | var gridDimSize = isHorizontal ? plot.getPlaceholder().innerHeight() : plot.getPlaceholder().innerWidth();
71 | var minMaxValues = isHorizontal ? getAxeMinMaxValues(plot.getData(),1) : getAxeMinMaxValues(plot.getData(),0);
72 | var AxeSize = minMaxValues[1] - minMaxValues[0];
73 | pixelInXWidthEquivalent = AxeSize / gridDimSize;
74 | }
75 |
76 | function getAxeMinMaxValues(series,AxeIdx){
77 | var minMaxValues = new Array();
78 | for(var i = 0; i < series.length; i++){
79 | minMaxValues[0] = series[i].data[0][AxeIdx];
80 | minMaxValues[1] = series[i].data[series[i].data.length - 1][AxeIdx];
81 | }
82 | return minMaxValues;
83 | }
84 |
85 | function retrieveBarSeries(plot){
86 | orderedBarSeries = findOthersBarsToReOrders(plot.getData());
87 | nbOfBarsToOrder = orderedBarSeries.length;
88 | }
89 |
90 | function findOthersBarsToReOrders(series){
91 | var retSeries = new Array();
92 |
93 | for(var i = 0; i < series.length; i++){
94 | if(series[i].bars.order != null && series[i].bars.show){
95 | retSeries.push(series[i]);
96 | }
97 | }
98 |
99 | return retSeries.sort(sortByOrder);
100 | }
101 |
102 | function sortByOrder(serie1,serie2){
103 | var x = serie1.bars.order;
104 | var y = serie2.bars.order;
105 | return ((x < y) ? -1 : ((x > y) ? 1 : 0));
106 | }
107 |
108 | function calculBorderAndBarWidth(serie){
109 | borderWidth = serie.bars.lineWidth ? serie.bars.lineWidth : 2;
110 | borderWidthInXabsWidth = borderWidth * pixelInXWidthEquivalent;
111 | }
112 |
113 | function checkIfGraphIsHorizontal(serie){
114 | if(serie.bars.horizontal){
115 | isHorizontal = true;
116 | }
117 | }
118 |
119 | function findPosition(serie){
120 | var pos = 0
121 | for (var i = 0; i < orderedBarSeries.length; ++i) {
122 | if (serie == orderedBarSeries[i]){
123 | pos = i;
124 | break;
125 | }
126 | }
127 |
128 | return pos+1;
129 | }
130 |
131 | function calculCenterBarShift(){
132 | var width = 0;
133 |
134 | if(nbOfBarsToOrder%2 != 0)
135 | width = (orderedBarSeries[Math.ceil(nbOfBarsToOrder / 2)].bars.barWidth)/2;
136 |
137 | return width;
138 | }
139 |
140 | function isBarAtLeftOfCenter(position){
141 | return position <= Math.ceil(nbOfBarsToOrder / 2);
142 | }
143 |
144 | function sumWidth(series,start,end){
145 | var totalWidth = 0;
146 |
147 | for(var i = start; i <= end; i++){
148 | totalWidth += series[i].bars.barWidth+borderWidthInXabsWidth*2;
149 | }
150 |
151 | return totalWidth;
152 | }
153 |
154 | function shiftPoints(datapoints,serie,dx){
155 | var ps = datapoints.pointsize;
156 | var points = datapoints.points;
157 | var j = 0;
158 | for(var i = isHorizontal ? 1 : 0;i < points.length; i += ps){
159 | points[i] += dx;
160 | //Adding the new x value in the serie to be abble to display the right tooltip value,
161 | //using the index 3 to not overide the third index.
162 | serie.data[j][3] = points[i];
163 | j++;
164 | }
165 |
166 | return points;
167 | }
168 |
169 | plot.hooks.processDatapoints.push(reOrderBars);
170 |
171 | }
172 |
173 | var options = {
174 | series : {
175 | bars: {order: null} // or number/string
176 | }
177 | };
178 |
179 | $.plot.plugins.push({
180 | init: init,
181 | options: options,
182 | name: "orderBars",
183 | version: "0.2"
184 | });
185 |
186 | })(jQuery)
--------------------------------------------------------------------------------
/WebRoot/js/jquery.flot.resize.js:
--------------------------------------------------------------------------------
1 | /*
2 | Flot plugin for automatically redrawing plots when the placeholder
3 | size changes, e.g. on window resizes.
4 |
5 | It works by listening for changes on the placeholder div (through the
6 | jQuery resize event plugin) - if the size changes, it will redraw the
7 | plot.
8 |
9 | There are no options. If you need to disable the plugin for some
10 | plots, you can just fix the size of their placeholders.
11 | */
12 |
13 |
14 | /* Inline dependency:
15 | * jQuery resize event - v1.1 - 3/14/2010
16 | * http://benalman.com/projects/jquery-resize-plugin/
17 | *
18 | * Copyright (c) 2010 "Cowboy" Ben Alman
19 | * Dual licensed under the MIT and GPL licenses.
20 | * http://benalman.com/about/license/
21 | */
22 | (function($,h,c){var a=$([]),e=$.resize=$.extend($.resize,{}),i,k="setTimeout",j="resize",d=j+"-special-event",b="delay",f="throttleWindow";e[b]=250;e[f]=true;$.event.special[j]={setup:function(){if(!e[f]&&this[k]){return false}var l=$(this);a=a.add(l);$.data(this,d,{w:l.width(),h:l.height()});if(a.length===1){g()}},teardown:function(){if(!e[f]&&this[k]){return false}var l=$(this);a=a.not(l);l.removeData(d);if(!a.length){clearTimeout(i)}},add:function(l){if(!e[f]&&this[k]){return false}var n;function m(s,o,p){var q=$(this),r=$.data(this,d);r.w=o!==c?o:q.width();r.h=p!==c?p:q.height();n.apply(this,arguments)}if($.isFunction(l)){n=l;return m}else{n=l.handler;l.handler=m}}};function g(){i=h[k](function(){a.each(function(){var n=$(this),m=n.width(),l=n.height(),o=$.data(this,d);if(m!==o.w||l!==o.h){n.trigger(j,[o.w=m,o.h=l])}});g()},e[b])}})(jQuery,this);
23 |
24 |
25 | (function ($) {
26 | var redrawing = 0;
27 | var options = { }; // no options
28 |
29 | function init(plot) {
30 | function bindEvents(plot, eventHolder) {
31 | if (!redrawing)
32 | plot.getPlaceholder().resize(onResize);
33 |
34 | function onResize() {
35 | var placeholder = plot.getPlaceholder();
36 |
37 | // somebody might have hidden us and we can't plot
38 | // when we don't have the dimensions
39 | if (placeholder.width() == 0 || placeholder.height() == 0)
40 | return;
41 |
42 | ++redrawing;
43 | $.plot(placeholder, plot.getData(), plot.getOptions());
44 | --redrawing;
45 | }
46 | }
47 |
48 | plot.hooks.bindEvents.push(bindEvents);
49 | }
50 |
51 | $.plot.plugins.push({
52 | init: init,
53 | options: options,
54 | name: 'resize',
55 | version: '1.0'
56 | });
57 | })(jQuery);
--------------------------------------------------------------------------------
/WebRoot/js/knowledgeAnswer.js:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/malizhigithub/answerWeb/75d419d7396b4085a33f282506422e3c16daa05d/WebRoot/js/knowledgeAnswer.js
--------------------------------------------------------------------------------
/WebRoot/js/login_register.js:
--------------------------------------------------------------------------------
1 | $(function(){
2 | var num=1;
3 | var time=null;
4 | function change(){ //背景图片切换
5 | time=setInterval(function(){
6 | num++;
7 | if(num>2) num=1;
8 | var str=".bg"+num;
9 | $(str).fadeIn().siblings().fadeOut();
10 | },3000)
11 | }
12 | change();
13 |
14 |
15 | //验证邮箱
16 | $('#email').blur(function(){
17 | var email=$('#email').val();
18 | if(is_email(email)){
19 | $('.email_error').html("");
20 | }else{
21 | $('.email_error').html("电子邮箱格式不正确");
22 | }
23 |
24 | })
25 |
26 | function is_email(email){
27 | reg=/^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((\.[a-zA-Z0-9_-]{2,3}){1,2})$/;
28 | if(email == ""){
29 | return false;
30 | }
31 | else if(! reg.test(email)) {
32 | return false;
33 | }
34 | return true;
35 | }
36 |
37 | })
--------------------------------------------------------------------------------
/WebRoot/login.jsp:
--------------------------------------------------------------------------------
1 | <%@ page language="java" contentType="text/html; charset=UTF-8"
2 | pageEncoding="UTF-8"%>
3 | <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
4 |
5 |
6 |
7 |
8 |
登录
9 |
10 |
11 |
12 |
13 |
14 |
15 |
19 |
20 |
21 | 登录
22 |
23 |
24 | ${loginerror}
25 |
26 |
47 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/WebRoot/register.jsp:
--------------------------------------------------------------------------------
1 | <%@ page language="java" contentType="text/html; charset=UTF-8"
2 | pageEncoding="UTF-8"%>
3 | <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
4 |
5 |
6 |
7 |
8 |
注册
9 |
10 |
11 |
12 |
13 |
14 |
15 |
19 |
20 |
21 | 注册
22 |
23 |
24 | ${error}
25 |
26 |
55 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/WebRoot/resource/images/Exit.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/malizhigithub/answerWeb/75d419d7396b4085a33f282506422e3c16daa05d/WebRoot/resource/images/Exit.png
--------------------------------------------------------------------------------
/WebRoot/resource/images/arrow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/malizhigithub/answerWeb/75d419d7396b4085a33f282506422e3c16daa05d/WebRoot/resource/images/arrow.png
--------------------------------------------------------------------------------
/WebRoot/resource/images/arrow_white.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/malizhigithub/answerWeb/75d419d7396b4085a33f282506422e3c16daa05d/WebRoot/resource/images/arrow_white.png
--------------------------------------------------------------------------------
/WebRoot/resource/images/banner_01.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/malizhigithub/answerWeb/75d419d7396b4085a33f282506422e3c16daa05d/WebRoot/resource/images/banner_01.png
--------------------------------------------------------------------------------
/WebRoot/resource/images/banner_02.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/malizhigithub/answerWeb/75d419d7396b4085a33f282506422e3c16daa05d/WebRoot/resource/images/banner_02.png
--------------------------------------------------------------------------------
/WebRoot/resource/images/bg1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/malizhigithub/answerWeb/75d419d7396b4085a33f282506422e3c16daa05d/WebRoot/resource/images/bg1.jpg
--------------------------------------------------------------------------------
/WebRoot/resource/images/body-bg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/malizhigithub/answerWeb/75d419d7396b4085a33f282506422e3c16daa05d/WebRoot/resource/images/body-bg.png
--------------------------------------------------------------------------------
/WebRoot/resource/images/content_topic.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/malizhigithub/answerWeb/75d419d7396b4085a33f282506422e3c16daa05d/WebRoot/resource/images/content_topic.png
--------------------------------------------------------------------------------
/WebRoot/resource/images/find.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/malizhigithub/answerWeb/75d419d7396b4085a33f282506422e3c16daa05d/WebRoot/resource/images/find.jpg
--------------------------------------------------------------------------------
/WebRoot/resource/images/headshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/malizhigithub/answerWeb/75d419d7396b4085a33f282506422e3c16daa05d/WebRoot/resource/images/headshot.png
--------------------------------------------------------------------------------
/WebRoot/resource/images/icon1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/malizhigithub/answerWeb/75d419d7396b4085a33f282506422e3c16daa05d/WebRoot/resource/images/icon1.png
--------------------------------------------------------------------------------
/WebRoot/resource/images/icon2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/malizhigithub/answerWeb/75d419d7396b4085a33f282506422e3c16daa05d/WebRoot/resource/images/icon2.png
--------------------------------------------------------------------------------
/WebRoot/resource/images/icon_nav_answer.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/malizhigithub/answerWeb/75d419d7396b4085a33f282506422e3c16daa05d/WebRoot/resource/images/icon_nav_answer.png
--------------------------------------------------------------------------------
/WebRoot/resource/images/icon_nav_people.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/malizhigithub/answerWeb/75d419d7396b4085a33f282506422e3c16daa05d/WebRoot/resource/images/icon_nav_people.png
--------------------------------------------------------------------------------
/WebRoot/resource/images/icon_tabbar.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/malizhigithub/answerWeb/75d419d7396b4085a33f282506422e3c16daa05d/WebRoot/resource/images/icon_tabbar.png
--------------------------------------------------------------------------------
/WebRoot/resource/images/logo.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/malizhigithub/answerWeb/75d419d7396b4085a33f282506422e3c16daa05d/WebRoot/resource/images/logo.jpg
--------------------------------------------------------------------------------
/WebRoot/resource/images/selection/1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/malizhigithub/answerWeb/75d419d7396b4085a33f282506422e3c16daa05d/WebRoot/resource/images/selection/1.png
--------------------------------------------------------------------------------
/WebRoot/resource/images/selection/2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/malizhigithub/answerWeb/75d419d7396b4085a33f282506422e3c16daa05d/WebRoot/resource/images/selection/2.png
--------------------------------------------------------------------------------
/WebRoot/resource/images/selection/3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/malizhigithub/answerWeb/75d419d7396b4085a33f282506422e3c16daa05d/WebRoot/resource/images/selection/3.png
--------------------------------------------------------------------------------
/WebRoot/resource/images/selection/4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/malizhigithub/answerWeb/75d419d7396b4085a33f282506422e3c16daa05d/WebRoot/resource/images/selection/4.png
--------------------------------------------------------------------------------
/WebRoot/success.jsp:
--------------------------------------------------------------------------------
1 | <%@ page language="java" contentType="text/html; charset=UTF-8"
2 | pageEncoding="UTF-8"%>
3 | <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
4 |
5 |
6 |
7 |
8 |
成功
9 |
10 |
17 |
18 |
19 |
25 |
26 |
39 |
--------------------------------------------------------------------------------
/WebRoot/wechatuser/index2.jsp:
--------------------------------------------------------------------------------
1 | <%@ page language="java" contentType="text/html; charset=UTF-8"
2 | pageEncoding="UTF-8"%>
3 | <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
4 |
5 |
6 |
7 |
8 |
9 |
类型
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
下拉刷新
50 |
释放刷新
51 |
正在刷新
52 |
53 |
71 |
72 |
124 |
--------------------------------------------------------------------------------
/config/applicationContext.xml:
--------------------------------------------------------------------------------
1 |
2 |
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 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
--------------------------------------------------------------------------------
/config/dbconfig.properties:
--------------------------------------------------------------------------------
1 | jdbc.jdbcUrl=jdbc:mysql://xxx.xxx.xxx.xxx:3306/answerWeb?characterEncoding=utf8
2 | jdbc.driverClass=com.mysql.jdbc.Driver
3 | jdbc.user=xxx
4 | jdbc.password=xxx
--------------------------------------------------------------------------------
/config/mapper/testMapper.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
8 |
9 |
--------------------------------------------------------------------------------
/config/mybatis-config.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/mysqlGeneratorConfig.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
41 |
42 |
43 |
44 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
--------------------------------------------------------------------------------
/repository/org/apache/apache/10/_remote.repositories:
--------------------------------------------------------------------------------
1 | #NOTE: This is an Aether internal implementation file, its format can be changed without prior notice.
2 | #Sat Mar 24 09:59:35 CST 2018
3 | apache-10.pom>alimaven=
4 |
--------------------------------------------------------------------------------
/repository/org/apache/apache/10/apache-10.pom.sha1:
--------------------------------------------------------------------------------
1 |
2 | 48296e511366fa13aad48c58d8e09721774abec6
--------------------------------------------------------------------------------
/repository/org/apache/apache/3/_remote.repositories:
--------------------------------------------------------------------------------
1 | #NOTE: This is an Aether internal implementation file, its format can be changed without prior notice.
2 | #Sat Mar 24 09:59:36 CST 2018
3 | apache-3.pom>alimaven=
4 |
--------------------------------------------------------------------------------
/repository/org/apache/apache/3/apache-3.pom:
--------------------------------------------------------------------------------
1 |
2 |
3 |
18 |
19 |
21 | 4.0.0
22 |
23 |
25 | org.apache
26 | apache
27 | 3
28 | pom
29 | The Apache Software Foundation
30 |
31 | The Apache Software Foundation provides support for the Apache community of open-source software projects.
32 | The Apache projects are characterized by a collaborative, consensus based development process, an open and
33 | pragmatic software license, and a desire to create high quality software that leads the way in its field.
34 | We consider ourselves not simply a group of projects sharing a server, but rather a community of developers
35 | and users.
36 |
37 |
38 |
39 | The Apache Software License, Version 2.0
40 | http://www.apache.org/licenses/LICENSE-2.0.txt
41 | repo
42 |
43 |
44 |
45 | Apache Software Foundation
46 | http://www.apache.org/
47 |
48 | http://www.apache.org/
49 |
50 |
51 | apache.snapshots
52 | Apache Snapshot Repository
53 | http://people.apache.org/repo/m2-snapshot-repository
54 |
55 | false
56 |
57 |
58 |
59 |
60 |
61 |
62 | apache.releases
63 | Apache Release Distribution Repository
64 | scp://people.apache.org/www/people.apache.org/repo/m2-ibiblio-rsync-repository
65 |
66 |
67 | apache.snapshots
68 | Apache Development Snapshot Repository
69 | scp://people.apache.org/www/people.apache.org/repo/m2-snapshot-repository
70 |
71 |
72 |
73 |
74 | Apache Announce List
75 | announce-subscribe@apache.org
76 | announce-unsubscribe@apache.org
77 | announce@apache.org
78 | http://mail-archives.apache.org/mod_mbox/www-announce/
79 |
80 |
81 |
82 |
83 |
--------------------------------------------------------------------------------
/repository/org/apache/apache/3/apache-3.pom.sha1:
--------------------------------------------------------------------------------
1 |
2 | 1bc0010136a890e2fd38d901a0b7ecdf0e3f9871
--------------------------------------------------------------------------------
/repository/org/apache/maven/maven-parent/21/_remote.repositories:
--------------------------------------------------------------------------------
1 | #NOTE: This is an Aether internal implementation file, its format can be changed without prior notice.
2 | #Sat Mar 24 09:59:35 CST 2018
3 | maven-parent-21.pom>alimaven=
4 |
--------------------------------------------------------------------------------
/repository/org/apache/maven/maven-parent/21/maven-parent-21.pom.sha1:
--------------------------------------------------------------------------------
1 |
2 | 0ecebf1043d9c7bdd3d32a4184ad4ef9ad3ea744
--------------------------------------------------------------------------------
/repository/org/apache/maven/maven-parent/5/_remote.repositories:
--------------------------------------------------------------------------------
1 | #NOTE: This is an Aether internal implementation file, its format can be changed without prior notice.
2 | #Sat Mar 24 09:59:36 CST 2018
3 | maven-parent-5.pom>alimaven=
4 |
--------------------------------------------------------------------------------
/repository/org/apache/maven/maven-parent/5/maven-parent-5.pom.sha1:
--------------------------------------------------------------------------------
1 |
2 | 5c1ab38decaca1ccd08294aeab135047ebbae00d
--------------------------------------------------------------------------------
/repository/org/apache/maven/maven-plugin-api/2.0.6/_remote.repositories:
--------------------------------------------------------------------------------
1 | #NOTE: This is an Aether internal implementation file, its format can be changed without prior notice.
2 | #Sat Mar 24 09:59:38 CST 2018
3 | maven-plugin-api-2.0.6.pom>alimaven=
4 | maven-plugin-api-2.0.6.jar>alimaven=
5 |
--------------------------------------------------------------------------------
/repository/org/apache/maven/maven-plugin-api/2.0.6/maven-plugin-api-2.0.6.jar.sha1:
--------------------------------------------------------------------------------
1 |
2 | 52b32fd980c8ead7a3858d057330bda1ace72d9d
--------------------------------------------------------------------------------
/repository/org/apache/maven/maven-plugin-api/2.0.6/maven-plugin-api-2.0.6.pom:
--------------------------------------------------------------------------------
1 |
2 |
3 |
21 |
22 |
23 |
24 | maven
25 | org.apache.maven
26 | 2.0.6
27 |
28 | 4.0.0
29 | maven-plugin-api
30 | Maven Plugin API
31 |
32 |
33 | junit
34 | junit
35 | 3.8.1
36 | test
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/repository/org/apache/maven/maven-plugin-api/2.0.6/maven-plugin-api-2.0.6.pom.sha1:
--------------------------------------------------------------------------------
1 |
2 | 3af72b052dfefb73ecfae742613012b5396c8863
--------------------------------------------------------------------------------
/repository/org/apache/maven/maven/2.0.6/_remote.repositories:
--------------------------------------------------------------------------------
1 | #NOTE: This is an Aether internal implementation file, its format can be changed without prior notice.
2 | #Sat Mar 24 09:59:36 CST 2018
3 | maven-2.0.6.pom>alimaven=
4 |
--------------------------------------------------------------------------------
/repository/org/apache/maven/maven/2.0.6/maven-2.0.6.pom.sha1:
--------------------------------------------------------------------------------
1 |
2 | 1991be0ed3e1820e135201406d5acabf8c08d426
--------------------------------------------------------------------------------
/repository/org/apache/maven/plugins/maven-clean-plugin/2.5/_remote.repositories:
--------------------------------------------------------------------------------
1 | #NOTE: This is an Aether internal implementation file, its format can be changed without prior notice.
2 | #Sat Mar 24 09:59:35 CST 2018
3 | maven-clean-plugin-2.5.jar>alimaven=
4 | maven-clean-plugin-2.5.pom>alimaven=
5 |
--------------------------------------------------------------------------------
/repository/org/apache/maven/plugins/maven-clean-plugin/2.5/maven-clean-plugin-2.5.jar.sha1:
--------------------------------------------------------------------------------
1 |
2 | 75653decaefa85ca8114ff3a4f869bb2ee6d605d
--------------------------------------------------------------------------------
/repository/org/apache/maven/plugins/maven-clean-plugin/2.5/maven-clean-plugin-2.5.pom:
--------------------------------------------------------------------------------
1 |
2 |
3 |
21 |
22 |
23 | 4.0.0
24 |
25 |
26 | org.apache.maven.plugins
27 | maven-plugins
28 | 22
29 | ../maven-plugins/pom.xml
30 |
31 |
32 | maven-clean-plugin
33 | 2.5
34 | maven-plugin
35 |
36 | Maven Clean Plugin
37 |
38 | The Maven Clean Plugin is a plugin that removes files generated at build-time in a project's directory.
39 |
40 | 2001
41 |
42 |
43 | ${mavenVersion}
44 |
45 |
46 |
47 | scm:svn:http://svn.apache.org/repos/asf/maven/plugins/tags/maven-clean-plugin-2.5
48 | scm:svn:https://svn.apache.org/repos/asf/maven/plugins/tags/maven-clean-plugin-2.5
49 | http://svn.apache.org/viewvc/maven/plugins/tags/maven-clean-plugin-2.5
50 |
51 |
52 | JIRA
53 | http://jira.codehaus.org/browse/MCLEAN
54 |
55 |
56 |
57 | 2.0.6
58 |
59 |
60 |
61 |
62 | org.apache.maven
63 | maven-plugin-api
64 | ${mavenVersion}
65 |
66 |
67 | org.codehaus.plexus
68 | plexus-utils
69 | 3.0
70 |
71 |
72 |
73 |
74 | org.apache.maven.shared
75 | maven-plugin-testing-harness
76 | 1.1
77 | test
78 |
79 |
80 |
81 |
82 |
83 | run-its
84 |
85 |
86 |
87 |
88 | org.apache.maven.plugins
89 | maven-invoker-plugin
90 |
91 | true
92 | true
93 | src/it
94 | ${project.build.directory}/it
95 |
96 | */pom.xml
97 |
98 | setup
99 | verify
100 | ${project.build.directory}/local-repo
101 | src/it/settings.xml
102 |
103 | clean
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
--------------------------------------------------------------------------------
/repository/org/apache/maven/plugins/maven-clean-plugin/2.5/maven-clean-plugin-2.5.pom.sha1:
--------------------------------------------------------------------------------
1 |
2 | 8571a1cd21bed4fe28656c3303526fa7d1e582ad
--------------------------------------------------------------------------------
/repository/org/apache/maven/plugins/maven-plugins/22/_remote.repositories:
--------------------------------------------------------------------------------
1 | #NOTE: This is an Aether internal implementation file, its format can be changed without prior notice.
2 | #Sat Mar 24 09:59:35 CST 2018
3 | maven-plugins-22.pom>alimaven=
4 |
--------------------------------------------------------------------------------
/repository/org/apache/maven/plugins/maven-plugins/22/maven-plugins-22.pom.sha1:
--------------------------------------------------------------------------------
1 |
2 | beff44ae4eff1e5c79c01972083cd11fa6982462
--------------------------------------------------------------------------------
/repository/org/codehaus/plexus/plexus-utils/3.0/_remote.repositories:
--------------------------------------------------------------------------------
1 | #NOTE: This is an Aether internal implementation file, its format can be changed without prior notice.
2 | #Sat Mar 24 09:59:38 CST 2018
3 | plexus-utils-3.0.pom>alimaven=
4 | plexus-utils-3.0.jar>alimaven=
5 |
--------------------------------------------------------------------------------
/repository/org/codehaus/plexus/plexus-utils/3.0/plexus-utils-3.0.jar.sha1:
--------------------------------------------------------------------------------
1 |
2 | d63aa0daf60d573bada235e2b4207617dcf24959
--------------------------------------------------------------------------------
/repository/org/codehaus/plexus/plexus-utils/3.0/plexus-utils-3.0.pom:
--------------------------------------------------------------------------------
1 |
2 |
3 |
18 |
19 |
20 | 4.0.0
21 |
22 |
23 | org.sonatype.spice
24 | spice-parent
25 | 16
26 |
27 |
28 | org.codehaus.plexus
29 | plexus-utils
30 | 3.0
31 |
32 | Plexus Common Utilities
33 | A collection of various utility classes to ease working with strings, files, command lines, XML and more.
34 | http://plexus.codehaus.org/plexus-utils
35 |
36 |
37 | scm:git:git@github.com:sonatype/plexus-utils.git
38 | scm:git:git@github.com:sonatype/plexus-utils.git
39 | http://github.com/sonatype/plexus-utils
40 |
41 |
42 | JIRA
43 | http://jira.codehaus.org/browse/PLXUTILS
44 |
45 |
46 |
47 |
48 | plexus-releases
49 | Plexus Release Repository
50 | https://oss.sonatype.org/service/local/staging/deploy/maven2/
51 |
52 |
53 | plexus-snapshots
54 | Plexus Snapshot Repository
55 | ${plexusDistMgmtSnapshotsUrl}
56 |
57 |
58 | codehaus.org
59 | dav:https://dav.codehaus.org/plexus
60 |
61 |
62 |
63 |
64 |
65 | junit
66 | junit
67 | 3.8.2
68 | test
69 |
70 |
71 |
72 |
73 |
74 |
75 | org.apache.maven.plugins
76 | maven-compiler-plugin
77 | 2.3.2
78 |
79 | 1.5
80 | 1.5
81 |
82 |
83 |
84 | org.apache.maven.plugins
85 | maven-release-plugin
86 | 2.1
87 |
88 |
89 | org.apache.maven.plugins
90 | maven-source-plugin
91 | 2.1.2
92 |
93 |
94 | org.apache.maven.plugins
95 | maven-deploy-plugin
96 | 2.6
97 |
98 |
99 | org.apache.maven.plugins
100 | maven-surefire-plugin
101 |
102 |
103 | true
104 |
105 | org/codehaus/plexus/util/FileBasedTestCase.java
106 | **/Test*.java
107 |
108 |
109 |
110 | JAVA_HOME
111 | ${JAVA_HOME}
112 |
113 |
114 | M2_HOME
115 | ${M2_HOME}
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
--------------------------------------------------------------------------------
/repository/org/codehaus/plexus/plexus-utils/3.0/plexus-utils-3.0.pom.sha1:
--------------------------------------------------------------------------------
1 |
2 | fe3d8457b0cf4e219fd8e3edad5054b8e38f17b0
--------------------------------------------------------------------------------
/repository/org/sonatype/forge/forge-parent/5/_remote.repositories:
--------------------------------------------------------------------------------
1 | #NOTE: This is an Aether internal implementation file, its format can be changed without prior notice.
2 | #Sat Mar 24 09:59:37 CST 2018
3 | forge-parent-5.pom>alimaven=
4 |
--------------------------------------------------------------------------------
/repository/org/sonatype/forge/forge-parent/5/forge-parent-5.pom.sha1:
--------------------------------------------------------------------------------
1 |
2 | a557514263bbd4a6daef8f125ab80e78413292d3
--------------------------------------------------------------------------------
/repository/org/sonatype/spice/spice-parent/16/_remote.repositories:
--------------------------------------------------------------------------------
1 | #NOTE: This is an Aether internal implementation file, its format can be changed without prior notice.
2 | #Sat Mar 24 09:59:37 CST 2018
3 | spice-parent-16.pom>alimaven=
4 |
--------------------------------------------------------------------------------
/repository/org/sonatype/spice/spice-parent/16/spice-parent-16.pom.sha1:
--------------------------------------------------------------------------------
1 |
2 | aefd3135046b7c3f5835283bcc3b670fc46692b9
--------------------------------------------------------------------------------
/src/cn/edu/lingnan/controller/AdminController.java:
--------------------------------------------------------------------------------
1 | package cn.edu.lingnan.controller;
2 |
3 | import java.util.Map;
4 |
5 | import org.springframework.beans.factory.annotation.Autowired;
6 | import org.springframework.stereotype.Controller;
7 | import org.springframework.web.bind.annotation.RequestMapping;
8 |
9 | import cn.edu.lingnan.pojo.Admins;
10 | import cn.edu.lingnan.service.AdminsService;
11 |
12 | @Controller
13 | public class AdminController extends BaseController {
14 |
15 | @Autowired
16 | private AdminsService adminsService;
17 |
18 | /**
19 | * 管理员登入
20 | * @param admins
21 | * @param map
22 | * @author lizhi
23 | */
24 | @RequestMapping("/adminLogin")
25 | public String adminLogin(Admins admins,Map
map){
26 | if(adminsService.login(admins).size()<=0){
27 | map.put("loginError", "帐号或密码错误");
28 | return "/admin/login";
29 | }
30 | super.session.setAttribute("admins", adminsService.login(admins).get(0));
31 | return "redirect:/selectUserByExample";
32 | }
33 |
34 | /**
35 | * 更新管理员资料(修改密码)
36 | * @param admins
37 | * @author lizhi
38 | */
39 | @RequestMapping("/changeAdminPassword")
40 | public String changeAdminPassword(Admins admins){
41 | adminsService.updateSelective(admins);
42 | return "redirect:/selectUserByExample";
43 | }
44 |
45 | /**
46 | * 注销
47 | * @return
48 | */
49 | @RequestMapping("/logout")
50 | public String logout(){
51 | session.invalidate();
52 | return "/admin/login";
53 | }
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/src/cn/edu/lingnan/controller/AnswerController.java:
--------------------------------------------------------------------------------
1 | package cn.edu.lingnan.controller;
2 |
3 | import java.util.ArrayList;
4 | import java.util.HashMap;
5 | import java.util.List;
6 | import java.util.Map;
7 |
8 | import org.springframework.beans.factory.annotation.Autowired;
9 | import org.springframework.stereotype.Controller;
10 | import org.springframework.web.bind.annotation.PathVariable;
11 | import org.springframework.web.bind.annotation.RequestMapping;
12 | import org.springframework.web.bind.annotation.RequestMethod;
13 | import org.springframework.web.bind.annotation.ResponseBody;
14 | import org.springframework.web.servlet.ModelAndView;
15 |
16 | import cn.edu.lingnan.pojo.Options;
17 | import cn.edu.lingnan.pojo.Question;
18 | import cn.edu.lingnan.pojo.QuestionOption;
19 | import cn.edu.lingnan.pojo.QuestionType;
20 | import cn.edu.lingnan.pojo.User;
21 | import cn.edu.lingnan.pojo.WeChatUser;
22 | import cn.edu.lingnan.service.AnswerService;
23 |
24 | @Controller
25 | public class AnswerController extends BaseController {
26 |
27 | public static final int QUESTION_NUMBER = 10;
28 |
29 | @Autowired
30 | private AnswerService answerService;
31 |
32 | /**
33 | * @author huang
34 | * 获取题目基础类型
35 | */
36 | @ResponseBody
37 | @RequestMapping(value="user/getType")
38 | public Map getQuestionType() {
39 | Map map = new HashMap();
40 | List firstlist = answerService.findType();
41 | if (firstlist.size() <= 0) {
42 | map.put("error", "系统错误:一级菜单获取失败");
43 | } else {
44 | map.put("firstlist", firstlist);
45 | }
46 | return map;
47 | }
48 |
49 | /**
50 | * @author huang
51 | * 获取题目具体类型
52 | */
53 | @ResponseBody
54 | @RequestMapping(value="user/getType/{id}")
55 | public Map getQuestionType(@PathVariable int id) {
56 | Map map = new HashMap();
57 | List secondlist = answerService.findType(id);
58 | if (secondlist.size() <= 0) {
59 | map.put("error", id);
60 | } else {
61 | //判断是否为3级菜单
62 | List thirdList = answerService.findType(secondlist.get(0).getTypeno());
63 | if(thirdList.size() <= 0)
64 | map.put("grade", "two");
65 | else
66 | map.put("grade", "third");
67 | map.put("secondlist", secondlist);
68 | }
69 | return map;
70 | }
71 |
72 | /**
73 | * @author huang
74 | * 根据类型获取题目
75 | */
76 | @ResponseBody
77 | @RequestMapping(value="user/getQuestion/{typeno}")
78 | public Map getQuestion(@PathVariable int typeno) {
79 | Map map = new HashMap();
80 | List questionList = answerService.getQuestionByType(typeno);
81 | List questionOptionsList = new ArrayList();
82 | for (Question q : questionList) {
83 | List optionlist = answerService.getOptionsByQuestion(q.getQuestionno());
84 | QuestionOption questionOption = new QuestionOption(q,optionlist);
85 | questionOptionsList.add(questionOption);
86 | }
87 | map.put("question",questionOptionsList);
88 | map.put("maxnumber", QUESTION_NUMBER);
89 | map.put("title", answerService.getQuestionTypeByID(typeno).getTypename());
90 | return map;
91 | }
92 |
93 | /**
94 | * @author huang
95 | * 用户答题更新记录
96 | */
97 | @RequestMapping(value="user/refreshRecord/{typeno}/{status}")
98 | public void refreshRecord(@PathVariable int typeno, @PathVariable int status){
99 | User user = (User) super.session.getAttribute("user");
100 | WeChatUser weuser = (WeChatUser) super.session.getAttribute("weChatUser");
101 | if (user != null)
102 | answerService.answerRecord(user.getUserno(), typeno, status, 0);
103 | else if (weuser != null)
104 | answerService.answerRecord(weuser.getWechatuserno(), typeno, status, 1);
105 | }
106 | }
107 |
--------------------------------------------------------------------------------
/src/cn/edu/lingnan/controller/BaseController.java:
--------------------------------------------------------------------------------
1 | package cn.edu.lingnan.controller;
2 |
3 | import javax.servlet.ServletContext;
4 | import javax.servlet.http.HttpServletRequest;
5 | import javax.servlet.http.HttpServletResponse;
6 | import javax.servlet.http.HttpSession;
7 |
8 | import org.springframework.context.ApplicationContext;
9 | import org.springframework.web.bind.annotation.ModelAttribute;
10 | import org.springframework.web.servlet.mvc.support.RedirectAttributes;
11 |
12 | public class BaseController {
13 |
14 | protected HttpServletRequest request;
15 | protected HttpServletResponse response;
16 | protected HttpSession session;
17 | protected RedirectAttributes redirectAttributes;
18 | protected ServletContext application;
19 |
20 | @ModelAttribute
21 | public void setReqAndRes(HttpServletRequest request, HttpServletResponse response,RedirectAttributes redirectAttributes ) {
22 | this.request = request;
23 | this.response = response;
24 | this.redirectAttributes = redirectAttributes;
25 | this.session = request.getSession();
26 | this.application = this.session.getServletContext();
27 | }
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/src/cn/edu/lingnan/controller/OptionsController.java:
--------------------------------------------------------------------------------
1 | package cn.edu.lingnan.controller;
2 |
3 | import java.util.List;
4 | import java.util.Map;
5 |
6 | import org.springframework.beans.factory.annotation.Autowired;
7 | import org.springframework.stereotype.Controller;
8 | import org.springframework.web.bind.annotation.RequestMapping;
9 | import org.springframework.web.bind.annotation.RequestParam;
10 |
11 | import com.github.pagehelper.PageHelper;
12 | import com.github.pagehelper.PageInfo;
13 |
14 | import cn.edu.lingnan.pojo.Options;
15 | import cn.edu.lingnan.pojo.OptionsExample;
16 | import cn.edu.lingnan.service.OptionsService;
17 |
18 | @Controller
19 | public class OptionsController extends BaseController {
20 |
21 | @Autowired
22 | private OptionsService optionsService;
23 |
24 | /**
25 | * 可根据条件分页查询所有候选答案
26 | * @return
27 | * @author lizhi
28 | */
29 | @RequestMapping("/selectOptions")
30 | public String selectOptions(OptionsExample options, Map map,
31 | @RequestParam(value = "pn", defaultValue = "1") Integer pn) {
32 | // 每页显示八条数据,且当前页是参数pn
33 | PageHelper.startPage(pn, 8);
34 | List list = optionsService.selectOptionsByExample(options);
35 | // 对数据进行分页处理
36 | PageInfo pageInfo = new PageInfo(list);
37 | map.put("optionsListPageInfo", pageInfo);
38 | // 到时候前端写出网页后再修改到具体的页面
39 | return "admin/index";
40 | }
41 |
42 | /**
43 | * 更新候选答案
44 | * @return
45 | * @author lizhi
46 | */
47 | @RequestMapping("/updateOptions")
48 | public String updateOptions(Options options){
49 | optionsService.updateByPrimaryKey(options);
50 | return "admin/index";
51 | }
52 |
53 |
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/src/cn/edu/lingnan/controller/RecordsController.java:
--------------------------------------------------------------------------------
1 | package cn.edu.lingnan.controller;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 | import java.util.Map;
6 |
7 | import org.springframework.beans.factory.annotation.Autowired;
8 | import org.springframework.stereotype.Controller;
9 | import org.springframework.web.bind.annotation.RequestMapping;
10 | import org.springframework.web.bind.annotation.RequestParam;
11 | import org.springframework.web.bind.annotation.ResponseBody;
12 |
13 | import com.github.pagehelper.PageHelper;
14 | import com.github.pagehelper.PageInfo;
15 |
16 | import cn.edu.lingnan.pojo.Records;
17 | import cn.edu.lingnan.pojo.RecordsExample;
18 | import cn.edu.lingnan.pojo.RecordsExample.Criteria;
19 | import cn.edu.lingnan.service.QuestionTypeService;
20 | import cn.edu.lingnan.service.RecordsService;
21 |
22 | @Controller
23 | public class RecordsController extends BaseController {
24 |
25 | @Autowired
26 | private RecordsService recordsService;
27 | @Autowired
28 | private QuestionTypeService questionTypeService;
29 |
30 | /**
31 | * 对记录表进行分页条件查询
32 | * @param recordsExample
33 | * @param pn
34 | * @param map
35 | * @author lizhi
36 | */
37 | @RequestMapping("/selectRecords")
38 | public String selectRecords(RecordsExample recordsExample, @RequestParam("pn") Integer pn,
39 | Map map) {
40 | // 每页显示八条数据,且当前页是参数pn
41 | PageHelper.startPage(pn, 8);
42 | List list = recordsService.selectRecordsByExample(recordsExample);
43 | // 对数据进行分页处理
44 | PageInfo pageInfo = new PageInfo(list);
45 | map.put("recordsListPageInfo", pageInfo);
46 | // 到时候前端写出网页后再修改到具体的页面
47 | return "/admin/index";
48 | }
49 |
50 | /**
51 | * 根据id更新记录表(可用于冲钱用户重置记录)
52 | * @param records
53 | * @author lizhi
54 | */
55 | @RequestMapping("/updateRecords")
56 | public String updateRecords(Records records){
57 | recordsService.updateRecords(records);
58 | return "/admin/index";
59 | }
60 |
61 | /**
62 | * 增加记录(可用于新增用户选择答题类型时添加答题记录)
63 | * @param userNo
64 | * @param typeNo
65 | * @author lizhi
66 | */
67 | @RequestMapping("/addRecords")
68 | public String addRecords(@RequestParam("userNo") Integer userNo,@RequestParam("typeNo") Integer typeNo){
69 | Records records = new Records();
70 | records.setUserno(userNo);
71 | records.setTypeno(typeNo);
72 | recordsService.addRecords(records);
73 | return "/admin/index";
74 | }
75 |
76 | /**
77 | * 删除记录
78 | * @param userNo
79 | * @author lizhi
80 | */
81 | @RequestMapping("/deleteRecords")
82 | public String deleteRecords(@RequestParam("userNo") Integer userNo){
83 | recordsService.deleteRecords(userNo);
84 | return "/admin/index";
85 | }
86 |
87 | /**
88 | * 微信端个人信息中显示个人答题记录
89 | * @return
90 | */
91 | @ResponseBody
92 | @RequestMapping("/getAllRecords")
93 | public List getAllRecords(Integer wechatuserno){
94 | RecordsExample recordsExample = new RecordsExample();
95 | Criteria criteria = recordsExample.createCriteria();
96 | criteria.andWechatusernoEqualTo(wechatuserno);
97 | List list = new ArrayList();
98 | list = recordsService.selectRecordsByExample(recordsExample);
99 | for(int i=0;i map){
21 | List list = testService.selectTest();
22 | //springmvc会自动把map中的数据放到请求域中
23 | map.put("testList",list);
24 | return "test";
25 | }
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/src/cn/edu/lingnan/dao/AdminsMapper.java:
--------------------------------------------------------------------------------
1 | package cn.edu.lingnan.dao;
2 |
3 | import cn.edu.lingnan.pojo.Admins;
4 | import cn.edu.lingnan.pojo.AdminsExample;
5 | import java.util.List;
6 | import org.apache.ibatis.annotations.Param;
7 |
8 | public interface AdminsMapper {
9 | long countByExample(AdminsExample example);
10 |
11 | int deleteByExample(AdminsExample example);
12 |
13 | int deleteByPrimaryKey(Integer adminid);
14 |
15 | int insert(Admins record);
16 |
17 | int insertSelective(Admins record);
18 |
19 | List selectByExample(AdminsExample example);
20 |
21 | Admins selectByPrimaryKey(Integer adminid);
22 |
23 | int updateByExampleSelective(@Param("record") Admins record, @Param("example") AdminsExample example);
24 |
25 | int updateByExample(@Param("record") Admins record, @Param("example") AdminsExample example);
26 |
27 | int updateByPrimaryKeySelective(Admins record);
28 |
29 | int updateByPrimaryKey(Admins record);
30 | }
--------------------------------------------------------------------------------
/src/cn/edu/lingnan/dao/OptionsMapper.java:
--------------------------------------------------------------------------------
1 | package cn.edu.lingnan.dao;
2 |
3 | import cn.edu.lingnan.pojo.Options;
4 | import cn.edu.lingnan.pojo.OptionsExample;
5 | import java.util.List;
6 | import org.apache.ibatis.annotations.Param;
7 |
8 | public interface OptionsMapper {
9 | long countByExample(OptionsExample example);
10 |
11 | int deleteByExample(OptionsExample example);
12 |
13 | int deleteByPrimaryKey(Integer optionsno);
14 |
15 | int insert(Options record);
16 |
17 | int insertSelective(Options record);
18 |
19 | List selectByExample(OptionsExample example);
20 |
21 | Options selectByPrimaryKey(Integer optionsno);
22 |
23 | int updateByExampleSelective(@Param("record") Options record, @Param("example") OptionsExample example);
24 |
25 | int updateByExample(@Param("record") Options record, @Param("example") OptionsExample example);
26 |
27 | int updateByPrimaryKeySelective(Options record);
28 |
29 | int updateByPrimaryKey(Options record);
30 | }
--------------------------------------------------------------------------------
/src/cn/edu/lingnan/dao/QuestionMapper.java:
--------------------------------------------------------------------------------
1 | package cn.edu.lingnan.dao;
2 |
3 | import cn.edu.lingnan.pojo.Question;
4 | import cn.edu.lingnan.pojo.QuestionExample;
5 | import java.util.List;
6 | import org.apache.ibatis.annotations.Param;
7 |
8 | public interface QuestionMapper {
9 | long countByExample(QuestionExample example);
10 |
11 | int deleteByExample(QuestionExample example);
12 |
13 | int deleteByPrimaryKey(Integer questionno);
14 |
15 | int insert(Question record);
16 |
17 | int insertSelective(Question record);
18 |
19 | List selectByExample(QuestionExample example);
20 |
21 | Question selectByPrimaryKey(Integer questionno);
22 |
23 | int updateByExampleSelective(@Param("record") Question record, @Param("example") QuestionExample example);
24 |
25 | int updateByExample(@Param("record") Question record, @Param("example") QuestionExample example);
26 |
27 | int updateByPrimaryKeySelective(Question record);
28 |
29 | int updateByPrimaryKey(Question record);
30 | //从数据库随机获取数据
31 | List randSelectQuestion(@Param("typeno")int typeno, @Param("number")int number);
32 | }
--------------------------------------------------------------------------------
/src/cn/edu/lingnan/dao/QuestionTypeMapper.java:
--------------------------------------------------------------------------------
1 | package cn.edu.lingnan.dao;
2 |
3 | import cn.edu.lingnan.pojo.QuestionType;
4 | import cn.edu.lingnan.pojo.QuestionTypeExample;
5 | import java.util.List;
6 | import org.apache.ibatis.annotations.Param;
7 |
8 | public interface QuestionTypeMapper {
9 | long countByExample(QuestionTypeExample example);
10 |
11 | int deleteByExample(QuestionTypeExample example);
12 |
13 | int deleteByPrimaryKey(Integer typeno);
14 |
15 | int insert(QuestionType record);
16 |
17 | int insertSelective(QuestionType record);
18 |
19 | List selectByExample(QuestionTypeExample example);
20 |
21 | QuestionType selectByPrimaryKey(Integer typeno);
22 |
23 | int updateByExampleSelective(@Param("record") QuestionType record, @Param("example") QuestionTypeExample example);
24 |
25 | int updateByExample(@Param("record") QuestionType record, @Param("example") QuestionTypeExample example);
26 |
27 | int updateByPrimaryKeySelective(QuestionType record);
28 |
29 | int updateByPrimaryKey(QuestionType record);
30 | }
--------------------------------------------------------------------------------
/src/cn/edu/lingnan/dao/QuestionTypePlus.java:
--------------------------------------------------------------------------------
1 | package cn.edu.lingnan.dao;
2 |
3 | import cn.edu.lingnan.pojo.QuestionType;
4 |
5 | public class QuestionTypePlus {
6 |
7 | private QuestionType questionType;
8 | //第几级目录
9 | private Integer status;
10 | //记录页码数
11 | private Integer pn;
12 |
13 | public QuestionType getQuestionType() {
14 | return questionType;
15 | }
16 |
17 | public void setQuestionType(QuestionType questionType) {
18 | this.questionType = questionType;
19 | }
20 |
21 | public Integer getStatus() {
22 | return status;
23 | }
24 |
25 | public void setStatus(Integer status) {
26 | this.status = status;
27 | }
28 |
29 | public Integer getPn() {
30 | return pn;
31 | }
32 |
33 | public void setPn(Integer pn) {
34 | this.pn = pn;
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/src/cn/edu/lingnan/dao/RecordsMapper.java:
--------------------------------------------------------------------------------
1 | package cn.edu.lingnan.dao;
2 |
3 | import cn.edu.lingnan.pojo.Records;
4 | import cn.edu.lingnan.pojo.RecordsExample;
5 | import java.util.List;
6 | import org.apache.ibatis.annotations.Param;
7 |
8 | public interface RecordsMapper {
9 | long countByExample(RecordsExample example);
10 |
11 | int deleteByExample(RecordsExample example);
12 |
13 | int deleteByPrimaryKey(Integer recordsno);
14 |
15 | int insert(Records record);
16 |
17 | int insertSelective(Records record);
18 |
19 | List selectByExample(RecordsExample example);
20 |
21 | Records selectByPrimaryKey(Integer recordsno);
22 |
23 | int updateByExampleSelective(@Param("record") Records record, @Param("example") RecordsExample example);
24 |
25 | int updateByExample(@Param("record") Records record, @Param("example") RecordsExample example);
26 |
27 | int updateByPrimaryKeySelective(Records record);
28 |
29 | int updateByPrimaryKey(Records record);
30 | }
--------------------------------------------------------------------------------
/src/cn/edu/lingnan/dao/TempUrlMapper.java:
--------------------------------------------------------------------------------
1 | package cn.edu.lingnan.dao;
2 |
3 | import cn.edu.lingnan.pojo.TempUrl;
4 | import cn.edu.lingnan.pojo.TempUrlExample;
5 | import java.util.List;
6 | import org.apache.ibatis.annotations.Param;
7 |
8 | public interface TempUrlMapper {
9 | long countByExample(TempUrlExample example);
10 |
11 | int deleteByExample(TempUrlExample example);
12 |
13 | int deleteByPrimaryKey(Integer tempurlid);
14 |
15 | int insert(TempUrl record);
16 |
17 | int insertSelective(TempUrl record);
18 |
19 | List selectByExample(TempUrlExample example);
20 |
21 | TempUrl selectByPrimaryKey(Integer tempurlid);
22 |
23 | int updateByExampleSelective(@Param("record") TempUrl record, @Param("example") TempUrlExample example);
24 |
25 | int updateByExample(@Param("record") TempUrl record, @Param("example") TempUrlExample example);
26 |
27 | int updateByPrimaryKeySelective(TempUrl record);
28 |
29 | int updateByPrimaryKey(TempUrl record);
30 | }
--------------------------------------------------------------------------------
/src/cn/edu/lingnan/dao/TestMapper.java:
--------------------------------------------------------------------------------
1 | package cn.edu.lingnan.dao;
2 |
3 | import java.util.List;
4 |
5 | import org.springframework.stereotype.Repository;
6 |
7 | public interface TestMapper {
8 |
9 | // 查询test表
10 | public List selectTest();
11 |
12 | }
13 |
--------------------------------------------------------------------------------
/src/cn/edu/lingnan/dao/UserMapper.java:
--------------------------------------------------------------------------------
1 | package cn.edu.lingnan.dao;
2 |
3 | import cn.edu.lingnan.pojo.User;
4 | import cn.edu.lingnan.pojo.UserExample;
5 | import java.util.List;
6 | import org.apache.ibatis.annotations.Param;
7 |
8 | public interface UserMapper {
9 | long countByExample(UserExample example);
10 |
11 | int deleteByExample(UserExample example);
12 |
13 | int deleteByPrimaryKey(Integer userno);
14 |
15 | int insert(User record);
16 |
17 | int insertSelective(User record);
18 |
19 | List selectByExample(UserExample example);
20 |
21 | User selectByPrimaryKey(Integer userno);
22 |
23 | int updateByExampleSelective(@Param("record") User record, @Param("example") UserExample example);
24 |
25 | int updateByExample(@Param("record") User record, @Param("example") UserExample example);
26 |
27 | int updateByPrimaryKeySelective(User record);
28 |
29 | int updateByPrimaryKey(User record);
30 | }
--------------------------------------------------------------------------------
/src/cn/edu/lingnan/dao/WeChatUserMapper.java:
--------------------------------------------------------------------------------
1 | package cn.edu.lingnan.dao;
2 |
3 | import cn.edu.lingnan.pojo.WeChatUser;
4 | import cn.edu.lingnan.pojo.WeChatUserExample;
5 | import java.util.List;
6 | import org.apache.ibatis.annotations.Param;
7 |
8 | public interface WeChatUserMapper {
9 | long countByExample(WeChatUserExample example);
10 |
11 | int deleteByExample(WeChatUserExample example);
12 |
13 | int deleteByPrimaryKey(Integer wechatuserno);
14 |
15 | int insert(WeChatUser record);
16 |
17 | int insertSelective(WeChatUser record);
18 |
19 | List selectByExample(WeChatUserExample example);
20 |
21 | WeChatUser selectByPrimaryKey(Integer wechatuserno);
22 |
23 | int updateByExampleSelective(@Param("record") WeChatUser record, @Param("example") WeChatUserExample example);
24 |
25 | int updateByExample(@Param("record") WeChatUser record, @Param("example") WeChatUserExample example);
26 |
27 | int updateByPrimaryKeySelective(WeChatUser record);
28 |
29 | int updateByPrimaryKey(WeChatUser record);
30 | }
--------------------------------------------------------------------------------
/src/cn/edu/lingnan/filter/CommonInterceptor.java:
--------------------------------------------------------------------------------
1 | package cn.edu.lingnan.filter;
2 |
3 | import java.util.List;
4 |
5 | import javax.servlet.http.HttpServletRequest;
6 | import javax.servlet.http.HttpServletResponse;
7 |
8 | import org.springframework.web.servlet.HandlerInterceptor;
9 | import org.springframework.web.servlet.ModelAndView;
10 |
11 | public class CommonInterceptor implements HandlerInterceptor {
12 |
13 | private List excludedUrls;
14 |
15 |
16 | @Override
17 | public void afterCompletion(HttpServletRequest arg0, HttpServletResponse arg1, Object arg2, Exception arg3)
18 | throws Exception {
19 | // TODO Auto-generated method stub
20 |
21 | }
22 |
23 | @Override
24 | public void postHandle(HttpServletRequest arg0, HttpServletResponse arg1, Object arg2, ModelAndView arg3)
25 | throws Exception {
26 | // TODO Auto-generated method stub
27 |
28 | }
29 |
30 | @Override
31 | public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object arg2) throws Exception {
32 |
33 |
34 | if (request.getSession().getAttribute("admins") == null) {
35 | String XRequested = request.getHeader("X-Requested-With");
36 | if ("XMLHttpRequest".equals(XRequested)) {
37 | response.getWriter().write("IsAjax");
38 | } else {
39 | response.sendRedirect("admin/login.jsp");
40 | }
41 | return false;
42 | }
43 | return true;
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/src/cn/edu/lingnan/filter/UserFilter.java:
--------------------------------------------------------------------------------
1 | package cn.edu.lingnan.filter;
2 |
3 | import java.io.IOException;
4 |
5 | import javax.servlet.Filter;
6 | import javax.servlet.FilterChain;
7 | import javax.servlet.FilterConfig;
8 | import javax.servlet.ServletException;
9 | import javax.servlet.ServletRequest;
10 | import javax.servlet.ServletResponse;
11 | import javax.servlet.http.HttpServletRequest;
12 | import javax.servlet.http.HttpServletResponse;
13 |
14 | /**
15 | * @author huang
16 | * 拦截未登录用户
17 | */
18 | public class UserFilter implements Filter {
19 |
20 | @Override
21 | public void destroy() {
22 |
23 | }
24 |
25 | @Override
26 | public void doFilter(ServletRequest arg0, ServletResponse arg1, FilterChain arg2)
27 | throws IOException, ServletException {
28 | // HttpServletRequest req = (HttpServletRequest) arg0;
29 | // HttpServletResponse resp = (HttpServletResponse) arg1;
30 | // Object user = req.getSession().getAttribute("user");
31 | // Object wechatuser = req.getSession().getAttribute("weChatUser");
32 | // if(user == null && wechatuser == null)
33 | // resp.sendRedirect(req.getContextPath() + "/login.jsp");
34 | arg2.doFilter(arg0, arg1);
35 | }
36 |
37 | @Override
38 | public void init(FilterConfig arg0) throws ServletException {
39 |
40 | }
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/src/cn/edu/lingnan/pojo/Admins.java:
--------------------------------------------------------------------------------
1 | package cn.edu.lingnan.pojo;
2 |
3 | public class Admins {
4 | private Integer adminid;
5 |
6 | private String adminname;
7 |
8 | private String password;
9 |
10 | private Integer adminflag;
11 |
12 | public Integer getAdminid() {
13 | return adminid;
14 | }
15 |
16 | public void setAdminid(Integer adminid) {
17 | this.adminid = adminid;
18 | }
19 |
20 | public String getAdminname() {
21 | return adminname;
22 | }
23 |
24 | public void setAdminname(String adminname) {
25 | this.adminname = adminname == null ? null : adminname.trim();
26 | }
27 |
28 | public String getPassword() {
29 | return password;
30 | }
31 |
32 | public void setPassword(String password) {
33 | this.password = password == null ? null : password.trim();
34 | }
35 |
36 | public Integer getAdminflag() {
37 | return adminflag;
38 | }
39 |
40 | public void setAdminflag(Integer adminflag) {
41 | this.adminflag = adminflag;
42 | }
43 | }
--------------------------------------------------------------------------------
/src/cn/edu/lingnan/pojo/Options.java:
--------------------------------------------------------------------------------
1 | package cn.edu.lingnan.pojo;
2 |
3 | public class Options {
4 | private Integer optionsno;
5 |
6 | private Integer questionno;
7 |
8 | private String content;
9 |
10 | private Integer status;
11 |
12 | public Integer getOptionsno() {
13 | return optionsno;
14 | }
15 |
16 | public void setOptionsno(Integer optionsno) {
17 | this.optionsno = optionsno;
18 | }
19 |
20 | public Integer getQuestionno() {
21 | return questionno;
22 | }
23 |
24 | public void setQuestionno(Integer questionno) {
25 | this.questionno = questionno;
26 | }
27 |
28 | public String getContent() {
29 | return content;
30 | }
31 |
32 | public void setContent(String content) {
33 | this.content = content == null ? null : content.trim();
34 | }
35 |
36 | public Integer getStatus() {
37 | return status;
38 | }
39 |
40 | public void setStatus(Integer status) {
41 | this.status = status;
42 | }
43 | }
--------------------------------------------------------------------------------
/src/cn/edu/lingnan/pojo/OptionsList.java:
--------------------------------------------------------------------------------
1 | package cn.edu.lingnan.pojo;
2 |
3 | import java.util.List;
4 |
5 | public class OptionsList {
6 |
7 | private List optionsList;
8 |
9 | public List getOptionsList() {
10 | return optionsList;
11 | }
12 |
13 | public void setOptionsList(List optionsList) {
14 | this.optionsList = optionsList;
15 | }
16 |
17 |
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/src/cn/edu/lingnan/pojo/Question.java:
--------------------------------------------------------------------------------
1 | package cn.edu.lingnan.pojo;
2 |
3 | public class Question {
4 | private Integer questionno;
5 |
6 | private String content;
7 |
8 | private String description;
9 |
10 | private Integer constatus;
11 |
12 | private Integer desstatus;
13 |
14 | private Integer typeno;
15 |
16 | public Integer getQuestionno() {
17 | return questionno;
18 | }
19 |
20 | public void setQuestionno(Integer questionno) {
21 | this.questionno = questionno;
22 | }
23 |
24 | public String getContent() {
25 | return content;
26 | }
27 |
28 | public void setContent(String content) {
29 | this.content = content == null ? null : content.trim();
30 | }
31 |
32 | public String getDescription() {
33 | return description;
34 | }
35 |
36 | public void setDescription(String description) {
37 | this.description = description == null ? null : description.trim();
38 | }
39 |
40 | public Integer getConstatus() {
41 | return constatus;
42 | }
43 |
44 | public void setConstatus(Integer constatus) {
45 | this.constatus = constatus;
46 | }
47 |
48 | public Integer getDesstatus() {
49 | return desstatus;
50 | }
51 |
52 | public void setDesstatus(Integer desstatus) {
53 | this.desstatus = desstatus;
54 | }
55 |
56 | public Integer getTypeno() {
57 | return typeno;
58 | }
59 |
60 | public void setTypeno(Integer typeno) {
61 | this.typeno = typeno;
62 | }
63 | }
--------------------------------------------------------------------------------
/src/cn/edu/lingnan/pojo/QuestionOption.java:
--------------------------------------------------------------------------------
1 | package cn.edu.lingnan.pojo;
2 |
3 | import java.util.List;
4 |
5 | /**
6 | *
7 | * @author huang
8 | * 题目以及题目选项的组合
9 | */
10 | public class QuestionOption {
11 |
12 | private Question question; //题目
13 | private List option; //选项
14 |
15 | public QuestionOption(Question question, List option){
16 | this.option = option;
17 | this.question = question;
18 | }
19 |
20 | public Question getQuestion() {
21 | return question;
22 | }
23 | public void setQuestion(Question question) {
24 | this.question = question;
25 | }
26 | public List getOption() {
27 | return option;
28 | }
29 | public void setOption(List option) {
30 | this.option = option;
31 | }
32 |
33 |
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/src/cn/edu/lingnan/pojo/QuestionType.java:
--------------------------------------------------------------------------------
1 | package cn.edu.lingnan.pojo;
2 |
3 | import javax.validation.constraints.NotNull;
4 |
5 | public class QuestionType {
6 | private Integer typeno;
7 | @NotNull
8 | private String typename;
9 |
10 | private Integer belongtypeno;
11 | @NotNull
12 | private String imageurl;
13 |
14 | public Integer getTypeno() {
15 | return typeno;
16 | }
17 |
18 | public void setTypeno(Integer typeno) {
19 | this.typeno = typeno;
20 | }
21 |
22 | public String getTypename() {
23 | return typename;
24 | }
25 |
26 | public void setTypename(String typename) {
27 | this.typename = typename == null ? null : typename.trim();
28 | }
29 |
30 | public Integer getBelongtypeno() {
31 | return belongtypeno;
32 | }
33 |
34 | public void setBelongtypeno(Integer belongtypeno) {
35 | this.belongtypeno = belongtypeno;
36 | }
37 |
38 | public String getImageurl() {
39 | return imageurl;
40 | }
41 |
42 | public void setImageurl(String imageurl) {
43 | this.imageurl = imageurl == null ? null : imageurl.trim();
44 | }
45 | }
--------------------------------------------------------------------------------
/src/cn/edu/lingnan/pojo/Records.java:
--------------------------------------------------------------------------------
1 | package cn.edu.lingnan.pojo;
2 |
3 | public class Records {
4 | private Integer recordsno;
5 |
6 | private Integer userno;
7 |
8 | private Integer typeno;
9 |
10 | private Integer acnumber;
11 |
12 | private Integer erunmber;
13 |
14 | private Integer wechatuserno;
15 |
16 | private String typename;
17 |
18 | public Integer getRecordsno() {
19 | return recordsno;
20 | }
21 |
22 | public void setRecordsno(Integer recordsno) {
23 | this.recordsno = recordsno;
24 | }
25 |
26 | public Integer getUserno() {
27 | return userno;
28 | }
29 |
30 | public void setUserno(Integer userno) {
31 | this.userno = userno;
32 | }
33 |
34 | public Integer getTypeno() {
35 | return typeno;
36 | }
37 |
38 | public void setTypeno(Integer typeno) {
39 | this.typeno = typeno;
40 | }
41 |
42 | public Integer getAcnumber() {
43 | return acnumber;
44 | }
45 |
46 | public void setAcnumber(Integer acnumber) {
47 | this.acnumber = acnumber;
48 | }
49 |
50 | public Integer getErunmber() {
51 | return erunmber;
52 | }
53 |
54 | public void setErunmber(Integer erunmber) {
55 | this.erunmber = erunmber;
56 | }
57 |
58 | public Integer getWechatuserno() {
59 | return wechatuserno;
60 | }
61 |
62 | public void setWechatuserno(Integer wechatuserno) {
63 | this.wechatuserno = wechatuserno;
64 | }
65 |
66 | public String getTypename() {
67 | return typename;
68 | }
69 |
70 | public void setTypename(String typename) {
71 | this.typename = typename;
72 | }
73 |
74 |
75 | }
--------------------------------------------------------------------------------
/src/cn/edu/lingnan/pojo/TempUrl.java:
--------------------------------------------------------------------------------
1 | package cn.edu.lingnan.pojo;
2 |
3 | import java.util.Date;
4 |
5 | public class TempUrl {
6 | private Integer tempurlid;
7 |
8 | private String fileurl;
9 |
10 | private String newdate;
11 |
12 |
13 | public TempUrl(String fileurl, String newdate) {
14 | this.fileurl = fileurl;
15 | this.newdate = newdate;
16 | }
17 |
18 | public TempUrl(Integer tempurlid, String fileurl, String newdate) {
19 | this.tempurlid = tempurlid;
20 | this.fileurl = fileurl;
21 | this.newdate = newdate;
22 | }
23 |
24 | public Integer getTempurlid() {
25 | return tempurlid;
26 | }
27 |
28 | public void setTempurlid(Integer tempurlid) {
29 | this.tempurlid = tempurlid;
30 | }
31 |
32 | public String getFileurl() {
33 | return fileurl;
34 | }
35 |
36 | public void setFileurl(String fileurl) {
37 | this.fileurl = fileurl == null ? null : fileurl.trim();
38 | }
39 |
40 | public String getNewdate() {
41 | return newdate;
42 | }
43 |
44 | public void setNewdate(String newdate) {
45 | this.newdate = newdate == null ? null : newdate.trim();
46 | }
47 | }
--------------------------------------------------------------------------------
/src/cn/edu/lingnan/pojo/Test.java:
--------------------------------------------------------------------------------
1 | package cn.edu.lingnan.pojo;
2 |
3 | public class Test {
4 |
5 | public String name;
6 |
7 | public String getName() {
8 | return name;
9 | }
10 |
11 | public void setName(String name) {
12 | this.name = name;
13 | }
14 |
15 | @Override
16 | public String toString() {
17 | return "Test [name=" + name + "]";
18 | }
19 |
20 |
21 |
22 |
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/src/cn/edu/lingnan/pojo/UploadFile.java:
--------------------------------------------------------------------------------
1 |
2 | package cn.edu.lingnan.pojo;
3 |
4 | import java.io.ByteArrayInputStream;
5 | import java.io.File;
6 | import java.io.IOException;
7 | import java.io.InputStream;
8 |
9 | import org.springframework.mock.web.MockMultipartHttpServletRequest;
10 | import org.springframework.util.Assert;
11 | import org.springframework.util.FileCopyUtils;
12 | import org.springframework.web.multipart.MultipartFile;
13 |
14 | /**
15 | * Mock implementation of the {@link org.springframework.web.multipart.MultipartFile}
16 | * interface.
17 | *
18 | * Useful in conjunction with a {@link MockMultipartHttpServletRequest}
19 | * for testing application controllers that access multipart uploads.
20 | *
21 | * @author Juergen Hoeller
22 | * @author Eric Crampton
23 | * @since 2.0
24 | * @see MockMultipartHttpServletRequest
25 | */
26 | public class UploadFile implements MultipartFile {
27 |
28 | private final String name;
29 |
30 | private String originalFilename;
31 |
32 | private String contentType;
33 |
34 | private final byte[] content;
35 |
36 |
37 | /**
38 | * Create a new MockMultipartFile with the given content.
39 | * @param name the name of the file
40 | * @param content the content of the file
41 | */
42 | public UploadFile(String name, byte[] content) {
43 | this(name, "", null, content);
44 | }
45 |
46 | /**
47 | * Create a new MockMultipartFile with the given content.
48 | * @param name the name of the file
49 | * @param contentStream the content of the file as stream
50 | * @throws IOException if reading from the stream failed
51 | */
52 | public UploadFile(String name, InputStream contentStream) throws IOException {
53 | this(name, "", null, FileCopyUtils.copyToByteArray(contentStream));
54 | }
55 |
56 | /**
57 | * Create a new MockMultipartFile with the given content.
58 | * @param name the name of the file
59 | * @param originalFilename the original filename (as on the client's machine)
60 | * @param contentType the content type (if known)
61 | * @param content the content of the file
62 | */
63 | public UploadFile(String name, String originalFilename, String contentType, byte[] content) {
64 | Assert.hasLength(name, "Name must not be null");
65 | this.name = name;
66 | this.originalFilename = (originalFilename != null ? originalFilename : "");
67 | this.contentType = contentType;
68 | this.content = (content != null ? content : new byte[0]);
69 | }
70 |
71 | /**
72 | * Create a new MockMultipartFile with the given content.
73 | * @param name the name of the file
74 | * @param originalFilename the original filename (as on the client's machine)
75 | * @param contentType the content type (if known)
76 | * @param contentStream the content of the file as stream
77 | * @throws IOException if reading from the stream failed
78 | */
79 | public UploadFile(String name, String originalFilename, String contentType, InputStream contentStream)
80 | throws IOException {
81 |
82 | this(name, originalFilename, contentType, FileCopyUtils.copyToByteArray(contentStream));
83 | }
84 |
85 | @Override
86 | public String getName() {
87 | return this.name;
88 | }
89 |
90 | @Override
91 | public String getOriginalFilename() {
92 | return this.originalFilename;
93 | }
94 |
95 | @Override
96 | public String getContentType() {
97 | return this.contentType;
98 | }
99 |
100 | @Override
101 | public boolean isEmpty() {
102 | return (this.content.length == 0);
103 | }
104 |
105 | @Override
106 | public long getSize() {
107 | return this.content.length;
108 | }
109 |
110 | @Override
111 | public byte[] getBytes() throws IOException {
112 | return this.content;
113 | }
114 |
115 | @Override
116 | public InputStream getInputStream() throws IOException {
117 | return new ByteArrayInputStream(this.content);
118 | }
119 |
120 | @Override
121 | public void transferTo(File dest) throws IOException, IllegalStateException {
122 | FileCopyUtils.copy(this.content, dest);
123 | }
124 |
125 | }
126 |
--------------------------------------------------------------------------------
/src/cn/edu/lingnan/pojo/User.java:
--------------------------------------------------------------------------------
1 | package cn.edu.lingnan.pojo;
2 |
3 | public class User {
4 | private Integer userno;
5 |
6 | private String username;
7 |
8 | private String password;
9 |
10 | private String email;
11 |
12 | private String sex;
13 |
14 | private Integer status;
15 |
16 | private String newdate;
17 |
18 | public Integer getUserno() {
19 | return userno;
20 | }
21 |
22 | public void setUserno(Integer userno) {
23 | this.userno = userno;
24 | }
25 |
26 | public String getUsername() {
27 | return username;
28 | }
29 |
30 | public void setUsername(String username) {
31 | this.username = username == null ? null : username.trim();
32 | }
33 |
34 | public String getPassword() {
35 | return password;
36 | }
37 |
38 | public void setPassword(String password) {
39 | this.password = password == null ? null : password.trim();
40 | }
41 |
42 | public String getEmail() {
43 | return email;
44 | }
45 |
46 | public void setEmail(String email) {
47 | this.email = email == null ? null : email.trim();
48 | }
49 |
50 | public String getSex() {
51 | return sex;
52 | }
53 |
54 | public void setSex(String sex) {
55 | this.sex = sex == null ? null : sex.trim();
56 | }
57 |
58 | public Integer getStatus() {
59 | return status;
60 | }
61 |
62 | public void setStatus(Integer status) {
63 | this.status = status;
64 | }
65 |
66 | public String getNewdate() {
67 | return newdate;
68 | }
69 |
70 | public void setNewdate(String newdate) {
71 | this.newdate = newdate == null ? null : newdate.trim();
72 | }
73 | }
--------------------------------------------------------------------------------
/src/cn/edu/lingnan/pojo/WeChatUser.java:
--------------------------------------------------------------------------------
1 | package cn.edu.lingnan.pojo;
2 |
3 | public class WeChatUser {
4 | private Integer wechatuserno;
5 |
6 | private String openid;
7 |
8 | private String nickname;
9 |
10 | private String sex;
11 |
12 | private String province;
13 |
14 | private String city;
15 |
16 | private String country;
17 |
18 | private String headimgurl;
19 |
20 | private Integer userno;
21 |
22 | @Override
23 | public String toString() {
24 | return "openid=" + openid + "\nnickname=" + nickname
25 | + "\nsex=" + sex + "\nprovince=" + province
26 | + "\ncity=" + city + "\ncountry=" + country
27 | + "\nheadimgurl=" + headimgurl + "\nwechatuserno=" + wechatuserno;
28 | }
29 |
30 | public Integer getWechatuserno() {
31 | return wechatuserno;
32 | }
33 |
34 | public void setWechatuserno(Integer wechatuserno) {
35 | this.wechatuserno = wechatuserno;
36 | }
37 |
38 | public String getOpenid() {
39 | return openid;
40 | }
41 |
42 | public void setOpenid(String openid) {
43 | this.openid = openid == null ? null : openid.trim();
44 | }
45 |
46 | public String getNickname() {
47 | return nickname;
48 | }
49 |
50 | public void setNickname(String nickname) {
51 | this.nickname = nickname == null ? null : nickname.trim();
52 | }
53 |
54 | public String getSex() {
55 | return sex;
56 | }
57 |
58 | public void setSex(String sex) {
59 | this.sex = sex == null ? null : sex.trim();
60 | }
61 |
62 | public String getProvince() {
63 | return province;
64 | }
65 |
66 | public void setProvince(String province) {
67 | this.province = province == null ? null : province.trim();
68 | }
69 |
70 | public String getCity() {
71 | return city;
72 | }
73 |
74 | public void setCity(String city) {
75 | this.city = city == null ? null : city.trim();
76 | }
77 |
78 | public String getCountry() {
79 | return country;
80 | }
81 |
82 | public void setCountry(String country) {
83 | this.country = country == null ? null : country.trim();
84 | }
85 |
86 | public String getHeadimgurl() {
87 | return headimgurl;
88 | }
89 |
90 | public void setHeadimgurl(String headimgurl) {
91 | this.headimgurl = headimgurl == null ? null : headimgurl.trim();
92 | }
93 |
94 | public Integer getUserno() {
95 | return userno;
96 | }
97 |
98 | public void setUserno(Integer userno) {
99 | this.userno = userno;
100 | }
101 | }
--------------------------------------------------------------------------------
/src/cn/edu/lingnan/pojo/wechatpojo/Article.java:
--------------------------------------------------------------------------------
1 | package cn.edu.lingnan.pojo.wechatpojo;
2 |
3 | public class Article {
4 |
5 | private String Title; //标题
6 | private String Description; //描述
7 | private String PicUrl; //图片链接
8 | private String Url; //点击后跳转链接
9 |
10 | public String getTitle() {
11 | return Title;
12 | }
13 | public void setTitle(String title) {
14 | this.Title = title;
15 | }
16 | public String getDescription() {
17 | return Description;
18 | }
19 | public void setDescription(String description) {
20 | this.Description = description;
21 | }
22 | public String getPicUrl() {
23 | return PicUrl;
24 | }
25 | public void setPicUrl(String picUrl) {
26 | this.PicUrl = picUrl;
27 | }
28 | public String getUrl() {
29 | return Url;
30 | }
31 | public void setUrl(String url) {
32 | this.Url = url;
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/src/cn/edu/lingnan/pojo/wechatpojo/AutowebParams.java:
--------------------------------------------------------------------------------
1 | package cn.edu.lingnan.pojo.wechatpojo;
2 |
3 | /**
4 | *
5 | * @author huang
6 | * 获取微信用户的access_token
7 | */
8 |
9 | public class AutowebParams {
10 |
11 | private String access_token;
12 | private String expires_in; //使用时间
13 | private String refresh_token; //刷新access_token的id
14 | private String openid; //用户唯一标识
15 | private String scope; //授权作用域
16 |
17 | public String getAccess_token() {
18 | return access_token;
19 | }
20 | public void setAccess_token(String access_token) {
21 | this.access_token = access_token;
22 | }
23 | public String getExpires_in() {
24 | return expires_in;
25 | }
26 | public void setExpires_in(String expires_in) {
27 | this.expires_in = expires_in;
28 | }
29 | public String getRefresh_token() {
30 | return refresh_token;
31 | }
32 | public void setRefresh_token(String refresh_token) {
33 | this.refresh_token = refresh_token;
34 | }
35 | public String getOpenid() {
36 | return openid;
37 | }
38 | public void setOpenid(String openid) {
39 | this.openid = openid;
40 | }
41 | public String getScope() {
42 | return scope;
43 | }
44 | public void setScope(String scope) {
45 | this.scope = scope;
46 | }
47 |
48 |
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/src/cn/edu/lingnan/pojo/wechatpojo/BaseMessage.java:
--------------------------------------------------------------------------------
1 | package cn.edu.lingnan.pojo.wechatpojo;
2 |
3 | public class BaseMessage {
4 |
5 | private String ToUserName; //给谁发送
6 | private String FromUserName; //从哪里发送
7 | private long CreateTime; //消息创建时间
8 | private String MsgType; //消息类型
9 |
10 | public String getToUserName() {
11 | return ToUserName;
12 | }
13 | public void setToUserName(String toUserName) {
14 | this.ToUserName = toUserName;
15 | }
16 | public String getFromUserName() {
17 | return FromUserName;
18 | }
19 | public void setFromUserName(String fromUserName) {
20 | this.FromUserName = fromUserName;
21 | }
22 | public long getCreateTime() {
23 | return CreateTime;
24 | }
25 | public void setCreateTime(long createTime) {
26 | this.CreateTime = createTime;
27 | }
28 | public String getMsgType() {
29 | return MsgType;
30 | }
31 | public void setMsgType(String msgType) {
32 | this.MsgType = msgType;
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/src/cn/edu/lingnan/pojo/wechatpojo/NewsMessage.java:
--------------------------------------------------------------------------------
1 | package cn.edu.lingnan.pojo.wechatpojo;
2 |
3 | import java.util.List;
4 |
5 | import cn.edu.lingnan.utils.WeChatMessageUtil;
6 |
7 |
8 | public class NewsMessage extends BaseMessage {
9 |
10 | private int ArticleCount; //图文消息数量
11 | private List Articles; //图文消息
12 |
13 | public NewsMessage(){
14 | super.setMsgType(WeChatMessageUtil.RESPONR_NEWS_MESSAGE);
15 | }
16 | public NewsMessage(String toUserName, String fromUserName) {
17 | super.setFromUserName(fromUserName);
18 | super.setToUserName(toUserName);
19 | super.setMsgType(WeChatMessageUtil.RESPONR_NEWS_MESSAGE);
20 | }
21 |
22 | public int getArticleCount() {
23 | return ArticleCount;
24 | }
25 | public void setArticleCount(int articleCount) {
26 | this.ArticleCount = articleCount;
27 | }
28 | public List getArticles() {
29 | return Articles;
30 | }
31 | public void setArticles(List articles) {
32 | this.Articles = articles;
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/src/cn/edu/lingnan/pojo/wechatpojo/TextMessage.java:
--------------------------------------------------------------------------------
1 | package cn.edu.lingnan.pojo.wechatpojo;
2 |
3 | import cn.edu.lingnan.utils.WeChatMessageUtil;
4 |
5 | public class TextMessage extends BaseMessage {
6 |
7 | private String Content; //文本消息内容
8 |
9 | public TextMessage(){
10 | super.setMsgType(WeChatMessageUtil.TEXT_MESSAGE);
11 | }
12 | public TextMessage(String toUserName, String fromUserName){
13 | super.setFromUserName(fromUserName);
14 | super.setToUserName(toUserName);
15 | super.setMsgType(WeChatMessageUtil.TEXT_MESSAGE);
16 | }
17 |
18 | public String getContent() {
19 | return Content;
20 | }
21 |
22 | public void setContent(String content) {
23 | this.Content = content;
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/src/cn/edu/lingnan/service/AdminsService.java:
--------------------------------------------------------------------------------
1 | package cn.edu.lingnan.service;
2 |
3 | import java.util.List;
4 |
5 | import org.springframework.beans.factory.annotation.Autowired;
6 | import org.springframework.stereotype.Service;
7 |
8 | import cn.edu.lingnan.dao.AdminsMapper;
9 | import cn.edu.lingnan.pojo.Admins;
10 | import cn.edu.lingnan.pojo.AdminsExample;
11 | import cn.edu.lingnan.pojo.AdminsExample.Criteria;
12 |
13 | @Service
14 | public class AdminsService {
15 |
16 | @Autowired
17 | private AdminsMapper adminsMapper;
18 |
19 | public List login(Admins admins) {
20 | AdminsExample adminsExample = new AdminsExample();
21 | Criteria criteria = adminsExample.createCriteria();
22 | criteria.andAdminnameEqualTo(admins.getAdminname());
23 | criteria.andPasswordEqualTo(admins.getPassword());
24 | return adminsMapper.selectByExample(adminsExample);
25 | }
26 |
27 |
28 | public void updateSelective(Admins admins) {
29 | adminsMapper.updateByPrimaryKeySelective(admins);
30 | }
31 |
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/src/cn/edu/lingnan/service/AnswerService.java:
--------------------------------------------------------------------------------
1 | package cn.edu.lingnan.service;
2 |
3 | import java.util.Collections;
4 | import java.util.List;
5 |
6 | import org.springframework.beans.factory.annotation.Autowired;
7 | import org.springframework.stereotype.Service;
8 |
9 |
10 | import cn.edu.lingnan.controller.AnswerController;
11 | import cn.edu.lingnan.dao.OptionsMapper;
12 | import cn.edu.lingnan.dao.QuestionMapper;
13 | import cn.edu.lingnan.dao.QuestionTypeMapper;
14 | import cn.edu.lingnan.dao.RecordsMapper;
15 | import cn.edu.lingnan.pojo.Options;
16 | import cn.edu.lingnan.pojo.OptionsExample;
17 | import cn.edu.lingnan.pojo.Question;
18 | import cn.edu.lingnan.pojo.QuestionExample;
19 | import cn.edu.lingnan.pojo.QuestionType;
20 | import cn.edu.lingnan.pojo.QuestionTypeExample;
21 | import cn.edu.lingnan.pojo.RecordsExample;
22 | import cn.edu.lingnan.pojo.QuestionTypeExample.Criteria;
23 | import cn.edu.lingnan.pojo.Records;
24 |
25 | @Service
26 | public class AnswerService {
27 |
28 | @Autowired
29 | private QuestionTypeMapper qtypeMapper;
30 | @Autowired
31 | private QuestionMapper questionMapper;
32 | @Autowired
33 | private OptionsMapper optionMapper;
34 | @Autowired
35 | private RecordsMapper recordsMapper;
36 |
37 | /**
38 | * @author huang
39 | * 查询一级菜单
40 | */
41 | public List findType() {
42 | QuestionTypeExample example = new QuestionTypeExample();
43 | Criteria criteria = example.createCriteria();
44 | criteria.andBelongtypenoIsNull();
45 | List list = qtypeMapper.selectByExample(example);
46 | return list;
47 | }
48 |
49 | /**
50 | * @author huang
51 | * 查询二级菜单
52 | */
53 | public List findType(int typeID) {
54 | QuestionTypeExample example = new QuestionTypeExample();
55 | Criteria criteria = example.createCriteria();
56 | criteria.andBelongtypenoEqualTo(typeID);
57 | List list = qtypeMapper.selectByExample(example);
58 | return list;
59 | }
60 |
61 | /**
62 | * @author huang
63 | * 根据题目类型返回题目
64 | */
65 | public List getQuestionByType(int typeno) {
66 | QuestionExample questionExample = new QuestionExample();
67 | cn.edu.lingnan.pojo.QuestionExample.Criteria criteria = questionExample.createCriteria();
68 | criteria.andTypenoEqualTo(typeno);
69 | List list = questionMapper.randSelectQuestion(typeno, AnswerController.QUESTION_NUMBER);
70 | return list;
71 | }
72 |
73 | /**
74 | * @author huang
75 | * 根据题目获取选项
76 | */
77 | public List getOptionsByQuestion(int questionno) {
78 | OptionsExample optionsExample = new OptionsExample();
79 | cn.edu.lingnan.pojo.OptionsExample.Criteria criteria = optionsExample.createCriteria();
80 | criteria.andQuestionnoEqualTo(questionno);
81 |
82 | List list = optionMapper.selectByExample(optionsExample);
83 | //将list的数据重新随机排列
84 | Collections.shuffle(list);
85 | return list;
86 | }
87 |
88 | /**
89 | * @author huang
90 | * 根据id获取类型名称
91 | */
92 | public QuestionType getQuestionTypeByID(int typeno) {
93 | return qtypeMapper.selectByPrimaryKey(typeno);
94 | }
95 |
96 | /**
97 | * @author huang
98 | * @param userno 用户编号
99 | * @param typeno 题目类型编号
100 | * @param status 答题情况,1:正确, 2:错误
101 | * 更新用户答题记录
102 | */
103 | public void answerRecord(int userno, int typeno, int status, int flag) {
104 | //判断用户是否有该类型记录
105 | RecordsExample recordsExample = new RecordsExample();
106 | cn.edu.lingnan.pojo.RecordsExample.Criteria recordCria = recordsExample.createCriteria();
107 | if (flag == 0)
108 | recordCria.andUsernoEqualTo(userno).andTypenoEqualTo(typeno);
109 | else
110 | recordCria.andWechatusernoEqualTo(userno).andTypenoEqualTo(typeno);
111 | List recordsList = recordsMapper.selectByExample(recordsExample);
112 | if (recordsList.size() <= 0) {
113 | //不存在就插入一条记录
114 | Records records = new Records();
115 | records.setTypeno(typeno);
116 | if(flag==0)
117 | records.setUserno(userno);
118 | else
119 | records.setWechatuserno(userno);
120 | if (status == 1)
121 | records.setAcnumber(1);
122 | else
123 | records.setErunmber(1);
124 | recordsMapper.insertSelective(records);
125 | return ;
126 | } else {
127 | //存在就更新记录
128 | Records rec = recordsList.get(0);
129 | if(status == 1)
130 | rec.setAcnumber(rec.getAcnumber()+1);
131 | else
132 | rec.setErunmber(rec.getErunmber()+1);
133 | recordsMapper.updateByPrimaryKey(rec);
134 | }
135 | }
136 | }
137 |
--------------------------------------------------------------------------------
/src/cn/edu/lingnan/service/OptionsService.java:
--------------------------------------------------------------------------------
1 | package cn.edu.lingnan.service;
2 |
3 | import java.util.List;
4 |
5 | import org.springframework.beans.factory.annotation.Autowired;
6 | import org.springframework.stereotype.Service;
7 |
8 | import cn.edu.lingnan.dao.OptionsMapper;
9 | import cn.edu.lingnan.pojo.Options;
10 | import cn.edu.lingnan.pojo.OptionsExample;
11 | import cn.edu.lingnan.pojo.OptionsExample.Criteria;
12 |
13 | @Service
14 | public class OptionsService {
15 |
16 | @Autowired
17 | private OptionsMapper optionsMapper;
18 |
19 | /**
20 | * 多条件查询
21 | * @param options
22 | * @return
23 | */
24 | public List selectOptionsByExample(OptionsExample options) {
25 | return optionsMapper.selectByExample(options);
26 | }
27 |
28 | /**
29 | * 更新
30 | * @param options
31 | */
32 | public void updateByPrimaryKey(Options options) {
33 | optionsMapper.updateByPrimaryKeySelective(options);
34 | }
35 |
36 |
37 | public List getQuestionOptions(Integer questionno){
38 | OptionsExample example = new OptionsExample();
39 | Criteria criteria = example.createCriteria();
40 | criteria.andQuestionnoEqualTo(questionno);
41 | return optionsMapper.selectByExample(example);
42 | }
43 |
44 | public void insert(Options options) {
45 | optionsMapper.insert(options);
46 | }
47 |
48 |
49 |
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/src/cn/edu/lingnan/service/QuestionService.java:
--------------------------------------------------------------------------------
1 | package cn.edu.lingnan.service;
2 |
3 | import java.util.List;
4 |
5 | import org.springframework.beans.factory.annotation.Autowired;
6 | import org.springframework.stereotype.Service;
7 |
8 | import cn.edu.lingnan.dao.QuestionMapper;
9 | import cn.edu.lingnan.pojo.Options;
10 | import cn.edu.lingnan.pojo.Question;
11 | import cn.edu.lingnan.pojo.QuestionExample;
12 | import cn.edu.lingnan.pojo.QuestionExample.Criteria;
13 |
14 | @Service
15 | public class QuestionService {
16 |
17 | @Autowired
18 | private QuestionMapper questionMapper;
19 |
20 | /**
21 | * 多条件查询试题
22 | * @param question
23 | * @author lizhi
24 | */
25 | public List selectQuestionByExample(Question question) {
26 | QuestionExample example = new QuestionExample();
27 | Criteria criteria = example.createCriteria();
28 | if(question.getQuestionno()!=null){
29 | criteria.andQuestionnoEqualTo(question.getQuestionno());
30 | }
31 | if(question.getConstatus()!=null&&!question.getConstatus().equals("")){
32 | criteria.andConstatusEqualTo(question.getConstatus());
33 | }
34 | if(question.getTypeno()!=null){
35 | criteria.andTypenoEqualTo(question.getTypeno());
36 | }
37 | List list = questionMapper.selectByExample(example);
38 | return list;
39 | }
40 |
41 | public void updateByPrimaryKey(Question question) {
42 | questionMapper.updateByPrimaryKeySelective(question);
43 | }
44 |
45 | public void updateSelective(Question question){
46 | questionMapper.updateByPrimaryKeySelective(question);
47 | }
48 |
49 |
50 | public void insertQuestion(Question question) {
51 | questionMapper.insert(question);
52 | }
53 |
54 | public void deleteQuestion(Integer id) {
55 | questionMapper.deleteByPrimaryKey(id);
56 | }
57 |
58 | public Question getQuestionByKey(Integer questionno) {
59 | return questionMapper.selectByPrimaryKey(questionno);
60 | }
61 |
62 | }
63 |
--------------------------------------------------------------------------------
/src/cn/edu/lingnan/service/RecordsService.java:
--------------------------------------------------------------------------------
1 | package cn.edu.lingnan.service;
2 |
3 | import java.util.List;
4 |
5 | import org.springframework.beans.factory.annotation.Autowired;
6 | import org.springframework.stereotype.Service;
7 |
8 | import cn.edu.lingnan.dao.RecordsMapper;
9 | import cn.edu.lingnan.pojo.Records;
10 | import cn.edu.lingnan.pojo.RecordsExample;
11 |
12 | @Service
13 | public class RecordsService {
14 |
15 | @Autowired
16 | private RecordsMapper recordsMapper;
17 |
18 | public List selectRecordsByExample(RecordsExample recordsExample) {
19 | return recordsMapper.selectByExample(recordsExample);
20 | }
21 |
22 | public void updateRecords(Records records) {
23 | recordsMapper.updateByPrimaryKeySelective(records);
24 | }
25 |
26 | public void addRecords(Records records) {
27 | recordsMapper.insert(records);
28 | }
29 |
30 | public void deleteRecords(Integer userNo) {
31 | recordsMapper.deleteByPrimaryKey(userNo);
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/src/cn/edu/lingnan/service/TaskService.java:
--------------------------------------------------------------------------------
1 | package cn.edu.lingnan.service;
2 |
3 | import java.text.SimpleDateFormat;
4 | import java.util.Date;
5 | import java.util.List;
6 |
7 | import org.springframework.beans.factory.annotation.Autowired;
8 | import org.springframework.context.annotation.Lazy;
9 | import org.springframework.scheduling.annotation.Scheduled;
10 | import org.springframework.stereotype.Component;
11 |
12 | import cn.edu.lingnan.dao.TempUrlMapper;
13 | import cn.edu.lingnan.dao.UserMapper;
14 | import cn.edu.lingnan.pojo.TempUrl;
15 | import cn.edu.lingnan.pojo.TempUrlExample;
16 | import cn.edu.lingnan.pojo.TempUrlExample.Criteria;
17 | import cn.edu.lingnan.pojo.User;
18 | import cn.edu.lingnan.pojo.UserExample;
19 | import cn.edu.lingnan.utils.BOSUtil;
20 |
21 | /**
22 | *
23 | * @author huang
24 | * 定时任务
25 | */
26 | @Component
27 | @Lazy(false)
28 | public class TaskService {
29 |
30 | @Autowired
31 | private TempUrlMapper tempUrlMapper;
32 | @Autowired
33 | private UserMapper userMapper;
34 | /**
35 | * @author huang
36 | * 定时清理BOS中当前时间5分钟前的文件
37 | */
38 | @Scheduled(cron="0 0 0/1 * * ?")
39 | public void timerDeleteBosTemp() {
40 | SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmss");
41 | Long nowdate = Long.parseLong(format.format(new Date()));
42 | String oldtime = new Long(nowdate-10000).toString();
43 | TempUrlExample tempExample = new TempUrlExample();
44 | Criteria criteria = tempExample.createCriteria();
45 | criteria.andNewdateLessThan(oldtime);
46 | List tempList = tempUrlMapper.selectByExample(tempExample);
47 | for(TempUrl t : tempList) {
48 | tempUrlMapper.deleteByPrimaryKey(t.getTempurlid());
49 | BOSUtil.deleteFile("temp/" + t.getFileurl());
50 | }
51 | }
52 |
53 | /**
54 | * @author huang
55 | * 每天2:30清理一天前没有验证的用户
56 | */
57 | @Scheduled(cron = "0 30 2 * * ?")
58 | public void timerDeleteNoValidatorUser(){
59 | SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmss");
60 | Long nowdate = Long.parseLong(format.format(new Date()));
61 | //找出数据库1天前的数据
62 | String oldtime = new Long(nowdate-1000000).toString();
63 | UserExample userExample = new UserExample();
64 | cn.edu.lingnan.pojo.UserExample.Criteria criteria = userExample.createCriteria();
65 | criteria.andNewdateLessThan(oldtime).andStatusEqualTo(0);
66 | userMapper.deleteByExample(userExample);
67 | }
68 |
69 | }
70 |
--------------------------------------------------------------------------------
/src/cn/edu/lingnan/service/TempUrlService.java:
--------------------------------------------------------------------------------
1 | package cn.edu.lingnan.service;
2 |
3 | import org.springframework.beans.factory.annotation.Autowired;
4 | import org.springframework.stereotype.Service;
5 |
6 | import cn.edu.lingnan.dao.TempUrlMapper;
7 | import cn.edu.lingnan.pojo.TempUrl;
8 |
9 | @Service
10 | public class TempUrlService {
11 |
12 | @Autowired
13 | private TempUrlMapper tempUrlMapper;
14 |
15 | public void addTempUrl(TempUrl tempUrl){
16 | tempUrlMapper.insertSelective(tempUrl);
17 | }
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/src/cn/edu/lingnan/service/TestService.java:
--------------------------------------------------------------------------------
1 | package cn.edu.lingnan.service;
2 |
3 | import java.util.List;
4 |
5 | import org.springframework.beans.factory.annotation.Autowired;
6 | import org.springframework.stereotype.Service;
7 |
8 | import cn.edu.lingnan.dao.TestMapper;
9 |
10 | @Service
11 | public class TestService {
12 |
13 | @Autowired
14 | private TestMapper testMapper;
15 |
16 | public List selectTest(){
17 | return testMapper.selectTest();
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/src/cn/edu/lingnan/service/UserService.java:
--------------------------------------------------------------------------------
1 | package cn.edu.lingnan.service;
2 |
3 | import java.util.List;
4 |
5 | import org.springframework.beans.factory.annotation.Autowired;
6 | import org.springframework.stereotype.Service;
7 |
8 | import cn.edu.lingnan.dao.RecordsMapper;
9 | import cn.edu.lingnan.dao.UserMapper;
10 | import cn.edu.lingnan.pojo.Records;
11 | import cn.edu.lingnan.pojo.RecordsExample;
12 | import cn.edu.lingnan.pojo.User;
13 | import cn.edu.lingnan.pojo.UserExample;
14 | import cn.edu.lingnan.pojo.UserExample.Criteria;
15 |
16 | @Service
17 | public class UserService {
18 |
19 | @Autowired
20 | private UserMapper userMapper;
21 | @Autowired
22 | private RecordsMapper recordsMapper;
23 |
24 | /**
25 | * 多条件查询用户
26 | * @param user
27 | * @author lizhi
28 | */
29 | public List selectUserByExample(User user){
30 | UserExample example = new UserExample();
31 | Criteria criteria = example.createCriteria();
32 | if(user.getUserno()!=null){
33 | criteria.andUsernoEqualTo(user.getUserno());
34 | }
35 | if(user.getUsername()!=null&&!user.getUsername().equals("")){
36 | criteria.andUsernameEqualTo(user.getUsername());
37 | }
38 | if(user.getPassword()!=null&&!user.getPassword().equals("")){
39 | criteria.andPasswordEqualTo(user.getPassword());
40 | }
41 | if(user.getEmail()!=null&&!user.getEmail().equals("")){
42 | criteria.andEmailEqualTo(user.getEmail());
43 | }
44 | if(user.getSex()!=null&&!user.getSex().equals("")){
45 | criteria.andSexEqualTo(user.getSex());
46 | }
47 | if(user.getStatus()!=null){
48 | criteria.andStatusEqualTo(user.getStatus());
49 | }
50 | return userMapper.selectByExample(example);
51 | }
52 |
53 | public void deleteUser(Integer id) {
54 | //1:先删除用户答题记录
55 | recordsMapper.deleteByPrimaryKey(id);
56 | //2:删除用户
57 | userMapper.deleteByPrimaryKey(id);
58 | }
59 |
60 | public void addUser(User user) {
61 | userMapper.insertSelective(user);
62 | }
63 |
64 | public void updateUser(User user) {
65 | userMapper.updateByPrimaryKeySelective(user);
66 | }
67 |
68 | /*
69 | * 登录
70 | */
71 | public List login(User user){
72 | UserExample userExample = new UserExample();
73 | Criteria criteria = userExample.createCriteria();
74 | criteria.andEmailEqualTo(user.getEmail()).andPasswordEqualTo(user.getPassword());
75 | return userMapper.selectByExample(userExample);
76 | }
77 |
78 | /*
79 | * 注册
80 | */
81 | public int register(User user) {
82 | return userMapper.insertSelective(user);
83 | }
84 |
85 | /*
86 | * 根据用户id获取用户信息
87 | */
88 | public User getUserByUserno(int userno) {
89 | return userMapper.selectByPrimaryKey(userno);
90 | }
91 |
92 | /*
93 | * 用户通过验证
94 | */
95 | public int confirmValidator(int userno) {
96 | //根据id获取用户对象
97 | User user = getUserByUserno(userno);
98 | //修改验证码
99 | user.setStatus(1);
100 | return userMapper.updateByPrimaryKeySelective(user);
101 | }
102 |
103 | /*
104 | * 根据邮箱判断用户是否存在
105 | */
106 | public User findUserByEmail(String email) {
107 | UserExample userExample = new UserExample();
108 | Criteria cri = userExample.createCriteria();
109 | cri.andEmailEqualTo(email);
110 | List list = userMapper.selectByExample(userExample);
111 | if (list.size() > 0)
112 | return list.get(0);
113 | return null;
114 | }
115 |
116 | /**
117 | * 批量根据用户id删除用户
118 | * @param str_ids
119 | */
120 | public void deleteBatch(List ids) {
121 | //封装一个条件
122 | UserExample example = new UserExample();
123 | //条件是什么
124 | Criteria criteria = example.createCriteria();
125 | //delete from tbl_emp where emp_id in (1,2,3)
126 | criteria.andUsernoIn(ids);
127 | userMapper.deleteByExample(example);
128 |
129 | }
130 |
131 | /**
132 | * @author huang
133 | * @param userno 用户编号
134 | * @return
135 | * 根据用户编号获取用户答题记录
136 | */
137 | public List getWebUserInfo(int userno){
138 | RecordsExample recordsExample = new RecordsExample();
139 | cn.edu.lingnan.pojo.RecordsExample.Criteria criteria = recordsExample.createCriteria();
140 | criteria.andUsernoEqualTo(userno);
141 | return recordsMapper.selectByExample(recordsExample);
142 | }
143 |
144 | }
145 |
--------------------------------------------------------------------------------
/src/cn/edu/lingnan/service/WeChatService.java:
--------------------------------------------------------------------------------
1 | package cn.edu.lingnan.service;
2 |
3 | import java.util.ArrayList;
4 | import java.util.Date;
5 | import java.util.List;
6 | import java.util.Map;
7 |
8 | import javax.servlet.http.HttpServletRequest;
9 |
10 | import org.springframework.beans.factory.annotation.Autowired;
11 | import org.springframework.stereotype.Service;
12 |
13 | import cn.edu.lingnan.controller.WeChatController;
14 | import cn.edu.lingnan.dao.RecordsMapper;
15 | import cn.edu.lingnan.dao.WeChatUserMapper;
16 | import cn.edu.lingnan.pojo.Records;
17 | import cn.edu.lingnan.pojo.RecordsExample;
18 | import cn.edu.lingnan.pojo.WeChatUser;
19 | import cn.edu.lingnan.pojo.WeChatUserExample;
20 | import cn.edu.lingnan.pojo.WeChatUserExample.Criteria;
21 | import cn.edu.lingnan.pojo.wechatpojo.Article;
22 | import cn.edu.lingnan.pojo.wechatpojo.NewsMessage;
23 | import cn.edu.lingnan.pojo.wechatpojo.TextMessage;
24 | import cn.edu.lingnan.utils.WeChatMessageUtil;
25 |
26 | @Service
27 | public class WeChatService {
28 |
29 | @Autowired
30 | private WeChatUserMapper weChatUserMapper;
31 | @Autowired
32 | private RecordsMapper recordsMapper;
33 |
34 | //解析用户发来的消息
35 | public String disposeMessage(HttpServletRequest req) {
36 | Map map = WeChatMessageUtil.parseXml(req);
37 | String fromUserName = map.get("FromUserName"); //从什么用户发来
38 | String toUserName = map.get("ToUserName"); //给谁发送
39 | String msgType = map.get("MsgType"); //消息类型
40 |
41 | if (msgType.equals(WeChatMessageUtil.TEXT_MESSAGE)) {
42 | //消息是文本消息
43 | String content = map.get("Content");
44 | return parseText(content, fromUserName, toUserName);
45 | } else if(msgType.equals(WeChatMessageUtil.REQUEST_EVENT_MESSAGE)) {
46 | //消息是点击菜单事件
47 | String event = map.get("Event");
48 | if (event.equals("CLICK")) {
49 | String eventKey = map.get("EventKey");
50 | return clickEvent(eventKey, fromUserName, toUserName);
51 | } else {
52 | return "";
53 | }
54 | } else {
55 | //其他消息不处理
56 | return "";
57 | }
58 | }
59 |
60 | /**
61 | * 解析用户发来的消息
62 | * @param str
63 | * @param toUserName
64 | * @param fromUserName
65 | * @return
66 | */
67 | public String parseText(String str,String toUserName, String fromUserName) {
68 | if (str.equals("帮助")) {
69 | StringBuffer content = new StringBuffer();
70 | content.append("您好, 请回复下方文字选择功能: \n\n");
71 | content.append("答题/:B-)\n");
72 | content.append("回复帮助显示此菜单");
73 | //封装消息
74 | TextMessage textMessage = new TextMessage(toUserName, fromUserName);
75 | textMessage.setCreateTime(new Date().getTime());
76 | textMessage.setContent(content.toString());
77 | return WeChatMessageUtil.textMessageToXml(textMessage);
78 | } else if (str.equals("答题")) {
79 | NewsMessage newsMessage = new NewsMessage(toUserName, fromUserName);
80 | newsMessage.setArticleCount(1);
81 | newsMessage.setCreateTime(new Date().getTime());
82 |
83 | Article article = new Article();
84 | article.setDescription("点击进入答题系统");
85 | article.setPicUrl("http://mmbiz.qpic.cn/mmbiz_jpg/3kesMWorbs7ZpPVv2YjdpSFNe6Z70dSDicAtHJiayT3icTmT3RkAmllficaxYibqbNm08sGPGw5WbmUa2Cvs0fn0GKw/0");
86 | article.setTitle("答题系统");
87 | article.setUrl(WeChatController.SERVER + "/AnswerWeb/wechat/authorize");
88 |
89 | List list = new ArrayList();
90 | list.add(article);
91 |
92 | newsMessage.setArticles(list);
93 | return WeChatMessageUtil.NewsMessageToXml(newsMessage);
94 | } else {
95 | TextMessage textMessage = new TextMessage(toUserName, fromUserName);
96 | textMessage.setCreateTime(new Date().getTime());
97 | textMessage.setContent(str + "(接收什么返回什么,用于测试)");
98 | return WeChatMessageUtil.textMessageToXml(textMessage);
99 | }
100 | }
101 |
102 | /**
103 | * @author huang
104 | * @param eventKey
105 | * @param toUserName
106 | * @param fromUserName
107 | * @return
108 | * 公众号菜单的点击事件
109 | */
110 | public String clickEvent(String eventKey, String toUserName, String fromUserName) {
111 | if (eventKey.equals("MyGame"))
112 | return parseText("答题", toUserName, fromUserName);
113 | else if (eventKey.equals("Menus"))
114 | return parseText("帮助", toUserName, fromUserName);
115 | else
116 | return "";
117 | }
118 |
119 | /**
120 | * @author huang
121 | * 储存微信用户信息
122 | */
123 | public void addWeChatUser(WeChatUser wechatuser) {
124 | if (wechatuser.getOpenid() != null)
125 | weChatUserMapper.insertSelective(wechatuser);
126 | }
127 |
128 | /**
129 | * @author huang
130 | * 判断有无微信用户存在
131 | */
132 | public WeChatUser isExistsUser(WeChatUser wechatuser) {
133 | if(wechatuser.getOpenid() != null) {
134 | WeChatUserExample example = new WeChatUserExample();
135 | Criteria criteria = example.createCriteria();
136 | criteria.andOpenidEqualTo(wechatuser.getOpenid());
137 | List list = weChatUserMapper.selectByExample(example);
138 | if (list.size() > 0)
139 | return list.get(0);
140 | else
141 | return null;
142 | }
143 | return null;
144 | }
145 |
146 | /**
147 | * @author huang
148 | * 获取微信用户答题记录
149 | */
150 | public List getWeChatUserInfo(int wechatuserno) {
151 | RecordsExample recordsExample = new RecordsExample();
152 | cn.edu.lingnan.pojo.RecordsExample.Criteria criteria = recordsExample.createCriteria();
153 | criteria.andWechatusernoEqualTo(wechatuserno);
154 | return recordsMapper.selectByExample(recordsExample);
155 | }
156 |
157 | public void updateWeChatUser(WeChatUser weChatUser) {
158 | weChatUserMapper.updateByPrimaryKeySelective(weChatUser);
159 | }
160 |
161 | /**
162 | * 根据id获取微信用户
163 | * @param wechatuserno
164 | * @return
165 | */
166 | public WeChatUser getWechatUser(Integer wechatuserno){
167 | return weChatUserMapper.selectByPrimaryKey(wechatuserno);
168 | }
169 |
170 |
171 | }
172 |
--------------------------------------------------------------------------------
/src/cn/edu/lingnan/utils/BOSUtil.java:
--------------------------------------------------------------------------------
1 | package cn.edu.lingnan.utils;
2 |
3 | import java.io.IOException;
4 | import java.io.InputStream;
5 |
6 | import org.springframework.web.multipart.MultipartFile;
7 |
8 | import com.baidubce.auth.DefaultBceCredentials;
9 | import com.baidubce.services.bos.BosClient;
10 | import com.baidubce.services.bos.BosClientConfiguration;
11 |
12 | /**
13 | *
14 | * @author huang
15 | * 上传数据到百度云BOS对象存储中
16 | */
17 | public class BOSUtil {
18 |
19 | //private final static String ACCESS_KEY_ID = "xxx";
20 | //private final static String SECRET_ACCESS_KEY = "xxx";
21 | private final static String ACCESS_KEY_ID = "xxx";
22 | private final static String SECRET_ACCESS_KEY = "xxx";
23 |
24 | private final static String BUCKET_NAME = "cn-malizhi-answerweb"; //上传的文件夹名称
25 | //private final static String BUCKET_NAME = "cn-edu-lingnan";
26 |
27 |
28 | /**
29 | * @author huang
30 | * @param file 文件对象
31 | * @param path 存储路径,例如/resource/images/type/test.txt
32 | * @return 成功失败
33 | * 将文件上传都BOS对象存储中
34 | */
35 | public static boolean upload(MultipartFile file, String path) {
36 | //创建BOS client
37 | BosClientConfiguration config = new BosClientConfiguration();
38 | config.setCredentials(new DefaultBceCredentials(ACCESS_KEY_ID, SECRET_ACCESS_KEY));
39 | config.setEndpoint("gz.bcebos.com");
40 | BosClient client = new BosClient(config);
41 |
42 | try {
43 | InputStream inputStream = file.getInputStream();
44 | client.putObject(BUCKET_NAME, path, inputStream);
45 | } catch (IOException e) {
46 | e.printStackTrace();
47 | return false;
48 | }
49 |
50 | /* 测试用例*/
51 | /*InputStream inputStream = new ByteArrayInputStream("hello java".getBytes());
52 | client.putObject(BUCKET_NAME, path, inputStream);*/
53 | return true;
54 | }
55 |
56 | /**
57 | * @author huange
58 | * @param filepath 原文件路径
59 | * @param newpath 移动的路径
60 | * @return
61 | * 移动BOS的文件
62 | */
63 | public static boolean moveFile(String filepath, String newpath) {
64 | BosClientConfiguration config = new BosClientConfiguration();
65 | config.setCredentials(new DefaultBceCredentials(ACCESS_KEY_ID, SECRET_ACCESS_KEY));
66 | config.setEndpoint("gz.bcebos.com");
67 | BosClient client = new BosClient(config);
68 | client.copyObject(BUCKET_NAME, filepath, BUCKET_NAME, newpath);
69 | return true;
70 | }
71 |
72 | /**
73 | * @author huang
74 | * @param filepath 删除文件路径
75 | * @return
76 | * 删除BOS文件
77 | */
78 | public static boolean deleteFile(String filepath) {
79 | BosClientConfiguration config = new BosClientConfiguration();
80 | config.setCredentials(new DefaultBceCredentials(ACCESS_KEY_ID, SECRET_ACCESS_KEY));
81 | config.setEndpoint("gz.bcebos.com");
82 | BosClient client = new BosClient(config);
83 | try {
84 | client.getObjectMetadata(BUCKET_NAME, filepath);
85 | client.deleteObject(BUCKET_NAME, filepath);
86 | } catch (Exception e) {
87 | return false;
88 | }
89 | return true;
90 | }
91 |
92 | public static void main(String[] args) {
93 | for (int i=1; i<=10; i++) {
94 | upload(null, "/temp/text" + i + ".txt");
95 | }
96 | // moveFile("/temp/text.txt", "/resource/images/ /test.txt");
97 | // deleteFile("/temp/text.txt");
98 | }
99 |
100 | }
101 |
--------------------------------------------------------------------------------
/src/cn/edu/lingnan/utils/GeneratorSqlmap.java:
--------------------------------------------------------------------------------
1 | package cn.edu.lingnan.utils;
2 |
3 | import java.io.File;
4 | import java.util.ArrayList;
5 | import java.util.List;
6 |
7 | import org.mybatis.generator.api.MyBatisGenerator;
8 | import org.mybatis.generator.config.Configuration;
9 | import org.mybatis.generator.config.xml.ConfigurationParser;
10 | import org.mybatis.generator.internal.DefaultShellCallback;
11 |
12 | /**
13 | * @version 1.0
14 | * @author huang
15 | * 不知道为什么使用Maven generate-source 反向工程失败, 只能手动来了
16 | */
17 |
18 | public class GeneratorSqlmap {
19 |
20 | public void generator() throws Exception {
21 | List warnings = new ArrayList();
22 | boolean overwrite = true;
23 |
24 | File configFile = new File("mysqlGeneratorConfig.xml");
25 | ConfigurationParser cp = new ConfigurationParser(warnings);
26 | Configuration config = cp.parseConfiguration(configFile);
27 | DefaultShellCallback callback = new DefaultShellCallback(overwrite);
28 | MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, callback, warnings);
29 | myBatisGenerator.generate(null);
30 | }
31 |
32 | public static void main(String[] args) {
33 | try{
34 | new GeneratorSqlmap().generator();
35 | } catch (Exception e) {
36 | e.printStackTrace();
37 | }
38 | }
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/src/cn/edu/lingnan/utils/HttpUtil.java:
--------------------------------------------------------------------------------
1 | package cn.edu.lingnan.utils;
2 |
3 | import java.io.InputStreamReader;
4 | import java.io.OutputStreamWriter;
5 | import java.net.MalformedURLException;
6 | import java.net.URL;
7 |
8 | import javax.net.ssl.HttpsURLConnection;
9 |
10 | /**
11 | *
12 | * @author huang
13 | * 根据链接获取微信的json返回值
14 | */
15 | public class HttpUtil {
16 |
17 | public static String getReturnJson(String url, String osrJson) {
18 | String result = "";
19 | try {
20 | URL reqURL = new URL(url);
21 | HttpsURLConnection httpsConn = (HttpsURLConnection) reqURL.openConnection();
22 | if(osrJson != null) {
23 | httpsConn.setDoOutput(true);
24 | OutputStreamWriter osr = new OutputStreamWriter(httpsConn.getOutputStream());
25 | osr.write(osrJson);
26 | osr.close();
27 | }
28 | InputStreamReader isr = new InputStreamReader(httpsConn.getInputStream());
29 | char[] chars = new char[1024];
30 | int len;
31 | while((len = isr.read(chars)) != -1) {
32 | result += new String(chars, 0, len);
33 | }
34 | isr.close();
35 | } catch (Exception e) {
36 | e.printStackTrace();
37 | }
38 | return result;
39 | }
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/src/cn/edu/lingnan/utils/MailUtil.java:
--------------------------------------------------------------------------------
1 | package cn.edu.lingnan.utils;
2 |
3 | import java.util.Properties;
4 |
5 | import javax.mail.MessagingException;
6 | import javax.mail.internet.MimeMessage;
7 |
8 | import org.springframework.mail.MailException;
9 | import org.springframework.mail.SimpleMailMessage;
10 | import org.springframework.mail.javamail.JavaMailSenderImpl;
11 | import org.springframework.mail.javamail.MimeMessageHelper;
12 |
13 | public class MailUtil {
14 |
15 | private static String myEmailAccount = "xxxxx";
16 | private static String myEmailPassword = "xxxxx";
17 |
18 | private static String myEmailSMTPHost = "smtp.qq.com";
19 | private static String SMTP = "smtp";
20 | private static int port = 587;
21 | private static String defaultEncoding = "UTF-8";
22 |
23 | private static JavaMailSenderImpl senderImpl = new JavaMailSenderImpl();
24 | private static Properties prop = new Properties();
25 |
26 | // 验证邮箱
27 | // String html = ""
28 | // + "点击验证邮箱"
29 | // + "";
30 |
31 | // 修改验证邮箱
32 |
33 | static {
34 | senderImpl.setHost(myEmailSMTPHost);
35 | senderImpl.setProtocol(SMTP);
36 | senderImpl.setUsername(myEmailAccount);
37 | senderImpl.setPassword(myEmailPassword);
38 | senderImpl.setPort(port);
39 | senderImpl.setDefaultEncoding(defaultEncoding);
40 |
41 | prop.put("mail.smtp.auth", true);
42 | prop.put("mail.smtp.timeout", 25000);
43 | prop.put("mail.debug", true);
44 |
45 | senderImpl.setJavaMailProperties(prop);
46 | }
47 |
48 | public static boolean sendFindPasswordMail(String to,String content) {
49 | boolean flag = true;
50 | SimpleMailMessage mailMessage = new SimpleMailMessage();
51 | mailMessage.setTo(to);
52 | mailMessage.setFrom(myEmailAccount);
53 | mailMessage.setSubject("找回密码");
54 | mailMessage.setText("您的密码是:" + content);
55 | try {
56 | senderImpl.send(mailMessage);
57 | } catch(MailException e) {
58 | flag = false;
59 | }
60 | return flag;
61 | }
62 |
63 | public static boolean sendValidatorMail(String to,String html) {
64 | boolean flag = true;
65 | MimeMessage mailMessage = senderImpl.createMimeMessage();
66 | MimeMessageHelper messageHelper = new MimeMessageHelper(mailMessage);
67 | try {
68 | messageHelper.setTo(to);
69 | messageHelper.setFrom(myEmailAccount);
70 | messageHelper.setSubject("邮箱验证");
71 | messageHelper.setText(html, true);
72 | senderImpl.send(mailMessage);
73 | } catch(Exception e) {
74 | flag = false;
75 | }
76 | return flag;
77 | }
78 |
79 | }
80 |
--------------------------------------------------------------------------------
/src/cn/edu/lingnan/utils/SignUtil.java:
--------------------------------------------------------------------------------
1 | package cn.edu.lingnan.utils;
2 |
3 | import java.security.MessageDigest;
4 | import java.security.NoSuchAlgorithmException;
5 | import java.util.Arrays;
6 |
7 | /**
8 | * @author huang
9 | * 对微信发来的验证信息做验证
10 | */
11 |
12 | public class SignUtil {
13 |
14 | private static String token = "yuanweixin";
15 |
16 | public static boolean checkSignature(String signature, String timestamp, String nonce) {
17 | String[] arr = new String[] {token, timestamp, nonce};
18 | Arrays.sort(arr);
19 | StringBuffer content = new StringBuffer();
20 | for (String str : arr)
21 | content.append(str);
22 | MessageDigest md = null;
23 | String tmpStr = null;
24 | try {
25 | md = MessageDigest.getInstance("SHA-1");
26 | byte[] digest = md.digest(content.toString().getBytes());
27 | tmpStr = byteTostr(digest);
28 | } catch (NoSuchAlgorithmException e) {
29 | e.printStackTrace();
30 | }
31 | content = null;
32 | return tmpStr != null ? tmpStr.equals(signature.toUpperCase()) : false;
33 | }
34 |
35 | public static String byteTostr(byte[] byteArray) {
36 | String strDigest = "";
37 | for (int i=0; i>> 4) & 0x0F];
47 | tempArr[1] = Digit[mByte & 0x0F];
48 | String s = new String(tempArr);
49 | return s;
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/src/cn/edu/lingnan/utils/TransmisstionProtected.java:
--------------------------------------------------------------------------------
1 | package cn.edu.lingnan.utils;
2 |
3 | import java.text.ParseException;
4 | import java.text.SimpleDateFormat;
5 | import java.util.Base64;
6 | import java.util.Date;
7 | import java.util.UUID;
8 |
9 | /**
10 | *
11 | * @author huang
12 | * 用于邮件信息加密
13 | */
14 | public class TransmisstionProtected {
15 |
16 | /**
17 | * @author huang
18 | * @param uuid 操作唯一标识符
19 | * @return Base64编码的加密字符串
20 | * 对加密信息类进行加密
21 | */
22 | public static String encodeToString(UUID uuid) {
23 | //拼接字符串
24 | SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmss");
25 | String appid = uuid.toString().replace("-", "") + "-" + format.format(new Date());
26 | //转化为Base64编码
27 | return Base64.getUrlEncoder().encodeToString(appid.getBytes());
28 | }
29 |
30 | /**
31 | * @author huang
32 | * @param appid 加密字符串
33 | * @return
34 | * 解密加密信息
35 | */
36 | public static String[] decodeToStringArray(String appid) {
37 | appid = new String(Base64.getUrlDecoder().decode(appid));
38 | return appid.split("-");
39 | }
40 |
41 | /**
42 | * @author huang
43 | * @param args
44 | * @throws InterruptedException
45 | * @throws ParseException
46 | * 用于测试
47 | */
48 | public static void main(String[] args) throws InterruptedException, ParseException {
49 | System.out.println("----------------加密---------------");
50 | UUID uuid = UUID.randomUUID();
51 | SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmss");
52 | String appid = uuid.toString().replace("-", "") + "-" + format.format(new Date());
53 | System.out.println("appid=" + appid);
54 | byte[] by = appid.getBytes();
55 | for(int i=0;i");
59 | } else {
60 | writer.write(text);
61 | }
62 | }
63 | };
64 | }
65 | });
66 |
67 | /**
68 | * @author huang
69 | * @param req
70 | * 解析微信发送的xml信息
71 | */
72 | public static Map parseXml(HttpServletRequest req) {
73 | Map map = new HashMap();
74 | try {
75 | InputStream inputStream = req.getInputStream();
76 | SAXReader reader = new SAXReader();
77 | Document document = reader.read(inputStream);
78 | Element root = document.getRootElement();
79 | List list = root.elements();
80 | for(Element e : list)
81 | map.put(e.getName(), e.getText());
82 | inputStream.close();
83 | inputStream = null;
84 | } catch (IOException | DocumentException e) {
85 | e.printStackTrace();
86 | }
87 | return map;
88 | }
89 |
90 | /**
91 | * @author huang
92 | * @param textMessage
93 | * 将文本消息封装为xml返回给微信
94 | */
95 | public static String textMessageToXml(TextMessage textMessage) {
96 | xstream.alias("xml", textMessage.getClass());
97 | return xstream.toXML(textMessage);
98 | }
99 |
100 | /**
101 | * @author huang
102 | * @param newsMessage
103 | * 将图文消息封装为xml返回给微信
104 | */
105 | public static String NewsMessageToXml(NewsMessage newsMessage) {
106 | xstream.alias("xml", newsMessage.getClass());
107 | xstream.alias("item", new Article().getClass());
108 | return xstream.toXML(newsMessage);
109 | }
110 | }
111 |
--------------------------------------------------------------------------------