Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
I
im-common
Project
Project
Details
Activity
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
陈永峰
im-common
Commits
dc367b43
Unverified
Commit
dc367b43
authored
Oct 11, 2021
by
Yang Libin
Committed by
GitHub
Oct 11, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: add recent contact api (#32)
parent
4143b3bd
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
439 additions
and
2 deletions
+439
-2
README.md
README.md
+1
-1
pom.xml
pom.xml
+1
-1
IMClient.java
src/main/java/io/github/doocs/im/IMClient.java
+2
-0
RecentContact.java
src/main/java/io/github/doocs/im/core/RecentContact.java
+40
-0
DeleteRecentContactRequest.java
...ub/doocs/im/model/request/DeleteRecentContactRequest.java
+55
-0
GetRecentContactListRequest.java
...b/doocs/im/model/request/GetRecentContactListRequest.java
+77
-0
DeleteRecentContactResult.java
...ub/doocs/im/model/response/DeleteRecentContactResult.java
+27
-0
GetRecentContactListResult.java
...b/doocs/im/model/response/GetRecentContactListResult.java
+101
-0
RecentContactSessionItem.java
...hub/doocs/im/model/response/RecentContactSessionItem.java
+75
-0
RecentContactTest.java
src/test/java/io/github/doocs/im/RecentContactTest.java
+60
-0
No files found.
README.md
View file @
dc367b43
...
...
@@ -22,7 +22,7 @@ Add the Maven dependency:
<dependency>
<groupId>
io.github.doocs
</groupId>
<artifactId>
im-server-sdk-java
</artifactId>
<version>
0.0.
6
</version>
<version>
0.0.
7
</version>
</dependency>
```
...
...
pom.xml
View file @
dc367b43
...
...
@@ -6,7 +6,7 @@
<groupId>
io.github.doocs
</groupId>
<artifactId>
im-server-sdk-java
</artifactId>
<version>
0.0.
6
</version>
<version>
0.0.
7
</version>
<packaging>
jar
</packaging>
<name>
qcloud-im-server-sdk-java
</name>
...
...
src/main/java/io/github/doocs/im/IMClient.java
View file @
dc367b43
...
...
@@ -24,6 +24,7 @@ public class IMClient {
public
Group
group
;
public
SNS
sns
;
public
Operation
operation
;
public
RecentContact
recentContact
;
/**
* init property
*/
...
...
@@ -59,6 +60,7 @@ public class IMClient {
group
=
new
Group
(
this
);
operation
=
new
Operation
(
this
);
sns
=
new
SNS
(
this
);
recentContact
=
new
RecentContact
(
this
);
}
public
String
getUrl
(
String
serviceName
,
String
command
)
{
...
...
src/main/java/io/github/doocs/im/core/RecentContact.java
0 → 100644
View file @
dc367b43
package
io
.
github
.
doocs
.
im
.
core
;
import
io.github.doocs.im.IMClient
;
import
io.github.doocs.im.model.request.DeleteRecentContactRequest
;
import
io.github.doocs.im.model.request.GetRecentContactListRequest
;
import
io.github.doocs.im.model.response.DeleteRecentContactResult
;
import
io.github.doocs.im.model.response.GetRecentContactListResult
;
import
io.github.doocs.im.util.HttpUtil
;
import
io.github.doocs.im.util.JsonUtil
;
import
java.io.IOException
;
/**
* @author bingo
* @since 2021/10/11 10:25
*/
public
class
RecentContact
{
private
static
final
String
SERVICE_NAME
=
"recentcontact"
;
private
static
final
String
GET_RECENT_CONTACT_LIST
=
"get_list"
;
private
static
final
String
DELETE_RECENT_CONTACT
=
"delete"
;
private
final
IMClient
imClient
;
public
RecentContact
(
IMClient
imClient
)
{
this
.
imClient
=
imClient
;
}
public
GetRecentContactListResult
recentContactList
(
GetRecentContactListRequest
recentContactListRequest
)
throws
IOException
{
String
url
=
imClient
.
getUrl
(
SERVICE_NAME
,
GET_RECENT_CONTACT_LIST
);
String
result
=
HttpUtil
.
post
(
url
,
JsonUtil
.
obj2Str
(
recentContactListRequest
),
null
);
return
JsonUtil
.
str2Obj
(
result
,
GetRecentContactListResult
.
class
);
}
public
DeleteRecentContactResult
deleteRecentContact
(
DeleteRecentContactRequest
deleteRecentContactRequest
)
throws
IOException
{
String
url
=
imClient
.
getUrl
(
SERVICE_NAME
,
DELETE_RECENT_CONTACT
);
String
result
=
HttpUtil
.
post
(
url
,
JsonUtil
.
obj2Str
(
deleteRecentContactRequest
),
null
);
return
JsonUtil
.
str2Obj
(
result
,
DeleteRecentContactResult
.
class
);
}
}
src/main/java/io/github/doocs/im/model/request/DeleteRecentContactRequest.java
0 → 100644
View file @
dc367b43
package
io
.
github
.
doocs
.
im
.
model
.
request
;
import
com.fasterxml.jackson.annotation.JsonInclude
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
/**
* @author bingo
* @since 2021/10/11 10:49
*/
@JsonInclude
(
JsonInclude
.
Include
.
NON_NULL
)
public
class
DeleteRecentContactRequest
extends
GenericRequest
{
@JsonProperty
(
"From_Account"
)
private
String
fromAccount
;
@JsonProperty
(
"Type"
)
private
Integer
type
;
@JsonProperty
(
"To_Account"
)
private
String
toAccount
;
@JsonProperty
(
"ClearRamble"
)
private
Integer
clearRamble
;
public
String
getFromAccount
()
{
return
fromAccount
;
}
public
void
setFromAccount
(
String
fromAccount
)
{
this
.
fromAccount
=
fromAccount
;
}
public
Integer
getType
()
{
return
type
;
}
public
void
setType
(
Integer
type
)
{
this
.
type
=
type
;
}
public
String
getToAccount
()
{
return
toAccount
;
}
public
void
setToAccount
(
String
toAccount
)
{
this
.
toAccount
=
toAccount
;
}
public
Integer
getClearRamble
()
{
return
clearRamble
;
}
public
void
setClearRamble
(
Integer
clearRamble
)
{
this
.
clearRamble
=
clearRamble
;
}
}
src/main/java/io/github/doocs/im/model/request/GetRecentContactListRequest.java
0 → 100644
View file @
dc367b43
package
io
.
github
.
doocs
.
im
.
model
.
request
;
import
com.fasterxml.jackson.annotation.JsonInclude
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
/**
* @author bingo
* @since 2021/10/11 10:28
*/
@JsonInclude
(
JsonInclude
.
Include
.
NON_NULL
)
public
class
GetRecentContactListRequest
extends
GenericRequest
{
@JsonProperty
(
"From_Account"
)
private
String
fromAccount
;
@JsonProperty
(
"TimeStamp"
)
private
Integer
timestamp
;
@JsonProperty
(
"StartIndex"
)
private
Integer
startIndex
;
@JsonProperty
(
"TopTimeStamp"
)
private
Integer
topTimestamp
;
@JsonProperty
(
"TopStartIndex"
)
private
Integer
topStartIndex
;
@JsonProperty
(
"AssistFlags"
)
private
Integer
assistFlags
;
public
String
getFromAccount
()
{
return
fromAccount
;
}
public
void
setFromAccount
(
String
fromAccount
)
{
this
.
fromAccount
=
fromAccount
;
}
public
Integer
getTimestamp
()
{
return
timestamp
;
}
public
void
setTimestamp
(
Integer
timestamp
)
{
this
.
timestamp
=
timestamp
;
}
public
Integer
getStartIndex
()
{
return
startIndex
;
}
public
void
setStartIndex
(
Integer
startIndex
)
{
this
.
startIndex
=
startIndex
;
}
public
Integer
getTopTimestamp
()
{
return
topTimestamp
;
}
public
void
setTopTimestamp
(
Integer
topTimestamp
)
{
this
.
topTimestamp
=
topTimestamp
;
}
public
Integer
getTopStartIndex
()
{
return
topStartIndex
;
}
public
void
setTopStartIndex
(
Integer
topStartIndex
)
{
this
.
topStartIndex
=
topStartIndex
;
}
public
Integer
getAssistFlags
()
{
return
assistFlags
;
}
public
void
setAssistFlags
(
Integer
assistFlags
)
{
this
.
assistFlags
=
assistFlags
;
}
}
src/main/java/io/github/doocs/im/model/response/DeleteRecentContactResult.java
0 → 100644
View file @
dc367b43
package
io
.
github
.
doocs
.
im
.
model
.
response
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
/**
* @author bingo
* @since 2021/10/11 10:53
*/
public
class
DeleteRecentContactResult
extends
GenericResult
{
@JsonProperty
(
"ErrorDisplay"
)
private
String
errorDisplay
;
public
String
getErrorDisplay
()
{
return
errorDisplay
;
}
public
void
setErrorDisplay
(
String
errorDisplay
)
{
this
.
errorDisplay
=
errorDisplay
;
}
@Override
public
String
toString
()
{
return
"DeleteRecentContactResult{"
+
"errorDisplay='"
+
errorDisplay
+
'\''
+
'}'
;
}
}
src/main/java/io/github/doocs/im/model/response/GetRecentContactListResult.java
0 → 100644
View file @
dc367b43
package
io
.
github
.
doocs
.
im
.
model
.
response
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
java.util.List
;
/**
* @author bingo
* @since 2021/10/11 10:31
*/
public
class
GetRecentContactListResult
extends
GenericResult
{
@JsonProperty
(
"SessionItem"
)
private
List
<
RecentContactSessionItem
>
sessionItem
;
@JsonProperty
(
"CompleteFlag"
)
private
Integer
completeFlag
;
@JsonProperty
(
"TimeStamp"
)
private
Integer
timestamp
;
@JsonProperty
(
"StartIndex"
)
private
Integer
startIndex
;
@JsonProperty
(
"TopTimeStamp"
)
private
Integer
topTimestamp
;
@JsonProperty
(
"TopStartIndex"
)
private
Integer
topStartIndex
;
@JsonProperty
(
"ErrorDisplay"
)
private
String
errorDisplay
;
public
List
<
RecentContactSessionItem
>
getSessionItem
()
{
return
sessionItem
;
}
public
void
setSessionItem
(
List
<
RecentContactSessionItem
>
sessionItem
)
{
this
.
sessionItem
=
sessionItem
;
}
public
Integer
getCompleteFlag
()
{
return
completeFlag
;
}
public
void
setCompleteFlag
(
Integer
completeFlag
)
{
this
.
completeFlag
=
completeFlag
;
}
public
Integer
getTimestamp
()
{
return
timestamp
;
}
public
void
setTimestamp
(
Integer
timestamp
)
{
this
.
timestamp
=
timestamp
;
}
public
Integer
getStartIndex
()
{
return
startIndex
;
}
public
void
setStartIndex
(
Integer
startIndex
)
{
this
.
startIndex
=
startIndex
;
}
public
Integer
getTopTimestamp
()
{
return
topTimestamp
;
}
public
void
setTopTimestamp
(
Integer
topTimestamp
)
{
this
.
topTimestamp
=
topTimestamp
;
}
public
Integer
getTopStartIndex
()
{
return
topStartIndex
;
}
public
void
setTopStartIndex
(
Integer
topStartIndex
)
{
this
.
topStartIndex
=
topStartIndex
;
}
public
String
getErrorDisplay
()
{
return
errorDisplay
;
}
public
void
setErrorDisplay
(
String
errorDisplay
)
{
this
.
errorDisplay
=
errorDisplay
;
}
@Override
public
String
toString
()
{
return
"GetRecentContactListResult{"
+
"sessionItem="
+
sessionItem
+
", completeFlag="
+
completeFlag
+
", timestamp="
+
timestamp
+
", startIndex="
+
startIndex
+
", topTimestamp="
+
topTimestamp
+
", topStartIndex="
+
topStartIndex
+
", errorDisplay='"
+
errorDisplay
+
'\''
+
'}'
;
}
}
src/main/java/io/github/doocs/im/model/response/RecentContactSessionItem.java
0 → 100644
View file @
dc367b43
package
io
.
github
.
doocs
.
im
.
model
.
response
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
/**
* @author bingo
* @since 2021/10/11 10:37
*/
public
class
RecentContactSessionItem
{
@JsonProperty
(
"Type"
)
private
Integer
type
;
@JsonProperty
(
"To_Account"
)
private
String
toAccount
;
@JsonProperty
(
"GroupId"
)
private
String
groupId
;
@JsonProperty
(
"MsgTime"
)
private
String
msgTime
;
@JsonProperty
(
"TopFlag"
)
private
Integer
topFlag
;
public
Integer
getType
()
{
return
type
;
}
public
void
setType
(
Integer
type
)
{
this
.
type
=
type
;
}
public
String
getToAccount
()
{
return
toAccount
;
}
public
void
setToAccount
(
String
toAccount
)
{
this
.
toAccount
=
toAccount
;
}
public
String
getGroupId
()
{
return
groupId
;
}
public
void
setGroupId
(
String
groupId
)
{
this
.
groupId
=
groupId
;
}
public
String
getMsgTime
()
{
return
msgTime
;
}
public
void
setMsgTime
(
String
msgTime
)
{
this
.
msgTime
=
msgTime
;
}
public
Integer
getTopFlag
()
{
return
topFlag
;
}
public
void
setTopFlag
(
Integer
topFlag
)
{
this
.
topFlag
=
topFlag
;
}
@Override
public
String
toString
()
{
return
"RecentContactSessionItem{"
+
"type="
+
type
+
", toAccount='"
+
toAccount
+
'\''
+
", groupId='"
+
groupId
+
'\''
+
", msgTime='"
+
msgTime
+
'\''
+
", topFlag="
+
topFlag
+
'}'
;
}
}
src/test/java/io/github/doocs/im/RecentContactTest.java
0 → 100644
View file @
dc367b43
package
io
.
github
.
doocs
.
im
;
import
io.github.doocs.im.model.request.DeleteRecentContactRequest
;
import
io.github.doocs.im.model.request.GetRecentContactListRequest
;
import
io.github.doocs.im.model.response.DeleteRecentContactResult
;
import
io.github.doocs.im.model.response.GetRecentContactListResult
;
import
org.junit.Assert
;
import
org.junit.Test
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.util.Properties
;
/**
* @author bingo
* @since 2021/10/11 10:56
*/
public
class
RecentContactTest
{
private
static
final
Properties
properties
=
new
Properties
();
private
static
final
IMClient
client
;
static
{
InputStream
resourceAsStream
=
RecentContactTest
.
class
.
getClassLoader
().
getResourceAsStream
(
"app.properties"
);
try
{
properties
.
load
(
resourceAsStream
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
String
key
=
properties
.
getProperty
(
"key"
);
String
identifier
=
properties
.
getProperty
(
"identifier"
);
Long
appId
=
Long
.
parseLong
(
properties
.
getProperty
(
"appId"
));
client
=
IMClient
.
getInstance
(
appId
,
identifier
,
key
);
}
@Test
public
void
testGetRecentContactList
()
throws
IOException
{
GetRecentContactListRequest
request
=
new
GetRecentContactListRequest
();
request
.
setFromAccount
(
"bingo"
);
request
.
setAssistFlags
(
1
);
request
.
setStartIndex
(
0
);
request
.
setTimestamp
(
213213123
);
request
.
setTopStartIndex
(
100
);
request
.
setTopTimestamp
(
1121212121
);
GetRecentContactListResult
result
=
client
.
recentContact
.
recentContactList
(
request
);
System
.
out
.
println
(
result
);
Assert
.
assertEquals
(
"OK"
,
result
.
getActionStatus
());
}
@Test
public
void
testDeleteRecentContact
()
throws
IOException
{
DeleteRecentContactRequest
request
=
new
DeleteRecentContactRequest
();
request
.
setFromAccount
(
"bingo"
);
request
.
setToAccount
(
"test1"
);
request
.
setType
(
1
);
request
.
setClearRamble
(
2
);
DeleteRecentContactResult
result
=
client
.
recentContact
.
deleteRecentContact
(
request
);
System
.
out
.
println
(
result
);
Assert
.
assertEquals
(
"OK"
,
result
.
getActionStatus
());
}
}
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