feat():账号密码存入数据库
parent
6ba71a95d4
commit
705414778c
|
@ -121,11 +121,11 @@ public class ManageInstance implements ApplicationRunner {
|
||||||
log.info("正在加载实例");
|
log.info("正在加载实例");
|
||||||
Thread.sleep(30000);
|
Thread.sleep(30000);
|
||||||
List<InstanceInfo> instanceInfos = SelectInstance.selectInstance(list);
|
List<InstanceInfo> instanceInfos = SelectInstance.selectInstance(list);
|
||||||
log.info("实例信息加载成功");
|
log.info("实例信息查询成功");
|
||||||
for (InstanceInfo instanceInfo : instanceInfos) {
|
// for (InstanceInfo instanceInfo : instanceInfos) {
|
||||||
redisService.getCacheObject(instanceInfo.getInstanceId());
|
// redisService.getCacheObject(instanceInfo.getInstanceId());
|
||||||
} log.info("实例信息:{}",instanceInfos);
|
// }
|
||||||
|
log.info("实例信息:",instanceInfos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
package com.muyu.vehicle.config;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 链接fluxMq
|
||||||
|
*/
|
||||||
|
public class ConnectFluxMq {
|
||||||
|
|
||||||
|
}
|
|
@ -1,29 +0,0 @@
|
||||||
package com.muyu.vehicle.config;
|
|
||||||
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import org.springframework.http.client.ClientHttpRequestFactory;
|
|
||||||
import org.springframework.http.client.SimpleClientHttpRequestFactory;
|
|
||||||
import org.springframework.web.client.RestTemplate;
|
|
||||||
|
|
||||||
@Configuration
|
|
||||||
public class RestTemplateConfig {
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public RestTemplate restTemplate(ClientHttpRequestFactory factory){
|
|
||||||
return new RestTemplate(factory);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public ClientHttpRequestFactory simpleClientHttpRequestFactory() {
|
|
||||||
SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory();
|
|
||||||
//超时设置
|
|
||||||
factory.setReadTimeout(5000);//ms
|
|
||||||
factory.setConnectTimeout(15000);//ms
|
|
||||||
return factory;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -35,7 +35,7 @@ public class SelectInstance {
|
||||||
DescribeInstancesResponse resp = client.describeInstancesWithOptions(describeInstancesRequest, runtime);
|
DescribeInstancesResponse resp = client.describeInstancesWithOptions(describeInstancesRequest, runtime);
|
||||||
DescribeInstancesResponseBody body = resp.getBody();
|
DescribeInstancesResponseBody body = resp.getBody();
|
||||||
|
|
||||||
ArrayList<InstanceInfo> exampleInformations = new ArrayList<>();
|
ArrayList<InstanceInfo> list = new ArrayList<>();
|
||||||
for (DescribeInstancesResponseBody.DescribeInstancesResponseBodyInstancesInstance instance : body.getInstances().getInstance()){
|
for (DescribeInstancesResponseBody.DescribeInstancesResponseBodyInstancesInstance instance : body.getInstances().getInstance()){
|
||||||
InstanceInfo instanceInfo = new InstanceInfo();
|
InstanceInfo instanceInfo = new InstanceInfo();
|
||||||
instanceInfo.setInstanceId(instance.getInstanceId());
|
instanceInfo.setInstanceId(instance.getInstanceId());
|
||||||
|
@ -44,9 +44,9 @@ public class SelectInstance {
|
||||||
log.info("实例状态:{}",instanceInfo.getStatus());
|
log.info("实例状态:{}",instanceInfo.getStatus());
|
||||||
instanceInfo.setIpAddress(String.valueOf(instance.getPublicIpAddress().getIpAddress()));
|
instanceInfo.setIpAddress(String.valueOf(instance.getPublicIpAddress().getIpAddress()));
|
||||||
log.info("实例IP:{}",instanceInfo.getIpAddress());
|
log.info("实例IP:{}",instanceInfo.getIpAddress());
|
||||||
exampleInformations.add(instanceInfo);
|
list.add(instanceInfo);
|
||||||
}
|
}
|
||||||
log.info("实例信息:{}",instanceInfos);
|
log.info("实例信息:",list);
|
||||||
return instanceInfos;
|
return instanceInfos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,19 +1,27 @@
|
||||||
package com.muyu.vehicle.controller;
|
package com.muyu.vehicle.controller;
|
||||||
import com.muyu.common.core.domain.Result;
|
import com.muyu.common.core.domain.Result;
|
||||||
|
import com.muyu.vehicle.domain.VehicleAuthentication;
|
||||||
import com.muyu.vehicle.domain.req.VehicleConnectionReq;
|
import com.muyu.vehicle.domain.req.VehicleConnectionReq;
|
||||||
|
import com.muyu.vehicle.service.VehicleAuthenticationService;
|
||||||
import lombok.extern.log4j.Log4j2;
|
import lombok.extern.log4j.Log4j2;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
@RestController
|
|
||||||
@Log4j2
|
@Log4j2
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/carInstance")
|
||||||
public class CarInstanceController {
|
public class CarInstanceController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private VehicleAuthenticationService vehicleAuthenticationService;
|
||||||
|
|
||||||
|
|
||||||
@PostMapping("/receiveMsg/connect")
|
@PostMapping("/receiveMsg")
|
||||||
public Result receiveMsg(@RequestBody VehicleConnectionReq vehicleConnectionReq){
|
public Result receiveMsg(@RequestBody VehicleConnectionReq vehicleConnectionReq){
|
||||||
log.info("=======>"+vehicleConnectionReq);
|
log.info("=======>"+vehicleConnectionReq);
|
||||||
return Result.success();
|
VehicleAuthentication vehicleAuthentication = VehicleAuthentication.buildVehicle(vehicleConnectionReq);
|
||||||
|
Integer i = vehicleAuthenticationService.insertVehicleAuthentication(vehicleAuthentication);
|
||||||
|
return i>0?Result.success():Result.error();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,51 @@
|
||||||
|
package com.muyu.vehicle.domain;
|
||||||
|
|
||||||
|
import com.muyu.vehicle.domain.req.VehicleConnectionReq;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车辆鉴权表
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class VehicleAuthentication {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ID
|
||||||
|
*/
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车辆VIN码
|
||||||
|
*/
|
||||||
|
private String vin;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户名
|
||||||
|
*/
|
||||||
|
private String userName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 密码
|
||||||
|
*/
|
||||||
|
private String password;
|
||||||
|
|
||||||
|
|
||||||
|
public static VehicleAuthentication buildVehicle(VehicleConnectionReq req){
|
||||||
|
return builder()
|
||||||
|
.vin(req.getVehicleVin())
|
||||||
|
.userName(req.getUsername())
|
||||||
|
.password((req.getVehicleVin()+req.getTimestamp()+req.getNonce()))
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
package com.muyu.vehicle.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.muyu.vehicle.domain.VehicleAuthentication;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface VehicleAuthenticationMapper extends BaseMapper<VehicleAuthentication> {
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
package com.muyu.vehicle.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.muyu.common.domain.DataType;
|
||||||
|
import com.muyu.vehicle.domain.VehicleAuthentication;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
|
public interface VehicleAuthenticationService extends IService<VehicleAuthentication> {
|
||||||
|
Integer insertVehicleAuthentication(VehicleAuthentication vehicleAuthentication);
|
||||||
|
}
|
|
@ -2,12 +2,10 @@ package com.muyu.vehicle.service.impl;
|
||||||
|
|
||||||
import com.muyu.common.core.domain.Result;
|
import com.muyu.common.core.domain.Result;
|
||||||
import com.muyu.common.core.utils.uuid.UUID;
|
import com.muyu.common.core.utils.uuid.UUID;
|
||||||
import com.muyu.vehicle.config.RestTemplateConfig;
|
|
||||||
import com.muyu.vehicle.domain.MqttServerModel;
|
import com.muyu.vehicle.domain.MqttServerModel;
|
||||||
import com.muyu.vehicle.domain.req.VehicleConnectionReq;
|
import com.muyu.vehicle.domain.req.VehicleConnectionReq;
|
||||||
import com.muyu.vehicle.service.CarInstanceService;
|
import com.muyu.vehicle.service.CarInstanceService;
|
||||||
import lombok.extern.log4j.Log4j2;
|
import lombok.extern.log4j.Log4j2;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
package com.muyu.vehicle.service.impl;
|
||||||
|
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.muyu.vehicle.domain.VehicleAuthentication;
|
||||||
|
import com.muyu.vehicle.mapper.VehicleAuthenticationMapper;
|
||||||
|
import com.muyu.vehicle.service.VehicleAuthenticationService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class VehicleAuthenticationServiceImpl extends ServiceImpl<VehicleAuthenticationMapper, VehicleAuthentication> implements VehicleAuthenticationService {
|
||||||
|
@Autowired
|
||||||
|
private VehicleAuthenticationMapper vehicleAuthenticationMapper;
|
||||||
|
@Override
|
||||||
|
public Integer insertVehicleAuthentication(VehicleAuthentication vehicleAuthentication) {
|
||||||
|
return vehicleAuthenticationMapper.insert(vehicleAuthentication);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue