diff --git a/doc/权限系统数据库备忘.doc b/doc/权限系统数据库备忘.doc new file mode 100644 index 0000000..c594208 Binary files /dev/null and b/doc/权限系统数据库备忘.doc differ diff --git a/power-admin/src/main/java/com/manage/interfaces/cache/Cache.java b/power-admin/src/main/java/com/manage/interfaces/cache/Cache.java deleted file mode 100644 index 0ebc1a0..0000000 --- a/power-admin/src/main/java/com/manage/interfaces/cache/Cache.java +++ /dev/null @@ -1,65 +0,0 @@ -package com.manage.interfaces.cache; - -/** - * @Description 缓存DTO - * @Date 2019/7/2 11:41 - * @Created by ljx - */ -public class Cache { - private String key;//缓存ID - private Object value;//缓存数据 - private long timeOut;//更新时间 - private boolean expired; //是否终止 - public Cache() { - super(); - } - - public Cache(String key, Object value, long timeOut, boolean expired) { - this.key = key; - this.value = value; - this.timeOut = timeOut; - this.expired = expired; - } - - public Cache(String key, Object value, long timeOut) { - this.key = key; - this.value = value; - this.timeOut = timeOut; - } - public Cache(String key, Object value) { - this.key = key; - this.value = value; - } - - public String getKey() { - return key; - } - - public long getTimeOut() { - return timeOut; - } - - public Object getValue() { - return value; - } - - public void setKey(String string) { - key = string; - } - - public void setTimeOut(long l) { - timeOut = l; - } - - public void setValue(Object object) { - value = object; - } - - public boolean isExpired() { - return expired; - } - - public void setExpired(boolean b) { - expired = b; - } -} diff --git a/power-admin/src/main/java/com/manage/interfaces/cache/CacheManager.java b/power-admin/src/main/java/com/manage/interfaces/cache/CacheManager.java deleted file mode 100644 index db23b16..0000000 --- a/power-admin/src/main/java/com/manage/interfaces/cache/CacheManager.java +++ /dev/null @@ -1,205 +0,0 @@ -package com.manage.interfaces.cache; - -import com.manage.vo.Power_UserVo; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; - -public class CacheManager { - private static HashMap cacheMap = new HashMap(); - - private CacheManager() { - super(); - } - public static boolean getSimpleFlag(String key){ - try{ - return (Boolean) cacheMap.get(key); - }catch(NullPointerException e){ - return false; - } - } - public static long getServerStartdt(String key){ - try { - return (Long)cacheMap.get(key); - } catch (Exception ex) { - return 0; - } - } - public synchronized static boolean setSimpleFlag(String key,boolean flag){ - if (flag && getSimpleFlag(key)) { - return false; - }else{ - cacheMap.put(key, flag); - return true; - } - } - public synchronized static boolean setSimpleFlag(String key,long serverbegrundt){ - if (cacheMap.get(key) == null) { - cacheMap.put(key,serverbegrundt); - return true; - }else{ - return false; - } - } - - - private synchronized static Cache getCache(String key) { - return (Cache) cacheMap.get(key); - } - - private synchronized static boolean hasCache(String key) { - return cacheMap.containsKey(key); - } - - public synchronized static void clearAll() { - cacheMap.clear(); - } - - public synchronized static void clearAll(String type) { - Iterator i = cacheMap.entrySet().iterator(); - String key; - ArrayList arr = new ArrayList(); - try { - while (i.hasNext()) { - java.util.Map.Entry entry = (java.util.Map.Entry) i.next(); - key = (String) entry.getKey(); - if (key.startsWith(type)) { - arr.add(key); - } - } - for (int k = 0; k < arr.size(); k++) { - clearOnly(arr.get(k)); - } - } catch (Exception ex) { - ex.printStackTrace(); - } - } - - public synchronized static void clearOnly(String key) { - cacheMap.remove(key); - } - - public synchronized static void putCache(String key, Cache obj) { - cacheMap.put(key, obj); - } - - public static Cache getCacheInfo(String key) { - - if (hasCache(key)) { - Cache cache = getCache(key); - if (cacheExpired(cache)) { - cache.setExpired(true); - } - return cache; - }else - return null; - } - - public static void putCacheInfo(String key, Cache obj, long dt,boolean expired) { - Cache cache = new Cache(); - cache.setKey(key); - cache.setTimeOut(dt + System.currentTimeMillis()); - cache.setValue(obj); - cache.setExpired(expired); - cacheMap.put(key, cache); - } - public static void putCacheInfo(String key,Cache obj,long dt){ - Cache cache = new Cache(); - cache.setKey(key); - cache.setTimeOut(dt+System.currentTimeMillis()); - cache.setValue(obj); - cache.setExpired(false); - cacheMap.put(key,cache); - } - - public static boolean cacheExpired(Cache cache) { - if (null == cache) { - return false; - } - long nowDt = System.currentTimeMillis(); - long cacheDt = cache.getTimeOut(); - if (cacheDt <= 0||cacheDt>nowDt) { - return false; - } else { - return true; - } - } - - public static int getCacheSize() { - return cacheMap.size(); - } - - public static int getCacheSize(String type) { - int k = 0; - Iterator i = cacheMap.entrySet().iterator(); - String key; - try { - while (i.hasNext()) { - java.util.Map.Entry entry = (java.util.Map.Entry) i.next(); - key = (String) entry.getKey(); - if (key.indexOf(type) != -1) { - k++; - } - } - } catch (Exception ex) { - ex.printStackTrace(); - } - - return k; - } - - public static ArrayList getCacheAllkey() { - ArrayList a = new ArrayList(); - try { - Iterator i = cacheMap.entrySet().iterator(); - while (i.hasNext()) { - java.util.Map.Entry entry = (java.util.Map.Entry) i.next(); - a.add((String) entry.getKey()); - } - } catch (Exception ex) {} finally { - return a; - } - } - - public static ArrayList getCacheListkey(String type) { - ArrayList a = new ArrayList(); - String key; - try { - Iterator i = cacheMap.entrySet().iterator(); - while (i.hasNext()) { - java.util.Map.Entry entry = (java.util.Map.Entry) i.next(); - key = (String) entry.getKey(); - if (key.indexOf(type) != -1) { - a.add(key); - } - } - } catch (Exception ex) {} finally { - return a; - } - } - - public synchronized static void removeCacheByObject(Power_UserVo obj) { - ArrayList a = new ArrayList(); - Object key; - ArrayList arr = new ArrayList(); - try { - Iterator i = cacheMap.entrySet().iterator(); - while (i.hasNext()) { - Map.Entry entry = (Map.Entry) i.next(); - Cache cache = CacheManager.getCacheInfo((String)entry.getKey()); - Power_UserVo o = (Power_UserVo)cache.getValue(); - if (obj.getUserName().equals(o.getUserName())) { - arr.add((String)entry.getKey()); - } - } - if(null != arr && !arr.isEmpty()){ - for (int k = 0; k < arr.size(); k++) { - clearOnly(arr.get(k)); - } - } - } catch (Exception ex) {} - } - -} \ No newline at end of file diff --git a/power-admin/src/main/webapp/doc/视图power_user_dict.sql b/power-admin/src/main/webapp/doc/视图power_user_dict.sql new file mode 100644 index 0000000..ce08b8f --- /dev/null +++ b/power-admin/src/main/webapp/doc/视图power_user_dict.sql @@ -0,0 +1,14 @@ +CREATE VIEW power_user_dict AS +SELECT +`power_user`.`user_id` AS `user_id`, +`power_dept`.`dict_id` AS `dict_id` +FROM + (( + `power_user` + JOIN `mysql`.`help_topic` `b` ON (( + `b`.`help_topic_id` < (( length( `power_user`.`dept_id` ) - length( REPLACE ( `power_user`.`dept_id`, _latin1 ',', _latin1 '' ))) + 1 )))) + LEFT JOIN `power_dept` ON (( + `power_dept`.`dept_id` = `power_user`.`dept_id` + ))) +GROUP BY + `power_user`.`user_id` \ No newline at end of file diff --git a/power-admin/src/main/webapp/static/js/user.js b/power-admin/src/main/webapp/static/js/user.js index b0e272f..41edb3c 100644 --- a/power-admin/src/main/webapp/static/js/user.js +++ b/power-admin/src/main/webapp/static/js/user.js @@ -524,7 +524,7 @@ function exportExcel(){ var checks = $("#checks").val(); if(checks != '') { checks = checks.substring(0, checks.length - 1); - var url = path+"/user/export?userName="+$("#user_name").val()+"&userEmail="+$("#user_email").val()+"&searchRoleId="+$("#roleId").val()+"&deptId="+$("#dept_id").val()+"&effective="+$("#effective").val()+"&checks="+checks; + var url = path+"/user/export?checks="+checks; window.location.href = url; }else{ Common.confirm({ @@ -532,7 +532,7 @@ function exportExcel(){ message: "没有选中,您确定要按搜索栏条件导出?", operate: function (reselt) { if (reselt) { - var url = path+"/user/export?userName="+$("#user_name").val()+"&userEmail="+$("#user_email").val()+"&searchRoleId="+$("#roleId").val()+"&deptId="+$("#dept_id").val()+"&effective="+$("#effective").val()+"&checks="+checks; + var url = path+"/user/export?userName="+$("#user_name").val()+"&searchRoleId="+$("#roleId").val()+"&deptId="+$("#dept_id").val()+"&effective="+$("#effective").val(); window.location.href = url; } } diff --git a/power-admin/src/main/webapp/static/js/user1.js b/power-admin/src/main/webapp/static/js/user1.js index 20667aa..6c09c14 100644 --- a/power-admin/src/main/webapp/static/js/user1.js +++ b/power-admin/src/main/webapp/static/js/user1.js @@ -523,7 +523,7 @@ function exportExcel(){ var checks = $("#checks").val(); if(checks != '') { checks = checks.substring(0, checks.length - 1); - var url = path+"/user/export1?userName="+$("#user_name").val()+"&userEmail="+$("#user_email").val()+"&searchRoleId="+$("#roleId").val()+"&deptId="+$("#dept_id").val()+"&effective="+$("#effective").val()+"&checks="+checks; + var url = path+"/user/export1?checks="+checks; window.location.href = url; }else{ Common.confirm({ @@ -531,7 +531,7 @@ function exportExcel(){ message: "没有选中,您确定要按搜索栏条件导出?", operate: function (reselt) { if (reselt) { - var url = path+"/user/export?userName="+$("#user_name").val()+"&userEmail="+$("#user_email").val()+"&searchRoleId="+$("#roleId").val()+"&deptId="+$("#dept_id").val()+"&effective="+$("#effective").val()+"&checks="+checks; + var url = path+"/user/export?userName="+$("#user_name").val()+"&searchRoleId="+$("#roleId").val()+"&deptId="+$("#dept_id").val()+"&effective="+$("#effective").val(); window.location.href = url; } } diff --git a/power-foundaton/src/main/java/com/manage/util/ActionScopeUtils.java b/power-foundaton/src/main/java/com/manage/util/ActionScopeUtils.java index 087c8ce..03a6917 100644 --- a/power-foundaton/src/main/java/com/manage/util/ActionScopeUtils.java +++ b/power-foundaton/src/main/java/com/manage/util/ActionScopeUtils.java @@ -31,13 +31,4 @@ public class ActionScopeUtils { public static Object getSessionAttribute(String key){ return getSession(getRequest()).getAttribute(key); } - - public static void setRequestAttribute(String key,Object value){ - getRequest().setAttribute(key,value); - } - - public static Object getRequestAttribute(String key){ - return getRequest().getAttribute(key); - } - } diff --git a/power-foundaton/src/main/java/com/manage/util/BeanMapperUtils.java b/power-foundaton/src/main/java/com/manage/util/BeanMapperUtils.java deleted file mode 100644 index 8801156..0000000 --- a/power-foundaton/src/main/java/com/manage/util/BeanMapperUtils.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.manage.util; - -import java.io.*; - -/** - * @ProjectName: - * @Description: - * @Param 传输参数 - * @Return - * @Author: 曾文和 - * @CreateDate: 2019/11/6 10:03 - * @UpdateUser: 曾文和 - * @UpdateDate: 2019/11/6 10:03 - * @UpdateRemark: 更新说明 - * @Version: 1.0 - */ -public class BeanMapperUtils { - /** - * 使用序列化技术实现深拷贝 - * @return - */ - public static Object deepClone(Object object) throws IOException,ClassNotFoundException{ - //将对象写入流中 - ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); - ObjectOutputStream objectOutputStream = new ObjectOutputStream(outputStream); - objectOutputStream.writeObject(object); - //从流中取出 - ByteArrayInputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray()); - ObjectInputStream objectInputStream = new ObjectInputStream(inputStream); - return objectInputStream.readObject(); - - } -} diff --git a/power-foundaton/src/main/java/com/manage/util/Constant.java b/power-foundaton/src/main/java/com/manage/util/Constant.java index b608c76..f72a488 100644 --- a/power-foundaton/src/main/java/com/manage/util/Constant.java +++ b/power-foundaton/src/main/java/com/manage/util/Constant.java @@ -11,8 +11,6 @@ public class Constant { public static final Integer EFFECTIVE_NO = 0; // 未登录拦截 public static final String RELEASE_REQUEST = "releaseRequest"; - // ajax拦截 - public static final String AJAX_REQUEST = "ajaxRequest"; public static final String CURRENT_USER = "CURRENT_USER"; } diff --git a/power-foundaton/src/main/java/com/manage/util/JsonModel.java b/power-foundaton/src/main/java/com/manage/util/JsonModel.java deleted file mode 100644 index f99e408..0000000 --- a/power-foundaton/src/main/java/com/manage/util/JsonModel.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.manage.util; - -import java.util.List; -/** - *

Title:JsonModel

- *

Description:

- *

Company:

- * @author hu - * @date - */ -public class JsonModel { - private String id; - private String text; - private String icon; - private StateForJsonModel state; - private List children; - private Object li_attr; - private Object a_attr; - - - public String getId() { - return id; - } - - - public void setId(String id) { - this.id = id; - } - - - public String getText() { - return text; - } - - - public void setText(String text) { - this.text = text; - } - - - public String getIcon() { - return icon; - } - - - public void setIcon(String icon) { - this.icon = icon; - } - - - public StateForJsonModel getState() { - return state; - } - - - public void setState(StateForJsonModel state) { - this.state = state; - } - - - public List getChildren() { - return children; - } - - - public void setChildren(List children) { - this.children = children; - } - - - public Object getLi_attr() { - return li_attr; - } - - - public void setLi_attr(Object li_attr) { - this.li_attr = li_attr; - } - - - public Object getA_attr() { - return a_attr; - } - - - public void setA_attr(Object a_attr) { - this.a_attr = a_attr; - } - - -} diff --git a/power-foundaton/src/main/java/com/manage/util/SigarUtils.java b/power-foundaton/src/main/java/com/manage/util/SigarUtils.java index 2c5766c..166e0e7 100644 --- a/power-foundaton/src/main/java/com/manage/util/SigarUtils.java +++ b/power-foundaton/src/main/java/com/manage/util/SigarUtils.java @@ -51,6 +51,6 @@ public class SigarUtils{ String OS = System.getProperty("os.name").toLowerCase(); if (OS.indexOf("win") >= 0) { return true; - } else return false; + } else {return false;} } } diff --git a/power-foundaton/src/main/java/com/manage/util/StateForJsonModel.java b/power-foundaton/src/main/java/com/manage/util/StateForJsonModel.java deleted file mode 100644 index 2228962..0000000 --- a/power-foundaton/src/main/java/com/manage/util/StateForJsonModel.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.manage.util; - -/** - *

Title:StateForJsonModel

- *

Description:

- *

Company:

- * @author hu - * @date - */ -public class StateForJsonModel { - private boolean opened; - private boolean disabled; - private boolean selected; - - - public boolean isOpened() { - return opened; - } - - - public void setOpened(boolean opened) { - this.opened = opened; - } - - - public boolean isDisabled() { - return disabled; - } - - - public void setDisabled(boolean disabled) { - this.disabled = disabled; - } - - - public boolean isSelected() { - return selected; - } - - - public void setSelected(boolean selected) { - this.selected = selected; - } - -} diff --git a/power-service/src/main/java/com/manage/service/ImportExcel/ImportExcelJudgeMethod.java b/power-service/src/main/java/com/manage/service/ImportExcel/ImportExcelJudgeMethod.java index 4eba7f4..be9236e 100644 --- a/power-service/src/main/java/com/manage/service/ImportExcel/ImportExcelJudgeMethod.java +++ b/power-service/src/main/java/com/manage/service/ImportExcel/ImportExcelJudgeMethod.java @@ -50,7 +50,7 @@ public class ImportExcelJudgeMethod { @Autowired private Power_Sys_DictMapper sysDictMapper; //公共批量插入方法 - private static final String SIMPLEINSERT = "SimpleInsert"; + private final String SIMPLEINSERT = "SimpleInsert"; /****************************************导入公共判断******************************************************/ /** diff --git a/power-service/src/main/java/com/manage/service/ImportExcel/ImportExcelUtil.java b/power-service/src/main/java/com/manage/service/ImportExcel/ImportExcelUtil.java index a3f66a1..4bccb53 100644 --- a/power-service/src/main/java/com/manage/service/ImportExcel/ImportExcelUtil.java +++ b/power-service/src/main/java/com/manage/service/ImportExcel/ImportExcelUtil.java @@ -299,11 +299,6 @@ public class ImportExcelUtil { return workbook; } - //移除缓存的工作簿 - public static void removeWorkBookMapByKey(String workBookKey){ - workBookMap.remove(workBookKey); - } - public static void copy(Object source, Object dest) throws Exception { Class destClz = dest.getClass(); diff --git a/power-service/src/main/java/com/manage/service/cache/CacheManager.java b/power-service/src/main/java/com/manage/service/cache/CacheManager.java index 883ea40..106baf6 100644 --- a/power-service/src/main/java/com/manage/service/cache/CacheManager.java +++ b/power-service/src/main/java/com/manage/service/cache/CacheManager.java @@ -9,17 +9,17 @@ import java.util.Map; public class CacheManager { private static HashMap cacheMap = new HashMap(); - private static HashMap cacheExceptionMap = new HashMap(); - private static HashMap> loginUserCacheMap = new HashMap(); - //无异常数量 + //private static HashMap cacheExceptionMap = new HashMap(); + //private static HashMap> loginUserCacheMap = new HashMap(); + /*//无异常数量 private static Integer noExcCount = 0; //异常数量 - private static Integer excCount = 0; + private static Integer excCount = 0;*/ //添加用户登录缓存 - public synchronized static void addloginUserCount(String date,String userName){ + public static void addloginUserCount(String date,String userName){ //取出当天数据 - HashMap map = loginUserCacheMap.get(date); + /*HashMap map = loginUserCacheMap.get(date); if(null == map){ map = new HashMap<>(); //首次登录 @@ -36,81 +36,52 @@ public class CacheManager { map.put(userName,count); } //重置 - loginUserCacheMap.put(date,map); + loginUserCacheMap.put(date,map);*/ } //获取当天用户集合 public static HashMap getCurrentDayCount(String date){ //取出当天数据 - HashMap map = loginUserCacheMap.get(date); - return map; + /* HashMap map = loginUserCacheMap.get(date); + return map;*/ + return null; } //添加异常数量 public synchronized static void addExcCount(String type){ if("noExc".equals(type)){ - noExcCount++; - cacheExceptionMap.put(type,noExcCount); + /*noExcCount++; + cacheExceptionMap.put(type,noExcCount);*/ } if("exc".equals(type)){ - excCount++; - cacheExceptionMap.put(type,excCount); + /*excCount++; + cacheExceptionMap.put(type,excCount);*/ } } //取异常数量 - public synchronized static Integer getExcCount(String type){ - return (Integer)cacheExceptionMap.get(type); + public static Integer getExcCount(String type){ + return 0; + //return (Integer)cacheExceptionMap.get(type); } private CacheManager() { super(); } - public static boolean getSimpleFlag(String key){ - try{ - return (Boolean) cacheMap.get(key); - }catch(NullPointerException e){ - return false; - } - } - public static long getServerStartdt(String key){ - try { - return (Long)cacheMap.get(key); - } catch (Exception ex) { - return 0; - } - } - public synchronized static boolean setSimpleFlag(String key,boolean flag){ - if (flag && getSimpleFlag(key)) { - return false; - }else{ - cacheMap.put(key, flag); - return true; - } - } - public synchronized static boolean setSimpleFlag(String key,long serverbegrundt){ - if (cacheMap.get(key) == null) { - cacheMap.put(key,serverbegrundt); - return true; - }else{ - return false; - } - } - - private synchronized static Cache getCache(String key) { + private static Cache getCache(String key) { return (Cache) cacheMap.get(key); } - private synchronized static boolean hasCache(String key) { + private static boolean hasCache(String key) { return cacheMap.containsKey(key); } - public synchronized static void clearAll() { + public static void clearAll() { cacheMap.clear(); } - public synchronized static void clearAll(String type) { + public static void clearAll(String type) { Iterator i = cacheMap.entrySet().iterator(); String key; ArrayList arr = new ArrayList(); @@ -130,41 +101,24 @@ public class CacheManager { } } - public synchronized static void clearOnly(String key) { + public static void clearOnly(String key) { cacheMap.remove(key); } - public synchronized static void putCache(String key, Cache obj) { + public static void putCache(String key, Cache obj) { cacheMap.put(key, obj); } public static Cache getCacheInfo(String key) { - if (hasCache(key)) { Cache cache = getCache(key); if (cacheExpired(cache)) { cache.setExpired(true); } return cache; - }else + }else { return null; - } - - public static void putCacheInfo(String key, Cache obj, long dt, boolean expired) { - Cache cache = new Cache(); - cache.setKey(key); - cache.setTimeOut(dt + System.currentTimeMillis()); - cache.setValue(obj); - cache.setExpired(expired); - cacheMap.put(key, cache); - } - public static void putCacheInfo(String key, Cache obj, long dt){ - Cache cache = new Cache(); - cache.setKey(key); - cache.setTimeOut(dt+System.currentTimeMillis()); - cache.setValue(obj); - cache.setExpired(false); - cacheMap.put(key,cache); + } } public static boolean cacheExpired(Cache cache) { @@ -180,62 +134,8 @@ public class CacheManager { } } - public static int getCacheSize() { - return cacheMap.size(); - } - - public static int getCacheSize(String type) { - int k = 0; - Iterator i = cacheMap.entrySet().iterator(); - String key; - try { - while (i.hasNext()) { - Map.Entry entry = (Map.Entry) i.next(); - key = (String) entry.getKey(); - if (key.indexOf(type) != -1) { - k++; - } - } - } catch (Exception ex) { - ex.printStackTrace(); - } - - return k; - } - - public static ArrayList getCacheAllkey() { - ArrayList a = new ArrayList(); - try { - Iterator i = cacheMap.entrySet().iterator(); - while (i.hasNext()) { - Map.Entry entry = (Map.Entry) i.next(); - a.add((String) entry.getKey()); - } - } catch (Exception ex) {} finally { - return a; - } - } - - public static ArrayList getCacheListkey(String type) { - ArrayList a = new ArrayList(); - String key; - try { - Iterator i = cacheMap.entrySet().iterator(); - while (i.hasNext()) { - Map.Entry entry = (Map.Entry) i.next(); - key = (String) entry.getKey(); - if (key.indexOf(type) != -1) { - a.add(key); - } - } - } catch (Exception ex) {} finally { - return a; - } - } //根据用户信息删除缓存 - public synchronized static void removeCacheByObject(Power_UserVo obj) { - ArrayList a = new ArrayList(); - Object key; + public static void removeCacheByObject(Power_UserVo obj) { ArrayList arr = new ArrayList(); try { Iterator i = cacheMap.entrySet().iterator(); @@ -254,5 +154,4 @@ public class CacheManager { } } catch (Exception ex) {} } - } \ No newline at end of file diff --git a/power-service/src/main/java/com/manage/service/webSocket/WebServer.java b/power-service/src/main/java/com/manage/service/webSocket/WebServer.java index e344f6b..19450d1 100644 --- a/power-service/src/main/java/com/manage/service/webSocket/WebServer.java +++ b/power-service/src/main/java/com/manage/service/webSocket/WebServer.java @@ -4,27 +4,17 @@ import org.java_websocket.WebSocket; import org.java_websocket.handshake.ClientHandshake; import org.java_websocket.server.WebSocketServer; -import javax.websocket.Session; -import java.io.IOException; import java.net.InetSocketAddress; public class WebServer extends WebSocketServer { - private Session session; public WebServer(int port) { super(new InetSocketAddress(port)); } - public WebServer(InetSocketAddress address) { - super(address); - } - @Override public void onOpen(WebSocket conn, ClientHandshake handshake) { // ws连接的时候触发的代码,onOpen中我们不做任何操作 } - public void sendMessage(String message) throws IOException { - this.session.getBasicRemote().sendText("2"); - } @Override public void onClose(WebSocket conn, int code, String reason, boolean remote) { diff --git a/power-service/src/main/java/com/manage/service/webSocket/WsPool.java b/power-service/src/main/java/com/manage/service/webSocket/WsPool.java index 1d5222c..87b5395 100644 --- a/power-service/src/main/java/com/manage/service/webSocket/WsPool.java +++ b/power-service/src/main/java/com/manage/service/webSocket/WsPool.java @@ -8,16 +8,6 @@ import java.util.*; public class WsPool { private static final Map wsUserMap = new HashMap(); - /** - * 通过websocket连接获取其对应的用户 - * - * @param conn - * @return - */ - public static String getUserByWs(WebSocket conn) { - return wsUserMap.get(conn); - } - /** * 根据userName获取WebSocket,这是一个list,此处取第一个 * 因为有可能多个websocket对应一个userName(但一般是只有一个,因为在close方法中,我们将失效的websocket连接去除了) @@ -44,20 +34,6 @@ public class WsPool { wsUserMap.put(conn, userName); // 添加连接 } - /** - * 获取所有连接池中的用户,因为set是不允许重复的,所以可以得到无重复的user数组 - * - * @return - */ - public static Collection getOnlineUser() { - List setUsers = new ArrayList(); - Collection setUser = wsUserMap.values(); - for (String u : setUser) { - setUsers.add(u); - } - return setUsers; - } - /** * 移除连接池中的连接 *