Commit fba7642fa64c284253932aa023bef7b8e8a16010
Merge branch 'develop' of http://120.78.57.84/Elvis/SunvoteEducation into develop
Showing
5 changed files
with
58 additions
and
51 deletions
WebRoot/WEB-INF/jsp/sunvote/teacher/teacher_edit3.jsp
| @@ -157,14 +157,16 @@ | @@ -157,14 +157,16 @@ | ||
| 157 | type:"POST", | 157 | type:"POST", |
| 158 | success:function(res){ | 158 | success:function(res){ |
| 159 | console.log(res); | 159 | console.log(res); |
| 160 | - | ||
| 161 | - $("#save_btn").tips({ | ||
| 162 | - side:3, | ||
| 163 | - msg:res.data, | ||
| 164 | - bg:'#AE81FF', | ||
| 165 | - time:2 | ||
| 166 | - }); | ||
| 167 | - window.top.modal.remove(); | 160 | + if(res.code == 0){ |
| 161 | + window.top.modal.remove(); | ||
| 162 | + }else{ | ||
| 163 | + $("#PASSWORD_OLD").tips({ | ||
| 164 | + side:3, | ||
| 165 | + msg:res.message, | ||
| 166 | + bg:'#AE81FF', | ||
| 167 | + time:2 | ||
| 168 | + }); | ||
| 169 | + } | ||
| 168 | } | 170 | } |
| 169 | }) | 171 | }) |
| 170 | //$("#Form").submit(); | 172 | //$("#Form").submit(); |
src/com/fh/controller/api/ResponseGson.java
| @@ -144,5 +144,9 @@ public class ResponseGson<T> { | @@ -144,5 +144,9 @@ public class ResponseGson<T> { | ||
| 144 | message = "分别对错误进行描述,1 具体到某个参数值问题的描述" ; | 144 | message = "分别对错误进行描述,1 具体到某个参数值问题的描述" ; |
| 145 | } | 145 | } |
| 146 | 146 | ||
| 147 | + public void set5Error(){ | ||
| 148 | + code = "5" ; | ||
| 149 | + message = "原密码输入错误!"; | ||
| 150 | + } | ||
| 147 | 151 | ||
| 148 | } | 152 | } |
src/com/fh/controller/sunvote/homework/HomeworkController.java
| @@ -338,6 +338,8 @@ public class HomeworkController extends BaseController { | @@ -338,6 +338,8 @@ public class HomeworkController extends BaseController { | ||
| 338 | } | 338 | } |
| 339 | stuPd.put("STUDENT_ALL_SCORE", get); | 339 | stuPd.put("STUDENT_ALL_SCORE", get); |
| 340 | stuPd.put("PAPER_ALL_SCORE", all); | 340 | stuPd.put("PAPER_ALL_SCORE", all); |
| 341 | + stuPd.put("COMPLETE_COUNT", 1); | ||
| 342 | + stuPd.put("ALL_COUNT", 1); | ||
| 341 | stuPd.remove("SCHOOL_ID"); | 343 | stuPd.remove("SCHOOL_ID"); |
| 342 | stuPd.remove("SEX"); | 344 | stuPd.remove("SEX"); |
| 343 | stuPd.remove("CLASS_ID"); | 345 | stuPd.remove("CLASS_ID"); |
| @@ -359,7 +361,6 @@ public class HomeworkController extends BaseController { | @@ -359,7 +361,6 @@ public class HomeworkController extends BaseController { | ||
| 359 | hpd.remove("CODE"); | 361 | hpd.remove("CODE"); |
| 360 | hpd.remove("GET_MAX_SCORE"); | 362 | hpd.remove("GET_MAX_SCORE"); |
| 361 | hpd.remove("HOMEWORK_DESC"); | 363 | hpd.remove("HOMEWORK_DESC"); |
| 362 | - hpd.remove("COMPLETE_DESC"); | ||
| 363 | } | 364 | } |
| 364 | data.put("HOMEWORKS", homeworkList);// | 365 | data.put("HOMEWORKS", homeworkList);// |
| 365 | data.put("STUDENTS", studentList); | 366 | data.put("STUDENTS", studentList); |
src/com/fh/controller/sunvote/teacher/TeacherController.java
| @@ -172,6 +172,18 @@ public class TeacherController extends BaseController { | @@ -172,6 +172,18 @@ public class TeacherController extends BaseController { | ||
| 172 | PageData pd = new PageData(); | 172 | PageData pd = new PageData(); |
| 173 | pd = this.getPageData(); | 173 | pd = this.getPageData(); |
| 174 | teacherService.edit(pd); | 174 | teacherService.edit(pd); |
| 175 | + pd.put("USER_ID", pd.getString("ID")); // ID 主键 | ||
| 176 | + pd.put("LAST_LOGIN", ""); // 最后登录时间 | ||
| 177 | + pd.put("IP", ""); // IP | ||
| 178 | + pd.put("STATUS", "0"); // 状态 | ||
| 179 | + pd.put("SKIN", "default"); | ||
| 180 | + pd.put("RIGHTS", ""); | ||
| 181 | + pd.put("USERNAME", pd.getString("ACCOUT")); | ||
| 182 | + pd.put("ROLE_ID", "57bb1e6f138247a0b05cc721a5da1b64"); | ||
| 183 | + pd.put("PASSWORD", | ||
| 184 | + new SimpleHash("SHA-1", pd.getString("ACCOUT"), pd | ||
| 185 | + .getString("PASSWORD")).toString()); // 密码加密 | ||
| 186 | + userService.editU(pd); // 执行保存 | ||
| 175 | mv.addObject("msg", "success"); | 187 | mv.addObject("msg", "success"); |
| 176 | mv.setViewName("save_result"); | 188 | mv.setViewName("save_result"); |
| 177 | return mv; | 189 | return mv; |
| @@ -197,17 +209,12 @@ public class TeacherController extends BaseController { | @@ -197,17 +209,12 @@ public class TeacherController extends BaseController { | ||
| 197 | pd.put("STATUS", "0"); // 状态 | 209 | pd.put("STATUS", "0"); // 状态 |
| 198 | pd.put("SKIN", "default"); | 210 | pd.put("SKIN", "default"); |
| 199 | pd.put("RIGHTS", ""); | 211 | pd.put("RIGHTS", ""); |
| 200 | - pd.put("USERNAME", pd.getString("ACCOUT")); | 212 | + pd.put("USERNAME", n.getString("ACCOUT")); |
| 201 | pd.put("ROLE_ID", "57bb1e6f138247a0b05cc721a5da1b64"); | 213 | pd.put("ROLE_ID", "57bb1e6f138247a0b05cc721a5da1b64"); |
| 202 | pd.put("PASSWORD", | 214 | pd.put("PASSWORD", |
| 203 | - new SimpleHash("SHA-1", pd.getString("ACCOUT"), pd | 215 | + new SimpleHash("SHA-1", n.getString("ACCOUT"), pd |
| 204 | .getString("PASSWORD")).toString()); // 密码加密 | 216 | .getString("PASSWORD")).toString()); // 密码加密 |
| 205 | - | ||
| 206 | - if (null == userService.findByUsername(pd)) { // 判断用户名是否存在 | ||
| 207 | - userService.saveU(pd); // 执行保存 | ||
| 208 | - FHLOG.save(Jurisdiction.getUsername(), | ||
| 209 | - "新增系统用户:" + pd.getString("USERNAME")); | ||
| 210 | - } | 217 | + userService.editU(pd); // 执行保存 |
| 211 | mv.addObject("msg", "success"); | 218 | mv.addObject("msg", "success"); |
| 212 | mv.setViewName("save_result2"); | 219 | mv.setViewName("save_result2"); |
| 213 | return mv; | 220 | return mv; |
| @@ -235,19 +242,15 @@ public class TeacherController extends BaseController { | @@ -235,19 +242,15 @@ public class TeacherController extends BaseController { | ||
| 235 | pd.put("STATUS", "0"); // 状态 | 242 | pd.put("STATUS", "0"); // 状态 |
| 236 | pd.put("SKIN", "default"); | 243 | pd.put("SKIN", "default"); |
| 237 | pd.put("RIGHTS", ""); | 244 | pd.put("RIGHTS", ""); |
| 238 | - pd.put("USERNAME", pd.getString("ACCOUT")); | 245 | + pd.put("USERNAME", n.getString("ACCOUT")); |
| 239 | pd.put("ROLE_ID", "57bb1e6f138247a0b05cc721a5da1b64"); | 246 | pd.put("ROLE_ID", "57bb1e6f138247a0b05cc721a5da1b64"); |
| 240 | pd.put("PASSWORD", | 247 | pd.put("PASSWORD", |
| 241 | - new SimpleHash("SHA-1", pd.getString("ACCOUT"), pd | 248 | + new SimpleHash("SHA-1", n.getString("ACCOUT"), pd |
| 242 | .getString("PASSWORD")).toString()); // 密码加密 | 249 | .getString("PASSWORD")).toString()); // 密码加密 |
| 243 | - | ||
| 244 | - if (null == userService.findByUsername(pd)) { // 判断用户名是否存在 | ||
| 245 | - userService.saveU(pd); // 执行保存 | ||
| 246 | - FHLOG.save(Jurisdiction.getUsername(), | ||
| 247 | - "新增系统用户:" + pd.getString("USERNAME")); | ||
| 248 | - } | 250 | + userService.editU(pd); // 执行保存 |
| 249 | ret.setData("Success"); | 251 | ret.setData("Success"); |
| 250 | }else{ | 252 | }else{ |
| 253 | + ret.set5Error(); | ||
| 251 | ret.setData("Fail"); | 254 | ret.setData("Fail"); |
| 252 | } | 255 | } |
| 253 | return ret.toJson(); | 256 | return ret.toJson(); |
src/com/fh/plugin/websocketInstantMsg/ChatServer.java
| @@ -3,7 +3,9 @@ package com.fh.plugin.websocketInstantMsg; | @@ -3,7 +3,9 @@ package com.fh.plugin.websocketInstantMsg; | ||
| 3 | import java.io.IOException; | 3 | import java.io.IOException; |
| 4 | import java.net.InetSocketAddress; | 4 | import java.net.InetSocketAddress; |
| 5 | import java.net.UnknownHostException; | 5 | import java.net.UnknownHostException; |
| 6 | +import java.util.ArrayList; | ||
| 6 | import java.util.Date; | 7 | import java.util.Date; |
| 8 | +import java.util.List; | ||
| 7 | 9 | ||
| 8 | import net.sf.json.JSONObject; | 10 | import net.sf.json.JSONObject; |
| 9 | 11 | ||
| @@ -15,6 +17,8 @@ import org.java_websocket.server.WebSocketServer; | @@ -15,6 +17,8 @@ import org.java_websocket.server.WebSocketServer; | ||
| 15 | 17 | ||
| 16 | 18 | ||
| 17 | public class ChatServer extends WebSocketServer{ | 19 | public class ChatServer extends WebSocketServer{ |
| 20 | + | ||
| 21 | + private List<WebSocket> list = new ArrayList<WebSocket>(); | ||
| 18 | 22 | ||
| 19 | public ChatServer(int port) throws UnknownHostException { | 23 | public ChatServer(int port) throws UnknownHostException { |
| 20 | super(new InetSocketAddress(port)); | 24 | super(new InetSocketAddress(port)); |
| @@ -31,6 +35,7 @@ public class ChatServer extends WebSocketServer{ | @@ -31,6 +35,7 @@ public class ChatServer extends WebSocketServer{ | ||
| 31 | public void onOpen( WebSocket conn, ClientHandshake handshake ) { | 35 | public void onOpen( WebSocket conn, ClientHandshake handshake ) { |
| 32 | //this.sendToAll( "new connection: " + handshake.getResourceDescriptor() ); | 36 | //this.sendToAll( "new connection: " + handshake.getResourceDescriptor() ); |
| 33 | //System.out.println("===" + conn.getRemoteSocketAddress().getAddress().getHostAddress()); | 37 | //System.out.println("===" + conn.getRemoteSocketAddress().getAddress().getHostAddress()); |
| 38 | + list.add(conn); | ||
| 34 | } | 39 | } |
| 35 | 40 | ||
| 36 | /** | 41 | /** |
| @@ -38,7 +43,7 @@ public class ChatServer extends WebSocketServer{ | @@ -38,7 +43,7 @@ public class ChatServer extends WebSocketServer{ | ||
| 38 | */ | 43 | */ |
| 39 | @Override | 44 | @Override |
| 40 | public void onClose( WebSocket conn, int code, String reason, boolean remote ) { | 45 | public void onClose( WebSocket conn, int code, String reason, boolean remote ) { |
| 41 | - userLeave(conn); | 46 | + list.remove(conn); |
| 42 | } | 47 | } |
| 43 | 48 | ||
| 44 | /** | 49 | /** |
| @@ -46,18 +51,10 @@ public class ChatServer extends WebSocketServer{ | @@ -46,18 +51,10 @@ public class ChatServer extends WebSocketServer{ | ||
| 46 | */ | 51 | */ |
| 47 | @Override | 52 | @Override |
| 48 | public void onMessage(WebSocket conn, String message){ | 53 | public void onMessage(WebSocket conn, String message){ |
| 49 | - message = message.toString(); | ||
| 50 | - if(null != message && message.startsWith("FHadminqq313596790")){ | ||
| 51 | - this.userjoin(message.replaceFirst("FHadminqq313596790", ""),conn); | ||
| 52 | - }if(null != message && message.startsWith("LeaveFHadminqq313596790")){ | ||
| 53 | - this.userLeave(conn); | ||
| 54 | - }if(null != message && message.contains("fhadmin886")){ | ||
| 55 | - String toUser = message.substring(message.indexOf("fhadmin886")+10, message.indexOf("fhfhadmin888")); | ||
| 56 | - message = message.substring(0, message.indexOf("fhadmin886")) +"[私信] "+ message.substring(message.indexOf("fhfhadmin888")+12, message.length()); | ||
| 57 | - ChatServerPool.sendMessageToUser(ChatServerPool.getWebSocketByUser(toUser),message);//向所某用户发送消息 | ||
| 58 | - ChatServerPool.sendMessageToUser(conn, message);//同时向本人发送消息 | ||
| 59 | - }else{ | ||
| 60 | - ChatServerPool.sendMessage(message.toString());//向所有在线用户发送消息 | 54 | + for(WebSocket w:list){ |
| 55 | + if(w != conn){ | ||
| 56 | + w.send(message); | ||
| 57 | + } | ||
| 61 | } | 58 | } |
| 62 | } | 59 | } |
| 63 | 60 | ||
| @@ -69,10 +66,10 @@ public class ChatServer extends WebSocketServer{ | @@ -69,10 +66,10 @@ public class ChatServer extends WebSocketServer{ | ||
| 69 | */ | 66 | */ |
| 70 | @Override | 67 | @Override |
| 71 | public void onError( WebSocket conn, Exception ex ) { | 68 | public void onError( WebSocket conn, Exception ex ) { |
| 72 | - ex.printStackTrace(); | ||
| 73 | - if( conn != null ) { | ||
| 74 | - //some errors like port binding failed may not be assignable to a specific websocket | ||
| 75 | - } | 69 | + try{ |
| 70 | + conn.close(0); | ||
| 71 | + }catch(Exception e){} | ||
| 72 | + list.remove(conn); | ||
| 76 | } | 73 | } |
| 77 | 74 | ||
| 78 | 75 | ||
| @@ -99,16 +96,16 @@ public class ChatServer extends WebSocketServer{ | @@ -99,16 +96,16 @@ public class ChatServer extends WebSocketServer{ | ||
| 99 | * @param user | 96 | * @param user |
| 100 | */ | 97 | */ |
| 101 | public void userLeave(WebSocket conn){ | 98 | public void userLeave(WebSocket conn){ |
| 102 | - String user = ChatServerPool.getUserByKey(conn); | 99 | +// String user = ChatServerPool.getUserByKey(conn); |
| 103 | boolean b = ChatServerPool.removeUser(conn); //在连接池中移除连接 | 100 | boolean b = ChatServerPool.removeUser(conn); //在连接池中移除连接 |
| 104 | - if(b){ | ||
| 105 | - JSONObject result = new JSONObject(); | ||
| 106 | - result.element("type", "user_leave"); | ||
| 107 | - result.element("user", "<a onclick=\"toUserMsg('"+user+"');\">"+user+"</a>"); | ||
| 108 | - ChatServerPool.sendMessage(result.toString()); //把当前用户从所有在线用户列表中删除 | ||
| 109 | - String joinMsg = "{\"from\":\"[系统]\",\"content\":\""+user+"下线了\",\"timestamp\":"+new Date().getTime()+",\"type\":\"message\"}"; | ||
| 110 | - ChatServerPool.sendMessage(joinMsg); //向在线用户发送当前用户退出的消息 | ||
| 111 | - } | 101 | +// if(b){ |
| 102 | +// JSONObject result = new JSONObject(); | ||
| 103 | +// result.element("type", "user_leave"); | ||
| 104 | +// result.element("user", "<a onclick=\"toUserMsg('"+user+"');\">"+user+"</a>"); | ||
| 105 | +// ChatServerPool.sendMessage(result.toString()); //把当前用户从所有在线用户列表中删除 | ||
| 106 | +// String joinMsg = "{\"from\":\"[系统]\",\"content\":\""+user+"下线了\",\"timestamp\":"+new Date().getTime()+",\"type\":\"message\"}"; | ||
| 107 | +// ChatServerPool.sendMessage(joinMsg); //向在线用户发送当前用户退出的消息 | ||
| 108 | +// } | ||
| 112 | } | 109 | } |
| 113 | public static void main( String[] args ) throws InterruptedException , IOException { | 110 | public static void main( String[] args ) throws InterruptedException , IOException { |
| 114 | WebSocketImpl.DEBUG = false; | 111 | WebSocketImpl.DEBUG = false; |