Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
open-source
/
chejia-smart-admin
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 55a3ab0f
authored
Mar 19, 2021
by
wnb0128
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge branch 'dev' of 192.168.3.233:open-source/chejia-smart-admin into dev
2 parents
4fcf50fa
1683233e
Show whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
184 additions
and
239 deletions
src/main/java/com/glsx/admin/controller/IndexController.java
src/main/java/com/glsx/admin/controller/ProductController.java
src/main/java/com/glsx/admin/controller/ProductTypeController.java
src/main/java/com/glsx/admin/exception/GlobalExceptionHandler.java
src/main/java/com/glsx/admin/exception/ResultEnum.java
src/main/java/com/glsx/admin/filter/CorsFilter.java
src/main/java/com/glsx/admin/pojo/request/DemoReq.java
src/main/java/com/glsx/admin/pojo/request/SmartDeviceOrderReq.java → src/main/java/com/glsx/admin/pojo/request/DeviceOrderReq.java
src/main/java/com/glsx/admin/pojo/request/ProductReq.java
src/main/java/com/glsx/admin/pojo/request/SmartProductTypeParamReq.java → src/main/java/com/glsx/admin/pojo/request/ProductTypeParamReq.java
src/main/java/com/glsx/admin/pojo/request/SmartProductTypeReq.java → src/main/java/com/glsx/admin/pojo/request/ProductTypeReq.java
src/main/java/com/glsx/admin/pojo/request/SmartProductReq.java
src/main/java/com/glsx/admin/pojo/response/DemoResp.java
src/main/java/com/glsx/admin/pojo/response/SmartDeviceOrderResp.java → src/main/java/com/glsx/admin/pojo/response/DeviceOrderResp.java
src/main/java/com/glsx/admin/pojo/response/SmartProductResp.java → src/main/java/com/glsx/admin/pojo/response/ProductResp.java
src/main/java/com/glsx/admin/pojo/response/SmartProductTypeResp.java → src/main/java/com/glsx/admin/pojo/response/ProductTypeResp.java
src/main/java/com/glsx/admin/remote/IndexFeignClient.java
src/main/java/com/glsx/admin/remote/ProductFeignClient.java
src/main/java/com/glsx/admin/remote/ProductTypeFeignClient.java
src/main/java/com/glsx/admin/remote/impl/IndexHystrix.java
src/main/java/com/glsx/admin/controller/IndexController.java
View file @
55a3ab0
package
com
.
glsx
.
admin
.
controller
;
package
com
.
glsx
.
admin
.
controller
;
import
com.glsx.admin.pojo.request.ProductReq
;
import
com.glsx.admin.remote.IndexFeignClient
;
import
com.glsx.admin.remote.IndexFeignClient
;
import
com.glsx.biz.user.common.entity.User
;
import
com.glsx.biz.user.common.entity.User
;
import
com.glsx.biz.user.service.UserService
;
import
com.glsx.biz.user.service.UserService
;
...
@@ -8,7 +7,9 @@ import com.glsx.cloudframework.exception.ServiceException;
...
@@ -8,7 +7,9 @@ import com.glsx.cloudframework.exception.ServiceException;
import
com.glsx.plat.core.web.R
;
import
com.glsx.plat.core.web.R
;
import
org.apache.dubbo.config.annotation.DubboReference
;
import
org.apache.dubbo.config.annotation.DubboReference
;
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.RequestMapping
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.bind.annotation.RestController
;
/**
/**
* @Title: IndexController.java
* @Title: IndexController.java
...
@@ -39,13 +40,4 @@ public class IndexController {
...
@@ -39,13 +40,4 @@ public class IndexController {
return
R
.
ok
().
data
(
indexFeignClient
.
getHome
());
//feign调用远程服务
return
R
.
ok
().
data
(
indexFeignClient
.
getHome
());
//feign调用远程服务
}
}
@ResponseBody
@RequestMapping
(
value
=
"/getProduct"
,
method
=
{
RequestMethod
.
GET
,
RequestMethod
.
POST
})
public
R
getProduct
(
@RequestParam
(
"url"
)
String
url
,
@RequestParam
(
"name"
)
String
name
){
ProductReq
product
=
new
ProductReq
();
product
.
setIconUrl
(
url
);
product
.
setProductName
(
name
);
return
R
.
ok
().
data
(
indexFeignClient
.
getProduct
(
product
));
//feign调用远程服务
}
}
}
src/main/java/com/glsx/admin/controller/ProductController.java
View file @
55a3ab0
package
com
.
glsx
.
admin
.
controller
;
package
com
.
glsx
.
admin
.
controller
;
import
javax.validation.groups.Default
;
import
java.util.List
;
import
java.util.List
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.github.pagehelper.PageInfo
;
import
com.github.pagehelper.PageInfo
;
import
com.glsx.admin.exception.BusinessException
;
import
com.glsx.admin.exception.BusinessException
;
import
com.glsx.admin.exception.ResultEnum
;
import
com.glsx.admin.exception.ResultEnum
;
import
com.glsx.admin.pojo.request.SmartProductReq
;
import
com.glsx.admin.pojo.GroupA
;
import
com.glsx.admin.pojo.response.SmartDeviceOrderResp
;
import
com.glsx.admin.pojo.request.ProductReq
;
import
com.glsx.admin.pojo.response.SmartProductResp
;
import
com.glsx.admin.pojo.response.DeviceOrderResp
;
import
com.glsx.admin.pojo.response.ProductResp
;
import
com.glsx.admin.remote.ProductFeignClient
;
import
com.glsx.admin.remote.ProductFeignClient
;
import
com.glsx.plat.common.utils.StringUtils
;
import
com.glsx.plat.common.utils.StringUtils
;
import
com.glsx.plat.core.web.R
;
import
com.glsx.plat.core.web.R
;
...
@@ -40,25 +42,22 @@ public class ProductController {
...
@@ -40,25 +42,22 @@ public class ProductController {
* @return 结果
* @return 结果
*/
*/
@RequestMapping
(
value
=
"/getList"
,
method
=
{
RequestMethod
.
GET
,
RequestMethod
.
POST
})
@RequestMapping
(
value
=
"/getList"
,
method
=
{
RequestMethod
.
GET
,
RequestMethod
.
POST
})
public
R
getList
(
Smart
ProductReq
req
)
{
public
R
getList
(
ProductReq
req
)
{
log
.
info
(
"$$$$ /product/getList param: {}"
,
JSON
.
toJSONString
(
req
));
log
.
info
(
"$$$$ /product/getList param: {}"
,
JSON
.
toJSONString
(
req
));
PageInfo
<
Smart
ProductResp
>
pageInfo
=
productFeignClient
.
getList
(
req
);
PageInfo
<
ProductResp
>
pageInfo
=
productFeignClient
.
getList
(
req
);
return
R
.
ok
().
putPageData
(
pageInfo
);
return
R
.
ok
().
putPageData
(
pageInfo
);
}
}
/**
/**
* 根据 id 查询产品详情。
* 根据 id 查询产品详情。
*
*
* @param
id 产品 id
* @param
req 请求体
* @return 结果
* @return 结果
*/
*/
@RequestMapping
(
value
=
"/getById"
,
method
=
{
RequestMethod
.
GET
,
RequestMethod
.
POST
})
@RequestMapping
(
value
=
"/getById"
,
method
=
{
RequestMethod
.
GET
,
RequestMethod
.
POST
})
public
R
getById
(
Long
id
)
{
public
R
getById
(
@Validated
({
Default
.
class
})
ProductReq
req
)
{
log
.
info
(
"$$$$ /product/getById param: {}"
,
id
);
log
.
info
(
"$$$$ /product/getById param: {}"
,
JSON
.
toJSONString
(
req
));
if
(
id
==
null
)
{
ProductResp
resp
=
productFeignClient
.
getById
(
req
);
throw
new
BusinessException
(
ResultEnum
.
PARAM_ERROR
);
}
SmartProductResp
resp
=
productFeignClient
.
getById
(
id
);
return
R
.
ok
().
data
(
resp
);
return
R
.
ok
().
data
(
resp
);
}
}
...
@@ -66,56 +65,54 @@ public class ProductController {
...
@@ -66,56 +65,54 @@ public class ProductController {
* 保存产品。无则插入,有则更新。
* 保存产品。无则插入,有则更新。
*
*
* @param req 产品
* @param req 产品
* @return 结果
*/
*/
@RequestMapping
(
value
=
"/save"
,
method
=
{
RequestMethod
.
POST
})
@RequestMapping
(
value
=
"/save"
,
method
=
{
RequestMethod
.
POST
})
public
R
save
(
@RequestBody
@Validated
Smart
ProductReq
req
)
{
public
R
save
(
@RequestBody
@Validated
({
GroupA
.
class
})
ProductReq
req
)
{
log
.
info
(
"$$$$ /product/save param: {}"
,
JSON
.
toJSONString
(
req
));
log
.
info
(
"$$$$ /product/save param: {}"
,
JSON
.
toJSONString
(
req
));
productFeignClient
.
save
(
req
);
Boolean
success
=
productFeignClient
.
save
(
req
);
return
R
.
ok
();
return
R
.
ok
()
.
data
(
success
)
;
}
}
/**
/**
* 根据产品 id 获取指令集。
* 根据产品 id 获取指令集。
*
*
* @param id 产品 id
* @param req 请求体
* @return 结果
*/
*/
@RequestMapping
(
value
=
"/getCommandSetById"
,
method
=
{
RequestMethod
.
GET
,
RequestMethod
.
POST
})
@RequestMapping
(
value
=
"/getCommandSetById"
,
method
=
{
RequestMethod
.
GET
,
RequestMethod
.
POST
})
public
R
getCommandSetById
(
String
id
)
{
public
R
getCommandSetById
(
@Validated
({
Default
.
class
})
ProductReq
req
)
{
log
.
info
(
"$$$$ /product/getCommandSetById param: {}"
,
id
);
log
.
info
(
"$$$$ /product/getCommandSetById param: {}"
,
JSON
.
toJSONString
(
req
));
if
(
StringUtils
.
isBlank
(
id
))
{
List
<
DeviceOrderResp
>
respList
=
productFeignClient
.
getCommandSetById
(
req
);
throw
new
BusinessException
(
ResultEnum
.
PARAM_ERROR
);
}
List
<
SmartDeviceOrderResp
>
respList
=
productFeignClient
.
getCommandSetById
(
id
);
return
R
.
ok
().
data
(
respList
);
return
R
.
ok
().
data
(
respList
);
}
}
/**
/**
* 校验商城商品 id。
* 校验商城商品 id。
*
*
* @param shopProductId 商品 id
* @param req 请求体
* @return 结果
*/
*/
@RequestMapping
(
value
=
"/checkShopProductId"
,
method
=
{
RequestMethod
.
GET
,
RequestMethod
.
POST
})
@RequestMapping
(
value
=
"/checkShopProductId"
,
method
=
{
RequestMethod
.
GET
,
RequestMethod
.
POST
})
public
R
checkShopProductId
(
String
shopProductId
)
{
public
R
checkShopProductId
(
ProductReq
req
)
{
log
.
info
(
"$$$$ /product/checkShopProductId param: {}"
,
shopProductId
);
log
.
info
(
"$$$$ /product/checkShopProductId param: {}"
,
JSON
.
toJSONString
(
req
)
);
if
(
StringUtils
.
isBlank
(
shopProductId
))
{
if
(
StringUtils
.
isBlank
(
req
.
getShopProductId
()
))
{
throw
new
BusinessException
(
ResultEnum
.
PARAM_ERROR
);
throw
new
BusinessException
(
ResultEnum
.
PARAM_ERROR
);
}
}
Boolean
productIdValid
=
productFeignClient
.
checkShopProductId
(
shopProductId
);
Boolean
productIdValid
=
productFeignClient
.
checkShopProductId
(
req
);
return
R
.
ok
().
data
(
productIdValid
);
return
R
.
ok
().
data
(
productIdValid
);
}
}
/**
/**
* 上下架产品。
* 上下架产品。
*
*
* @param id 产品 id
* @param req 请求体
* @return 结果
*/
*/
@RequestMapping
(
value
=
"/putOnOff"
,
method
=
{
RequestMethod
.
GET
,
RequestMethod
.
POST
})
@RequestMapping
(
value
=
"/putOnOff"
,
method
=
{
RequestMethod
.
GET
,
RequestMethod
.
POST
})
public
R
putOnOff
(
Long
id
)
{
public
R
putOnOff
(
@Validated
({
Default
.
class
})
ProductReq
req
)
{
log
.
info
(
"$$$$ /product/putOnOff param: {}"
,
id
);
log
.
info
(
"$$$$ /product/putOnOff param: {}"
,
JSON
.
toJSONString
(
req
));
if
(
id
==
null
)
{
Boolean
success
=
productFeignClient
.
putOnOff
(
req
);
throw
new
BusinessException
(
ResultEnum
.
PARAM_ERROR
);
return
R
.
ok
().
data
(
success
);
}
productFeignClient
.
putOnOff
(
id
);
return
R
.
ok
();
}
}
}
}
src/main/java/com/glsx/admin/controller/ProductTypeController.java
View file @
55a3ab0
package
com
.
glsx
.
admin
.
controller
;
package
com
.
glsx
.
admin
.
controller
;
import
javax.validation.groups.Default
;
import
java.util.List
;
import
java.util.List
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.github.pagehelper.PageInfo
;
import
com.github.pagehelper.PageInfo
;
import
com.glsx.admin.exception.BusinessException
;
import
com.glsx.admin.pojo.GroupA
;
import
com.glsx.admin.exception.ResultEnum
;
import
com.glsx.admin.pojo.request.ProductTypeReq
;
import
com.glsx.admin.pojo.request.SmartProductTypeReq
;
import
com.glsx.admin.pojo.response.ProductTypeResp
;
import
com.glsx.admin.pojo.response.SmartProductTypeResp
;
import
com.glsx.admin.remote.ProductTypeFeignClient
;
import
com.glsx.admin.remote.ProductTypeFeignClient
;
import
com.glsx.plat.core.web.R
;
import
com.glsx.plat.core.web.R
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
...
@@ -38,25 +38,22 @@ public class ProductTypeController {
...
@@ -38,25 +38,22 @@ public class ProductTypeController {
* @return 结果
* @return 结果
*/
*/
@RequestMapping
(
value
=
"/getList"
,
method
=
{
RequestMethod
.
GET
,
RequestMethod
.
POST
})
@RequestMapping
(
value
=
"/getList"
,
method
=
{
RequestMethod
.
GET
,
RequestMethod
.
POST
})
public
R
getList
(
Smart
ProductTypeReq
req
)
{
public
R
getList
(
ProductTypeReq
req
)
{
log
.
info
(
"$$$$ /productType/getList param: {}"
,
JSON
.
toJSONString
(
req
));
log
.
info
(
"$$$$ /productType/getList param: {}"
,
JSON
.
toJSONString
(
req
));
PageInfo
<
Smart
ProductTypeResp
>
pageInfo
=
productTypeFeignClient
.
getList
(
req
);
PageInfo
<
ProductTypeResp
>
pageInfo
=
productTypeFeignClient
.
getList
(
req
);
return
R
.
ok
().
putPageData
(
pageInfo
);
return
R
.
ok
().
putPageData
(
pageInfo
);
}
}
/**
/**
* 根据 id 获取产品类型。
* 根据 id 获取产品类型。
*
*
* @param
id 产品类型 id
* @param
req 请求体
* @return 结果
* @return 结果
*/
*/
@RequestMapping
(
value
=
"/getById"
,
method
=
{
RequestMethod
.
GET
,
RequestMethod
.
POST
})
@RequestMapping
(
value
=
"/getById"
,
method
=
{
RequestMethod
.
GET
,
RequestMethod
.
POST
})
public
R
getById
(
Long
id
)
{
public
R
getById
(
@Validated
({
Default
.
class
})
ProductTypeReq
req
)
{
log
.
info
(
"$$$$ /productType/getById param: {}"
,
id
);
log
.
info
(
"$$$$ /productType/getById param: {}"
,
JSON
.
toJSONString
(
req
));
if
(
id
==
null
)
{
ProductTypeResp
resp
=
productTypeFeignClient
.
getById
(
req
);
throw
new
BusinessException
(
ResultEnum
.
PARAM_ERROR
);
}
SmartProductTypeResp
resp
=
productTypeFeignClient
.
getById
(
id
);
return
R
.
ok
().
data
(
resp
);
return
R
.
ok
().
data
(
resp
);
}
}
...
@@ -64,16 +61,17 @@ public class ProductTypeController {
...
@@ -64,16 +61,17 @@ public class ProductTypeController {
* 保存产品类型。
* 保存产品类型。
*
*
* @param req 产品类型
* @param req 产品类型
* @return 结果
*/
*/
@RequestMapping
(
value
=
"/save"
,
method
=
{
RequestMethod
.
POST
})
@RequestMapping
(
value
=
"/save"
,
method
=
{
RequestMethod
.
POST
})
public
R
save
(
@RequestBody
@Validated
Smart
ProductTypeReq
req
)
{
public
R
save
(
@RequestBody
@Validated
({
GroupA
.
class
})
ProductTypeReq
req
)
{
log
.
info
(
"$$$$ /productType/save param: {}"
,
JSON
.
toJSONString
(
req
));
log
.
info
(
"$$$$ /productType/save param: {}"
,
JSON
.
toJSONString
(
req
));
productTypeFeignClient
.
save
(
req
);
Boolean
success
=
productTypeFeignClient
.
save
(
req
);
return
R
.
ok
();
return
R
.
ok
()
.
data
(
success
)
;
}
}
/**
/**
* 获取商城标签
* 获取商城标签
。
*
*
* @return 结果
* @return 结果
*/
*/
...
...
src/main/java/com/glsx/admin/exception/GlobalExceptionHandler.java
View file @
55a3ab0
package
com
.
glsx
.
admin
.
exception
;
package
com
.
glsx
.
admin
.
exception
;
import
java.util.List
;
import
java.util.concurrent.TimeoutException
;
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
;
...
@@ -8,6 +10,7 @@ import com.netflix.hystrix.exception.HystrixRuntimeException;
...
@@ -8,6 +10,7 @@ import com.netflix.hystrix.exception.HystrixRuntimeException;
import
feign.FeignException
;
import
feign.FeignException
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.validation.BindException
;
import
org.springframework.validation.BindException
;
import
org.springframework.validation.FieldError
;
import
org.springframework.web.bind.MethodArgumentNotValidException
;
import
org.springframework.web.bind.MethodArgumentNotValidException
;
import
org.springframework.web.bind.ServletRequestBindingException
;
import
org.springframework.web.bind.ServletRequestBindingException
;
import
org.springframework.web.bind.annotation.ExceptionHandler
;
import
org.springframework.web.bind.annotation.ExceptionHandler
;
...
@@ -33,8 +36,27 @@ public class GlobalExceptionHandler {
...
@@ -33,8 +36,27 @@ public class GlobalExceptionHandler {
BindException
.
class
})
BindException
.
class
})
public
R
handleBindException
(
Exception
e
)
{
public
R
handleBindException
(
Exception
e
)
{
log
.
error
(
"!!!! 参数错误"
,
e
);
log
.
error
(
"!!!! 参数错误"
,
e
);
if
((
e
instanceof
MethodArgumentNotValidException
)
||
(
e
instanceof
BindException
))
{
List
<
FieldError
>
errorList
;
if
(
e
instanceof
MethodArgumentNotValidException
)
{
MethodArgumentNotValidException
ex
=
(
MethodArgumentNotValidException
)
e
;
errorList
=
ex
.
getBindingResult
().
getFieldErrors
();
}
else
{
BindException
ex
=
(
BindException
)
e
;
errorList
=
ex
.
getFieldErrors
();
}
StringBuffer
messageSb
=
new
StringBuffer
();
for
(
FieldError
error
:
errorList
)
{
String
fieldMessage
=
String
.
format
(
"%s: %s, "
,
error
.
getField
(),
error
.
getDefaultMessage
());
messageSb
.
append
(
fieldMessage
);
}
return
R
.
error
(
ResultEnum
.
PARAM_ERROR
.
getCode
(),
messageSb
.
toString
().
replaceAll
(
", +$"
,
""
));
}
else
{
return
R
.
error
(
ResultEnum
.
PARAM_ERROR
.
getCode
(),
ResultEnum
.
PARAM_ERROR
.
getMessage
());
return
R
.
error
(
ResultEnum
.
PARAM_ERROR
.
getCode
(),
ResultEnum
.
PARAM_ERROR
.
getMessage
());
}
}
}
@ExceptionHandler
({
HystrixRuntimeException
.
class
})
@ExceptionHandler
({
HystrixRuntimeException
.
class
})
public
R
handleHystrixException
(
HystrixRuntimeException
e
)
{
public
R
handleHystrixException
(
HystrixRuntimeException
e
)
{
...
@@ -42,6 +64,10 @@ public class GlobalExceptionHandler {
...
@@ -42,6 +64,10 @@ public class GlobalExceptionHandler {
if
(
cause
instanceof
FeignException
)
{
if
(
cause
instanceof
FeignException
)
{
FeignException
feignException
=
(
FeignException
)
cause
;
FeignException
feignException
=
(
FeignException
)
cause
;
return
this
.
handleFeignException
(
feignException
);
return
this
.
handleFeignException
(
feignException
);
}
else
if
(
cause
instanceof
TimeoutException
)
{
log
.
error
(
"!!!! 服务调用超时"
,
e
);
return
R
.
error
(
ResultEnum
.
REMOTE_SERVER_TIME_OUT
.
getCode
(),
ResultEnum
.
REMOTE_SERVER_TIME_OUT
.
getMessage
());
}
else
{
}
else
{
log
.
error
(
"!!!! Hystrix熔断错误"
,
e
);
log
.
error
(
"!!!! Hystrix熔断错误"
,
e
);
return
R
.
error
(
ResultEnum
.
ERROR
.
getCode
(),
ResultEnum
.
ERROR
.
getMessage
());
return
R
.
error
(
ResultEnum
.
ERROR
.
getCode
(),
ResultEnum
.
ERROR
.
getMessage
());
...
...
src/main/java/com/glsx/admin/exception/ResultEnum.java
View file @
55a3ab0
...
@@ -19,6 +19,7 @@ public enum ResultEnum {
...
@@ -19,6 +19,7 @@ public enum ResultEnum {
PRODUCT_TYPE_NOT_FOUND
(
3001
,
"产品类型ID未找到"
),
PRODUCT_TYPE_NOT_FOUND
(
3001
,
"产品类型ID未找到"
),
REMOTE_SERVICE_ERROR
(
9001
,
"服务调用错误"
),
REMOTE_SERVICE_ERROR
(
9001
,
"服务调用错误"
),
REMOTE_SERVER_TIME_OUT
(
9002
,
"远程服务超时,请重试"
),
;
;
private
final
Integer
code
;
private
final
Integer
code
;
...
...
src/main/java/com/glsx/admin/filter/CorsFilter.java
0 → 100644
View file @
55a3ab0
package
com
.
glsx
.
admin
.
filter
;
import
javax.servlet.Filter
;
import
javax.servlet.FilterChain
;
import
javax.servlet.ServletException
;
import
javax.servlet.ServletRequest
;
import
javax.servlet.ServletResponse
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.util.Enumeration
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.stereotype.Component
;
/**
* <p>Description: 跨域配置
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-18
*/
@Component
public
class
CorsFilter
implements
Filter
{
@Override
public
void
doFilter
(
ServletRequest
request
,
ServletResponse
response
,
FilterChain
chain
)
throws
IOException
,
ServletException
{
HttpServletRequest
httpRequest
=
(
HttpServletRequest
)
request
;
HttpServletResponse
httpResponse
=
(
HttpServletResponse
)
response
;
StringBuffer
headersSb
=
new
StringBuffer
();
Enumeration
<
String
>
headerNames
=
httpRequest
.
getHeaderNames
();
while
(
headerNames
.
hasMoreElements
())
{
headersSb
.
append
(
headerNames
.
nextElement
()).
append
(
", "
);
}
if
(!
headersSb
.
toString
().
toLowerCase
().
contains
(
"authorization"
))
{
headersSb
.
append
(
"authorization"
);
}
httpResponse
.
addHeader
(
HttpHeaders
.
ACCESS_CONTROL_ALLOW_HEADERS
,
headersSb
.
toString
().
replaceAll
(
", +$"
,
""
));
httpResponse
.
addHeader
(
HttpHeaders
.
ACCESS_CONTROL_ALLOW_CREDENTIALS
,
"true"
);
httpResponse
.
addHeader
(
HttpHeaders
.
ACCESS_CONTROL_ALLOW_ORIGIN
,
httpRequest
.
getHeader
(
HttpHeaders
.
ORIGIN
));
httpResponse
.
addHeader
(
HttpHeaders
.
ACCESS_CONTROL_ALLOW_METHODS
,
httpRequest
.
getMethod
());
httpResponse
.
addHeader
(
HttpHeaders
.
ACCESS_CONTROL_EXPOSE_HEADERS
,
"*"
);
httpResponse
.
addHeader
(
HttpHeaders
.
ACCESS_CONTROL_MAX_AGE
,
"18000L"
);
chain
.
doFilter
(
request
,
response
);
}
}
src/main/java/com/glsx/admin/pojo/request/DemoReq.java
deleted
100644 → 0
View file @
4fcf50f
package
com
.
glsx
.
admin
.
pojo
.
request
;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-16
*/
public
class
DemoReq
{
}
src/main/java/com/glsx/admin/pojo/request/
Smart
DeviceOrderReq.java
→
src/main/java/com/glsx/admin/pojo/request/DeviceOrderReq.java
View file @
55a3ab0
...
@@ -11,7 +11,7 @@ import lombok.Data;
...
@@ -11,7 +11,7 @@ import lombok.Data;
*/
*/
@Data
@Data
public
class
Smart
DeviceOrderReq
{
public
class
DeviceOrderReq
{
private
Integer
id
;
private
Integer
id
;
/**
/**
...
...
src/main/java/com/glsx/admin/pojo/request/ProductReq.java
View file @
55a3ab0
package
com
.
glsx
.
admin
.
pojo
.
request
;
package
com
.
glsx
.
admin
.
pojo
.
request
;
import
lombok.Data
;
import
javax.validation.constraints.NotBlank
;
import
javax.validation.constraints.NotNull
;
import
javax.validation.groups.Default
;
import
java.util.Date
;
import
java.util.Date
;
import
com.glsx.admin.pojo.BaseDTO
;
import
com.glsx.admin.pojo.GroupA
;
import
lombok.Data
;
/**
/**
* <p>Description:
* <p>Description:
...
@@ -17,66 +21,53 @@ import java.util.Date;
...
@@ -17,66 +21,53 @@ import java.util.Date;
* 车家智能产品数据表
* 车家智能产品数据表
*/
*/
@Data
@Data
public
class
ProductReq
{
public
class
ProductReq
extends
BaseDTO
{
/**
* 图标 url
*/
private
String
iconUrl
;
/**
* 产品类型名称
*/
private
String
typeName
;
/**
* 接入平台名称
*/
private
String
platformName
;
/**
* 配网模式名称
*/
private
String
networkName
;
/**
/**
* 标识ID
* 标识ID
*/
*/
@NotNull
(
message
=
"id不能为空"
,
groups
=
{
Default
.
class
})
private
Long
id
;
private
Long
id
;
/**
/**
* 产品名称
* 产品名称
*/
*/
@NotBlank
(
message
=
"产品名称不能为空"
,
groups
=
{
GroupA
.
class
})
private
String
productName
;
private
String
productName
;
/**
/**
* 图片ID 关联smart_sys_file中id
* 图片ID 关联smart_sys_file中id
*/
*/
@NotNull
(
message
=
"缩略图不能为空"
,
groups
=
{
GroupA
.
class
})
private
Long
icon
;
private
Long
icon
;
/**
/**
* 产品类型ID 关联smart_product_type中id
* 产品类型ID 关联smart_product_type中id
*/
*/
@NotNull
(
message
=
"产品类型不能为空"
,
groups
=
{
GroupA
.
class
})
private
Long
typeId
;
private
Long
typeId
;
/**
/**
* 商城产品id
* 商城产品id
*/
*/
@NotBlank
(
message
=
"商品id不能为空"
,
groups
=
{
GroupA
.
class
})
private
String
shopProductId
;
private
String
shopProductId
;
/**
/**
* 接入平台key 关联smart_sys_code中dict_key
* 接入平台key 关联smart_sys_code中dict_key
*/
*/
@NotBlank
(
message
=
"接入平台不能为空"
,
groups
=
{
GroupA
.
class
})
private
String
platformKey
;
private
String
platformKey
;
/**
/**
* 接入平台产品id
* 接入平台产品id
*/
*/
@NotBlank
(
message
=
"产品id不能为空"
,
groups
=
{
GroupA
.
class
})
private
String
platformProductId
;
private
String
platformProductId
;
/**
/**
* 配网方式key 关联smart_sys_code中dict_key
* 配网方式key 关联smart_sys_code中dict_key
*/
*/
@NotBlank
(
message
=
"配网模式不能为空"
,
groups
=
{
GroupA
.
class
})
private
String
networkKey
;
private
String
networkKey
;
/**
/**
...
...
src/main/java/com/glsx/admin/pojo/request/
Smart
ProductTypeParamReq.java
→
src/main/java/com/glsx/admin/pojo/request/ProductTypeParamReq.java
View file @
55a3ab0
...
@@ -15,7 +15,7 @@ import lombok.Data;
...
@@ -15,7 +15,7 @@ import lombok.Data;
* 车家智能产品类型参数表
* 车家智能产品类型参数表
*/
*/
@Data
@Data
public
class
Smart
ProductTypeParamReq
{
public
class
ProductTypeParamReq
{
/**
/**
* 标识ID
* 标识ID
*/
*/
...
...
src/main/java/com/glsx/admin/pojo/request/
Smart
ProductTypeReq.java
→
src/main/java/com/glsx/admin/pojo/request/ProductTypeReq.java
View file @
55a3ab0
package
com
.
glsx
.
admin
.
pojo
.
request
;
package
com
.
glsx
.
admin
.
pojo
.
request
;
import
javax.validation.constraints.NotBlank
;
import
javax.validation.constraints.NotBlank
;
import
javax.validation.constraints.NotNull
;
import
javax.validation.groups.Default
;
import
java.util.Date
;
import
java.util.Date
;
import
com.glsx.admin.pojo.BaseDTO
;
import
com.glsx.admin.pojo.BaseDTO
;
import
com.glsx.admin.pojo.GroupA
;
import
lombok.Data
;
import
lombok.Data
;
/**
/**
...
@@ -18,26 +21,29 @@ import lombok.Data;
...
@@ -18,26 +21,29 @@ import lombok.Data;
* 车家智能产品类型表
* 车家智能产品类型表
*/
*/
@Data
@Data
public
class
Smart
ProductTypeReq
extends
BaseDTO
{
public
class
ProductTypeReq
extends
BaseDTO
{
/**
/**
* 标识ID
* 标识ID
*/
*/
@NotNull
(
message
=
"id不能为空"
,
groups
=
{
Default
.
class
})
private
Long
id
;
private
Long
id
;
/**
/**
* 类型名称
* 类型名称
*/
*/
@NotBlank
@NotBlank
(
message
=
"产品类型名称不能为空"
,
groups
=
{
GroupA
.
class
})
private
String
typeName
;
private
String
typeName
;
/**
/**
* 类别key 关联smart_sys_code中dict_key
* 类别key 关联smart_sys_code中dict_key
*/
*/
@NotBlank
(
message
=
"分类不能为空"
,
groups
=
{
GroupA
.
class
})
private
String
categoryKey
;
private
String
categoryKey
;
/**
/**
* 商城标签
* 商城标签
*/
*/
@NotBlank
(
message
=
"商城标签不能为空"
,
groups
=
{
GroupA
.
class
})
private
String
shopTag
;
private
String
shopTag
;
/**
/**
...
...
src/main/java/com/glsx/admin/pojo/request/SmartProductReq.java
deleted
100644 → 0
View file @
4fcf50f
package
com
.
glsx
.
admin
.
pojo
.
request
;
import
javax.validation.constraints.NotBlank
;
import
java.util.Date
;
import
com.glsx.admin.pojo.BaseDTO
;
import
lombok.Data
;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-15
*/
/**
* 车家智能产品数据表
*/
@Data
public
class
SmartProductReq
extends
BaseDTO
{
/**
* 标识ID
*/
private
Long
id
;
/**
* 产品名称
*/
@NotBlank
private
String
productName
;
/**
* 图片ID 关联smart_sys_file中id
*/
private
Long
icon
;
/**
* 产品类型ID 关联smart_product_type中id
*/
private
Long
typeId
;
/**
* 商城产品id
*/
private
String
shopProductId
;
/**
* 接入平台key 关联smart_sys_code中dict_key
*/
private
String
platformKey
;
/**
* 接入平台产品id
*/
private
String
platformProductId
;
/**
* 配网方式key 关联smart_sys_code中dict_key
*/
private
String
networkKey
;
/**
* 状态:0下线 1上线
*/
private
Byte
status
;
/**
* 备注
*/
private
String
remark
;
/**
* 创建时间
*/
private
Date
createTime
;
/**
* 创建人
*/
private
Long
createBy
;
/**
* 更新时间
*/
private
Date
updateTime
;
/**
* 更新人
*/
private
Long
updateBy
;
}
src/main/java/com/glsx/admin/pojo/response/DemoResp.java
deleted
100644 → 0
View file @
4fcf50f
package
com
.
glsx
.
admin
.
pojo
.
response
;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-16
*/
public
class
DemoResp
{
}
src/main/java/com/glsx/admin/pojo/response/
Smart
DeviceOrderResp.java
→
src/main/java/com/glsx/admin/pojo/response/DeviceOrderResp.java
View file @
55a3ab0
...
@@ -11,7 +11,7 @@ import lombok.Data;
...
@@ -11,7 +11,7 @@ import lombok.Data;
*/
*/
@Data
@Data
public
class
Smart
DeviceOrderResp
{
public
class
DeviceOrderResp
{
private
Integer
id
;
private
Integer
id
;
/**
/**
...
...
src/main/java/com/glsx/admin/pojo/response/
Smart
ProductResp.java
→
src/main/java/com/glsx/admin/pojo/response/ProductResp.java
View file @
55a3ab0
package
com
.
glsx
.
admin
.
pojo
.
response
;
package
com
.
glsx
.
admin
.
pojo
.
response
;
import
javax.persistence.Transient
;
import
java.util.Date
;
import
java.util.Date
;
import
com.glsx.admin.pojo.BaseDTO
;
import
com.glsx.admin.pojo.BaseDTO
;
import
lombok.Data
;
import
lombok.Data
;
...
@@ -17,7 +18,20 @@ import lombok.Data;
...
@@ -17,7 +18,20 @@ import lombok.Data;
* 车家智能产品数据表
* 车家智能产品数据表
*/
*/
@Data
@Data
public
class
SmartProductResp
extends
BaseDTO
{
public
class
ProductResp
extends
BaseDTO
{
/**
* 图标 url
*/
@Transient
private
String
iconUrl
;
/**
* 产品类型名称
*/
@Transient
private
String
typeName
;
/**
/**
* 标识ID
* 标识ID
*/
*/
...
...
src/main/java/com/glsx/admin/pojo/response/
Smart
ProductTypeResp.java
→
src/main/java/com/glsx/admin/pojo/response/ProductTypeResp.java
View file @
55a3ab0
package
com
.
glsx
.
admin
.
pojo
.
response
;
package
com
.
glsx
.
admin
.
pojo
.
response
;
import
javax.validation.constraints.NotBlank
;
import
java.util.Date
;
import
java.util.Date
;
import
com.glsx.admin.pojo.BaseDTO
;
import
com.glsx.admin.pojo.BaseDTO
;
import
lombok.Data
;
import
lombok.Data
;
...
@@ -18,7 +17,7 @@ import lombok.Data;
...
@@ -18,7 +17,7 @@ import lombok.Data;
* 车家智能产品类型表
* 车家智能产品类型表
*/
*/
@Data
@Data
public
class
Smart
ProductTypeResp
extends
BaseDTO
{
public
class
ProductTypeResp
extends
BaseDTO
{
/**
/**
* 标识ID
* 标识ID
*/
*/
...
@@ -27,7 +26,6 @@ public class SmartProductTypeResp extends BaseDTO {
...
@@ -27,7 +26,6 @@ public class SmartProductTypeResp extends BaseDTO {
/**
/**
* 类型名称
* 类型名称
*/
*/
@NotBlank
private
String
typeName
;
private
String
typeName
;
/**
/**
...
...
src/main/java/com/glsx/admin/remote/IndexFeignClient.java
View file @
55a3ab0
package
com
.
glsx
.
admin
.
remote
;
package
com
.
glsx
.
admin
.
remote
;
import
com.glsx.admin.pojo.request.ProductReq
;
import
com.glsx.admin.remote.impl.IndexHystrix
;
import
com.glsx.admin.remote.impl.IndexHystrix
;
import
org.springframework.cloud.openfeign.FeignClient
;
import
org.springframework.cloud.openfeign.FeignClient
;
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.RequestMethod
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.bind.annotation.ResponseBody
;
...
@@ -14,9 +12,4 @@ public interface IndexFeignClient {
...
@@ -14,9 +12,4 @@ public interface IndexFeignClient {
@ResponseBody
@ResponseBody
@RequestMapping
(
value
=
"/home"
,
method
=
{
RequestMethod
.
GET
})
@RequestMapping
(
value
=
"/home"
,
method
=
{
RequestMethod
.
GET
})
String
getHome
();
String
getHome
();
@ResponseBody
@RequestMapping
(
value
=
"/getProduct"
,
method
=
{
RequestMethod
.
GET
})
String
getProduct
(
@RequestBody
ProductReq
product
);
}
}
src/main/java/com/glsx/admin/remote/ProductFeignClient.java
View file @
55a3ab0
...
@@ -2,15 +2,14 @@ package com.glsx.admin.remote;
...
@@ -2,15 +2,14 @@ package com.glsx.admin.remote;
import
java.util.List
;
import
java.util.List
;
import
com.github.pagehelper.PageInfo
;
import
com.github.pagehelper.PageInfo
;
import
com.glsx.admin.pojo.request.
Smart
ProductReq
;
import
com.glsx.admin.pojo.request.ProductReq
;
import
com.glsx.admin.pojo.response.
Smart
DeviceOrderResp
;
import
com.glsx.admin.pojo.response.DeviceOrderResp
;
import
com.glsx.admin.pojo.response.
Smart
ProductResp
;
import
com.glsx.admin.pojo.response.ProductResp
;
import
org.springframework.cloud.openfeign.FeignClient
;
import
org.springframework.cloud.openfeign.FeignClient
;
import
org.springframework.cloud.openfeign.SpringQueryMap
;
import
org.springframework.cloud.openfeign.SpringQueryMap
;
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.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.bind.annotation.ResponseBody
;
/**
/**
...
@@ -24,25 +23,25 @@ import org.springframework.web.bind.annotation.ResponseBody;
...
@@ -24,25 +23,25 @@ import org.springframework.web.bind.annotation.ResponseBody;
public
interface
ProductFeignClient
{
public
interface
ProductFeignClient
{
@RequestMapping
(
value
=
"/product/getList"
,
method
=
{
RequestMethod
.
GET
})
@RequestMapping
(
value
=
"/product/getList"
,
method
=
{
RequestMethod
.
GET
})
@ResponseBody
@ResponseBody
PageInfo
<
SmartProductResp
>
getList
(
@SpringQueryMap
Smart
ProductReq
req
);
PageInfo
<
ProductResp
>
getList
(
@SpringQueryMap
ProductReq
req
);
@RequestMapping
(
value
=
"/product/getById"
,
method
=
{
RequestMethod
.
GET
})
@RequestMapping
(
value
=
"/product/getById"
,
method
=
{
RequestMethod
.
GET
})
@ResponseBody
@ResponseBody
SmartProductResp
getById
(
@RequestParam
Long
id
);
ProductResp
getById
(
@SpringQueryMap
ProductReq
req
);
@RequestMapping
(
value
=
"/product/save"
,
method
=
{
RequestMethod
.
POST
})
@RequestMapping
(
value
=
"/product/save"
,
method
=
{
RequestMethod
.
POST
})
@ResponseBody
@ResponseBody
void
save
(
@RequestBody
Smart
ProductReq
req
);
Boolean
save
(
@RequestBody
ProductReq
req
);
@RequestMapping
(
"/product/getCommandSetById"
)
@RequestMapping
(
"/product/getCommandSetById"
)
@ResponseBody
@ResponseBody
List
<
SmartDeviceOrderResp
>
getCommandSetById
(
@RequestParam
String
id
);
List
<
DeviceOrderResp
>
getCommandSetById
(
@SpringQueryMap
ProductReq
req
);
@RequestMapping
(
value
=
"/product/checkShopProductId"
,
method
=
{
RequestMethod
.
GET
})
@RequestMapping
(
value
=
"/product/checkShopProductId"
,
method
=
{
RequestMethod
.
GET
})
@ResponseBody
@ResponseBody
Boolean
checkShopProductId
(
@
RequestParam
String
shopProductId
);
Boolean
checkShopProductId
(
@
SpringQueryMap
ProductReq
req
);
@RequestMapping
(
value
=
"/product/putOnOff"
,
method
=
{
RequestMethod
.
POST
})
@RequestMapping
(
value
=
"/product/putOnOff"
,
method
=
{
RequestMethod
.
POST
})
@ResponseBody
@ResponseBody
void
putOnOff
(
@RequestParam
Long
id
);
Boolean
putOnOff
(
@SpringQueryMap
ProductReq
req
);
}
}
src/main/java/com/glsx/admin/remote/ProductTypeFeignClient.java
View file @
55a3ab0
...
@@ -2,14 +2,13 @@ package com.glsx.admin.remote;
...
@@ -2,14 +2,13 @@ package com.glsx.admin.remote;
import
java.util.List
;
import
java.util.List
;
import
com.github.pagehelper.PageInfo
;
import
com.github.pagehelper.PageInfo
;
import
com.glsx.admin.pojo.request.
Smart
ProductTypeReq
;
import
com.glsx.admin.pojo.request.ProductTypeReq
;
import
com.glsx.admin.pojo.response.
Smart
ProductTypeResp
;
import
com.glsx.admin.pojo.response.ProductTypeResp
;
import
org.springframework.cloud.openfeign.FeignClient
;
import
org.springframework.cloud.openfeign.FeignClient
;
import
org.springframework.cloud.openfeign.SpringQueryMap
;
import
org.springframework.cloud.openfeign.SpringQueryMap
;
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.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.bind.annotation.ResponseBody
;
/**
/**
...
@@ -23,15 +22,15 @@ import org.springframework.web.bind.annotation.ResponseBody;
...
@@ -23,15 +22,15 @@ import org.springframework.web.bind.annotation.ResponseBody;
public
interface
ProductTypeFeignClient
{
public
interface
ProductTypeFeignClient
{
@RequestMapping
(
value
=
"/productType/getList"
,
method
=
{
RequestMethod
.
GET
})
@RequestMapping
(
value
=
"/productType/getList"
,
method
=
{
RequestMethod
.
GET
})
@ResponseBody
@ResponseBody
PageInfo
<
SmartProductTypeResp
>
getList
(
@SpringQueryMap
Smart
ProductTypeReq
req
);
PageInfo
<
ProductTypeResp
>
getList
(
@SpringQueryMap
ProductTypeReq
req
);
@RequestMapping
(
value
=
"/productType/getById"
,
method
=
{
RequestMethod
.
GET
})
@RequestMapping
(
value
=
"/productType/getById"
,
method
=
{
RequestMethod
.
GET
})
@ResponseBody
@ResponseBody
SmartProductTypeResp
getById
(
@RequestParam
Long
id
);
ProductTypeResp
getById
(
@SpringQueryMap
ProductTypeReq
req
);
@RequestMapping
(
value
=
"/productType/save"
,
method
=
{
RequestMethod
.
POST
})
@RequestMapping
(
value
=
"/productType/save"
,
method
=
{
RequestMethod
.
POST
})
@ResponseBody
@ResponseBody
void
save
(
@RequestBody
Smart
ProductTypeReq
req
);
Boolean
save
(
@RequestBody
ProductTypeReq
req
);
@RequestMapping
(
value
=
"/productType/getShopTagList"
,
method
=
{
RequestMethod
.
GET
})
@RequestMapping
(
value
=
"/productType/getShopTagList"
,
method
=
{
RequestMethod
.
GET
})
@ResponseBody
@ResponseBody
...
...
src/main/java/com/glsx/admin/remote/impl/IndexHystrix.java
View file @
55a3ab0
package
com
.
glsx
.
admin
.
remote
.
impl
;
package
com
.
glsx
.
admin
.
remote
.
impl
;
import
com.glsx.admin.pojo.request.ProductReq
;
import
com.glsx.admin.remote.IndexFeignClient
;
import
com.glsx.admin.remote.IndexFeignClient
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
...
@@ -22,9 +21,4 @@ public class IndexHystrix implements IndexFeignClient {
...
@@ -22,9 +21,4 @@ public class IndexHystrix implements IndexFeignClient {
log
.
error
(
"请求getHome()异常"
);
log
.
error
(
"请求getHome()异常"
);
return
"服务请求异常"
;
return
"服务请求异常"
;
}
}
@Override
public
String
getProduct
(
ProductReq
product
)
{
return
"服务请求异常"
;
}
}
}
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