├── README.md ├── img ├── QQ20180629-165244.png ├── QQ20180629-165327.png ├── QQ20180629-165341.png └── QQ20180629-165500.png ├── pom.xml └── src ├── main ├── java │ └── com │ │ └── neo │ │ ├── Application.java │ │ ├── config │ │ ├── InterceptorConfig.java │ │ └── WebAppConfig.java │ │ ├── controller │ │ ├── AddMessageController.java │ │ ├── BaseController.java │ │ ├── ChatController.java │ │ ├── GroupController.java │ │ ├── IndexController.java │ │ └── UserController.java │ │ ├── dao │ │ ├── AddMessageDao.java │ │ ├── BaseDao.java │ │ ├── GroupDao.java │ │ ├── UserDao.java │ │ └── impl │ │ │ ├── AddMessageDaoImpl.java │ │ │ ├── BaseDaoImpl.java │ │ │ ├── GroupDaoImpl.java │ │ │ └── UserDaoImpl.java │ │ ├── entity │ │ ├── AddInfo.java │ │ ├── AddMessage.java │ │ ├── BaseEntity.java │ │ ├── Bodies.java │ │ ├── GpsData.java │ │ ├── GroupEntity.java │ │ ├── GroupUser.java │ │ ├── MessageEntity.java │ │ ├── Result.java │ │ └── UserEntity.java │ │ ├── enums │ │ ├── AddMessageType.java │ │ ├── Body_type.java │ │ ├── Chat_type.java │ │ └── EResultType.java │ │ ├── exception │ │ ├── GlobalExceptionHandler.java │ │ ├── ParameterException.java │ │ └── RepeatException.java │ │ ├── listener │ │ └── SessionListener.java │ │ ├── serivce │ │ ├── AddMessageSerivice.java │ │ ├── BaseSerivice.java │ │ ├── ChatSerivice.java │ │ ├── GroupSerivice.java │ │ ├── UserSerivice.java │ │ └── impl │ │ │ ├── AddMessageSeriviceImpl.java │ │ │ ├── BaseSeriviceImpl.java │ │ │ ├── ChatSeriviceImpl.java │ │ │ ├── GroupSeriviceImpl.java │ │ │ └── UserSeriviceImpl.java │ │ ├── socketio │ │ ├── ChatLauncher.java │ │ ├── MessageEventHandler.java │ │ └── ServerRunner.java │ │ └── utils │ │ ├── DateUtils.java │ │ └── SessionUtil.java └── resources │ ├── AuthKey.p8 │ ├── application.properties │ └── static │ ├── css │ └── login │ │ ├── animate-custom.css │ │ └── style3.css │ ├── favicon.ico │ ├── html │ ├── chatlog.html │ ├── creategroup.html │ ├── find.html │ ├── friend.html │ ├── msgbox.html │ ├── setting.html │ └── userinfo.html │ ├── image │ ├── avatar │ │ ├── 094fc8fb017743cea89eece53c7f35be.jpg │ │ ├── 2a015308ac4544fea8a2f32ecc599961.gif │ │ ├── avatar(1).jpg │ │ ├── avatar(10).jpg │ │ ├── avatar(2).jpg │ │ ├── avatar(3).jpg │ │ ├── avatar(4).jpg │ │ ├── avatar(5).jpg │ │ ├── avatar(6).jpg │ │ ├── avatar(7).jpg │ │ ├── avatar(8).jpg │ │ └── avatar(9).jpg │ └── group │ │ ├── group_1.gif │ │ ├── group_2.gif │ │ ├── group_3.jpg │ │ └── group_4.jpg │ ├── index.html │ ├── js │ ├── particles.min.js │ ├── protobuf.js │ ├── reconnecting │ │ └── reconnecting-websocket.js │ ├── socket.io.js │ ├── user.js │ └── websocket.js │ ├── json │ ├── particles0.json │ ├── particles1.json │ └── particles2.json │ ├── layui │ ├── css │ │ ├── layui.css │ │ ├── layui.mobile.css │ │ └── modules │ │ │ ├── code.css │ │ │ ├── laydate │ │ │ ├── icon.png │ │ │ └── laydate.css │ │ │ ├── layer │ │ │ └── default │ │ │ │ ├── icon-ext.png │ │ │ │ ├── icon.png │ │ │ │ ├── layer.css │ │ │ │ ├── loading-0.gif │ │ │ │ ├── loading-1.gif │ │ │ │ └── loading-2.gif │ │ │ └── layim │ │ │ ├── html │ │ │ ├── find.html │ │ │ ├── getmsg.json │ │ │ └── msgbox.html │ │ │ ├── layim.css │ │ │ ├── mobile │ │ │ └── layim.css │ │ │ ├── skin │ │ │ ├── 1.jpg │ │ │ ├── 2.jpg │ │ │ ├── 3.jpg │ │ │ ├── 4.jpg │ │ │ ├── 5.jpg │ │ │ └── logo.jpg │ │ │ └── voice │ │ │ └── default.wav │ ├── font │ │ ├── iconfont.eot │ │ ├── iconfont.svg │ │ ├── iconfont.ttf │ │ └── iconfont.woff │ ├── images │ │ └── face │ │ │ ├── 0.gif │ │ │ ├── 1.gif │ │ │ ├── 10.gif │ │ │ ├── 11.gif │ │ │ ├── 12.gif │ │ │ ├── 13.gif │ │ │ ├── 14.gif │ │ │ ├── 15.gif │ │ │ ├── 16.gif │ │ │ ├── 17.gif │ │ │ ├── 18.gif │ │ │ ├── 19.gif │ │ │ ├── 2.gif │ │ │ ├── 20.gif │ │ │ ├── 21.gif │ │ │ ├── 22.gif │ │ │ ├── 23.gif │ │ │ ├── 24.gif │ │ │ ├── 25.gif │ │ │ ├── 26.gif │ │ │ ├── 27.gif │ │ │ ├── 28.gif │ │ │ ├── 29.gif │ │ │ ├── 3.gif │ │ │ ├── 30.gif │ │ │ ├── 31.gif │ │ │ ├── 32.gif │ │ │ ├── 33.gif │ │ │ ├── 34.gif │ │ │ ├── 35.gif │ │ │ ├── 36.gif │ │ │ ├── 37.gif │ │ │ ├── 38.gif │ │ │ ├── 39.gif │ │ │ ├── 4.gif │ │ │ ├── 40.gif │ │ │ ├── 41.gif │ │ │ ├── 42.gif │ │ │ ├── 43.gif │ │ │ ├── 44.gif │ │ │ ├── 45.gif │ │ │ ├── 46.gif │ │ │ ├── 47.gif │ │ │ ├── 48.gif │ │ │ ├── 49.gif │ │ │ ├── 5.gif │ │ │ ├── 50.gif │ │ │ ├── 51.gif │ │ │ ├── 52.gif │ │ │ ├── 53.gif │ │ │ ├── 54.gif │ │ │ ├── 55.gif │ │ │ ├── 56.gif │ │ │ ├── 57.gif │ │ │ ├── 58.gif │ │ │ ├── 59.gif │ │ │ ├── 6.gif │ │ │ ├── 60.gif │ │ │ ├── 61.gif │ │ │ ├── 62.gif │ │ │ ├── 63.gif │ │ │ ├── 64.gif │ │ │ ├── 65.gif │ │ │ ├── 66.gif │ │ │ ├── 67.gif │ │ │ ├── 68.gif │ │ │ ├── 69.gif │ │ │ ├── 7.gif │ │ │ ├── 70.gif │ │ │ ├── 71.gif │ │ │ ├── 8.gif │ │ │ └── 9.gif │ ├── lay │ │ ├── all-mobile.js │ │ ├── all.js │ │ └── modules │ │ │ ├── code.js │ │ │ ├── element.js │ │ │ ├── flow.js │ │ │ ├── form.js │ │ │ ├── jquery.js │ │ │ ├── laydate.js │ │ │ ├── layedit.js │ │ │ ├── layer.js │ │ │ ├── layim.js │ │ │ ├── laypage.js │ │ │ ├── laytpl.js │ │ │ ├── mobile.js │ │ │ ├── mobile │ │ │ ├── layer-mobile.js │ │ │ ├── layim-mobile-open.js │ │ │ ├── layim-mobile.js │ │ │ ├── upload-mobile.js │ │ │ └── zepto.js │ │ │ ├── tree.js │ │ │ ├── upload.js │ │ │ └── util.js │ ├── layui.js │ ├── 更新日志.txt │ └── 说明.txt │ ├── login.html │ ├── protobuf │ └── gps_data.proto │ └── themes │ ├── bg1.jpg │ ├── bg1_small.jpg │ ├── bg2.jpg │ ├── bg2_small.jpg │ ├── bg3.jpg │ ├── bg3_small.jpg │ ├── bg4.jpg │ ├── bg4_small.jpg │ ├── bg5.jpg │ └── bg5_small.jpg └── test └── java └── com └── neo ├── ApplicationTests.java └── dao └── UserDaoTest.java /README.md: -------------------------------------------------------------------------------- 1 | # spring-boot-netty-socket.io---chat 2 | 注 : 改为java 版本,是因为个人倾向java的代码的编写 非其他。 3 | 4 | node.js + socket.io 版本改 为spring + boot + socket.io 形式 目前实现了注册,登录与一对一聊天群聊,及 创建群,搜索群,加群功能(验证需同意), 5 | 6 | 页面使用了layim 框架,如需在生产环境中使用,请去官方网站授权使用 7 | 8 | 前端页面 借用自 https://github.com/scalad/LayIM 的前端, @scalad 9 | 10 | mongodb 数据库连接,IM 地址和端口 请修改 application.properties 文件 11 | 12 | 前端页面的websocket连接地址 请自行修改resource/static/js/websocket.js 13 | 14 | ![image](https://github.com/githuanl/spring-boot-netty-socket.io---chat/blob/master/img/QQ20180629-165244.png) 15 | 16 | ![image](https://github.com/githuanl/spring-boot-netty-socket.io---chat/blob/master/img/QQ20180629-165327.png) 17 | 18 | ![image](https://github.com/githuanl/spring-boot-netty-socket.io---chat/blob/master/img/QQ20180629-165341.png) 19 | 20 | ![image](https://github.com/githuanl/spring-boot-netty-socket.io---chat/blob/master/img/QQ20180629-165500.png) 21 | -------------------------------------------------------------------------------- /img/QQ20180629-165244.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/img/QQ20180629-165244.png -------------------------------------------------------------------------------- /img/QQ20180629-165327.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/img/QQ20180629-165327.png -------------------------------------------------------------------------------- /img/QQ20180629-165341.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/img/QQ20180629-165341.png -------------------------------------------------------------------------------- /img/QQ20180629-165500.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/img/QQ20180629-165500.png -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.neo 7 | spring-boot-chat 8 | 1.0.0 9 | war 10 | 11 | spring-boot-chat 12 | Demo project for Spring Boot and mongodb 13 | 14 | 15 | org.springframework.boot 16 | spring-boot-starter-parent 17 | 1.5.9.RELEASE 18 | 19 | 20 | 21 | 22 | UTF-8 23 | 1.8 24 | 25 | 26 | 27 | 28 | 29 | org.springframework.boot 30 | spring-boot-starter-web 31 | 32 | 33 | 34 | org.springframework.boot 35 | spring-boot-starter 36 | 37 | 38 | org.springframework.boot 39 | spring-boot-starter-test 40 | test 41 | 42 | 43 | org.springframework.boot 44 | spring-boot-devtools 45 | true 46 | 47 | 48 | org.springframework.boot 49 | spring-boot-starter-data-mongodb 50 | 51 | 52 | 53 | 54 | com.alibaba 55 | fastjson 56 | 1.2.31 57 | 58 | 59 | 60 | 61 | com.corundumstudio.socketio 62 | netty-socketio 63 | 1.7.14 64 | 65 | 66 | 67 | org.slf4j 68 | slf4j-simple 69 | 1.7.7 70 | 71 | 72 | 73 | org.springframework 74 | springloaded 75 | 1.2.6.RELEASE 76 | 77 | 78 | 79 | org.springframework.boot 80 | spring-boot-devtools 81 | true 82 | true 83 | 1.3.0.RELEASE 84 | 85 | 86 | 87 | 88 | com.turo 89 | pushy 90 | 0.13.2 91 | 92 | 93 | 94 | 95 | com.google.protobuf 96 | protobuf-java 97 | 3.6.0 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | org.springframework.boot 106 | spring-boot-maven-plugin 107 | 108 | true 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | -------------------------------------------------------------------------------- /src/main/java/com/neo/Application.java: -------------------------------------------------------------------------------- 1 | package com.neo; 2 | 3 | import com.corundumstudio.socketio.Configuration; 4 | import com.corundumstudio.socketio.SocketConfig; 5 | import com.corundumstudio.socketio.SocketIOClient; 6 | import com.corundumstudio.socketio.SocketIOServer; 7 | import com.corundumstudio.socketio.annotation.SpringAnnotationScanner; 8 | import com.neo.entity.UserEntity; 9 | import com.neo.serivce.UserSerivice; 10 | import com.neo.utils.SessionUtil; 11 | import io.netty.util.internal.StringUtil; 12 | import org.springframework.beans.factory.annotation.Autowired; 13 | import org.springframework.beans.factory.annotation.Value; 14 | import org.springframework.boot.SpringApplication; 15 | import org.springframework.boot.autoconfigure.SpringBootApplication; 16 | import org.springframework.context.annotation.Bean; 17 | 18 | @SpringBootApplication 19 | public class Application { 20 | 21 | @Value("${im.server.host}") 22 | private String host; 23 | @Value("${im.server.port}") 24 | private Integer port; 25 | 26 | @Autowired 27 | UserSerivice userSerivice; 28 | 29 | @Bean 30 | public SocketIOServer socketIOServer() { 31 | 32 | Configuration config = new Configuration(); 33 | config.setHostname(host); 34 | config.setPort(port); 35 | config.setPingInterval(5000); 36 | config.setPingTimeout(3000); 37 | config.setWorkerThreads(100); 38 | 39 | SocketConfig socketConfig = new SocketConfig(); 40 | socketConfig.setReuseAddress(true); 41 | config.setSocketConfig(socketConfig); 42 | 43 | //设置最大每帧处理数据的长度,防止他人利用大数据来攻击服务器 44 | config.setMaxFramePayloadLength(1024 * 1024); 45 | //设置http交互最大内容长度 46 | config.setMaxHttpContentLength(1024 * 1024); 47 | 48 | // // Instantiate Redisson configuration 49 | // Config redissonConfig = new Config(); 50 | // redissonConfig.useSingleServer().setAddress("127.0.0.1:6379"); 51 | // 52 | //// Instantiate Redisson connection 53 | // RedissonClient redisson = Redisson.create(redissonConfig); 54 | // 55 | //// Instantiate RedissonClientStoreFactory 56 | // RedissonStoreFactory redisStoreFactory = new RedissonStoreFactory(redisson); 57 | // config.setStoreFactory(redisStoreFactory); 58 | 59 | config.setAuthorizationListener(hd -> { 60 | 61 | System.out.println(hd.getUrlParams()); 62 | 63 | String auth_token = hd.getSingleUrlParam("auth_token"); 64 | 65 | if (StringUtil.isNullOrEmpty(auth_token)) { 66 | return false; 67 | } 68 | 69 | UserEntity userEntity = userSerivice.findUserByToken(auth_token); 70 | //同一个账号登录多次登录 关闭之前的连接 71 | if (userEntity != null && SessionUtil.userId_socket_Map.containsKey(userEntity.getId())) { 72 | SocketIOClient socketIOClient = SessionUtil.userId_socket_Map.get(userEntity.getId()); 73 | socketIOClient.sendEvent("otherLogin"); 74 | return false; 75 | } 76 | 77 | // 移动设备不能同时登录 (android ios) 待处理 78 | 79 | //是否拦截 socket.io 连接 80 | return userEntity == null ? false : true; 81 | }); 82 | 83 | final SocketIOServer server = new SocketIOServer(config); 84 | return server; 85 | } 86 | 87 | @Bean 88 | public SpringAnnotationScanner springAnnotationScanner(SocketIOServer socketServer) { 89 | return new SpringAnnotationScanner(socketServer); 90 | } 91 | 92 | public static void main(String[] args) { 93 | SpringApplication.run(Application.class, args); 94 | } 95 | 96 | } 97 | -------------------------------------------------------------------------------- /src/main/java/com/neo/config/InterceptorConfig.java: -------------------------------------------------------------------------------- 1 | package com.neo.config; 2 | 3 | /** 4 | * Created by liudong on 2018/6/8. 5 | */ 6 | 7 | import com.alibaba.fastjson.JSON; 8 | import com.neo.entity.Result; 9 | import org.slf4j.Logger; 10 | import org.slf4j.LoggerFactory; 11 | import org.springframework.util.StringUtils; 12 | import org.springframework.web.servlet.HandlerInterceptor; 13 | import org.springframework.web.servlet.ModelAndView; 14 | 15 | import javax.servlet.http.HttpServletRequest; 16 | import javax.servlet.http.HttpServletResponse; 17 | import javax.servlet.http.HttpSession; 18 | import java.io.PrintWriter; 19 | 20 | 21 | public class InterceptorConfig implements HandlerInterceptor { 22 | 23 | private static final Logger log = LoggerFactory.getLogger(InterceptorConfig.class); 24 | 25 | /** 26 | * 进入controller层之前拦截请求 27 | * 28 | * @param request 29 | * @param response 30 | * @param o 31 | * @return 32 | * @throws Exception 33 | */ 34 | @Override 35 | public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object o) throws Exception { 36 | 37 | // log.info("---------------------开始进入请求地址拦截----------------------------"); 38 | HttpSession session = request.getSession(); 39 | if (!StringUtils.isEmpty(session.getAttribute("username"))) { 40 | return true; 41 | } else { 42 | // 跳转登录 43 | // String url = "/login"; 44 | // response.sendRedirect(url); 45 | PrintWriter printWriter = response.getWriter(); 46 | printWriter.write(JSON.toJSONString(new Result(-1, "please login"))); 47 | return false; 48 | } 49 | } 50 | 51 | @Override 52 | public void postHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, ModelAndView modelAndView) throws Exception { 53 | // log.info("--------------处理请求完成后视图渲染之前的处理操作---------------"); 54 | } 55 | 56 | @Override 57 | public void afterCompletion(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, Exception e) throws Exception { 58 | // log.info("---------------视图渲染之后的操作-------------------------0"); 59 | } 60 | } -------------------------------------------------------------------------------- /src/main/java/com/neo/config/WebAppConfig.java: -------------------------------------------------------------------------------- 1 | package com.neo.config; 2 | 3 | /** 4 | * Created by liudong on 2018/6/8. 5 | */ 6 | 7 | import org.springframework.context.annotation.Bean; 8 | import org.springframework.context.annotation.Configuration; 9 | import org.springframework.http.converter.HttpMessageConverter; 10 | import org.springframework.http.converter.StringHttpMessageConverter; 11 | import org.springframework.web.servlet.config.annotation.InterceptorRegistry; 12 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; 13 | 14 | import java.nio.charset.Charset; 15 | import java.util.List; 16 | 17 | /** 18 | * 注册拦截器 19 | * Created by SYSTEM on 2017/8/16. 20 | */ 21 | @Configuration 22 | //@EnableWebMvc 23 | public class WebAppConfig extends WebMvcConfigurerAdapter { 24 | 25 | 26 | // // 如果启用了 @EnableWebMvc 注解 必须在这里设置 静态资源路径 properties中的设置将失效 27 | // @Override 28 | // public void addResourceHandlers(ResourceHandlerRegistry registry) { 29 | // //将所有/static/** 访问都映射到classpath:/static/ 目录下 favicon.ico 太坑爹了。。。 30 | // registry.addResourceHandler("/static/**","/favicon.ico") 31 | // .addResourceLocations("classpath:/static/", "file:/Users/liudong/Downloads/111111111/"); 32 | // } 33 | 34 | @Override 35 | public void addInterceptors(InterceptorRegistry registry) { 36 | //注册自定义拦截器,添加拦截路径和排除拦截路径 37 | registry.addInterceptor(new InterceptorConfig()) 38 | .addPathPatterns("/**") 39 | .excludePathPatterns("/user/login", "/user/register","/"); 40 | } 41 | 42 | // 以下 两个方法 解决乱码问题 43 | @Bean 44 | public HttpMessageConverter responseBodyConverter() { 45 | HttpMessageConverter converter = new StringHttpMessageConverter(Charset.forName("UTF-8")); 46 | return converter; 47 | } 48 | 49 | @Override 50 | public void configureMessageConverters(List> converters) { 51 | super.configureMessageConverters(converters); 52 | converters.add(responseBodyConverter()); 53 | } 54 | 55 | } -------------------------------------------------------------------------------- /src/main/java/com/neo/controller/AddMessageController.java: -------------------------------------------------------------------------------- 1 | package com.neo.controller; 2 | 3 | import com.alibaba.fastjson.JSONObject; 4 | import com.neo.entity.UserEntity; 5 | import com.neo.serivce.AddMessageSerivice; 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.RequestMethod; 10 | import org.springframework.web.bind.annotation.ResponseBody; 11 | 12 | @Controller 13 | @RequestMapping(value = "/addMsg") 14 | public class AddMessageController extends BaseController { 15 | 16 | @Autowired 17 | AddMessageSerivice addMessageSerivice; 18 | 19 | /** 20 | * 询消息盒子信息 21 | * 22 | * @return 23 | */ 24 | @ResponseBody 25 | @RequestMapping(method = RequestMethod.GET, value = "/findAddInfo") 26 | public String findAddInfo(String page) { 27 | JSONObject obj = addMessageSerivice.findAddInfo(getSessionUser().getId()); 28 | return retResultData(0, "", obj); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/neo/controller/BaseController.java: -------------------------------------------------------------------------------- 1 | package com.neo.controller; 2 | 3 | import com.alibaba.fastjson.JSON; 4 | import com.neo.entity.BaseEntity; 5 | import com.neo.entity.Result; 6 | import com.neo.entity.UserEntity; 7 | import com.neo.enums.EResultType; 8 | import org.apache.log4j.LogManager; 9 | import org.apache.log4j.Logger; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | 12 | import javax.servlet.http.HttpSession; 13 | 14 | public class BaseController { 15 | 16 | 17 | @Autowired 18 | HttpSession session; 19 | 20 | 21 | public UserEntity getSessionUser(){ 22 | return (UserEntity) session.getAttribute("username"); 23 | } 24 | 25 | protected Logger logger = LogManager.getLogger(getClass().getName()); 26 | 27 | 28 | protected String retResultData(EResultType type) { 29 | return JSON.toJSONString(new Result(type)); 30 | } 31 | 32 | protected String retResultData(EResultType type, Object data) { 33 | return JSON.toJSONString(new Result(type, data)); 34 | } 35 | 36 | protected String retResultData(Integer code, String message) { 37 | return JSON.toJSONString(new Result(code, message)); 38 | } 39 | 40 | protected String retResultData(Integer code, String message, Object data) { 41 | return JSON.toJSONString(new Result(code, message, data)); 42 | } 43 | 44 | 45 | 46 | 47 | 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/com/neo/controller/ChatController.java: -------------------------------------------------------------------------------- 1 | package com.neo.controller; 2 | 3 | import com.neo.entity.MessageEntity; 4 | import com.neo.enums.EResultType; 5 | import com.neo.serivce.ChatSerivice; 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.ResponseBody; 10 | 11 | 12 | @Controller 13 | @RequestMapping(value = "/chat") 14 | public class ChatController extends BaseController { 15 | 16 | @Autowired 17 | ChatSerivice chatSerivice; 18 | 19 | @ResponseBody 20 | @RequestMapping(value = "/t") 21 | public String test() { 22 | return retResultData(EResultType.SUCCESS, "ks"); 23 | } 24 | 25 | @ResponseBody 26 | @RequestMapping(value = "/t4") 27 | public String tests() { 28 | chatSerivice.sendApnData(); 29 | return retResultData(EResultType.SUCCESS); 30 | } 31 | 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/neo/controller/GroupController.java: -------------------------------------------------------------------------------- 1 | package com.neo.controller; 2 | 3 | import com.alibaba.fastjson.JSONObject; 4 | import com.neo.entity.GroupEntity; 5 | import com.neo.entity.GroupUser; 6 | import com.neo.entity.UserEntity; 7 | import com.neo.serivce.GroupSerivice; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.stereotype.Controller; 10 | import org.springframework.web.bind.annotation.PostMapping; 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 | 15 | import java.util.List; 16 | 17 | @Controller 18 | @RequestMapping(value = "/group") 19 | public class GroupController extends BaseController { 20 | 21 | @Autowired 22 | GroupSerivice groupSerivice; 23 | 24 | 25 | /** 26 | * 根据名字 查询 对应的群,群名称为空则查询 所有群 27 | * 28 | * @return 29 | */ 30 | @ResponseBody 31 | @PostMapping(value = "/creat") 32 | public String creatGroup(String name, String avatar) { 33 | GroupEntity groupEntity = groupSerivice.creatGroup(name, avatar, getSessionUser()); 34 | return retResultData(0, "", groupEntity); 35 | } 36 | 37 | 38 | /** 39 | * 根据 名字 查询对应的群 40 | * 41 | * @return 42 | */ 43 | @ResponseBody 44 | @RequestMapping(method = RequestMethod.GET, value = "/findGroupsByName") 45 | public String findGroupsByName(String page, String name) { 46 | List list = groupSerivice.findGroupsByGroupName(name); 47 | return retResultData(0, "", list); 48 | } 49 | 50 | 51 | /** 52 | * 查询指定群下面的 群成员 53 | * id 群id 54 | * 55 | * @return 56 | */ 57 | @ResponseBody 58 | @RequestMapping(method = RequestMethod.GET, value = "/findGroupUsers") 59 | public String findGroupUsers(String id) { 60 | List list = groupSerivice.findUsersByGroupId(id); 61 | for (GroupUser user : list) { 62 | user.setId(user.getUser_id()); 63 | user.setUser_id(""); 64 | } 65 | JSONObject obj = new JSONObject(); 66 | obj.put("list", list); 67 | return retResultData(0, "", obj); 68 | } 69 | 70 | 71 | } 72 | -------------------------------------------------------------------------------- /src/main/java/com/neo/controller/IndexController.java: -------------------------------------------------------------------------------- 1 | package com.neo.controller; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.web.bind.annotation.RequestMapping; 5 | 6 | import javax.servlet.http.HttpSession; 7 | 8 | /** 9 | * Created by liudong on 2018/6/15. 10 | */ 11 | @Controller 12 | public class IndexController extends BaseController { 13 | 14 | @RequestMapping("/") 15 | public String index(HttpSession session) { 16 | if (session.getAttribute("username") != null) { 17 | return "static/index.html"; 18 | } 19 | return "static/login.html"; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/neo/controller/UserController.java: -------------------------------------------------------------------------------- 1 | package com.neo.controller; 2 | 3 | import com.alibaba.fastjson.JSONArray; 4 | import com.alibaba.fastjson.JSONObject; 5 | import com.neo.entity.UserEntity; 6 | import com.neo.enums.EResultType; 7 | import com.neo.serivce.GroupSerivice; 8 | import com.neo.serivce.UserSerivice; 9 | import io.netty.util.internal.StringUtil; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.beans.factory.annotation.Value; 12 | import org.springframework.stereotype.Controller; 13 | import org.springframework.web.bind.annotation.*; 14 | import org.springframework.web.multipart.MultipartFile; 15 | 16 | import javax.servlet.http.HttpServletRequest; 17 | import java.io.IOException; 18 | import java.net.InetAddress; 19 | import java.net.UnknownHostException; 20 | import java.nio.file.Files; 21 | import java.nio.file.Path; 22 | import java.nio.file.Paths; 23 | import java.util.List; 24 | import java.util.UUID; 25 | 26 | @Controller 27 | @RequestMapping(value = "/user") 28 | public class UserController extends BaseController { 29 | 30 | @Value("${server.port}") 31 | private Integer port; 32 | 33 | @Autowired 34 | UserSerivice userSerivice; 35 | 36 | @Autowired 37 | GroupSerivice groupSerivice; 38 | 39 | 40 | /** 41 | * 登录 42 | * 43 | * @param name 44 | * @param password 45 | * @return 46 | */ 47 | @ResponseBody 48 | @RequestMapping(value = "/login") 49 | public String login(String name, String password) { 50 | 51 | if (StringUtil.isNullOrEmpty(name) || StringUtil.isNullOrEmpty(password)) { 52 | return retResultData(-1, "用户名或密码不能为空"); 53 | } 54 | 55 | UserEntity user = userSerivice.findUserByUserName(name); 56 | if (user != null) { 57 | if (!user.getPassword().equals(password)) { 58 | return retResultData(EResultType.PASSWORK_ERROR); 59 | } 60 | user.setPassword(""); 61 | session.setAttribute("username", user); 62 | } else { 63 | return retResultData(EResultType.PASSWORK_ERROR); 64 | } 65 | return retResultData(EResultType.SUCCESS, user); 66 | } 67 | 68 | // 注册 69 | @ResponseBody 70 | @GetMapping(value = "/register") 71 | public String register(String name, String password, String avatar) { 72 | 73 | if (StringUtil.isNullOrEmpty(name) || StringUtil.isNullOrEmpty(password)) { 74 | return retResultData(-1, "用户名或密码不能为空"); 75 | } 76 | 77 | UserEntity user = userSerivice.findUserByUserName(name); 78 | if (user != null) { 79 | return retResultData(-1, "用户名已存在"); 80 | } 81 | 82 | user = userSerivice.register(name, password, avatar); 83 | 84 | return retResultData(EResultType.SUCCESS, user); 85 | } 86 | 87 | //退出登录 88 | @RequestMapping(value = "/logout") 89 | public String logout() { 90 | session.invalidate(); 91 | return "/static/index.html"; 92 | } 93 | 94 | 95 | //获取当前登录人的Token 96 | @ResponseBody 97 | @GetMapping(value = "/getToken") 98 | public String getAuthToken() { 99 | return retResultData(EResultType.SUCCESS, getSessionUser().getAuth_token()); 100 | } 101 | 102 | 103 | //修改 个性签名 104 | @ResponseBody 105 | @PostMapping(value = "/updateSign") 106 | public String updateSign(String sign) { 107 | 108 | UserEntity entity = getSessionUser(); 109 | entity = (UserEntity) userSerivice.getEntityById(entity.getId()); 110 | entity.setSign(sign); 111 | userSerivice.saveEntity(entity); 112 | 113 | return retResultData(0, "修改成功"); 114 | } 115 | 116 | 117 | /** 118 | * 目前是 查询系统中的 所有人员 119 | * 及 自己所在的群 120 | * 和 创建的群 121 | * @return 122 | */ 123 | @ResponseBody 124 | @RequestMapping(method = RequestMethod.GET, value = "/findAllUser") 125 | public String findAllUser() { 126 | 127 | //获取所有的群组 128 | UserEntity userEntity = getSessionUser(); 129 | 130 | JSONObject obj = new JSONObject(); 131 | obj.put("mine", userEntity); 132 | 133 | //分组 134 | JSONArray array = new JSONArray(); 135 | JSONObject f = new JSONObject(); 136 | f.put("groupname", "我的好友"); 137 | f.put("id", "0"); 138 | f.put("list", userSerivice.selectAll()); 139 | array.add(f); 140 | obj.put("friend", array); 141 | 142 | obj.put("group", groupSerivice.findMyGroupsByUserId(userEntity.getId())); 143 | 144 | return retResultData(0, "", obj); 145 | } 146 | 147 | 148 | /** 149 | * 询消息盒子信息 150 | * 151 | * @return 152 | */ 153 | @ResponseBody 154 | @RequestMapping(method = RequestMethod.GET, value = "/findUsersByName") 155 | public String findUsersByName(String page, String name) { 156 | 157 | List list = userSerivice.findUsersByName(page, name); 158 | return retResultData(0, "", list); 159 | } 160 | 161 | 162 | @Value("${web.upload-path}") 163 | private String path; //文件上传的路径 164 | 165 | //文件上传 166 | @RequestMapping(value = "/upload", method = RequestMethod.POST) 167 | public @ResponseBody 168 | String uploadImg(@RequestParam("file") MultipartFile file, 169 | HttpServletRequest request) throws UnknownHostException { 170 | 171 | if (file.isEmpty()) { 172 | return retResultData(-1, "上传文件不能为空"); 173 | } 174 | 175 | // String contentType = file.getContentType(); 176 | String fileName = file.getOriginalFilename(); 177 | String uuid = UUID.randomUUID().toString(); 178 | 179 | byte[] bytes = new byte[0]; 180 | try { 181 | bytes = file.getBytes(); 182 | Path ph = Paths.get(path + uuid + fileName); 183 | Files.write(ph, bytes); 184 | } catch (IOException e) { 185 | e.printStackTrace(); 186 | } 187 | 188 | InetAddress addr = InetAddress.getLocalHost(); 189 | String ip = addr.getHostAddress();//获得本机IP 190 | JSONObject obj = new JSONObject(); 191 | obj.put("src", "http://" + ip + ":" + port + "/static/" + uuid + fileName); 192 | //返回json 193 | return retResultData(0, "", obj); 194 | } 195 | 196 | } 197 | -------------------------------------------------------------------------------- /src/main/java/com/neo/dao/AddMessageDao.java: -------------------------------------------------------------------------------- 1 | package com.neo.dao; 2 | 3 | import com.neo.entity.AddMessage; 4 | import com.neo.entity.BaseEntity; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * Created by summer on 2017/5/5. 10 | */ 11 | public interface AddMessageDao extends BaseDao { 12 | 13 | /** 14 | * @description 查询消息盒子信息 15 | */ 16 | List findAddInfo(String userId); 17 | 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/neo/dao/BaseDao.java: -------------------------------------------------------------------------------- 1 | package com.neo.dao; 2 | 3 | import com.neo.entity.BaseEntity; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * Created by summer on 2017/5/5. 9 | */ 10 | public interface BaseDao { 11 | 12 | 13 | /** 14 | * 根据Id查询实体 15 | */ 16 | public T findEntityById(String id); 17 | 18 | /** 19 | * 新增实体 20 | */ 21 | public void saveEntity(T entity); 22 | 23 | /** 24 | * 更新实体 25 | */ 26 | public T updateEntityById(String id,T entity); 27 | 28 | /** 29 | * 根据Id删除实体 30 | */ 31 | public int deleteEntityById(String id); 32 | 33 | /** 34 | * 查询全部 35 | */ 36 | public List selectAll(); 37 | 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/neo/dao/GroupDao.java: -------------------------------------------------------------------------------- 1 | package com.neo.dao; 2 | 3 | import com.neo.entity.BaseEntity; 4 | import com.neo.entity.GroupEntity; 5 | import com.neo.entity.GroupUser; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * Created by summer on 2017/5/5. 11 | */ 12 | public interface GroupDao extends BaseDao { 13 | 14 | /** 15 | * 根据群的名字查询所有的群 16 | * 17 | * @return 18 | */ 19 | List findGroupsByGroupName(String groupName); 20 | 21 | 22 | /** 23 | * 获取 我所在的 所有的群 24 | * 25 | * @return 26 | */ 27 | List findMyGroupsByUserId(String userId); 28 | 29 | 30 | 31 | /** 32 | * 获取 群 下面的所有人员 33 | * @return 34 | */ 35 | List findUsersByGroupId(String group_id); 36 | 37 | 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/neo/dao/UserDao.java: -------------------------------------------------------------------------------- 1 | package com.neo.dao; 2 | 3 | import com.neo.entity.*; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * Created by summer on 2017/5/5. 9 | */ 10 | public interface UserDao extends BaseDao { 11 | 12 | //根据名称查询 user 13 | UserEntity findUserByUserName(String name); 14 | 15 | //根据Token查询 user 16 | UserEntity findUserByToken(String access_token); 17 | 18 | 19 | /** 20 | * 根据用户名查询 对应的人员 21 | * 22 | * @return 23 | */ 24 | List findUsersByName(String page, String name); 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/neo/dao/impl/AddMessageDaoImpl.java: -------------------------------------------------------------------------------- 1 | package com.neo.dao.impl; 2 | 3 | import com.neo.dao.AddMessageDao; 4 | import com.neo.entity.AddMessage; 5 | import com.neo.entity.BaseEntity; 6 | import org.springframework.data.domain.Sort; 7 | import org.springframework.data.mongodb.core.query.Criteria; 8 | import org.springframework.data.mongodb.core.query.Query; 9 | import org.springframework.stereotype.Component; 10 | 11 | import java.util.List; 12 | 13 | /** 14 | * Created by summer on 2017/5/5. 15 | */ 16 | @Component 17 | public class AddMessageDaoImpl extends BaseDaoImpl implements AddMessageDao { 18 | 19 | /** 20 | * @description 查询消息盒子信息 21 | */ 22 | @Override 23 | public List findAddInfo(String userId) { 24 | Query query = new Query(Criteria.where("toUid").is(userId)); 25 | query.with(new Sort(new Sort.Order(Sort.Direction.DESC, "time"))); 26 | List list = mongoTemplate.find(query,entityClass); 27 | return list; 28 | } 29 | 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/neo/dao/impl/BaseDaoImpl.java: -------------------------------------------------------------------------------- 1 | package com.neo.dao.impl; 2 | 3 | import com.alibaba.fastjson.JSON; 4 | import com.alibaba.fastjson.JSONObject; 5 | import com.mongodb.WriteResult; 6 | import com.neo.dao.BaseDao; 7 | import com.neo.entity.BaseEntity; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.data.mongodb.core.MongoTemplate; 10 | import org.springframework.data.mongodb.core.query.Criteria; 11 | import org.springframework.data.mongodb.core.query.Query; 12 | import org.springframework.data.mongodb.core.query.Update; 13 | 14 | import java.lang.reflect.ParameterizedType; 15 | import java.util.List; 16 | import java.util.Map; 17 | 18 | /** 19 | * Created by summer on 2017/5/5. 20 | */ 21 | public class BaseDaoImpl implements BaseDao { 22 | 23 | @Autowired 24 | protected MongoTemplate mongoTemplate; 25 | 26 | protected Class entityClass; 27 | 28 | public BaseDaoImpl() { 29 | // 使用反射技术得到T的真实类型 30 | ParameterizedType pt = (ParameterizedType) this.getClass().getGenericSuperclass(); // 获取当前new的对象的 泛型的父类 类型 31 | this.entityClass = (Class) pt.getActualTypeArguments()[0]; // 获取第一个类型参数的真实类型 32 | } 33 | 34 | 35 | @Override 36 | public T findEntityById(String id) { 37 | Query query = new Query(Criteria.where("id").is(id)); 38 | T t = mongoTemplate.findOne(query, entityClass); 39 | return t; 40 | } 41 | 42 | @Override 43 | public void saveEntity(T entity) { 44 | mongoTemplate.save(entity); 45 | } 46 | 47 | @Override 48 | public T updateEntityById(String id, T entity) { 49 | 50 | Query query = new Query(Criteria.where("id").is(id)); 51 | 52 | Update update = new Update(); 53 | 54 | JSONObject jsonObject = (JSONObject) JSON.toJSON(entity); 55 | 56 | for (Map.Entry entry : jsonObject.entrySet()) { 57 | if (!entry.getKey().equals("id")) { 58 | update.set(entry.getKey(), entry.getValue() == null ? "" : entry.getValue()); 59 | } 60 | } 61 | //更新查询返回结果集的第一条 62 | WriteResult result = mongoTemplate.updateFirst(query, update, entityClass); 63 | //更新查询返回结果集的所有 64 | // return mongoTemplate.updateMulti(query,update,entityClass); 65 | // if (result != null) 66 | // return result.getN(); 67 | // else 68 | // return t; 69 | return entity; 70 | } 71 | 72 | 73 | // 删除对象 74 | @Override 75 | public int deleteEntityById(String id) { 76 | Query query = new Query(Criteria.where("id").is(id)); 77 | WriteResult writeResult = mongoTemplate.remove(query, entityClass); 78 | return writeResult != null ? writeResult.getN() : 0; 79 | } 80 | 81 | @Override 82 | public List selectAll() { 83 | return mongoTemplate.findAll(entityClass); 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /src/main/java/com/neo/dao/impl/GroupDaoImpl.java: -------------------------------------------------------------------------------- 1 | package com.neo.dao.impl; 2 | 3 | import com.neo.dao.GroupDao; 4 | import com.neo.entity.BaseEntity; 5 | import com.neo.entity.GroupEntity; 6 | import com.neo.entity.GroupUser; 7 | import org.springframework.data.mongodb.core.query.Criteria; 8 | import org.springframework.data.mongodb.core.query.Query; 9 | import org.springframework.stereotype.Component; 10 | import org.springframework.util.StringUtils; 11 | 12 | import java.util.List; 13 | 14 | /** 15 | * Created by summer on 2017/5/5. 16 | */ 17 | @Component 18 | public class GroupDaoImpl extends BaseDaoImpl implements GroupDao { 19 | 20 | 21 | /** 22 | * 根据群的名字 查询所有的群 23 | * 24 | * @return 25 | */ 26 | @Override 27 | public List findGroupsByGroupName(String groupName) { 28 | List list; 29 | if (StringUtils.isEmpty(groupName)) { 30 | list = mongoTemplate.findAll(GroupEntity.class); 31 | } else { 32 | Query query = new Query(Criteria.where("groupname").regex(groupName)); 33 | list = mongoTemplate.find(query, GroupEntity.class); 34 | } 35 | return list; 36 | } 37 | 38 | 39 | /** 40 | * 获取 我所在的 所有的群 41 | * 42 | * @return 43 | */ 44 | @Override 45 | public List findMyGroupsByUserId(String user_id) { 46 | // 我创建的群 47 | Query query = new Query(Criteria.where("user_id").is(user_id)); 48 | List list = mongoTemplate.find(query, GroupEntity.class); 49 | 50 | //我加过的群 51 | List users = mongoTemplate.find(query, GroupUser.class); 52 | 53 | for (GroupUser user : users) { 54 | query = new Query(Criteria.where("id").is(user.getGroup_id())); 55 | GroupEntity entity = mongoTemplate.findOne(query, GroupEntity.class); 56 | if (!entity.getUser_id().equals(user_id)) { //不是自己创建的群 (只是加入的群) 57 | list.add(entity); 58 | } 59 | } 60 | return list; 61 | } 62 | 63 | 64 | /** 65 | * 根据群id 查询群下面的所有的人 66 | * 67 | * @return 68 | */ 69 | @Override 70 | public List findUsersByGroupId(String group_id) { 71 | Query query = new Query(Criteria.where("group_id").is(group_id)); 72 | List list = mongoTemplate.find(query, GroupUser.class); 73 | return list; 74 | } 75 | 76 | 77 | } 78 | -------------------------------------------------------------------------------- /src/main/java/com/neo/dao/impl/UserDaoImpl.java: -------------------------------------------------------------------------------- 1 | package com.neo.dao.impl; 2 | 3 | import com.mongodb.BasicDBObject; 4 | import com.mongodb.DBObject; 5 | import com.neo.dao.UserDao; 6 | import com.neo.entity.BaseEntity; 7 | import com.neo.entity.UserEntity; 8 | import org.springframework.data.mongodb.core.query.BasicQuery; 9 | import org.springframework.data.mongodb.core.query.Criteria; 10 | import org.springframework.data.mongodb.core.query.Query; 11 | import org.springframework.stereotype.Component; 12 | import org.springframework.util.StringUtils; 13 | 14 | import java.util.List; 15 | 16 | /** 17 | * Created by summer on 2017/5/5. 18 | */ 19 | @Component 20 | public class UserDaoImpl extends BaseDaoImpl implements UserDao { 21 | 22 | /** 23 | * 根据用户名查询对象 24 | * 25 | * @param name 26 | * @return 27 | */ 28 | @Override 29 | public UserEntity findUserByUserName(String name) { 30 | Query query = new Query(Criteria.where("username").is(name)); 31 | UserEntity user = mongoTemplate.findOne(query, UserEntity.class); 32 | return user; 33 | } 34 | 35 | /** 36 | * 根据用户Token查询对象 37 | * 38 | * @param access_token 39 | * @return 40 | */ 41 | @Override 42 | public UserEntity findUserByToken(String access_token) { 43 | Query query = new Query(Criteria.where("auth_token").is(access_token)); 44 | UserEntity user = mongoTemplate.findOne(query, UserEntity.class); 45 | return user; 46 | } 47 | 48 | /** 49 | * 根据用户名查询 对应的人员 50 | * 51 | * @return 52 | */ 53 | @Override 54 | public List findUsersByName(String page, String name) { 55 | List list; 56 | if (StringUtils.isEmpty(name)) { 57 | list = mongoTemplate.findAll(UserEntity.class); 58 | } else { 59 | Query query = new Query(Criteria.where("String").regex(name)); 60 | list = mongoTemplate.find(query, UserEntity.class); 61 | } 62 | return list; 63 | } 64 | 65 | 66 | @Override 67 | public List selectAll() { 68 | DBObject dbObject = new BasicDBObject(); 69 | //dbObject.put("name", "zhangsan"); //查询条件 70 | 71 | BasicDBObject fieldsObject = new BasicDBObject(); 72 | //指定返回的字段 73 | fieldsObject.put("id", true); 74 | fieldsObject.put("username", true); 75 | fieldsObject.put("avatar", true); 76 | fieldsObject.put("sign", true); 77 | fieldsObject.put("nickname", true); 78 | 79 | Query query = new BasicQuery(dbObject, fieldsObject); 80 | List userEntities = mongoTemplate.find(query, UserEntity.class); 81 | return userEntities; 82 | } 83 | 84 | 85 | } 86 | -------------------------------------------------------------------------------- /src/main/java/com/neo/entity/AddInfo.java: -------------------------------------------------------------------------------- 1 | package com.neo.entity; 2 | 3 | /** 4 | * Created by liudong on 2018/6/27. 5 | */ 6 | public class AddInfo extends BaseEntity { 7 | 8 | private String id; 9 | 10 | private String uid; 11 | 12 | private String content; 13 | 14 | private String from; 15 | 16 | private String from_group; 17 | 18 | private String Type; 19 | 20 | private String remark; 21 | 22 | private String href; 23 | 24 | private String read; 25 | 26 | private String time; 27 | 28 | private UserEntity user; 29 | 30 | public String getId() { 31 | return id; 32 | } 33 | 34 | public void setId(String id) { 35 | this.id = id; 36 | } 37 | 38 | public String getUid() { 39 | return uid; 40 | } 41 | 42 | public void setUid(String uid) { 43 | this.uid = uid; 44 | } 45 | 46 | public String getContent() { 47 | return content; 48 | } 49 | 50 | public void setContent(String content) { 51 | this.content = content; 52 | } 53 | 54 | public String getFrom() { 55 | return from; 56 | } 57 | 58 | public void setFrom(String from) { 59 | this.from = from; 60 | } 61 | 62 | public String getFrom_group() { 63 | return from_group; 64 | } 65 | 66 | public void setFrom_group(String from_group) { 67 | this.from_group = from_group; 68 | } 69 | 70 | public String getType() { 71 | return Type; 72 | } 73 | 74 | public void setType(String type) { 75 | Type = type; 76 | } 77 | 78 | public String getRemark() { 79 | return remark; 80 | } 81 | 82 | public void setRemark(String remark) { 83 | this.remark = remark; 84 | } 85 | 86 | public String getHref() { 87 | return href; 88 | } 89 | 90 | public void setHref(String href) { 91 | this.href = href; 92 | } 93 | 94 | public String getRead() { 95 | return read; 96 | } 97 | 98 | public void setRead(String read) { 99 | this.read = read; 100 | } 101 | 102 | public String getTime() { 103 | return time; 104 | } 105 | 106 | public void setTime(String time) { 107 | this.time = time; 108 | } 109 | 110 | public UserEntity getUser() { 111 | return user; 112 | } 113 | 114 | public void setUser(UserEntity user) { 115 | this.user = user; 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /src/main/java/com/neo/entity/AddMessage.java: -------------------------------------------------------------------------------- 1 | package com.neo.entity; 2 | 3 | import com.neo.enums.AddMessageType; 4 | import org.springframework.data.annotation.Id; 5 | import org.springframework.data.mongodb.core.mapping.Document; 6 | 7 | /** 8 | * Created by liudong on 2018/6/26. 9 | */ 10 | @Document(collection = "t_add_message") 11 | public class AddMessage extends BaseEntity { 12 | 13 | @Id 14 | private String id; 15 | 16 | private String fromUid; //谁发起的请求 17 | 18 | private String toUid; //发送给谁的申请,可能是群,那么就是创建该群组的用户 19 | private String groupId; //创建人,群主 20 | 21 | private String remark; //附言 22 | 23 | private String ext; //扩展数据 24 | 25 | private AddMessageType msgResult = AddMessageType.Untreated; //消息处理结果 26 | 27 | private String type; //类型 ,可能是添加好友或群组 friend 好友, group 群组 28 | 29 | private String time; //申请时间 30 | 31 | 32 | public String getExt() { 33 | return ext; 34 | } 35 | 36 | public void setExt(String ext) { 37 | this.ext = ext; 38 | } 39 | 40 | public String getId() { 41 | return id; 42 | } 43 | 44 | public void setId(String id) { 45 | this.id = id; 46 | } 47 | 48 | public String getFromUid() { 49 | return fromUid; 50 | } 51 | 52 | public void setFromUid(String fromUid) { 53 | this.fromUid = fromUid; 54 | } 55 | 56 | public String getToUid() { 57 | return toUid; 58 | } 59 | 60 | public void setToUid(String toUid) { 61 | this.toUid = toUid; 62 | } 63 | 64 | public String getGroupId() { 65 | return groupId; 66 | } 67 | 68 | public void setGroupId(String groupId) { 69 | this.groupId = groupId; 70 | } 71 | 72 | public String getRemark() { 73 | return remark; 74 | } 75 | 76 | public void setRemark(String remark) { 77 | this.remark = remark; 78 | } 79 | 80 | 81 | public AddMessageType getMsgResult() { 82 | return msgResult; 83 | } 84 | 85 | public void setMsgResult(AddMessageType msgResult) { 86 | this.msgResult = msgResult; 87 | } 88 | 89 | public String getType() { 90 | return type; 91 | } 92 | 93 | public void setType(String type) { 94 | this.type = type; 95 | } 96 | 97 | public String getTime() { 98 | return time; 99 | } 100 | 101 | public void setTime(String time) { 102 | this.time = time; 103 | } 104 | 105 | 106 | @Override 107 | public String toString() { 108 | return "AddMessage{" + 109 | "id='" + id + '\'' + 110 | ", fromUid='" + fromUid + '\'' + 111 | ", toUid='" + toUid + '\'' + 112 | ", groupId='" + groupId + '\'' + 113 | ", remark='" + remark + '\'' + 114 | ", ext=" + ext + 115 | ", msgResult=" + msgResult + 116 | ", type='" + type + '\'' + 117 | ", time=" + time + 118 | '}'; 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /src/main/java/com/neo/entity/BaseEntity.java: -------------------------------------------------------------------------------- 1 | package com.neo.entity; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * Created by liudong on 2018/6/8. 7 | */ 8 | public class BaseEntity implements Serializable { 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/com/neo/entity/Bodies.java: -------------------------------------------------------------------------------- 1 | package com.neo.entity; 2 | 3 | import com.neo.enums.Body_type; 4 | 5 | /** 6 | * Created by liudong on 2018/6/12. 7 | */ 8 | public class Bodies extends BaseEntity { 9 | 10 | private Body_type type; 11 | private String msg; //消息内容 12 | 13 | private String imgUrl; //imageUrl 14 | private String imageName; //imageName 15 | 16 | /*图片*/ 17 | private String thumbnailRemotePath; //缩略图 18 | private String originImagePath; //原始路径 19 | 20 | /*位置*/ 21 | private double latitude; 22 | private double longitude; 23 | private String locationName; 24 | private String detailLocationName; 25 | 26 | 27 | private Byte[] fileData; 28 | private String fileName; 29 | private String fileRemotePath; 30 | 31 | /*语音*/ 32 | private int duration; 33 | 34 | 35 | public Body_type getType() { 36 | return type; 37 | } 38 | 39 | public void setType(Body_type type) { 40 | this.type = type; 41 | } 42 | 43 | public String getMsg() { 44 | return msg; 45 | } 46 | 47 | public void setMsg(String msg) { 48 | this.msg = msg; 49 | } 50 | 51 | public String getImgUrl() { 52 | return imgUrl; 53 | } 54 | 55 | public void setImgUrl(String imgUrl) { 56 | this.imgUrl = imgUrl; 57 | } 58 | 59 | public String getImageName() { 60 | return imageName; 61 | } 62 | 63 | public void setImageName(String imageName) { 64 | this.imageName = imageName; 65 | } 66 | 67 | public String getThumbnailRemotePath() { 68 | return thumbnailRemotePath; 69 | } 70 | 71 | public void setThumbnailRemotePath(String thumbnailRemotePath) { 72 | this.thumbnailRemotePath = thumbnailRemotePath; 73 | } 74 | 75 | public String getOriginImagePath() { 76 | return originImagePath; 77 | } 78 | 79 | public void setOriginImagePath(String originImagePath) { 80 | this.originImagePath = originImagePath; 81 | } 82 | 83 | public double getLatitude() { 84 | return latitude; 85 | } 86 | 87 | public void setLatitude(double latitude) { 88 | this.latitude = latitude; 89 | } 90 | 91 | public double getLongitude() { 92 | return longitude; 93 | } 94 | 95 | public void setLongitude(double longitude) { 96 | this.longitude = longitude; 97 | } 98 | 99 | public String getLocationName() { 100 | return locationName; 101 | } 102 | 103 | public void setLocationName(String locationName) { 104 | this.locationName = locationName; 105 | } 106 | 107 | public String getDetailLocationName() { 108 | return detailLocationName; 109 | } 110 | 111 | public void setDetailLocationName(String detailLocationName) { 112 | this.detailLocationName = detailLocationName; 113 | } 114 | 115 | public Byte[] getFileData() { 116 | return fileData; 117 | } 118 | 119 | public void setFileData(Byte[] fileData) { 120 | this.fileData = fileData; 121 | } 122 | 123 | public String getFileName() { 124 | return fileName; 125 | } 126 | 127 | public void setFileName(String fileName) { 128 | this.fileName = fileName; 129 | } 130 | 131 | public String getFileRemotePath() { 132 | return fileRemotePath; 133 | } 134 | 135 | public void setFileRemotePath(String fileRemotePath) { 136 | this.fileRemotePath = fileRemotePath; 137 | } 138 | 139 | public int getDuration() { 140 | return duration; 141 | } 142 | 143 | public void setDuration(int duration) { 144 | this.duration = duration; 145 | } 146 | } 147 | -------------------------------------------------------------------------------- /src/main/java/com/neo/entity/GroupEntity.java: -------------------------------------------------------------------------------- 1 | package com.neo.entity; 2 | 3 | import org.springframework.data.annotation.Id; 4 | import org.springframework.data.mongodb.core.mapping.Document; 5 | 6 | /** 7 | * Created by liudong on 2018/6/20. 8 | */ 9 | @Document(collection = "t_group") 10 | public class GroupEntity extends BaseEntity { 11 | 12 | @Id 13 | private String id; //群id 14 | private String groupname; //群的名字 15 | private String user_id; //创建的人 id 16 | private String user_name; //创建人的名字,群主 17 | private String creat_date; //创建时间 18 | private String avatar; //群的头像 19 | 20 | public String getId() { 21 | return id; 22 | } 23 | 24 | public void setId(String id) { 25 | this.id = id; 26 | } 27 | 28 | public String getGroupname() { 29 | return groupname; 30 | } 31 | 32 | public void setGroupname(String groupname) { 33 | this.groupname = groupname; 34 | } 35 | 36 | public String getUser_id() { 37 | return user_id; 38 | } 39 | 40 | public void setUser_id(String user_id) { 41 | this.user_id = user_id; 42 | } 43 | 44 | public String getUser_name() { 45 | return user_name; 46 | } 47 | 48 | public void setUser_name(String user_name) { 49 | this.user_name = user_name; 50 | } 51 | 52 | public String getCreat_date() { 53 | return creat_date; 54 | } 55 | 56 | public void setCreat_date(String creat_date) { 57 | this.creat_date = creat_date; 58 | } 59 | 60 | public String getAvatar() { 61 | return avatar; 62 | } 63 | 64 | public void setAvatar(String avatar) { 65 | this.avatar = avatar; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/main/java/com/neo/entity/GroupUser.java: -------------------------------------------------------------------------------- 1 | package com.neo.entity; 2 | 3 | import org.springframework.data.annotation.Id; 4 | import org.springframework.data.mongodb.core.mapping.Document; 5 | 6 | /** 7 | * Created by liudong on 2018/6/20. 8 | */ 9 | 10 | //群成员 11 | @Document(collection = "t_group_user") 12 | public class GroupUser extends BaseEntity { 13 | 14 | @Id 15 | private String id; 16 | private String group_id; // 群 id 17 | private String user_id; //群成员的id 18 | private String username; //群成员的名字 19 | 20 | // 冗余数据,不想关联查询 21 | private String avatar; //群成员的头像 22 | private String sign; //签名 23 | private String joninTime; //加入时间 24 | 25 | public String getJoninTime() { 26 | return joninTime; 27 | } 28 | 29 | public void setJoninTime(String joninTime) { 30 | this.joninTime = joninTime; 31 | } 32 | 33 | public String getId() { 34 | return id; 35 | } 36 | 37 | public void setId(String id) { 38 | this.id = id; 39 | } 40 | 41 | public String getUser_id() { 42 | return user_id; 43 | } 44 | 45 | public void setUser_id(String user_id) { 46 | this.user_id = user_id; 47 | } 48 | 49 | public String getUsername() { 50 | return username; 51 | } 52 | 53 | public void setUsername(String username) { 54 | this.username = username; 55 | } 56 | 57 | 58 | public String getAvatar() { 59 | return avatar; 60 | } 61 | 62 | public void setAvatar(String avatar) { 63 | this.avatar = avatar; 64 | } 65 | 66 | public String getSign() { 67 | return sign; 68 | } 69 | 70 | public void setSign(String sign) { 71 | this.sign = sign; 72 | } 73 | 74 | 75 | public String getGroup_id() { 76 | return group_id; 77 | } 78 | 79 | public void setGroup_id(String group_id) { 80 | this.group_id = group_id; 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /src/main/java/com/neo/entity/MessageEntity.java: -------------------------------------------------------------------------------- 1 | package com.neo.entity; 2 | 3 | import com.neo.enums.Chat_type; 4 | import org.springframework.data.annotation.Id; 5 | import org.springframework.data.mongodb.core.mapping.Document; 6 | 7 | /** 8 | * Created by liudong on 2018/6/8. 9 | */ 10 | @Document(collection = "t_message") 11 | public class MessageEntity extends BaseEntity { 12 | 13 | // msg_id: String, //消息id uuid 14 | // timestamp: Number, //发送(服务器)时间 15 | // sendtime: Number, //客户端发送时间 16 | // from_user: String, //发送人 17 | 18 | // to_user: String, //要发送的人 19 | // chat_type: String, //聊天的类型 chat(单聊) groupChat (群聊) 20 | // group_id: String, //群聊 房间id (群聊时房间id) 21 | // group_name: String, //群聊 房间id (群聊时房间name) 22 | // ext: String, //扩展 23 | // bodies: String //内容 json 文本 存储 24 | //类型1-->文本类型 { "type":"txt","msg":"hello from test2"} 25 | //类型2-->图片类型 { "type":"img","imgUrl":"hello from test2","imageName","图片名称" //消息内容} 26 | 27 | @Id 28 | private String msg_id; //消息id uuid 29 | private long timestamp; //发送(服务器)时间 30 | private String sendtime; //客户端发送时间 31 | private String from_user; // 32 | private String from_user_id; // 33 | private String to_user; // 34 | private String to_user_id; 35 | private Chat_type chat_type; // 36 | private String group_id; // 37 | private String group_name; // 38 | private String ext; // 扩展数据 39 | private Bodies bodies; // 40 | 41 | public String getMsg_id() { 42 | return msg_id; 43 | } 44 | 45 | public void setMsg_id(String msg_id) { 46 | this.msg_id = msg_id; 47 | } 48 | 49 | public long getTimestamp() { 50 | return timestamp; 51 | } 52 | 53 | public void setTimestamp(long timestamp) { 54 | this.timestamp = timestamp; 55 | } 56 | 57 | public String getSendtime() { 58 | return sendtime; 59 | } 60 | 61 | public void setSendtime(String sendtime) { 62 | this.sendtime = sendtime; 63 | } 64 | 65 | public String getFrom_user() { 66 | return from_user; 67 | } 68 | 69 | public void setFrom_user(String from_user) { 70 | this.from_user = from_user; 71 | } 72 | 73 | public String getTo_user() { 74 | return to_user; 75 | } 76 | 77 | public void setTo_user(String to_user) { 78 | this.to_user = to_user; 79 | } 80 | 81 | 82 | public String getGroup_id() { 83 | return group_id; 84 | } 85 | 86 | public void setGroup_id(String group_id) { 87 | this.group_id = group_id; 88 | } 89 | 90 | public String getGroup_name() { 91 | return group_name; 92 | } 93 | 94 | public void setGroup_name(String group_name) { 95 | this.group_name = group_name; 96 | } 97 | 98 | public String getExt() { 99 | return ext; 100 | } 101 | 102 | public void setExt(String ext) { 103 | this.ext = ext; 104 | } 105 | 106 | public Chat_type getChat_type() { 107 | return chat_type; 108 | } 109 | 110 | public void setChat_type(Chat_type chat_type) { 111 | this.chat_type = chat_type; 112 | } 113 | 114 | public Bodies getBodies() { 115 | return bodies; 116 | } 117 | 118 | public void setBodies(Bodies bodies) { 119 | this.bodies = bodies; 120 | } 121 | 122 | public String getFrom_user_id() { 123 | return from_user_id; 124 | } 125 | 126 | public void setFrom_user_id(String from_user_id) { 127 | this.from_user_id = from_user_id; 128 | } 129 | 130 | public String getTo_user_id() { 131 | return to_user_id; 132 | } 133 | 134 | public void setTo_user_id(String to_user_id) { 135 | this.to_user_id = to_user_id; 136 | } 137 | 138 | @Override 139 | public String toString() { 140 | return "MessageEntity{" + 141 | "msg_id='" + msg_id + '\'' + 142 | ", timestamp=" + timestamp + 143 | ", sendtime='" + sendtime + '\'' + 144 | ", from_user='" + from_user + '\'' + 145 | ", to_user='" + to_user + '\'' + 146 | ", chat_type=" + chat_type + 147 | ", group_id='" + group_id + '\'' + 148 | ", group_name='" + group_name + '\'' + 149 | ", ext='" + ext + '\'' + 150 | ", bodies=" + bodies + 151 | '}'; 152 | } 153 | } 154 | -------------------------------------------------------------------------------- /src/main/java/com/neo/entity/Result.java: -------------------------------------------------------------------------------- 1 | package com.neo.entity; 2 | 3 | import com.neo.enums.EResultType; 4 | 5 | /** 6 | * Created by liudong on 2018/6/11. 7 | */ 8 | public class Result { 9 | /*返回码*/ 10 | private Integer code; 11 | /*返回信息提示*/ 12 | private String msg; 13 | /*返回的数据*/ 14 | private T data; 15 | 16 | public Result() { 17 | } 18 | 19 | public Result(Integer code, String msg) { 20 | this.code = code; 21 | this.msg = msg; 22 | } 23 | 24 | public Result(Integer code, String msg, T data) { 25 | this.code = code; 26 | this.msg = msg; 27 | this.data = data; 28 | } 29 | 30 | public Result(EResultType type,T data) { 31 | this.code = type.getCode(); 32 | this.msg = type.getMsg(); 33 | this.data = data; 34 | } 35 | 36 | public Result(EResultType type) { 37 | this.code = type.getCode(); 38 | this.msg = type.getMsg(); 39 | } 40 | 41 | public Integer getCode() { 42 | return code; 43 | } 44 | 45 | public void setCode(Integer code) { 46 | this.code = code; 47 | } 48 | 49 | public String getMsg() { 50 | return msg; 51 | } 52 | 53 | public void setMsg(String msg) { 54 | this.msg = msg; 55 | } 56 | 57 | public T getData() { 58 | return data; 59 | } 60 | 61 | public void setData(T data) { 62 | this.data = data; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/com/neo/entity/UserEntity.java: -------------------------------------------------------------------------------- 1 | package com.neo.entity; 2 | 3 | import org.springframework.data.annotation.Id; 4 | import org.springframework.data.mongodb.core.mapping.Document; 5 | 6 | /** 7 | * Created by lh on 2018/6/5. 8 | */ 9 | @Document(collection = "t_user") 10 | public class UserEntity extends BaseEntity { 11 | 12 | // userId: Number, 13 | // name: String, 14 | // headImageUrl: String, //头像 15 | // nickname: String, //昵称 16 | // password: String, 17 | // auth_token: String, 18 | // auth_date: Number 19 | 20 | @Id 21 | private String id; 22 | private String username; 23 | private String password; 24 | private String auth_token; //token 25 | private String auth_date; //过期时间 26 | private String sign; //我的签名 27 | private String avatar; //头像 28 | private String nickname; //昵称 29 | private int sex; //性别 0 男,1,女 2,其他 30 | 31 | 32 | public int getSex() { 33 | return sex; 34 | } 35 | 36 | public void setSex(int sex) { 37 | this.sex = sex; 38 | } 39 | 40 | public String getId() { 41 | return id; 42 | } 43 | 44 | public void setId(String id) { 45 | this.id = id; 46 | } 47 | 48 | public String getUsername() { 49 | return username; 50 | } 51 | 52 | public void setUsername(String username) { 53 | this.username = username; 54 | } 55 | 56 | public String getPassword() { 57 | return password; 58 | } 59 | 60 | public void setPassword(String password) { 61 | this.password = password; 62 | } 63 | 64 | public String getAuth_token() { 65 | return auth_token; 66 | } 67 | 68 | public void setAuth_token(String auth_token) { 69 | this.auth_token = auth_token; 70 | } 71 | 72 | public String getAuth_date() { 73 | return auth_date; 74 | } 75 | 76 | public void setAuth_date(String auth_date) { 77 | this.auth_date = auth_date; 78 | } 79 | 80 | 81 | public String getSign() { 82 | return sign; 83 | } 84 | 85 | public void setSign(String sign) { 86 | this.sign = sign; 87 | } 88 | 89 | public String getAvatar() { 90 | return avatar; 91 | } 92 | 93 | public void setAvatar(String avatar) { 94 | this.avatar = avatar; 95 | } 96 | 97 | public String getNickname() { 98 | return nickname; 99 | } 100 | 101 | public void setNickname(String nickname) { 102 | this.nickname = nickname; 103 | } 104 | 105 | @Override 106 | public String toString() { 107 | return "UserEntity{" + 108 | "id='" + id + '\'' + 109 | ", username='" + username + '\'' + 110 | ", password='" + password + '\'' + 111 | ", auth_token='" + auth_token + '\'' + 112 | ", auth_date='" + auth_date + '\'' + 113 | ", sign='" + sign + '\'' + 114 | ", avatar='" + avatar + '\'' + 115 | ", nickname='" + nickname + '\'' + 116 | '}'; 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /src/main/java/com/neo/enums/AddMessageType.java: -------------------------------------------------------------------------------- 1 | package com.neo.enums; 2 | 3 | /** 4 | * Created by liudong on 2018/6/12. 5 | */ 6 | public enum AddMessageType { 7 | // 0未处理,1同意,2拒绝 8 | Untreated, //未处理 9 | Agree, //同意 10 | Reject, //拒绝 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/com/neo/enums/Body_type.java: -------------------------------------------------------------------------------- 1 | package com.neo.enums; 2 | 3 | /** 4 | * Created by liudong on 2018/6/12. 5 | */ 6 | public enum Body_type { 7 | txt, 8 | img, 9 | audio, 10 | loc, 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/com/neo/enums/Chat_type.java: -------------------------------------------------------------------------------- 1 | package com.neo.enums; 2 | 3 | /** 4 | * Created by liudong on 2018/6/12. 5 | */ 6 | public enum Chat_type { 7 | chat, //单聊 8 | groupChat, //群聊 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/com/neo/enums/EResultType.java: -------------------------------------------------------------------------------- 1 | package com.neo.enums; 2 | 3 | /** 4 | * Created by liudong on 2018/6/11. 5 | */ 6 | public enum EResultType { 7 | 8 | /** 9 | * 访问成功返回 10 | */ 11 | SUCCESS(1, "success"), 12 | 13 | /** 14 | * 用户名或者密码错误 15 | */ 16 | PASSWORK_ERROR(-1, "用户名或者密码错误"), 17 | 18 | /** 19 | * 数据不存在返回 20 | */ 21 | NOT_FOUND(-1, "notFound [数据不存在 或者 数据为空]"), 22 | 23 | /** 24 | * 异常返回 25 | */ 26 | ERROR(-1, "error [未知异常]"), 27 | 28 | /** 29 | * 参数有异常返回 30 | */ 31 | GLOABLE_ERROR(-1, "全局异常"), 32 | 33 | /** 34 | * 参数有异常返回 35 | */ 36 | PARAMETER_ERROR(-1, "parameter error [参数异常:参数为空或者参数类型不符]"); 37 | 38 | private Integer code; 39 | 40 | private String msg; 41 | 42 | private EResultType(Integer code, String msg) { 43 | this.code = code; 44 | this.msg = msg; 45 | } 46 | 47 | public Integer getCode() { 48 | return code; 49 | } 50 | 51 | public String getMsg() { 52 | return msg; 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/com/neo/exception/GlobalExceptionHandler.java: -------------------------------------------------------------------------------- 1 | package com.neo.exception; 2 | 3 | import com.alibaba.fastjson.JSON; 4 | import com.neo.entity.Result; 5 | import org.apache.log4j.LogManager; 6 | import org.apache.log4j.Logger; 7 | import org.springframework.web.bind.annotation.ControllerAdvice; 8 | import org.springframework.web.bind.annotation.ExceptionHandler; 9 | import org.springframework.web.bind.annotation.ResponseBody; 10 | 11 | import javax.servlet.http.HttpServletRequest; 12 | import java.util.Enumeration; 13 | 14 | /** 15 | * Created by liudong on 2018/6/11. 16 | */ 17 | @ControllerAdvice 18 | public class GlobalExceptionHandler { 19 | 20 | private static Logger logger = LogManager.getLogger(GlobalExceptionHandler.class.getName()); 21 | 22 | @ExceptionHandler(value = Exception.class) 23 | @ResponseBody 24 | public String errorHandler(HttpServletRequest req, Exception e) throws Exception { 25 | log(e, req); 26 | return JSON.toJSONString(new Result(-1, e.getMessage())); 27 | } 28 | 29 | @ExceptionHandler(value = ParameterException.class) 30 | @ResponseBody 31 | public String parameterHandler(Exception e) throws Exception { 32 | return JSON.toJSONString(new Result(-1, e.getMessage())); 33 | } 34 | 35 | //重复 36 | @ExceptionHandler(value = RepeatException.class) 37 | @ResponseBody 38 | public String repeatHandler(Exception e) throws Exception { 39 | return JSON.toJSONString(new Result(-1, e.getMessage())); 40 | } 41 | 42 | private void log(Exception ex, HttpServletRequest request) { 43 | logger.error("有异常啦:============》" + ex.getMessage()); 44 | logger.error("************************异常开始*******************************"); 45 | // if(getUser() != null) 46 | // logger.error("当前用户id是" + getUser().getUserId()); 47 | logger.error(ex); 48 | logger.error("请求地址:" + request.getRequestURL()); 49 | Enumeration enumeration = request.getParameterNames(); 50 | logger.error("请求参数:"); 51 | while (enumeration.hasMoreElements()) { 52 | String name = enumeration.nextElement().toString(); 53 | logger.error(name + "---" + request.getParameter(name)); 54 | } 55 | 56 | StackTraceElement[] error = ex.getStackTrace(); 57 | for (StackTraceElement stackTraceElement : error) { 58 | logger.error(stackTraceElement.toString()); 59 | } 60 | logger.error("************************异常结束*******************************"); 61 | } 62 | 63 | } -------------------------------------------------------------------------------- /src/main/java/com/neo/exception/ParameterException.java: -------------------------------------------------------------------------------- 1 | package com.neo.exception; 2 | 3 | /** 4 | * Created by liudong on 2018/6/11. 5 | */ 6 | public class ParameterException extends RuntimeException{ 7 | 8 | //自定义错误码 9 | private Integer code; 10 | //自定义构造器,只保留一个,让其必须输入错误码及内容 11 | public ParameterException(int code,String msg) { 12 | super(msg); 13 | this.code = code; 14 | } 15 | 16 | public Integer getCode() { 17 | return code; 18 | } 19 | 20 | public void setCode(Integer code) { 21 | this.code = code; 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/neo/exception/RepeatException.java: -------------------------------------------------------------------------------- 1 | package com.neo.exception; 2 | 3 | /** 4 | * Created by liudong on 2018/6/11. 5 | */ 6 | //重复数据异常 7 | public class RepeatException extends RuntimeException{ 8 | 9 | //自定义错误码 10 | private Integer code; 11 | //自定义构造器,只保留一个,让其必须输入错误码及内容 12 | public RepeatException(int code, String msg) { 13 | super(msg); 14 | this.code = code; 15 | } 16 | 17 | public Integer getCode() { 18 | return code; 19 | } 20 | 21 | public void setCode(Integer code) { 22 | this.code = code; 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/neo/listener/SessionListener.java: -------------------------------------------------------------------------------- 1 | package com.neo.listener; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | 6 | import javax.servlet.ServletContext; 7 | import javax.servlet.annotation.WebListener; 8 | import javax.servlet.http.*; 9 | import java.util.HashSet; 10 | 11 | /** 12 | * Created by liudong on 2018/6/15. 13 | */ 14 | // 要实现监听 需要 打开 WebAppConfig @EnableWebMvc 注解 15 | @WebListener 16 | public class SessionListener implements HttpSessionListener, HttpSessionAttributeListener { 17 | public static final Logger logger = LoggerFactory.getLogger(SessionListener.class); 18 | 19 | @Override 20 | public void attributeAdded(HttpSessionBindingEvent httpSessionBindingEvent) { 21 | logger.info("--attributeAdded--"); 22 | HttpSession session = httpSessionBindingEvent.getSession(); 23 | logger.info("key----:" + httpSessionBindingEvent.getName()); 24 | logger.info("value---:" + httpSessionBindingEvent.getValue()); 25 | 26 | } 27 | 28 | @Override 29 | public void attributeRemoved(HttpSessionBindingEvent httpSessionBindingEvent) { 30 | logger.info("--attributeRemoved--"); 31 | } 32 | 33 | @Override 34 | public void attributeReplaced(HttpSessionBindingEvent httpSessionBindingEvent) { 35 | logger.info("--attributeReplaced--"); 36 | } 37 | 38 | @Override 39 | public void sessionCreated(HttpSessionEvent event) { 40 | logger.info("---sessionCreated----"); 41 | HttpSession session = event.getSession(); 42 | ServletContext application = session.getServletContext(); 43 | // 在application范围由一个HashSet集保存所有的session 44 | HashSet sessions = (HashSet) application.getAttribute("sessions"); 45 | if (sessions == null) { 46 | sessions = new HashSet(); 47 | application.setAttribute("sessions", sessions); 48 | } 49 | // 新创建的session均添加到HashSet集中 50 | sessions.add(session); 51 | // 可以在别处从application范围中取出sessions集合 52 | // 然后使用sessions.size()获取当前活动的session数,即为“在线人数” 53 | } 54 | 55 | @Override 56 | public void sessionDestroyed(HttpSessionEvent event) throws ClassCastException { 57 | logger.info("---sessionDestroyed----"); 58 | HttpSession session = event.getSession(); 59 | logger.info("deletedSessionId: " + session.getId()); 60 | System.out.println(session.getCreationTime()); 61 | System.out.println(session.getLastAccessedTime()); 62 | ServletContext application = session.getServletContext(); 63 | HashSet sessions = (HashSet) application.getAttribute("sessions"); 64 | // 销毁的session均从HashSet集中移除 65 | if (sessions != null && sessions.contains(session)) { 66 | sessions.remove(session); 67 | } 68 | } 69 | 70 | } -------------------------------------------------------------------------------- /src/main/java/com/neo/serivce/AddMessageSerivice.java: -------------------------------------------------------------------------------- 1 | package com.neo.serivce; 2 | 3 | import com.alibaba.fastjson.JSONObject; 4 | import com.neo.entity.AddMessage; 5 | import com.neo.entity.BaseEntity; 6 | import com.neo.entity.UserEntity; 7 | 8 | /** 9 | * Created by liudong on 2018/6/8. 10 | */ 11 | 12 | public interface AddMessageSerivice extends BaseSerivice { 13 | 14 | /** 15 | * 添加好友、群组信息请求 16 | * @param msg 17 | */ 18 | void saveAddMessage(AddMessage msg); 19 | 20 | /** 21 | * @description 查询消息盒子信息 22 | */ 23 | JSONObject findAddInfo(String userId); 24 | 25 | 26 | /** 27 | * 拒绝添加群组,或者,好友 28 | * @param messageBoxId 29 | */ 30 | void updateAddMessage(String messageBoxId); 31 | 32 | 33 | /** 34 | * 更新 添加消息数据 35 | * @param entity 36 | * @param messageId 37 | * @return 38 | */ 39 | void updateAddMessage(UserEntity entity,String groupId,String messageId); 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/neo/serivce/BaseSerivice.java: -------------------------------------------------------------------------------- 1 | package com.neo.serivce; 2 | 3 | import com.neo.entity.BaseEntity; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * Created by liudong on 2018/6/8. 9 | */ 10 | 11 | public interface BaseSerivice { 12 | /** 13 | * 根据Id查询实体 14 | */ 15 | T getEntityById(String id); 16 | 17 | /** 18 | * 新增实体 19 | */ 20 | void saveEntity(final T entity); 21 | /** 22 | * 更新实体 23 | */ 24 | T updateEntityById(String id, T entity); 25 | /** 26 | * 根据Id删除实体 27 | */ 28 | int deleteEntityById(String id); 29 | 30 | /** 31 | * 查询所有 32 | */ 33 | List selectAll(); 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/neo/serivce/ChatSerivice.java: -------------------------------------------------------------------------------- 1 | package com.neo.serivce; 2 | 3 | import com.neo.entity.BaseEntity; 4 | import com.neo.entity.MessageEntity; 5 | import com.neo.entity.UserEntity; 6 | 7 | /** 8 | * Created by liudong on 2018/6/8. 9 | */ 10 | 11 | public interface ChatSerivice extends BaseSerivice { 12 | 13 | void saveMessageData(T entity); 14 | 15 | void sendApnData(); 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/neo/serivce/GroupSerivice.java: -------------------------------------------------------------------------------- 1 | package com.neo.serivce; 2 | 3 | import com.neo.entity.BaseEntity; 4 | import com.neo.entity.GroupEntity; 5 | import com.neo.entity.GroupUser; 6 | import com.neo.entity.UserEntity; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * Created by liudong on 2018/6/8. 12 | */ 13 | 14 | public interface GroupSerivice extends BaseSerivice { 15 | 16 | 17 | /** 18 | * 创建群组 19 | * 20 | * @param name 21 | * @return 22 | */ 23 | GroupEntity creatGroup(String name, String avatar, UserEntity userEntity); 24 | 25 | 26 | /** 27 | * 根据 名字 查询对应的群 28 | * 29 | * @return 30 | */ 31 | List findGroupsByGroupName(String groupName); 32 | 33 | 34 | /** 35 | * 获取 我所在的 所有的群 36 | * 37 | * @return 38 | */ 39 | List findMyGroupsByUserId(String id); 40 | 41 | 42 | /** 43 | * 加入群组 44 | * @param entity 45 | * @param groupId 46 | * @return 47 | */ 48 | GroupUser joinGroup(UserEntity entity, String groupId); 49 | 50 | 51 | /** 52 | * 获取 群下面的所有成员 53 | * 54 | * @return 55 | */ 56 | List findUsersByGroupId(String group_id); 57 | 58 | 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/com/neo/serivce/UserSerivice.java: -------------------------------------------------------------------------------- 1 | package com.neo.serivce; 2 | 3 | import com.neo.entity.BaseEntity; 4 | import com.neo.entity.UserEntity; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * Created by liudong on 2018/6/8. 10 | */ 11 | 12 | public interface UserSerivice extends BaseSerivice { 13 | 14 | 15 | /** 16 | * 根据名称查具体的人 17 | * 18 | * @param name 19 | * @return 20 | */ 21 | UserEntity findUserByUserName(String name); 22 | 23 | /** 24 | * 使用 token 查询 实体 25 | * 26 | * @param access_token 27 | * @return 28 | */ 29 | UserEntity findUserByToken(String access_token); 30 | 31 | /** 32 | * 注册 33 | * 34 | * @param name 35 | * @param password 36 | * @return 37 | */ 38 | UserEntity register(String name, String password, String avatar); 39 | 40 | 41 | /** 42 | * 根据用户名查询 对应的人员 43 | * 44 | * @return 45 | */ 46 | List findUsersByName(String page, String name); 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/com/neo/serivce/impl/AddMessageSeriviceImpl.java: -------------------------------------------------------------------------------- 1 | package com.neo.serivce.impl; 2 | 3 | import com.alibaba.fastjson.JSONObject; 4 | import com.neo.dao.AddMessageDao; 5 | import com.neo.dao.GroupDao; 6 | import com.neo.dao.UserDao; 7 | import com.neo.entity.*; 8 | import com.neo.enums.AddMessageType; 9 | import com.neo.exception.RepeatException; 10 | import com.neo.serivce.AddMessageSerivice; 11 | import com.neo.serivce.GroupSerivice; 12 | import com.neo.utils.DateUtils; 13 | import org.springframework.stereotype.Component; 14 | import org.springframework.transaction.annotation.Transactional; 15 | 16 | import javax.annotation.Resource; 17 | import java.util.ArrayList; 18 | import java.util.List; 19 | 20 | /** 21 | * Created by liudong on 2018/6/8. 22 | */ 23 | @Component 24 | public class AddMessageSeriviceImpl extends BaseSeriviceImpl implements AddMessageSerivice { 25 | 26 | @Resource 27 | UserDao userDao; 28 | 29 | @Resource 30 | AddMessageDao addMessageDao; 31 | 32 | @Resource 33 | GroupDao groupDao; 34 | 35 | @Resource 36 | GroupSerivice groupSerivice; 37 | 38 | /** 39 | * 添加好友、群组信息请求 40 | * 41 | * @param msg 42 | */ 43 | @Override 44 | public void saveAddMessage(AddMessage msg) { 45 | msg.setTime(DateUtils.getDataTimeYMDHMS()); 46 | userDao.saveEntity(msg); 47 | } 48 | 49 | /** 50 | * @description 查询消息盒子信息 51 | */ 52 | @Override 53 | public JSONObject findAddInfo(String userId) { 54 | 55 | JSONObject obj = new JSONObject(); 56 | 57 | List list = addMessageDao.findAddInfo(userId); 58 | 59 | List infos = new ArrayList<>(); 60 | for (AddMessage message : list) { 61 | AddInfo info = new AddInfo(); 62 | if (message.getType().equals("group")) { 63 | GroupEntity entity = (GroupEntity) groupDao.findEntityById(message.getGroupId()); 64 | info.setContent("申请加入 '" + entity.getGroupname() + "' 群聊!"); 65 | } else { 66 | info.setContent("申请添加你为好友"); 67 | } 68 | 69 | info.setId(message.getId()); 70 | info.setType(message.getType()); 71 | info.setFrom(message.getFromUid()); 72 | info.setUid(message.getToUid()); 73 | info.setRead(message.getMsgResult().toString()); 74 | UserEntity userEntity = getEntityById(message.getFromUid()); 75 | userEntity.setPassword(""); 76 | userEntity.setAuth_token(""); 77 | info.setUser(userEntity); 78 | info.setFrom_group(message.getGroupId()); 79 | info.setTime(message.getTime()); 80 | info.setRemark(message.getRemark()); 81 | infos.add(info); 82 | } 83 | 84 | obj.put("list", infos); 85 | obj.put("pages", 1); 86 | return obj; 87 | } 88 | 89 | 90 | /** 91 | * 更新 添加消息数据 92 | * 93 | * @param entity 94 | * @param messageId 95 | * @return 96 | */ 97 | @Override 98 | @Transactional 99 | public void updateAddMessage(UserEntity entity, String groupId, String messageId) { 100 | 101 | String userId = entity.getId(); //申请加群的人 102 | //查询群下面的所有人 如果有当前群包含了 自己则说明是重复加群 103 | List groupUsers = groupSerivice.findUsersByGroupId(groupId); 104 | for (GroupUser user : groupUsers) { 105 | if (user.getUser_id().equals(userId)) { 106 | throw new RepeatException(-1, "不能重复加群"); 107 | } 108 | } 109 | 110 | AddMessage addMessage = (AddMessage) addMessageDao.findEntityById(messageId); 111 | addMessage.setMsgResult(AddMessageType.Agree); 112 | addMessageDao.updateEntityById(messageId, addMessage); 113 | 114 | groupSerivice.joinGroup(entity, groupId); 115 | } 116 | 117 | /** 118 | * 拒绝添加群组,或者,好友 119 | * 120 | * @param messageBoxId 121 | */ 122 | @Override 123 | public void updateAddMessage(String messageBoxId) { 124 | AddMessage addMessage = (AddMessage) addMessageDao.findEntityById(messageBoxId); 125 | addMessage.setMsgResult(AddMessageType.Reject); 126 | addMessageDao.saveEntity(addMessage); //更新数据 127 | } 128 | 129 | 130 | } 131 | -------------------------------------------------------------------------------- /src/main/java/com/neo/serivce/impl/BaseSeriviceImpl.java: -------------------------------------------------------------------------------- 1 | package com.neo.serivce.impl; 2 | 3 | import com.neo.dao.BaseDao; 4 | import com.neo.entity.BaseEntity; 5 | import com.neo.serivce.BaseSerivice; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.beans.factory.annotation.Qualifier; 8 | 9 | import java.lang.reflect.ParameterizedType; 10 | import java.util.List; 11 | 12 | /** 13 | * Created by liudong on 2018/6/8. 14 | */ 15 | public class BaseSeriviceImpl implements BaseSerivice { 16 | 17 | @Qualifier("userDaoImpl") 18 | @Autowired 19 | BaseDao baseDao; 20 | 21 | protected Class entityClass; 22 | 23 | public BaseSeriviceImpl() { 24 | // 使用反射技术得到T的真实类型 25 | ParameterizedType pt = (ParameterizedType) this.getClass().getGenericSuperclass(); // 获取当前new的对象的 泛型的父类 类型 26 | this.entityClass = (Class) pt.getActualTypeArguments()[0]; // 获取第一个类型参数的真实类型 27 | } 28 | 29 | @Override 30 | public T getEntityById(String id) { 31 | return baseDao.findEntityById(id); 32 | } 33 | 34 | @Override 35 | public void saveEntity(T entity) { 36 | baseDao.saveEntity(entity); 37 | } 38 | 39 | @Override 40 | public T updateEntityById(String id, T entity) { 41 | return baseDao.updateEntityById(id, entity); 42 | } 43 | 44 | @Override 45 | public int deleteEntityById(String id) { 46 | return baseDao.deleteEntityById(id); 47 | } 48 | 49 | @Override 50 | public List selectAll() { 51 | return baseDao.selectAll(); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/com/neo/serivce/impl/ChatSeriviceImpl.java: -------------------------------------------------------------------------------- 1 | package com.neo.serivce.impl; 2 | 3 | import com.neo.dao.UserDao; 4 | import com.neo.entity.BaseEntity; 5 | import com.neo.entity.MessageEntity; 6 | import com.neo.entity.UserEntity; 7 | import com.neo.serivce.ChatSerivice; 8 | import com.neo.serivce.UserSerivice; 9 | import com.turo.pushy.apns.ApnsClient; 10 | import com.turo.pushy.apns.ApnsClientBuilder; 11 | import com.turo.pushy.apns.PushNotificationResponse; 12 | import com.turo.pushy.apns.auth.ApnsSigningKey; 13 | import com.turo.pushy.apns.util.ApnsPayloadBuilder; 14 | import com.turo.pushy.apns.util.SimpleApnsPushNotification; 15 | import io.netty.util.concurrent.Future; 16 | import io.netty.util.concurrent.GenericFutureListener; 17 | import org.springframework.core.io.ClassPathResource; 18 | import org.springframework.stereotype.Component; 19 | 20 | import javax.annotation.Resource; 21 | import java.io.IOException; 22 | import java.security.InvalidKeyException; 23 | import java.security.NoSuchAlgorithmException; 24 | import java.text.SimpleDateFormat; 25 | import java.util.Calendar; 26 | import java.util.Date; 27 | import java.util.UUID; 28 | 29 | /** 30 | * Created by liudong on 2018/6/8. 31 | */ 32 | @Component 33 | public class ChatSeriviceImpl extends BaseSeriviceImpl implements ChatSerivice { 34 | 35 | @Override 36 | public void saveMessageData(MessageEntity entity) { 37 | long time = new Date().getTime(); 38 | entity.setTimestamp(time); 39 | saveEntity(entity); 40 | } 41 | 42 | @Override 43 | public void sendApnData() { 44 | final ApnsClient apnsClient; 45 | 46 | try { 47 | apnsClient = new ApnsClientBuilder() 48 | .setApnsServer(ApnsClientBuilder.PRODUCTION_APNS_HOST) 49 | .setSigningKey(ApnsSigningKey.loadFromPkcs8File(new ClassPathResource("AuthKey.p8").getFile(), 50 | "5HBP8N48W6", "SXZZL6BZ83")) 51 | .build(); 52 | final ApnsPayloadBuilder payloadBuilder = new ApnsPayloadBuilder(); 53 | payloadBuilder.setAlertBody("Example!"); 54 | payloadBuilder.setBadgeNumber(1); 55 | payloadBuilder.setAlertBody("sdfsdfsfsddf0"); 56 | final String payload = payloadBuilder.buildWithDefaultMaximumLength(); 57 | final String token = "431b9699945a0fa11e692f9a281e3be5deec70ea61c8530aef7efbcc098b7e71"; 58 | 59 | SimpleApnsPushNotification pushNotification = new SimpleApnsPushNotification(token, "com.example.myApp", payload); 60 | final Future sendNotificationFuture = apnsClient.sendNotification(pushNotification); 61 | 62 | sendNotificationFuture.addListener(new GenericFutureListener>() { 63 | 64 | @Override 65 | public void operationComplete(final Future future) throws Exception { 66 | // This will get called when the sever has replied and returns immediately 67 | final PushNotificationResponse response = future.getNow(); 68 | } 69 | }); 70 | } catch (IOException e) { 71 | e.printStackTrace(); 72 | } catch (NoSuchAlgorithmException e) { 73 | e.printStackTrace(); 74 | } catch (InvalidKeyException e) { 75 | e.printStackTrace(); 76 | } 77 | 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /src/main/java/com/neo/serivce/impl/GroupSeriviceImpl.java: -------------------------------------------------------------------------------- 1 | package com.neo.serivce.impl; 2 | 3 | import com.neo.dao.GroupDao; 4 | import com.neo.entity.BaseEntity; 5 | import com.neo.entity.GroupEntity; 6 | import com.neo.entity.GroupUser; 7 | import com.neo.entity.UserEntity; 8 | import com.neo.exception.RepeatException; 9 | import com.neo.serivce.GroupSerivice; 10 | import com.neo.utils.DateUtils; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.stereotype.Component; 13 | import org.springframework.transaction.annotation.Transactional; 14 | 15 | import java.util.List; 16 | 17 | /** 18 | * Created by liudong on 2018/6/8. 19 | */ 20 | @Component 21 | public class GroupSeriviceImpl extends BaseSeriviceImpl implements GroupSerivice { 22 | 23 | @Autowired 24 | GroupDao groupDao; 25 | 26 | 27 | @Transactional 28 | @Override 29 | public GroupEntity creatGroup(String name, String avatar, UserEntity user) { 30 | 31 | //不允许 创建重复的群名字 32 | if (groupDao.findGroupsByGroupName(name).size() > 0) { 33 | throw new RepeatException(-1, "群名称不能重复"); 34 | } 35 | 36 | //创建 群组 37 | GroupEntity entity = new GroupEntity(); 38 | entity.setCreat_date(DateUtils.getDataTimeYMD()); 39 | entity.setGroupname(name); 40 | entity.setUser_id(user.getId()); 41 | entity.setUser_name(user.getUsername()); 42 | entity.setAvatar(avatar); 43 | groupDao.saveEntity(entity); 44 | 45 | //把自己加入群组 46 | joinGroup(user, entity.getId()); 47 | 48 | return entity; 49 | } 50 | 51 | //加入群组 52 | @Override 53 | public GroupUser joinGroup(UserEntity user, String groupId) { 54 | 55 | GroupUser groupUser = new GroupUser(); 56 | groupUser.setGroup_id(groupId); 57 | groupUser.setUser_id(user.getId()); 58 | groupUser.setUsername(user.getUsername()); 59 | groupUser.setAvatar(user.getAvatar()); 60 | groupUser.setSign(user.getSign()); 61 | groupUser.setJoninTime(DateUtils.getDataTimeYMDHMS()); 62 | 63 | groupDao.saveEntity(groupUser); 64 | return groupUser; 65 | } 66 | 67 | 68 | 69 | /** 70 | * 根据群id 获取 群下面的所有成员 71 | * 72 | * @return 73 | */ 74 | @Override 75 | public List findUsersByGroupId(String group_id) { 76 | return groupDao.findUsersByGroupId(group_id); 77 | } 78 | 79 | 80 | /** 81 | * 根据 名字 查询对应的群 82 | * 83 | * @return 84 | */ 85 | @Override 86 | public List findGroupsByGroupName(String groupName) { 87 | return groupDao.findGroupsByGroupName(groupName); 88 | } 89 | 90 | /** 91 | * 获取 我所在的 所有的群 92 | * 93 | * @return 94 | */ 95 | @Override 96 | public List findMyGroupsByUserId(String id) { 97 | return groupDao.findMyGroupsByUserId(id); 98 | } 99 | 100 | 101 | 102 | } 103 | -------------------------------------------------------------------------------- /src/main/java/com/neo/serivce/impl/UserSeriviceImpl.java: -------------------------------------------------------------------------------- 1 | package com.neo.serivce.impl; 2 | 3 | import com.neo.dao.AddMessageDao; 4 | import com.neo.dao.GroupDao; 5 | import com.neo.dao.UserDao; 6 | import com.neo.entity.BaseEntity; 7 | import com.neo.entity.UserEntity; 8 | import com.neo.exception.RepeatException; 9 | import com.neo.serivce.UserSerivice; 10 | import org.springframework.stereotype.Component; 11 | 12 | import javax.annotation.Resource; 13 | import java.text.SimpleDateFormat; 14 | import java.util.Calendar; 15 | import java.util.Date; 16 | import java.util.List; 17 | import java.util.UUID; 18 | 19 | /** 20 | * Created by liudong on 2018/6/8. 21 | */ 22 | @Component 23 | public class UserSeriviceImpl extends BaseSeriviceImpl implements UserSerivice { 24 | 25 | @Resource 26 | UserDao userDao; 27 | 28 | @Resource 29 | GroupDao groupDao; 30 | 31 | 32 | @Resource 33 | AddMessageDao addMessageDao; 34 | 35 | // Query.query(Criteria.where("classObj.$id") 36 | // .is(new ObjectId("57fa4b99d4c68bb7d044d616"))), Student.class) 37 | 38 | 39 | @Override 40 | public UserEntity findUserByUserName(String name) { 41 | return userDao.findUserByUserName(name); 42 | } 43 | 44 | @Override 45 | public UserEntity findUserByToken(String access_token) { 46 | return userDao.findUserByToken(access_token); 47 | } 48 | 49 | /** 50 | * 注册 51 | * 52 | * @param name 53 | * @param password 54 | * @return 55 | */ 56 | @Override 57 | public UserEntity register(String name, String password, String avatar) { 58 | 59 | //用户名必须唯一 60 | if (userDao.findUserByUserName(name) != null) { 61 | throw new RepeatException(-1, "用户名不能重复"); 62 | } 63 | 64 | //获取当前日期 65 | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); 66 | Date today = new Date(); 67 | //获取三十天后日期 68 | Calendar theCa = Calendar.getInstance(); 69 | theCa.setTime(today); 70 | theCa.add(theCa.DATE, 30); 71 | Date start = theCa.getTime(); 72 | String startDate = sdf.format(start);//三十天之后日期 73 | 74 | UserEntity user = new UserEntity(); 75 | user.setAuth_token(UUID.randomUUID().toString()); 76 | user.setAuth_date(startDate); 77 | user.setUsername(name); 78 | user.setPassword(password); 79 | user.setAvatar(avatar); 80 | user.setSign("一路有你"); 81 | userDao.saveEntity(user); 82 | return user; 83 | } 84 | 85 | /** 86 | * 根据用户名查询 对应的人员 87 | * 88 | * @return 89 | */ 90 | @Override 91 | public List findUsersByName(String page, String name) { 92 | return userDao.findUsersByName(page,name); 93 | } 94 | 95 | 96 | } 97 | -------------------------------------------------------------------------------- /src/main/java/com/neo/socketio/ServerRunner.java: -------------------------------------------------------------------------------- 1 | package com.neo.socketio; 2 | 3 | import com.corundumstudio.socketio.SocketIOServer; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.boot.CommandLineRunner; 6 | import org.springframework.stereotype.Component; 7 | 8 | /** 9 | * Created by liudong on 2018/6/13. 10 | */ 11 | @Component 12 | public class ServerRunner implements CommandLineRunner { 13 | 14 | private final SocketIOServer server; 15 | 16 | @Autowired 17 | public ServerRunner(SocketIOServer server) { 18 | this.server = server; 19 | } 20 | 21 | @Override 22 | public void run(String... args) throws Exception { 23 | server.start(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/neo/utils/DateUtils.java: -------------------------------------------------------------------------------- 1 | package com.neo.utils; 2 | 3 | import java.text.SimpleDateFormat; 4 | import java.util.Date; 5 | 6 | /** 7 | * Created by liudong on 2018/6/20. 8 | */ 9 | public class DateUtils { 10 | 11 | /** 12 | * 返回当前系统时间 13 | */ 14 | public static String getDataTime(String format) { 15 | SimpleDateFormat df = new SimpleDateFormat(format); 16 | return df.format(new Date()); 17 | } 18 | 19 | /** 20 | * 返回当前系统时间 21 | */ 22 | public static String getDataTimeYMDHMSS() { 23 | return getDataTime("yyyy-MM-dd HH:mm:ss:sss"); 24 | } 25 | 26 | /** 27 | * 返回当前系统时间 28 | */ 29 | public static String getDataTimeYMDHMS() { 30 | return getDataTime("yyyy-MM-dd HH:mm:ss"); 31 | } 32 | 33 | /** 34 | * 返回当前系统时间 35 | */ 36 | public static String getDataTimeYMD() { 37 | return getDataTime("yyyy-MM-dd"); 38 | } 39 | 40 | /** 41 | * 返回当前系统时间 42 | */ 43 | public static String getDataTime() { 44 | return getDataTime("HH:mm"); 45 | } 46 | 47 | 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/com/neo/utils/SessionUtil.java: -------------------------------------------------------------------------------- 1 | package com.neo.utils; 2 | 3 | import com.corundumstudio.socketio.SocketIOClient; 4 | 5 | import java.util.Map; 6 | import java.util.concurrent.ConcurrentHashMap; 7 | 8 | public class SessionUtil { 9 | 10 | //保存所有的 user :socket 连接 11 | public static Map userId_socket_Map = new ConcurrentHashMap<>(); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/main/resources/AuthKey.p8: -------------------------------------------------------------------------------- 1 | -----BEGIN PRIVATE KEY----- 2 | MIGTAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBHkwdwIBAQQgsz9/O3BAwxCRHnp57ChLye/C5DJinnYnY+m8yiKDvWugCgYIKoZIzj0DAQehRANCAARFV61TSXPCxcUKXNU5so8Njrhndav/xuCmSQxfJsk5h0RP+KM9bdswtgc/jxEnI2Qa80KVL+ZVI7ZscauA9HH/ 3 | -----END PRIVATE KEY----- -------------------------------------------------------------------------------- /src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=spirng-chat 2 | spring.data.mongodb.uri=mongodb://192.168.0.33:27017/springchat 3 | server.port=8080 4 | # IM info 5 | im.server.host=192.168.0.33 6 | im.server.port=9006 7 | #解决乱码问题 8 | spring.http.encoding.force=true 9 | spring.http.encoding.charset=UTF-8 10 | spring.http.encoding.enabled=true 11 | server.tomcat.uri-encoding=UTF-8 12 | #出现错误时, 直接抛出异常 13 | spring.mvc.throw-exception-if-no-handler-found=true 14 | #spring.resources.add-mappings=false 15 | #server.sessionTimeout=10 16 | #favicon.ico放置在src/main/resources/static下 17 | spring.mvc.favicon.enabled=false 18 | # 文件上传配置 19 | spring.http.multipart.max-file-size=15MB 20 | spring.http.multipart.max-request-size=15MB 21 | web.upload-path=/Users/liudong/Downloads/111111111/ 22 | spring.mvc.static-path-pattern=/static/** 23 | spring.resources.static-locations=classpath:/static/,file:${web.upload-path} 24 | 25 | -------------------------------------------------------------------------------- /src/main/resources/static/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/favicon.ico -------------------------------------------------------------------------------- /src/main/resources/static/html/chatlog.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 聊天记录 9 | 10 | 11 | 16 | 17 | 18 | 19 |
20 |
    21 |
    22 | 23 |
    24 | 25 | 26 | 39 | 40 | 44 | 45 | 46 | 108 | 109 | 110 | -------------------------------------------------------------------------------- /src/main/resources/static/html/creategroup.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 创建群组 6 | 7 | 8 | 9 | 10 | 13 | 14 | 15 |
    16 |
    17 | 18 |
    19 | 20 |
    21 |
    22 | 23 |
    24 |
    25 | 26 |
    27 | 28 | 29 | 30 | 31 |
    32 |
    33 |
    34 | 35 |
    36 | 注:上传的图片不能够超过500kb 37 |
    38 |
    39 | 40 |
    41 |
    42 | 43 | 69 | -------------------------------------------------------------------------------- /src/main/resources/static/html/friend.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 好友信息 6 | 7 | 8 | 9 | 10 | 11 |
    12 |
    13 |
    14 |
    15 | 16 |
    17 | 18 |
    19 |
    20 | 21 |
    22 | 23 |
    24 | 25 |
    26 | 27 |
    28 | 29 |
    30 |
    31 |
    32 | 33 |
    34 | 35 |
    36 |
    37 |
    38 | 39 |
    40 | 42 |
    43 |
    44 |
    45 |
    46 |
    47 | 48 | 75 | -------------------------------------------------------------------------------- /src/main/resources/static/html/setting.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 设置 7 | 8 | 9 | 12 | 13 | 14 |
    15 |
      16 |
    • 分组管理
    • 17 |
    • 群组管理
    • 18 |
    19 |
    20 |
    内容1
    21 |
    内容2
    22 |
    23 |
    24 |
    25 |
    26 |
    27 | 28 |
    29 |
    30 |
    31 | 32 | 33 | 43 | 44 | -------------------------------------------------------------------------------- /src/main/resources/static/html/userinfo.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 修改用户信息 6 | 7 | 8 | 9 | 10 | 11 | 12 |
    13 |
    14 |
    15 | 个人信息 16 |
    17 |
    18 |
    19 | 20 |
    21 | 22 |
    23 |
    24 | 25 |
    26 | 27 | 28 |
    29 | 30 |
    31 |
    32 | 33 |
    34 | 35 |
    36 | 37 |
    38 |
    39 |
    40 | 41 | 42 | 43 |
    44 |
    45 | 46 |
    47 | 49 |
    50 |
    51 |
    52 |
    53 | 修改密码 54 |
    55 |
    56 | 57 |
    58 | 59 |
    60 |
    61 |
    62 | 63 |
    64 | 65 |
    66 |
    6到16个字符
    67 |
    68 |
    69 | 70 |
    71 | 72 |
    73 |
    6到16个字符
    74 |
    75 |
    76 | 注:密码改后下次登录用 77 |
    78 |
    79 | 80 |
    81 |
    82 |
    83 | 84 | -------------------------------------------------------------------------------- /src/main/resources/static/image/avatar/094fc8fb017743cea89eece53c7f35be.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/image/avatar/094fc8fb017743cea89eece53c7f35be.jpg -------------------------------------------------------------------------------- /src/main/resources/static/image/avatar/2a015308ac4544fea8a2f32ecc599961.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/image/avatar/2a015308ac4544fea8a2f32ecc599961.gif -------------------------------------------------------------------------------- /src/main/resources/static/image/avatar/avatar(1).jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/image/avatar/avatar(1).jpg -------------------------------------------------------------------------------- /src/main/resources/static/image/avatar/avatar(10).jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/image/avatar/avatar(10).jpg -------------------------------------------------------------------------------- /src/main/resources/static/image/avatar/avatar(2).jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/image/avatar/avatar(2).jpg -------------------------------------------------------------------------------- /src/main/resources/static/image/avatar/avatar(3).jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/image/avatar/avatar(3).jpg -------------------------------------------------------------------------------- /src/main/resources/static/image/avatar/avatar(4).jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/image/avatar/avatar(4).jpg -------------------------------------------------------------------------------- /src/main/resources/static/image/avatar/avatar(5).jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/image/avatar/avatar(5).jpg -------------------------------------------------------------------------------- /src/main/resources/static/image/avatar/avatar(6).jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/image/avatar/avatar(6).jpg -------------------------------------------------------------------------------- /src/main/resources/static/image/avatar/avatar(7).jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/image/avatar/avatar(7).jpg -------------------------------------------------------------------------------- /src/main/resources/static/image/avatar/avatar(8).jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/image/avatar/avatar(8).jpg -------------------------------------------------------------------------------- /src/main/resources/static/image/avatar/avatar(9).jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/image/avatar/avatar(9).jpg -------------------------------------------------------------------------------- /src/main/resources/static/image/group/group_1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/image/group/group_1.gif -------------------------------------------------------------------------------- /src/main/resources/static/image/group/group_2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/image/group/group_2.gif -------------------------------------------------------------------------------- /src/main/resources/static/image/group/group_3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/image/group/group_3.jpg -------------------------------------------------------------------------------- /src/main/resources/static/image/group/group_4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/image/group/group_4.jpg -------------------------------------------------------------------------------- /src/main/resources/static/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 即时通讯 6 | 7 | 8 | 81 | 82 | 83 |
    84 |
    85 | 86 |  87 | 88 | 89 | 换屏 90 | 91 |
    92 |
    93 | 94 |  95 | 96 | 97 | 效果 98 | 99 |
    100 |
    101 |
    102 | 103 |
    104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 153 | 154 | 155 | 156 | 157 | -------------------------------------------------------------------------------- /src/main/resources/static/js/user.js: -------------------------------------------------------------------------------- 1 | layui.use(['jquery', 'layer', 'form', 'upload'], function() { 2 | var $ = layui.jquery, 3 | layim = parent.layim, 4 | form = layui.form, 5 | layer = layui.layer; 6 | //屏蔽右键菜单 7 | $(document).bind("contextmenu",function(e){ 8 | return false; 9 | }); 10 | //修改头像 11 | layui.upload({ 12 | url: "/user/updateAvatar" 13 | ,title: '修改头像' 14 | ,ext: 'jpg|png|gif' 15 | ,before: function(input) { 16 | console.log("before upload!"); 17 | } 18 | ,success: function(res, input){ 19 | if(0 == res.code){ 20 | $("#LAY_demo_upload").attr('src', res.data.src); 21 | $("#user_avatar").val(res.data.src); 22 | layer.msg("修改成功!", {time:2000}); 23 | }else{ 24 | layer.msg(res.msg, {time:2000}); 25 | } 26 | } 27 | }); 28 | 29 | //从缓存中初始化数据 30 | $(document).ready(function(){ 31 | var mine = layim.cache().mine; 32 | $("#username").val(mine.username); 33 | $("#email").val(mine.email); 34 | $("#sign").val(mine.sign); 35 | $("#LAY_demo_upload").attr("src", mine.avatar); 36 | if (mine.sex == "0") { 37 | $("input[type='radio']").eq(0).attr("checked",true); 38 | } else { 39 | $("input[type='radio']").eq(1).attr("checked",true); 40 | } 41 | }); 42 | 43 | //提交修改项 44 | $("#btn").click(function(){ 45 | layer.ready(function(){ 46 | var username = $("#username").val(); 47 | var email = $("#email").val(); 48 | var sex = $("input[type='radio']:checked").val(); 49 | if('' == username){ 50 | layer.tips('用户名不能为空', '#username'); 51 | return ; 52 | } 53 | if('' == email){ 54 | layer.tips('邮箱不能为空!', '#email'); 55 | return ; 56 | } 57 | 58 | var oldpwd = $("#oldpwd").val(); //旧密码 59 | var pwd = $("#pwd").val(); 60 | var repwd = $("#repwd").val(); 61 | if('' != oldpwd){ 62 | if('' == pwd){ 63 | layer.tips('新密码不能为空', '#pwd'); 64 | return ; 65 | } 66 | if('' != pwd && '' == repwd){ 67 | layer.tips('重复密码不能为空', '#repwd'); 68 | return ; 69 | } 70 | if(!/^[\S]{6,12}$/.test(oldpwd)){ 71 | layer.tips('密码必须6到12位', '#oldpwd'); 72 | return ; 73 | } 74 | if('' != pwd && '' != repwd && '' == oldpwd){ 75 | layer.tips('必须输入旧密码', '#oldpwd'); 76 | return ; 77 | } 78 | if('' != pwd && '' != repwd && '' != oldpwd && pwd != repwd){ 79 | layer.tips('两次密码不一致', '#pwd'); 80 | return ; 81 | } 82 | if('' != pwd && '' != repwd && '' != oldpwd && pwd == repwd){ 83 | if(!/^[\S]{6,12}$/.test(pwd)){ 84 | layer.tips('密码必须6到12位', '#pwd'); 85 | return ; 86 | } 87 | if(!/^[\S]{6,12}$/.test(repwd)){ 88 | layer.tips('密码必须6到12位', '#repwd'); 89 | return ; 90 | } 91 | } 92 | } 93 | 94 | }); 95 | }); 96 | }); -------------------------------------------------------------------------------- /src/main/resources/static/json/particles0.json: -------------------------------------------------------------------------------- 1 | { 2 | "particles": { 3 | "number": { 4 | "value": 80, 5 | "density": { 6 | "enable": true, 7 | "value_area": 800 8 | } 9 | }, 10 | "color": { 11 | "value": "#ffffff" 12 | }, 13 | "shape": { 14 | "type": "circle", 15 | "stroke": { 16 | "width": 0, 17 | "color": "#000000" 18 | }, 19 | "polygon": { 20 | "nb_sides": 5 21 | }, 22 | "image": { 23 | "src": "img/github.svg", 24 | "width": 100, 25 | "height": 100 26 | } 27 | }, 28 | "opacity": { 29 | "value": 0.5, 30 | "random": false, 31 | "anim": { 32 | "enable": false, 33 | "speed": 1, 34 | "opacity_min": 0.1, 35 | "sync": false 36 | } 37 | }, 38 | "size": { 39 | "value": 5, 40 | "random": true, 41 | "anim": { 42 | "enable": false, 43 | "speed": 40, 44 | "size_min": 0.1, 45 | "sync": false 46 | } 47 | }, 48 | "line_linked": { 49 | "enable": true, 50 | "distance": 150, 51 | "color": "#ffffff", 52 | "opacity": 0.4, 53 | "width": 1 54 | }, 55 | "move": { 56 | "enable": true, 57 | "speed": 6, 58 | "direction": "none", 59 | "random": false, 60 | "straight": false, 61 | "out_mode": "out", 62 | "attract": { 63 | "enable": false, 64 | "rotateX": 600, 65 | "rotateY": 1200 66 | } 67 | } 68 | }, 69 | "interactivity": { 70 | "detect_on": "canvas", 71 | "events": { 72 | "onhover": { 73 | "enable": true, 74 | "mode": "repulse" 75 | }, 76 | "onclick": { 77 | "enable": true, 78 | "mode": "push" 79 | }, 80 | "resize": true 81 | }, 82 | "modes": { 83 | "grab": { 84 | "distance": 400, 85 | "line_linked": { 86 | "opacity": 1 87 | } 88 | }, 89 | "bubble": { 90 | "distance": 400, 91 | "size": 40, 92 | "duration": 2, 93 | "opacity": 8, 94 | "speed": 3 95 | }, 96 | "repulse": { 97 | "distance": 200 98 | }, 99 | "push": { 100 | "particles_nb": 4 101 | }, 102 | "remove": { 103 | "particles_nb": 2 104 | } 105 | } 106 | }, 107 | "retina_detect": true, 108 | "config_demo": { 109 | "hide_card": false, 110 | "background_color": "#b61924", 111 | "background_image": "", 112 | "background_position": "50% 50%", 113 | "background_repeat": "no-repeat", 114 | "background_size": "cover" 115 | } 116 | } -------------------------------------------------------------------------------- /src/main/resources/static/json/particles1.json: -------------------------------------------------------------------------------- 1 | { 2 | "particles": { 3 | "number": { 4 | "value": 150, 5 | "density": { 6 | "enable": true, 7 | "value_area": 800 8 | } 9 | }, 10 | "color": { 11 | "value": "#ffffff" 12 | }, 13 | "shape": { 14 | "type": "circle", 15 | "stroke": { 16 | "width": 0, 17 | "color": "#000000" 18 | }, 19 | "polygon": { 20 | "nb_sides": 5 21 | }, 22 | "image": { 23 | "src": "img/github.svg", 24 | "width": 100, 25 | "height": 100 26 | } 27 | }, 28 | "opacity": { 29 | "value": 0.5, 30 | "random": false, 31 | "anim": { 32 | "enable": false, 33 | "speed": 1, 34 | "opacity_min": 0.1, 35 | "sync": false 36 | } 37 | }, 38 | "size": { 39 | "value": 3, 40 | "random": true, 41 | "anim": { 42 | "enable": false, 43 | "speed": 40, 44 | "size_min": 0.1, 45 | "sync": false 46 | } 47 | }, 48 | "line_linked": { 49 | "enable": true, 50 | "distance": 150, 51 | "color": "#ffffff", 52 | "opacity": 0.4, 53 | "width": 1 54 | }, 55 | "move": { 56 | "enable": true, 57 | "speed": 6, 58 | "direction": "none", 59 | "random": false, 60 | "straight": false, 61 | "out_mode": "out", 62 | "bounce": false, 63 | "attract": { 64 | "enable": false, 65 | "rotateX": 600, 66 | "rotateY": 1200 67 | } 68 | } 69 | }, 70 | "interactivity": { 71 | "detect_on": "canvas", 72 | "events": { 73 | "onhover": { 74 | "enable": true, 75 | "mode": "grab" 76 | }, 77 | "onclick": { 78 | "enable": true, 79 | "mode": "push" 80 | }, 81 | "resize": true 82 | }, 83 | "modes": { 84 | "grab": { 85 | "distance": 140, 86 | "line_linked": { 87 | "opacity": 1 88 | } 89 | }, 90 | "bubble": { 91 | "distance": 400, 92 | "size": 40, 93 | "duration": 2, 94 | "opacity": 8, 95 | "speed": 3 96 | }, 97 | "repulse": { 98 | "distance": 200, 99 | "duration": 0.4 100 | }, 101 | "push": { 102 | "particles_nb": 4 103 | }, 104 | "remove": { 105 | "particles_nb": 2 106 | } 107 | } 108 | }, 109 | "retina_detect": true 110 | } -------------------------------------------------------------------------------- /src/main/resources/static/json/particles2.json: -------------------------------------------------------------------------------- 1 | { 2 | "particles": { 3 | "number": { 4 | "value": 100 5 | }, 6 | "shape": { 7 | "type": "circle" 8 | }, 9 | "size": { 10 | "value": 10, 11 | "random": true 12 | }, 13 | "line_linked": { 14 | "enable": false 15 | }, 16 | "move": { 17 | "enable": true, 18 | "speed": 2, 19 | "direction": "bottom", 20 | "straight": false 21 | } 22 | }, 23 | "interactivity": { 24 | "detect_on": "canvas", 25 | "events": { 26 | "onhover": { 27 | "enable": false 28 | } 29 | }, 30 | "modes": { 31 | "push": { 32 | "particles_nb": 12 33 | } 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /src/main/resources/static/layui/css/modules/code.css: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | @Name: layui.code 4 | @Author: 贤心 5 | @Site: http://www.layui.com 6 | 7 | */ 8 | 9 | /* 加载就绪标志 */ 10 | html #layuicss-skincodecss{display:none; position: absolute; width:1989px;} 11 | 12 | /* 默认风格 */ 13 | .layui-code-view{display: block; position: relative; margin: 10px 0; padding: 0; border: 1px solid #ddd; border-left-width: 6px; background-color: #F2F2F2; color: #333; font-family: Courier New; font-size: 12px;} 14 | .layui-code-h3{position: relative; padding: 0 10px; height: 30px; line-height: 30px; border-bottom: 1px solid #ddd; font-size: 12px;} 15 | .layui-code-h3 a{position: absolute; right: 10px; top: 0; color: #999;} 16 | .layui-code-view .layui-code-ol{position: relative; overflow: auto;} 17 | .layui-code-view .layui-code-ol li{position: relative; margin-left: 45px; line-height: 20px; padding: 0 5px; border-left: 1px solid #ddd; list-style-type: decimal-leading-zero; *list-style-type: decimal; background-color: #fff;} 18 | .layui-code-view pre{margin: 0;} 19 | 20 | /* notepadd++风格 */ 21 | .layui-code-notepad{border: 1px solid #0C0C0C; border-left-color: #3F3F3F; background-color: #0C0C0C; color: #C2BE9E} 22 | .layui-code-notepad .layui-code-h3{border-bottom: none;} 23 | .layui-code-notepad .layui-code-ol li{background-color: #3F3F3F; border-left: none;} -------------------------------------------------------------------------------- /src/main/resources/static/layui/css/modules/laydate/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/layui/css/modules/laydate/icon.png -------------------------------------------------------------------------------- /src/main/resources/static/layui/css/modules/layer/default/icon-ext.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/layui/css/modules/layer/default/icon-ext.png -------------------------------------------------------------------------------- /src/main/resources/static/layui/css/modules/layer/default/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/layui/css/modules/layer/default/icon.png -------------------------------------------------------------------------------- /src/main/resources/static/layui/css/modules/layer/default/loading-0.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/layui/css/modules/layer/default/loading-0.gif -------------------------------------------------------------------------------- /src/main/resources/static/layui/css/modules/layer/default/loading-1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/layui/css/modules/layer/default/loading-1.gif -------------------------------------------------------------------------------- /src/main/resources/static/layui/css/modules/layer/default/loading-2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/layui/css/modules/layer/default/loading-2.gif -------------------------------------------------------------------------------- /src/main/resources/static/layui/css/modules/layim/html/find.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 发现 9 | 10 | 11 | 14 | 15 | 16 | 17 |
    18 |
    此为自定义的【查找】页面,因需求不一,所以官方暂不提供该模版结构与样式,实际使用时,可移至该文件到你的项目中,对页面自行把控。 19 |
    文件所在目录(相对于layui.js):/css/modules/layim/html/find.html
    20 |
    21 | 22 | 23 | 24 | 25 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /src/main/resources/static/layui/css/modules/layim/html/getmsg.json: -------------------------------------------------------------------------------- 1 | { 2 | "code": 0, 3 | "pages": 1, 4 | "data": [ 5 | { 6 | "id": 76, 7 | "content": "申请添加你为好友", 8 | "uid": 168, 9 | "from": 166488, 10 | "from_group": 0, 11 | "type": 1, 12 | "remark": "有问题要问", 13 | "href": null, 14 | "read": 1, 15 | "time": "刚刚", 16 | "user": { 17 | "id": 166488, 18 | "avatar": "http://q.qlogo.cn/qqapp/101235792/B704597964F9BD0DB648292D1B09F7E8/100", 19 | "username": "李彦宏", 20 | "sign": null 21 | } 22 | }, 23 | { 24 | "id": 75, 25 | "content": "申请添加你为好友", 26 | "uid": 168, 27 | "from": 347592, 28 | "from_group": 0, 29 | "type": 1, 30 | "remark": "你好啊!", 31 | "href": null, 32 | "read": 1, 33 | "time": "刚刚", 34 | "user": { 35 | "id": 347592, 36 | "avatar": "http://q.qlogo.cn/qqapp/101235792/B78751375E0531675B1272AD994BA875/100", 37 | "username": "麻花疼", 38 | "sign": null 39 | } 40 | }, 41 | { 42 | "id": 62, 43 | "content": "雷军 拒绝了你的好友申请", 44 | "uid": 168, 45 | "from": null, 46 | "from_group": null, 47 | "type": 1, 48 | "remark": null, 49 | "href": null, 50 | "read": 1, 51 | "time": "10天前", 52 | "user": { 53 | "id": null 54 | } 55 | }, 56 | { 57 | "id": 60, 58 | "content": "马小云 已经同意你的好友申请", 59 | "uid": 168, 60 | "from": null, 61 | "from_group": null, 62 | "type": 1, 63 | "remark": null, 64 | "href": null, 65 | "read": 1, 66 | "time": "10天前", 67 | "user": { 68 | "id": null 69 | } 70 | }, 71 | { 72 | "id": 61, 73 | "content": "贤心 已经同意你的好友申请", 74 | "uid": 168, 75 | "from": null, 76 | "from_group": null, 77 | "type": 1, 78 | "remark": null, 79 | "href": null, 80 | "read": 1, 81 | "time": "10天前", 82 | "user": { 83 | "id": null 84 | } 85 | } 86 | ] 87 | } -------------------------------------------------------------------------------- /src/main/resources/static/layui/css/modules/layim/mobile/layim.css: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | @Name: layim 4 | @Author: 贤心 5 | @Site: http://layim.layui.com 6 | 7 | */ 8 | 9 | /* 加载就绪标志 */ 10 | html #layuicss-skinlayim-mobilecss{display: none; position: absolute; width: 1989px;} 11 | 12 | /* 辅助 */ 13 | 14 | 15 | /* 聊天面板 */ 16 | .layim-chat{position: fixed; bottom: 0; top: 0; left: 0; right: 0; background-color: #eee;} 17 | 18 | .layim-chat-title{position: fixed; top: 0; left: 0; right: 0; height: 50px; line-height: 50px; text-align: center; background-color: #36373C; color: #fff; font-size: 16px;} 19 | .layim-chat-status{padding-left: 5px; font-size: 14px;} 20 | 21 | .layim-chat-main{position: fixed; width: 100%; bottom: 85px; top: 50px; left: 0; right: 0; padding: 15px; overflow-y: auto; overflow-x: hidden; -webkit-box-sizing: border-box !important; -moz-box-sizing: border-box !important; box-sizing: border-box !important;} 22 | .layim-chat-main[nonetitle]{top: 0;} 23 | .layim-chat-main ul{overflow-x: hidden;} 24 | .layim-chat-main ul li{position: relative; font-size: 0; margin-bottom: 10px; padding-left: 60px; min-height: 68px;} 25 | .layim-chat-user, 26 | .layim-chat-text{display: inline-block; *display:inline; *zoom:1; vertical-align:top; font-size: 14px;} 27 | .layim-chat-user{position: absolute; left: 3px;} 28 | .layim-chat-user img{width: 40px; height: 40px; border-radius: 100%;} 29 | .layim-chat-user cite{position: absolute; left: 60px; top: -2px; width: 500px; line-height: 24px; font-size: 12px; white-space: nowrap; color: #999; text-align: left; font-style: normal;} 30 | .layim-chat-user cite i{padding-left: 15px; font-style: normal;} 31 | .layim-chat-text{position: relative; min-height: 22px; line-height: 22px; margin-top: 25px; padding: 8px 15px; background-color: #fff; border-radius: 3px; color: #333; word-break: break-all;} 32 | .layim-chat-text:after{content: ''; position: absolute; left: -10px; top: 13px; width: 0; height: 0; border-style: dashed; border-color:transparent; overflow:hidden; border-width: 10px; border-top-style: solid; border-top-color: #fff;} 33 | .layim-chat-text a{color: #33DF83;} 34 | .layim-chat-text img{ max-width: 100%; vertical-align: middle;} 35 | .layui-layim-file, 36 | .layim-chat-text .layui-layim-file{display: block; text-align: center; } 37 | .layim-chat-text .layui-layim-file{color: #333;} 38 | .layui-layim-file:hover{opacity: 0.9} 39 | .layui-layim-file i{font-size: 80px; line-height: 80px;} 40 | .layui-layim-file cite{display: block; line-height: 20px; font-size: 14px;} 41 | .layim-chat-main ul .layim-chat-system{min-height: 0; padding: 0;} 42 | 43 | .layim-chat-main ul .layim-chat-mine{text-align: right; padding-left: 0; padding-right: 60px;} 44 | .layim-chat-mine .layim-chat-user{left: auto; right: 3px;} 45 | .layim-chat-mine .layim-chat-user cite{left: auto; right: 60px; text-align: right;} 46 | .layim-chat-mine .layim-chat-user cite i{padding-left: 0; padding-right: 15px;} 47 | .layim-chat-mine .layim-chat-text{margin-left: 0; text-align: left; background-color: #5FB878; color: #fff;} 48 | .layim-chat-mine .layim-chat-text:after{left: auto; right: -10px; border-top-color: #5FB878;} 49 | .layim-chat-mine .layim-chat-text a{color: #fff;} 50 | 51 | .layim-chat-main ul .layim-chat-system{min-height: 0; margin: 20px 0 5px; padding: 0;} 52 | .layim-chat-system{margin: 10px 0; text-align: center;} 53 | .layim-chat-system span{display: inline-block; line-height: 30px; padding: 0 15px; border-radius: 3px; background-color: #ddd; color: #fff; font-size: 14px;} 54 | 55 | .layim-chat-footer{ position: fixed; bottom: 0; left: 10px; right: 10px; height: 80px;} 56 | .layim-chat-send{display: -webkit-box; display: -webkit-flex; display: flex;} 57 | .layim-chat-send input{-webkit-box-flex: 1; -webkit-flex: 1; flex: 1; height: 36px; padding-left: 5px; border: none 0; background-color: #fff; border-radius: 3px;} 58 | .layim-chat-send button{border-radius: 3px; height: 36px; padding: 0 10px; border: none 0; margin-left: 10px; background-color: #5FB878; color: #fff;} 59 | 60 | .layim-chat-tool{position: relative; width: 100%; overflow-x: auto; padding: 0; height: 38px; line-height: 38px; margin-top: 5px; font-size: 0; white-space: nowrap;} 61 | .layim-chat-tool span{position: relative; margin: 0 10px; display: inline-block; *display:inline; *zoom:1; vertical-align:top; font-size: 24px; cursor: pointer;} 62 | .layim-chat-tool .layim-tool-log{position: absolute; right: 5px; font-size: 14px; } 63 | .layim-tool-log i{position: relative; top: 2px; margin-right: 5px; font-size: 20px; color: #999} 64 | .layim-tool-image input{position: absolute; font-size: 0; left: 0; top: 0; width: 100%; height: 100%; opacity: 0.01; filter: Alpha(opacity=1); cursor: pointer;} 65 | 66 | 67 | .layim-layer{position: fixed; bottom: 85px; left: 10px; right: 10px; margin: 0 auto;} 68 | 69 | .layui-layim-face{position:relative; max-height: 180px; overflow: auto; padding: 10px; font-size: 0;} 70 | .layui-layim-face li{cursor: pointer; display: inline-block; vertical-align: bottom; padding: 5px 2px; text-align: center; width: 10%; -webkit-box-sizing: border-box !important; -moz-box-sizing: border-box !important; box-sizing: border-box !important;} 71 | .layui-layim-face li img{width: 22px; height: 22px;} 72 | 73 | -------------------------------------------------------------------------------- /src/main/resources/static/layui/css/modules/layim/skin/1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/layui/css/modules/layim/skin/1.jpg -------------------------------------------------------------------------------- /src/main/resources/static/layui/css/modules/layim/skin/2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/layui/css/modules/layim/skin/2.jpg -------------------------------------------------------------------------------- /src/main/resources/static/layui/css/modules/layim/skin/3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/layui/css/modules/layim/skin/3.jpg -------------------------------------------------------------------------------- /src/main/resources/static/layui/css/modules/layim/skin/4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/layui/css/modules/layim/skin/4.jpg -------------------------------------------------------------------------------- /src/main/resources/static/layui/css/modules/layim/skin/5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/layui/css/modules/layim/skin/5.jpg -------------------------------------------------------------------------------- /src/main/resources/static/layui/css/modules/layim/skin/logo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/layui/css/modules/layim/skin/logo.jpg -------------------------------------------------------------------------------- /src/main/resources/static/layui/css/modules/layim/voice/default.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/layui/css/modules/layim/voice/default.wav -------------------------------------------------------------------------------- /src/main/resources/static/layui/font/iconfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/layui/font/iconfont.eot -------------------------------------------------------------------------------- /src/main/resources/static/layui/font/iconfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/layui/font/iconfont.ttf -------------------------------------------------------------------------------- /src/main/resources/static/layui/font/iconfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/layui/font/iconfont.woff -------------------------------------------------------------------------------- /src/main/resources/static/layui/images/face/0.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/layui/images/face/0.gif -------------------------------------------------------------------------------- /src/main/resources/static/layui/images/face/1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/layui/images/face/1.gif -------------------------------------------------------------------------------- /src/main/resources/static/layui/images/face/10.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/layui/images/face/10.gif -------------------------------------------------------------------------------- /src/main/resources/static/layui/images/face/11.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/layui/images/face/11.gif -------------------------------------------------------------------------------- /src/main/resources/static/layui/images/face/12.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/layui/images/face/12.gif -------------------------------------------------------------------------------- /src/main/resources/static/layui/images/face/13.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/layui/images/face/13.gif -------------------------------------------------------------------------------- /src/main/resources/static/layui/images/face/14.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/layui/images/face/14.gif -------------------------------------------------------------------------------- /src/main/resources/static/layui/images/face/15.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/layui/images/face/15.gif -------------------------------------------------------------------------------- /src/main/resources/static/layui/images/face/16.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/layui/images/face/16.gif -------------------------------------------------------------------------------- /src/main/resources/static/layui/images/face/17.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/layui/images/face/17.gif -------------------------------------------------------------------------------- /src/main/resources/static/layui/images/face/18.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/layui/images/face/18.gif -------------------------------------------------------------------------------- /src/main/resources/static/layui/images/face/19.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/layui/images/face/19.gif -------------------------------------------------------------------------------- /src/main/resources/static/layui/images/face/2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/layui/images/face/2.gif -------------------------------------------------------------------------------- /src/main/resources/static/layui/images/face/20.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/layui/images/face/20.gif -------------------------------------------------------------------------------- /src/main/resources/static/layui/images/face/21.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/layui/images/face/21.gif -------------------------------------------------------------------------------- /src/main/resources/static/layui/images/face/22.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/layui/images/face/22.gif -------------------------------------------------------------------------------- /src/main/resources/static/layui/images/face/23.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/layui/images/face/23.gif -------------------------------------------------------------------------------- /src/main/resources/static/layui/images/face/24.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/layui/images/face/24.gif -------------------------------------------------------------------------------- /src/main/resources/static/layui/images/face/25.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/layui/images/face/25.gif -------------------------------------------------------------------------------- /src/main/resources/static/layui/images/face/26.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/layui/images/face/26.gif -------------------------------------------------------------------------------- /src/main/resources/static/layui/images/face/27.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/layui/images/face/27.gif -------------------------------------------------------------------------------- /src/main/resources/static/layui/images/face/28.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/layui/images/face/28.gif -------------------------------------------------------------------------------- /src/main/resources/static/layui/images/face/29.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/layui/images/face/29.gif -------------------------------------------------------------------------------- /src/main/resources/static/layui/images/face/3.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/layui/images/face/3.gif -------------------------------------------------------------------------------- /src/main/resources/static/layui/images/face/30.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/layui/images/face/30.gif -------------------------------------------------------------------------------- /src/main/resources/static/layui/images/face/31.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/layui/images/face/31.gif -------------------------------------------------------------------------------- /src/main/resources/static/layui/images/face/32.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/layui/images/face/32.gif -------------------------------------------------------------------------------- /src/main/resources/static/layui/images/face/33.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/layui/images/face/33.gif -------------------------------------------------------------------------------- /src/main/resources/static/layui/images/face/34.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/layui/images/face/34.gif -------------------------------------------------------------------------------- /src/main/resources/static/layui/images/face/35.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/layui/images/face/35.gif -------------------------------------------------------------------------------- /src/main/resources/static/layui/images/face/36.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/layui/images/face/36.gif -------------------------------------------------------------------------------- /src/main/resources/static/layui/images/face/37.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/layui/images/face/37.gif -------------------------------------------------------------------------------- /src/main/resources/static/layui/images/face/38.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/layui/images/face/38.gif -------------------------------------------------------------------------------- /src/main/resources/static/layui/images/face/39.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/layui/images/face/39.gif -------------------------------------------------------------------------------- /src/main/resources/static/layui/images/face/4.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/layui/images/face/4.gif -------------------------------------------------------------------------------- /src/main/resources/static/layui/images/face/40.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/layui/images/face/40.gif -------------------------------------------------------------------------------- /src/main/resources/static/layui/images/face/41.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/layui/images/face/41.gif -------------------------------------------------------------------------------- /src/main/resources/static/layui/images/face/42.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/layui/images/face/42.gif -------------------------------------------------------------------------------- /src/main/resources/static/layui/images/face/43.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/layui/images/face/43.gif -------------------------------------------------------------------------------- /src/main/resources/static/layui/images/face/44.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/layui/images/face/44.gif -------------------------------------------------------------------------------- /src/main/resources/static/layui/images/face/45.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/layui/images/face/45.gif -------------------------------------------------------------------------------- /src/main/resources/static/layui/images/face/46.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/layui/images/face/46.gif -------------------------------------------------------------------------------- /src/main/resources/static/layui/images/face/47.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/layui/images/face/47.gif -------------------------------------------------------------------------------- /src/main/resources/static/layui/images/face/48.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/layui/images/face/48.gif -------------------------------------------------------------------------------- /src/main/resources/static/layui/images/face/49.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/layui/images/face/49.gif -------------------------------------------------------------------------------- /src/main/resources/static/layui/images/face/5.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/layui/images/face/5.gif -------------------------------------------------------------------------------- /src/main/resources/static/layui/images/face/50.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/layui/images/face/50.gif -------------------------------------------------------------------------------- /src/main/resources/static/layui/images/face/51.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/layui/images/face/51.gif -------------------------------------------------------------------------------- /src/main/resources/static/layui/images/face/52.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/layui/images/face/52.gif -------------------------------------------------------------------------------- /src/main/resources/static/layui/images/face/53.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/layui/images/face/53.gif -------------------------------------------------------------------------------- /src/main/resources/static/layui/images/face/54.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/layui/images/face/54.gif -------------------------------------------------------------------------------- /src/main/resources/static/layui/images/face/55.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/layui/images/face/55.gif -------------------------------------------------------------------------------- /src/main/resources/static/layui/images/face/56.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/layui/images/face/56.gif -------------------------------------------------------------------------------- /src/main/resources/static/layui/images/face/57.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/layui/images/face/57.gif -------------------------------------------------------------------------------- /src/main/resources/static/layui/images/face/58.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/layui/images/face/58.gif -------------------------------------------------------------------------------- /src/main/resources/static/layui/images/face/59.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/layui/images/face/59.gif -------------------------------------------------------------------------------- /src/main/resources/static/layui/images/face/6.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/layui/images/face/6.gif -------------------------------------------------------------------------------- /src/main/resources/static/layui/images/face/60.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/layui/images/face/60.gif -------------------------------------------------------------------------------- /src/main/resources/static/layui/images/face/61.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/layui/images/face/61.gif -------------------------------------------------------------------------------- /src/main/resources/static/layui/images/face/62.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/layui/images/face/62.gif -------------------------------------------------------------------------------- /src/main/resources/static/layui/images/face/63.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/layui/images/face/63.gif -------------------------------------------------------------------------------- /src/main/resources/static/layui/images/face/64.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/layui/images/face/64.gif -------------------------------------------------------------------------------- /src/main/resources/static/layui/images/face/65.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/layui/images/face/65.gif -------------------------------------------------------------------------------- /src/main/resources/static/layui/images/face/66.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/layui/images/face/66.gif -------------------------------------------------------------------------------- /src/main/resources/static/layui/images/face/67.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/layui/images/face/67.gif -------------------------------------------------------------------------------- /src/main/resources/static/layui/images/face/68.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/layui/images/face/68.gif -------------------------------------------------------------------------------- /src/main/resources/static/layui/images/face/69.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/layui/images/face/69.gif -------------------------------------------------------------------------------- /src/main/resources/static/layui/images/face/7.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/layui/images/face/7.gif -------------------------------------------------------------------------------- /src/main/resources/static/layui/images/face/70.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/layui/images/face/70.gif -------------------------------------------------------------------------------- /src/main/resources/static/layui/images/face/71.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/layui/images/face/71.gif -------------------------------------------------------------------------------- /src/main/resources/static/layui/images/face/8.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/layui/images/face/8.gif -------------------------------------------------------------------------------- /src/main/resources/static/layui/images/face/9.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/layui/images/face/9.gif -------------------------------------------------------------------------------- /src/main/resources/static/layui/lay/all-mobile.js: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | @Name:用于打包移动完整版 4 | @Author:贤心 5 | @License:LGPL 6 | 7 | */ 8 | 9 | layui.define(function(exports){ 10 | exports('layui.mobile', layui.v); 11 | }); 12 | -------------------------------------------------------------------------------- /src/main/resources/static/layui/lay/all.js: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | @Name:用于打包PC完整版,即包含layui.js和所有模块的完整合并(该文件不会存在于构建后的目录) 4 | @Author:贤心 5 | @License:LGPL 6 | 7 | */ 8 | 9 | layui.define(function(exports){ 10 | var cache = layui.cache; 11 | layui.config({ 12 | dir: cache.dir.replace(/lay\/dest\/$/, '') 13 | }); 14 | exports('layui.all', layui.v); 15 | }); 16 | -------------------------------------------------------------------------------- /src/main/resources/static/layui/lay/modules/code.js: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | @Name:layui.code 代码修饰器 4 | @Author:贤心 5 | @License:LGPL 6 | 7 | */ 8 | 9 | layui.define('jquery', function(exports){ 10 | "use strict"; 11 | 12 | var $ = layui.jquery; 13 | var about = 'http://www.layui.com/doc/modules/code.html'; //关于信息 14 | 15 | exports('code', function(options){ 16 | var elems = []; 17 | options = options || {}; 18 | options.elem = $(options.elem||'.layui-code'); 19 | options.about = 'about' in options ? options.about : true; 20 | 21 | options.elem.each(function(){ 22 | elems.push(this); 23 | }); 24 | 25 | layui.each(elems.reverse(), function(index, item){ 26 | var othis = $(item), html = othis.html(); 27 | 28 | //转义HTML标签 29 | if(othis.attr('lay-encode') || options.encode){ 30 | html = html.replace(/&(?!#?[a-zA-Z0-9]+;)/g, '&') 31 | .replace(//g, '>').replace(/'/g, ''').replace(/"/g, '"') 32 | } 33 | 34 | othis.html('
    1. ' + html.replace(/[\r\t\n]+/g, '
    2. ') + '
    ') 35 | 36 | if(!othis.find('>.layui-code-h3')[0]){ 37 | othis.prepend('

    '+ (othis.attr('lay-title')||options.title||'code') + (options.about ? 'layui.code' : '') + '

    '); 38 | } 39 | 40 | var ol = othis.find('>.layui-code-ol'); 41 | othis.addClass('layui-box layui-code-view'); 42 | 43 | //识别皮肤 44 | if(othis.attr('lay-skin') || options.skin){ 45 | othis.addClass('layui-code-' +(othis.attr('lay-skin') || options.skin)); 46 | } 47 | 48 | //按行数适配左边距 49 | if((ol.find('li').length/100|0) > 0){ 50 | ol.css('margin-left', (ol.find('li').length/100|0) + 'px'); 51 | } 52 | 53 | //设置最大高度 54 | if(othis.attr('lay-height') || options.height){ 55 | ol.css('max-height', othis.attr('lay-height') || options.height); 56 | } 57 | 58 | }); 59 | 60 | }); 61 | }).addcss('modules/code.css', 'skincodecss'); -------------------------------------------------------------------------------- /src/main/resources/static/layui/lay/modules/flow.js: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | @Name:layui.flow 流加载 4 | @Author:贤心 5 | @License:LGPL 6 | 7 | */ 8 | 9 | 10 | layui.define('jquery', function(exports){ 11 | "use strict"; 12 | 13 | var $ = layui.jquery, Flow = function(options){} 14 | ,ELEM_MORE = 'layui-flow-more' 15 | ,ELEM_LOAD = ''; 16 | 17 | //主方法 18 | Flow.prototype.load = function(options){ 19 | var that = this, page = 0, lock, isOver, lazyimg, timer; 20 | options = options || {}; 21 | 22 | var elem = $(options.elem); if(!elem[0]) return; 23 | var scrollElem = $(options.scrollElem || document); //滚动条所在元素 24 | var mb = options.mb || 50; //与底部的临界距离 25 | var isAuto = 'isAuto' in options ? options.isAuto : true; //是否自动滚动加载 26 | var end = options.end || '没有更多了'; //“末页”显示文案 27 | 28 | //滚动条所在元素是否为document 29 | var notDocment = options.scrollElem && options.scrollElem !== document; 30 | 31 | //加载更多 32 | var ELEM_TEXT = '加载更多' 33 | ,more = $(''); 34 | 35 | if(!elem.find('.layui-flow-more')[0]){ 36 | elem.append(more); 37 | } 38 | 39 | //加载下一个元素 40 | var next = function(html, over){ 41 | html = $(html); 42 | more.before(html); 43 | over = over == 0 ? true : null; 44 | over ? more.html(end) : more.find('a').html(ELEM_TEXT); 45 | isOver = over; 46 | lock = null; 47 | lazyimg && lazyimg(); 48 | }; 49 | 50 | //触发请求 51 | var done = function(){ 52 | lock = true; 53 | more.find('a').html(ELEM_LOAD); 54 | typeof options.done === 'function' && options.done(++page, next); 55 | }; 56 | 57 | done(); 58 | 59 | //不自动滚动加载 60 | more.find('a').on('click', function(){ 61 | var othis = $(this); 62 | if(isOver) return; 63 | lock || done(); 64 | }); 65 | 66 | //如果允许图片懒加载 67 | if(options.isLazyimg){ 68 | var lazyimg = that.lazyimg({ 69 | elem: options.elem + ' img' 70 | ,scrollElem: options.scrollElem 71 | }); 72 | } 73 | 74 | if(!isAuto) return that; 75 | 76 | scrollElem.on('scroll', function(){ 77 | var othis = $(this), top = othis.scrollTop(); 78 | 79 | if(timer) clearTimeout(timer); 80 | if(isOver) return; 81 | 82 | timer = setTimeout(function(){ 83 | //计算滚动所在容器的可视高度 84 | var height = notDocment ? othis.height() : $(window).height(); 85 | 86 | //计算滚动所在容器的实际高度 87 | var scrollHeight = notDocment 88 | ? othis.prop('scrollHeight') 89 | : document.documentElement.scrollHeight; 90 | 91 | //临界点 92 | if(scrollHeight - top - height <= mb){ 93 | lock || done(); 94 | } 95 | }, 100); 96 | }); 97 | return that; 98 | }; 99 | 100 | //图片懒加载 101 | Flow.prototype.lazyimg = function(options){ 102 | var that = this, index = 0, haveScroll; 103 | options = options || {}; 104 | 105 | var scrollElem = $(options.scrollElem || document); //滚动条所在元素 106 | var elem = options.elem || 'img'; 107 | 108 | //滚动条所在元素是否为document 109 | var notDocment = options.scrollElem && options.scrollElem !== document; 110 | 111 | //显示图片 112 | var show = function(item, height){ 113 | var start = scrollElem.scrollTop(), end = start + height; 114 | var elemTop = notDocment ? function(){ 115 | return item.offset().top - scrollElem.offset().top + start; 116 | }() : item.offset().top; 117 | 118 | /* 始终只加载在当前屏范围内的图片 */ 119 | if(elemTop >= start && elemTop <= end){ 120 | if(!item.attr('src')){ 121 | var src = item.attr('lay-src'); 122 | layui.img(src, function(){ 123 | var next = that.lazyimg.elem.eq(index); 124 | item.attr('src', src).removeAttr('lay-src'); 125 | 126 | /* 当前图片加载就绪后,检测下一个图片是否在当前屏 */ 127 | next[0] && render(next); 128 | index++; 129 | }); 130 | } 131 | } 132 | }, render = function(othis, scroll){ 133 | 134 | //计算滚动所在容器的可视高度 135 | var height = notDocment ? (scroll||scrollElem).height() : $(window).height(); 136 | var start = scrollElem.scrollTop(), end = start + height; 137 | 138 | that.lazyimg.elem = $(elem); 139 | 140 | if(othis){ 141 | show(othis, height); 142 | } else { 143 | //计算未加载过的图片 144 | for(var i = 0; i < that.lazyimg.elem.length; i++){ 145 | var item = that.lazyimg.elem.eq(i), elemTop = notDocment ? function(){ 146 | return item.offset().top - scrollElem.offset().top + start; 147 | }() : item.offset().top; 148 | 149 | show(item, height); 150 | index = i; 151 | 152 | //如果图片的top坐标,超出了当前屏,则终止后续图片的遍历 153 | if(elemTop > end) break; 154 | } 155 | } 156 | }; 157 | 158 | render(); 159 | 160 | if(!haveScroll){ 161 | var timer; 162 | scrollElem.on('scroll', function(){ 163 | var othis = $(this); 164 | if(timer) clearTimeout(timer) 165 | timer = setTimeout(function(){ 166 | render(null, othis); 167 | }, 50); 168 | }); 169 | haveScroll = true; 170 | } 171 | return render; 172 | }; 173 | 174 | //暴露接口 175 | exports('flow', new Flow()); 176 | }); 177 | -------------------------------------------------------------------------------- /src/main/resources/static/layui/lay/modules/laytpl.js: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | @Name : layui.laytpl 模板引擎 4 | @Author:贤心 5 | @License:LGPL 6 | 7 | */ 8 | 9 | layui.define(function(exports){ 10 | 11 | "use strict"; 12 | 13 | var config = { 14 | open: '{{', 15 | close: '}}' 16 | }; 17 | 18 | var tool = { 19 | exp: function(str){ 20 | return new RegExp(str, 'g'); 21 | }, 22 | //匹配满足规则内容 23 | query: function(type, _, __){ 24 | var types = [ 25 | '#([\\s\\S])+?', //js语句 26 | '([^{#}])*?' //普通字段 27 | ][type || 0]; 28 | return exp((_||'') + config.open + types + config.close + (__||'')); 29 | }, 30 | escape: function(html){ 31 | return String(html||'').replace(/&(?!#?[a-zA-Z0-9]+;)/g, '&') 32 | .replace(//g, '>').replace(/'/g, ''').replace(/"/g, '"'); 33 | }, 34 | error: function(e, tplog){ 35 | var error = 'Laytpl Error:'; 36 | typeof console === 'object' && console.error(error + e + '\n'+ (tplog || '')); 37 | return error + e; 38 | } 39 | }; 40 | 41 | var exp = tool.exp, Tpl = function(tpl){ 42 | this.tpl = tpl; 43 | }; 44 | 45 | Tpl.pt = Tpl.prototype; 46 | 47 | window.errors = 0; 48 | 49 | //编译模版 50 | Tpl.pt.parse = function(tpl, data){ 51 | var that = this, tplog = tpl; 52 | var jss = exp('^'+config.open+'#', ''), jsse = exp(config.close+'$', ''); 53 | 54 | tpl = tpl.replace(/\s+|\r|\t|\n/g, ' ').replace(exp(config.open+'#'), config.open+'# ') 55 | 56 | .replace(exp(config.close+'}'), '} '+config.close).replace(/\\/g, '\\\\') 57 | 58 | .replace(/(?="|')/g, '\\').replace(tool.query(), function(str){ 59 | str = str.replace(jss, '').replace(jsse, ''); 60 | return '";' + str.replace(/\\/g, '') + ';view+="'; 61 | }) 62 | 63 | .replace(tool.query(1), function(str){ 64 | var start = '"+('; 65 | if(str.replace(/\s/g, '') === config.open+config.close){ 66 | return ''; 67 | } 68 | str = str.replace(exp(config.open+'|'+config.close), ''); 69 | if(/^=/.test(str)){ 70 | str = str.replace(/^=/, ''); 71 | start = '"+_escape_('; 72 | } 73 | return start + str.replace(/\\/g, '') + ')+"'; 74 | }); 75 | 76 | tpl = '"use strict";var view = "' + tpl + '";return view;'; 77 | 78 | try{ 79 | that.cache = tpl = new Function('d, _escape_', tpl); 80 | return tpl(data, tool.escape); 81 | } catch(e){ 82 | delete that.cache; 83 | return tool.error(e, tplog); 84 | } 85 | }; 86 | 87 | Tpl.pt.render = function(data, callback){ 88 | var that = this, tpl; 89 | if(!data) return tool.error('no data'); 90 | tpl = that.cache ? that.cache(data, tool.escape) : that.parse(that.tpl, data); 91 | if(!callback) return tpl; 92 | callback(tpl); 93 | }; 94 | 95 | var laytpl = function(tpl){ 96 | if(typeof tpl !== 'string') return tool.error('Template not found'); 97 | return new Tpl(tpl); 98 | }; 99 | 100 | laytpl.config = function(options){ 101 | options = options || {}; 102 | for(var i in options){ 103 | config[i] = options[i]; 104 | } 105 | }; 106 | 107 | laytpl.v = '1.2.0'; 108 | 109 | exports('laytpl', laytpl); 110 | 111 | }); -------------------------------------------------------------------------------- /src/main/resources/static/layui/lay/modules/mobile.js: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | @Name:layui 移动模块入口 | 构建后则为移动模块集合 4 | @Author:贤心 5 | @License:MIT 6 | 7 | */ 8 | 9 | 10 | if(!layui['layui.mobile']){ 11 | layui.config({ 12 | base: layui.cache.dir + 'lay/modules/mobile/' 13 | }).extend({ 14 | 'layer-mobile': 'layer-mobile' 15 | ,'zepto': 'zepto' 16 | ,'upload-mobile': 'upload-mobile' 17 | ,'layim-mobile': 'layim-mobile' 18 | }); 19 | } 20 | 21 | layui.define([ 22 | 'layer-mobile' 23 | ,'zepto' 24 | ,'layim-mobile' 25 | ], function(exports){ 26 | exports('mobile', { 27 | layer: layui['layer-mobile'] //弹层 28 | ,layim: layui['layim-mobile'] //WebIM 29 | }); 30 | }); -------------------------------------------------------------------------------- /src/main/resources/static/layui/lay/modules/mobile/layer-mobile.js: -------------------------------------------------------------------------------- 1 | /*! 2 | 3 | @Name:layer mobile v2.0 弹层组件移动版 4 | @Author:贤心 5 | @Site:http://layer.layui.com/mobie/ 6 | @License:LGPL 7 | 8 | */ 9 | 10 | layui.define(function(exports){ 11 | 12 | "use strict"; 13 | 14 | var win = window, doc = document, query = 'querySelectorAll', claname = 'getElementsByClassName', S = function(s){ 15 | return doc[query](s); 16 | }; 17 | 18 | //默认配置 19 | var config = { 20 | type: 0 21 | ,shade: true 22 | ,shadeClose: true 23 | ,fixed: true 24 | ,anim: 'scale' //默认动画类型 25 | }; 26 | 27 | var ready = { 28 | extend: function(obj){ 29 | var newobj = JSON.parse(JSON.stringify(config)); 30 | for(var i in obj){ 31 | newobj[i] = obj[i]; 32 | } 33 | return newobj; 34 | }, 35 | timer: {}, end: {} 36 | }; 37 | 38 | //点触事件 39 | ready.touch = function(elem, fn){ 40 | elem.addEventListener('click', function(e){ 41 | fn.call(this, e); 42 | }, false); 43 | }; 44 | 45 | var index = 0, classs = ['layui-m-layer'], Layer = function(options){ 46 | var that = this; 47 | that.config = ready.extend(options); 48 | that.view(); 49 | }; 50 | 51 | Layer.prototype.view = function(){ 52 | var that = this, config = that.config, layerbox = doc.createElement('div'); 53 | 54 | that.id = layerbox.id = classs[0] + index; 55 | layerbox.setAttribute('class', classs[0] + ' ' + classs[0]+(config.type || 0)); 56 | layerbox.setAttribute('index', index); 57 | 58 | //标题区域 59 | var title = (function(){ 60 | var titype = typeof config.title === 'object'; 61 | return config.title 62 | ? '

    '+ (titype ? config.title[0] : config.title) +'

    ' 63 | : ''; 64 | }()); 65 | 66 | //按钮区域 67 | var button = (function(){ 68 | typeof config.btn === 'string' && (config.btn = [config.btn]); 69 | var btns = (config.btn || []).length, btndom; 70 | if(btns === 0 || !config.btn){ 71 | return ''; 72 | } 73 | btndom = ''+ config.btn[0] +'' 74 | if(btns === 2){ 75 | btndom = ''+ config.btn[1] +'' + btndom; 76 | } 77 | return '
    '+ btndom + '
    '; 78 | }()); 79 | 80 | if(!config.fixed){ 81 | config.top = config.hasOwnProperty('top') ? config.top : 100; 82 | config.style = config.style || ''; 83 | config.style += ' top:'+ ( doc.body.scrollTop + config.top) + 'px'; 84 | } 85 | 86 | if(config.type === 2){ 87 | config.content = '

    '+ (config.content||'') +'

    '; 88 | } 89 | 90 | if(config.skin) config.anim = 'up'; 91 | if(config.skin === 'msg') config.shade = false; 92 | 93 | layerbox.innerHTML = (config.shade ? '
    ' : '') 94 | +'
    ' 95 | +'
    ' 96 | +'
    ' 97 | + title 98 | +'
    '+ config.content +'
    ' 99 | + button 100 | +'
    ' 101 | +'
    ' 102 | +'
    '; 103 | 104 | if(!config.type || config.type === 2){ 105 | var dialogs = doc[claname](classs[0] + config.type), dialen = dialogs.length; 106 | if(dialen >= 1){ 107 | layer.close(dialogs[0].getAttribute('index')) 108 | } 109 | } 110 | 111 | document.body.appendChild(layerbox); 112 | var elem = that.elem = S('#'+that.id)[0]; 113 | config.success && config.success(elem); 114 | 115 | that.index = index++; 116 | that.action(config, elem); 117 | }; 118 | 119 | Layer.prototype.action = function(config, elem){ 120 | var that = this; 121 | 122 | //自动关闭 123 | if(config.time){ 124 | ready.timer[that.index] = setTimeout(function(){ 125 | layer.close(that.index); 126 | }, config.time*1000); 127 | } 128 | 129 | //确认取消 130 | var btn = function(){ 131 | var type = this.getAttribute('type'); 132 | if(type == 0){ 133 | config.no && config.no(); 134 | layer.close(that.index); 135 | } else { 136 | config.yes ? config.yes(that.index) : layer.close(that.index); 137 | } 138 | }; 139 | if(config.btn){ 140 | var btns = elem[claname]('layui-m-layerbtn')[0].children, btnlen = btns.length; 141 | for(var ii = 0; ii < btnlen; ii++){ 142 | ready.touch(btns[ii], btn); 143 | } 144 | } 145 | 146 | //点遮罩关闭 147 | if(config.shade && config.shadeClose){ 148 | var shade = elem[claname]('layui-m-layershade')[0]; 149 | ready.touch(shade, function(){ 150 | layer.close(that.index, config.end); 151 | }); 152 | } 153 | 154 | config.end && (ready.end[that.index] = config.end); 155 | }; 156 | 157 | var layer = { 158 | v: '2.0 m', 159 | index: index, 160 | 161 | //核心方法 162 | open: function(options){ 163 | var o = new Layer(options || {}); 164 | return o.index; 165 | }, 166 | 167 | close: function(index){ 168 | var ibox = S('#'+classs[0]+index)[0]; 169 | if(!ibox) return; 170 | ibox.innerHTML = ''; 171 | doc.body.removeChild(ibox); 172 | clearTimeout(ready.timer[index]); 173 | delete ready.timer[index]; 174 | typeof ready.end[index] === 'function' && ready.end[index](); 175 | delete ready.end[index]; 176 | }, 177 | 178 | //关闭所有layer层 179 | closeAll: function(){ 180 | var boxs = doc[claname](classs[0]); 181 | for(var i = 0, len = boxs.length; i < len; i++){ 182 | layer.close((boxs[0].getAttribute('index')|0)); 183 | } 184 | } 185 | }; 186 | 187 | exports('layer-mobile', layer); 188 | 189 | }); -------------------------------------------------------------------------------- /src/main/resources/static/layui/lay/modules/mobile/layim-mobile-open.js: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | @Name:layim mobile 开源包 4 | @Author:贤心 5 | @License:MIT 6 | 7 | */ 8 | 9 | layui.define(function(exports){ 10 | exports('layim-mobile', layui.v); 11 | }); -------------------------------------------------------------------------------- /src/main/resources/static/layui/lay/modules/mobile/upload-mobile.js: -------------------------------------------------------------------------------- 1 | /*! 2 | 3 | @Title: layui.upload 单文件上传 - 全浏览器兼容版 4 | @Author: 贤心 5 | @License:LGPL 6 | 7 | */ 8 | 9 | layui.define(['layer-mobile', 'zepto'] , function(exports){ 10 | "use strict"; 11 | 12 | var $ = layui.zepto; 13 | var layer = layui['layer-mobile']; 14 | var device = layui.device(); 15 | 16 | var elemDragEnter = 'layui-upload-enter'; 17 | var elemIframe = 'layui-upload-iframe'; 18 | 19 | var msgConf = { 20 | icon: 2 21 | ,shift: 6 22 | }, fileType = { 23 | file: '文件' 24 | ,video: '视频' 25 | ,audio: '音频' 26 | }; 27 | 28 | layer.msg = function(content){ 29 | return layer.open({ 30 | content: content || '' 31 | ,skin: 'msg' 32 | ,time: 0 //2秒后自动关闭 33 | }); 34 | }; 35 | 36 | var Upload = function(options){ 37 | this.options = options; 38 | }; 39 | 40 | //初始化渲染 41 | Upload.prototype.init = function(){ 42 | var that = this, options = that.options; 43 | var body = $('body'), elem = $(options.elem || '.layui-upload-file'); 44 | var iframe = $(''); 45 | 46 | //插入iframe 47 | $('#'+elemIframe)[0] || body.append(iframe); 48 | 49 | return elem.each(function(index, item){ 50 | item = $(item); 51 | var form = '
    '; 52 | 53 | var type = item.attr('lay-type') || options.type; //获取文件类型 54 | 55 | //包裹ui元素 56 | if(!options.unwrap){ 57 | form = '
    ' + form + ''+ ( 58 | item.attr('lay-title') || options.title|| ('上传'+ (fileType[type]||'图片') ) 59 | ) +'
    '; 60 | } 61 | 62 | form = $(form); 63 | 64 | //拖拽支持 65 | if(!options.unwrap){ 66 | form.on('dragover', function(e){ 67 | e.preventDefault(); 68 | $(this).addClass(elemDragEnter); 69 | }).on('dragleave', function(){ 70 | $(this).removeClass(elemDragEnter); 71 | }).on('drop', function(){ 72 | $(this).removeClass(elemDragEnter); 73 | }); 74 | } 75 | 76 | //如果已经实例化,则移除包裹元素 77 | if(item.parent('form').attr('target') === elemIframe){ 78 | if(options.unwrap){ 79 | item.unwrap(); 80 | } else { 81 | item.parent().next().remove(); 82 | item.unwrap().unwrap(); 83 | } 84 | }; 85 | 86 | //包裹元素 87 | item.wrap(form); 88 | 89 | //触发上传 90 | item.off('change').on('change', function(){ 91 | that.action(this, type); 92 | }); 93 | }); 94 | }; 95 | 96 | //提交上传 97 | Upload.prototype.action = function(input, type){ 98 | var that = this, options = that.options, val = input.value; 99 | var item = $(input), ext = item.attr('lay-ext') || options.ext || ''; //获取支持上传的文件扩展名; 100 | 101 | if(!val){ 102 | return; 103 | }; 104 | 105 | //校验文件 106 | switch(type){ 107 | case 'file': //一般文件 108 | if(ext && !RegExp('\\w\\.('+ ext +')$', 'i').test(escape(val))){ 109 | layer.msg('不支持该文件格式', msgConf); 110 | return input.value = ''; 111 | } 112 | break; 113 | case 'video': //视频文件 114 | if(!RegExp('\\w\\.('+ (ext||'avi|mp4|wma|rmvb|rm|flash|3gp|flv') +')$', 'i').test(escape(val))){ 115 | layer.msg('不支持该视频格式', msgConf); 116 | return input.value = ''; 117 | } 118 | break; 119 | case 'audio': //音频文件 120 | if(!RegExp('\\w\\.('+ (ext||'mp3|wav|mid') +')$', 'i').test(escape(val))){ 121 | layer.msg('不支持该音频格式', msgConf); 122 | return input.value = ''; 123 | } 124 | break; 125 | default: //图片文件 126 | if(!RegExp('\\w\\.('+ (ext||'jpg|png|gif|bmp|jpeg') +')$', 'i').test(escape(val))){ 127 | layer.msg('不支持该图片格式', msgConf); 128 | return input.value = ''; 129 | } 130 | break; 131 | } 132 | 133 | options.before && options.before(input); 134 | item.parent().submit(); 135 | 136 | var iframe = $('#'+elemIframe), timer = setInterval(function() { 137 | var res; 138 | try { 139 | res = iframe.contents().find('body').text(); 140 | } catch(e) { 141 | layer.msg('上传接口存在跨域', msgConf); 142 | clearInterval(timer); 143 | } 144 | if(res){ 145 | clearInterval(timer); 146 | iframe.contents().find('body').html(''); 147 | try { 148 | res = JSON.parse(res); 149 | } catch(e){ 150 | res = {}; 151 | return layer.msg('请对上传接口返回JSON字符', msgConf); 152 | } 153 | typeof options.success === 'function' && options.success(res, input); 154 | } 155 | }, 30); 156 | 157 | input.value = ''; 158 | }; 159 | 160 | //暴露接口 161 | exports('upload-mobile', function(options){ 162 | var upload = new Upload(options = options || {}); 163 | upload.init(); 164 | }); 165 | }); 166 | 167 | -------------------------------------------------------------------------------- /src/main/resources/static/layui/lay/modules/upload.js: -------------------------------------------------------------------------------- 1 | /*! 2 | 3 | @Title: layui.upload 单文件上传 - 全浏览器兼容版 4 | @Author: 贤心 5 | @License:LGPL 6 | 7 | */ 8 | 9 | layui.define('layer' , function(exports){ 10 | "use strict"; 11 | 12 | var $ = layui.jquery; 13 | var layer = layui.layer; 14 | var device = layui.device(); 15 | 16 | var elemDragEnter = 'layui-upload-enter'; 17 | var elemIframe = 'layui-upload-iframe'; 18 | 19 | var msgConf = { 20 | icon: 2 21 | ,shift: 6 22 | }, fileType = { 23 | file: '文件' 24 | ,video: '视频' 25 | ,audio: '音频' 26 | }; 27 | 28 | var Upload = function(options){ 29 | this.options = options; 30 | }; 31 | 32 | //初始化渲染 33 | Upload.prototype.init = function(){ 34 | var that = this, options = that.options; 35 | var body = $('body'), elem = $(options.elem || '.layui-upload-file'); 36 | var iframe = $(''); 37 | 38 | //插入iframe 39 | $('#'+elemIframe)[0] || body.append(iframe); 40 | 41 | return elem.each(function(index, item){ 42 | item = $(item); 43 | var form = '
    '; 44 | 45 | var type = item.attr('lay-type') || options.type; //获取文件类型 46 | 47 | //包裹ui元素 48 | if(!options.unwrap){ 49 | form = '
    ' + form + ''+ ( 50 | item.attr('lay-title') || options.title|| ('上传'+ (fileType[type]||'图片') ) 51 | ) +'
    '; 52 | } 53 | 54 | form = $(form); 55 | 56 | //拖拽支持 57 | if(!options.unwrap){ 58 | form.on('dragover', function(e){ 59 | e.preventDefault(); 60 | $(this).addClass(elemDragEnter); 61 | }).on('dragleave', function(){ 62 | $(this).removeClass(elemDragEnter); 63 | }).on('drop', function(){ 64 | $(this).removeClass(elemDragEnter); 65 | }); 66 | } 67 | 68 | //如果已经实例化,则移除包裹元素 69 | if(item.parent('form').attr('target') === elemIframe){ 70 | if(options.unwrap){ 71 | item.unwrap(); 72 | } else { 73 | item.parent().next().remove(); 74 | item.unwrap().unwrap(); 75 | } 76 | }; 77 | 78 | //包裹元素 79 | item.wrap(form); 80 | 81 | //触发上传 82 | item.off('change').on('change', function(){ 83 | that.action(this, type); 84 | }); 85 | }); 86 | }; 87 | 88 | //提交上传 89 | Upload.prototype.action = function(input, type){ 90 | var that = this, options = that.options, val = input.value; 91 | var item = $(input), ext = item.attr('lay-ext') || options.ext || ''; //获取支持上传的文件扩展名; 92 | 93 | if(!val){ 94 | return; 95 | }; 96 | 97 | //校验文件 98 | switch(type){ 99 | case 'file': //一般文件 100 | if(ext && !RegExp('\\w\\.('+ ext +')$', 'i').test(escape(val))){ 101 | layer.msg('不支持该文件格式', msgConf); 102 | return input.value = ''; 103 | } 104 | break; 105 | case 'video': //视频文件 106 | if(!RegExp('\\w\\.('+ (ext||'avi|mp4|wma|rmvb|rm|flash|3gp|flv') +')$', 'i').test(escape(val))){ 107 | layer.msg('不支持该视频格式', msgConf); 108 | return input.value = ''; 109 | } 110 | break; 111 | case 'audio': //音频文件 112 | if(!RegExp('\\w\\.('+ (ext||'mp3|wav|mid') +')$', 'i').test(escape(val))){ 113 | layer.msg('不支持该音频格式', msgConf); 114 | return input.value = ''; 115 | } 116 | break; 117 | default: //图片文件 118 | if(!RegExp('\\w\\.('+ (ext||'jpg|png|gif|bmp|jpeg') +')$', 'i').test(escape(val))){ 119 | layer.msg('不支持该图片格式', msgConf); 120 | return input.value = ''; 121 | } 122 | break; 123 | } 124 | 125 | options.before && options.before(input); 126 | item.parent().submit(); 127 | 128 | var iframe = $('#'+elemIframe), timer = setInterval(function() { 129 | var res; 130 | try { 131 | res = iframe.contents().find('body').text(); 132 | } catch(e) { 133 | layer.msg('上传接口存在跨域', msgConf); 134 | clearInterval(timer); 135 | } 136 | if(res){ 137 | clearInterval(timer); 138 | iframe.contents().find('body').html(''); 139 | try { 140 | res = JSON.parse(res); 141 | } catch(e){ 142 | res = {}; 143 | return layer.msg('请对上传接口返回JSON字符', msgConf); 144 | } 145 | typeof options.success === 'function' && options.success(res, input); 146 | } 147 | }, 30); 148 | 149 | input.value = ''; 150 | }; 151 | 152 | //暴露接口 153 | exports('upload', function(options){ 154 | var upload = new Upload(options = options || {}); 155 | upload.init(); 156 | }); 157 | }); 158 | 159 | -------------------------------------------------------------------------------- /src/main/resources/static/layui/lay/modules/util.js: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | @Name:layui.util 工具集 4 | @Author:贤心 5 | @License:LGPL 6 | 7 | */ 8 | 9 | layui.define('jquery', function(exports){ 10 | "use strict"; 11 | 12 | var $ = layui.jquery 13 | 14 | ,util = { 15 | //固定块 16 | fixbar: function(options){ 17 | options = options || {}; 18 | options.bgcolor = options.bgcolor ? ('background-color:' + options.bgcolor) : ''; 19 | 20 | var TOP_BAR = 'layui-fixbar-top', timer, is, icon = [ 21 | options.bar1 === true ? '' : options.bar1 //bar1 - 信息图标 22 | ,options.bar2 === true ? '' : options.bar2 //bar2 - 问号图标 23 | ,'' //置顶 24 | ] 25 | 26 | ,dom = $(['
      ' 27 | ,options.bar1 ? '
    • '+ icon[0] +'
    • ' : '' 28 | ,options.bar2 ? '
    • '+ icon[1] +'
    • ' : '' 29 | ,'
    • '+ icon[2] +'
    • ' 30 | ,'
    '].join('')) 31 | 32 | ,topbar = dom.find('.'+TOP_BAR) 33 | 34 | ,scroll = function(){ 35 | var stop = $(document).scrollTop(); 36 | if(stop >= (options.showHeight || 200)){ 37 | is || (topbar.show(), is = 1); 38 | } else { 39 | is && (topbar.hide(), is = 0); 40 | } 41 | }; 42 | 43 | if($('.layui-fixbar')[0]) return; 44 | typeof options.css === 'object' && (dom.css(options.css)); 45 | $('body').append(dom), scroll(); 46 | 47 | //bar点击事件 48 | dom.find('li').on('click', function(){ 49 | var othis = $(this), type = othis.attr('lay-type'); 50 | if(type === 'top'){ 51 | $('html,body').animate({ 52 | scrollTop : 0 53 | }, 200);; 54 | } 55 | options.click && options.click.call(this, type); 56 | }); 57 | 58 | //Top显示控制 59 | $(document).on('scroll', function(){ 60 | if(timer) clearTimeout(timer); 61 | timer = setTimeout(function(){ 62 | scroll(); 63 | }, 100); 64 | }); 65 | } 66 | }; 67 | 68 | exports('util', util); 69 | }); -------------------------------------------------------------------------------- /src/main/resources/static/layui/更新日志.txt: -------------------------------------------------------------------------------- 1 |  2 | # v3.0.1 Pro版 2016.12.10 3 | 4 | * 扩展工具栏的事件体增加第二个参数:send,用于自动发送,而不是插入到编辑器中。 5 | * 扩展工具栏的事件体增加第三个参数:obj,用于获得当前聊天窗口的elem、data等数据 6 | * layim.getMessage() 增加了消息id:cid参数的支持,会赋值在li的data-cid上,以便完成一些消息的操作(如撤回) 7 | * layim.getMessage() 增加了fromid参数,即消息来源者的id,可用于自动解决浏览器多窗口时的一些问题 8 | 9 | * 修复打开多浏览器窗口时,聊天记录重复保存的bug 10 | * 修复移动版点击图片和文件上传报错的bug 11 | * 解决上传部分格式的文件,点击时直接被浏览器预览而无法下载的问题 12 | 13 | 14 | --- 15 | 16 | # v3.0 Pro版 2016.12.07 17 | 18 | * 最新Layui提供强力支撑 19 | * 新增聊天面板最大化显示功能 20 | * 新增聊天面板拖拽右下角调整窗口大小功能,是不是碉堡了 ^_^ 21 | * 内置LayIM移动端会话界面,接口与PC版几乎完全一致 22 | 23 | * 新增扩展聊天面板工具栏接口 24 | * 新增桌面消息提醒功能(即浏览器之外的提醒) 25 | * 新增消息声音提醒功能 26 | * 新增添加好友/群组的弹出面板 27 | * 新增“消息盒子”、“聊天记录”的内置模版 28 | * 新增“消息盒子”消息数提醒功能(仅限好友、群组申请的系统消息) 29 | * 新增主面板直接修改签名功能 30 | * 新增好友聊天面板的状态区域,通过方法layim.setChatStatus(str),可用于显示:对方输入状态、在线离线状态等 31 | * 新增聊天区域的系统消息支持,如:xxx加入群 等。(该功能需在聊天窗口打开状态才会显示其内) 32 | * 新增群聊面板的群员私聊会话支持 33 | * 新增好友置灰、和取消置灰接口 34 | * 新增主面板底部“消息盒子”入口 35 | * 新增了一套内置的背景图 36 | * 新增layim.config()参数tool,用于扩展聊天面板工具栏 37 | * 新增layim.config()参数initSkin,用于初始时默认背景的设置 38 | * 新增layim.config()参数notice,用于控制是否开启桌面消息提醒,默认开启 39 | * 新增layim.config()参数voice,用于设置消息声音源,默认播放内置声音。若不开启,设置 false即可 40 | 41 | * 图片和文件改为上传成功即自动发送 42 | * layim.config()的init参数支持直接赋值列表数据,且对ajax接口配置方式仍然支持 43 | * 剔除layim.config()的mine参数,通过init中配置mine取代 44 | * init初始化信息的friend集合中,新增了status字段,若值为offline代表离线,online为在线 45 | * 优化消息快捷键的相关代码 46 | * 去除面板上双击的默认选中蓝色背景 47 | * 诸多样式细节的完善 48 | 49 | -------------------------------------------------------------------------------- /src/main/resources/static/layui/说明.txt: -------------------------------------------------------------------------------- 1 | =============== 2 | 目录说明 3 | =============== 4 | 5 | ./layui 目录下是经过压缩后的代码(包括LayIM) 6 | ./source/layui 目录下Layui源代码(包括LayIM的源代码,标准版无此目录) 7 | 8 | =============== 9 | 使用说明 10 | =============== 11 | 12 | LayIM基于layui模块体系,因此你获得的其实是一个包含LayIM的layui框架,不同的是,开源版的layui并不包含LayIM。捐助后,将您获得的压缩包解压,将layui整个目录文件放入你的项目后,不用再对其代码做任何修改(方便下次升级)。然后您只需引入下述两个文件即可。 13 | 14 | ./layui/css/layui.css 15 | ./layui/layui.js 16 | 17 | 18 | =============== 19 | 官网文档 20 | =============== 21 | 22 | 官网:http://layim.layui.com/ 23 | 接口文档:http://www.layui.com/doc/layim.html 24 | 授权通道:http://fly.layui.com/auth/get/ 25 | 26 | 27 | =============== 28 | 关于版权 29 | =============== 30 | 31 | LayIM目前并非开源产品(以后也许会开源),因此如果你是通过捐助渠道获得LayIM,可以通过layer.config设定copyright: true来剔除LayIM主面板的关于信息,这就表示你已经过授权。当然,如果你想友好地保留,我们也是非常欢迎的。如果你通过非捐助渠道获得LayIM,我们并不会进行追究,但是请勿进行销售,这是唯一的红线吧。 32 | 33 | 另外,再次强调一点:LayIM虽然并不开源,但layui是完全免费且开源的。LayIM是我们为数不多的接受收费的产品。因为一定资金的来源,是对我们整个开发流可持续发展的有力保障。仍然是那句话,如果你对LayIM的“收费”表示厌恶,请忽视它的存在。即便是没有一个人为LayIM买单,我们仍然会坚持初衷,即:通过极简的体验,拉近你的用户在web间的距离。 34 | 35 | LayIM的作者是贤心一人,版权最终解释权归他所有。 36 | 37 | -------------------------------------------------------------------------------- /src/main/resources/static/login.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | LayIM 登陆 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |
    13 |
    14 |

    聊天室登录

    15 |
    16 |
    17 |
    18 |
    19 |
    20 |
    21 |

    登陆

    22 |

    23 | 24 | 25 |

    26 |

    27 | 28 | 30 |

    31 |

    32 | 33 | 34 |

    35 | 38 | 42 |
    43 |
    44 |
    45 |
    46 |
    47 |
    48 | 82 | 83 | -------------------------------------------------------------------------------- /src/main/resources/static/protobuf/gps_data.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | message gps_data { 4 | int64 id = 1; 5 | string terminalId = 2; 6 | string dataTime = 3; 7 | double lon = 4; 8 | double lat = 5; 9 | float speed = 6; 10 | int32 altitude = 7; 11 | int32 locType = 8; 12 | int32 gpsStatus = 9; 13 | float direction = 10; 14 | int32 satellite = 11; 15 | } -------------------------------------------------------------------------------- /src/main/resources/static/themes/bg1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/themes/bg1.jpg -------------------------------------------------------------------------------- /src/main/resources/static/themes/bg1_small.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/themes/bg1_small.jpg -------------------------------------------------------------------------------- /src/main/resources/static/themes/bg2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/themes/bg2.jpg -------------------------------------------------------------------------------- /src/main/resources/static/themes/bg2_small.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/themes/bg2_small.jpg -------------------------------------------------------------------------------- /src/main/resources/static/themes/bg3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/themes/bg3.jpg -------------------------------------------------------------------------------- /src/main/resources/static/themes/bg3_small.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/themes/bg3_small.jpg -------------------------------------------------------------------------------- /src/main/resources/static/themes/bg4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/themes/bg4.jpg -------------------------------------------------------------------------------- /src/main/resources/static/themes/bg4_small.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/themes/bg4_small.jpg -------------------------------------------------------------------------------- /src/main/resources/static/themes/bg5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/themes/bg5.jpg -------------------------------------------------------------------------------- /src/main/resources/static/themes/bg5_small.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githuanl/spring-boot-netty-socket.io---chat/6dc439f9e22f120b883b44acc9b14eafa2745529/src/main/resources/static/themes/bg5_small.jpg -------------------------------------------------------------------------------- /src/test/java/com/neo/ApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.neo; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class ApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | System.out.println("hello world"); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/test/java/com/neo/dao/UserDaoTest.java: -------------------------------------------------------------------------------- 1 | package com.neo.dao; 2 | 3 | import com.google.protobuf.InvalidProtocolBufferException; 4 | import com.neo.entity.GpsData; 5 | import com.neo.entity.GroupEntity; 6 | import com.neo.entity.UserEntity; 7 | import com.neo.serivce.GroupSerivice; 8 | import com.neo.serivce.UserSerivice; 9 | import org.junit.Test; 10 | import org.junit.runner.RunWith; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.boot.test.context.SpringBootTest; 13 | import org.springframework.test.context.junit4.SpringRunner; 14 | 15 | import javax.servlet.http.HttpSession; 16 | 17 | /** 18 | * Created by summer on 2017/5/5. 19 | */ 20 | @RunWith(SpringRunner.class) 21 | @SpringBootTest 22 | public class UserDaoTest { 23 | 24 | @Autowired 25 | private UserSerivice serivice; 26 | 27 | @Autowired 28 | private GroupSerivice groupSerivice; 29 | 30 | @Autowired 31 | protected HttpSession session; 32 | 33 | @Test 34 | public void testSaveUser() throws Exception { 35 | 36 | 37 | UserEntity user = serivice.register("123", "111", "http://tva1.sinaimg.cn/crop.0.0.118.118.180/5db11ff4gw1e77d3nqrv8j203b03cweg.jpg"); 38 | System.out.println("已生成ID:" + user.getId()); 39 | user = serivice.register("111", "111", "http://tva4.sinaimg.cn/crop.0.1.1125.1125.180/475bb144jw8f9nwebnuhkj20v90vbwh9.jpg"); 40 | System.out.println("已生成ID:" + user.getId()); 41 | user = serivice.register("马云", "111", "http://tva1.sinaimg.cn/crop.0.0.118.118.180/5db11ff4gw1e77d3nqrv8j203b03cweg.jpg"); 42 | System.out.println("已生成ID:" + user.getId()); 43 | 44 | user = serivice.register("刘流", "111", "http://tva1.sinaimg.cn/crop.0.0.512.512.180/6a4acad5jw8eqi6yaholjj20e80e8t9f.jpg"); 45 | System.out.println("已生成ID======:" + user.getId()); 46 | 47 | creatGroup(); 48 | 49 | } 50 | 51 | public void creatGroup() throws Exception { 52 | // UserEntity user = new UserEntity(); 53 | // user.setAuth_token(UUID.randomUUID().toString()); 54 | // user.setUsername("90905555"); 55 | // user.setPassword("456"); 56 | // serivice.saveEntity(user); 57 | 58 | UserEntity user = serivice.findUserByUserName("123"); 59 | session.setAttribute("username", user); 60 | 61 | GroupEntity entity = groupSerivice.creatGroup("前端群", "http://tva1.sinaimg.cn/crop.0.0.200.200.50/006q8Q6bjw8f20zsdem2mj305k05kdfw.jpg", user); 62 | System.out.println("已生成ID:" + entity.getId()); 63 | 64 | entity = groupSerivice.creatGroup("后端群", "http://tva2.sinaimg.cn/crop.0.0.199.199.180/005Zseqhjw1eplix1brxxj305k05kjrf.jpg", user); 65 | System.out.println("已生成ID:" + entity.getId()); 66 | 67 | entity = groupSerivice.creatGroup("UI设计", "http://tva2.sinaimg.cn/crop.0.8.751.751.180/961a9be5jw8fczq7q98i7j20kv0lcwfn.jpg", user); 68 | System.out.println("已生成ID:" + entity.getId()); 69 | 70 | } 71 | 72 | 73 | @Test 74 | public void testProutobu() throws InvalidProtocolBufferException { 75 | //模拟将对象转成byte[],方便传输 76 | GpsData.gps_data.Builder builder = GpsData.gps_data.newBuilder(); 77 | builder.setId(1); 78 | builder.setDataTime("2018-07-03"); 79 | GpsData.gps_data bd = builder.build(); 80 | System.out.println("before :"+ bd.toString()); 81 | 82 | System.out.println("===========Person Byte=========="); 83 | for(byte b : bd.toByteArray()){ 84 | System.out.print(b); 85 | } 86 | System.out.println(); 87 | System.out.println(bd.toByteString()); 88 | System.out.println("================================"); 89 | 90 | //模拟接收Byte[],反序列化成Person类 91 | byte[] byteArray =bd.toByteArray(); 92 | GpsData.gps_data gps_data = GpsData.gps_data.parseFrom(byteArray); 93 | System.out.println("after :" +gps_data.toString()); 94 | } 95 | 96 | 97 | } 98 | --------------------------------------------------------------------------------