Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
open-source
/
chejia-smart-service
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit e0a0f956
authored
May 08, 2021
by
tyfanchz
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
修改 Controller 返回值类型
1 parent
de2508b6
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
124 additions
and
254 deletions
src/main/java/cn/com/glsx/smart/common/utils/DjApiInvoker.java
src/main/java/cn/com/glsx/smart/modules/controller/ProductController.java
src/main/java/cn/com/glsx/smart/modules/controller/ProductTypeController.java
src/main/java/cn/com/glsx/smart/modules/controller/SysCodeController.java
src/main/java/cn/com/glsx/smart/modules/controller/SysFileController.java
src/main/java/cn/com/glsx/smart/modules/controller/UserDeviceController.java
src/main/java/cn/com/glsx/smart/modules/service/impl/AiLockingKeyServiceImpl.java
src/main/java/cn/com/glsx/smart/common/utils/DjApiInvoker.java
deleted
100644 → 0
View file @
de2508b
package
cn
.
com
.
glsx
.
smart
.
common
.
utils
;
import
cn.com.glsx.smart.modules.model.DjApiDTO
;
import
cn.hutool.core.date.DateUtil
;
import
com.alibaba.fastjson.JSON
;
import
com.glsx.plat.common.utils.HttpUtils
;
import
com.glsx.plat.common.utils.StringUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.DisposableBean
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.context.ApplicationContextAware
;
import
org.springframework.core.env.Environment
;
import
java.util.Date
;
import
java.util.Map
;
/**
* <p>Description: 嘀加商城 API 调用工具类
* <p>Project: chejia-smart
*
* @deprecated 已废弃,改成在上层应用中使用 dubbo 调用嘀加接口
* @author wbh
* @date 2021-03-23
*/
@Slf4j
//@Component
@Deprecated
public
class
DjApiInvoker
implements
ApplicationContextAware
,
DisposableBean
{
private
static
final
String
ARG_METHOD
=
"method"
;
private
static
final
String
ARG_FORMAT
=
"format"
;
private
static
final
String
ARG_APP_KEY
=
"appKey"
;
private
static
final
String
ARG_VERSION
=
"v"
;
private
static
final
String
ARG_SIGN
=
"sign"
;
private
static
final
String
ARG_TIMESTAMP
=
"timestamp"
;
private
static
final
String
ARG_SOURCE
=
"source"
;
private
static
ApplicationContext
ctx
;
@Autowired
private
Environment
env
;
@Value
(
"${dj-carlife.url}"
)
private
String
djUrl
;
@Value
(
"${dj-carlife.app-key}"
)
private
String
djAppKey
;
@Value
(
"${dj-carlife.secret}"
)
private
String
djSecret
;
@Value
(
"${dj-carlife.format}"
)
private
String
djFormat
;
@Value
(
"${dj-carlife.version}"
)
private
String
djVersion
;
@Value
(
"${dj-carlife.source}"
)
private
String
djSource
;
/**
* 可用的接口
*/
public
enum
DjApiMethod
{
GET_SHOP_TAGS
(
"dj-carlife.api.get-shop-tags"
),
CHECK_SHOP_PRODUCT_ID
(
"dj-carlife.api.check-shop-product-id"
),
;
private
final
String
apiMethod
;
DjApiMethod
(
String
apiMethod
)
{
this
.
apiMethod
=
apiMethod
;
}
public
String
getApiMethod
()
{
return
apiMethod
;
}
}
private
DjApiInvoker
()
{}
@Override
public
void
setApplicationContext
(
ApplicationContext
applicationContext
)
{
ctx
=
applicationContext
;
}
@Override
public
void
destroy
()
{
ctx
=
null
;
}
/**
* 获取实例
*
* @return 实例
*/
public
static
DjApiInvoker
of
()
{
return
ctx
.
getBean
(
DjApiInvoker
.
class
);
}
/**
* 调用接口
*
* @param apiMethod 接口枚举
* @param paramMap 参数
* @return 结果
*/
public
DjApiDTO
postForResult
(
DjApiMethod
apiMethod
,
Map
<
String
,
Object
>
paramMap
)
{
return
this
.
postForResult
(
env
.
getProperty
(
apiMethod
.
getApiMethod
()),
paramMap
);
}
/**
* 调用接口
*
* @param apiMethodName 接口方法名
* @param paramMap 参数
* @return 结果
*/
public
DjApiDTO
postForResult
(
String
apiMethodName
,
Map
<
String
,
Object
>
paramMap
)
{
log
.
info
(
"$$$$ request api: {}, param: {}"
,
apiMethodName
,
JSON
.
toJSON
(
paramMap
));
Map
<
String
,
Object
>
signedMap
=
this
.
buildSignParamMap
(
apiMethodName
,
paramMap
);
String
respJson
=
HttpUtils
.
post
(
djUrl
,
signedMap
);
log
.
info
(
"$$$$ response json: {}"
,
respJson
);
DjApiDTO
result
=
StringUtils
.
isNotBlank
(
respJson
)
?
JSON
.
parseObject
(
respJson
,
DjApiDTO
.
class
)
:
new
DjApiDTO
();
return
result
;
}
/**
* 生成带签名的参数 map
*
* @param apiMethodName 方法名称
* @param paramMap 参数
* @return 带签名的参数 map
*/
private
Map
<
String
,
Object
>
buildSignParamMap
(
String
apiMethodName
,
Map
<
String
,
Object
>
paramMap
)
{
paramMap
.
put
(
ARG_METHOD
,
apiMethodName
);
paramMap
.
put
(
ARG_FORMAT
,
djFormat
);
paramMap
.
put
(
ARG_APP_KEY
,
djAppKey
);
paramMap
.
put
(
ARG_VERSION
,
djVersion
);
paramMap
.
put
(
ARG_TIMESTAMP
,
DateUtil
.
formatDateTime
(
new
Date
()));
paramMap
.
put
(
ARG_SOURCE
,
djSource
);
String
sign
=
SignUtil
.
signBySha1
(
paramMap
,
djSecret
);
log
.
info
(
"$$$$ generated sign: {}"
,
sign
);
paramMap
.
put
(
ARG_SIGN
,
sign
);
return
paramMap
;
}
}
src/main/java/cn/com/glsx/smart/modules/controller/ProductController.java
View file @
e0a0f95
package
cn
.
com
.
glsx
.
smart
.
modules
.
controller
;
package
cn
.
com
.
glsx
.
smart
.
modules
.
controller
;
import
java.util.List
;
import
cn.com.glsx.smart.modules.entity.SmartDeviceOrder
;
import
cn.com.glsx.smart.modules.entity.SmartDeviceOrder
;
import
cn.com.glsx.smart.modules.entity.SmartProduct
;
import
cn.com.glsx.smart.modules.entity.SmartProduct
;
import
cn.com.glsx.smart.modules.service.SmartProductService
;
import
cn.com.glsx.smart.modules.service.SmartProductService
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONArray
;
import
com.github.pagehelper.PageInfo
;
import
com.github.pagehelper.PageInfo
;
import
com.glsx.plat.core.web.R
;
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.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.List
;
/**
/**
* <p>Description: 产品列表业务
* <p>Description: 产品列表业务
* <p>Project: chejia-smart
* <p>Project: chejia-smart
...
@@ -35,10 +36,11 @@ public class ProductController {
...
@@ -35,10 +36,11 @@ public class ProductController {
* @param req 请求体
* @param req 请求体
* @return 结果
* @return 结果
*/
*/
@
RequestMapping
(
value
=
"/getPageList"
,
method
=
{
RequestMethod
.
GET
,
RequestMethod
.
POST
}
)
@
GetMapping
(
"/getPageList"
)
public
PageInfo
<
SmartProduct
>
getPageList
(
SmartProduct
req
)
{
public
R
getPageList
(
SmartProduct
req
)
{
log
.
info
(
"$$$$ /product/getPageList param: {}"
,
JSON
.
toJSONString
(
req
));
log
.
info
(
"$$$$ /product/getPageList param: {}"
,
JSON
.
toJSONString
(
req
));
return
productService
.
getPageList
(
req
);
PageInfo
<
SmartProduct
>
pageInfo
=
productService
.
getPageList
(
req
);
return
R
.
ok
().
putPageData
(
pageInfo
);
}
}
/**
/**
...
@@ -47,10 +49,11 @@ public class ProductController {
...
@@ -47,10 +49,11 @@ public class ProductController {
* @param req 请求体
* @param req 请求体
* @return 结果
* @return 结果
*/
*/
@
RequestMapping
(
value
=
"/getList"
,
method
=
{
RequestMethod
.
GET
,
RequestMethod
.
POST
}
)
@
GetMapping
(
"/getList"
)
public
List
<
SmartProduct
>
getList
(
SmartProduct
req
)
{
public
R
getList
(
SmartProduct
req
)
{
log
.
info
(
"$$$$ /product/getList param: {}"
,
JSON
.
toJSONString
(
req
));
log
.
info
(
"$$$$ /product/getList param: {}"
,
JSON
.
toJSONString
(
req
));
return
productService
.
getList
(
req
);
List
<
SmartProduct
>
productList
=
productService
.
getList
(
req
);
return
R
.
ok
().
data
(
productList
);
}
}
/**
/**
...
@@ -59,10 +62,11 @@ public class ProductController {
...
@@ -59,10 +62,11 @@ public class ProductController {
* @param req 请求体
* @param req 请求体
* @return 结果
* @return 结果
*/
*/
@
RequestMapping
(
value
=
"/getListByCondition"
,
method
=
{
RequestMethod
.
GET
,
RequestMethod
.
POST
}
)
@
GetMapping
(
"/getListByCondition"
)
public
List
<
SmartProduct
>
getListByCondition
(
@RequestBody
SmartProduct
req
)
{
public
R
getListByCondition
(
@RequestBody
SmartProduct
req
)
{
log
.
info
(
"/product/getListByCondition param: {}"
,
JSON
.
toJSONString
(
req
));
log
.
info
(
"/product/getListByCondition param: {}"
,
JSON
.
toJSONString
(
req
));
return
productService
.
getListByCondition
(
req
);
List
<
SmartProduct
>
productList
=
productService
.
getListByCondition
(
req
);
return
R
.
ok
().
data
(
productList
);
}
}
/**
/**
...
@@ -71,10 +75,11 @@ public class ProductController {
...
@@ -71,10 +75,11 @@ public class ProductController {
* @param id 产品 id
* @param id 产品 id
* @return 结果
* @return 结果
*/
*/
@
RequestMapping
(
value
=
"/getById"
,
method
=
{
RequestMethod
.
GET
,
RequestMethod
.
POST
}
)
@
GetMapping
(
"/getById"
)
public
SmartProduct
getById
(
Long
id
)
{
public
R
getById
(
Long
id
)
{
log
.
info
(
"$$$$ /product/getById param: {}"
,
id
);
log
.
info
(
"$$$$ /product/getById param: {}"
,
id
);
return
productService
.
getById
(
id
);
SmartProduct
product
=
productService
.
getById
(
id
);
return
R
.
ok
().
data
(
product
);
}
}
/**
/**
...
@@ -82,11 +87,11 @@ public class ProductController {
...
@@ -82,11 +87,11 @@ public class ProductController {
*
*
* @return 结果
* @return 结果
*/
*/
@RequestMapping
(
value
=
"/getProductAndCategory"
,
@GetMapping
(
"/getProductAndCategory"
)
method
=
{
RequestMethod
.
GET
,
RequestMethod
.
POST
})
public
R
getProductAndCategory
()
{
public
JSONArray
getProductAndCategory
()
{
log
.
info
(
"$$$$ /product/getProductAndCategory..."
);
log
.
info
(
"$$$$ /product/getProductAndCategory..."
);
return
productService
.
getProductTree
();
JSONArray
productTree
=
productService
.
getProductTree
();
return
R
.
ok
().
data
(
productTree
);
}
}
/**
/**
...
@@ -95,10 +100,11 @@ public class ProductController {
...
@@ -95,10 +100,11 @@ public class ProductController {
* @param product 产品
* @param product 产品
* @return 是否成功
* @return 是否成功
*/
*/
@
RequestMapping
(
value
=
"/save"
,
method
=
{
RequestMethod
.
POST
}
)
@
PostMapping
(
"/save"
)
public
Boolean
save
(
@RequestBody
SmartProduct
product
)
{
public
R
save
(
@RequestBody
SmartProduct
product
)
{
log
.
info
(
"$$$$ /product/save param: {}"
,
JSON
.
toJSONString
(
product
));
log
.
info
(
"$$$$ /product/save param: {}"
,
JSON
.
toJSONString
(
product
));
return
productService
.
save
(
product
);
Boolean
success
=
productService
.
save
(
product
);
return
R
.
ok
().
data
(
success
);
}
}
/**
/**
...
@@ -106,10 +112,11 @@ public class ProductController {
...
@@ -106,10 +112,11 @@ public class ProductController {
*
*
* @param id 产品 id
* @param id 产品 id
*/
*/
@
RequestMapping
(
value
=
"/getCommandSetById"
,
method
=
{
RequestMethod
.
GET
,
RequestMethod
.
POST
}
)
@
GetMapping
(
"/getCommandSetById"
)
public
List
<
SmartDeviceOrder
>
getCommandSetById
(
Long
id
)
{
public
R
getCommandSetById
(
Long
id
)
{
log
.
info
(
"$$$$ /product/getCommandSetById param: {}"
,
id
);
log
.
info
(
"$$$$ /product/getCommandSetById param: {}"
,
id
);
return
productService
.
getCommandSetById
(
id
);
List
<
SmartDeviceOrder
>
deviceOrderList
=
productService
.
getCommandSetById
(
id
);
return
R
.
ok
().
data
(
deviceOrderList
);
}
}
/**
/**
...
@@ -118,10 +125,11 @@ public class ProductController {
...
@@ -118,10 +125,11 @@ public class ProductController {
* @param platformProductId 平台产品 ID
* @param platformProductId 平台产品 ID
* @return 结果
* @return 结果
*/
*/
@
RequestMapping
(
value
=
"/getSupportedCommands"
,
method
=
{
RequestMethod
.
GET
,
RequestMethod
.
POST
}
)
@
GetMapping
(
"/getSupportedCommands"
)
public
List
<
String
>
getSupportedCommands
(
String
platformProductId
)
{
public
R
getSupportedCommands
(
String
platformProductId
)
{
log
.
info
(
"$$$$ /product/getSupportedCommands param: {}"
,
platformProductId
);
log
.
info
(
"$$$$ /product/getSupportedCommands param: {}"
,
platformProductId
);
return
productService
.
getSupportedCommands
(
platformProductId
);
List
<
String
>
commands
=
productService
.
getSupportedCommands
(
platformProductId
);
return
R
.
ok
().
data
(
commands
);
}
}
/**
/**
...
@@ -130,9 +138,10 @@ public class ProductController {
...
@@ -130,9 +138,10 @@ public class ProductController {
* @param id 产品 id
* @param id 产品 id
* @return 是否成功
* @return 是否成功
*/
*/
@
RequestMapping
(
value
=
"/putOnOff"
,
method
=
{
RequestMethod
.
GET
,
RequestMethod
.
POST
}
)
@
PostMapping
(
"/putOnOff"
)
public
Boolean
putOnOff
(
Long
id
)
{
public
R
putOnOff
(
Long
id
)
{
log
.
info
(
"$$$$ /product/putOnOff param: {}"
,
id
);
log
.
info
(
"$$$$ /product/putOnOff param: {}"
,
id
);
return
productService
.
putOnOff
(
id
);
Boolean
success
=
productService
.
putOnOff
(
id
);
return
R
.
ok
().
data
(
success
);
}
}
}
}
src/main/java/cn/com/glsx/smart/modules/controller/ProductTypeController.java
View file @
e0a0f95
package
cn
.
com
.
glsx
.
smart
.
modules
.
controller
;
package
cn
.
com
.
glsx
.
smart
.
modules
.
controller
;
import
java.util.List
;
import
cn.com.glsx.smart.modules.entity.SmartProductType
;
import
cn.com.glsx.smart.modules.entity.SmartProductType
;
import
cn.com.glsx.smart.modules.service.SmartProductTypeService
;
import
cn.com.glsx.smart.modules.service.SmartProductTypeService
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.github.pagehelper.PageInfo
;
import
com.github.pagehelper.PageInfo
;
import
com.glsx.plat.core.web.R
;
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.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.List
;
/**
/**
* <p>Description: 产品类型业务
* <p>Description: 产品类型业务
* <p>Project: chejia-smart
* <p>Project: chejia-smart
...
@@ -33,10 +34,11 @@ public class ProductTypeController {
...
@@ -33,10 +34,11 @@ public class ProductTypeController {
* @param req 请求
* @param req 请求
* @return 结果
* @return 结果
*/
*/
@
RequestMapping
(
value
=
"/getPageList"
,
method
=
{
RequestMethod
.
GET
,
RequestMethod
.
POST
}
)
@
GetMapping
(
"/getPageList"
)
public
PageInfo
<
SmartProductType
>
getPageList
(
SmartProductType
req
)
{
public
R
getPageList
(
SmartProductType
req
)
{
log
.
info
(
"$$$$ /productType/getPageList param: {}"
,
JSON
.
toJSONString
(
req
));
log
.
info
(
"$$$$ /productType/getPageList param: {}"
,
JSON
.
toJSONString
(
req
));
return
productTypeService
.
getPageList
(
req
);
PageInfo
<
SmartProductType
>
pageInfo
=
productTypeService
.
getPageList
(
req
);
return
R
.
ok
().
putPageData
(
pageInfo
);
}
}
/**
/**
...
@@ -45,10 +47,11 @@ public class ProductTypeController {
...
@@ -45,10 +47,11 @@ public class ProductTypeController {
* @param req 请求
* @param req 请求
* @return 结果
* @return 结果
*/
*/
@
RequestMapping
(
value
=
"/getList"
,
method
=
{
RequestMethod
.
GET
,
RequestMethod
.
POST
}
)
@
GetMapping
(
"/getList"
)
public
List
<
SmartProductType
>
getList
(
SmartProductType
req
)
{
public
R
getList
(
SmartProductType
req
)
{
log
.
info
(
"$$$$ /productType/getList param: {}"
,
JSON
.
toJSONString
(
req
));
log
.
info
(
"$$$$ /productType/getList param: {}"
,
JSON
.
toJSONString
(
req
));
return
productTypeService
.
getList
(
req
);
List
<
SmartProductType
>
productTypeList
=
productTypeService
.
getList
(
req
);
return
R
.
ok
().
data
(
productTypeList
);
}
}
/**
/**
...
@@ -57,9 +60,10 @@ public class ProductTypeController {
...
@@ -57,9 +60,10 @@ public class ProductTypeController {
* @param id 产品类型 id
* @param id 产品类型 id
* @return 结果
* @return 结果
*/
*/
@RequestMapping
(
value
=
"/getById"
,
method
=
{
RequestMethod
.
GET
,
RequestMethod
.
POST
})
@GetMapping
(
"/getById"
)
public
SmartProductType
getById
(
Long
id
)
{
public
R
getById
(
Long
id
)
{
return
productTypeService
.
getById
(
id
);
SmartProductType
productType
=
productTypeService
.
getById
(
id
);
return
R
.
ok
().
data
(
productType
);
}
}
/**
/**
...
@@ -68,10 +72,11 @@ public class ProductTypeController {
...
@@ -68,10 +72,11 @@ public class ProductTypeController {
* @param productType 产品类型
* @param productType 产品类型
* @return 是否成功
* @return 是否成功
*/
*/
@
RequestMapping
(
value
=
"/save"
,
method
=
{
RequestMethod
.
POST
}
)
@
PostMapping
(
"/save"
)
public
Boolean
save
(
@RequestBody
SmartProductType
productType
)
{
public
R
save
(
@RequestBody
SmartProductType
productType
)
{
log
.
info
(
"$$$$ /productType/save param: {}"
,
JSON
.
toJSONString
(
productType
));
log
.
info
(
"$$$$ /productType/save param: {}"
,
JSON
.
toJSONString
(
productType
));
return
productTypeService
.
save
(
productType
);
Boolean
success
=
productTypeService
.
save
(
productType
);
return
R
.
ok
().
data
(
success
);
}
}
/**
/**
...
@@ -79,9 +84,10 @@ public class ProductTypeController {
...
@@ -79,9 +84,10 @@ public class ProductTypeController {
*
*
* @return 结果
* @return 结果
*/
*/
@RequestMapping
(
value
=
"/getListAndContent"
,
method
=
{
RequestMethod
.
GET
,
RequestMethod
.
POST
})
@GetMapping
(
"/getListAndContent"
)
public
List
<
SmartProductType
>
getListAndContent
(
@RequestBody
List
<
Long
>
list
)
{
public
R
getListAndContent
(
@RequestBody
List
<
Long
>
list
)
{
return
productTypeService
.
getListAndContent
(
list
);
List
<
SmartProductType
>
productTypeList
=
productTypeService
.
getListAndContent
(
list
);
return
R
.
ok
().
data
(
productTypeList
);
}
}
/**
/**
...
@@ -89,8 +95,9 @@ public class ProductTypeController {
...
@@ -89,8 +95,9 @@ public class ProductTypeController {
*
*
* @return 结果
* @return 结果
*/
*/
@RequestMapping
(
value
=
"/getListAndCondition"
,
method
=
{
RequestMethod
.
GET
,
RequestMethod
.
POST
})
@GetMapping
(
"/getListAndCondition"
)
public
List
<
SmartProductType
>
getListAndCondition
(
@RequestBody
List
<
Long
>
list
)
{
public
R
getListAndCondition
(
@RequestBody
List
<
Long
>
list
)
{
return
productTypeService
.
getListAndCondition
(
list
);
List
<
SmartProductType
>
productTypeList
=
productTypeService
.
getListAndCondition
(
list
);
return
R
.
ok
().
data
(
productTypeList
);
}
}
}
}
src/main/java/cn/com/glsx/smart/modules/controller/SysCodeController.java
View file @
e0a0f95
package
cn
.
com
.
glsx
.
smart
.
modules
.
controller
;
package
cn
.
com
.
glsx
.
smart
.
modules
.
controller
;
import
java.util.List
;
import
java.util.List
;
import
cn.com.glsx.smart.common.exception.ChejiaBusinessException
;
import
cn.com.glsx.smart.common.exception.ResultEnum
;
import
cn.com.glsx.smart.common.exception.ResultEnum
;
import
cn.com.glsx.smart.modules.entity.SmartSysCode
;
import
cn.com.glsx.smart.modules.entity.SmartSysCode
;
import
cn.com.glsx.smart.modules.service.SmartSysCodeService
;
import
cn.com.glsx.smart.modules.service.SmartSysCodeService
;
...
@@ -9,9 +10,10 @@ import com.glsx.plat.common.utils.StringUtils;
...
@@ -9,9 +10,10 @@ import com.glsx.plat.common.utils.StringUtils;
import
com.glsx.plat.core.web.R
;
import
com.glsx.plat.core.web.R
;
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.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
/**
/**
...
@@ -28,25 +30,20 @@ public class SysCodeController {
...
@@ -28,25 +30,20 @@ public class SysCodeController {
@Autowired
@Autowired
private
SmartSysCodeService
sysCodeService
;
private
SmartSysCodeService
sysCodeService
;
@
RequestMapping
(
value
=
"/getList"
,
method
=
{
RequestMethod
.
GET
,
RequestMethod
.
POST
}
)
@
GetMapping
(
"/getList"
)
public
R
getList
(
SmartSysCode
code
)
{
public
R
getList
(
SmartSysCode
code
)
{
log
.
info
(
"/sysCode/getList param: {}"
,
JSON
.
toJSONString
(
code
));
log
.
info
(
"/sysCode/getList param: {}"
,
JSON
.
toJSONString
(
code
));
if
(
StringUtils
.
isEmpty
(
code
.
getDictType
())
if
(
StringUtils
.
isAnyBlank
(
code
.
getDictType
(),
code
.
getParentKey
()))
{
||
StringUtils
.
isEmpty
(
code
.
getParentKey
())){
throw
ChejiaBusinessException
.
create
(
ResultEnum
.
PARAM_ERROR
);
return
R
.
error
(
ResultEnum
.
PARAM_ERROR
.
getCode
(),
ResultEnum
.
PARAM_ERROR
.
getMessage
());
}
try
{
List
<
SmartSysCode
>
sysCodeList
=
sysCodeService
.
getList
(
code
);
return
R
.
ok
().
data
(
sysCodeList
);
}
catch
(
Exception
e
)
{
log
.
error
(
"!!!! /sysCode/getList ERROR"
,
e
);
return
R
.
error
();
}
}
List
<
SmartSysCode
>
sysCodeList
=
sysCodeService
.
getList
(
code
);
return
R
.
ok
().
data
(
sysCodeList
);
}
}
@
RequestMapping
(
value
=
"/getListByCondition"
,
method
=
{
RequestMethod
.
POST
}
)
@
PostMapping
(
"/getListByCondition"
)
public
List
<
SmartSysCode
>
getListByCondition
(
@RequestBody
SmartSysCode
code
)
{
public
R
getListByCondition
(
@RequestBody
SmartSysCode
code
)
{
log
.
info
(
"/sysCode/getListByCondition param: {}"
,
JSON
.
toJSONString
(
code
));
log
.
info
(
"/sysCode/getListByCondition param: {}"
,
JSON
.
toJSONString
(
code
));
return
sysCodeService
.
getList
(
code
);
List
<
SmartSysCode
>
sysCodeList
=
sysCodeService
.
getList
(
code
);
return
R
.
ok
().
data
(
sysCodeList
);
}
}
}
}
src/main/java/cn/com/glsx/smart/modules/controller/SysFileController.java
View file @
e0a0f95
package
cn
.
com
.
glsx
.
smart
.
modules
.
controller
;
package
cn
.
com
.
glsx
.
smart
.
modules
.
controller
;
import
java.util.List
;
import
java.util.Map
;
import
cn.com.glsx.smart.modules.model.FileDTO
;
import
cn.com.glsx.smart.modules.model.FileDTO
;
import
cn.com.glsx.smart.modules.service.SmartSysFileService
;
import
cn.com.glsx.smart.modules.service.SmartSysFileService
;
import
com.glsx.plat.core.web.R
;
import
com.glsx.plat.core.web.R
;
...
@@ -7,10 +9,12 @@ import io.swagger.annotations.Api;
...
@@ -7,10 +9,12 @@ import io.swagger.annotations.Api;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
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.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
java.util.List
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
java.util.Map
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
/**
/**
* <p>Description:
* <p>Description:
...
@@ -28,13 +32,13 @@ public class SysFileController {
...
@@ -28,13 +32,13 @@ public class SysFileController {
@Autowired
@Autowired
private
SmartSysFileService
sysFileService
;
private
SmartSysFileService
sysFileService
;
@
RequestMapping
(
value
=
"/getList"
,
method
=
{
RequestMethod
.
GET
}
)
@
GetMapping
(
"/getList"
)
@ApiOperation
(
value
=
"查询图片"
)
@ApiOperation
(
value
=
"查询图片"
)
public
R
findAll
(
@RequestParam
(
"type"
)
Byte
type
)
{
public
R
findAll
(
@RequestParam
(
"type"
)
Byte
type
)
{
return
R
.
ok
().
data
(
sysFileService
.
findByType
(
type
));
return
R
.
ok
().
data
(
sysFileService
.
findByType
(
type
));
}
}
@
RequestMapping
(
value
=
"/batchSaveFile"
,
method
=
{
RequestMethod
.
POST
}
)
@
PostMapping
(
"/batchSaveFile"
)
@ApiOperation
(
value
=
"批量保存图片"
)
@ApiOperation
(
value
=
"批量保存图片"
)
public
R
saveFile
(
@RequestBody
List
<
FileDTO
>
files
)
{
public
R
saveFile
(
@RequestBody
List
<
FileDTO
>
files
)
{
List
<
Map
<
String
,
Object
>>
mapList
=
null
;
List
<
Map
<
String
,
Object
>>
mapList
=
null
;
...
@@ -47,7 +51,7 @@ public class SysFileController {
...
@@ -47,7 +51,7 @@ public class SysFileController {
return
R
.
ok
().
data
(
mapList
);
return
R
.
ok
().
data
(
mapList
);
}
}
@
RequestMapping
(
value
=
"/saveFile"
,
method
=
{
RequestMethod
.
POST
}
)
@
PostMapping
(
"/saveFile"
)
@ApiOperation
(
value
=
"保存更新图片"
)
@ApiOperation
(
value
=
"保存更新图片"
)
public
R
updateFile
(
@RequestBody
FileDTO
fileDTO
)
{
public
R
updateFile
(
@RequestBody
FileDTO
fileDTO
)
{
try
{
try
{
...
...
src/main/java/cn/com/glsx/smart/modules/controller/UserDeviceController.java
View file @
e0a0f95
...
@@ -8,11 +8,14 @@ import cn.com.glsx.smart.modules.service.SmartUserDeviceService;
...
@@ -8,11 +8,14 @@ import cn.com.glsx.smart.modules.service.SmartUserDeviceService;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.glsx.plat.common.utils.StringUtils
;
import
com.glsx.plat.common.utils.StringUtils
;
import
com.glsx.plat.core.web.R
;
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.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.Request
Method
;
import
org.springframework.web.bind.annotation.Request
Param
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
/**
/**
...
@@ -35,13 +38,14 @@ public class UserDeviceController {
...
@@ -35,13 +38,14 @@ public class UserDeviceController {
* @param req 请求
* @param req 请求
* @return 结果
* @return 结果
*/
*/
@
RequestMapping
(
value
=
"/getList"
,
method
=
{
RequestMethod
.
GET
,
RequestMethod
.
POST
}
)
@
GetMapping
(
"/getList"
)
public
List
<
SmartUserDevice
>
getList
(
SmartUserDevice
req
)
{
public
R
getList
(
SmartUserDevice
req
)
{
log
.
info
(
"$$$$ /userDevice/getList param: {}"
,
JSON
.
toJSONString
(
req
));
log
.
info
(
"$$$$ /userDevice/getList param: {}"
,
JSON
.
toJSONString
(
req
));
if
(
req
.
getUserId
()
==
null
)
{
if
(
req
.
getUserId
()
==
null
)
{
throw
ChejiaBusinessException
.
create
(
ResultEnum
.
PARAM_EMPTY
,
"userId"
);
throw
ChejiaBusinessException
.
create
(
ResultEnum
.
PARAM_EMPTY
,
"userId"
);
}
}
return
userDeviceService
.
getList
(
req
);
List
<
SmartUserDevice
>
userDeviceList
=
userDeviceService
.
getList
(
req
);
return
R
.
ok
().
data
(
userDeviceList
);
}
}
/**
/**
...
@@ -50,13 +54,14 @@ public class UserDeviceController {
...
@@ -50,13 +54,14 @@ public class UserDeviceController {
* @param req 请求
* @param req 请求
* @return 结果
* @return 结果
*/
*/
@
RequestMapping
(
value
=
"/getByDeviceId"
,
method
=
{
RequestMethod
.
GET
,
RequestMethod
.
POST
}
)
@
GetMapping
(
"/getByDeviceId"
)
public
SmartUserDevice
getByDeviceId
(
SmartUserDevice
req
)
{
public
R
getByDeviceId
(
SmartUserDevice
req
)
{
log
.
info
(
"$$$$ /userDevice/getByDeviceId param: {}"
,
JSON
.
toJSONString
(
req
));
log
.
info
(
"$$$$ /userDevice/getByDeviceId param: {}"
,
JSON
.
toJSONString
(
req
));
if
(
StringUtils
.
isBlank
(
req
.
getDeviceId
()))
{
if
(
StringUtils
.
isBlank
(
req
.
getDeviceId
()))
{
throw
ChejiaBusinessException
.
create
(
ResultEnum
.
PARAM_EMPTY
,
"deviceId"
);
throw
ChejiaBusinessException
.
create
(
ResultEnum
.
PARAM_EMPTY
,
"deviceId"
);
}
}
return
userDeviceService
.
getByDeviceId
(
req
);
SmartUserDevice
userDevice
=
userDeviceService
.
getByDeviceId
(
req
);
return
R
.
ok
().
data
(
userDevice
);
}
}
/**
/**
...
@@ -65,13 +70,14 @@ public class UserDeviceController {
...
@@ -65,13 +70,14 @@ public class UserDeviceController {
* @param req 请求
* @param req 请求
* @return 结果
* @return 结果
*/
*/
@
RequestMapping
(
value
=
"/save"
,
method
=
{
RequestMethod
.
POST
}
)
@
PostMapping
(
"/save"
)
public
boolean
save
(
@RequestBody
SmartUserDevice
req
)
{
public
R
save
(
@RequestBody
SmartUserDevice
req
)
{
log
.
info
(
"$$$$ /userDevice/save param: {}"
,
JSON
.
toJSONString
(
req
));
log
.
info
(
"$$$$ /userDevice/save param: {}"
,
JSON
.
toJSONString
(
req
));
if
(
StringUtils
.
isBlank
(
req
.
getDeviceId
())
||
req
.
getChannel
()
==
null
)
{
if
(
StringUtils
.
isBlank
(
req
.
getDeviceId
())
||
req
.
getChannel
()
==
null
)
{
throw
ChejiaBusinessException
.
create
(
ResultEnum
.
PARAM_EMPTY
,
"deviceId, channel"
);
throw
ChejiaBusinessException
.
create
(
ResultEnum
.
PARAM_EMPTY
,
"deviceId, channel"
);
}
}
return
userDeviceService
.
save
(
req
)
>
0
;
int
rows
=
userDeviceService
.
save
(
req
);
return
R
.
ok
().
data
(
rows
>
0
);
}
}
/**
/**
...
@@ -80,13 +86,14 @@ public class UserDeviceController {
...
@@ -80,13 +86,14 @@ public class UserDeviceController {
* @param req 请求
* @param req 请求
* @return 结果
* @return 结果
*/
*/
@
RequestMapping
(
value
=
"/deleteDevice"
,
method
=
{
RequestMethod
.
POST
}
)
@
PostMapping
(
"/deleteDevice"
)
public
boolean
deleteDevice
(
@RequestBody
SmartUserDevice
req
)
{
public
R
deleteDevice
(
@RequestBody
SmartUserDevice
req
)
{
log
.
info
(
"$$$$ /userDevice/deleteDevice param: {}"
,
JSON
.
toJSONString
(
req
));
log
.
info
(
"$$$$ /userDevice/deleteDevice param: {}"
,
JSON
.
toJSONString
(
req
));
if
(
StringUtils
.
isBlank
(
req
.
getDeviceId
())
||
req
.
getChannel
()
==
null
)
{
if
(
StringUtils
.
isBlank
(
req
.
getDeviceId
())
||
req
.
getChannel
()
==
null
)
{
throw
ChejiaBusinessException
.
create
(
ResultEnum
.
PARAM_EMPTY
,
"deviceId, channel"
);
throw
ChejiaBusinessException
.
create
(
ResultEnum
.
PARAM_EMPTY
,
"deviceId, channel"
);
}
}
return
userDeviceService
.
deleteDevice
(
req
)
>
0
;
int
rows
=
userDeviceService
.
deleteDevice
(
req
);
return
R
.
ok
().
data
(
rows
>
0
);
}
}
/**
/**
...
@@ -95,13 +102,11 @@ public class UserDeviceController {
...
@@ -95,13 +102,11 @@ public class UserDeviceController {
* @param token 用户 token
* @param token 用户 token
* @return 结果
* @return 结果
*/
*/
@
RequestMapping
(
value
=
"/getUserBindKey"
,
method
=
{
RequestMethod
.
GET
,
RequestMethod
.
POST
}
)
@
GetMapping
(
"/getUserBindKey"
)
public
String
getUserBindKey
(
String
token
)
{
public
R
getUserBindKey
(
@RequestParam
String
token
)
{
log
.
info
(
"$$$$ /userDevice/getUserBindKey param: {}"
,
token
);
log
.
info
(
"$$$$ /userDevice/getUserBindKey param: {}"
,
token
);
if
(
StringUtils
.
isBlank
(
token
))
{
String
userBindKey
=
userDeviceService
.
getUserBindKey
(
token
);
throw
ChejiaBusinessException
.
create
(
ResultEnum
.
PARAM_EMPTY
,
"token"
);
return
R
.
ok
().
data
(
userBindKey
);
}
return
userDeviceService
.
getUserBindKey
(
token
);
}
}
/**
/**
...
@@ -110,10 +115,11 @@ public class UserDeviceController {
...
@@ -110,10 +115,11 @@ public class UserDeviceController {
* @param req 请求
* @param req 请求
* @return 结果
* @return 结果
*/
*/
@
RequestMapping
(
value
=
"/sendCommand"
,
method
=
{
RequestMethod
.
POST
}
)
@
PostMapping
(
"/sendCommand"
)
public
String
sendCommand
(
@RequestBody
JSONObject
req
)
{
public
R
sendCommand
(
@RequestBody
JSONObject
req
)
{
log
.
info
(
"$$$$ /userDevice/sendCommand param: {}"
,
req
.
toJSONString
());
log
.
info
(
"$$$$ /userDevice/sendCommand param: {}"
,
req
.
toJSONString
());
return
userDeviceService
.
sendCommand
(
req
);
String
result
=
userDeviceService
.
sendCommand
(
req
);
return
R
.
ok
().
data
(
result
);
}
}
/**
/**
...
@@ -122,9 +128,10 @@ public class UserDeviceController {
...
@@ -122,9 +128,10 @@ public class UserDeviceController {
* @param req 请求
* @param req 请求
* @return 结果
* @return 结果
*/
*/
@
RequestMapping
(
value
=
"/unbind"
,
method
=
{
RequestMethod
.
POST
}
)
@
PostMapping
(
"/unbind"
)
public
String
unbind
(
@RequestBody
JSONObject
req
)
{
public
R
unbind
(
@RequestBody
JSONObject
req
)
{
log
.
info
(
"$$$$ /userDevice/unbind param: {}"
,
req
.
toJSONString
());
log
.
info
(
"$$$$ /userDevice/unbind param: {}"
,
req
.
toJSONString
());
return
userDeviceService
.
unbind
(
req
);
String
result
=
userDeviceService
.
unbind
(
req
);
return
R
.
ok
().
data
(
result
);
}
}
}
}
src/main/java/cn/com/glsx/smart/modules/service/impl/AiLockingKeyServiceImpl.java
View file @
e0a0f95
...
@@ -222,7 +222,7 @@ public class AiLockingKeyServiceImpl implements AiLockingKeyService {
...
@@ -222,7 +222,7 @@ public class AiLockingKeyServiceImpl implements AiLockingKeyService {
crep
=
aesEncryptUtils
.
decrypt
(
key
.
getCrepCode
());
crep
=
aesEncryptUtils
.
decrypt
(
key
.
getCrepCode
());
key
.
setCrepCode
(
crep
);
key
.
setCrepCode
(
crep
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
new
BusinessException
(
ResultEnum
.
CAR_KEY_EXCEP_4
);
throw
ChejiaBusinessException
.
create
(
ResultEnum
.
CAR_KEY_EXCEP_4
);
}
}
});
});
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment