Commit 6735a928 authored by zhangzhenbang's avatar zhangzhenbang

试探性写了一两个接口

parent 0057d3d2
package com.yingxin.beijingvehicleflow.controller; package com.yingxin.beijingvehicleflow.controller;
import com.yingxin.beijingvehicleflow.constant.Const;
import com.yingxin.beijingvehicleflow.entity.FloatingPopulation; import com.yingxin.beijingvehicleflow.entity.FloatingPopulation;
import com.yingxin.beijingvehicleflow.entity.IdentityInformation;
import com.yingxin.beijingvehicleflow.response.Response; import com.yingxin.beijingvehicleflow.response.Response;
import com.yingxin.beijingvehicleflow.service.FloatingPopulationServcie; import com.yingxin.beijingvehicleflow.service.FloatingPopulationServcie;
import com.yingxin.beijingvehicleflow.util.DesUtil;
import net.sf.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
...@@ -22,11 +28,31 @@ import java.util.Date; ...@@ -22,11 +28,31 @@ import java.util.Date;
@RequestMapping("/api/v1") @RequestMapping("/api/v1")
public class FloatingPopulationController { public class FloatingPopulationController {
private static Logger LOGGER = LoggerFactory.getLogger(FloatingPopulationController.class);
@Autowired @Autowired
private FloatingPopulationServcie populationServcie; private FloatingPopulationServcie populationServcie;
@PostMapping("/float-population") @PostMapping("/float-population")
public Response checkFloatingPopulation(@RequestBody FloatingPopulation floatingPopulation) { public Response checkFloatingPopulation(@RequestBody String json) {
IdentityInformation info;
JSONObject datafterDecryptJson;
try {
JSONObject jsonObject = JSONObject.fromObject(json);
String encodedData = jsonObject.getString("encodedData");
String datafterDecryptStr = DesUtil.decrypt(Const.KEY, encodedData);
datafterDecryptJson = JSONObject.fromObject(datafterDecryptStr);
} catch (Exception e) {
LOGGER.error("json解析异常", e);
return Response.fail();
}
FloatingPopulation floatingPopulation = new FloatingPopulation();
floatingPopulation.setAuthTime(datafterDecryptJson.getString("authTime"));
floatingPopulation.setAuthCoordinate(datafterDecryptJson.getString("authCoordinate"));
floatingPopulation.setReservationId(datafterDecryptJson.getInt("id"));
if (!populationServcie.isIdentityInfoValid(floatingPopulation)) { if (!populationServcie.isIdentityInfoValid(floatingPopulation)) {
return Response.fail("INVALID-CODE","二维码已过期,请重新生成二维码。"); return Response.fail("INVALID-CODE","二维码已过期,请重新生成二维码。");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment