17 changed files with 1523 additions and 25 deletions
@ -0,0 +1,53 @@
|
||||
package net.sopod.soim.common.util; |
||||
|
||||
import com.google.common.base.Preconditions; |
||||
|
||||
import java.time.*; |
||||
import java.util.Date; |
||||
|
||||
/** |
||||
* ImClock |
||||
* |
||||
* @author tmy |
||||
* @date 2022-03-31 21:16 |
||||
*/ |
||||
public class ImClock { |
||||
|
||||
private static Clock clock = Clock.systemDefaultZone(); |
||||
|
||||
public static long millis() { |
||||
return clock.millis(); |
||||
} |
||||
|
||||
public static int seconds() { |
||||
return (int) (millis() / 1000); |
||||
} |
||||
|
||||
public static LocalDateTime dateTime() { |
||||
return LocalDateTime.now(clock); |
||||
} |
||||
|
||||
public static LocalDate localDate() { |
||||
return LocalDate.now(clock); |
||||
} |
||||
|
||||
public static Date date() { |
||||
return new Date(clock.millis()); |
||||
} |
||||
|
||||
public static LocalDateTime msec2time(long msec) { |
||||
Instant instant = Instant.ofEpochMilli(msec); |
||||
return LocalDateTime.ofInstant(instant, ZoneId.systemDefault()); |
||||
} |
||||
|
||||
public static void setClock(Clock newClock) { |
||||
Preconditions.checkNotNull(newClock); |
||||
Preconditions.checkArgument( |
||||
clock.millis() <= newClock.millis(), |
||||
"不允许回调时间: current=%s, new=%s", |
||||
LocalDateTime.now(clock), |
||||
LocalDateTime.now(newClock)); |
||||
ImClock.clock = newClock; |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" |
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
||||
<parent> |
||||
<artifactId>so-im</artifactId> |
||||
<groupId>net.sopod</groupId> |
||||
<version>1.0.0</version> |
||||
</parent> |
||||
<modelVersion>4.0.0</modelVersion> |
||||
|
||||
<artifactId>im-das-api</artifactId> |
||||
|
||||
|
||||
</project> |
||||
@ -0,0 +1,60 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" |
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
||||
<parent> |
||||
<artifactId>im-das</artifactId> |
||||
<groupId>net.sopod</groupId> |
||||
<version>1.0.0</version> |
||||
</parent> |
||||
<modelVersion>4.0.0</modelVersion> |
||||
|
||||
<artifactId>im-das-user</artifactId> |
||||
|
||||
<dependencies> |
||||
<dependency> |
||||
<groupId>org.springframework.boot</groupId> |
||||
<artifactId>spring-boot-starter</artifactId> |
||||
<exclusions><!-- 去掉springboot默认logback日志配置 --> |
||||
<exclusion> |
||||
<groupId>org.springframework.boot</groupId> |
||||
<artifactId>spring-boot-starter-logging</artifactId> |
||||
</exclusion> |
||||
</exclusions> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.springframework.boot</groupId> |
||||
<artifactId>spring-boot-starter-log4j2</artifactId> |
||||
<exclusions> |
||||
<exclusion> |
||||
<groupId>com.fasterxml.jackson.core</groupId> |
||||
<artifactId>jackson-databind</artifactId> |
||||
</exclusion> |
||||
<exclusion> |
||||
<groupId>com.fasterxml.jackson.datatype</groupId> |
||||
<artifactId>jackson-datatype-jsr310</artifactId> |
||||
</exclusion> |
||||
</exclusions> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.apache.dubbo</groupId> |
||||
<artifactId>dubbo-spring-boot-starter</artifactId> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.apache.dubbo</groupId> |
||||
<artifactId>dubbo-registry-nacos</artifactId> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.apache.shardingsphere</groupId> |
||||
<artifactId>sharding-jdbc-spring-boot-starter</artifactId> |
||||
<exclusions> |
||||
<exclusion> |
||||
<groupId>com.google.guava</groupId> |
||||
<artifactId>guava</artifactId> |
||||
</exclusion> |
||||
</exclusions> |
||||
</dependency> |
||||
</dependencies> |
||||
|
||||
|
||||
</project> |
||||
@ -0,0 +1,21 @@
|
||||
package net.sopod.soim.das.user; |
||||
|
||||
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo; |
||||
import org.springframework.boot.SpringApplication; |
||||
import org.springframework.boot.autoconfigure.SpringBootApplication; |
||||
|
||||
/** |
||||
* DasUserApplication |
||||
* |
||||
* @author tmy |
||||
* @date 2022-03-31 22:31 |
||||
*/ |
||||
@EnableDubbo(scanBasePackages = {"net.sopod.soim.das.user.service"}) |
||||
@SpringBootApplication |
||||
public class DasUserApplication { |
||||
|
||||
public static void main(String[] args) { |
||||
SpringApplication.run(DasUserApplication.class, args); |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,7 @@
|
||||
package net.sopod.soim.das.user.service; |
||||
|
||||
public interface HelloService { |
||||
|
||||
String sayHello(String name); |
||||
|
||||
} |
||||
@ -0,0 +1,21 @@
|
||||
package net.sopod.soim.das.user.service; |
||||
|
||||
import org.apache.dubbo.config.annotation.DubboService; |
||||
import org.apache.dubbo.rpc.RpcContext; |
||||
|
||||
/** |
||||
* HelloServiceImpl |
||||
* |
||||
* @author tmy |
||||
* @date 2022-03-28 16:23 |
||||
*/ |
||||
@DubboService(version = "1.0.0") |
||||
public class HelloServiceImpl implements HelloService { |
||||
|
||||
@Override |
||||
public String sayHello(String name) { |
||||
System.out.println("be invoked! client:" + RpcContext.getClientAttachment().getObjectAttachments()); |
||||
return "hello "+ name; |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,7 @@
|
||||
dubbo: |
||||
application: |
||||
name: das-user |
||||
registry: |
||||
address: nacos://124.222.131.236:3848 |
||||
protocol: |
||||
port: 8081 |
||||
@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" |
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
||||
<parent> |
||||
<artifactId>so-im</artifactId> |
||||
<groupId>net.sopod</groupId> |
||||
<version>1.0.0</version> |
||||
</parent> |
||||
<modelVersion>4.0.0</modelVersion> |
||||
|
||||
<artifactId>im-das</artifactId> |
||||
<packaging>pom</packaging> |
||||
<modules> |
||||
<module>im-das-user</module> |
||||
</modules> |
||||
|
||||
</project> |
||||
@ -0,0 +1,15 @@
|
||||
package net.sopod.soim.logic.api.auth.model; |
||||
|
||||
/** |
||||
* LoginParam |
||||
* |
||||
* @author tmy |
||||
* @date 2022-03-31 21:06 |
||||
*/ |
||||
public class ReqLogin { |
||||
|
||||
private String username; |
||||
|
||||
private String password; |
||||
|
||||
} |
||||
@ -0,0 +1,18 @@
|
||||
package net.sopod.soim.logic.api.auth.service; |
||||
|
||||
import net.sopod.soim.logic.api.auth.model.ReqLogin; |
||||
|
||||
/** |
||||
* AuthService |
||||
* |
||||
* @author tmy |
||||
* @date 2022-03-31 21:03 |
||||
*/ |
||||
public interface AuthService { |
||||
|
||||
/** |
||||
* 登录请求 |
||||
*/ |
||||
void login(ReqLogin reqLogin); |
||||
|
||||
} |
||||
Loading…
Reference in new issue