连接数据

master
sikadi 2023-12-01 20:21:21 +08:00
parent 449118c06d
commit ce57ddfe16
5 changed files with 17 additions and 17 deletions

View File

@ -15,7 +15,7 @@ import lombok.experimental.SuperBuilder;
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
@SuperBuilder @SuperBuilder
public class Vehiclelaunch { public class VehicleConnectionReq {
/** /**
* Vin * Vin

View File

@ -1,7 +1,7 @@
package com.shiyi.launch.controller; package com.shiyi.launch.controller;
import com.fate.common.core.domain.Result; import com.fate.common.core.domain.Result;
import com.shiyi.launch.domain.Vehiclelaunch; import com.shiyi.launch.domain.VehicleConnectionReq;
import com.shiyi.launch.service.VehiclelaunchService; import com.shiyi.launch.service.VehiclelaunchService;
import lombok.extern.log4j.Log4j2; import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -28,8 +28,8 @@ public class VehiclelaunchController {
* 线 * 线
*/ */
@PostMapping("vehiclelaunch") @PostMapping("vehiclelaunch")
public Result vehiclelaunchs(@RequestBody Vehiclelaunch vehiclelaunch){ public Result vehicleConnection(@RequestBody VehicleConnectionReq vehicleConnectionReq){
String topic = vehiclelaunchService.vehiclelaunch(vehiclelaunch); String topic = vehiclelaunchService.vehicleConnection(vehicleConnectionReq);
return Result.success(topic); return Result.success(topic);
} }

View File

@ -1,7 +1,7 @@
package com.shiyi.launch.mapper; package com.shiyi.launch.mapper;
import com.shiyi.launch.domain.Car; import com.shiyi.launch.domain.Car;
import com.shiyi.launch.domain.Vehiclelaunch; import com.shiyi.launch.domain.VehicleConnectionReq;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
/** /**
@ -13,7 +13,7 @@ import org.apache.ibatis.annotations.Mapper;
**/ **/
@Mapper @Mapper
public interface VehicleaunchMapper { public interface VehicleaunchMapper {
Car save(Vehiclelaunch vehiclelaunch); Car save(VehicleConnectionReq vehicleConnectionReq);
int into(Vehiclelaunch vehiclelaunch); int into(VehicleConnectionReq vehicleConnectionReq);
} }

View File

@ -1,6 +1,6 @@
package com.shiyi.launch.service; package com.shiyi.launch.service;
import com.shiyi.launch.domain.Vehiclelaunch; import com.shiyi.launch.domain.VehicleConnectionReq;
/** /**
* @Description : * @Description :
@ -8,5 +8,6 @@ import com.shiyi.launch.domain.Vehiclelaunch;
* @Date: 2023-11-30 20:01 * @Date: 2023-11-30 20:01
*/ */
public interface VehiclelaunchService { public interface VehiclelaunchService {
String vehiclelaunch(Vehiclelaunch vehiclelaunch);
String vehicleConnection(VehicleConnectionReq vehicleConnectionReq);
} }

View File

@ -1,8 +1,7 @@
package com.shiyi.launch.service.impl; package com.shiyi.launch.service.impl;
import com.fate.common.core.utils.StringUtils; import com.fate.common.core.utils.StringUtils;
import com.shiyi.launch.domain.Car; import com.shiyi.launch.domain.VehicleConnectionReq;
import com.shiyi.launch.domain.Vehiclelaunch;
import com.shiyi.launch.mapper.VehicleaunchMapper; import com.shiyi.launch.mapper.VehicleaunchMapper;
import com.shiyi.launch.service.VehiclelaunchService; import com.shiyi.launch.service.VehiclelaunchService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -23,28 +22,28 @@ public class VehiclelaunchServiceimpl implements VehiclelaunchService {
private VehicleaunchMapper vehicleaunchMapper; private VehicleaunchMapper vehicleaunchMapper;
@Override @Override
public String vehiclelaunch(Vehiclelaunch vehiclelaunch) { public String vehicleConnection(VehicleConnectionReq vehicleConnectionReq) {
// 先去查询车辆的vin 在不在 ,如果不在就连接不上 // 先去查询车辆的vin 在不在 ,如果不在就连接不上
if (StringUtils.isEmpty(vehiclelaunch.getVin())){ if (StringUtils.isEmpty(vehicleConnectionReq.getVin())){
return "vin为空"; return "vin为空";
} }
long time = new Date().getTime(); long time = new Date().getTime();
vehiclelaunch.setTimestamp(String.valueOf(time)); vehicleConnectionReq.setTimestamp(String.valueOf(time));
String uuid = UUID.randomUUID().toString().replaceAll("-","").substring(0,8); String uuid = UUID.randomUUID().toString().replaceAll("-","").substring(0,8);
vehiclelaunch.setNonce(uuid); vehicleConnectionReq.setNonce(uuid);
int i = vehicleaunchMapper.into(vehiclelaunch); int i = vehicleaunchMapper.into(vehicleConnectionReq);
if(i < 0){ if(i < 0){
return "失败"; return "失败";
} }
String fate = "fate" + vehiclelaunch.getVin().substring(3,7) + vehiclelaunch.getNonce(); String fate = "fate" + vehicleConnectionReq.getVin().substring(3,7) + vehicleConnectionReq.getNonce();
return fate; return fate;
} }