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
2bac04b8
Unverified
Commit
2bac04b8
authored
Jul 31, 2021
by
yu
Committed by
GitHub
Jul 31, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: add operation api (#11)
* feat: add operation api * doc: modify author
parent
6ef2496d
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
276 additions
and
9 deletions
+276
-9
IMClient.java
src/main/java/com/qcloud/im/IMClient.java
+3
-4
Operation.java
src/main/java/com/qcloud/im/core/Operation.java
+43
-0
FriendImportRequest.java
...java/com/qcloud/im/model/request/FriendImportRequest.java
+1
-2
GetNoSpeakingRequest.java
...ava/com/qcloud/im/model/request/GetNoSpeakingRequest.java
+28
-0
SetNoSpeakingRequest.java
...ava/com/qcloud/im/model/request/SetNoSpeakingRequest.java
+52
-0
GenericResult.java
...main/java/com/qcloud/im/model/response/GenericResult.java
+3
-3
GetNoSpeakingResult.java
...ava/com/qcloud/im/model/response/GetNoSpeakingResult.java
+45
-0
SetNoSpeakingResult.java
...ava/com/qcloud/im/model/response/SetNoSpeakingResult.java
+45
-0
OperationTest.java
src/test/java/com/qcloud/im/OperationTest.java
+56
-0
No files found.
src/main/java/com/qcloud/im/IMClient.java
View file @
2bac04b8
package
com
.
qcloud
.
im
;
package
com
.
qcloud
.
im
;
import
com.qcloud.im.core.Account
;
import
com.qcloud.im.core.*
;
import
com.qcloud.im.core.Message
;
import
com.qcloud.im.core.Profile
;
import
com.qcloud.im.core.SNS
;
import
com.qcloud.im.util.SigUtil
;
import
com.qcloud.im.util.SigUtil
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.concurrent.ConcurrentHashMap
;
...
@@ -24,6 +21,7 @@ public class IMClient {
...
@@ -24,6 +21,7 @@ public class IMClient {
public
Message
message
;
public
Message
message
;
public
Profile
profile
;
public
Profile
profile
;
public
SNS
sns
;
public
SNS
sns
;
public
Operation
operation
;
/**
/**
* init property
* init property
*/
*/
...
@@ -55,6 +53,7 @@ public class IMClient {
...
@@ -55,6 +53,7 @@ public class IMClient {
account
=
new
Account
(
this
);
account
=
new
Account
(
this
);
message
=
new
Message
(
this
);
message
=
new
Message
(
this
);
profile
=
new
Profile
(
this
);
profile
=
new
Profile
(
this
);
operation
=
new
Operation
(
this
);
sns
=
new
SNS
(
this
);
sns
=
new
SNS
(
this
);
}
}
...
...
src/main/java/com/qcloud/im/core/Operation.java
0 → 100644
View file @
2bac04b8
package
com
.
qcloud
.
im
.
core
;
import
com.qcloud.im.IMClient
;
import
com.qcloud.im.model.request.GetNoSpeakingRequest
;
import
com.qcloud.im.model.request.SetNoSpeakingRequest
;
import
com.qcloud.im.model.response.GetNoSpeakingResult
;
import
com.qcloud.im.model.response.SetNoSpeakingResult
;
import
com.qcloud.im.util.HttpUtil
;
import
com.qcloud.im.util.JsonUtil
;
import
java.io.IOException
;
/**
* @author xy
* @since 2021/07/31 11:17
*/
public
class
Operation
{
private
static
final
String
SERVICE_NAME_OPEN_CONFIG
=
"openconfigsvr"
;
private
static
final
String
SERVICE_NAME_OPEN_MSG
=
"open_msg_svc"
;
private
static
final
String
SERVICE_NAME_CONFIG
=
"ConfigSvc"
;
private
static
final
String
SET_NO_SPEAKING_COMMAND
=
"setnospeaking"
;
private
static
final
String
GET_NO_SPEAKING_COMMAND
=
"getnospeaking"
;
private
final
IMClient
imClient
;
public
SetNoSpeakingResult
setNoSpeaking
(
SetNoSpeakingRequest
setNoSpeakingRequest
)
throws
IOException
{
String
url
=
imClient
.
getUrl
(
SERVICE_NAME_OPEN_CONFIG
,
SET_NO_SPEAKING_COMMAND
);
String
result
=
HttpUtil
.
post
(
url
,
JsonUtil
.
obj2Str
(
setNoSpeakingRequest
),
null
);
return
JsonUtil
.
str2Obj
(
result
,
SetNoSpeakingResult
.
class
);
}
public
GetNoSpeakingResult
getNoSpeaking
(
GetNoSpeakingRequest
getNoSpeakingRequest
)
throws
IOException
{
String
url
=
imClient
.
getUrl
(
SERVICE_NAME_OPEN_CONFIG
,
GET_NO_SPEAKING_COMMAND
);
String
result
=
HttpUtil
.
post
(
url
,
JsonUtil
.
obj2Str
(
getNoSpeakingRequest
),
null
);
return
JsonUtil
.
str2Obj
(
result
,
GetNoSpeakingResult
.
class
);
}
public
Operation
(
IMClient
imClient
)
{
this
.
imClient
=
imClient
;
}
}
src/main/java/com/qcloud/im/model/request/FriendImportRequest.java
View file @
2bac04b8
package
com
.
qcloud
.
im
.
model
.
request
;
package
com
.
qcloud
.
im
.
model
.
request
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
com.qcloud.im.model.response.GenericResult
;
import
java.util.List
;
import
java.util.List
;
...
@@ -9,7 +8,7 @@ import java.util.List;
...
@@ -9,7 +8,7 @@ import java.util.List;
* @author hyh
* @author hyh
* @since 2021/07/29 15:19
* @since 2021/07/29 15:19
*/
*/
public
class
FriendImportRequest
extends
GenericRe
sul
t
{
public
class
FriendImportRequest
extends
GenericRe
ques
t
{
@JsonProperty
(
"From_Account"
)
@JsonProperty
(
"From_Account"
)
private
String
fromAccount
;
private
String
fromAccount
;
...
...
src/main/java/com/qcloud/im/model/request/GetNoSpeakingRequest.java
0 → 100644
View file @
2bac04b8
package
com
.
qcloud
.
im
.
model
.
request
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
/**
* @author xy
* @since 2021/07/31 11:48
*/
public
class
GetNoSpeakingRequest
extends
GenericRequest
{
@JsonProperty
(
"Get_Account"
)
private
String
getAccount
;
public
GetNoSpeakingRequest
()
{
}
public
GetNoSpeakingRequest
(
String
getAccount
)
{
this
.
getAccount
=
getAccount
;
}
public
String
getGetAccount
()
{
return
getAccount
;
}
public
void
setGetAccount
(
String
getAccount
)
{
this
.
getAccount
=
getAccount
;
}
}
src/main/java/com/qcloud/im/model/request/SetNoSpeakingRequest.java
0 → 100644
View file @
2bac04b8
package
com
.
qcloud
.
im
.
model
.
request
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
/**
* @author xy
* @since 2021/07/31 11:39
*/
public
class
SetNoSpeakingRequest
extends
GenericRequest
{
@JsonProperty
(
"Set_Account"
)
private
String
setAccount
;
@JsonProperty
(
"C2CmsgNospeakingTime"
)
private
Integer
msgNoSpeakingTime
;
@JsonProperty
(
"GroupmsgNospeakingTime"
)
private
Integer
groupMsgNoSpeakingTime
;
public
SetNoSpeakingRequest
()
{
}
public
SetNoSpeakingRequest
(
String
setAccount
,
Integer
msgNoSpeakingTime
,
Integer
groupMsgNoSpeakingTime
)
{
this
.
setAccount
=
setAccount
;
this
.
msgNoSpeakingTime
=
msgNoSpeakingTime
;
this
.
groupMsgNoSpeakingTime
=
groupMsgNoSpeakingTime
;
}
public
String
getSetAccount
()
{
return
setAccount
;
}
public
void
setSetAccount
(
String
setAccount
)
{
this
.
setAccount
=
setAccount
;
}
public
Integer
getMsgNoSpeakingTime
()
{
return
msgNoSpeakingTime
;
}
public
void
setMsgNoSpeakingTime
(
Integer
msgNoSpeakingTime
)
{
this
.
msgNoSpeakingTime
=
msgNoSpeakingTime
;
}
public
Integer
getGroupMsgNoSpeakingTime
()
{
return
groupMsgNoSpeakingTime
;
}
public
void
setGroupMsgNoSpeakingTime
(
Integer
groupMsgNoSpeakingTime
)
{
this
.
groupMsgNoSpeakingTime
=
groupMsgNoSpeakingTime
;
}
}
src/main/java/com/qcloud/im/model/response/GenericResult.java
View file @
2bac04b8
...
@@ -23,7 +23,7 @@ public abstract class GenericResult {
...
@@ -23,7 +23,7 @@ public abstract class GenericResult {
* 错误码,0为成功,其他为失败,错误码表:https://cloud.tencent.com/document/product/269/1671
* 错误码,0为成功,其他为失败,错误码表:https://cloud.tencent.com/document/product/269/1671
*/
*/
@JsonProperty
(
"ErrorCode"
)
@JsonProperty
(
"ErrorCode"
)
private
String
errorCode
;
private
Integer
errorCode
;
public
String
getActionStatus
()
{
public
String
getActionStatus
()
{
return
actionStatus
;
return
actionStatus
;
...
@@ -41,11 +41,11 @@ public abstract class GenericResult {
...
@@ -41,11 +41,11 @@ public abstract class GenericResult {
this
.
errorInfo
=
errorInfo
;
this
.
errorInfo
=
errorInfo
;
}
}
public
String
getErrorCode
()
{
public
Integer
getErrorCode
()
{
return
errorCode
;
return
errorCode
;
}
}
public
void
setErrorCode
(
String
errorCode
)
{
public
void
setErrorCode
(
Integer
errorCode
)
{
this
.
errorCode
=
errorCode
;
this
.
errorCode
=
errorCode
;
}
}
...
...
src/main/java/com/qcloud/im/model/response/GetNoSpeakingResult.java
0 → 100644
View file @
2bac04b8
package
com
.
qcloud
.
im
.
model
.
response
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
/**
* @author xy
* @since 2021/07/31 11:51:01
*/
public
class
GetNoSpeakingResult
{
/**
* 失败原因
*/
@JsonProperty
(
"ErrorInfo"
)
private
String
errorInfo
;
/**
* 错误码,0为成功,其他为失败,错误码表:https://cloud.tencent.com/document/product/269/1671
*/
@JsonProperty
(
"ErrorCode"
)
private
Integer
errorCode
;
public
String
getErrorInfo
()
{
return
errorInfo
;
}
public
void
setErrorInfo
(
String
errorInfo
)
{
this
.
errorInfo
=
errorInfo
;
}
public
Integer
getErrorCode
()
{
return
errorCode
;
}
public
void
setErrorCode
(
Integer
errorCode
)
{
this
.
errorCode
=
errorCode
;
}
@Override
public
String
toString
()
{
return
"GetNoSpeakingResult{"
+
"errorInfo='"
+
errorInfo
+
'\''
+
", errorCode="
+
errorCode
+
'}'
;
}
}
src/main/java/com/qcloud/im/model/response/SetNoSpeakingResult.java
0 → 100644
View file @
2bac04b8
package
com
.
qcloud
.
im
.
model
.
response
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
/**
* @author xy
* @since 2021/07/31 11:51:01
*/
public
class
SetNoSpeakingResult
{
/**
* 失败原因
*/
@JsonProperty
(
"ErrorInfo"
)
private
String
errorInfo
;
/**
* 错误码,0为成功,其他为失败,错误码表:https://cloud.tencent.com/document/product/269/1671
*/
@JsonProperty
(
"ErrorCode"
)
private
Integer
errorCode
;
public
String
getErrorInfo
()
{
return
errorInfo
;
}
public
void
setErrorInfo
(
String
errorInfo
)
{
this
.
errorInfo
=
errorInfo
;
}
public
Integer
getErrorCode
()
{
return
errorCode
;
}
public
void
setErrorCode
(
Integer
errorCode
)
{
this
.
errorCode
=
errorCode
;
}
@Override
public
String
toString
()
{
return
"SetNoSpeakingResult{"
+
"errorInfo='"
+
errorInfo
+
'\''
+
", errorCode="
+
errorCode
+
'}'
;
}
}
src/test/java/com/qcloud/im/OperationTest.java
0 → 100644
View file @
2bac04b8
package
com
.
qcloud
.
im
;
import
com.qcloud.im.model.request.GetNoSpeakingRequest
;
import
com.qcloud.im.model.request.SetNoSpeakingRequest
;
import
com.qcloud.im.model.response.GetNoSpeakingResult
;
import
com.qcloud.im.model.response.SetNoSpeakingResult
;
import
org.junit.Assert
;
import
org.junit.Test
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.util.Properties
;
/**
* @author xy
* @since 2021/07/31 15:36:40
*/
public
class
OperationTest
{
private
static
final
Properties
properties
=
new
Properties
();
private
static
final
IMClient
client
;
static
{
InputStream
resourceAsStream
=
OperationTest
.
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
testSetNoSpeaking
()
throws
IOException
{
SetNoSpeakingRequest
request
=
new
SetNoSpeakingRequest
();
request
.
setSetAccount
(
"test1"
);
request
.
setMsgNoSpeakingTime
(
11111
);
request
.
setGroupMsgNoSpeakingTime
(
11111
);
SetNoSpeakingResult
result
=
client
.
operation
.
setNoSpeaking
(
request
);
System
.
out
.
println
(
result
);
Assert
.
assertEquals
(
0
,
(
int
)
result
.
getErrorCode
());
}
@Test
public
void
testGetNoSpeaking
()
throws
IOException
{
GetNoSpeakingRequest
request
=
new
GetNoSpeakingRequest
();
request
.
setGetAccount
(
"test1"
);
GetNoSpeakingResult
result
=
client
.
operation
.
getNoSpeaking
(
request
);
System
.
out
.
println
(
result
);
Assert
.
assertEquals
(
0
,
(
int
)
result
.
getErrorCode
());
}
}
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