Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
cloud-platform
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
youjj
cloud-platform
Commits
9fd85723
Commit
9fd85723
authored
Jun 21, 2019
by
jiaorz
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/base-modify' into base-modify
parents
767f5cac
e758708e
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
1407 additions
and
0 deletions
+1407
-0
MsgBiz.java
...server/src/main/java/com/xxfc/platform/im/biz/MsgBiz.java
+75
-0
AddMsgParam.java
...src/main/java/com/xxfc/platform/im/model/AddMsgParam.java
+217
-0
Comment.java
...ver/src/main/java/com/xxfc/platform/im/model/Comment.java
+123
-0
Givegift.java
...er/src/main/java/com/xxfc/platform/im/model/Givegift.java
+160
-0
Msg.java
...-server/src/main/java/com/xxfc/platform/im/model/Msg.java
+649
-0
Praise.java
...rver/src/main/java/com/xxfc/platform/im/model/Praise.java
+76
-0
MsgController.java
...rc/main/java/com/xxfc/platform/im/rest/MsgController.java
+27
-0
BeanUtil.java
...er/src/main/java/com/xxfc/platform/im/utils/BeanUtil.java
+80
-0
No files found.
xx-im/xx-im-server/src/main/java/com/xxfc/platform/im/biz/MsgBiz.java
0 → 100644
View file @
9fd85723
package
com
.
xxfc
.
platform
.
im
.
biz
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.mongodb.DBCollection
;
import
com.mongodb.DBCursor
;
import
com.mongodb.DBObject
;
import
com.xxfc.platform.im.model.Comment
;
import
com.xxfc.platform.im.model.Praise
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.mongodb.core.MongoTemplate
;
import
org.springframework.data.mongodb.core.query.Criteria
;
import
org.springframework.data.mongodb.core.query.Query
;
import
org.springframework.stereotype.Component
;
import
java.util.List
;
import
java.util.Map
;
@Component
public
class
MsgBiz
{
@Autowired
private
MongoTemplate
mongoTemplate
;
DBCollection
collection
;
/**
* 获取消息列表
* @param map
* @return
* @throws Exception
*/
public
Object
getMsgList
(
Map
<
String
,
Object
>
map
)
throws
Exception
{
/* PageHelper.startPage(Integer.parseInt(map.get("page").toString()),Integer.parseInt(map.get("limit").toString()));
PageInfo<Msg> goodPageInfo = new PageInfo<>(mongoTemplate.findAll(Msg.class));
Query query = new Query(Criteria.where("userId").is(10000012));
List<Msg> msg= mongoTemplate.findAll(Msg.class);*/
if
(
null
==
collection
)
collection
=
MGDBCollection
.
getDB
().
getCollection
(
"s_msg"
);
DBCursor
cursor
=
collection
.
find
();
//collection.find()
//return PageDataVO.pageInfo(goodPageInfo);
JSONArray
array
=
new
JSONArray
();
DBObject
dbObject
=
null
;
while
(
cursor
.
hasNext
()){
dbObject
=
cursor
.
next
();
JSONObject
json
=
fetchAndAttach
(
JSONObject
.
parseObject
(
dbObject
.
toString
()));
array
.
add
(
json
);
}
return
array
;
}
private
JSONObject
fetchAndAttach
(
JSONObject
json
)
{
//查询评论
Query
query
=
new
Query
(
Criteria
.
where
(
"msgId"
).
is
(
json
.
getString
(
"_id"
)));
List
<
Comment
>
msgComment
=
mongoTemplate
.
findAll
(
Comment
.
class
);
json
.
put
(
"comments"
,
msgComment
);
//查询点赞
Query
query1
=
new
Query
(
Criteria
.
where
(
"msgId"
).
is
(
json
.
getString
(
"_id"
)));
List
<
Praise
>
msgPraise
=
mongoTemplate
.
findAll
(
Praise
.
class
);
json
.
put
(
"praises"
,
msgPraise
);
/* msg.setComments(getComments(msg.getMsgId().toString()));
msg.setPraises(getPraises(msg.getMsgId().toString()));
msg.setGifts(SKBeanUtils.getMsgGiftRepository().find(msg.getMsgId(), null, 0, 10));
msg.setIsPraise(SKBeanUtils.getMsgPraiseRepository().exists(ReqUtil.getUserId(), msg.getMsgId()) ? 1 : 0);
msg.setIsCollect(SKBeanUtils.getMsgPraiseRepository().existsCollect(ReqUtil.getUserId(), msg.getMsgId()) ? 1 : 0);*/
return
json
;
}
}
xx-im/xx-im-server/src/main/java/com/xxfc/platform/im/model/AddMsgParam.java
0 → 100644
View file @
9fd85723
package
com
.
xxfc
.
platform
.
im
.
model
;
import
java.util.List
;
public
class
AddMsgParam
extends
BaseExample
{
private
String
address
;
//地理位置
private
String
audios
;
// 语音地址
private
int
flag
;
//消息标记 :默认是3 普通消息
private
String
images
;
// 图片地址
private
String
messageId
;
// 消息id
private
String
remark
;
// 评论
private
int
source
;
// 来源
private
String
text
;
// 内容
private
long
time
;
// 发送的时间
private
String
title
;
// 标题
private
int
type
;
// 基础属性 1=文字消息、2=图文消息、3=语音消息、4=视频消息、 5=文件消息 、 6=SDK分享消息
private
String
videos
;
// 视频地址
private
String
files
;
// 文件地址
private
int
visible
=
1
;
// 默认 1 公开 2 私密 3 部分好友可见 4 不给谁看
private
String
lable
;
// 标签(目前用于短视频标签)
private
String
musicId
;
// 短视频的音乐Id
private
String
sdkUrl
;
// sdk分享url
private
String
sdkIcon
;
// sdk分享icon
private
String
sdkTitle
;
// sdk分享title
private
List
<
Integer
>
userLook
;
//谁可以看的玩家id
private
List
<
Integer
>
userNotLook
;
//谁不能看的玩家id
private
List
<
Integer
>
userRemindLook
;
//提醒谁看的玩家id
private
int
isAllowComment
;
// 是否允许评论 0:允许 1:禁止评论
public
String
getAddress
()
{
return
address
;
}
public
String
getAudios
()
{
return
audios
;
}
public
int
getFlag
()
{
return
flag
;
}
public
String
getImages
()
{
return
images
;
}
public
String
getMessageId
()
{
return
messageId
;
}
public
String
getRemark
()
{
return
remark
;
}
public
int
getSource
()
{
return
source
;
}
public
String
getText
()
{
return
text
;
}
public
long
getTime
()
{
return
time
;
}
public
String
getTitle
()
{
return
title
;
}
public
int
getType
()
{
return
type
;
}
public
String
getVideos
()
{
return
videos
;
}
public
int
getVisible
()
{
return
visible
;
}
public
void
setAddress
(
String
address
)
{
this
.
address
=
address
;
}
public
void
setAudios
(
String
audios
)
{
this
.
audios
=
audios
;
}
public
void
setFlag
(
int
flag
)
{
this
.
flag
=
flag
;
}
public
void
setImages
(
String
images
)
{
this
.
images
=
images
;
}
public
void
setMessageId
(
String
messageId
)
{
this
.
messageId
=
messageId
;
}
public
void
setRemark
(
String
remark
)
{
this
.
remark
=
remark
;
}
public
void
setSource
(
int
source
)
{
this
.
source
=
source
;
}
public
void
setText
(
String
text
)
{
this
.
text
=
text
;
}
public
void
setTime
(
long
time
)
{
this
.
time
=
time
;
}
public
void
setTitle
(
String
title
)
{
this
.
title
=
title
;
}
public
void
setType
(
int
type
)
{
this
.
type
=
type
;
}
public
void
setVideos
(
String
videos
)
{
this
.
videos
=
videos
;
}
public
void
setVisible
(
int
visible
)
{
this
.
visible
=
visible
;
}
public
List
<
Integer
>
getUserLook
()
{
return
userLook
;
}
public
void
setUserLook
(
List
<
Integer
>
userLook
)
{
this
.
userLook
=
userLook
;
}
public
List
<
Integer
>
getUserNotLook
()
{
return
userNotLook
;
}
public
void
setUserNotLook
(
List
<
Integer
>
userNotLook
)
{
this
.
userNotLook
=
userNotLook
;
}
public
List
<
Integer
>
getUserRemindLook
()
{
return
userRemindLook
;
}
public
void
setUserRemindLook
(
List
<
Integer
>
userRemindLook
)
{
this
.
userRemindLook
=
userRemindLook
;
}
public
String
getFiles
()
{
return
files
;
}
public
void
setFiles
(
String
files
)
{
this
.
files
=
files
;
}
public
String
getSdkUrl
()
{
return
sdkUrl
;
}
public
void
setSdkUrl
(
String
sdkUrl
)
{
this
.
sdkUrl
=
sdkUrl
;
}
public
String
getSdkIcon
()
{
return
sdkIcon
;
}
public
void
setSdkIcon
(
String
sdkIcon
)
{
this
.
sdkIcon
=
sdkIcon
;
}
public
String
getSdkTitle
()
{
return
sdkTitle
;
}
public
void
setSdkTitle
(
String
sdkTitle
)
{
this
.
sdkTitle
=
sdkTitle
;
}
public
String
getLable
()
{
return
lable
;
}
public
void
setLable
(
String
lable
)
{
this
.
lable
=
lable
;
}
public
String
getMusicId
()
{
return
musicId
;
}
public
void
setMusicId
(
String
musicId
)
{
this
.
musicId
=
musicId
;
}
public
int
getIsAllowComment
()
{
return
isAllowComment
;
}
public
void
setIsAllowComment
(
int
isAllowComment
)
{
this
.
isAllowComment
=
isAllowComment
;
}
}
xx-im/xx-im-server/src/main/java/com/xxfc/platform/im/model/Comment.java
0 → 100644
View file @
9fd85723
package
com
.
xxfc
.
platform
.
im
.
model
;
import
org.bson.types.ObjectId
;
import
org.mongodb.morphia.annotations.Entity
;
import
org.mongodb.morphia.annotations.Id
;
import
org.mongodb.morphia.annotations.Indexed
;
/**
* 朋友圈评论
* @author Administrator
*
*/
@Entity
(
value
=
"s_comment"
,
noClassnameStored
=
true
)
public
class
Comment
{
private
String
body
;
// 评论内容
private
@Id
ObjectId
commentId
;
// 评论Id
private
@Indexed
ObjectId
msgId
;
// 评论所属消息Id
private
String
nickname
;
// 评论用户昵称
private
long
time
;
// 评论时间
private
String
toBody
;
// 被回复内容
private
String
toNickname
;
// 被回复人用户昵称
private
int
toUserId
;
// 被回复用户Id
private
int
userId
;
// 评论用户Id
public
Comment
()
{
super
();
}
public
Comment
(
ObjectId
commentId
,
ObjectId
msgId
,
int
userId
,
String
nickname
,
String
body
,
int
toUserId
,
String
toNickname
,
String
toBody
,
long
time
)
{
super
();
this
.
commentId
=
commentId
;
this
.
msgId
=
msgId
;
this
.
userId
=
userId
;
this
.
nickname
=
nickname
;
this
.
body
=
body
;
this
.
toUserId
=
toUserId
;
this
.
toNickname
=
toNickname
;
this
.
toBody
=
toBody
;
this
.
time
=
time
;
}
public
String
getBody
()
{
return
body
;
}
public
ObjectId
getCommentId
()
{
return
commentId
;
}
public
ObjectId
getMsgId
()
{
return
msgId
;
}
public
String
getNickname
()
{
return
nickname
;
}
public
long
getTime
()
{
return
time
;
}
public
String
getToBody
()
{
return
toBody
;
}
public
String
getToNickname
()
{
return
toNickname
;
}
public
int
getToUserId
()
{
return
toUserId
;
}
public
int
getUserId
()
{
return
userId
;
}
public
void
setBody
(
String
body
)
{
this
.
body
=
body
;
}
public
void
setCommentId
(
ObjectId
commentId
)
{
this
.
commentId
=
commentId
;
}
public
void
setMsgId
(
ObjectId
msgId
)
{
this
.
msgId
=
msgId
;
}
public
void
setNickname
(
String
nickname
)
{
this
.
nickname
=
nickname
;
}
public
void
setTime
(
long
time
)
{
this
.
time
=
time
;
}
public
void
setToBody
(
String
toBody
)
{
this
.
toBody
=
toBody
;
}
public
void
setToNickname
(
String
toNickname
)
{
this
.
toNickname
=
toNickname
;
}
public
void
setToUserId
(
int
toUserId
)
{
this
.
toUserId
=
toUserId
;
}
public
void
setUserId
(
int
userId
)
{
this
.
userId
=
userId
;
}
//@Override
/*public String toString() {
return JSONUtil.toJSONString(this);
}*/
}
xx-im/xx-im-server/src/main/java/com/xxfc/platform/im/model/Givegift.java
0 → 100644
View file @
9fd85723
package
com
.
xxfc
.
platform
.
im
.
model
;
import
org.bson.types.ObjectId
;
import
org.mongodb.morphia.annotations.Entity
;
import
org.mongodb.morphia.annotations.Id
;
import
org.mongodb.morphia.annotations.Indexed
;
import
org.mongodb.morphia.annotations.NotSaved
;
/**
* 送礼物记录
* @author Administrator
*
*/
@Entity
(
value
=
"givegift"
,
noClassnameStored
=
true
)
public
class
Givegift
{
private
@Id
ObjectId
id
;
// 送礼物记录Id
private
int
count
;
// 礼物数量
private
ObjectId
giftId
;
// 礼物Id
private
@Indexed
ObjectId
msgId
;
// 送礼物所属消息Id
private
String
nickname
;
// 送礼物用户昵称
private
Double
price
;
// 礼物价格
private
Double
actualPrice
;
// 实收金额
private
long
time
;
// 送礼物时间
private
@Indexed
int
userId
;
// 送礼物用户Id
private
int
toUserId
;
//接收礼物用户Id
@NotSaved
private
String
giftName
;
// 礼物名称
@NotSaved
private
String
liveRoomName
;
// 直播间名称
@NotSaved
private
String
userName
;
// 送礼物用户昵称
@NotSaved
private
String
toUserName
;
// 接收礼物用户昵称
public
Givegift
()
{}
public
Givegift
(
int
count
,
ObjectId
giftId
,
ObjectId
msgId
,
String
nickname
,
Double
price
,
long
time
,
int
userId
,
int
toUserId
)
{
this
.
count
=
count
;
this
.
giftId
=
giftId
;
this
.
msgId
=
msgId
;
this
.
nickname
=
nickname
;
this
.
price
=
price
;
this
.
time
=
time
;
this
.
userId
=
userId
;
this
.
toUserId
=
toUserId
;
}
public
int
getCount
()
{
return
count
;
}
public
ObjectId
getGiftId
()
{
return
giftId
;
}
public
ObjectId
getMsgId
()
{
return
msgId
;
}
public
String
getNickname
()
{
return
nickname
;
}
public
Double
getPrice
()
{
return
price
;
}
public
long
getTime
()
{
return
time
;
}
public
int
getUserId
()
{
return
userId
;
}
public
void
setCount
(
int
count
)
{
this
.
count
=
count
;
}
public
void
setGiftId
(
ObjectId
giftId
)
{
this
.
giftId
=
giftId
;
}
public
void
setMsgId
(
ObjectId
msgId
)
{
this
.
msgId
=
msgId
;
}
public
void
setNickname
(
String
nickname
)
{
this
.
nickname
=
nickname
;
}
public
void
setPrice
(
Double
price
)
{
this
.
price
=
price
;
}
public
void
setTime
(
long
time
)
{
this
.
time
=
time
;
}
public
void
setUserId
(
int
userId
)
{
this
.
userId
=
userId
;
}
public
int
getToUserId
()
{
return
toUserId
;
}
public
void
setToUserId
(
int
toUserId
)
{
this
.
toUserId
=
toUserId
;
}
/*@Override
public String toString() {
return JSONUtil.toJSONString(this);
}*/
public
String
getGiftName
()
{
return
giftName
;
}
public
void
setGiftName
(
String
giftName
)
{
this
.
giftName
=
giftName
;
}
public
Double
getActualPrice
()
{
return
actualPrice
;
}
public
void
setActualPrice
(
Double
actualPrice
)
{
this
.
actualPrice
=
actualPrice
;
}
public
String
getLiveRoomName
()
{
return
liveRoomName
;
}
public
void
setLiveRoomName
(
String
liveRoomName
)
{
this
.
liveRoomName
=
liveRoomName
;
}
public
String
getUserName
()
{
return
userName
;
}
public
void
setUserName
(
String
userName
)
{
this
.
userName
=
userName
;
}
public
String
getToUserName
()
{
return
toUserName
;
}
public
void
setToUserName
(
String
toUserName
)
{
this
.
toUserName
=
toUserName
;
}
}
xx-im/xx-im-server/src/main/java/com/xxfc/platform/im/model/Msg.java
0 → 100644
View file @
9fd85723
This diff is collapsed.
Click to expand it.
xx-im/xx-im-server/src/main/java/com/xxfc/platform/im/model/Praise.java
0 → 100644
View file @
9fd85723
package
com
.
xxfc
.
platform
.
im
.
model
;
import
org.bson.types.ObjectId
;
import
org.mongodb.morphia.annotations.Entity
;
import
org.mongodb.morphia.annotations.Id
;
import
org.mongodb.morphia.annotations.Indexed
;
@Entity
(
value
=
"s_praise"
,
noClassnameStored
=
true
)
public
class
Praise
{
private
@Indexed
ObjectId
msgId
;
// 赞所属消息Id
private
String
nickname
;
// 赞用户昵称
private
@Id
ObjectId
praiseId
;
// 赞Id
private
long
time
;
// 赞时间
private
int
userId
;
// 赞用户Id
public
Praise
()
{
super
();
}
public
Praise
(
ObjectId
praiseId
,
ObjectId
msgId
,
int
userId
,
String
nickname
,
long
time
)
{
super
();
this
.
praiseId
=
praiseId
;
this
.
msgId
=
msgId
;
this
.
userId
=
userId
;
this
.
nickname
=
nickname
;
this
.
time
=
time
;
}
public
ObjectId
getMsgId
()
{
return
msgId
;
}
public
String
getNickname
()
{
return
nickname
;
}
public
ObjectId
getPraiseId
()
{
return
praiseId
;
}
public
long
getTime
()
{
return
time
;
}
public
int
getUserId
()
{
return
userId
;
}
public
void
setMsgId
(
ObjectId
msgId
)
{
this
.
msgId
=
msgId
;
}
public
void
setNickname
(
String
nickname
)
{
this
.
nickname
=
nickname
;
}
public
void
setPraiseId
(
ObjectId
praiseId
)
{
this
.
praiseId
=
praiseId
;
}
public
void
setTime
(
long
time
)
{
this
.
time
=
time
;
}
public
void
setUserId
(
int
userId
)
{
this
.
userId
=
userId
;
}
/*@Override
public String toString() {
return JSONUtil.toJSONString(this);
}*/
}
xx-im/xx-im-server/src/main/java/com/xxfc/platform/im/rest/MsgController.java
0 → 100644
View file @
9fd85723
package
com
.
xxfc
.
platform
.
im
.
rest
;
import
com.alibaba.fastjson.JSONArray
;
import
com.github.wxiaoqi.security.common.msg.ObjectRestResponse
;
import
com.mongodb.DBCursor
;
import
com.xxfc.platform.im.biz.MsgBiz
;
import
com.xxfc.platform.im.biz.UserBiz
;
import
com.xxfc.platform.im.model.Msg
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.Map
;
@RestController
@RequestMapping
(
"msg"
)
public
class
MsgController
{
@Autowired
private
MsgBiz
msgBiz
;
@RequestMapping
(
value
=
"/app/unauth/list"
,
method
=
RequestMethod
.
POST
)
@ResponseBody
public
Object
getMsgList
(
@RequestBody
Map
<
String
,
Object
>
map
)
throws
Exception
{
//@RequestParam(value = "page", required = true) Integer page, @RequestParam(value = "limit", required = true) Integer limit
return
msgBiz
.
getMsgList
(
map
);
}
}
xx-im/xx-im-server/src/main/java/com/xxfc/platform/im/utils/BeanUtil.java
0 → 100644
View file @
9fd85723
package
com
.
xxfc
.
platform
.
im
.
utils
;
import
com.mongodb.DBObject
;
import
org.apache.commons.beanutils.BeanUtils
;
import
java.lang.reflect.Field
;
import
java.lang.reflect.InvocationTargetException
;
import
java.lang.reflect.Method
;
public
class
BeanUtil
{
/**
* 将DBObject转换成Bean对象
*
*/
public
static
<
T
>
T
dbObjectToBean
(
DBObject
dbObject
,
T
bean
)
throws
IllegalAccessException
,
InvocationTargetException
,
NoSuchMethodException
{
if
(
bean
==
null
)
{
return
null
;
}
Field
[]
fields
=
bean
.
getClass
().
getDeclaredFields
();
for
(
Field
field
:
fields
)
{
String
varName
=
field
.
getName
();
Object
object
=
dbObject
.
get
(
varName
);
if
(
object
!=
null
)
{
org
.
apache
.
commons
.
beanutils
.
BeanUtils
.
setProperty
(
bean
,
varName
,
object
);
}
}
return
bean
;
}
// 取出Mongo中的属性值,为bean赋值
public
static
<
T
>
void
setProperty
(
T
bean
,
String
varName
,
T
object
)
{
varName
=
varName
.
substring
(
0
,
1
).
toUpperCase
()
+
varName
.
substring
(
1
);
try
{
String
type
=
object
.
getClass
().
getName
();
// 类型为String
if
(
type
.
equals
(
"java.lang.String"
))
{
Method
m
=
bean
.
getClass
().
getMethod
(
"get"
+
varName
);
String
value
=
(
String
)
m
.
invoke
(
bean
);
if
(
value
==
null
)
{
m
=
bean
.
getClass
()
.
getMethod
(
"set"
+
varName
,
String
.
class
);
m
.
invoke
(
bean
,
object
);
}
}
// 类型为Integer
if
(
type
.
equals
(
"java.lang.Integer"
))
{
Method
m
=
bean
.
getClass
().
getMethod
(
"get"
+
varName
);
String
value
=
(
String
)
m
.
invoke
(
bean
);
if
(
value
==
null
)
{
m
=
bean
.
getClass
().
getMethod
(
"set"
+
varName
,
Integer
.
class
);
m
.
invoke
(
bean
,
object
);
}
}
// 类型为Boolean
if
(
type
.
equals
(
"java.lang.Boolean"
))
{
Method
m
=
bean
.
getClass
().
getMethod
(
"get"
+
varName
);
String
value
=
(
String
)
m
.
invoke
(
bean
);
if
(
value
==
null
)
{
m
=
bean
.
getClass
().
getMethod
(
"set"
+
varName
,
Boolean
.
class
);
m
.
invoke
(
bean
,
object
);
}
}
}
catch
(
NoSuchMethodException
e
)
{
e
.
printStackTrace
();
}
catch
(
SecurityException
e
)
{
e
.
printStackTrace
();
}
catch
(
IllegalAccessException
e
)
{
e
.
printStackTrace
();
}
catch
(
IllegalArgumentException
e
)
{
e
.
printStackTrace
();
}
catch
(
InvocationTargetException
e
)
{
e
.
printStackTrace
();
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment