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
635a5a1e
Commit
635a5a1e
authored
Feb 24, 2020
by
zhangzhenbang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
试探性写了一两个接口
parent
3d5cba66
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
321 additions
and
3 deletions
+321
-3
IdentityInfoController.java
...beijingvehicleflow/controller/IdentityInfoController.java
+43
-0
AuthInfo.java
...ain/java/com/yingxin/beijingvehicleflow/dto/AuthInfo.java
+92
-0
EncodeData.java
...n/java/com/yingxin/beijingvehicleflow/dto/EncodeData.java
+26
-0
ReservationsDisplayDTO.java
...ingxin/beijingvehicleflow/dto/ReservationsDisplayDTO.java
+7
-1
IdentityInformationMapper.java
.../beijingvehicleflow/mapper/IdentityInformationMapper.java
+1
-1
AuthResponse.java
...com/yingxin/beijingvehicleflow/response/AuthResponse.java
+50
-0
AuthService.java
...a/com/yingxin/beijingvehicleflow/service/AuthService.java
+22
-0
ReservationService.java
...ingxin/beijingvehicleflow/service/ReservationService.java
+2
-0
AuthServiceImpl.java
...gxin/beijingvehicleflow/service/impl/AuthServiceImpl.java
+57
-0
ReservationServiceImpl.java
...ijingvehicleflow/service/impl/ReservationServiceImpl.java
+21
-1
No files found.
src/main/java/com/yingxin/beijingvehicleflow/controller/IdentityInfoController.java
View file @
635a5a1e
package
com
.
yingxin
.
beijingvehicleflow
.
controller
;
import
com.yingxin.beijingvehicleflow.constant.Const
;
import
com.yingxin.beijingvehicleflow.dto.ReservationInfoDTO
;
import
com.yingxin.beijingvehicleflow.dto.ReservationsDisplayDTO
;
import
com.yingxin.beijingvehicleflow.entity.IdentityInformation
;
import
com.yingxin.beijingvehicleflow.entity.Reservation
;
import
com.yingxin.beijingvehicleflow.response.Response
;
import
com.yingxin.beijingvehicleflow.service.AuthService
;
import
com.yingxin.beijingvehicleflow.service.IdentityInformationService
;
import
com.yingxin.beijingvehicleflow.service.ReservationService
;
import
com.yingxin.beijingvehicleflow.util.AESUtil
;
import
com.yingxin.beijingvehicleflow.util.PicUtils
;
import
net.sf.json.JSONObject
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.List
;
/**
...
...
@@ -103,4 +111,39 @@ public class IdentityInfoController {
return
identityInformationService
.
selectReservatinsByIdentityId
(
info
);
}
@Autowired
private
AuthService
authService
;
@Autowired
private
ReservationService
reservationService
;
/**
* 认证接口,此处不用再次判断身份证号码
*
* 1.图片压缩
*
* @date 2020/2/24
* @param reservationInfoDTO
* @return com.yingxin.beijingvehicleflow.response.Response
*/
@PostMapping
(
"/identity/auth"
)
public
Response
verifyIdentity
(
@RequestBody
ReservationInfoDTO
reservationInfoDTO
)
{
IdentityInformation
info
=
reservationInfoDTO
.
getIdentityInformation
();
/*图片压缩*/
info
.
setFaceImage
(
PicUtils
.
compressImage
(
info
.
getFaceImage
(),
Const
.
FACE_IMG_SIZE
));
if
(!
authService
.
is0x42AuthSucc
(
info
))
{
return
Response
.
fail
(
"AUTH-FAILED"
,
"实名认证失败。"
);
}
Reservation
reservation
=
reservationInfoDTO
.
getReservation
();
Date
date
=
new
Date
();
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
reservation
.
setAuthTime
(
sdf
.
format
(
date
));
reservationInfoDTO
.
setReservation
(
reservation
);
return
reservationService
.
isUpdateAuthInfoSucc
(
reservation
)?
Response
.
succ
():
Response
.
fail
();
}
}
src/main/java/com/yingxin/beijingvehicleflow/dto/AuthInfo.java
0 → 100644
View file @
635a5a1e
package
com
.
yingxin
.
beijingvehicleflow
.
dto
;
/**
* 发给认证接口的请求数据
*
* @author 226
* @version 1.0
* @date 2020/2/13
*/
public
class
AuthInfo
{
private
String
cusNbr
;
private
String
appID
;
private
String
authMode
;
private
String
idNbr
;
private
String
idName
;
private
String
idIssueExp
;
private
String
idIssueSt
;
private
String
faceData
;
public
AuthInfo
()
{
cusNbr
=
"YWZD49"
;
appID
=
"国投盈信"
;
idIssueExp
=
""
;
idIssueSt
=
""
;
}
public
String
getCusNbr
()
{
return
cusNbr
;
}
public
void
setCusNbr
(
String
cusNbr
)
{
this
.
cusNbr
=
cusNbr
;
}
public
String
getAppID
()
{
return
appID
;
}
public
void
setAppID
(
String
appID
)
{
this
.
appID
=
appID
;
}
public
String
getAuthMode
()
{
return
authMode
;
}
public
void
setAuthMode
(
String
authMode
)
{
this
.
authMode
=
authMode
;
}
public
String
getIdNbr
()
{
return
idNbr
;
}
public
void
setIdNbr
(
String
idNbr
)
{
this
.
idNbr
=
idNbr
;
}
public
String
getIdName
()
{
return
idName
;
}
public
void
setIdName
(
String
idName
)
{
this
.
idName
=
idName
;
}
public
String
getIdIssueExp
()
{
return
idIssueExp
;
}
public
void
setIdIssueExp
(
String
idIssueExp
)
{
this
.
idIssueExp
=
idIssueExp
;
}
public
String
getIdIssueSt
()
{
return
idIssueSt
;
}
public
void
setIdIssueSt
(
String
idIssueSt
)
{
this
.
idIssueSt
=
idIssueSt
;
}
public
String
getFaceData
()
{
return
faceData
;
}
public
void
setFaceData
(
String
faceData
)
{
this
.
faceData
=
faceData
;
}
}
src/main/java/com/yingxin/beijingvehicleflow/dto/EncodeData.java
0 → 100644
View file @
635a5a1e
package
com
.
yingxin
.
beijingvehicleflow
.
dto
;
/**
* description //TODO
*
* @author 226
* @version 1.0
* @date 2020/2/24
*/
public
class
EncodeData
{
private
ReservationInfoDTO
data
;
private
String
encodedData
;
public
EncodeData
(
ReservationInfoDTO
data
)
{
this
.
data
=
data
;
}
// public EncodeData encodeData() {
//
// encodedData = DesUtil.encrypt(Constant.KEY, String.valueOf(resident.getrId()));
//
// return
// }
}
src/main/java/com/yingxin/beijingvehicleflow/dto/ReservationsDisplayDTO.java
View file @
635a5a1e
...
...
@@ -12,9 +12,15 @@ import lombok.Data;
@Data
public
class
ReservationsDisplayDTO
{
private
int
reservationId
;
/*展示数据*/
private
String
name
;
private
String
toBeijingDate
;
private
String
submitCoordinate
;
/*可能会用到的数据*/
private
int
identityId
;
private
int
reservationId
;
private
String
idCardNumber
;
}
src/main/java/com/yingxin/beijingvehicleflow/mapper/IdentityInformationMapper.java
View file @
635a5a1e
...
...
@@ -44,7 +44,7 @@ public interface IdentityInformationMapper {
@Select
(
"select * from identity_information where wechat_openid = #{openid}"
)
IdentityInformation
getAllInfoByOpenid
(
String
openid
);
@Select
(
"select r.id as reservationId,info.name,info.toBeijing_date,r.submit_coordinate,r.identity_id "
+
@Select
(
"select r.id as reservationId,info.name,info.
id_card_number,info.
toBeijing_date,r.submit_coordinate,r.identity_id "
+
"from identity_information AS info LEFT JOIN reservation AS r ON info.id=r.identity_id WHERE info.id = #{id} "
)
List
<
ReservationsDisplayDTO
>
selectReservatinsByIdentityId
(
IdentityInformation
info
);
}
src/main/java/com/yingxin/beijingvehicleflow/response/AuthResponse.java
0 → 100644
View file @
635a5a1e
package
com
.
yingxin
.
beijingvehicleflow
.
response
;
/**
* description //TODO
*
* @author 226
* @version 1.0
* @date 2020/2/13
*/
public
class
AuthResponse
{
private
String
errorDesc
;
private
boolean
success
;
private
String
authResult
;
private
String
transNbr
;
public
AuthResponse
()
{}
public
String
getErrorDesc
()
{
return
errorDesc
;
}
public
void
setErrorDesc
(
String
errorDesc
)
{
this
.
errorDesc
=
errorDesc
;
}
public
boolean
isSuccess
()
{
return
success
;
}
public
void
setSuccess
(
boolean
success
)
{
this
.
success
=
success
;
}
public
String
getAuthResult
()
{
return
authResult
;
}
public
void
setAuthResult
(
String
authResult
)
{
this
.
authResult
=
authResult
;
}
public
String
getTransNbr
()
{
return
transNbr
;
}
public
void
setTransNbr
(
String
transNbr
)
{
this
.
transNbr
=
transNbr
;
}
}
src/main/java/com/yingxin/beijingvehicleflow/service/AuthService.java
0 → 100644
View file @
635a5a1e
package
com
.
yingxin
.
beijingvehicleflow
.
service
;
import
com.yingxin.beijingvehicleflow.entity.IdentityInformation
;
/**
* description //TODO
*
* @author 226
* @version 1.0
* @date 2020/2/13
*/
public
interface
AuthService
{
/**
* 认证,返回成功或失败
* @param info
* @return
*/
boolean
is0x42AuthSucc
(
IdentityInformation
info
);
}
src/main/java/com/yingxin/beijingvehicleflow/service/ReservationService.java
View file @
635a5a1e
...
...
@@ -16,4 +16,6 @@ public interface ReservationService {
Response
insertIdentityInfoAndReservation
(
ReservationInfoDTO
info
)
throws
Exception
;
boolean
isInsertReservationSucc
(
Reservation
reservation
);
boolean
isUpdateAuthInfoSucc
(
Reservation
reservation
);
}
src/main/java/com/yingxin/beijingvehicleflow/service/impl/AuthServiceImpl.java
0 → 100644
View file @
635a5a1e
package
com
.
yingxin
.
beijingvehicleflow
.
service
.
impl
;
import
com.yingxin.beijingvehicleflow.constant.Const
;
import
com.yingxin.beijingvehicleflow.dto.AuthInfo
;
import
com.yingxin.beijingvehicleflow.entity.IdentityInformation
;
import
com.yingxin.beijingvehicleflow.response.AuthResponse
;
import
com.yingxin.beijingvehicleflow.service.AuthService
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
org.springframework.web.client.RestTemplate
;
/**
* description //TODO
*
* @author 226
* @version 1.0
* @date 2020/2/13
*/
@Service
public
class
AuthServiceImpl
implements
AuthService
{
private
static
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
AuthService
.
class
);
@Autowired
private
RestTemplate
restTemplate
;
@Value
(
"${auth-url}"
)
private
String
url
;
@Override
public
boolean
is0x42AuthSucc
(
IdentityInformation
info
)
{
AuthInfo
authInfo
=
new
AuthInfo
();
authInfo
.
setAuthMode
(
"0x42"
);
authInfo
.
setFaceData
(
info
.
getFaceImage
());
authInfo
.
setIdName
(
info
.
getName
());
authInfo
.
setIdNbr
(
info
.
getIdCardNumber
());
AuthResponse
authResponse
;
try
{
authResponse
=
restTemplate
.
postForObject
(
url
,
authInfo
,
AuthResponse
.
class
);
}
catch
(
Exception
e
)
{
LOGGER
.
error
(
"调用认证接口报错:"
,
e
);
return
false
;
}
/* TODO 刪掉 */
System
.
out
.
println
(
"0x42"
);
System
.
out
.
println
(
authResponse
.
getTransNbr
());
System
.
out
.
println
(
authResponse
.
getErrorDesc
());
System
.
out
.
println
(
authResponse
.
getAuthResult
());
System
.
out
.
println
(
authResponse
.
isSuccess
());
return
"00XX"
.
equals
(
authResponse
.
getAuthResult
());
}
}
src/main/java/com/yingxin/beijingvehicleflow/service/impl/ReservationServiceImpl.java
View file @
635a5a1e
...
...
@@ -7,6 +7,8 @@ import com.yingxin.beijingvehicleflow.response.Response;
import
com.yingxin.beijingvehicleflow.service.IdentityInformationService
;
import
com.yingxin.beijingvehicleflow.service.ReservationService
;
import
com.yingxin.beijingvehicleflow.util.IdCardUtil
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
...
...
@@ -24,6 +26,9 @@ import java.util.Date;
@Service
public
class
ReservationServiceImpl
implements
ReservationService
{
private
static
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
ReservationService
.
class
);
@Autowired
private
ReservationMapper
reservationMapper
;
...
...
@@ -54,6 +59,21 @@ public class ReservationServiceImpl implements ReservationService {
Date
date
=
new
Date
();
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
reservation
.
setSubmitTime
(
sdf
.
format
(
date
));
return
reservationMapper
.
insertReservation
(
reservation
)
==
1
;
try
{
return
reservationMapper
.
insertReservation
(
reservation
)
==
1
;
}
catch
(
Exception
e
)
{
LOGGER
.
error
(
"预约单信息插入异常:"
,
e
);
return
false
;
}
}
@Override
public
boolean
isUpdateAuthInfoSucc
(
Reservation
reservation
)
{
try
{
return
reservationMapper
.
updateAuthInfo
(
reservation
)
==
1
;
}
catch
(
Exception
e
)
{
LOGGER
.
error
(
"更新预约单认证坐标及时间异常:"
,
e
);
return
false
;
}
}
}
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