Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
梦境迷离
Sim
提交
90273d7d
S
Sim
项目概览
梦境迷离
/
Sim
9 个月 前同步成功
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
Sim
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
90273d7d
编写于
11月 25, 2021
作者:
梦境迷离
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
重构++
上级
6a1786c2
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
44 addition
and
44 deletion
+44
-44
deploy.sh
deploy.sh
+2
-1
src/main/scala/io/github/dreamylost/Application.scala
src/main/scala/io/github/dreamylost/Application.scala
+3
-2
src/main/scala/io/github/dreamylost/config/CacheConfig.scala
src/main/scala/io/github/dreamylost/config/CacheConfig.scala
+7
-4
src/main/scala/io/github/dreamylost/config/DruidConfig.scala
src/main/scala/io/github/dreamylost/config/DruidConfig.scala
+1
-1
src/main/scala/io/github/dreamylost/config/RedisConfig.scala
src/main/scala/io/github/dreamylost/config/RedisConfig.scala
+1
-1
src/main/scala/io/github/dreamylost/config/Swagger2Config.scala
...in/scala/io/github/dreamylost/config/Swagger2Config.scala
+1
-1
src/main/scala/io/github/dreamylost/controller/UserController.scala
...cala/io/github/dreamylost/controller/UserController.scala
+17
-18
src/main/scala/io/github/dreamylost/service/MailService.scala
...main/scala/io/github/dreamylost/service/MailService.scala
+2
-2
src/main/scala/io/github/dreamylost/service/UserService.scala
...main/scala/io/github/dreamylost/service/UserService.scala
+7
-10
src/main/scala/io/github/dreamylost/websocket/RedisService.scala
...n/scala/io/github/dreamylost/websocket/RedisService.scala
+1
-2
src/main/scala/io/github/dreamylost/websocket/WebSocketService.scala
...ala/io/github/dreamylost/websocket/WebSocketService.scala
+1
-1
src/main/webapp/WEB-INF/view/chatLog.jsp
src/main/webapp/WEB-INF/view/chatLog.jsp
+1
-1
未找到文件。
deploy.sh
浏览文件 @
90273d7d
#!/bin/bash
version
=
$1
git pull origin master
# gradle build
gradle bootRepackage
nohup
java
-jar
dist/LayIM-
1.2.1
.jar
>
layim.log 2>&1 &
nohup
java
-jar
dist/LayIM-
$version
.jar
>
layim.log 2>&1 &
tail
-f
layim.log
src/main/scala/io/github/dreamylost/Application.scala
浏览文件 @
90273d7d
...
...
@@ -22,11 +22,12 @@ object Application extends SpringBootServletInitializer {
@BeanProperty
var
applicationContext
:
ApplicationContext
=
null
def
main
(
args
:
Array
[
String
])
=
def
main
(
args
:
Array
[
String
])
:
Unit
=
applicationContext
=
{
SpringApplication
.
run
(
classOf
[
Config
])
}
override
protected
def
configure
(
builder
:
SpringApplicationBuilder
)
=
builder
.
sources
(
Application
)
override
protected
def
configure
(
builder
:
SpringApplicationBuilder
)
:
SpringApplicationBuilder
=
builder
.
sources
(
Application
)
}
src/main/scala/io/github/dreamylost/config/CacheConfig.scala
浏览文件 @
90273d7d
...
...
@@ -17,6 +17,7 @@ import org.springframework.data.redis.core.RedisTemplate
import
org.springframework.data.redis.core.StringRedisTemplate
import
org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer
import
org.springframework.data.redis.serializer.StringRedisSerializer
import
com.fasterxml.jackson.databind.jsontype.impl.LaissezFaireSubTypeValidator
import
com.fasterxml.jackson.annotation.JsonInclude
import
com.fasterxml.jackson.databind.DeserializationFeature
...
...
@@ -47,7 +48,7 @@ class CacheConfig extends CachingConfigurerSupport {
val
cacheManager
=
new
RedisCacheManager
(
redisTemplate
)
//设置key-value过期时间
cacheManager
.
setDefaultExpiration
(
timeout
)
LOGGER
.
info
(
"
初始化Redis缓存管理器完成!
"
)
LOGGER
.
info
(
"
Init the CacheManager Finished
"
)
cacheManager
}
...
...
@@ -79,16 +80,18 @@ class CacheConfig extends CachingConfigurerSupport {
}
private
def
setSerializer
(
template
:
StringRedisTemplate
)
:
Unit
=
{
import
com.fasterxml.jackson.databind.jsontype.impl.LaissezFaireSubTypeValidator
val
objectMapper
=
new
ObjectMapper
()
with
ScalaObjectMapper
objectMapper
.
setVisibility
(
PropertyAccessor
.
ALL
,
JsonAutoDetect
.
Visibility
.
ANY
)
objectMapper
.
setSerializationInclusion
(
JsonInclude
.
Include
.
NON_EMPTY
)
objectMapper
.
configure
(
DeserializationFeature
.
FAIL_ON_UNKNOWN_PROPERTIES
,
false
)
objectMapper
.
configure
(
SerializationFeature
.
WRITE_NULL_MAP_VALUES
,
false
)
objectMapper
.
registerModule
(
DefaultScalaModule
)
objectMapper
.
activateDefaultTyping
(
LaissezFaireSubTypeValidator
.
instance
,
ObjectMapper
.
DefaultTyping
.
EVERYTHING
)
objectMapper
.
activateDefaultTyping
(
LaissezFaireSubTypeValidator
.
instance
,
ObjectMapper
.
DefaultTyping
.
EVERYTHING
)
// 必须使用这个序列化Scala+List
// 必须使用这个序列化Scala+
java.util.
List
val
genericJackson2JsonRedisSerializer
=
new
GenericJackson2JsonRedisSerializer
(
objectMapper
)
template
.
setKeySerializer
(
new
StringRedisSerializer
())
template
.
setDefaultSerializer
(
genericJackson2JsonRedisSerializer
)
...
...
src/main/scala/io/github/dreamylost/config/DruidConfig.scala
浏览文件 @
90273d7d
...
...
@@ -7,7 +7,7 @@ import org.springframework.boot.web.servlet.ServletRegistrationBean
import
org.springframework.context.annotation.Bean
import
org.springframework.context.annotation.Configuration
import
scala.
collection.Java
Converters._
import
scala.
jdk.Collection
Converters._
/** Alibaba Druid数据源配置
*
...
...
src/main/scala/io/github/dreamylost/config/RedisConfig.scala
浏览文件 @
90273d7d
...
...
@@ -10,7 +10,7 @@ import redis.clients.jedis.JedisPoolConfig
/** redis连接配置
*
* @
dat
e 2018年9月8日
* @
sinc
e 2018年9月8日
* @author 梦境迷离
*/
@Configuration
...
...
src/main/scala/io/github/dreamylost/config/Swagger2Config.scala
浏览文件 @
90273d7d
...
...
@@ -40,7 +40,7 @@ class Swagger2Config {
// 创建人
.
contact
(
"梦境迷离"
)
// 版本号
.
version
(
"1.
2
"
)
.
version
(
"1.
3
"
)
.
build
()
}
src/main/scala/io/github/dreamylost/controller/UserController.scala
浏览文件 @
90273d7d
...
...
@@ -54,8 +54,7 @@ class UserController @Autowired() (userService: UserService, cookieService: Cook
)
:
ResultSet
=
{
val
user
=
request
.
getSession
.
getAttribute
(
"user"
).
asInstanceOf
[
User
]
val
result
=
userService
.
leaveOutGroup
(
groupId
,
user
.
id
)
if
(
result
)
ResultSet
(
code
=
SystemConstant
.
SUCCESS
,
msg
=
SystemConstant
.
SUCCESS_MESSAGE
)
if
(
result
)
ResultSet
(
code
=
SystemConstant
.
SUCCESS
,
msg
=
SystemConstant
.
SUCCESS_MESSAGE
)
else
ResultSet
(
code
=
SystemConstant
.
ERROR
,
msg
=
SystemConstant
.
LEAVEOUT_GROUP_ERROR
)
}
...
...
@@ -107,8 +106,7 @@ class UserController @Autowired() (userService: UserService, cookieService: Cook
@RequestParam
(
"messageBoxId"
)
messageBoxId
:
Integer
,
request
:
HttpServletRequest
)
:
ResultSet
=
{
val
result
=
userService
.
updateAddMessage
(
messageBoxId
,
2
)
ResultSet
(
result
)
ResultSet
(
userService
.
updateAddMessage
(
messageBoxId
,
2
))
}
/** 同意添加好友
...
...
@@ -130,8 +128,7 @@ class UserController @Autowired() (userService: UserService, cookieService: Cook
)
:
ResultSet
=
{
val
user
=
request
.
getSession
.
getAttribute
(
"user"
).
asInstanceOf
[
User
]
val
result
=
userService
.
addFriend
(
user
.
id
,
group
,
uid
,
fromGroup
,
messageBoxId
)
if
(!
result
)
ResultSet
(
code
=
SystemConstant
.
ERROR
,
msg
=
SystemConstant
.
ERROR_ADD_REPETITION
)
if
(!
result
)
ResultSet
(
code
=
SystemConstant
.
ERROR
,
msg
=
SystemConstant
.
ERROR_ADD_REPETITION
)
else
ResultSet
(
result
)
}
...
...
@@ -251,8 +248,8 @@ class UserController @Autowired() (userService: UserService, cookieService: Cook
val
user
=
request
.
getSession
.
getAttribute
(
"user"
).
asInstanceOf
[
User
]
PageHelper
.
startPage
(
page
,
SystemConstant
.
SYSTEM_PAGE
)
//查找聊天记录
val
histor
y
s
:
util.List
[
ChatHistory
]
=
userService
.
findHistoryMessage
(
user
,
id
,
`type`
)
ResultSet
(
histor
y
s
)
val
histor
ie
s
:
util.List
[
ChatHistory
]
=
userService
.
findHistoryMessage
(
user
,
id
,
`type`
)
ResultSet
(
histor
ie
s
)
}
/** 弹出聊天记录页面
...
...
@@ -404,9 +401,9 @@ class UserController @Autowired() (userService: UserService, cookieService: Cook
@RequestParam
(
"file"
)
file
:
MultipartFile
,
request
:
HttpServletRequest
)
:
ResultSet
=
{
if
(
file
.
isEmpty
)
if
(
file
.
isEmpty
)
{
ResultSet
(
code
=
SystemConstant
.
ERROR
,
msg
=
SystemConstant
.
UPLOAD_FAIL
)
else
{
}
else
{
val
path
=
request
.
getServletContext
.
getRealPath
(
"/"
)
val
src
=
FileUtil
.
upload
(
SystemConstant
.
IMAGE_PATH
,
path
,
file
)
val
result
=
new
util
.
HashMap
[
String
,
String
]
...
...
@@ -455,9 +452,10 @@ class UserController @Autowired() (userService: UserService, cookieService: Cook
return
ResultSet
(
code
=
SystemConstant
.
ERROR
,
msg
=
SystemConstant
.
CREATE_GROUP_ERROR
)
}
if
(
userService
.
addGroupMember
(
ret
,
groupList
.
createId
))
{
return
ResultSet
(
code
=
SystemConstant
.
SUCCESS
,
msg
=
SystemConstant
.
CREATE_GROUP_SUCCCESS
)
ResultSet
(
code
=
SystemConstant
.
SUCCESS
,
msg
=
SystemConstant
.
CREATE_GROUP_SUCCCESS
)
}
else
{
ResultSet
(
code
=
SystemConstant
.
ERROR
,
msg
=
SystemConstant
.
CREATE_GROUP_ERROR
)
}
ResultSet
(
code
=
SystemConstant
.
ERROR
,
msg
=
SystemConstant
.
CREATE_GROUP_ERROR
)
}
/** 用户创建好友分组
...
...
@@ -470,9 +468,10 @@ class UserController @Autowired() (userService: UserService, cookieService: Cook
def
createUserGroup
(
@RequestBody
friendGroup
:
FriendGroup
)
:
ResultSet
=
{
val
ret
=
userService
.
createFriendGroup
(
friendGroup
.
groupname
,
friendGroup
.
uid
)
if
(!
ret
)
{
return
ResultSet
(
code
=
SystemConstant
.
ERROR
,
msg
=
SystemConstant
.
CREATE_USER_GROUP_ERROR
)
ResultSet
(
code
=
SystemConstant
.
ERROR
,
msg
=
SystemConstant
.
CREATE_USER_GROUP_ERROR
)
}
else
{
ResultSet
(
code
=
SystemConstant
.
SUCCESS
,
msg
=
SystemConstant
.
CREATE_USER_GROUP_SUCCCESS
)
}
ResultSet
(
code
=
SystemConstant
.
SUCCESS
,
msg
=
SystemConstant
.
CREATE_USER_GROUP_SUCCCESS
)
}
/** 客户端上传文件
...
...
@@ -487,9 +486,9 @@ class UserController @Autowired() (userService: UserService, cookieService: Cook
@RequestParam
(
"file"
)
file
:
MultipartFile
,
request
:
HttpServletRequest
)
:
ResultSet
=
{
if
(
file
.
isEmpty
)
if
(
file
.
isEmpty
)
{
ResultSet
(
code
=
SystemConstant
.
ERROR
,
msg
=
SystemConstant
.
UPLOAD_FAIL
)
else
{
}
else
{
val
path
=
request
.
getServletContext
.
getRealPath
(
"/"
)
val
src
=
FileUtil
.
upload
(
SystemConstant
.
FILE_PATH
,
path
,
file
)
val
result
=
new
util
.
HashMap
[
String
,
String
]
...
...
@@ -529,9 +528,9 @@ class UserController @Autowired() (userService: UserService, cookieService: Cook
@ResponseBody
@PostMapping
(
Array
(
"/updateInfo"
))
def
updateAvatar
(
@RequestBody
user
:
UserVo
)
:
ResultSet
=
{
if
(
user
==
null
)
if
(
user
==
null
)
{
ResultSet
(
code
=
SystemConstant
.
ERROR
,
msg
=
SystemConstant
.
UPDATE_INFO_FAIL
)
else
{
}
else
{
val
u
=
userService
.
findUserById
(
user
.
id
)
val
sex
=
if
(
user
.
sex
.
equals
(
"nan"
))
1
else
0
//前台明文传输,有安全问题
...
...
src/main/scala/io/github/dreamylost/service/MailService.scala
浏览文件 @
90273d7d
...
...
@@ -15,7 +15,7 @@ import javax.mail.MessagingException
/** 邮件发送相关服务
*
* @
dat
e 2018年9月9日
* @
sinc
e 2018年9月9日
* @author 梦境迷离
*/
@Service
...
...
@@ -32,7 +32,7 @@ class MailService @Autowired() (sender: JavaMailSender) {
* @param subject 主题
* @param content 内容
*/
def
sendSimpleMail
(
to
:
String
,
subject
:
String
,
content
:
String
)
=
{
def
sendSimpleMail
(
to
:
String
,
subject
:
String
,
content
:
String
)
:
Unit
=
{
val
message
=
new
SimpleMailMessage
message
.
setFrom
(
username
)
message
.
setTo
(
to
)
...
...
src/main/scala/io/github/dreamylost/service/UserService.scala
浏览文件 @
90273d7d
...
...
@@ -417,9 +417,9 @@ class UserService @Autowired() (userRepository: UserRepository, mailService: Mai
* @return User
*/
def
matchUser
(
user
:
User
)
:
User
=
{
if
(
user
==
null
||
user
.
email
==
null
)
if
(
user
==
null
||
user
.
email
==
null
)
{
null
else
{
}
else
{
val
u
:
User
=
userRepository
.
matchUser
(
user
.
email
)
//密码不匹配
if
(
u
==
null
||
!
SecurityUtil
.
matchs
(
user
.
password
,
u
.
password
))
{
...
...
@@ -461,9 +461,7 @@ class UserService @Autowired() (userRepository: UserRepository, mailService: Mai
* @return User
*/
@Cacheable
(
value
=
Array
(
"findUserById"
),
keyGenerator
=
"wiselyKeyGenerator"
)
def
findUserById
(
id
:
Int
)
:
User
=
{
userRepository
.
findUserById
(
id
)
}
def
findUserById
(
id
:
Int
)
:
User
=
userRepository
.
findUserById
(
id
)
/** 根据用户ID查询用户的群组列表
*
...
...
@@ -471,9 +469,7 @@ class UserService @Autowired() (userRepository: UserRepository, mailService: Mai
* @return List[GroupList]
*/
@Cacheable
(
value
=
Array
(
"findGroupsById"
),
keyGenerator
=
"wiselyKeyGenerator"
)
def
findGroupsById
(
id
:
Int
)
:
util.List
[
GroupList
]
=
{
userRepository
.
findGroupsById
(
id
)
}
def
findGroupsById
(
id
:
Int
)
:
util.List
[
GroupList
]
=
userRepository
.
findGroupsById
(
id
)
/** 保存用户信息
*
...
...
@@ -488,8 +484,9 @@ class UserService @Autowired() (userRepository: UserRepository, mailService: Mai
)
@Transactional
def
saveUser
(
user
:
User
,
request
:
HttpServletRequest
)
:
Boolean
=
{
if
(
user
==
null
||
user
.
username
==
null
||
user
.
password
==
null
||
user
.
email
==
null
)
false
else
{
if
(
user
==
null
||
user
.
username
==
null
||
user
.
password
==
null
||
user
.
email
==
null
)
{
false
}
else
{
//激活码
val
activeCode
=
UUIDUtil
.
getUUID64String
()
val
userCopy
=
user
.
copy
(
...
...
src/main/scala/io/github/dreamylost/websocket/RedisService.scala
浏览文件 @
90273d7d
...
...
@@ -7,7 +7,6 @@ import org.springframework.data.redis.core.RedisTemplate
import
org.springframework.stereotype.Service
import
java.util
import
java.util.Set
import
java.util.concurrent.TimeUnit
/** redis操作
...
...
@@ -113,7 +112,7 @@ class RedisService @Autowired() (redisTemplate: RedisTemplate[String, String]) {
* @param keyParttern
*/
def
removePattern
(
keyParttern
:
String
)
:
Unit
=
{
val
keys
:
Set
[
String
]
=
redisTemplate
.
keys
(
keyParttern
)
val
keys
=
redisTemplate
.
keys
(
keyParttern
)
if
(
keys
.
size
()
>
0
)
redisTemplate
.
delete
(
keys
)
}
}
src/main/scala/io/github/dreamylost/websocket/WebSocketService.scala
浏览文件 @
90273d7d
...
...
@@ -17,7 +17,7 @@ import org.slf4j.LoggerFactory
import
java.util
import
java.util.concurrent.ConcurrentHashMap
import
scala.
collection.Java
Converters._
import
scala.
jdk.Collection
Converters._
/** WebSocket 单例
*
...
...
src/main/webapp/WEB-INF/view/chatLog.jsp
浏览文件 @
90273d7d
...
...
@@ -47,7 +47,7 @@ layui.use(['layim', 'laypage'], function(){
url
:
"
${pageContext.request.contextPath}/user/chatLog
"
,
dataType
:
"
JSON
"
,
type
:
"
POST
"
,
data
:{
"
id
"
:
$
{
id
},
"
type
"
:
'
${
T
ype}
'
,
"
page
"
:
curr
},
data
:{
"
id
"
:
$
{
id
},
"
type
"
:
'
${
t
ype}
'
,
"
page
"
:
curr
},
success
:
function
(
data
)
{
if
(
data
.
data
.
length
!=
0
)
{
var
html
=
laytpl
(
LAY_tpl
.
value
).
render
({
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录