R修改为Result

master
张小东 2023-11-21 10:46:50 +08:00
parent 64e0d665c7
commit 8332d53c64
4 changed files with 23 additions and 40 deletions

View File

@ -22,24 +22,16 @@
<dependencies>
<dependency>
<groupId>com.february</groupId>
<artifactId>february-vehicle-remote</artifactId>
<artifactId>february-vehicle-common</artifactId>
<version>3.6.3</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.february</groupId>
<artifactId>february-vehicle-remote</artifactId>
<version>3.6.3</version>
<scope>compile</scope>
</dependency>
<!-- RuoYi Common Log -->
<dependency>
<groupId>com.february</groupId>
<artifactId>february-common-log</artifactId>
<version>3.6.3</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>com.february</groupId>-->
<!-- <artifactId>february-common-log</artifactId>-->
<!-- <version>3.6.3</version>-->
<!-- </dependency>-->
<!-- RuoYi Common DataScope -->
<dependency>
@ -48,13 +40,6 @@
<version>3.6.3</version>
</dependency>
<!-- RuoYi Common core -->
<dependency>
<groupId>com.february</groupId>
<artifactId>february-common-core</artifactId>
<version>3.6.3</version>
</dependency>
<!-- RuoYi Common DataSource -->
<dependency>

View File

@ -1,7 +1,7 @@
package com.vehicle.trajectory.controller;
import com.alibaba.nacos.api.model.v2.Result;
import com.february.common.core.domain.R;
import com.february.common.core.domain.Result;
import com.february.common.domain.Car;
import com.february.common.domain.RealData;
import com.vehicle.trajectory.service.TrajectoryService;
@ -27,9 +27,9 @@ public class TrajectoryController {
*
*/
@GetMapping("/realDateList")
public R<List<RealData>> realDateList() {
public Result<List<RealData>> realDateList() {
log.info("功能名称:【实时数据查看】,请求路径:【{}】,请求方式:【{}】", request.getRequestURI(), request.getMethod());
R<List<RealData>> result = trajectoryService.realDateList();
Result<List<RealData>> result = trajectoryService.realDateList();
log.info("请求结果:【{}】", result);
return result;
}
@ -40,9 +40,9 @@ public class TrajectoryController {
*
*/
@GetMapping("/carList")
public R<List<Car>> carList() {
public Result<List<Car>> carList() {
log.info("功能名称:【查看在线车辆】,请求路径:【{}】,请求方式:【{}】", request.getRequestURI(), request.getMethod());
R<List<Car>> result = trajectoryService.carList();
Result<List<Car>> result = trajectoryService.carList();
log.info("请求结果:【{}】", result);
return result;
}

View File

@ -1,13 +1,13 @@
package com.vehicle.trajectory.service;
import com.february.common.core.domain.R;
import com.february.common.core.domain.Result;
import com.february.common.domain.Car;
import com.february.common.domain.RealData;
import java.util.List;
public interface TrajectoryService {
R<List<RealData>> realDateList();
public interface TrajectoryService<T, C> {
Result<List<RealData>> realDateList();
R<List<Car>> carList();
Result<List<Car>> carList();
}

View File

@ -3,36 +3,34 @@ package com.vehicle.trajectory.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.february.common.core.domain.R;
import com.february.common.core.domain.Result;
import com.february.common.domain.Car;
import com.february.common.domain.RealData;
import com.february.common.redis.service.RedisService;
import com.vehicle.trajectory.mapper.TrajectoryMapper;
import com.vehicle.trajectory.service.TrajectoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
@Service
@Configuration
public class TrajectoryServiceImpl implements TrajectoryService {
@Autowired
private TrajectoryMapper mapper;
@Override
public R<List<RealData>> realDateList() {
public Result<List<RealData>> realDateList() {
List<RealData> realData = mapper.realDateList();
return R.ok(realData);
return Result.success(realData);
}
@Autowired
private RedisService redisService;
@Override
public R<List<Car>> carList() {
Boolean aBoolean = redisService.hasKey("状态为上线的车辆信息");
public Result<List<Car>> carList() {
Boolean aBoolean = redisService.hasKey("状态为上线的车辆信息");//查询redis中是否有此键
if (Boolean.TRUE.equals(aBoolean)){
List<Object> list = redisService.redisTemplate.opsForList().range("状态为上线的车辆信息", 0, -1);
ArrayList<Car> carArrayList = new ArrayList<>();
@ -42,13 +40,13 @@ public class TrajectoryServiceImpl implements TrajectoryService {
Car notice = JSON.parseObject(o1, Car.class);
carArrayList.add(notice);
}
return R.ok(carArrayList);
return Result.success(carArrayList);
}
}
List<Car> carList = mapper.carList(); //上线车辆的信息
for (Car car : carList) {
redisService.redisTemplate.opsForList().leftPush("状态为上线的车辆信息", JSONObject.toJSONString(car));
}
return R.ok(carList);
return Result.success(carList);
}
}