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
e758708e
Commit
e758708e
authored
Jun 21, 2019
by
wuwz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
发现
parent
38baf36c
Changes
8
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 @
e758708e
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 @
e758708e
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 @
e758708e
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 @
e758708e
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 @
e758708e
package
com
.
xxfc
.
platform
.
im
.
model
;
import
java.util.List
;
import
com.aliyun.oss.ServiceException
;
import
com.xxfc.platform.im.utils.DateUtil
;
import
com.xxfc.platform.im.utils.StringUtil
;
import
org.bson.types.ObjectId
;
import
org.mongodb.morphia.annotations.Entity
;
import
org.mongodb.morphia.annotations.Id
;
import
org.mongodb.morphia.annotations.Index
;
import
org.mongodb.morphia.annotations.Indexes
;
import
org.mongodb.morphia.annotations.NotSaved
;
import
org.mongodb.morphia.annotations.Reference
;
import
org.mongodb.morphia.annotations.Transient
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
/**
* 朋友圈消息
* @author Administrator
*
*/
@Entity
(
value
=
"s_msg"
,
noClassnameStored
=
true
)
@Indexes
(
@Index
(
"cityId,flag,userId,visible,body.title"
))
public
class
Msg
{
private
Body
body
;
// 消息内容
private
int
cityId
;
// 消息所属城市Id
private
String
cityName
;
// 消息所属城市名
private
Count
count
;
// 计数对象
private
Integer
flag
;
// 标记( 1=求职消息、2=招聘消息、3=普通消息)
private
Double
latitude
;
// 纬度
private
String
location
;
private
Double
longitude
;
// 经度
private
String
model
;
// 发送消息手机型号(如:iPhone 5)
private
@Id
ObjectId
msgId
;
// 消息Id
private
String
nickname
;
// 昵称
private
Long
time
;
// 发朋友圈消息时间
private
Integer
userId
;
// 发消息用户Id
private
String
lable
;
// 标签(目前用于短视频标签)
private
Integer
visible
=
1
;
//是否可见(1:公开,2:私密,3:部分可见选中的朋友的可见,4:不给谁看,5:@谁看)
private
List
<
Integer
>
userLook
;
//选中可见的朋友列表
private
List
<
Integer
>
userNotLook
;
//选中不可见的朋友列表
private
List
<
Integer
>
userRemindLook
;
//@提醒朋友列表
private
@Reference
List
<
Comment
>
comments
;
// 评论列表
private
@Reference
List
<
Givegift
>
gifts
;
// 礼物列表
private
@Reference
List
<
Praise
>
praises
;
// 赞列表
private
@Transient
int
isPraise
;
// 请求接口人是否赞过本条消息 0:未点赞 1:已点赞
private
@Transient
int
isCollect
;
// 请求接口人是否收藏本条消息 0:未收藏过 1:已收藏
private
int
state
;
// 是否被锁定 0:正常 1:锁定
private
int
isAllowComment
;
// 是否允许评论 0:允许 1:禁止评论
@NotSaved
private
Integer
userStatus
;
// 该用户 状态:1=正常, -1=禁用
private
String
fileName
;
// 原文件名称
public
int
getIsCollect
()
{
return
isCollect
;
}
public
void
setIsCollect
(
int
isCollect
)
{
this
.
isCollect
=
isCollect
;
}
public
Body
getBody
()
{
return
body
;
}
public
int
getCityId
()
{
return
cityId
;
}
public
String
getCityName
()
{
return
cityName
;
}
public
Count
getCount
()
{
return
count
;
}
public
Integer
getFlag
()
{
return
flag
;
}
public
Double
getLatitude
()
{
return
latitude
;
}
public
String
getLocation
()
{
return
location
;
}
public
Double
getLongitude
()
{
return
longitude
;
}
public
String
getModel
()
{
return
model
;
}
public
ObjectId
getMsgId
()
{
return
msgId
;
}
public
String
getNickname
()
{
return
nickname
;
}
public
Long
getTime
()
{
return
time
;
}
public
Integer
getUserId
()
{
return
userId
;
}
public
Integer
getVisible
()
{
return
visible
;
}
public
void
setBody
(
Body
body
)
{
this
.
body
=
body
;
}
public
void
setCityId
(
int
cityId
)
{
this
.
cityId
=
cityId
;
}
public
void
setCityName
(
String
cityName
)
{
this
.
cityName
=
cityName
;
}
public
void
setCount
(
Count
count
)
{
this
.
count
=
count
;
}
public
void
setFlag
(
Integer
flag
)
{
this
.
flag
=
flag
;
}
public
void
setLatitude
(
Double
latitude
)
{
this
.
latitude
=
latitude
;
}
public
void
setLocation
(
String
location
)
{
this
.
location
=
location
;
}
public
void
setLongitude
(
Double
longitude
)
{
this
.
longitude
=
longitude
;
}
public
void
setModel
(
String
model
)
{
this
.
model
=
model
;
}
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
setUserId
(
Integer
userId
)
{
this
.
userId
=
userId
;
}
public
void
setVisible
(
Integer
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
List
<
Comment
>
getComments
()
{
return
comments
;
}
public
void
setComments
(
List
<
Comment
>
comments
)
{
this
.
comments
=
comments
;
}
public
List
<
Givegift
>
getGifts
()
{
return
gifts
;
}
public
void
setGifts
(
List
<
Givegift
>
gifts
)
{
this
.
gifts
=
gifts
;
}
public
List
<
Praise
>
getPraises
()
{
return
praises
;
}
public
void
setPraises
(
List
<
Praise
>
praises
)
{
this
.
praises
=
praises
;
}
public
int
getIsPraise
()
{
return
isPraise
;
}
public
void
setIsPraise
(
int
isPraise
)
{
this
.
isPraise
=
isPraise
;
}
public
static
class
Body
{
private
String
address
;
// 发送消息地址
private
List
<
Resource
>
audios
;
// 音频列表
private
List
<
Resource
>
images
;
// 图片列表
private
String
remark
;
// 备注
private
String
text
;
// 文本
private
long
time
;
// 发送时间
private
String
title
;
// 消息标题
private
int
type
;
// 消息类型 1=文字消息、2=图文消息、3=语音消息、4=视频消息、 5=文件消息 、 6=SDK分享消息
private
String
lable
;
// 标签(目前用于短视频标签)
private
String
sdkUrl
;
// sdk分享url
private
String
sdkIcon
;
// sdk分享icon
private
String
sdkTitle
;
// sdk分享title
private
List
<
Resource
>
videos
;
// 视频列表
private
List
<
Resource
>
files
;
// 文件列表
public
String
getAddress
()
{
return
address
;
}
public
List
<
Resource
>
getAudios
()
{
return
audios
;
}
public
List
<
Resource
>
getImages
()
{
return
images
;
}
public
String
getRemark
()
{
return
remark
;
}
public
String
getText
()
{
return
text
;
}
public
long
getTime
()
{
return
time
;
}
public
String
getTitle
()
{
return
title
;
}
public
int
getType
()
{
return
type
;
}
public
List
<
Resource
>
getVideos
()
{
return
videos
;
}
public
void
setAddress
(
String
address
)
{
this
.
address
=
address
;
}
public
void
setAudios
(
List
<
Resource
>
audios
)
{
this
.
audios
=
audios
;
}
public
void
setImages
(
List
<
Resource
>
images
)
{
this
.
images
=
images
;
}
public
void
setRemark
(
String
remark
)
{
this
.
remark
=
remark
;
}
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
(
List
<
Resource
>
videos
)
{
this
.
videos
=
videos
;
}
public
List
<
Resource
>
getFiles
()
{
return
files
;
}
public
void
setFiles
(
List
<
Resource
>
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
static
class
Count
{
private
long
collect
;
// 收藏数
private
long
comment
;
// 评论数
private
long
forward
;
// 转发数(APP内)
private
long
money
;
// 金币数
private
long
play
;
// 播放数
private
long
praise
;
// 被赞数
private
long
share
;
// 分享数(APP外)
private
long
total
;
// 参考数
public
long
getCollect
()
{
return
collect
;
}
public
long
getComment
()
{
return
comment
;
}
public
long
getForward
()
{
return
forward
;
}
public
long
getMoney
()
{
return
money
;
}
public
long
getPlay
()
{
return
play
;
}
public
long
getPraise
()
{
return
praise
;
}
public
long
getShare
()
{
return
share
;
}
public
long
getTotal
()
{
return
total
;
}
public
void
setCollect
(
long
collect
)
{
this
.
collect
=
collect
;
}
public
void
setComment
(
long
comment
)
{
this
.
comment
=
comment
;
}
public
void
setForward
(
long
forward
)
{
this
.
forward
=
forward
;
}
public
void
setMoney
(
long
money
)
{
this
.
money
=
money
;
}
public
void
setPlay
(
long
play
)
{
this
.
play
=
play
;
}
public
void
setPraise
(
long
praise
)
{
this
.
praise
=
praise
;
}
public
void
setShare
(
long
share
)
{
this
.
share
=
share
;
}
public
void
setTotal
(
long
total
)
{
this
.
total
=
total
;
}
}
public
static
enum
Op
{
/** 收藏 */
Collect
(
"count.collect"
),
/** 评论 */
Comment
(
"count.comment"
),
/** 转发 */
Forwarding
(
"count.forward"
),
/** 送礼物 */
Gift
(
"count.gift"
),
/** 播放音频或视频 */
Play
(
"count.play"
),
/** 赞 */
Praise
(
"count.praise"
),
/** 分享 */
Share
(
"count.share"
);
private
String
key
;
private
Op
(
String
key
)
{
this
.
key
=
key
;
}
/**
* count.${key}
*
* @return
*/
public
String
getKey
()
{
return
key
;
}
}
public
static
class
Resource
{
private
int
length
;
// 播放时长(s)
@JsonProperty
(
value
=
"oUrl"
)
@JSONField
(
name
=
"oUrl"
)
private
String
oUrl
;
// 原始URL
@JsonProperty
(
value
=
"tUrl"
)
@JSONField
(
name
=
"tUrl"
)
private
String
tUrl
;
// 缩略URL
@JsonProperty
(
value
=
"oFileName"
)
@JSONField
(
name
=
"oFileName"
)
private
String
oFileName
;
// 文件原名称
private
long
size
;
// 文件大小
public
long
getLength
()
{
return
length
;
}
public
String
getOUrl
()
{
return
oUrl
;
}
public
long
getSize
()
{
return
size
;
}
public
String
getTUrl
()
{
return
tUrl
;
}
public
void
setLength
(
int
length
)
{
this
.
length
=
length
;
}
public
void
setOUrl
(
String
oUrl
)
{
this
.
oUrl
=
oUrl
;
}
public
void
setSize
(
long
size
)
{
this
.
size
=
size
;
}
public
void
setTUrl
(
String
tUrl
)
{
this
.
tUrl
=
tUrl
;
}
public
String
getoFileName
()
{
return
oFileName
;
}
public
void
setoFileName
(
String
oFileName
)
{
this
.
oFileName
=
oFileName
;
}
}
public
static
Msg
build
(
User
user
,
AddMsgParam
param
)
{
Body
body
=
new
Body
();
body
.
title
=
param
.
getTitle
();
// 标题
body
.
text
=
param
.
getText
();
// 文字内容
if
(!
StringUtil
.
isEmpty
(
param
.
getLable
()))
body
.
lable
=
param
.
getLable
();
body
.
type
=
param
.
getType
();
// 1=文字消息、2=图文消息、3=语音消息、4=视频消息、 5=文件消息、6=sdk分享
// body.images = com.mongodb.util.JSON.parse(param.getImages());
// body.audios = com.mongodb.util.JSON.parse(param.getAudios());
// body.videos = com.mongodb.util.JSON.parse(param.getVideos());
if
(
2
==
param
.
getType
()||
4
==
param
.
getType
()){
body
.
images
=
JSON
.
parseArray
(
param
.
getImages
(),
Resource
.
class
);
if
(
null
!=
body
.
images
&&
0
==
body
.
images
.
size
())
throw
new
ServiceException
(
"请上传有效图片"
);
}
// body.images = JSON.parseArray(param.getImages(), Resource.class);
body
.
audios
=
JSON
.
parseArray
(
param
.
getAudios
(),
Resource
.
class
);
body
.
videos
=
JSON
.
parseArray
(
param
.
getVideos
(),
Resource
.
class
);
body
.
files
=
JSON
.
parseArray
(
param
.
getFiles
(),
Resource
.
class
);
// 文件地址
body
.
time
=
param
.
getTime
();
// 时间
body
.
address
=
param
.
getAddress
();
// 地址
body
.
remark
=
param
.
getRemark
();
// 备注
body
.
sdkUrl
=
param
.
getSdkUrl
();
// sdk分享url
body
.
sdkIcon
=
param
.
getSdkIcon
();
// sdk分享icon
body
.
sdkTitle
=
param
.
getSdkTitle
();
// sdk分享title
Count
count
=
new
Count
();
count
.
play
=
0
;
// 播放数
count
.
forward
=
0
;
// 转发数(APP内)
count
.
share
=
0
;
// 分享数(APP外)
count
.
collect
=
0
;
// 收藏数
count
.
praise
=
0
;
// 被赞数
count
.
comment
=
0
;
// 评论数
count
.
money
=
0
;
// 金币数
count
.
total
=
0
;
// 参考数
Msg
entity
=
new
Msg
();
entity
.
msgId
=
ObjectId
.
get
();
entity
.
userId
=
user
.
getUserId
();
if
(
10000
==
user
.
getUserId
())
entity
.
nickname
=
"客服公众号"
;
else
entity
.
nickname
=
user
.
getNickname
();
entity
.
flag
=
param
.
getFlag
();
// 1=求职消息、2=招聘消息、3=普通消息
if
(
0
==
param
.
getVisible
())
param
.
setVisible
(
1
);
entity
.
visible
=
param
.
getVisible
();
// 0=不可见、1=朋友可见、2=粉丝可见、3=广场
entity
.
userLook
=
param
.
getUserLook
();
entity
.
userNotLook
=
param
.
getUserNotLook
();
entity
.
userRemindLook
=
param
.
getUserRemindLook
();
entity
.
body
=
body
;
entity
.
count
=
count
;
entity
.
time
=
DateUtil
.
currentTimeSeconds
();
entity
.
model
=
param
.
getModel
();
entity
.
cityId
=
param
.
getCityId
();
entity
.
cityName
=
param
.
getCityName
();
entity
.
latitude
=
param
.
getLatitude
();
entity
.
longitude
=
param
.
getLongitude
();
entity
.
location
=
param
.
getLocation
();
entity
.
isAllowComment
=
param
.
getIsAllowComment
();
return
entity
;
}
/**//*@Override
public String toString() {
return JSONUtil.toJSONString(this);
}*/
public
int
getState
()
{
return
state
;
}
public
void
setState
(
int
state
)
{
this
.
state
=
state
;
}
public
Integer
getUserStatus
()
{
return
userStatus
;
}
public
void
setUserStatus
(
Integer
userStatus
)
{
this
.
userStatus
=
userStatus
;
}
public
String
getFileName
()
{
return
fileName
;
}
public
void
setFileName
(
String
fileName
)
{
this
.
fileName
=
fileName
;
}
public
String
getLable
()
{
return
lable
;
}
public
void
setLable
(
String
lable
)
{
this
.
lable
=
lable
;
}
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/Praise.java
0 → 100644
View file @
e758708e
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 @
e758708e
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 @
e758708e
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