Skip to content

Commit

Permalink
v1.4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
hacker committed Sep 5, 2018
1 parent ff7a241 commit fe07c2f
Show file tree
Hide file tree
Showing 21 changed files with 738 additions and 36 deletions.
22 changes: 14 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# SBToNettyChat(当前版本1.3.0
# SBToNettyChat(当前版本1.4.1

## 简介
仿微信聊天应用,一步一步更新,基于SpringBoot-WebSocket通用框架,结合Netty进行聊天社交,并记录聊天日志,异步存储
仿微信聊天应用,一步一步更新,基于SpringBoot-WebSocket通用框架,结合Netty进行聊天社交,并记录聊天日志,异步存储,前端暂用SUI Mobile

## 特点
异步处理,netty实时消息通信,JPA,WebSocket,数据库操作记录,聊天历史等,1.2(修复bug),1.3(用户登录、防止二次登录)
异步处理,netty实时消息通信,JPA,WebSocket,数据库操作记录,聊天历史等,1.2(修复bug),1.3(用户登录、防止二次登录),1.4.1(前端模块确定SUI Mobile,仿微信样式)

## 功能

Expand All @@ -13,6 +13,7 @@
获取聊天历史
用户登录、记录登录用户聊天历史
防止二次登录
SUI Mobile仿微信样式
下版(1.5.0):好友功能等

## 相关项目
Expand Down Expand Up @@ -54,17 +55,22 @@ SpringBoot集成了WebSocket所以开发通信流比较简单,Netty是一个

用户注册登录功能,系统聊天绑定用户,禁止二次登录等,前端页面大改

* 1.4.1版本

本人主导SUI Mobile构建仿微信样式页面版,使用时开F12手机界面

## 配置

application.yml 数据库配置
http://localhost:8080/susu/admin/login 启动访问路径
http://localhost:8080/susu/admin/loginsui 启动访问路径

## 效果图

![Image text](https://raw.githubusercontent.com/UncleCatMySelf/img-myself/master/img/nettychat/1.png)
![Image text](https://raw.githubusercontent.com/UncleCatMySelf/img-myself/master/img/nettychat/2.png)
![Image text](https://raw.githubusercontent.com/UncleCatMySelf/img-myself/master/img/nettychat/3.png)
![Image text](https://raw.githubusercontent.com/UncleCatMySelf/img-myself/master/img/nettychat/4.png)
![Image text](https://raw.githubusercontent.com/UncleCatMySelf/img-myself/master/img/nettychat/001%20(5).png)
![Image text](https://raw.githubusercontent.com/UncleCatMySelf/img-myself/master/img/nettychat/001%20(3).png)
![Image text](https://raw.githubusercontent.com/UncleCatMySelf/img-myself/master/img/nettychat/001%20(4).png)
![Image text](https://raw.githubusercontent.com/UncleCatMySelf/img-myself/master/img/nettychat/001%20(2).png)
![Image text](https://raw.githubusercontent.com/UncleCatMySelf/img-myself/master/img/nettychat/001%20(1).png)

## 下载地址

Expand Down
47 changes: 47 additions & 0 deletions h5/home.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>酥酥</title>
<meta name="viewport" content="initial-scale=1, maximum-scale=1">
<link rel="shortcut icon" href="/susu/image/logoSmall.png">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">

<link rel="stylesheet" href="http://g.alicdn.com/msui/sm/0.6.2/css/sm.min.css">
<link rel="stylesheet" href="http://g.alicdn.com/msui/sm/0.6.2/css/sm-extend.min.css">

</head>
<body>
<div class="page">
<header class="bar bar-nav">
<h1 class="title">酥酥</h1>
</header>
<nav class="bar bar-tab">
<a class="tab-item active" href="#">
<span class="icon icon-message"></span>
<span class="tab-label">信息</span>
</a>
<a class="tab-item" href="#">
<span class="icon icon-friends"></span>
<span class="tab-label">通讯录</span>
</a>
<a class="tab-item" href="#">
<span class="icon icon-browser"></span>
<span class="tab-label">发现</span>
</a>
<a class="tab-item" href="#">
<span class="icon icon-me"></span>
<span class="tab-label"></span>
</a>
</nav>
<div class="content">

</div>
</div>
<script type='text/javascript' src='http://g.alicdn.com/sj/lib/zepto/zepto.min.js' charset='utf-8'></script>
<script type='text/javascript' src='http://g.alicdn.com/msui/sm/0.6.2/js/sm.min.js' charset='utf-8'></script>
<script type='text/javascript' src='http://g.alicdn.com/msui/sm/0.6.2/js/sm-extend.min.js' charset='utf-8'></script>
</body>
</html>
67 changes: 67 additions & 0 deletions h5/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>酥酥</title>
<meta name="viewport" content="initial-scale=1, maximum-scale=1">
<!--<link rel="shortcut icon" href="/favicon.ico">-->
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">

<link rel="stylesheet" href="http://g.alicdn.com/msui/sm/0.6.2/css/sm.min.css">
<link rel="stylesheet" href="http://g.alicdn.com/msui/sm/0.6.2/css/sm-extend.min.css">

</head>
<body>
<div class="page-group">
<div class="page page-current">
<!-- 你的html代码 -->
<header class="bar bar-nav">
<h1 class="title">登录</h1>
</header>
<div class="content">
<div class="list-block">
<ul>
<!-- Text inputs -->
<li>
<div class="item-content">
<div class="item-media"><i class="icon icon-form-name"></i></div>
<div class="item-inner">
<div class="item-title label">账号</div>
<div class="item-input">
<input type="text" placeholder="Your name">
</div>
</div>
</div>
</li>
<li>
<div class="item-content">
<div class="item-media"><i class="icon icon-form-password"></i></div>
<div class="item-inner">
<div class="item-title label">密码</div>
<div class="item-input">
<input type="password" placeholder="Password" class="">
</div>
</div>
</div>
</li>
</ul>
</div>
<div class="content-block">
<div class="row">
<div class="col-50"><a href="#" class="button button-big button-fill button-danger">登录</a></div>
<div class="col-50"><a href="#" class="button button-big button-fill button-success">注册</a></div>
</div>
</div>
</div>
<!-- 你的html代码 -->
</div>
</div>

<script type='text/javascript' src='http://g.alicdn.com/sj/lib/zepto/zepto.min.js' charset='utf-8'></script>
<script type='text/javascript' src='http://g.alicdn.com/msui/sm/0.6.2/js/sm.min.js' charset='utf-8'></script>
<script type='text/javascript' src='http://g.alicdn.com/msui/sm/0.6.2/js/sm-extend.min.js' charset='utf-8'></script>

</body>
</html>
Binary file added h5/logoSmall.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 14 additions & 1 deletion src/main/java/com/myself/nettychat/constont/H5Constant.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,21 @@
public interface H5Constant {
//登录页面
String LOGIN = "login/login";
//登录页面
String LOGIN_SUI = "login/loginSui";

//首页2
String HOME = "home/home";
//首页
String INDEX = "index";
//聊天界面
String CHAT = "h5";
//String CHAT = "h5";

String ME = "me/me";

String FIND = "find/find";

String CHAT = "chat/chat";

String ALLCHAT = "chat/allchat";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
package com.myself.nettychat.controller;

import com.myself.nettychat.constont.CookieConstant;
import com.myself.nettychat.constont.H5Constant;
import com.myself.nettychat.dataobject.User;
import com.myself.nettychat.service.UserService;
import com.myself.nettychat.store.TokenStore;
import com.myself.nettychat.utils.CookieUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
* @Author:UncleCatMySelf
* @Email:[email protected]
* @QQ:1341933031
* @Date:Created in 15:59 2018\9\5 0005
*/
@Controller
@RequestMapping("/su")
public class NcChangeController {

@Autowired
private UserService userService;

/**
* 我的中心界面
* @param map
* @return
*/
@GetMapping("/me")
public ModelAndView Me(Map<String,Object> map){
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
HttpServletRequest request = attributes.getRequest();
Cookie cookie = CookieUtil.get(request, CookieConstant.TOKEN);
if (cookie == null){
map.put("msg","cookie中不存在token");
return new ModelAndView(H5Constant.LOGIN_SUI,map);
}
Integer userId = (Integer) TokenStore.get(cookie.getValue());
if (userId == null){
map.put("msg","用户信息不存在");
return new ModelAndView(H5Constant.LOGIN_SUI,map);
}
User user = userService.findOne(userId);
map.put("userName",user.getUserName());
return new ModelAndView(H5Constant.ME,map);
}

/**
* 发现
* @param map
* @return
*/
@GetMapping("/find")
public ModelAndView find(Map<String,Object> map){
return new ModelAndView(H5Constant.FIND);
}

/**
* 聊天
* @param map
* @return
*/
@GetMapping("/chat")
public ModelAndView chat(Map<String,Object> map){
return new ModelAndView(H5Constant.CHAT);
}

/**
* 主页
* @param map
* @return
*/
@GetMapping("/home")
public ModelAndView home(Map<String,Object> map){
return new ModelAndView(H5Constant.HOME);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

import com.myself.nettychat.constont.CookieConstant;
import com.myself.nettychat.constont.H5Constant;
import com.myself.nettychat.dataobject.User;
import com.myself.nettychat.dataobject.UserMsg;
import com.myself.nettychat.repository.UserMsgRepository;
import com.myself.nettychat.service.UserService;
import com.myself.nettychat.store.TokenStore;
import com.myself.nettychat.utils.CookieUtil;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down Expand Up @@ -39,6 +41,9 @@ public class NcChatController {
@Autowired
private UserMsgRepository userMsgRepository;

@Autowired
private UserService userService;

@GetMapping("/netty")
public ModelAndView netty(@RequestParam(value = "page",defaultValue = "1") Integer page,
@RequestParam(value = "size",defaultValue = "10") Integer size,
Expand All @@ -55,6 +60,7 @@ public ModelAndView netty(@RequestParam(value = "page",defaultValue = "1") Integ
map.put("msg","用户信息不存在");
return new ModelAndView(H5Constant.LOGIN,map);
}
User user = userService.findOne(userId);
Sort sort = new Sort(Sort.Direction.DESC,"id");
Pageable pageable = new PageRequest(page-1,size,sort);
Page<UserMsg> userMsgPage = userMsgRepository.findAll(pageable);
Expand All @@ -63,8 +69,9 @@ public ModelAndView netty(@RequestParam(value = "page",defaultValue = "1") Integ
for (int i = 0,j = userMsgPage.getContent().size()-1; i < userMsgPage.getContent().size();i++,j--){
userMsgList.add(userMsgPage.getContent().get(j));
}
map.put("userName",user.getUserName());
map.put("userMsgList",userMsgList);
return new ModelAndView("h5",map);
return new ModelAndView(H5Constant.ALLCHAT,map);
}

}
Loading

0 comments on commit fe07c2f

Please sign in to comment.