Result修改为R
parent
dd041b3ffe
commit
64e0d665c7
|
@ -1,18 +0,0 @@
|
||||||
package com.february.system.domain.constants;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @description: 系统常量
|
|
||||||
* @author
|
|
||||||
*/
|
|
||||||
public class Constants {
|
|
||||||
/**
|
|
||||||
* 成功标记
|
|
||||||
*/
|
|
||||||
public static final Integer SUCCESS = 200;
|
|
||||||
public static final String SUCCESS_MSG = "操作成功";
|
|
||||||
/**
|
|
||||||
* 失败标记
|
|
||||||
*/
|
|
||||||
public static final Integer ERROR = 500;
|
|
||||||
public static final String ERROR_MSG = "操作异常";
|
|
||||||
}
|
|
|
@ -6,7 +6,7 @@ import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* 历史轨迹详情
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@Builder
|
@Builder
|
||||||
|
|
|
@ -1,76 +0,0 @@
|
||||||
package com.february.common.domain;
|
|
||||||
|
|
||||||
import com.february.system.domain.constants.Constants;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author
|
|
||||||
* @description: 响应信息主体
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class Result<T> implements Serializable {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
/**
|
|
||||||
* 成功
|
|
||||||
*/
|
|
||||||
public static final int SUCCESS = Constants.SUCCESS;
|
|
||||||
/**
|
|
||||||
* 失败
|
|
||||||
*/
|
|
||||||
public static final int FAIL = Constants.ERROR;
|
|
||||||
/**
|
|
||||||
* 返回状态码
|
|
||||||
*/
|
|
||||||
private int code;
|
|
||||||
/**
|
|
||||||
* 响应信息
|
|
||||||
*/
|
|
||||||
private String msg;
|
|
||||||
/**
|
|
||||||
* 响应数据
|
|
||||||
*/
|
|
||||||
private T data;
|
|
||||||
|
|
||||||
public static <T> Result<T> success() {
|
|
||||||
return restResult(null, SUCCESS, Constants.SUCCESS_MSG);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T> Result<T> success(T data) {
|
|
||||||
return restResult(data, SUCCESS, Constants.SUCCESS_MSG);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T> Result<T> success(T data, String msg) {
|
|
||||||
return restResult(data, SUCCESS, msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T> Result<T> error() {
|
|
||||||
return restResult(null, FAIL, Constants.ERROR_MSG);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T> Result<T> error(String msg) {
|
|
||||||
return restResult(null, FAIL, msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T> Result<T> error(T data) {
|
|
||||||
return restResult(data, FAIL, Constants.ERROR_MSG);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T> Result<T> error(T data, String msg) {
|
|
||||||
return restResult(data, FAIL, msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T> Result<T> error(int code, String msg) {
|
|
||||||
return restResult(null, code, msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static <T> Result<T> restResult(T data, int code, String msg) {
|
|
||||||
Result<T> apiResult = new Result<>();
|
|
||||||
apiResult.setCode(code);
|
|
||||||
apiResult.setData(data);
|
|
||||||
apiResult.setMsg(msg);
|
|
||||||
return apiResult;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -27,39 +27,41 @@
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.february</groupId>
|
||||||
|
<artifactId>february-vehicle-remote</artifactId>
|
||||||
|
<version>3.6.3</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- RuoYi Common Log -->
|
<!-- RuoYi Common Log -->
|
||||||
<!-- <dependency>-->
|
<dependency>
|
||||||
<!-- <groupId>com.february</groupId>-->
|
<groupId>com.february</groupId>
|
||||||
<!-- <artifactId>february-common-log</artifactId>-->
|
<artifactId>february-common-log</artifactId>
|
||||||
<!-- <version>3.6.3</version>-->
|
<version>3.6.3</version>
|
||||||
<!-- </dependency>-->
|
</dependency>
|
||||||
|
|
||||||
<!-- RuoYi Common DataScope -->
|
<!-- RuoYi Common DataScope -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.february</groupId>
|
<groupId>com.february</groupId>
|
||||||
<artifactId>february-common-datascope</artifactId>
|
<artifactId>february-common-datascope</artifactId>
|
||||||
<version>3.6.3</version>
|
<version>3.6.3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- RuoYi Common core -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.february</groupId>
|
||||||
|
<artifactId>february-common-core</artifactId>
|
||||||
|
<version>3.6.3</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
<!-- RuoYi Common DataSource -->
|
<!-- RuoYi Common DataSource -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.february</groupId>
|
<groupId>com.february</groupId>
|
||||||
<artifactId>february-common-datasource</artifactId>
|
<artifactId>february-common-datasource</artifactId>
|
||||||
<version>3.6.3</version>
|
<version>3.6.3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>com.february</groupId>
|
|
||||||
<artifactId>february-common-redis</artifactId>
|
|
||||||
<version>3.6.3</version>
|
|
||||||
</dependency>
|
|
||||||
<!-- <dependency>-->
|
|
||||||
<!-- <groupId>org.springframework.boot</groupId>-->
|
|
||||||
<!-- <artifactId>spring-boot-starter-data-redis</artifactId>-->
|
|
||||||
<!-- </dependency>-->
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.redisson</groupId>
|
|
||||||
<artifactId>redisson</artifactId>
|
|
||||||
<version>3.16.0</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<build>
|
<build>
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
package com.vehicle.trajectory.controller;
|
package com.vehicle.trajectory.controller;
|
||||||
|
|
||||||
|
import com.alibaba.nacos.api.model.v2.Result;
|
||||||
|
import com.february.common.core.domain.R;
|
||||||
import com.february.common.domain.Car;
|
import com.february.common.domain.Car;
|
||||||
import com.february.common.domain.RealData;
|
import com.february.common.domain.RealData;
|
||||||
import com.february.common.domain.Result;
|
|
||||||
import com.vehicle.trajectory.service.TrajectoryService;
|
import com.vehicle.trajectory.service.TrajectoryService;
|
||||||
import lombok.extern.log4j.Log4j2;
|
import lombok.extern.log4j.Log4j2;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -11,7 +12,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Log4j2
|
@Log4j2
|
||||||
|
@ -23,21 +23,26 @@ public class TrajectoryController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private HttpServletRequest request;
|
private HttpServletRequest request;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实时数据
|
||||||
|
*/
|
||||||
@GetMapping("/realDateList")
|
@GetMapping("/realDateList")
|
||||||
public Result<List<RealData>> realDateList() {
|
public R<List<RealData>> realDateList() {
|
||||||
log.info("功能名称:【实时数据查看】,请求路径:【{}】,请求方式:【{}】", request.getRequestURI(), request.getMethod());
|
log.info("功能名称:【实时数据查看】,请求路径:【{}】,请求方式:【{}】", request.getRequestURI(), request.getMethod());
|
||||||
Result<List<RealData>> result = trajectoryService.realDateList();
|
R<List<RealData>> result = trajectoryService.realDateList();
|
||||||
log.info("请求结果:【{}】", result);
|
log.info("请求结果:【{}】", result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询车辆信息
|
* 车辆信息
|
||||||
*/
|
*/
|
||||||
@GetMapping("/carList")
|
@GetMapping("/carList")
|
||||||
public Result<List<Car>> carList() {
|
public R<List<Car>> carList() {
|
||||||
log.info("功能名称:【查看在线车辆】,请求路径:【{}】,请求方式:【{}】", request.getRequestURI(), request.getMethod());
|
log.info("功能名称:【查看在线车辆】,请求路径:【{}】,请求方式:【{}】", request.getRequestURI(), request.getMethod());
|
||||||
Result<List<Car>> result = trajectoryService.carList();
|
R<List<Car>> result = trajectoryService.carList();
|
||||||
log.info("请求结果:【{}】", result);
|
log.info("请求结果:【{}】", result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
package com.vehicle.trajectory.service;
|
package com.vehicle.trajectory.service;
|
||||||
|
|
||||||
|
import com.february.common.core.domain.R;
|
||||||
import com.february.common.domain.Car;
|
import com.february.common.domain.Car;
|
||||||
import com.february.common.domain.RealData;
|
import com.february.common.domain.RealData;
|
||||||
import com.february.common.domain.Result;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public interface TrajectoryService {
|
public interface TrajectoryService {
|
||||||
Result<List<RealData>> realDateList();
|
R<List<RealData>> realDateList();
|
||||||
|
|
||||||
Result<List<Car>> carList();
|
R<List<Car>> carList();
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@ package com.vehicle.trajectory.service.impl;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.february.common.core.domain.R;
|
||||||
import com.february.common.domain.Car;
|
import com.february.common.domain.Car;
|
||||||
import com.february.common.domain.RealData;
|
import com.february.common.domain.RealData;
|
||||||
import com.february.common.domain.Result;
|
|
||||||
import com.february.common.redis.service.RedisService;
|
import com.february.common.redis.service.RedisService;
|
||||||
import com.vehicle.trajectory.mapper.TrajectoryMapper;
|
import com.vehicle.trajectory.mapper.TrajectoryMapper;
|
||||||
import com.vehicle.trajectory.service.TrajectoryService;
|
import com.vehicle.trajectory.service.TrajectoryService;
|
||||||
|
@ -13,7 +13,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -24,15 +23,15 @@ public class TrajectoryServiceImpl implements TrajectoryService {
|
||||||
private TrajectoryMapper mapper;
|
private TrajectoryMapper mapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Result<List<RealData>> realDateList() {
|
public R<List<RealData>> realDateList() {
|
||||||
List<RealData> realData = mapper.realDateList();
|
List<RealData> realData = mapper.realDateList();
|
||||||
return Result.success(realData);
|
return R.ok(realData);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private RedisService redisService;
|
private RedisService redisService;
|
||||||
@Override
|
@Override
|
||||||
public Result<List<Car>> carList() {
|
public R<List<Car>> carList() {
|
||||||
Boolean aBoolean = redisService.hasKey("状态为上线的车辆信息");
|
Boolean aBoolean = redisService.hasKey("状态为上线的车辆信息");
|
||||||
if (Boolean.TRUE.equals(aBoolean)){
|
if (Boolean.TRUE.equals(aBoolean)){
|
||||||
List<Object> list = redisService.redisTemplate.opsForList().range("状态为上线的车辆信息", 0, -1);
|
List<Object> list = redisService.redisTemplate.opsForList().range("状态为上线的车辆信息", 0, -1);
|
||||||
|
@ -43,13 +42,13 @@ public class TrajectoryServiceImpl implements TrajectoryService {
|
||||||
Car notice = JSON.parseObject(o1, Car.class);
|
Car notice = JSON.parseObject(o1, Car.class);
|
||||||
carArrayList.add(notice);
|
carArrayList.add(notice);
|
||||||
}
|
}
|
||||||
return Result.success(carArrayList);
|
return R.ok(carArrayList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
List<Car> carList = mapper.carList(); //上线车辆的信息
|
List<Car> carList = mapper.carList(); //上线车辆的信息
|
||||||
for (Car car : carList) {
|
for (Car car : carList) {
|
||||||
redisService.redisTemplate.opsForList().leftPush("状态为上线的车辆信息", JSONObject.toJSONString(car));
|
redisService.redisTemplate.opsForList().leftPush("状态为上线的车辆信息", JSONObject.toJSONString(car));
|
||||||
}
|
}
|
||||||
return Result.success(carList);
|
return R.ok(carList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue