Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
app-service
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
SuperHive
back-end
app-service
Commits
b4e939ac
Commit
b4e939ac
authored
Jun 10, 2020
by
zhangzc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加消息推送接口
parent
8e16155a
Changes
29
Hide whitespace changes
Inline
Side-by-side
Showing
29 changed files
with
979 additions
and
49 deletions
+979
-49
ProtocolComponent.java
...m/esv/freight/app/common/component/ProtocolComponent.java
+24
-24
TokenComponent.java
.../com/esv/freight/app/common/component/TokenComponent.java
+2
-2
AccountConstants.java
...om/esv/freight/app/common/constants/AccountConstants.java
+5
-0
AuthFilter.java
...in/java/com/esv/freight/app/common/filter/AuthFilter.java
+10
-3
FeignConfigure.java
src/main/java/com/esv/freight/app/config/FeignConfigure.java
+1
-1
DataPermParser.java
...va/com/esv/freight/app/config/mybatis/DataPermParser.java
+132
-0
EsvMetaObjectHandler.java
.../esv/freight/app/config/mybatis/EsvMetaObjectHandler.java
+42
-0
NoticeInterface.java
src/main/java/com/esv/freight/app/feign/NoticeInterface.java
+8
-0
DriverAccountController.java
...pp/module/account/controller/DriverAccountController.java
+38
-7
OwnerAccountController.java
...app/module/account/controller/OwnerAccountController.java
+38
-5
AppLoginEntity.java
...esv/freight/app/module/account/entity/AppLoginEntity.java
+8
-0
LoginForm.java
...va/com/esv/freight/app/module/account/form/LoginForm.java
+7
-0
RefreshTokenForm.java
...esv/freight/app/module/account/form/RefreshTokenForm.java
+11
-1
AppLoginService.java
...v/freight/app/module/account/service/AppLoginService.java
+1
-1
AppLoginServiceImpl.java
.../app/module/account/service/impl/AppLoginServiceImpl.java
+6
-4
DriverMessageController.java
...pp/module/message/controller/DriverMessageController.java
+43
-0
MessagePushController.java
.../app/module/message/controller/MessagePushController.java
+40
-0
OwnerMessageController.java
...app/module/message/controller/OwnerMessageController.java
+43
-0
AccountDeviceInfoDao.java
.../freight/app/module/message/dao/AccountDeviceInfoDao.java
+18
-0
BusinessMessageDao.java
...sv/freight/app/module/message/dao/BusinessMessageDao.java
+18
-0
AccountDeviceInfoEntity.java
...ht/app/module/message/entity/AccountDeviceInfoEntity.java
+69
-0
BusinessMessageEntity.java
...ight/app/module/message/entity/BusinessMessageEntity.java
+96
-0
AccountDeviceForm.java
...sv/freight/app/module/message/form/AccountDeviceForm.java
+31
-0
PushMessageForm.java
.../esv/freight/app/module/message/form/PushMessageForm.java
+46
-0
AccountDeviceInfoService.java
.../app/module/message/service/AccountDeviceInfoService.java
+42
-0
BusinessMessageService.java
...ht/app/module/message/service/BusinessMessageService.java
+25
-0
AccountDeviceInfoServiceImpl.java
...le/message/service/impl/AccountDeviceInfoServiceImpl.java
+66
-0
BusinessMessageServiceImpl.java
...dule/message/service/impl/BusinessMessageServiceImpl.java
+108
-0
BaseTestController.java
...t/java/com/esv/freight/app/module/BaseTestController.java
+1
-1
No files found.
src/main/java/com/esv/freight/app/common/component/ProtocolComponent.java
View file @
b4e939ac
...
@@ -25,42 +25,42 @@ public class ProtocolComponent {
...
@@ -25,42 +25,42 @@ public class ProtocolComponent {
/**
/**
* description 校验Http请求的Header
* description 校验Http请求的Header
* Map<String,String> map = new HashMap<>();
* Map<String,String> map = new HashMap<>();
* map.put("
requestSource", "2"); // 终端类型:2-Android端、3-iOS
端
* map.put("
Source-Type", "2"); // 访问端来源:1-浏览器端、2-Android端、3-iOS端、4-后台服务
端
* map.put("Union-Authorization", AppConfig.getInstance().getToken()); // token
* map.put("Union-Authorization", AppConfig.getInstance().getToken()); // token
* map.put("osType", osType); // 客户端操作系统名称
* map.put("osType", osType); // 客户端操作系统名称
* map.put("osVer", osVer); // 客户端操作系统版本
* map.put("osVer", osVer); // 客户端操作系统版本
* map.put("mobileId", mobileId); // 手机唯一标识
* map.put("mobileId", mobileId); // 手机唯一标识
* map.put("cVer", cVer); // 客户端版本
* map.put("cVer", cVer); // 客户端版本
* map.put("accountType", "1"); // 帐号身份类型:1-司机、2-货主
* map.put("accountType", "1"); // 帐号身份类型:1-司机、2-货主
* map.put("tenantId", "1"); // 租户ID:
1-司机、2-货主
* map.put("tenantId", "1"); // 租户ID:
* param [request]
* param [request]
* return void
* return void
* author Administrator
* author Administrator
* createTime 2020/05/14 16:00
* createTime 2020/05/14 16:00
**/
**/
public
void
checkReqHeader
(
HttpServletRequest
request
)
throws
EException
{
public
void
checkReqHeader
(
HttpServletRequest
request
)
throws
EException
{
if
(!
String
.
valueOf
(
AccountConstants
.
APP_TYPE_ANDROID
).
equals
(
request
.
getHeader
(
"requestSource"
))
&&
!
String
.
valueOf
(
AccountConstants
.
APP_TYPE_IOS
).
equals
(
request
.
getHeader
(
"requestSource"
)))
{
if
(
String
.
valueOf
(
AccountConstants
.
APP_TYPE_ANDROID
).
equals
(
request
.
getHeader
(
"Source-Type"
))
throw
new
EException
(
ECode
.
PROTOCOL_ILLEGAL
.
code
(),
"请求头[requestSource]不符合协议"
);
||
String
.
valueOf
(
AccountConstants
.
APP_TYPE_IOS
).
equals
(
request
.
getHeader
(
"Source-Type"
)))
{
}
if
(
StringUtils
.
isBlank
(
request
.
getHeader
(
"osType"
)))
{
if
(
StringUtils
.
isBlank
(
request
.
getHeader
(
"osType"
)))
{
throw
new
EException
(
ECode
.
PROTOCOL_ILLEGAL
.
code
(),
"请求头[osType]不符合协议"
);
throw
new
EException
(
ECode
.
PROTOCOL_ILLEGAL
.
code
(),
"请求头[osType]不符合协议"
);
}
}
if
(
StringUtils
.
isBlank
(
request
.
getHeader
(
"osVer"
)))
{
if
(
StringUtils
.
isBlank
(
request
.
getHeader
(
"osVer"
)))
{
throw
new
EException
(
ECode
.
PROTOCOL_ILLEGAL
.
code
(),
"请求头[osVer]不符合协议"
);
throw
new
EException
(
ECode
.
PROTOCOL_ILLEGAL
.
code
(),
"请求头[osVer]不符合协议"
);
}
}
if
(
StringUtils
.
isBlank
(
request
.
getHeader
(
"mobileId"
)))
{
if
(
StringUtils
.
isBlank
(
request
.
getHeader
(
"mobileId"
)))
{
throw
new
EException
(
ECode
.
PROTOCOL_ILLEGAL
.
code
(),
"请求头[mobileId]不符合协议"
);
throw
new
EException
(
ECode
.
PROTOCOL_ILLEGAL
.
code
(),
"请求头[mobileId]不符合协议"
);
}
}
if
(
StringUtils
.
isBlank
(
request
.
getHeader
(
"cVer"
)))
{
if
(
StringUtils
.
isBlank
(
request
.
getHeader
(
"cVer"
)))
{
throw
new
EException
(
ECode
.
PROTOCOL_ILLEGAL
.
code
(),
"请求头[cVer]不符合协议"
);
throw
new
EException
(
ECode
.
PROTOCOL_ILLEGAL
.
code
(),
"请求头[cVer]不符合协议"
);
}
}
if
(
StringUtils
.
isBlank
(
request
.
getHeader
(
"tenantId"
)))
{
if
(
StringUtils
.
isBlank
(
request
.
getHeader
(
"tenantId"
)))
{
throw
new
EException
(
ECode
.
PROTOCOL_ILLEGAL
.
code
(),
"请求头[tenantId]不符合协议"
);
throw
new
EException
(
ECode
.
PROTOCOL_ILLEGAL
.
code
(),
"请求头[tenantId]不符合协议"
);
}
}
if
(!
String
.
valueOf
(
AccountConstants
.
ACCOUNT_TYPE_DRIVER
).
equals
(
request
.
getHeader
(
"accountType"
))
if
(!
String
.
valueOf
(
AccountConstants
.
ACCOUNT_TYPE_DRIVER
).
equals
(
request
.
getHeader
(
"accountType"
))
&&
!
String
.
valueOf
(
AccountConstants
.
ACCOUNT_TYPE_GOODS_OWNER
).
equals
(
request
.
getHeader
(
"accountType"
)))
{
&&
!
String
.
valueOf
(
AccountConstants
.
ACCOUNT_TYPE_GOODS_OWNER
).
equals
(
request
.
getHeader
(
"accountType"
)))
{
throw
new
EException
(
ECode
.
PROTOCOL_ILLEGAL
.
code
(),
"请求头[accountType]不符合协议"
);
throw
new
EException
(
ECode
.
PROTOCOL_ILLEGAL
.
code
(),
"请求头[accountType]不符合协议"
);
}
}
}
}
}
...
...
src/main/java/com/esv/freight/app/common/component/TokenComponent.java
View file @
b4e939ac
...
@@ -72,7 +72,7 @@ public class TokenComponent {
...
@@ -72,7 +72,7 @@ public class TokenComponent {
// 构建Token信息
// 构建Token信息
tokenInfoPojo
.
setIp
(
ReqUtils
.
getHttpClientIp
());
tokenInfoPojo
.
setIp
(
ReqUtils
.
getHttpClientIp
());
tokenInfoPojo
.
setSn
(
ReqUtils
.
getRequestHeader
(
"mobileId"
));
tokenInfoPojo
.
setSn
(
ReqUtils
.
getRequestHeader
(
"mobileId"
));
tokenInfoPojo
.
setDeviceType
(
Integer
.
parseInt
(
ReqUtils
.
getRequestHeader
(
"
requestSourc
e"
)));
tokenInfoPojo
.
setDeviceType
(
Integer
.
parseInt
(
ReqUtils
.
getRequestHeader
(
"
Source-Typ
e"
)));
tokenInfoPojo
.
setOsType
(
ReqUtils
.
getRequestHeader
(
"osType"
));
tokenInfoPojo
.
setOsType
(
ReqUtils
.
getRequestHeader
(
"osType"
));
tokenInfoPojo
.
setOsVersion
(
ReqUtils
.
getRequestHeader
(
"osVer"
));
tokenInfoPojo
.
setOsVersion
(
ReqUtils
.
getRequestHeader
(
"osVer"
));
tokenInfoPojo
.
setAppVersion
(
ReqUtils
.
getRequestHeader
(
"cVer"
));
tokenInfoPojo
.
setAppVersion
(
ReqUtils
.
getRequestHeader
(
"cVer"
));
...
@@ -104,7 +104,7 @@ public class TokenComponent {
...
@@ -104,7 +104,7 @@ public class TokenComponent {
// 构建Token信息
// 构建Token信息
tokenInfoPojo
.
setIp
(
ReqUtils
.
getHttpClientIp
());
tokenInfoPojo
.
setIp
(
ReqUtils
.
getHttpClientIp
());
tokenInfoPojo
.
setSn
(
ReqUtils
.
getRequestHeader
(
"mobileId"
));
tokenInfoPojo
.
setSn
(
ReqUtils
.
getRequestHeader
(
"mobileId"
));
tokenInfoPojo
.
setDeviceType
(
Integer
.
parseInt
(
ReqUtils
.
getRequestHeader
(
"
requestSourc
e"
)));
tokenInfoPojo
.
setDeviceType
(
Integer
.
parseInt
(
ReqUtils
.
getRequestHeader
(
"
Source-Typ
e"
)));
tokenInfoPojo
.
setOsType
(
ReqUtils
.
getRequestHeader
(
"osType"
));
tokenInfoPojo
.
setOsType
(
ReqUtils
.
getRequestHeader
(
"osType"
));
tokenInfoPojo
.
setOsVersion
(
ReqUtils
.
getRequestHeader
(
"osVer"
));
tokenInfoPojo
.
setOsVersion
(
ReqUtils
.
getRequestHeader
(
"osVer"
));
tokenInfoPojo
.
setAppVersion
(
ReqUtils
.
getRequestHeader
(
"cVer"
));
tokenInfoPojo
.
setAppVersion
(
ReqUtils
.
getRequestHeader
(
"cVer"
));
...
...
src/main/java/com/esv/freight/app/common/constants/AccountConstants.java
View file @
b4e939ac
...
@@ -47,4 +47,9 @@ public class AccountConstants {
...
@@ -47,4 +47,9 @@ public class AccountConstants {
public
static
final
Integer
AUDIT_STATUS_CHECK_PENDING
=
0
;
public
static
final
Integer
AUDIT_STATUS_CHECK_PENDING
=
0
;
public
static
final
Integer
AUDIT_STATUS_CHECK_SUCCESS
=
1
;
public
static
final
Integer
AUDIT_STATUS_CHECK_SUCCESS
=
1
;
public
static
final
Integer
AUDIT_STATUS_CHECK_FAIL
=
2
;
public
static
final
Integer
AUDIT_STATUS_CHECK_FAIL
=
2
;
/**
* 消息类型
**/
public
static
final
Integer
MESSAGE_TYPE_BILL_CONFIRM
=
101
;
// 账单生成后用户确认消息
}
}
src/main/java/com/esv/freight/app/common/filter/AuthFilter.java
View file @
b4e939ac
...
@@ -32,9 +32,16 @@ public class AuthFilter implements Filter {
...
@@ -32,9 +32,16 @@ public class AuthFilter implements Filter {
/**
/**
* 不需要TOKEN校验的URL
* 不需要TOKEN校验的URL
**/
**/
private
static
final
String
[]
NOT_TOKEN_URL
=
new
String
[]{
"/app/ownerBackend/account/login/loginBySms"
,
"/app/ownerBackend/account/login/loginByPwd"
,
private
static
final
String
[]
NOT_TOKEN_URL
=
new
String
[]{
"/app/ownerBackend/account/login/loginBySms"
,
"/app/driverBackend/account/login/loginBySms"
,
"/app/driverBackend/account/login/loginByPwd"
,
"/app/driverBackend/account/login/check/phone"
,
"/app/ownerBackend/account/login/loginByPwd"
,
"/app/driverBackend/account/carrier/list"
,
"/app/driverBackend/grab/find/list"
,
"/app/ownerBackend/password/reset"
,
"/app/driverBackend/password/reset"
};
"/app/driverBackend/account/login/loginBySms"
,
"/app/driverBackend/account/login/loginByPwd"
,
"/app/driverBackend/account/login/check/phone"
,
"/app/driverBackend/account/carrier/list"
,
"/app/driverBackend/grab/find/list"
,
"/app/ownerBackend/password/reset"
,
"/app/message/push2Account"
,
"/app/driverBackend/password/reset"
};
@Autowired
@Autowired
private
ProtocolComponent
protocolComponent
;
private
ProtocolComponent
protocolComponent
;
...
...
src/main/java/com/esv/freight/app/config/FeignConfigure.java
View file @
b4e939ac
...
@@ -48,7 +48,7 @@ public class FeignConfigure {
...
@@ -48,7 +48,7 @@ public class FeignConfigure {
RequestInterceptor
requestInterceptor
=
((
requestTemplate
->
{
RequestInterceptor
requestInterceptor
=
((
requestTemplate
->
{
requestTemplate
.
header
(
"trace_id"
,
MDC
.
get
(
"traceId"
));
requestTemplate
.
header
(
"trace_id"
,
MDC
.
get
(
"traceId"
));
requestTemplate
.
header
(
"application_name"
,
applicationName
);
requestTemplate
.
header
(
"application_name"
,
applicationName
);
requestTemplate
.
header
(
"Source-Type"
,
ReqUtils
.
getRequestHeader
(
"requestSource"
)
);
requestTemplate
.
header
(
"Source-Type"
,
"4"
);
requestTemplate
.
header
(
"esv_data_perm"
,
"0"
);
requestTemplate
.
header
(
"esv_data_perm"
,
"0"
);
requestTemplate
.
header
(
"esv_system"
,
"app"
);
requestTemplate
.
header
(
"esv_system"
,
"app"
);
requestTemplate
.
header
(
"esv_department"
,
"5"
);
requestTemplate
.
header
(
"esv_department"
,
"5"
);
...
...
src/main/java/com/esv/freight/app/config/mybatis/DataPermParser.java
0 → 100644
View file @
b4e939ac
package
com
.
esv
.
freight
.
app
.
config
.
mybatis
;
import
com.baomidou.mybatisplus.extension.plugins.tenant.TenantSqlParser
;
import
lombok.extern.slf4j.Slf4j
;
import
net.sf.jsqlparser.expression.BinaryExpression
;
import
net.sf.jsqlparser.expression.Expression
;
import
net.sf.jsqlparser.expression.Parenthesis
;
import
net.sf.jsqlparser.expression.operators.conditional.AndExpression
;
import
net.sf.jsqlparser.expression.operators.conditional.OrExpression
;
import
net.sf.jsqlparser.expression.operators.relational.*
;
import
net.sf.jsqlparser.schema.Column
;
import
net.sf.jsqlparser.schema.Table
;
import
net.sf.jsqlparser.statement.select.*
;
import
java.util.List
;
/**
* @description:
* @project: spring-cloud-single-template
* @name: com.esv.springcloud.single.template.config.mybatis.DataPermParser
* @author: chenfm
* @email: chenfengman@esvtek.com
* @createTime: 2020/4/7 17:00
* @version:1.0
*/
@Slf4j
public
class
DataPermParser
extends
TenantSqlParser
{
/**
* 目前仅支持:in, between, >, <, =, !=等比较操作,处理多租户的字段加上表别名
*
* @param expression
* @param table
* @return
*/
protected
Expression
processTableAlias
(
Expression
expression
,
Table
table
)
{
String
tableAliasName
;
if
(
table
.
getAlias
()
==
null
)
{
tableAliasName
=
table
.
getName
();
}
else
{
tableAliasName
=
table
.
getAlias
().
getName
();
}
if
(
expression
instanceof
InExpression
)
{
InExpression
in
=
(
InExpression
)
expression
;
if
(
in
.
getLeftExpression
()
instanceof
Column
)
{
setTableAliasNameForColumn
((
Column
)
in
.
getLeftExpression
(),
tableAliasName
);
}
}
else
if
(
expression
instanceof
BinaryExpression
)
{
BinaryExpression
compare
=
(
BinaryExpression
)
expression
;
if
(
compare
.
getLeftExpression
()
instanceof
Column
)
{
setTableAliasNameForColumn
((
Column
)
compare
.
getLeftExpression
(),
tableAliasName
);
}
else
if
(
compare
.
getRightExpression
()
instanceof
Column
)
{
setTableAliasNameForColumn
((
Column
)
compare
.
getRightExpression
(),
tableAliasName
);
}
}
else
if
(
expression
instanceof
Between
)
{
Between
between
=
(
Between
)
expression
;
if
(
between
.
getLeftExpression
()
instanceof
Column
)
{
setTableAliasNameForColumn
((
Column
)
between
.
getLeftExpression
(),
tableAliasName
);
}
}
return
expression
;
}
private
void
setTableAliasNameForColumn
(
Column
column
,
String
tableAliasName
)
{
column
.
setColumnName
(
tableAliasName
+
"."
+
column
.
getColumnName
());
}
/**
* 默认是按 tenant_id=1 按等于条件追加
*
* @param currentExpression 现有的条件:比如你原来的sql查询条件
* @param table
* @return
*/
@Override
protected
Expression
builderExpression
(
Expression
currentExpression
,
Table
table
)
{
final
Expression
tenantExpression
=
this
.
getTenantHandler
().
getTenantId
(
true
);
Expression
appendExpression
;
if
(!(
tenantExpression
instanceof
SupportsOldOracleJoinSyntax
))
{
appendExpression
=
new
EqualsTo
();
((
EqualsTo
)
appendExpression
).
setLeftExpression
(
this
.
getAliasColumn
(
table
));
((
EqualsTo
)
appendExpression
).
setRightExpression
(
tenantExpression
);
}
else
{
appendExpression
=
processTableAlias
(
tenantExpression
,
table
);
}
if
(
currentExpression
==
null
)
{
return
appendExpression
;
}
if
(
currentExpression
instanceof
BinaryExpression
)
{
BinaryExpression
binaryExpression
=
(
BinaryExpression
)
currentExpression
;
if
(
binaryExpression
.
getLeftExpression
()
instanceof
FromItem
)
{
processFromItem
((
FromItem
)
binaryExpression
.
getLeftExpression
());
}
if
(
binaryExpression
.
getRightExpression
()
instanceof
FromItem
)
{
processFromItem
((
FromItem
)
binaryExpression
.
getRightExpression
());
}
}
else
if
(
currentExpression
instanceof
InExpression
)
{
InExpression
inExp
=
(
InExpression
)
currentExpression
;
ItemsList
rightItems
=
inExp
.
getRightItemsList
();
if
(
rightItems
instanceof
SubSelect
)
{
processSelectBody
(((
SubSelect
)
rightItems
).
getSelectBody
());
}
}
if
(
currentExpression
instanceof
OrExpression
)
{
return
new
AndExpression
(
new
Parenthesis
(
currentExpression
),
appendExpression
);
}
else
{
return
new
AndExpression
(
currentExpression
,
appendExpression
);
}
}
@Override
protected
void
processPlainSelect
(
PlainSelect
plainSelect
,
boolean
addColumn
)
{
FromItem
fromItem
=
plainSelect
.
getFromItem
();
if
(
fromItem
instanceof
Table
)
{
Table
fromTable
=
(
Table
)
fromItem
;
if
(!
this
.
getTenantHandler
().
doTableFilter
(
fromTable
.
getName
()
+
"|select"
))
{
plainSelect
.
setWhere
(
builderExpression
(
plainSelect
.
getWhere
(),
fromTable
));
if
(
addColumn
)
{
plainSelect
.
getSelectItems
().
add
(
new
SelectExpressionItem
(
new
Column
(
this
.
getTenantHandler
().
getTenantIdColumn
())));
}
}
}
else
{
processFromItem
(
fromItem
);
}
List
<
Join
>
joins
=
plainSelect
.
getJoins
();
if
(
joins
!=
null
&&
joins
.
size
()
>
0
)
{
joins
.
forEach
(
j
->
{
processJoin
(
j
);
processFromItem
(
j
.
getRightItem
());
});
}
}
}
src/main/java/com/esv/freight/app/config/mybatis/EsvMetaObjectHandler.java
0 → 100644
View file @
b4e939ac
package
com
.
esv
.
freight
.
app
.
config
.
mybatis
;
import
com.baomidou.mybatisplus.core.handlers.MetaObjectHandler
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.ibatis.reflection.MetaObject
;
import
org.springframework.stereotype.Component
;
import
java.util.Date
;
/**
* @description:
* @project: esv-cc
* @name: com.esv.cc.config.mybatis.MetaHandler
* @author: chenfm
* @email: chenfengman@esvtek.com
* @createTime: 2020/4/7 20:15
* @version:1.0
*/
@Slf4j
@Component
public
class
EsvMetaObjectHandler
implements
MetaObjectHandler
{
private
static
final
String
CREATE_TIME_NAME
=
"createTime"
;
private
static
final
String
UPDATE_TIME_NAME
=
"updateTime"
;
@Override
public
void
insertFill
(
MetaObject
metaObject
)
{
if
(
metaObject
.
hasSetter
(
CREATE_TIME_NAME
))
{
this
.
setFieldValByName
(
CREATE_TIME_NAME
,
new
Date
(),
metaObject
);
}
if
(
metaObject
.
hasSetter
(
UPDATE_TIME_NAME
))
{
this
.
setFieldValByName
(
UPDATE_TIME_NAME
,
new
Date
(),
metaObject
);
}
}
@Override
public
void
updateFill
(
MetaObject
metaObject
)
{
if
(
metaObject
.
hasSetter
(
UPDATE_TIME_NAME
))
{
this
.
setFieldValByName
(
UPDATE_TIME_NAME
,
new
Date
(),
metaObject
);
}
}
}
src/main/java/com/esv/freight/app/feign/NoticeInterface.java
View file @
b4e939ac
...
@@ -23,6 +23,14 @@ public interface NoticeInterface {
...
@@ -23,6 +23,14 @@ public interface NoticeInterface {
*/
*/
@PostMapping
(
value
=
"/notice/sms/captcha/check"
)
@PostMapping
(
value
=
"/notice/sms/captcha/check"
)
JSONObject
checkSmsCaptcha
(
JSONObject
bodyJson
);
JSONObject
checkSmsCaptcha
(
JSONObject
bodyJson
);
/**
* 给指定帐号推送消息
* @param bodyJson
* @return
*/
@PostMapping
(
value
=
"/notice/message/push2Device"
)
JSONObject
push2Device
(
JSONObject
bodyJson
);
}
}
src/main/java/com/esv/freight/app/module/account/controller/DriverAccountController.java
View file @
b4e939ac
...
@@ -7,17 +7,14 @@ import com.esv.freight.app.common.constants.AccountConstants;
...
@@ -7,17 +7,14 @@ import com.esv.freight.app.common.constants.AccountConstants;
import
com.esv.freight.app.common.response.EResponse
;
import
com.esv.freight.app.common.response.EResponse
;
import
com.esv.freight.app.common.util.FeignUtils
;
import
com.esv.freight.app.common.util.FeignUtils
;
import
com.esv.freight.app.common.util.ReqUtils
;
import
com.esv.freight.app.common.util.ReqUtils
;
import
com.esv.freight.app.common.validator.groups.ValidatorInsert
;
import
com.esv.freight.app.common.validator.groups.ValidatorUpdate
;
import
com.esv.freight.app.common.validator.groups.ValidatorUpdate
;
import
com.esv.freight.app.feign.CarrierInterface
;
import
com.esv.freight.app.feign.CarrierInterface
;
import
com.esv.freight.app.feign.DriverInterface
;
import
com.esv.freight.app.feign.DriverInterface
;
import
com.esv.freight.app.feign.NoticeInterface
;
import
com.esv.freight.app.feign.NoticeInterface
;
import
com.esv.freight.app.module.account.CustomToken
;
import
com.esv.freight.app.module.account.form.DriverAuthForm
;
import
com.esv.freight.app.module.account.form.DriverAuthForm
;
import
com.esv.freight.app.module.account.form.LoginForm
;
import
com.esv.freight.app.module.account.form.LoginForm
;
import
com.esv.freight.app.module.account.form.RefreshTokenForm
;
import
com.esv.freight.app.module.account.form.RefreshTokenForm
;
import
com.esv.freight.app.module.account.pojo.DriverAccountInfoPojo
;
import
com.esv.freight.app.module.account.pojo.DriverAccountInfoPojo
;
import
com.esv.freight.app.module.account.pojo.OwnerAccountInfoPojo
;
import
com.esv.freight.app.module.account.pojo.TokenInfoPojo
;
import
com.esv.freight.app.module.account.pojo.TokenInfoPojo
;
import
com.esv.freight.app.module.account.service.AppLoginService
;
import
com.esv.freight.app.module.account.service.AppLoginService
;
import
com.esv.freight.app.module.account.validator.groups.ValidatorAccountExist
;
import
com.esv.freight.app.module.account.validator.groups.ValidatorAccountExist
;
...
@@ -27,9 +24,9 @@ import com.esv.freight.app.module.account.vo.AccountExistVO;
...
@@ -27,9 +24,9 @@ import com.esv.freight.app.module.account.vo.AccountExistVO;
import
com.esv.freight.app.module.account.vo.CarrierInfoBriefVO
;
import
com.esv.freight.app.module.account.vo.CarrierInfoBriefVO
;
import
com.esv.freight.app.module.account.vo.DriverAccountDetailVO
;
import
com.esv.freight.app.module.account.vo.DriverAccountDetailVO
;
import
com.esv.freight.app.module.account.vo.LoginVO
;
import
com.esv.freight.app.module.account.vo.LoginVO
;
import
com.esv.freight.app.module.message.form.AccountDeviceForm
;
import
com.esv.freight.app.module.message.service.AccountDeviceInfoService
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
...
@@ -57,14 +54,16 @@ public class DriverAccountController {
...
@@ -57,14 +54,16 @@ public class DriverAccountController {
private
AppLoginService
appLoginService
;
private
AppLoginService
appLoginService
;
private
CarrierInterface
carrierInterface
;
private
CarrierInterface
carrierInterface
;
private
TokenComponent
tokenComponent
;
private
TokenComponent
tokenComponent
;
private
AccountDeviceInfoService
accountDeviceInfoService
;
@Autowired
@Autowired
public
DriverAccountController
(
TokenComponent
tokenComponent
,
CarrierInterface
carrierInterface
,
DriverInterface
driverInterface
,
NoticeInterface
noticeInterface
,
AppLoginService
appLoginService
)
{
public
DriverAccountController
(
TokenComponent
tokenComponent
,
AccountDeviceInfoService
accountDeviceInfoService
,
CarrierInterface
carrierInterface
,
DriverInterface
driverInterface
,
NoticeInterface
noticeInterface
,
AppLoginService
appLoginService
)
{
this
.
noticeInterface
=
noticeInterface
;
this
.
noticeInterface
=
noticeInterface
;
this
.
appLoginService
=
appLoginService
;
this
.
appLoginService
=
appLoginService
;
this
.
driverInterface
=
driverInterface
;
this
.
driverInterface
=
driverInterface
;
this
.
carrierInterface
=
carrierInterface
;
this
.
carrierInterface
=
carrierInterface
;
this
.
tokenComponent
=
tokenComponent
;
this
.
tokenComponent
=
tokenComponent
;
this
.
accountDeviceInfoService
=
accountDeviceInfoService
;
}
}
/**
/**
...
@@ -127,6 +126,14 @@ public class DriverAccountController {
...
@@ -127,6 +126,14 @@ public class DriverAccountController {
pojo
.
setAccount
(
loginForm
.
getPhone
());
pojo
.
setAccount
(
loginForm
.
getPhone
());
pojo
.
setLoginMode
(
AccountConstants
.
ACCOUNT_LOGIN_MODE_SMS
);
pojo
.
setLoginMode
(
AccountConstants
.
ACCOUNT_LOGIN_MODE_SMS
);
LoginVO
vo
=
appLoginService
.
driverLogin
(
pojo
);
LoginVO
vo
=
appLoginService
.
driverLogin
(
pojo
);
// 提交推送标识
AccountDeviceForm
accountDeviceForm
=
new
AccountDeviceForm
();
accountDeviceForm
.
setAccount
(
loginForm
.
getPhone
());
accountDeviceForm
.
setAccountId
(
pojo
.
getId
());
accountDeviceForm
.
setDeviceSn
(
loginForm
.
getPushId
());
accountDeviceInfoService
.
saveAccountDevice
(
accountDeviceForm
);
return
EResponse
.
ok
(
vo
);
return
EResponse
.
ok
(
vo
);
}
}
...
@@ -146,6 +153,13 @@ public class DriverAccountController {
...
@@ -146,6 +153,13 @@ public class DriverAccountController {
driverAccountInfoPojo
.
setLoginMode
(
AccountConstants
.
ACCOUNT_LOGIN_MODE_SMS
);
driverAccountInfoPojo
.
setLoginMode
(
AccountConstants
.
ACCOUNT_LOGIN_MODE_SMS
);
LoginVO
vo
=
appLoginService
.
driverLogin
(
driverAccountInfoPojo
);
LoginVO
vo
=
appLoginService
.
driverLogin
(
driverAccountInfoPojo
);
// 提交推送标识
AccountDeviceForm
accountDeviceForm
=
new
AccountDeviceForm
();
accountDeviceForm
.
setAccount
(
loginForm
.
getPhone
());
accountDeviceForm
.
setAccountId
(
driverAccountInfoPojo
.
getId
());
accountDeviceForm
.
setDeviceSn
(
loginForm
.
getPushId
());
accountDeviceInfoService
.
saveAccountDevice
(
accountDeviceForm
);
return
EResponse
.
ok
(
vo
);
return
EResponse
.
ok
(
vo
);
}
}
...
@@ -187,6 +201,13 @@ public class DriverAccountController {
...
@@ -187,6 +201,13 @@ public class DriverAccountController {
driverAccountInfoPojo
.
setLoginMode
(
AccountConstants
.
ACCOUNT_LOGIN_MODE_PWD
);
driverAccountInfoPojo
.
setLoginMode
(
AccountConstants
.
ACCOUNT_LOGIN_MODE_PWD
);
LoginVO
vo
=
appLoginService
.
driverLogin
(
driverAccountInfoPojo
);
LoginVO
vo
=
appLoginService
.
driverLogin
(
driverAccountInfoPojo
);
// 提交推送标识
AccountDeviceForm
accountDeviceForm
=
new
AccountDeviceForm
();
accountDeviceForm
.
setAccount
(
loginForm
.
getPhone
());
accountDeviceForm
.
setAccountId
(
driverAccountInfoPojo
.
getId
());
accountDeviceForm
.
setDeviceSn
(
loginForm
.
getPushId
());
accountDeviceInfoService
.
saveAccountDevice
(
accountDeviceForm
);
return
EResponse
.
ok
(
vo
);
return
EResponse
.
ok
(
vo
);
}
}
...
@@ -233,6 +254,7 @@ public class DriverAccountController {
...
@@ -233,6 +254,7 @@ public class DriverAccountController {
**/
**/
@PostMapping
(
"/logout"
)
@PostMapping
(
"/logout"
)
public
EResponse
logout
()
{
public
EResponse
logout
()
{
accountDeviceInfoService
.
accountLogout
();
appLoginService
.
logout
();
appLoginService
.
logout
();
return
EResponse
.
ok
();
return
EResponse
.
ok
();
}
}
...
@@ -245,9 +267,18 @@ public class DriverAccountController {
...
@@ -245,9 +267,18 @@ public class DriverAccountController {
* createTime 2020/04/13 09:00
* createTime 2020/04/13 09:00
**/
**/
@PostMapping
(
"/token/refresh"
)
@PostMapping
(
"/token/refresh"
)
public
EResponse
refresh
(
@RequestBody
(
required
=
false
)
@Validated
(
Validator
Insert
.
class
)
RefreshTokenForm
refreshTokenForm
)
{
public
EResponse
refresh
(
@RequestBody
(
required
=
false
)
@Validated
(
Validator
Update
.
class
)
RefreshTokenForm
refreshTokenForm
)
{
LoginVO
loginByPwdVO
=
appLoginService
.
refreshToken
(
refreshTokenForm
);
LoginVO
loginByPwdVO
=
appLoginService
.
refreshToken
(
refreshTokenForm
);
TokenInfoPojo
tokenInfoPojo
=
tokenComponent
.
getTokenInfo
();
// 提交推送标识
AccountDeviceForm
accountDeviceForm
=
new
AccountDeviceForm
();
accountDeviceForm
.
setAccount
(
tokenInfoPojo
.
getAccount
());
accountDeviceForm
.
setAccountId
(
tokenInfoPojo
.
getAccountId
());
accountDeviceForm
.
setDeviceSn
(
refreshTokenForm
.
getPushId
());
accountDeviceInfoService
.
saveAccountDevice
(
accountDeviceForm
);
return
EResponse
.
ok
(
loginByPwdVO
);
return
EResponse
.
ok
(
loginByPwdVO
);
}
}
...
...
src/main/java/com/esv/freight/app/module/account/controller/OwnerAccountController.java
View file @
b4e939ac
...
@@ -8,7 +8,6 @@ import com.esv.freight.app.common.util.ReqUtils;
...
@@ -8,7 +8,6 @@ import com.esv.freight.app.common.util.ReqUtils;
import
com.esv.freight.app.common.validator.groups.ValidatorUpdate
;
import
com.esv.freight.app.common.validator.groups.ValidatorUpdate
;
import
com.esv.freight.app.feign.GoodsOwnerInterface
;
import
com.esv.freight.app.feign.GoodsOwnerInterface
;
import
com.esv.freight.app.feign.NoticeInterface
;
import
com.esv.freight.app.feign.NoticeInterface
;
import
com.esv.freight.app.module.account.CustomToken
;
import
com.esv.freight.app.module.account.form.*
;
import
com.esv.freight.app.module.account.form.*
;
import
com.esv.freight.app.module.account.pojo.OwnerAccountInfoPojo
;
import
com.esv.freight.app.module.account.pojo.OwnerAccountInfoPojo
;
import
com.esv.freight.app.module.account.pojo.TokenInfoPojo
;
import
com.esv.freight.app.module.account.pojo.TokenInfoPojo
;
...
@@ -17,10 +16,10 @@ import com.esv.freight.app.module.account.validator.groups.ValidatorAccountExist
...
@@ -17,10 +16,10 @@ import com.esv.freight.app.module.account.validator.groups.ValidatorAccountExist
import
com.esv.freight.app.module.account.validator.groups.ValidatorLoginByPwd
;
import
com.esv.freight.app.module.account.validator.groups.ValidatorLoginByPwd
;
import
com.esv.freight.app.module.account.validator.groups.ValidatorLoginBySms
;
import
com.esv.freight.app.module.account.validator.groups.ValidatorLoginBySms
;
import
com.esv.freight.app.module.account.vo.OwnerAccountDetailVO
;
import
com.esv.freight.app.module.account.vo.OwnerAccountDetailVO
;
import
com.esv.freight.app.common.response.ECode
;
import
com.esv.freight.app.common.response.EResponse
;
import
com.esv.freight.app.common.response.EResponse
;
import
com.esv.freight.app.common.validator.groups.ValidatorInsert
;
import
com.esv.freight.app.module.account.vo.LoginVO
;
import
com.esv.freight.app.module.account.vo.LoginVO
;
import
com.esv.freight.app.module.message.form.AccountDeviceForm
;
import
com.esv.freight.app.module.message.service.AccountDeviceInfoService
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.validation.annotation.Validated
;
...
@@ -45,13 +44,15 @@ public class OwnerAccountController {
...
@@ -45,13 +44,15 @@ public class OwnerAccountController {
private
NoticeInterface
noticeInterface
;
private
NoticeInterface
noticeInterface
;
private
AppLoginService
appLoginService
;
private
AppLoginService
appLoginService
;
private
TokenComponent
tokenComponent
;
private
TokenComponent
tokenComponent
;
private
AccountDeviceInfoService
accountDeviceInfoService
;
@Autowired
@Autowired
public
OwnerAccountController
(
TokenComponent
tokenComponent
,
GoodsOwnerInterface
goodsOwnerInterface
,
NoticeInterface
noticeInterface
,
AppLoginService
appLoginService
)
{
public
OwnerAccountController
(
TokenComponent
tokenComponent
,
AccountDeviceInfoService
accountDeviceInfoService
,
GoodsOwnerInterface
goodsOwnerInterface
,
NoticeInterface
noticeInterface
,
AppLoginService
appLoginService
)
{
this
.
goodsOwnerInterface
=
goodsOwnerInterface
;
this
.
goodsOwnerInterface
=
goodsOwnerInterface
;
this
.
noticeInterface
=
noticeInterface
;
this
.
noticeInterface
=
noticeInterface
;
this
.
appLoginService
=
appLoginService
;
this
.
appLoginService
=
appLoginService
;
this
.
tokenComponent
=
tokenComponent
;
this
.
tokenComponent
=
tokenComponent
;
this
.
accountDeviceInfoService
=
accountDeviceInfoService
;
}
}
/**
/**
...
@@ -112,6 +113,14 @@ public class OwnerAccountController {
...
@@ -112,6 +113,14 @@ public class OwnerAccountController {
pojo
.
setAccount
(
loginForm
.
getPhone
());
pojo
.
setAccount
(
loginForm
.
getPhone
());
pojo
.
setLoginMode
(
AccountConstants
.
ACCOUNT_LOGIN_MODE_SMS
);
pojo
.
setLoginMode
(
AccountConstants
.
ACCOUNT_LOGIN_MODE_SMS
);
LoginVO
vo
=
appLoginService
.
ownerLogin
(
pojo
);
LoginVO
vo
=
appLoginService
.
ownerLogin
(
pojo
);
// 提交推送标识
AccountDeviceForm
accountDeviceForm
=
new
AccountDeviceForm
();
accountDeviceForm
.
setAccount
(
loginForm
.
getPhone
());
accountDeviceForm
.
setAccountId
(
pojo
.
getId
());
accountDeviceForm
.
setDeviceSn
(
loginForm
.
getPushId
());
accountDeviceInfoService
.
saveAccountDevice
(
accountDeviceForm
);
return
EResponse
.
ok
(
vo
);
return
EResponse
.
ok
(
vo
);
}
}
...
@@ -132,6 +141,13 @@ public class OwnerAccountController {
...
@@ -132,6 +141,13 @@ public class OwnerAccountController {
ownerAccountInfoPojo
.
setLoginMode
(
AccountConstants
.
ACCOUNT_LOGIN_MODE_SMS
);
ownerAccountInfoPojo
.
setLoginMode
(
AccountConstants
.
ACCOUNT_LOGIN_MODE_SMS
);
LoginVO
vo
=
appLoginService
.
ownerLogin
(
ownerAccountInfoPojo
);
LoginVO
vo
=
appLoginService
.
ownerLogin
(
ownerAccountInfoPojo
);
// 提交推送标识
AccountDeviceForm
accountDeviceForm
=
new
AccountDeviceForm
();
accountDeviceForm
.
setAccount
(
loginForm
.
getPhone
());
accountDeviceForm
.
setAccountId
(
ownerAccountInfoPojo
.
getId
());
accountDeviceForm
.
setDeviceSn
(
loginForm
.
getPushId
());
accountDeviceInfoService
.
saveAccountDevice
(
accountDeviceForm
);
return
EResponse
.
ok
(
vo
);
return
EResponse
.
ok
(
vo
);
}
}
...
@@ -174,6 +190,12 @@ public class OwnerAccountController {
...
@@ -174,6 +190,12 @@ public class OwnerAccountController {
ownerAccountInfoPojo
.
setLoginMode
(
AccountConstants
.
ACCOUNT_LOGIN_MODE_PWD
);
ownerAccountInfoPojo
.
setLoginMode
(
AccountConstants
.
ACCOUNT_LOGIN_MODE_PWD
);
LoginVO
vo
=
appLoginService
.
ownerLogin
(
ownerAccountInfoPojo
);
LoginVO
vo
=
appLoginService
.
ownerLogin
(
ownerAccountInfoPojo
);
// 提交推送标识
AccountDeviceForm
accountDeviceForm
=
new
AccountDeviceForm
();
accountDeviceForm
.
setAccount
(
loginForm
.
getPhone
());
accountDeviceForm
.
setAccountId
(
ownerAccountInfoPojo
.
getId
());
accountDeviceForm
.
setDeviceSn
(
loginForm
.
getPushId
());
accountDeviceInfoService
.
saveAccountDevice
(
accountDeviceForm
);
return
EResponse
.
ok
(
vo
);
return
EResponse
.
ok
(
vo
);
}
}
...
@@ -186,7 +208,9 @@ public class OwnerAccountController {
...
@@ -186,7 +208,9 @@ public class OwnerAccountController {
**/
**/
@PostMapping
(
"/logout"
)
@PostMapping
(
"/logout"
)
public
EResponse
logout
()
{
public
EResponse
logout
()
{
accountDeviceInfoService
.
accountLogout
();
appLoginService
.
logout
();
appLoginService
.
logout
();
return
EResponse
.
ok
();
return
EResponse
.
ok
();
}
}
...
@@ -198,9 +222,18 @@ public class OwnerAccountController {
...
@@ -198,9 +222,18 @@ public class OwnerAccountController {
* createTime 2020/04/13 09:00
* createTime 2020/04/13 09:00
**/
**/
@PostMapping
(
"/token/refresh"
)
@PostMapping
(
"/token/refresh"
)
public
EResponse
refresh
(
@RequestBody
(
required
=
false
)
@Validated
(
Validator
Insert
.
class
)
RefreshTokenForm
refreshTokenForm
)
{
public
EResponse
refresh
(
@RequestBody
(
required
=
false
)
@Validated
(
Validator
Update
.
class
)
RefreshTokenForm
refreshTokenForm
)
{
LoginVO
loginByPwdVO
=
appLoginService
.
refreshToken
(
refreshTokenForm
);
LoginVO
loginByPwdVO
=
appLoginService
.
refreshToken
(
refreshTokenForm
);
TokenInfoPojo
tokenInfoPojo
=
tokenComponent
.
getTokenInfo
();
// 提交推送标识
AccountDeviceForm
accountDeviceForm
=
new
AccountDeviceForm
();
accountDeviceForm
.
setAccount
(
tokenInfoPojo
.
getAccount
());
accountDeviceForm
.
setAccountId
(
tokenInfoPojo
.
getAccountId
());
accountDeviceForm
.
setDeviceSn
(
refreshTokenForm
.
getPushId
());
accountDeviceInfoService
.
saveAccountDevice
(
accountDeviceForm
);
return
EResponse
.
ok
(
loginByPwdVO
);
return
EResponse
.
ok
(
loginByPwdVO
);
}
}
...
...
src/main/java/com/esv/freight/app/module/account/entity/AppLoginEntity.java
View file @
b4e939ac
...
@@ -29,6 +29,14 @@ public class AppLoginEntity implements Serializable {
...
@@ -29,6 +29,14 @@ public class AppLoginEntity implements Serializable {
* 手机号码
* 手机号码
*/
*/
private
String
phone
;
private
String
phone
;
/**
* 帐号ID
*/
private
Long
accountId
;
/**
* 租户ID
*/
private
Long
tenantId
;
/**
/**
* 帐号身份类型:1-司机、2-货主
* 帐号身份类型:1-司机、2-货主
*/
*/
...
...
src/main/java/com/esv/freight/app/module/account/form/LoginForm.java
View file @
b4e939ac
package
com
.
esv
.
freight
.
app
.
module
.
account
.
form
;
package
com
.
esv
.
freight
.
app
.
module
.
account
.
form
;
import
com.esv.freight.app.common.validator.groups.ValidatorUpdate
;
import
com.esv.freight.app.module.account.validator.groups.*
;
import
com.esv.freight.app.module.account.validator.groups.*
;
import
lombok.Data
;
import
lombok.Data
;
import
org.apache.commons.lang3.builder.ToStringBuilder
;
import
org.apache.commons.lang3.builder.ToStringBuilder
;
...
@@ -48,6 +49,12 @@ public class LoginForm {
...
@@ -48,6 +49,12 @@ public class LoginForm {
@NotNull
(
message
=
"参数carrierId不能为空"
,
groups
=
{
ValidatorDriverLoginBySms
.
class
})
@NotNull
(
message
=
"参数carrierId不能为空"
,
groups
=
{
ValidatorDriverLoginBySms
.
class
})
private
Long
carrierId
;
private
Long
carrierId
;
/**
* 推送设备ID
*/
@NotBlank
(
message
=
"参数pushId不能为空"
,
groups
=
{
ValidatorResetPwd
.
class
,
ValidatorLoginByPwd
.
class
,
ValidatorLoginBySms
.
class
,
ValidatorDriverLoginBySms
.
class
})
private
String
pushId
;
@Override
@Override
public
String
toString
()
{
public
String
toString
()
{
return
ToStringBuilder
.
reflectionToString
(
this
,
ToStringStyle
.
JSON_STYLE
);
return
ToStringBuilder
.
reflectionToString
(
this
,
ToStringStyle
.
JSON_STYLE
);
...
...
src/main/java/com/esv/freight/app/module/account/form/RefreshTokenForm.java
View file @
b4e939ac
package
com
.
esv
.
freight
.
app
.
module
.
account
.
form
;
package
com
.
esv
.
freight
.
app
.
module
.
account
.
form
;
import
com.esv.freight.app.common.validator.groups.ValidatorUpdate
;
import
com.esv.freight.app.module.account.validator.groups.ValidatorLoginBySms
;
import
com.esv.freight.app.module.account.validator.groups.ValidatorResetPwd
;
import
lombok.Data
;
import
lombok.Data
;
import
javax.validation.constraints.NotBlank
;
import
javax.validation.constraints.NotNull
;
import
javax.validation.constraints.NotNull
;
/**
/**
...
@@ -19,6 +23,12 @@ public class RefreshTokenForm {
...
@@ -19,6 +23,12 @@ public class RefreshTokenForm {
/**
/**
* 刷新token
* 刷新token
*/
*/
@Not
Null
(
message
=
"参数refreshToken不能为空"
)
@Not
Blank
(
message
=
"参数refreshToken不能为空"
,
groups
=
{
ValidatorUpdate
.
class
}
)
private
String
refreshToken
;
private
String
refreshToken
;
/**
* 推送设备ID
*/
@NotBlank
(
message
=
"参数pushId不能为空"
,
groups
=
{
ValidatorUpdate
.
class
})
private
String
pushId
;
}
}
src/main/java/com/esv/freight/app/module/account/service/AppLoginService.java
View file @
b4e939ac
...
@@ -69,5 +69,5 @@ public interface AppLoginService extends IService<AppLoginEntity> {
...
@@ -69,5 +69,5 @@ public interface AppLoginService extends IService<AppLoginEntity> {
* author 张志臣
* author 张志臣
* createTime 2020/04/13 16:48
* createTime 2020/04/13 16:48
**/
**/
AppLoginEntity
getAccountBy
Phone
(
String
phone
);
AppLoginEntity
getAccountBy
Id
(
Long
accountId
);
}
}
\ No newline at end of file
src/main/java/com/esv/freight/app/module/account/service/impl/AppLoginServiceImpl.java
View file @
b4e939ac
...
@@ -50,6 +50,8 @@ public class AppLoginServiceImpl extends ServiceImpl<AppLoginDao, AppLoginEntity
...
@@ -50,6 +50,8 @@ public class AppLoginServiceImpl extends ServiceImpl<AppLoginDao, AppLoginEntity
appLoginEntity
.
setRefreshTime
(
appLoginEntity
.
getLoginTime
());
appLoginEntity
.
setRefreshTime
(
appLoginEntity
.
getLoginTime
());
appLoginEntity
.
setAccessTokenValidTime
(
new
Date
(
tokenInfoPojo
.
getAccessTokenValidTime
()));
appLoginEntity
.
setAccessTokenValidTime
(
new
Date
(
tokenInfoPojo
.
getAccessTokenValidTime
()));
appLoginEntity
.
setRefreshTokenValidTime
(
new
Date
(
tokenInfoPojo
.
getRefreshTokenValidTime
()));
appLoginEntity
.
setRefreshTokenValidTime
(
new
Date
(
tokenInfoPojo
.
getRefreshTokenValidTime
()));
appLoginEntity
.
setAccountId
(
tokenInfoPojo
.
getAccountId
());
appLoginEntity
.
setTenantId
(
Long
.
parseLong
(
ReqUtils
.
getRequestHeader
(
"tenantId"
)));
if
(
null
==
record
)
{
if
(
null
==
record
)
{
this
.
baseMapper
.
insert
(
appLoginEntity
);
this
.
baseMapper
.
insert
(
appLoginEntity
);
...
@@ -84,6 +86,8 @@ public class AppLoginServiceImpl extends ServiceImpl<AppLoginDao, AppLoginEntity
...
@@ -84,6 +86,8 @@ public class AppLoginServiceImpl extends ServiceImpl<AppLoginDao, AppLoginEntity
appLoginEntity
.
setRefreshTime
(
appLoginEntity
.
getLoginTime
());
appLoginEntity
.
setRefreshTime
(
appLoginEntity
.
getLoginTime
());
appLoginEntity
.
setAccessTokenValidTime
(
new
Date
(
tokenInfoPojo
.
getAccessTokenValidTime
()));
appLoginEntity
.
setAccessTokenValidTime
(
new
Date
(
tokenInfoPojo
.
getAccessTokenValidTime
()));
appLoginEntity
.
setRefreshTokenValidTime
(
new
Date
(
tokenInfoPojo
.
getRefreshTokenValidTime
()));
appLoginEntity
.
setRefreshTokenValidTime
(
new
Date
(
tokenInfoPojo
.
getRefreshTokenValidTime
()));
appLoginEntity
.
setAccountId
(
tokenInfoPojo
.
getAccountId
());
appLoginEntity
.
setTenantId
(
Long
.
parseLong
(
ReqUtils
.
getRequestHeader
(
"tenantId"
)));
if
(
null
==
record
)
{
if
(
null
==
record
)
{
this
.
baseMapper
.
insert
(
appLoginEntity
);
this
.
baseMapper
.
insert
(
appLoginEntity
);
...
@@ -160,9 +164,7 @@ public class AppLoginServiceImpl extends ServiceImpl<AppLoginDao, AppLoginEntity
...
@@ -160,9 +164,7 @@ public class AppLoginServiceImpl extends ServiceImpl<AppLoginDao, AppLoginEntity
}
}
@Override
@Override
public
AppLoginEntity
getAccountByPhone
(
String
phone
)
{
public
AppLoginEntity
getAccountById
(
Long
accountId
)
{
QueryWrapper
<
AppLoginEntity
>
queryWrapper
=
new
QueryWrapper
<>();
return
lambdaQuery
().
eq
(
AppLoginEntity:
:
getAccountId
,
accountId
).
one
();
queryWrapper
.
eq
(
"phone"
,
phone
);
return
this
.
baseMapper
.
selectOne
(
queryWrapper
);
}
}
}
}
src/main/java/com/esv/freight/app/module/message/controller/DriverMessageController.java
0 → 100644
View file @
b4e939ac
package
com
.
esv
.
freight
.
app
.
module
.
message
.
controller
;
import
com.esv.freight.app.common.response.EResponse
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
/**
* @description: 司机消息Controller
* @project: freight-app-service
* @name: com.esv.freight.app.module.message.controller.MessageController
* @author: 张志臣
* @email: zhangzhichen@esvtek.com
* @createTime: 2020/06/10 09:40
* @version:1.0
*/
@RestController
@RequestMapping
(
"/driverBackend/message"
)
@Slf4j
@Validated
public
class
DriverMessageController
{
public
EResponse
getMessageType
()
{
return
EResponse
.
ok
();
}
public
EResponse
getMessageList
(
Integer
type
)
{
return
EResponse
.
ok
();
}
public
EResponse
getMessageDetail
(
Long
messageId
)
{
return
EResponse
.
ok
();
}
public
EResponse
deleteMessage
(
Long
messageId
)
{
return
EResponse
.
ok
();
}
public
EResponse
setAllRead
()
{
return
EResponse
.
ok
();
}
}
src/main/java/com/esv/freight/app/module/message/controller/MessagePushController.java
0 → 100644
View file @
b4e939ac
package
com
.
esv
.
freight
.
app
.
module
.
message
.
controller
;
import
com.esv.freight.app.common.response.EResponse
;
import
com.esv.freight.app.common.validator.groups.ValidatorInsert
;
import
com.esv.freight.app.module.message.form.PushMessageForm
;
import
com.esv.freight.app.module.message.service.BusinessMessageService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
/**
* @description: 消息Controller
* @project: freight-app-service
* @name: com.esv.freight.app.module.message.controller.MessagePushController
* @author: 张志臣
* @email: zhangzhichen@esvtek.com
* @createTime: 2020/06/10 09:40
* @version:1.0
*/
@RestController
@RequestMapping
(
"/message"
)
@Slf4j
@Validated
public
class
MessagePushController
{
private
BusinessMessageService
businessMessageService
;
@Autowired
public
MessagePushController
(
BusinessMessageService
businessMessageService
)
{
this
.
businessMessageService
=
businessMessageService
;
}
@PostMapping
(
"/push2Account"
)
public
EResponse
push2Account
(
@RequestHeader
@RequestBody
(
required
=
false
)
@Validated
(
ValidatorInsert
.
class
)
PushMessageForm
pushMessageForm
)
{
businessMessageService
.
insertMessage
(
pushMessageForm
);
return
EResponse
.
ok
();
}
}
src/main/java/com/esv/freight/app/module/message/controller/OwnerMessageController.java
0 → 100644
View file @
b4e939ac
package
com
.
esv
.
freight
.
app
.
module
.
message
.
controller
;
import
com.esv.freight.app.common.response.EResponse
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
/**
* @description: 货主消息Controller
* @project: freight-app-service
* @name: com.esv.freight.app.module.message.controller.MessageController
* @author: 张志臣
* @email: zhangzhichen@esvtek.com
* @createTime: 2020/06/10 09:40
* @version:1.0
*/
@RestController
@RequestMapping
(
"/ownerBackend/message"
)
@Slf4j
@Validated
public
class
OwnerMessageController
{
public
EResponse
getMessageType
()
{
return
EResponse
.
ok
();
}
public
EResponse
getMessageList
(
Integer
type
)
{
return
EResponse
.
ok
();
}
public
EResponse
getMessageDetail
(
Long
messageId
)
{
return
EResponse
.
ok
();
}
public
EResponse
deleteMessage
(
Long
messageId
)
{
return
EResponse
.
ok
();
}
public
EResponse
setAllRead
()
{
return
EResponse
.
ok
();
}
}
src/main/java/com/esv/freight/app/module/message/dao/AccountDeviceInfoDao.java
0 → 100644
View file @
b4e939ac
package
com
.
esv
.
freight
.
app
.
module
.
message
.
dao
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.esv.freight.app.module.message.entity.AccountDeviceInfoEntity
;
import
org.apache.ibatis.annotations.Mapper
;
/**
* @description: APP帐号设备信息表
* @project: freight-app-service
* @name: com.esv.freight.app.module.message.dao.AccountDeviceInfoDao
* @author: 张志臣
* @email: zhangzhichen@esvtek.com
* @createTime: 2020/06/09 17:05
* @version:1.0
*/
@Mapper
public
interface
AccountDeviceInfoDao
extends
BaseMapper
<
AccountDeviceInfoEntity
>
{
}
src/main/java/com/esv/freight/app/module/message/dao/BusinessMessageDao.java
0 → 100644
View file @
b4e939ac
package
com
.
esv
.
freight
.
app
.
module
.
message
.
dao
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.esv.freight.app.module.message.entity.BusinessMessageEntity
;
import
org.apache.ibatis.annotations.Mapper
;
/**
* @description: APP业务消息表
* @project: freight-app-service
* @name: com.esv.freight.app.module.message.dao.BusinessMessageDao
* @author: 张志臣
* @email: zhangzhichen@esvtek.com
* @createTime: 2020/06/10 11:15
* @version:1.0
*/
@Mapper
public
interface
BusinessMessageDao
extends
BaseMapper
<
BusinessMessageEntity
>
{
}
src/main/java/com/esv/freight/app/module/message/entity/AccountDeviceInfoEntity.java
0 → 100644
View file @
b4e939ac
package
com
.
esv
.
freight
.
app
.
module
.
message
.
entity
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
lombok.Data
;
import
java.io.Serializable
;
import
java.util.Date
;
/**
* @description: APP帐号设备信息表
* @project: freight-app-service
* @name: com.esv.freight.app.module.message.entity.AccountDeviceInfoEntity
* @author: 张志臣
* @email: zhangzhichen@esvtek.com
* @createTime: 2020/06/09 17:00
* @version:1.0
*/
@Data
@TableName
(
"account_device_info"
)
public
class
AccountDeviceInfoEntity
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
/**
*
*/
@TableId
private
Long
id
;
/**
* 租户ID
*/
private
Long
tenantId
;
/**
* 部门ID
*/
private
Long
departmentId
;
/**
* 帐号
*/
private
String
account
;
/**
* 帐号ID
*/
private
Long
accountId
;
/**
* 帐号类型:1-司机、2-货主
*/
private
Integer
accountType
;
/**
* 设备类型:2-android、3-ios
*/
private
Integer
deviceType
;
/**
* 设备序列号
*/
private
String
deviceSn
;
/**
* 修改时间
*/
private
Date
updateTime
;
}
src/main/java/com/esv/freight/app/module/message/entity/BusinessMessageEntity.java
0 → 100644
View file @
b4e939ac
package
com
.
esv
.
freight
.
app
.
module
.
message
.
entity
;
import
com.baomidou.mybatisplus.annotation.*
;
import
lombok.Data
;
import
java.io.Serializable
;
import
java.util.Date
;
/**
* @description: APP业务消息表
* @project: freight-app-service
* @name: com.esv.freight.app.module.message.entity.BusinessMessageEntity
* @author: 张志臣
* @email: zhangzhichen@esvtek.com
* @createTime: 2020/06/09 17:00
* @version:1.0
*/
@Data
@TableName
(
"app_business_message"
)
public
class
BusinessMessageEntity
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
/**
*
*/
@TableId
private
Long
id
;
/**
* 租户ID
*/
private
Long
tenantId
;
/**
* 部门ID
*/
private
Long
departmentId
;
/**
* 帐号ID
*/
private
Long
accountId
;
/**
* 帐号类型:1-司机、2-货主
*/
private
Integer
accountType
;
/**
* 消息本文内容
*/
private
String
messageContent
;
/**
* 消息类型 101-货主账单对账消息、102-司机账单对账消息
*/
private
Integer
messageType
;
/**
* 消息标题
*/
private
String
messageTitle
;
/**
* 消息内容(根据message_type由终端自行解析)
*/
private
String
messageData
;
/**
* 推送成功第三方返回的ID
*/
private
String
msgId
;
/**
* 是否删除 0-否;1-是
*/
@TableLogic
private
Boolean
deleted
;
/**
* 是否已读 0-未读;1-已读
*/
private
Boolean
isRead
;
/**
* 创建时间
*/
@TableField
(
fill
=
FieldFill
.
INSERT
)
private
Date
createTime
;
/**
* 更新时间
*/
@TableField
(
fill
=
FieldFill
.
INSERT_UPDATE
)
private
Date
updateTime
;
}
src/main/java/com/esv/freight/app/module/message/form/AccountDeviceForm.java
0 → 100644
View file @
b4e939ac
package
com
.
esv
.
freight
.
app
.
module
.
message
.
form
;
import
lombok.Data
;
/**
* @description: 设备信息
* @project: freight-app-service
* @name: com.esv.freight.app.module.message.form.AccountDeviceForm
* @author: 张志臣
* @email: zhangzhichen@esvtek.com
* @createTime: 2020/06/09 17:40
* @version:1.0
*/
@Data
public
class
AccountDeviceForm
{
/**
* 帐号
*/
private
String
account
;
/**
* 帐号ID
*/
private
Long
accountId
;
/**
* 设备序列号
*/
private
String
deviceSn
;
}
src/main/java/com/esv/freight/app/module/message/form/PushMessageForm.java
0 → 100644
View file @
b4e939ac
package
com
.
esv
.
freight
.
app
.
module
.
message
.
form
;
import
com.esv.freight.app.common.validator.groups.ValidatorInsert
;
import
com.esv.freight.app.common.validator.groups.ValidatorUpdate
;
import
lombok.Data
;
import
org.hibernate.validator.constraints.Range
;
import
javax.validation.constraints.NotBlank
;
import
javax.validation.constraints.NotNull
;
/**
* @description: 推送消息
* @project: freight-app-service
* @name: com.esv.freight.app.module.message.form.PushMessageForm
* @author: 张志臣
* @email: zhangzhichen@esvtek.com
* @createTime: 2020/06/10 10:15
* @version:1.0
*/
@Data
public
class
PushMessageForm
{
/**
* 帐号ID
**/
@NotNull
(
message
=
"参数accountId不能为空"
,
groups
=
{
ValidatorInsert
.
class
})
private
Long
accountId
;
/**
* APP类型:1-司机、2-货主
*/
@NotNull
(
message
=
"参数appType不能为空"
,
groups
=
{
ValidatorInsert
.
class
})
@Range
(
min
=
1
,
max
=
2
,
message
=
"无效的appType"
,
groups
=
{
ValidatorInsert
.
class
})
private
Integer
appType
;
/**
* 消息类型,具体请参考文档
*/
@NotNull
(
message
=
"参数messageType不能为空"
,
groups
=
{
ValidatorInsert
.
class
})
private
Integer
messageType
;
/**
* 业务数据,根据业务自定义JSON
*/
private
String
messageData
;
}
src/main/java/com/esv/freight/app/module/message/service/AccountDeviceInfoService.java
0 → 100644
View file @
b4e939ac
package
com
.
esv
.
freight
.
app
.
module
.
message
.
service
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.esv.freight.app.module.message.entity.AccountDeviceInfoEntity
;
import
com.esv.freight.app.module.message.form.AccountDeviceForm
;
/**
* APP帐号设备信息表
*
* @author 张志臣
* @email zhangzhichen@esvtek.com
* @date 2020-06-09 17:07
*/
public
interface
AccountDeviceInfoService
extends
IService
<
AccountDeviceInfoEntity
>
{
/**
* description 保存设备信息
* param [accountDeviceForm]
* return
* author Administrator
* createTime 2020/06/09 17:42
**/
void
saveAccountDevice
(
AccountDeviceForm
accountDeviceForm
);
/**
* description 查询设备ID
* param [accountId, deviceType]
* return
* author Administrator
* createTime 2020/06/10 10:40
**/
String
getDeviceSn
(
Long
accountId
,
Integer
deviceType
);
/**
* description 账号登出
* param
* return
* author Administrator
* createTime 2020/06/10 09:12
**/
void
accountLogout
();
}
src/main/java/com/esv/freight/app/module/message/service/BusinessMessageService.java
0 → 100644
View file @
b4e939ac
package
com
.
esv
.
freight
.
app
.
module
.
message
.
service
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.esv.freight.app.module.message.entity.BusinessMessageEntity
;
import
com.esv.freight.app.module.message.form.AccountDeviceForm
;
import
com.esv.freight.app.module.message.form.PushMessageForm
;
/**
* APP业务消息表
*
* @author 张志臣
* @email zhangzhichen@esvtek.com
* @date 2020-06-10 11:17
*/
public
interface
BusinessMessageService
extends
IService
<
BusinessMessageEntity
>
{
/**
* description 添加消息
* param [pushMessageForm]
* return
* author Administrator
* createTime 2020/06/10 11:19
**/
void
insertMessage
(
PushMessageForm
pushMessageForm
);
}
src/main/java/com/esv/freight/app/module/message/service/impl/AccountDeviceInfoServiceImpl.java
0 → 100644
View file @
b4e939ac
package
com
.
esv
.
freight
.
app
.
module
.
message
.
service
.
impl
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.esv.freight.app.common.component.TokenComponent
;
import
com.esv.freight.app.common.exception.EException
;
import
com.esv.freight.app.common.util.ReqUtils
;
import
com.esv.freight.app.module.account.pojo.TokenInfoPojo
;
import
com.esv.freight.app.module.message.dao.AccountDeviceInfoDao
;
import
com.esv.freight.app.module.message.entity.AccountDeviceInfoEntity
;
import
com.esv.freight.app.module.message.form.AccountDeviceForm
;
import
com.esv.freight.app.module.message.service.AccountDeviceInfoService
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.Date
;
@Service
(
"AccountDeviceInfoService"
)
public
class
AccountDeviceInfoServiceImpl
extends
ServiceImpl
<
AccountDeviceInfoDao
,
AccountDeviceInfoEntity
>
implements
AccountDeviceInfoService
{
private
TokenComponent
tokenComponent
;
@Autowired
public
AccountDeviceInfoServiceImpl
(
TokenComponent
tokenComponent
)
{
this
.
tokenComponent
=
tokenComponent
;
}
@Override
public
void
saveAccountDevice
(
AccountDeviceForm
accountDeviceForm
)
{
QueryWrapper
<
AccountDeviceInfoEntity
>
queryWrapper
=
new
QueryWrapper
<>();
queryWrapper
.
lambda
()
.
eq
(
AccountDeviceInfoEntity:
:
getAccountId
,
accountDeviceForm
.
getAccountId
());
this
.
remove
(
queryWrapper
);
AccountDeviceInfoEntity
accountDeviceInfoEntity
=
new
AccountDeviceInfoEntity
();
BeanUtils
.
copyProperties
(
accountDeviceForm
,
accountDeviceInfoEntity
);
accountDeviceInfoEntity
.
setUpdateTime
(
new
Date
());
accountDeviceInfoEntity
.
setAccountType
(
Integer
.
parseInt
(
ReqUtils
.
getRequestHeader
(
"accountType"
)));
accountDeviceInfoEntity
.
setDeviceType
(
Integer
.
parseInt
(
ReqUtils
.
getRequestHeader
(
"Source-Type"
)));
accountDeviceInfoEntity
.
setTenantId
(
Long
.
parseLong
(
ReqUtils
.
getRequestHeader
(
"tenantId"
)));
save
(
accountDeviceInfoEntity
);
}
@Override
public
String
getDeviceSn
(
Long
accountId
,
Integer
deviceType
)
{
AccountDeviceInfoEntity
entity
=
lambdaQuery
().
eq
(
AccountDeviceInfoEntity:
:
getAccountId
,
accountId
)
.
eq
(
AccountDeviceInfoEntity:
:
getDeviceType
,
deviceType
).
one
();
if
(
entity
==
null
)
{
throw
new
EException
(
1001
,
"无效的账号ID"
);
}
return
entity
.
getDeviceSn
();
}
@Override
public
void
accountLogout
()
{
TokenInfoPojo
tokenInfoPojo
=
this
.
tokenComponent
.
getTokenInfo
();
QueryWrapper
<
AccountDeviceInfoEntity
>
queryWrapper
=
new
QueryWrapper
<>();
queryWrapper
.
lambda
()
.
eq
(
AccountDeviceInfoEntity:
:
getAccountId
,
tokenInfoPojo
.
getAccountId
());
this
.
remove
(
queryWrapper
);
}
}
src/main/java/com/esv/freight/app/module/message/service/impl/BusinessMessageServiceImpl.java
0 → 100644
View file @
b4e939ac
package
com
.
esv
.
freight
.
app
.
module
.
message
.
service
.
impl
;
import
com.alibaba.fastjson.JSONObject
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.esv.freight.app.common.constants.AccountConstants
;
import
com.esv.freight.app.common.exception.EException
;
import
com.esv.freight.app.common.util.ReqUtils
;
import
com.esv.freight.app.feign.NoticeInterface
;
import
com.esv.freight.app.module.account.entity.AppLoginEntity
;
import
com.esv.freight.app.module.account.service.AppLoginService
;
import
com.esv.freight.app.module.message.dao.BusinessMessageDao
;
import
com.esv.freight.app.module.message.entity.BusinessMessageEntity
;
import
com.esv.freight.app.module.message.form.PushMessageForm
;
import
com.esv.freight.app.module.message.service.AccountDeviceInfoService
;
import
com.esv.freight.app.module.message.service.BusinessMessageService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
@Slf4j
@Service
(
"BusinessMessageService"
)
public
class
BusinessMessageServiceImpl
extends
ServiceImpl
<
BusinessMessageDao
,
BusinessMessageEntity
>
implements
BusinessMessageService
{
private
NoticeInterface
noticeInterface
;
private
AccountDeviceInfoService
accountDeviceInfoService
;
private
AppLoginService
appLoginService
;
@Autowired
public
BusinessMessageServiceImpl
(
AppLoginService
appLoginService
,
NoticeInterface
noticeInterface
,
AccountDeviceInfoService
accountDeviceInfoService
)
{
this
.
noticeInterface
=
noticeInterface
;
this
.
accountDeviceInfoService
=
accountDeviceInfoService
;
this
.
appLoginService
=
appLoginService
;
}
@Override
public
void
insertMessage
(
PushMessageForm
pushMessageForm
)
{
// 1:保存消息
BusinessMessageEntity
entity
=
new
BusinessMessageEntity
();
BeanUtils
.
copyProperties
(
pushMessageForm
,
entity
);
entity
.
setAccountType
(
pushMessageForm
.
getAppType
());
JSONObject
jo
;
if
(
pushMessageForm
.
getMessageType
()
==
AccountConstants
.
MESSAGE_TYPE_BILL_CONFIRM
)
{
jo
=
get101Message
(
pushMessageForm
);
}
else
{
throw
new
EException
(
1001
,
"无效的消息类型"
);
}
entity
.
setMessageContent
(
jo
.
getString
(
"msg_content"
));
entity
.
setMessageTitle
(
jo
.
getString
(
"title"
));
entity
.
setMessageData
(
pushMessageForm
.
getMessageData
());
save
(
entity
);
// 2:调用给指定设备推送消息接口
AppLoginEntity
appLoginEntity
=
appLoginService
.
getAccountById
(
pushMessageForm
.
getAccountId
());
if
(
appLoginEntity
==
null
)
{
return
;
}
JSONObject
reqJson
=
new
JSONObject
();
if
(
pushMessageForm
.
getAppType
()
==
AccountConstants
.
ACCOUNT_TYPE_DRIVER
)
{
reqJson
.
put
(
"appType"
,
2
);
// 给指定设备推送消息接口APP类型:1-货主、2-司机
}
else
{
reqJson
.
put
(
"appType"
,
1
);
}
if
(
appLoginEntity
.
getDeviceType
()
==
AccountConstants
.
APP_TYPE_ANDROID
)
{
reqJson
.
put
(
"deviceType"
,
1
);
// 设备类型:1-android、2-ios
}
else
{
reqJson
.
put
(
"deviceType"
,
2
);
}
reqJson
.
put
(
"registrationId"
,
accountDeviceInfoService
.
getDeviceSn
(
pushMessageForm
.
getAccountId
(),
appLoginEntity
.
getDeviceType
()));
reqJson
.
put
(
"message"
,
jo
);
JSONObject
result
;
log
.
info
(
reqJson
.
toJSONString
());
result
=
noticeInterface
.
push2Device
(
reqJson
);
log
.
info
(
result
.
toJSONString
());
if
(
result
.
getInteger
(
"code"
)
==
200
)
{
String
msgId
=
result
.
getJSONObject
(
"data"
).
getString
(
"msgId"
);
lambdaUpdate
()
.
eq
(
BusinessMessageEntity:
:
getId
,
entity
.
getId
())
.
set
(
BusinessMessageEntity:
:
getMsgId
,
msgId
)
.
update
();
}
}
private
JSONObject
get101Message
(
PushMessageForm
pushMessageForm
)
{
JSONObject
jo
=
JSONObject
.
parseObject
(
pushMessageForm
.
getMessageData
());
String
billNo
=
jo
.
getString
(
"billNo"
);
JSONObject
reqMessage
=
new
JSONObject
();
reqMessage
.
put
(
"title"
,
"账单提醒"
);
String
content
=
"您的新账单"
+
billNo
+
"已经生成,请尽快确认"
;
reqMessage
.
put
(
"msg_content"
,
content
);
JSONObject
extras
=
new
JSONObject
();
extras
.
put
(
"messageType"
,
AccountConstants
.
MESSAGE_TYPE_BILL_CONFIRM
);
extras
.
put
(
"data"
,
jo
);
reqMessage
.
put
(
"extras"
,
extras
);
return
reqMessage
;
}
}
src/test/java/com/esv/freight/app/module/BaseTestController.java
View file @
b4e939ac
...
@@ -49,7 +49,7 @@ public class BaseTestController {
...
@@ -49,7 +49,7 @@ public class BaseTestController {
httpHeaders
.
add
(
"esv_department_children"
,
"1,2,3"
);
httpHeaders
.
add
(
"esv_department_children"
,
"1,2,3"
);
httpHeaders
.
add
(
"esv_user"
,
"1"
);
httpHeaders
.
add
(
"esv_user"
,
"1"
);
httpHeaders
.
add
(
"esv_account"
,
"admin"
);
httpHeaders
.
add
(
"esv_account"
,
"admin"
);
httpHeaders
.
add
(
"
requestSourc
e"
,
"2"
);
httpHeaders
.
add
(
"
Source-Typ
e"
,
"2"
);
httpHeaders
.
add
(
"osType"
,
"Android_test"
);
httpHeaders
.
add
(
"osType"
,
"Android_test"
);
httpHeaders
.
add
(
"osVer"
,
"10.0.0_test"
);
httpHeaders
.
add
(
"osVer"
,
"10.0.0_test"
);
httpHeaders
.
add
(
"mobileId"
,
"1234ASDFOWEF_test"
);
httpHeaders
.
add
(
"mobileId"
,
"1234ASDFOWEF_test"
);
...
...
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