Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add type #68

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,20 @@
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.13.2</version>
<scope>compile</scope>
</dependency>
<dependency> <!-- 桥接:告诉Slf4j使用Log4j2 -->
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>2.13.1</version>
<scope>compile</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/com.lmax/disruptor -->
<dependency>
<groupId>com.lmax</groupId>
<artifactId>disruptor</artifactId>
<version>3.4.2</version>
<scope>compile</scope>
</dependency>

<dependency>
Expand Down
15 changes: 15 additions & 0 deletions examples/src/main/resources/log4j2.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="INFO">
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t]%-5level %logger{36}-[%L] - %msg%n"/>
</Console>
</Appenders>
<Loggers>
<AsyncRoot level="INFO" includeLocation="true">
<AppenderRef ref="Console"/>
</AsyncRoot>
<Logger name="io.github.wechaty" level="DEBUG">
</Logger>
</Loggers>
</Configuration>
10 changes: 6 additions & 4 deletions wechaty/src/main/kotlin/io/github/wechaty/user/Friendship.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ package io.github.wechaty.user
import io.github.wechaty.Accessory
import io.github.wechaty.Wechaty
import io.github.wechaty.schemas.FriendshipPayload
import io.github.wechaty.schemas.FriendshipSearchCondition
import io.github.wechaty.schemas.FriendshipType
import io.github.wechaty.utils.JsonUtils
import org.apache.commons.lang3.StringUtils
import org.slf4j.LoggerFactory

class Friendship (wechaty: Wechaty,val id:String):Accessory(wechaty){
Expand Down Expand Up @@ -50,7 +48,7 @@ class Friendship (wechaty: Wechaty,val id:String):Accessory(wechaty){

fun hello():String{
if(payload==null){
throw Exception("ne payload")
throw Exception("no payload")
}
return this.payload?.hello ?: "";
}
Expand All @@ -61,11 +59,15 @@ class Friendship (wechaty: Wechaty,val id:String):Accessory(wechaty){

fun toJson():String{
if(payload==null){
throw Exception("ne payload")
throw Exception("no payload")
}
return JsonUtils.write(payload!!);
}

fun getType():FriendshipType{
return payload?.type ?: throw Exception("no payload")
}

companion object{
private val log = LoggerFactory.getLogger(Friendship::class.java)
}
Expand Down