Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
B
beijing-vehicleflow
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhangzhenbang
beijing-vehicleflow
Commits
6f1a92e0
Commit
6f1a92e0
authored
Feb 24, 2020
by
zhangzhenbang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
试探性写了一两个接口
parent
ad18cc3c
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
35 additions
and
31 deletions
+35
-31
FloatingPopulationController.java
...gvehicleflow/controller/FloatingPopulationController.java
+0
-4
IdentityInfoController.java
...beijingvehicleflow/controller/IdentityInfoController.java
+6
-4
FloatingPopulationServcie.java
...beijingvehicleflow/service/FloatingPopulationServcie.java
+0
-2
IdentityInformationService.java
...eijingvehicleflow/service/IdentityInformationService.java
+2
-0
FloatingPopulationServcieImpl.java
...hicleflow/service/impl/FloatingPopulationServcieImpl.java
+1
-21
IdentityInformationServiceImpl.java
...icleflow/service/impl/IdentityInformationServiceImpl.java
+26
-0
No files found.
src/main/java/com/yingxin/beijingvehicleflow/controller/FloatingPopulationController.java
View file @
6f1a92e0
...
@@ -28,10 +28,6 @@ public class FloatingPopulationController {
...
@@ -28,10 +28,6 @@ public class FloatingPopulationController {
@PostMapping
(
"/float-population"
)
@PostMapping
(
"/float-population"
)
public
Response
checkFloatingPopulation
(
@RequestBody
FloatingPopulation
floatingPopulation
)
{
public
Response
checkFloatingPopulation
(
@RequestBody
FloatingPopulation
floatingPopulation
)
{
if
(!
populationServcie
.
isIdentityInfoValid
(
floatingPopulation
))
{
return
Response
.
fail
(
"INVALID-CODE"
,
"二维码已过期,请重新生成二维码。"
);
}
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
floatingPopulation
.
setCheckTime
(
sdf
.
format
(
new
Date
()));
floatingPopulation
.
setCheckTime
(
sdf
.
format
(
new
Date
()));
FloatingPopulation
selectResult
=
populationServcie
.
selectOneByReservationId
(
floatingPopulation
);
FloatingPopulation
selectResult
=
populationServcie
.
selectOneByReservationId
(
floatingPopulation
);
...
...
src/main/java/com/yingxin/beijingvehicleflow/controller/IdentityInfoController.java
View file @
6f1a92e0
...
@@ -157,19 +157,21 @@ public class IdentityInfoController {
...
@@ -157,19 +157,21 @@ public class IdentityInfoController {
public
Response
selectOneByEncodedId
(
@RequestBody
String
json
)
{
public
Response
selectOneByEncodedId
(
@RequestBody
String
json
)
{
IdentityInformation
info
;
IdentityInformation
info
;
JSONObject
datafterDecryptJson
;
JSONObject
datafterDecryptJson
;
try
{
try
{
JSONObject
jsonObject
=
JSONObject
.
fromObject
(
json
);
JSONObject
jsonObject
=
JSONObject
.
fromObject
(
json
);
String
encodedData
=
jsonObject
.
getString
(
"encodedData"
);
String
encodedData
=
jsonObject
.
getString
(
"encodedData"
);
String
datafterDecryptStr
=
DesUtil
.
decrypt
(
Const
.
KEY
,
encodedData
);
String
datafterDecryptStr
=
DesUtil
.
decrypt
(
Const
.
KEY
,
encodedData
);
datafterDecryptJson
=
JSONObject
.
fromObject
(
datafterDecryptStr
);
datafterDecryptJson
=
JSONObject
.
fromObject
(
datafterDecryptStr
);
String
authTime
=
datafterDecryptJson
.
getString
(
"authTime"
);
// String lastFourNumOfIdCard = resident.getrIdCard().substring(14);
if
(!
identityInformationService
.
isIdentityInfoValid
(
authTime
))
{
// resident.setrIdCard(Constant.ID_CARD_14NUM_FLAG + lastFourNumOfIdCard);
return
Response
.
fail
(
"INVALID-CODE"
,
"二维码已过期,请重新生成二维码。"
);
}
}
catch
(
JSONException
e
)
{
}
catch
(
JSONException
e
)
{
LOGGER
.
error
(
"解密查询接口Json解析异常"
,
e
);
LOGGER
.
error
(
"解密查询接口Json解析异常"
,
e
);
return
Response
.
fail
(
"JSON-PARSE-ERROR"
,
"json解析异常"
);
return
Response
.
fail
(
"JSON-PARSE-ERROR"
,
"json解析异常"
);
}
}
catch
(
Exception
e
)
{
catch
(
Exception
e
)
{
LOGGER
.
error
(
"解密查询接口异常"
,
e
);
LOGGER
.
error
(
"解密查询接口异常"
,
e
);
return
Response
.
fail
(
"DECRYPT-ERROR"
,
"解密异常!"
);
return
Response
.
fail
(
"DECRYPT-ERROR"
,
"解密异常!"
);
}
}
...
...
src/main/java/com/yingxin/beijingvehicleflow/service/FloatingPopulationServcie.java
View file @
6f1a92e0
...
@@ -13,7 +13,5 @@ public interface FloatingPopulationServcie {
...
@@ -13,7 +13,5 @@ public interface FloatingPopulationServcie {
boolean
isInsertFloatingPopulationSucc
(
FloatingPopulation
floatingPopulation
);
boolean
isInsertFloatingPopulationSucc
(
FloatingPopulation
floatingPopulation
);
boolean
isIdentityInfoValid
(
FloatingPopulation
floatingPopulation
);
FloatingPopulation
selectOneByReservationId
(
FloatingPopulation
floatingPopulation
);
FloatingPopulation
selectOneByReservationId
(
FloatingPopulation
floatingPopulation
);
}
}
src/main/java/com/yingxin/beijingvehicleflow/service/IdentityInformationService.java
View file @
6f1a92e0
...
@@ -39,4 +39,6 @@ public interface IdentityInformationService {
...
@@ -39,4 +39,6 @@ public interface IdentityInformationService {
List
<
ReservationsDisplayDTO
>
selectReservatinsByIdentityId
(
IdentityInformation
info
);
List
<
ReservationsDisplayDTO
>
selectReservatinsByIdentityId
(
IdentityInformation
info
);
boolean
isIdentityInfoValid
(
String
authTime
);
}
}
src/main/java/com/yingxin/beijingvehicleflow/service/impl/FloatingPopulationServcieImpl.java
View file @
6f1a92e0
...
@@ -28,33 +28,13 @@ public class FloatingPopulationServcieImpl implements FloatingPopulationServcie
...
@@ -28,33 +28,13 @@ public class FloatingPopulationServcieImpl implements FloatingPopulationServcie
@Autowired
@Autowired
private
FloatingPopulationMapper
populationMapper
;
private
FloatingPopulationMapper
populationMapper
;
@Value
(
"${QR-code-validTime}"
)
private
long
validTime
;
@Override
@Override
public
boolean
isInsertFloatingPopulationSucc
(
FloatingPopulation
floatingPopulation
)
{
public
boolean
isInsertFloatingPopulationSucc
(
FloatingPopulation
floatingPopulation
)
{
return
populationMapper
.
insertFloatingPopulation
(
floatingPopulation
)
==
1
;
return
populationMapper
.
insertFloatingPopulation
(
floatingPopulation
)
==
1
;
}
}
@Override
public
boolean
isIdentityInfoValid
(
FloatingPopulation
floatingPopulation
)
{
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
String
authTime
=
floatingPopulation
.
getAuthTime
();
String
checkTime
=
sdf
.
format
(
new
Date
());
long
milliSeconds
;
try
{
Date
authDate
=
sdf
.
parse
(
authTime
);
Date
checkDate
=
sdf
.
parse
(
checkTime
);
milliSeconds
=
checkDate
.
getTime
()
-
authDate
.
getTime
();
}
catch
(
ParseException
e
)
{
LOGGER
.
error
(
"检验二维码是否过期日期解析异常"
,
e
);
return
false
;
}
return
(
milliSeconds
/
60.0
/
1000.0
)
<
validTime
;
}
@Override
@Override
public
FloatingPopulation
selectOneByReservationId
(
FloatingPopulation
floatingPopulation
)
{
public
FloatingPopulation
selectOneByReservationId
(
FloatingPopulation
floatingPopulation
)
{
return
populationMapper
.
selectOneByReservationId
(
floatingPopulation
);
return
populationMapper
.
selectOneByReservationId
(
floatingPopulation
);
...
...
src/main/java/com/yingxin/beijingvehicleflow/service/impl/IdentityInformationServiceImpl.java
View file @
6f1a92e0
...
@@ -10,6 +10,7 @@ import net.sf.json.JSONObject;
...
@@ -10,6 +10,7 @@ import net.sf.json.JSONObject;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
java.io.BufferedReader
;
import
java.io.BufferedReader
;
...
@@ -18,6 +19,9 @@ import java.io.InputStreamReader;
...
@@ -18,6 +19,9 @@ import java.io.InputStreamReader;
import
java.net.MalformedURLException
;
import
java.net.MalformedURLException
;
import
java.net.URL
;
import
java.net.URL
;
import
java.net.URLConnection
;
import
java.net.URLConnection
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
/**
/**
...
@@ -95,4 +99,26 @@ public class IdentityInformationServiceImpl implements IdentityInformationServic
...
@@ -95,4 +99,26 @@ public class IdentityInformationServiceImpl implements IdentityInformationServic
public
List
<
ReservationsDisplayDTO
>
selectReservatinsByIdentityId
(
IdentityInformation
info
)
{
public
List
<
ReservationsDisplayDTO
>
selectReservatinsByIdentityId
(
IdentityInformation
info
)
{
return
identityInformationMapper
.
selectReservatinsByIdentityId
(
info
);
return
identityInformationMapper
.
selectReservatinsByIdentityId
(
info
);
}
}
@Value
(
"${QR-code-validTime}"
)
private
long
validTime
;
@Override
public
boolean
isIdentityInfoValid
(
String
authTime
)
{
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
String
checkTime
=
sdf
.
format
(
new
Date
());
long
milliSeconds
;
try
{
Date
authDate
=
sdf
.
parse
(
authTime
);
Date
checkDate
=
sdf
.
parse
(
checkTime
);
milliSeconds
=
checkDate
.
getTime
()
-
authDate
.
getTime
();
}
catch
(
ParseException
e
)
{
LOGGER
.
error
(
"检验二维码是否过期日期解析异常"
,
e
);
return
false
;
}
return
(
milliSeconds
/
60.0
/
1000.0
)
<
validTime
;
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment