diff --git a/cim-boot-server/README.txt b/cim-boot-server/README.txt
new file mode 100644
index 0000000..aca2670
--- /dev/null
+++ b/cim-boot-server/README.txt
@@ -0,0 +1,2 @@
+如果你不想搭建服务端也可以使用,公共的服务器做测试喔
+具体信息参见:https://www.yuque.com/yuanfangxiyang/ma4ytb/vvy3iz#yC5Vq
diff --git a/cim-boot-server/pom.xml b/cim-boot-server/pom.xml
index 591572b..8be0608 100644
--- a/cim-boot-server/pom.xml
+++ b/cim-boot-server/pom.xml
@@ -48,6 +48,11 @@
spring-boot-starter-data-jpa
+
+ org.springframework.boot
+ spring-boot-starter-validation
+
+
org.springframework.boot
spring-boot-configuration-processor
diff --git a/cim-boot-server/run.sh b/cim-boot-server/run.sh
index 409113e..d95476e 100755
--- a/cim-boot-server/run.sh
+++ b/cim-boot-server/run.sh
@@ -1,3 +1,3 @@
#! /bin/bash
-java -Dcom.sun.akuma.Daemon=daemonized -Dspring.profiles.active=pro -jar ./cim-boot-server-4.2.0.jar &
\ No newline at end of file
+java -Dcom.sun.akuma.Daemon=daemonized -Dspring.profiles.active=dev -Dserver.port=9090 -jar ./cim-boot-server-4.2.0.jar &
\ No newline at end of file
diff --git a/cim-boot-server/src/main/java/com/farsunset/cim/annotation/AccessToken.java b/cim-boot-server/src/main/java/com/farsunset/cim/annotation/AccessToken.java
new file mode 100644
index 0000000..5fd208a
--- /dev/null
+++ b/cim-boot-server/src/main/java/com/farsunset/cim/annotation/AccessToken.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2013-2019 Xia Jun(3979434@qq.com).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ***************************************************************************************
+ * *
+ * Website : http://www.farsunset.com *
+ * *
+ ***************************************************************************************
+ */
+package com.farsunset.cim.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * 用户标注通过 token查到的用户账号,注入到Controller参数里面
+ */
+@Target(ElementType.PARAMETER)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface AccessToken {
+}
diff --git a/cim-boot-server/src/main/java/com/farsunset/cim/annotation/CreateAction.java b/cim-boot-server/src/main/java/com/farsunset/cim/annotation/CreateAction.java
new file mode 100644
index 0000000..b76a1f1
--- /dev/null
+++ b/cim-boot-server/src/main/java/com/farsunset/cim/annotation/CreateAction.java
@@ -0,0 +1,4 @@
+package com.farsunset.cim.annotation;
+
+public @interface CreateAction {
+}
diff --git a/cim-boot-server/src/main/java/com/farsunset/cim/annotation/UID.java b/cim-boot-server/src/main/java/com/farsunset/cim/annotation/UID.java
new file mode 100644
index 0000000..046cb4f
--- /dev/null
+++ b/cim-boot-server/src/main/java/com/farsunset/cim/annotation/UID.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2013-2019 Xia Jun(3979434@qq.com).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ***************************************************************************************
+ * *
+ * Website : http://www.farsunset.com *
+ * *
+ ***************************************************************************************
+ */
+package com.farsunset.cim.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * 用户标注通过 token查到的用户账号,注入到Controller参数里面
+ */
+@Target(ElementType.PARAMETER)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface UID {
+}
diff --git a/cim-boot-server/src/main/java/com/farsunset/cim/component/redis/TokenRedisTemplate.java b/cim-boot-server/src/main/java/com/farsunset/cim/component/redis/TokenRedisTemplate.java
new file mode 100644
index 0000000..6fee49b
--- /dev/null
+++ b/cim-boot-server/src/main/java/com/farsunset/cim/component/redis/TokenRedisTemplate.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2013-2019 Xia Jun(3979434@qq.com).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ***************************************************************************************
+ * *
+ * Website : http://www.farsunset.com *
+ * *
+ ***************************************************************************************
+ */
+package com.farsunset.cim.component.redis;
+
+import org.springframework.data.redis.connection.RedisConnectionFactory;
+import org.springframework.data.redis.core.StringRedisTemplate;
+import org.springframework.stereotype.Component;
+
+@Component
+public class TokenRedisTemplate extends StringRedisTemplate {
+
+ private static final String TOKEN_CACHE_PREFIX = "TOKEN_%s";
+
+
+ public TokenRedisTemplate(RedisConnectionFactory connectionFactory) {
+ super(connectionFactory);
+ }
+
+ public void save(String token, String uid) {
+
+ String key = String.format(TOKEN_CACHE_PREFIX,token);
+
+ super.boundValueOps(key).set(uid);
+ }
+
+ public String get(String token) {
+
+ String key = String.format(TOKEN_CACHE_PREFIX,token);
+
+ return super.boundValueOps(key).get();
+
+ }
+
+ public void remove(String token) {
+
+ String key = String.format(TOKEN_CACHE_PREFIX,token);
+
+ super.delete(key);
+ }
+
+}
diff --git a/cim-boot-server/src/main/java/com/farsunset/cim/config/MvcConfig.java b/cim-boot-server/src/main/java/com/farsunset/cim/config/MvcConfig.java
new file mode 100644
index 0000000..a4d7d57
--- /dev/null
+++ b/cim-boot-server/src/main/java/com/farsunset/cim/config/MvcConfig.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2013-2019 Xia Jun(3979434@qq.com).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ***************************************************************************************
+ * *
+ * Website : http://www.farsunset.com *
+ * *
+ ***************************************************************************************
+ */
+package com.farsunset.cim.config;
+
+import com.farsunset.cim.mvc.resolver.TokenArgumentResolver;
+import com.farsunset.cim.mvc.resolver.UidArgumentResolver;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.cors.CorsConfiguration;
+import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
+import org.springframework.web.filter.CorsFilter;
+import org.springframework.web.method.support.HandlerMethodArgumentResolver;
+import org.springframework.web.servlet.HandlerInterceptor;
+import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+@Configuration
+public class MvcConfig implements WebMvcConfigurer{
+
+ @Resource
+ private HandlerInterceptor tokenInterceptor;
+
+
+ @Override
+ public void addInterceptors(InterceptorRegistry registry) {
+
+ registry.addInterceptor(tokenInterceptor)
+ .addPathPatterns("/webrtc/**");
+
+ }
+
+
+ @Override
+ public void addArgumentResolvers(List argumentResolvers) {
+ argumentResolvers.add(new UidArgumentResolver());
+ argumentResolvers.add(new TokenArgumentResolver());
+
+ }
+
+ @Bean
+ public CorsFilter corsFilter() {
+
+ UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
+ CorsConfiguration configuration = new CorsConfiguration();
+ configuration.addAllowedOriginPattern("*");
+ configuration.addAllowedHeader("*");
+ configuration.addAllowedMethod("*");
+ configuration.setAllowCredentials(true);
+ source.registerCorsConfiguration("/**", configuration);
+
+ return new CorsFilter(source);
+ }
+
+}
\ No newline at end of file
diff --git a/cim-boot-server/src/main/java/com/farsunset/cim/config/SwaggerConfig.java b/cim-boot-server/src/main/java/com/farsunset/cim/config/SwaggerConfig.java
index ef5dbd4..405f917 100644
--- a/cim-boot-server/src/main/java/com/farsunset/cim/config/SwaggerConfig.java
+++ b/cim-boot-server/src/main/java/com/farsunset/cim/config/SwaggerConfig.java
@@ -26,10 +26,14 @@ import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.oas.annotations.EnableOpenApi;
-import springfox.documentation.service.ApiInfo;
+import springfox.documentation.service.*;
import springfox.documentation.spi.DocumentationType;
+import springfox.documentation.spi.service.contexts.SecurityContext;
import springfox.documentation.spring.web.plugins.Docket;
+import java.util.ArrayList;
+import java.util.List;
+
@EnableOpenApi
@Configuration
public class SwaggerConfig {
@@ -38,10 +42,12 @@ public class SwaggerConfig {
public Docket userApiDocket(ApiInfo apiInfo) {
return new Docket(DocumentationType.OAS_30)
.apiInfo(apiInfo)
- .groupName("APP接口")
+ .groupName("客户端接口")
.select()
.apis(RequestHandlerSelectors.basePackage("com.farsunset.cim.mvc.controller.api"))
- .build();
+ .build()
+ .securitySchemes(securitySchemes())
+ .securityContexts(securityContexts());
}
@Bean
@@ -49,8 +55,27 @@ public class SwaggerConfig {
return new ApiInfoBuilder()
.title("CIM Push Service APIs.")
.description("CIM客户端接口文档")
- .version("2.0")
+ .version("3.0")
.build();
}
+ private List securitySchemes() {
+ List schemeList = new ArrayList<>();
+ schemeList.add(new ApiKey("access-token", "access-token", "header"));
+ return schemeList;
+ }
+
+ private List securityContexts() {
+ List securityContextList = new ArrayList<>();
+ List securityReferenceList = new ArrayList<>();
+ securityReferenceList.add(new SecurityReference("access-token", new AuthorizationScope[]{new AuthorizationScope("global", "accessAnything")}));
+ securityContextList.add(SecurityContext
+ .builder()
+ .securityReferences(securityReferenceList)
+ .operationSelector(operationContext -> true)
+ .build()
+ );
+ return securityContextList;
+ }
+
}
diff --git a/cim-boot-server/src/main/java/com/farsunset/cim/constants/MessageAction.java b/cim-boot-server/src/main/java/com/farsunset/cim/constants/MessageAction.java
new file mode 100644
index 0000000..c3d2546
--- /dev/null
+++ b/cim-boot-server/src/main/java/com/farsunset/cim/constants/MessageAction.java
@@ -0,0 +1,165 @@
+/*
+ * Copyright 2013-2019 Xia Jun(3979434@qq.com).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ***************************************************************************************
+ * *
+ * Website : http://www.farsunset.com *
+ * *
+ ***************************************************************************************
+ */
+package com.farsunset.cim.constants;
+
+public interface MessageAction {
+
+ /*
+ * 系统定制消息---语音通话请求
+ */
+ String ACTION_900 = "900";
+
+ /*
+ * 系统定制消息---视频通话请求
+ */
+ String ACTION_901 = "901";
+
+ /*
+ * 系统定制消息---通话接受
+ */
+ String ACTION_902 = "902";
+
+ /*
+ * 系统定制消息---通话拒绝
+ */
+ String ACTION_903 = "903";
+
+ /*
+ * 系统定制消息---对方正忙
+ */
+ String ACTION_904 = "904";
+
+ /*
+ * 系统定制消息---对方挂断
+ */
+ String ACTION_905 = "905";
+
+ /*
+ * 系统定制消息---取消呼叫
+ */
+ String ACTION_906 = "906";
+
+ /*
+ * 系统定制消息---同步ICE SPD
+ */
+ String ACTION_907 = "907";
+
+ /*
+ * 系统定制消息---同步Offer
+ */
+ String ACTION_908 = "908";
+
+ /*
+ * 系统定制消息---同步Answer
+ */
+ String ACTION_909 = "909";
+
+ /*
+ * 系统定制消息---多人语音通话请求
+ */
+ String ACTION_910 = "910";
+
+ /*
+ * 系统定制消息---多人视频通话请求
+ */
+ String ACTION_911 = "911";
+
+ /*
+ *系统定制消息---多人通话-同意
+ */
+ String ACTION_912 = "912";
+
+ /*
+ *系统定制消息---多人通话-拒绝
+ */
+ String ACTION_913 = "913";
+
+ /*
+ *系统定制消息---多人通话-忙线
+ */
+ String ACTION_914 = "914";
+
+ /*
+ *系统定制消息---多人通话-开麦开关
+ */
+ String ACTION_915 = "915";
+
+ /*
+ *系统定制消息---多人通话-摄像头开关
+ */
+ String ACTION_916 = "916";
+
+ /*
+ *系统定制消息---多人通话-加人
+ */
+ String ACTION_917 = "917";
+
+ /*
+ *系统定制消息---多人通话-退出
+ */
+ String ACTION_918 = "918";
+
+ /*
+ *系统定制消息---多人通话-取消呼叫
+ */
+ String ACTION_919 = "919";
+
+ /*
+ * 系统定制消息---多人通话-同步Offer
+ */
+ String ACTION_920 = "920";
+
+ /*
+ * 系统定制消息---多人通话-同步Answer
+ */
+ String ACTION_921 = "921";
+
+ /*
+ * 系统定制消息---多人通话-同步ICE
+ */
+ String ACTION_922 = "922";
+
+ /*
+ *系统定制消息---多人通话-未响应
+ */
+ String ACTION_923 = "923";
+
+ /*
+ *系统定制消息---多人通话-结束会议
+ */
+ String ACTION_924 = "924";
+
+ /*
+ *系统定制消息---多人通话-全员静音
+ */
+ String ACTION_925 = "925";
+
+ /*
+ *系统定制消息---多人通话-取消全员静音
+ */
+ String ACTION_926 = "926";
+
+ /*
+ *系统定制消息---多人通话-有人再次被呼叫
+ */
+ String ACTION_927 = "927";
+}
diff --git a/cim-boot-server/src/main/java/com/farsunset/cim/mvc/controller/api/UserController.java b/cim-boot-server/src/main/java/com/farsunset/cim/mvc/controller/api/UserController.java
new file mode 100644
index 0000000..f9f7807
--- /dev/null
+++ b/cim-boot-server/src/main/java/com/farsunset/cim/mvc/controller/api/UserController.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2013-2019 Xia Jun(3979434@qq.com).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ***************************************************************************************
+ * *
+ * Website : http://www.farsunset.com *
+ * *
+ ***************************************************************************************
+ */
+package com.farsunset.cim.mvc.controller.api;
+
+
+import com.farsunset.cim.annotation.AccessToken;
+import com.farsunset.cim.mvc.response.ResponseEntity;
+import com.farsunset.cim.service.AccessTokenService;
+import io.swagger.annotations.*;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import java.util.HashMap;
+import java.util.Map;
+
+@RestController
+@RequestMapping("/user")
+@Api(produces = "application/json", tags = "用户登录接口" )
+@Validated
+public class UserController {
+
+ @Resource
+ private AccessTokenService accessTokenService;
+
+ @ApiOperation(httpMethod = "POST", value = "模拟登录")
+ @ApiImplicitParams({
+ @ApiImplicitParam(name = "telephone", value = "手机号码", paramType = "query", dataTypeClass = String.class),
+ @ApiImplicitParam(name = "password", value = "密码", paramType = "query", dataTypeClass = String.class),
+ })
+ @PostMapping(value = "/login")
+ public ResponseEntity> login(@RequestParam String telephone) {
+
+
+ Map body = new HashMap<>();
+ body.put("id",Long.parseLong(telephone));
+ body.put("name","测试用户");
+ body.put("telephone","telephone");
+
+ ResponseEntity