测试接口
This commit is contained in:
parent
75ae0a7a28
commit
094e86130d
38
iot-modules/iot-box-user-api/.gitignore
vendored
Normal file
38
iot-modules/iot-box-user-api/.gitignore
vendored
Normal file
@ -0,0 +1,38 @@
|
||||
target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**/target/
|
||||
!**/src/test/**/target/
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea/modules.xml
|
||||
.idea/jarRepositories.xml
|
||||
.idea/compiler.xml
|
||||
.idea/libraries/
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### Eclipse ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
build/
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
|
||||
### Mac OS ###
|
||||
.DS_Store
|
||||
101
iot-modules/iot-box-user-api/pom.xml
Normal file
101
iot-modules/iot-box-user-api/pom.xml
Normal file
@ -0,0 +1,101 @@
|
||||
<?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">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.qiuguo.iot</groupId>
|
||||
<artifactId>iot-modules</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>iot-box-user-api</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-webflux</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.hswebframework.web</groupId>
|
||||
<artifactId>hsweb-commons-crud</artifactId>
|
||||
<version>${hsweb.framework.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hswebframework.web</groupId>
|
||||
<artifactId>hsweb-system-authorization-default</artifactId>
|
||||
<version>${hsweb.framework.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.hswebframework</groupId>
|
||||
<artifactId>hsweb-easy-orm-rdb</artifactId>
|
||||
<version>${hsweb.framework.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.hswebframework.web</groupId>
|
||||
<artifactId>hsweb-starter</artifactId>
|
||||
<version>${hsweb.framework.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.projectreactor</groupId>
|
||||
<artifactId>reactor-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<finalName>${project.artifactId}</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spring-milestones</id>
|
||||
<name>Spring Milestones</name>
|
||||
<url>https://repo.spring.io/milestone</url>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>spring-snapshots</id>
|
||||
<name>Spring Snapshots</name>
|
||||
<url>https://repo.spring.io/snapshot</url>
|
||||
<releases>
|
||||
<enabled>false</enabled>
|
||||
</releases>
|
||||
</repository>
|
||||
</repositories>
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>spring-milestones</id>
|
||||
<name>Spring Milestones</name>
|
||||
<url>https://repo.spring.io/milestone</url>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</pluginRepository>
|
||||
<pluginRepository>
|
||||
<id>spring-snapshots</id>
|
||||
<name>Spring Snapshots</name>
|
||||
<url>https://repo.spring.io/snapshot</url>
|
||||
<releases>
|
||||
<enabled>false</enabled>
|
||||
</releases>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
|
||||
</project>
|
||||
@ -0,0 +1,13 @@
|
||||
package com.qiuguo.iot.user.api;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class IotBoxUserApiApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(IotBoxUserApiApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,64 @@
|
||||
package com.qiuguo.iot.user.api.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import java.util.Objects;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.reactive.function.client.WebClient;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import static org.springframework.http.MediaType.APPLICATION_FORM_URLENCODED_VALUE;
|
||||
|
||||
/**
|
||||
* XXX
|
||||
*
|
||||
* @author weiyachao
|
||||
* @since 2023/8/3 17:29
|
||||
*/
|
||||
|
||||
@RestController
|
||||
@Slf4j
|
||||
@RequestMapping("/user")
|
||||
public class UserController {
|
||||
private final WebClient webClient = WebClient.builder()
|
||||
.defaultHeader(HttpHeaders.CONTENT_TYPE,APPLICATION_FORM_URLENCODED_VALUE)
|
||||
// .defaultHeader("Api-Type","box")
|
||||
.build();
|
||||
|
||||
@Value("${userUrl.baseUrl}")
|
||||
private String baseUrl;
|
||||
|
||||
@Value("${userUrl.pwdUrl}")
|
||||
private String pwdUrl;
|
||||
|
||||
@Value("${userUrl.smsUrl}")
|
||||
private String smsUrl;
|
||||
|
||||
@Value("${userUrl.sendSmsUrl}")
|
||||
private String sendSmsUrl;
|
||||
|
||||
@PostMapping("/login/pwd")
|
||||
public Mono<JSONObject> loginByPwd(@RequestBody JSONObject jsonObject) {
|
||||
MultiValueMap<String,String> object = new LinkedMultiValueMap<>();
|
||||
jsonObject.forEach((k,v)->{
|
||||
object.add(k, String.valueOf(v));
|
||||
});
|
||||
Mono<JSONObject> jsonObjectMono = webClient.post().uri(baseUrl + pwdUrl).bodyValue(object).retrieve()
|
||||
.bodyToMono(JSONObject.class)
|
||||
.doOnNext(res -> {
|
||||
if (!Objects.equals(res.getInteger("code"), 1)) {
|
||||
throw new RuntimeException("参数错误");
|
||||
}
|
||||
});
|
||||
return jsonObjectMono;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,53 @@
|
||||
server:
|
||||
port: 9701
|
||||
spring:
|
||||
profiles:
|
||||
# 环境配置
|
||||
active: dev
|
||||
application:
|
||||
name: qiuguo-iot-box-user-api
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 172.24.218.235:8848/
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 172.24.218.235:8848/
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
shared-configs:
|
||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||
redis:
|
||||
# cluster:
|
||||
# nodes:
|
||||
# - 127.0.0.1:7001
|
||||
# - 127.0.0.1:7002
|
||||
host: 192.168.8.101
|
||||
port: 6379
|
||||
password: 123456
|
||||
timeout: 5000
|
||||
r2dbc:
|
||||
url: r2dbc:mysql://172.24.218.235:3306/qiuguo-reseller?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
|
||||
username: root
|
||||
password: '!pHuRvGKIsbiqcX1'
|
||||
easyorm:
|
||||
auto-ddl: true
|
||||
default-schema: qiuguo_iot # 默认使用的schema. mysql时则为数据库名
|
||||
dialect: mysql # 方言: h2,mysql,postgresql
|
||||
logging:
|
||||
level:
|
||||
org.hswebframework: debug
|
||||
org.hswebframework.expands: error
|
||||
hsweb:
|
||||
webflux:
|
||||
response-wrapper:
|
||||
enabled: true # 将响应结果包装为{"status":200,"result":{}}
|
||||
excludes: #不包装的类
|
||||
- org.springdoc
|
||||
userUrl:
|
||||
baseUrl: 'https://exper.qiuguojihua.com/data'
|
||||
pwdUrl: '/api.login/in'
|
||||
smsUrl: '/api.login/phone'
|
||||
sendSmsUrl: '/api.login/sendsms'
|
||||
@ -12,6 +12,8 @@
|
||||
<modules>
|
||||
<module>iot-customer-http-api</module>
|
||||
<module>iot-admin-http-api</module>
|
||||
<module>iot-box-websocket</module>
|
||||
<module>iot-box-user-api</module>
|
||||
</modules>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user