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 26438a54
authored
May 11, 2021
by
tyfanchz
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
admin服务代码规范修改
1 parent
e07bf921
Show whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
308 additions
and
375 deletions
pom.xml
src/main/java/com/glsx/admin/SmartAdminApplication.java
src/main/java/com/glsx/admin/config/FeignDecoder.java
src/main/java/com/glsx/admin/config/FeignDecoderForR.java
src/main/java/com/glsx/admin/controller/BaseController.java
src/main/java/com/glsx/admin/controller/OrderValueController.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/controller/SceneTemplateController.java
src/main/java/com/glsx/admin/exception/BusinessException.java
src/main/java/com/glsx/admin/exception/ChejiaBusinessException.java
src/main/java/com/glsx/admin/exception/GlobalExceptionHandler.java
src/main/java/com/glsx/admin/filter/CorsFilter.java
src/main/java/com/glsx/admin/pojo/BaseDTO.java
src/main/java/com/glsx/admin/pojo/GroupA.java
src/main/java/com/glsx/admin/pojo/ValidateGroups.java
src/main/java/com/glsx/admin/pojo/request/DeviceOrderValueReq.java
src/main/java/com/glsx/admin/pojo/request/ProductReq.java
src/main/java/com/glsx/admin/pojo/request/ProductTypeReq.java
src/main/java/com/glsx/admin/pojo/request/SceneTemplateReq.java
src/main/java/com/glsx/admin/pojo/response/ProductResp.java
src/main/java/com/glsx/admin/pojo/response/ProductTypeResp.java
pom.xml
View file @
26438a5
...
@@ -16,6 +16,11 @@
...
@@ -16,6 +16,11 @@
</properties>
</properties>
<dependencies>
<dependencies>
<!-- 运行环境上下文 -->
<dependency>
<groupId>
com.glsx
</groupId>
<artifactId>
rest-admin-context
</artifactId>
</dependency>
<!-- nacos 服务管理和配置中心-->
<!-- nacos 服务管理和配置中心-->
<dependency>
<dependency>
<groupId>
com.glsx
</groupId>
<groupId>
com.glsx
</groupId>
...
...
src/main/java/com/glsx/admin/SmartAdminApplication.java
View file @
26438a5
package
com
.
glsx
.
admin
;
package
com
.
glsx
.
admin
;
import
com.glsx.plat.context.EnableRestAdmin
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.dubbo.config.spring.context.annotation.EnableDubbo
;
import
org.apache.dubbo.config.spring.context.annotation.EnableDubbo
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.SpringApplication
;
...
@@ -18,6 +19,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients;
...
@@ -18,6 +19,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients;
* @Copyright Copyright (c) 2015
* @Copyright Copyright (c) 2015
*/
*/
@Slf4j
@Slf4j
@EnableRestAdmin
@SpringBootApplication
@SpringBootApplication
@EnableDiscoveryClient
@EnableDiscoveryClient
@ServletComponentScan
@ServletComponentScan
...
...
src/main/java/com/glsx/admin/config/FeignDecoder.java
View file @
26438a5
...
@@ -6,7 +6,7 @@ import java.lang.reflect.Type;
...
@@ -6,7 +6,7 @@ import java.lang.reflect.Type;
import
java.nio.charset.StandardCharsets
;
import
java.nio.charset.StandardCharsets
;
import
cn.hutool.core.io.IoUtil
;
import
cn.hutool.core.io.IoUtil
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.glsx.admin.exception.BusinessException
;
import
com.glsx.admin.exception.
Chejia
BusinessException
;
import
com.glsx.admin.exception.ResultEnum
;
import
com.glsx.admin.exception.ResultEnum
;
import
feign.Response
;
import
feign.Response
;
import
feign.codec.Decoder
;
import
feign.codec.Decoder
;
...
@@ -36,10 +36,10 @@ public abstract class FeignDecoder<T> implements Decoder {
...
@@ -36,10 +36,10 @@ public abstract class FeignDecoder<T> implements Decoder {
this
.
handleErrorResponse
(
response
);
this
.
handleErrorResponse
(
response
);
result
=
null
;
result
=
null
;
}
}
}
catch
(
BusinessException
e
)
{
}
catch
(
Chejia
BusinessException
e
)
{
throw
e
;
throw
e
;
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
BusinessException
.
create
(
ResultEnum
.
REMOTE_SERVICE_ERROR
);
throw
Chejia
BusinessException
.
create
(
ResultEnum
.
REMOTE_SERVICE_ERROR
);
}
}
return
result
;
return
result
;
}
}
...
@@ -89,12 +89,12 @@ public abstract class FeignDecoder<T> implements Decoder {
...
@@ -89,12 +89,12 @@ public abstract class FeignDecoder<T> implements Decoder {
private
void
handleErrorResponse
(
Response
response
)
throws
IOException
{
private
void
handleErrorResponse
(
Response
response
)
throws
IOException
{
Response
.
Body
body
=
response
.
body
();
Response
.
Body
body
=
response
.
body
();
if
(
body
==
null
)
{
if
(
body
==
null
)
{
throw
BusinessException
.
create
(
ResultEnum
.
REMOTE_SERVICE_ERROR
);
throw
Chejia
BusinessException
.
create
(
ResultEnum
.
REMOTE_SERVICE_ERROR
);
}
else
{
}
else
{
String
respJson
=
IoUtil
.
read
(
body
.
asReader
(
StandardCharsets
.
UTF_8
));
String
respJson
=
IoUtil
.
read
(
body
.
asReader
(
StandardCharsets
.
UTF_8
));
Type
responseType
=
this
.
getResponseType
();
Type
responseType
=
this
.
getResponseType
();
T
resp
=
JSON
.
parseObject
(
respJson
,
responseType
);
T
resp
=
JSON
.
parseObject
(
respJson
,
responseType
);
throw
BusinessException
.
create
(
this
.
extractCode
(
resp
),
this
.
extractMessage
(
resp
));
throw
Chejia
BusinessException
.
create
(
this
.
extractCode
(
resp
),
this
.
extractMessage
(
resp
));
}
}
}
}
...
...
src/main/java/com/glsx/admin/config/FeignDecoderForR.java
View file @
26438a5
...
@@ -6,7 +6,7 @@ import com.alibaba.fastjson.JSON;
...
@@ -6,7 +6,7 @@ import com.alibaba.fastjson.JSON;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.github.pagehelper.Page
;
import
com.github.pagehelper.Page
;
import
com.github.pagehelper.PageInfo
;
import
com.github.pagehelper.PageInfo
;
import
com.glsx.admin.exception.BusinessException
;
import
com.glsx.admin.exception.
Chejia
BusinessException
;
import
com.glsx.admin.exception.ResultEnum
;
import
com.glsx.admin.exception.ResultEnum
;
import
com.glsx.plat.core.web.R
;
import
com.glsx.plat.core.web.R
;
...
@@ -43,7 +43,7 @@ public class FeignDecoderForR extends FeignDecoder<R> {
...
@@ -43,7 +43,7 @@ public class FeignDecoderForR extends FeignDecoder<R> {
int
code
=
resp
.
getCode
();
int
code
=
resp
.
getCode
();
String
message
=
resp
.
getMessage
();
String
message
=
resp
.
getMessage
();
if
(!
ResultEnum
.
SUCCESS
.
getCode
().
equals
(
code
))
{
if
(!
ResultEnum
.
SUCCESS
.
getCode
().
equals
(
code
))
{
throw
BusinessException
.
create
(
code
,
message
);
throw
Chejia
BusinessException
.
create
(
code
,
message
);
}
}
}
}
...
...
src/main/java/com/glsx/admin/controller/BaseController.java
View file @
26438a5
package
com
.
glsx
.
admin
.
controller
;
package
com
.
glsx
.
admin
.
controller
;
import
com.glsx.admin.exception.BusinessException
;
import
java.util.Collection
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
com.glsx.admin.exception.ChejiaBusinessException
;
import
com.glsx.admin.exception.ResultEnum
;
import
com.glsx.admin.exception.ResultEnum
;
import
com.glsx.plat.common.utils.StringUtils
;
import
com.glsx.plat.common.utils.StringUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.validation.BindingResult
;
import
org.springframework.validation.BindingResult
;
import
org.springframework.validation.FieldError
;
import
org.springframework.validation.FieldError
;
import
java.util.Collection
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
/**
/**
* @author think.wang
* @author think.wang
* @version 1.0.0
* @version 1.0.0
...
@@ -39,7 +38,7 @@ public class BaseController {
...
@@ -39,7 +38,7 @@ public class BaseController {
}
}
/**
/**
* 将请求参数进行校验,校验不成功则抛出 {@link BusinessException} 异常
* 将请求参数进行校验,校验不成功则抛出 {@link
Chejia
BusinessException} 异常
*
*
* @param bindingResult Spring校验结果
* @param bindingResult Spring校验结果
*/
*/
...
@@ -48,7 +47,7 @@ public class BaseController {
...
@@ -48,7 +47,7 @@ public class BaseController {
Map
<
String
,
String
>
errorMap
=
this
.
getErrors
(
bindingResult
);
Map
<
String
,
String
>
errorMap
=
this
.
getErrors
(
bindingResult
);
Collection
<
String
>
values
=
errorMap
.
values
();
Collection
<
String
>
values
=
errorMap
.
values
();
String
errorMsg
=
StringUtils
.
join
(
values
,
";"
);
String
errorMsg
=
StringUtils
.
join
(
values
,
";"
);
throw
BusinessException
.
create
(
ResultEnum
.
PARAM_ERROR
.
getCode
(),
errorMsg
);
throw
Chejia
BusinessException
.
create
(
ResultEnum
.
PARAM_ERROR
.
getCode
(),
errorMsg
);
}
}
}
}
...
...
src/main/java/com/glsx/admin/controller/OrderValueController.java
View file @
26438a5
package
com
.
glsx
.
admin
.
controller
;
package
com
.
glsx
.
admin
.
controller
;
import
javax.validation.groups.Default
;
import
com.glsx.admin.pojo.ValidateGroups
;
import
com.glsx.admin.pojo.request.DeviceOrderValueReq
;
import
com.glsx.admin.pojo.request.DeviceOrderValueReq
;
import
com.glsx.admin.remote.OrderValueFeignClient
;
import
com.glsx.admin.remote.OrderValueFeignClient
;
import
com.glsx.plat.core.web.R
;
import
com.glsx.plat.core.web.R
;
...
@@ -31,7 +31,7 @@ public class OrderValueController extends BaseController{
...
@@ -31,7 +31,7 @@ public class OrderValueController extends BaseController{
@ResponseBody
@ResponseBody
@RequestMapping
(
value
=
"/getList"
,
method
=
{
RequestMethod
.
POST
})
@RequestMapping
(
value
=
"/getList"
,
method
=
{
RequestMethod
.
POST
})
public
R
getList
(
@Validated
(
value
=
{
Default
.
class
}
)
DeviceOrderValueReq
req
,
public
R
getList
(
@Validated
(
ValidateGroups
.
Query
.
class
)
DeviceOrderValueReq
req
,
BindingResult
result
){
BindingResult
result
){
this
.
checkRequestParam
(
result
);
this
.
checkRequestParam
(
result
);
return
R
.
ok
().
data
(
valueFeignClient
.
getList
(
req
));
return
R
.
ok
().
data
(
valueFeignClient
.
getList
(
req
));
...
...
src/main/java/com/glsx/admin/controller/ProductController.java
View file @
26438a5
package
com
.
glsx
.
admin
.
controller
;
package
com
.
glsx
.
admin
.
controller
;
import
java.util.List
;
import
cn.com.glsx.framework.core.beans.rpc.RpcResponse
;
import
cn.com.glsx.framework.core.beans.rpc.RpcResponse
;
import
cn.com.glsx.platform.shopmall.dto.CreateMallGoodsRequestDTO
;
import
cn.com.glsx.platform.shopmall.dto.CreateMallGoodsRequestDTO
;
import
cn.com.glsx.platform.shopmall.remote.ShopMallGoodsRemote
;
import
cn.com.glsx.platform.shopmall.remote.ShopMallGoodsRemote
;
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.
Chejia
BusinessException
;
import
com.glsx.admin.exception.ResultEnum
;
import
com.glsx.admin.exception.ResultEnum
;
import
com.glsx.admin.pojo.
GroupA
;
import
com.glsx.admin.pojo.
ValidateGroups
;
import
com.glsx.admin.pojo.request.ProductReq
;
import
com.glsx.admin.pojo.request.ProductReq
;
import
com.glsx.admin.pojo.response.DeviceOrderResp
;
import
com.glsx.admin.pojo.response.DeviceOrderResp
;
import
com.glsx.admin.pojo.response.ProductResp
;
import
com.glsx.admin.pojo.response.ProductResp
;
...
@@ -23,9 +24,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
...
@@ -23,9 +24,6 @@ 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.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.validation.groups.Default
;
import
java.util.List
;
/**
/**
* <p>Description: 产品列表业务
* <p>Description: 产品列表业务
* <p>Project: chejia-smart
* <p>Project: chejia-smart
...
@@ -53,7 +51,8 @@ public class ProductController {
...
@@ -53,7 +51,8 @@ public class ProductController {
public
R
getPageList
(
ProductReq
req
)
{
public
R
getPageList
(
ProductReq
req
)
{
log
.
info
(
"$$$$ /product/getPageList param: {}"
,
JSON
.
toJSONString
(
req
));
log
.
info
(
"$$$$ /product/getPageList param: {}"
,
JSON
.
toJSONString
(
req
));
PageInfo
<
ProductResp
>
pageInfo
=
productFeignClient
.
getPageList
(
req
);
PageInfo
<
ProductResp
>
pageInfo
=
productFeignClient
.
getPageList
(
req
);
return
R
.
ok
().
putPageData
(
pageInfo
);
//return R.ok().putPageData(pageInfo);
throw
ChejiaBusinessException
.
create
(
ResultEnum
.
PARAM_ERROR
);
}
}
/**
/**
...
@@ -76,7 +75,7 @@ public class ProductController {
...
@@ -76,7 +75,7 @@ public class ProductController {
* @return 结果
* @return 结果
*/
*/
@RequestMapping
(
value
=
"/getById"
,
method
=
{
RequestMethod
.
GET
,
RequestMethod
.
POST
})
@RequestMapping
(
value
=
"/getById"
,
method
=
{
RequestMethod
.
GET
,
RequestMethod
.
POST
})
public
R
getById
(
@Validated
({
Default
.
class
})
ProductReq
req
)
{
public
R
getById
(
@Validated
({
ValidateGroups
.
Query
.
class
})
ProductReq
req
)
{
log
.
info
(
"$$$$ /product/getById param: {}"
,
JSON
.
toJSONString
(
req
));
log
.
info
(
"$$$$ /product/getById param: {}"
,
JSON
.
toJSONString
(
req
));
ProductResp
resp
=
productFeignClient
.
getById
(
req
);
ProductResp
resp
=
productFeignClient
.
getById
(
req
);
return
R
.
ok
().
data
(
resp
);
return
R
.
ok
().
data
(
resp
);
...
@@ -89,7 +88,7 @@ public class ProductController {
...
@@ -89,7 +88,7 @@ public class ProductController {
* @return 结果
* @return 结果
*/
*/
@RequestMapping
(
value
=
"/save"
,
method
=
{
RequestMethod
.
POST
})
@RequestMapping
(
value
=
"/save"
,
method
=
{
RequestMethod
.
POST
})
public
R
save
(
@RequestBody
@Validated
({
GroupA
.
class
})
ProductReq
req
)
{
public
R
save
(
@RequestBody
@Validated
({
ValidateGroups
.
Insert
.
class
})
ProductReq
req
)
{
log
.
info
(
"$$$$ /product/save param: {}"
,
JSON
.
toJSONString
(
req
));
log
.
info
(
"$$$$ /product/save param: {}"
,
JSON
.
toJSONString
(
req
));
Boolean
success
=
productFeignClient
.
save
(
req
);
Boolean
success
=
productFeignClient
.
save
(
req
);
return
R
.
ok
().
data
(
success
);
return
R
.
ok
().
data
(
success
);
...
@@ -102,7 +101,7 @@ public class ProductController {
...
@@ -102,7 +101,7 @@ public class ProductController {
* @return 结果
* @return 结果
*/
*/
@RequestMapping
(
value
=
"/getCommandSetById"
,
method
=
{
RequestMethod
.
GET
,
RequestMethod
.
POST
})
@RequestMapping
(
value
=
"/getCommandSetById"
,
method
=
{
RequestMethod
.
GET
,
RequestMethod
.
POST
})
public
R
getCommandSetById
(
@Validated
({
Default
.
class
})
ProductReq
req
)
{
public
R
getCommandSetById
(
@Validated
({
ValidateGroups
.
Query
.
class
})
ProductReq
req
)
{
log
.
info
(
"$$$$ /product/getCommandSetById param: {}"
,
JSON
.
toJSONString
(
req
));
log
.
info
(
"$$$$ /product/getCommandSetById param: {}"
,
JSON
.
toJSONString
(
req
));
List
<
DeviceOrderResp
>
respList
=
productFeignClient
.
getCommandSetById
(
req
);
List
<
DeviceOrderResp
>
respList
=
productFeignClient
.
getCommandSetById
(
req
);
return
R
.
ok
().
data
(
respList
);
return
R
.
ok
().
data
(
respList
);
...
@@ -118,7 +117,7 @@ public class ProductController {
...
@@ -118,7 +117,7 @@ public class ProductController {
public
R
checkShopProductId
(
ProductReq
req
)
{
public
R
checkShopProductId
(
ProductReq
req
)
{
log
.
info
(
"$$$$ /product/checkShopProductId param: {}"
,
JSON
.
toJSONString
(
req
));
log
.
info
(
"$$$$ /product/checkShopProductId param: {}"
,
JSON
.
toJSONString
(
req
));
if
(
StringUtils
.
isBlank
(
req
.
getShopProductId
()))
{
if
(
StringUtils
.
isBlank
(
req
.
getShopProductId
()))
{
throw
new
BusinessException
(
ResultEnum
.
PARAM_ERROR
);
throw
ChejiaBusinessException
.
create
(
ResultEnum
.
PARAM_ERROR
);
}
}
RpcResponse
<
CreateMallGoodsRequestDTO
>
rpcResponse
=
shopMallGoodsRemote
RpcResponse
<
CreateMallGoodsRequestDTO
>
rpcResponse
=
shopMallGoodsRemote
.
selectOneById
(
Integer
.
valueOf
(
req
.
getShopProductId
()),
false
);
.
selectOneById
(
Integer
.
valueOf
(
req
.
getShopProductId
()),
false
);
...
@@ -135,7 +134,7 @@ public class ProductController {
...
@@ -135,7 +134,7 @@ public class ProductController {
* @return 结果
* @return 结果
*/
*/
@RequestMapping
(
value
=
"/putOnOff"
,
method
=
{
RequestMethod
.
GET
,
RequestMethod
.
POST
})
@RequestMapping
(
value
=
"/putOnOff"
,
method
=
{
RequestMethod
.
GET
,
RequestMethod
.
POST
})
public
R
putOnOff
(
@Validated
({
Default
.
class
})
ProductReq
req
)
{
public
R
putOnOff
(
@Validated
({
ValidateGroups
.
Query
.
class
})
ProductReq
req
)
{
log
.
info
(
"$$$$ /product/putOnOff param: {}"
,
JSON
.
toJSONString
(
req
));
log
.
info
(
"$$$$ /product/putOnOff param: {}"
,
JSON
.
toJSONString
(
req
));
Boolean
success
=
productFeignClient
.
putOnOff
(
req
);
Boolean
success
=
productFeignClient
.
putOnOff
(
req
);
return
R
.
ok
().
data
(
success
);
return
R
.
ok
().
data
(
success
);
...
...
src/main/java/com/glsx/admin/controller/ProductTypeController.java
View file @
26438a5
package
com
.
glsx
.
admin
.
controller
;
package
com
.
glsx
.
admin
.
controller
;
import
java.util.ArrayList
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Set
;
import
cn.com.glsx.framework.core.beans.rpc.RpcResponse
;
import
cn.com.glsx.framework.core.beans.rpc.RpcResponse
;
import
cn.com.glsx.platform.shopmall.model.PlatformMallGoodLabel
;
import
cn.com.glsx.platform.shopmall.model.PlatformMallGoodLabel
;
import
cn.com.glsx.platform.shopmall.remote.ShopMallLGoodLabelRemote
;
import
cn.com.glsx.platform.shopmall.remote.ShopMallLGoodLabelRemote
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.github.pagehelper.PageInfo
;
import
com.github.pagehelper.PageInfo
;
import
com.glsx.admin.pojo.
GroupA
;
import
com.glsx.admin.pojo.
ValidateGroups
;
import
com.glsx.admin.pojo.request.DeviceOrderReq
;
import
com.glsx.admin.pojo.request.DeviceOrderReq
;
import
com.glsx.admin.pojo.request.ProductTypeReq
;
import
com.glsx.admin.pojo.request.ProductTypeReq
;
import
com.glsx.admin.pojo.request.ScenceSupstatusReq
;
import
com.glsx.admin.pojo.request.ScenceSupstatusReq
;
...
@@ -25,12 +29,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
...
@@ -25,12 +29,6 @@ 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.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.validation.groups.Default
;
import
java.util.ArrayList
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Set
;
/**
/**
* <p>Description:
* <p>Description:
* <p>Project: chejia-smart
* <p>Project: chejia-smart
...
@@ -88,7 +86,7 @@ public class ProductTypeController {
...
@@ -88,7 +86,7 @@ public class ProductTypeController {
* @return 结果
* @return 结果
*/
*/
@RequestMapping
(
value
=
"/getById"
,
method
=
{
RequestMethod
.
GET
,
RequestMethod
.
POST
})
@RequestMapping
(
value
=
"/getById"
,
method
=
{
RequestMethod
.
GET
,
RequestMethod
.
POST
})
public
R
getById
(
@Validated
(
{
Default
.
class
}
)
ProductTypeReq
req
)
{
public
R
getById
(
@Validated
(
ValidateGroups
.
Query
.
class
)
ProductTypeReq
req
)
{
log
.
info
(
"$$$$ /productType/getById param: {}"
,
JSON
.
toJSONString
(
req
));
log
.
info
(
"$$$$ /productType/getById param: {}"
,
JSON
.
toJSONString
(
req
));
ProductTypeResp
resp
=
productTypeFeignClient
.
getById
(
req
);
ProductTypeResp
resp
=
productTypeFeignClient
.
getById
(
req
);
return
R
.
ok
().
data
(
resp
);
return
R
.
ok
().
data
(
resp
);
...
@@ -101,7 +99,7 @@ public class ProductTypeController {
...
@@ -101,7 +99,7 @@ public class ProductTypeController {
* @return 结果
* @return 结果
*/
*/
@RequestMapping
(
value
=
"/save"
,
method
=
{
RequestMethod
.
POST
})
@RequestMapping
(
value
=
"/save"
,
method
=
{
RequestMethod
.
POST
})
public
R
save
(
@RequestBody
@Validated
(
{
GroupA
.
class
}
)
ProductTypeReq
req
)
{
public
R
save
(
@RequestBody
@Validated
(
ValidateGroups
.
Insert
.
class
)
ProductTypeReq
req
)
{
log
.
info
(
"$$$$ /productType/save param: {}"
,
JSON
.
toJSONString
(
req
));
log
.
info
(
"$$$$ /productType/save param: {}"
,
JSON
.
toJSONString
(
req
));
Boolean
success
=
productTypeFeignClient
.
save
(
req
);
Boolean
success
=
productTypeFeignClient
.
save
(
req
);
return
R
.
ok
().
data
(
success
);
return
R
.
ok
().
data
(
success
);
...
...
src/main/java/com/glsx/admin/controller/SceneTemplateController.java
View file @
26438a5
package
com
.
glsx
.
admin
.
controller
;
package
com
.
glsx
.
admin
.
controller
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.stream.Collectors
;
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.
Chejia
BusinessException
;
import
com.glsx.admin.exception.ResultEnum
;
import
com.glsx.admin.exception.ResultEnum
;
import
com.glsx.admin.pojo.
GroupA
;
import
com.glsx.admin.pojo.
ValidateGroups
;
import
com.glsx.admin.pojo.request.SceneTemplateReq
;
import
com.glsx.admin.pojo.request.SceneTemplateReq
;
import
com.glsx.admin.pojo.response.SceneTemplateResp
;
import
com.glsx.admin.pojo.response.SceneTemplateResp
;
import
com.glsx.admin.remote.SceneTemplateFeignClient
;
import
com.glsx.admin.remote.SceneTemplateFeignClient
;
...
@@ -24,11 +27,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
...
@@ -24,11 +27,6 @@ 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.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.validation.groups.Default
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.stream.Collectors
;
/**
/**
* <p>Description:
* <p>Description:
* <p>Project: chejia-smart
* <p>Project: chejia-smart
...
@@ -78,7 +76,7 @@ public class SceneTemplateController extends BaseController {
...
@@ -78,7 +76,7 @@ public class SceneTemplateController extends BaseController {
}
}
@RequestMapping
(
value
=
"/getById"
,
method
=
{
RequestMethod
.
GET
,
RequestMethod
.
POST
})
@RequestMapping
(
value
=
"/getById"
,
method
=
{
RequestMethod
.
GET
,
RequestMethod
.
POST
})
public
R
getById
(
@RequestBody
@Validated
(
value
=
Default
.
class
)
SceneTemplateReq
sceneTemplate
,
public
R
getById
(
@RequestBody
@Validated
(
ValidateGroups
.
Query
.
class
)
SceneTemplateReq
sceneTemplate
,
BindingResult
result
)
{
BindingResult
result
)
{
this
.
checkRequestParam
(
result
);
this
.
checkRequestParam
(
result
);
Long
id
=
sceneTemplate
.
getId
();
Long
id
=
sceneTemplate
.
getId
();
...
@@ -88,7 +86,7 @@ public class SceneTemplateController extends BaseController {
...
@@ -88,7 +86,7 @@ public class SceneTemplateController extends BaseController {
@RequestMapping
(
value
=
"/save"
,
method
=
{
RequestMethod
.
POST
})
@RequestMapping
(
value
=
"/save"
,
method
=
{
RequestMethod
.
POST
})
public
R
save
(
@RequestBody
@Validated
(
value
=
GroupA
.
class
)
SceneTemplateReq
sceneTemplate
,
BindingResult
result
)
{
public
R
save
(
@RequestBody
@Validated
(
ValidateGroups
.
Insert
.
class
)
SceneTemplateReq
sceneTemplate
,
BindingResult
result
)
{
log
.
info
(
"新增调用/sceneTemplate/save param: {}"
,
JSON
.
toJSONString
(
sceneTemplate
));
log
.
info
(
"新增调用/sceneTemplate/save param: {}"
,
JSON
.
toJSONString
(
sceneTemplate
));
this
.
checkRequestParam
(
result
);
this
.
checkRequestParam
(
result
);
Long
id
=
sceneTemplate
.
getId
();
Long
id
=
sceneTemplate
.
getId
();
...
@@ -98,14 +96,14 @@ public class SceneTemplateController extends BaseController {
...
@@ -98,14 +96,14 @@ public class SceneTemplateController extends BaseController {
List
<
SceneTemplateResp
>
list
=
templateFeignClient
.
getList
(
sameRequest
);
List
<
SceneTemplateResp
>
list
=
templateFeignClient
.
getList
(
sameRequest
);
if
(
id
==
null
||
id
<=
0
)
{
//新增
if
(
id
==
null
||
id
<=
0
)
{
//新增
if
(!
list
.
isEmpty
())
{
if
(!
list
.
isEmpty
())
{
throw
new
BusinessException
(
ResultEnum
.
SAME_NAME_ERROR
);
throw
ChejiaBusinessException
.
create
(
ResultEnum
.
SAME_NAME_ERROR
);
}
}
sceneTemplate
.
setCreateTime
(
now
);
sceneTemplate
.
setCreateTime
(
now
);
sceneTemplate
.
setCreateBy
(-
1L
);
sceneTemplate
.
setCreateBy
(-
1L
);
return
R
.
ok
().
data
(
templateFeignClient
.
add
(
sceneTemplate
));
return
R
.
ok
().
data
(
templateFeignClient
.
add
(
sceneTemplate
));
}
else
{
}
else
{
if
(!
list
.
isEmpty
()
&&
list
.
get
(
0
).
getId
()
!=
id
)
{
if
(!
list
.
isEmpty
()
&&
list
.
get
(
0
).
getId
()
!=
id
)
{
throw
new
BusinessException
(
ResultEnum
.
SAME_NAME_ERROR
);
throw
ChejiaBusinessException
.
create
(
ResultEnum
.
SAME_NAME_ERROR
);
}
}
sceneTemplate
.
setUpdateTime
(
now
);
sceneTemplate
.
setUpdateTime
(
now
);
sceneTemplate
.
setUpdateBy
(-
1L
);
sceneTemplate
.
setUpdateBy
(-
1L
);
...
@@ -114,7 +112,7 @@ public class SceneTemplateController extends BaseController {
...
@@ -114,7 +112,7 @@ public class SceneTemplateController extends BaseController {
}
}
@RequestMapping
(
value
=
"/updateStatus"
,
method
=
{
RequestMethod
.
POST
})
@RequestMapping
(
value
=
"/updateStatus"
,
method
=
{
RequestMethod
.
POST
})
public
R
update
(
@RequestBody
@Validated
(
value
=
Default
.
class
)
SceneTemplateReq
sceneTemplate
,
BindingResult
result
)
{
public
R
update
(
@RequestBody
@Validated
(
ValidateGroups
.
Query
.
class
)
SceneTemplateReq
sceneTemplate
,
BindingResult
result
)
{
this
.
checkRequestParam
(
result
);
this
.
checkRequestParam
(
result
);
log
.
info
(
"更新调用/sceneTemplate/updateStatus param: {}"
,
JSON
.
toJSONString
(
sceneTemplate
));
log
.
info
(
"更新调用/sceneTemplate/updateStatus param: {}"
,
JSON
.
toJSONString
(
sceneTemplate
));
Date
now
=
new
Date
();
Date
now
=
new
Date
();
...
...
src/main/java/com/glsx/admin/exception/BusinessException.java
deleted
100644 → 0
View file @
e07bf92
package
com
.
glsx
.
admin
.
exception
;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-16
*/
public
class
BusinessException
extends
RuntimeException
{
private
Integer
code
;
private
String
message
;
public
BusinessException
()
{}
public
BusinessException
(
ResultEnum
resultEnum
)
{
this
.
code
=
resultEnum
.
getCode
();
this
.
message
=
resultEnum
.
getMessage
();
}
public
Integer
getCode
()
{
return
code
;
}
public
void
setCode
(
Integer
code
)
{
this
.
code
=
code
;
}
@Override
public
String
getMessage
()
{
return
message
;
}
public
void
setMessage
(
String
message
)
{
this
.
message
=
message
;
}
public
static
BusinessException
create
(
int
code
,
String
message
){
BusinessException
businessException
=
new
BusinessException
();
businessException
.
code
=
code
;
businessException
.
message
=
message
;
return
businessException
;
}
public
static
BusinessException
create
(
ResultEnum
resultEnum
)
{
return
create
(
resultEnum
.
getCode
(),
resultEnum
.
getMessage
());
}
}
src/main/java/com/glsx/admin/exception/ChejiaBusinessException.java
0 → 100644
View file @
26438a5
package
com
.
glsx
.
admin
.
exception
;
import
com.glsx.plat.exception.BusinessException
;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-16
*/
public
class
ChejiaBusinessException
extends
BusinessException
{
private
ChejiaBusinessException
(
int
code
,
String
message
)
{
super
(
BusinessException
.
create
(
code
,
message
));
}
public
static
ChejiaBusinessException
create
(
int
code
,
String
message
){
return
new
ChejiaBusinessException
(
code
,
message
);
}
public
static
ChejiaBusinessException
create
(
ResultEnum
resultEnum
,
Object
...
args
)
{
String
message
=
String
.
format
(
resultEnum
.
getMessage
(),
args
);
return
create
(
resultEnum
.
getCode
(),
message
);
}
}
src/main/java/com/glsx/admin/exception/GlobalExceptionHandler.java
View file @
26438a5
package
com
.
glsx
.
admin
.
exception
;
//
package com.glsx.admin.exception;
//
import
java.util.List
;
//
import java.util.List;
import
java.util.concurrent.TimeoutException
;
//
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;
import
com.glsx.plat.core.web.R
;
//
import com.glsx.plat.core.web.R;
import
com.netflix.hystrix.exception.HystrixRuntimeException
;
//
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.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;
import
org.springframework.web.bind.annotation.RestControllerAdvice
;
//
import org.springframework.web.bind.annotation.RestControllerAdvice;
//
/**
/
//
**
* <p>Description:
//
* <p>Description:
* <p>Project: chejia-smart
//
* <p>Project: chejia-smart
*
//
*
* @author wbh
//
* @author wbh
* @date 2021-03-16
//
* @date 2021-03-16
*/
//
*/
@Slf4j
//
@Slf4j
@RestControllerAdvice
//
@RestControllerAdvice
public
class
GlobalExceptionHandler
{
//
public class GlobalExceptionHandler {
@ExceptionHandler
({
BusinessException
.
class
})
// @ExceptionHandler({Chejia
BusinessException.class})
public
R
handleBusinessException
(
BusinessException
e
)
{
// public R handleBusinessException(Chejia
BusinessException e) {
log
.
error
(
"!!!! 业务异常"
,
e
);
//
log.error("!!!! 业务异常", e);
return
R
.
error
(
e
.
getCode
(),
e
.
getMessage
());
//
return R.error(e.getCode(), e.getMessage());
}
//
}
//
@ExceptionHandler
({
ServletRequestBindingException
.
class
,
MethodArgumentNotValidException
.
class
,
//
@ExceptionHandler({ServletRequestBindingException.class, MethodArgumentNotValidException.class,
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
))
{
//
if ((e instanceof MethodArgumentNotValidException) || (e instanceof BindException)) {
List
<
FieldError
>
errorList
;
//
List<FieldError> errorList;
if
(
e
instanceof
MethodArgumentNotValidException
)
{
//
if (e instanceof MethodArgumentNotValidException) {
MethodArgumentNotValidException
ex
=
(
MethodArgumentNotValidException
)
e
;
//
MethodArgumentNotValidException ex = (MethodArgumentNotValidException) e;
errorList
=
ex
.
getBindingResult
().
getFieldErrors
();
//
errorList = ex.getBindingResult().getFieldErrors();
}
else
{
//
} else {
BindException
ex
=
(
BindException
)
e
;
//
BindException ex = (BindException) e;
errorList
=
ex
.
getFieldErrors
();
//
errorList = ex.getFieldErrors();
}
//
}
StringBuffer
messageSb
=
new
StringBuffer
();
//
StringBuffer messageSb = new StringBuffer();
for
(
FieldError
error
:
errorList
)
{
//
for (FieldError error : errorList) {
String
fieldMessage
=
String
.
format
(
"%s: %s, "
,
//
String fieldMessage = String.format("%s: %s, ",
error
.
getField
(),
error
.
getDefaultMessage
());
//
error.getField(), error.getDefaultMessage());
messageSb
.
append
(
fieldMessage
);
//
messageSb.append(fieldMessage);
}
//
}
return
R
.
error
(
ResultEnum
.
PARAM_ERROR
.
getCode
(),
//
return R.error(ResultEnum.PARAM_ERROR.getCode(),
messageSb
.
toString
().
replaceAll
(
", +$"
,
""
));
//
messageSb.toString().replaceAll(", +$", ""));
}
else
{
//
} 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) {
Throwable
cause
=
e
.
getCause
();
//
Throwable cause = e.getCause();
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
)
{
//
} else if (cause instanceof TimeoutException) {
log
.
error
(
"!!!! 服务调用超时"
,
e
);
//
log.error("!!!! 服务调用超时", e);
return
R
.
error
(
ResultEnum
.
REMOTE_SERVER_TIME_OUT
.
getCode
(),
//
return R.error(ResultEnum.REMOTE_SERVER_TIME_OUT.getCode(),
ResultEnum
.
REMOTE_SERVER_TIME_OUT
.
getMessage
());
//
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());
}
//
}
}
//
}
//
@ExceptionHandler
({
FeignException
.
class
})
//
@ExceptionHandler({FeignException.class})
public
R
handleFeignException
(
FeignException
e
)
{
//
public R handleFeignException(FeignException e) {
log
.
error
(
"!!!! 远程服务错误"
,
e
);
//
log.error("!!!! 远程服务错误", e);
String
respMessage
;
//
String respMessage;
if
(
StringUtils
.
isNotBlank
(
e
.
contentUTF8
()))
{
//
if (StringUtils.isNotBlank(e.contentUTF8())) {
JSONObject
respObj
=
JSON
.
parseObject
(
e
.
contentUTF8
());
//
JSONObject respObj = JSON.parseObject(e.contentUTF8());
respMessage
=
respObj
.
getString
(
"message"
);
//
respMessage = respObj.getString("message");
}
else
{
//
} else {
respMessage
=
""
;
//
respMessage = "";
}
//
}
int
code
=
ResultEnum
.
REMOTE_SERVICE_ERROR
.
getCode
();
//
int code = ResultEnum.REMOTE_SERVICE_ERROR.getCode();
String
message
=
StringUtils
.
isBlank
(
respMessage
)
//
String message = StringUtils.isBlank(respMessage)
?
ResultEnum
.
REMOTE_SERVICE_ERROR
.
getMessage
()
:
respMessage
;
//
? ResultEnum.REMOTE_SERVICE_ERROR.getMessage() : respMessage;
return
R
.
error
(
code
,
message
);
//
return R.error(code, message);
}
//
}
//
@ExceptionHandler
(
Exception
.
class
)
//
@ExceptionHandler(Exception.class)
public
R
handleException
(
Exception
e
)
{
//
public R handleException(Exception e) {
log
.
error
(
"!!!! 未知异常"
,
e
);
//
log.error("!!!! 未知异常", 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/filter/CorsFilter.java
View file @
26438a5
package
com
.
glsx
.
admin
.
filter
;
//
package com.glsx.admin.filter;
//
import
javax.servlet.Filter
;
//
import javax.servlet.Filter;
import
javax.servlet.FilterChain
;
//
import javax.servlet.FilterChain;
import
javax.servlet.ServletException
;
//
import javax.servlet.ServletException;
import
javax.servlet.ServletRequest
;
//
import javax.servlet.ServletRequest;
import
javax.servlet.ServletResponse
;
//
import javax.servlet.ServletResponse;
import
javax.servlet.http.HttpServletRequest
;
//
import javax.servlet.http.HttpServletRequest;
import
javax.servlet.http.HttpServletResponse
;
//
import javax.servlet.http.HttpServletResponse;
import
java.io.IOException
;
//
import java.io.IOException;
import
java.util.Enumeration
;
//
import java.util.Enumeration;
import
com.glsx.plat.common.utils.StringUtils
;
//
import com.glsx.plat.common.utils.StringUtils;
import
org.springframework.http.HttpHeaders
;
//
import org.springframework.http.HttpHeaders;
import
org.springframework.http.HttpMethod
;
//
import org.springframework.http.HttpMethod;
import
org.springframework.stereotype.Component
;
//
import org.springframework.stereotype.Component;
//
/**
/
//
**
* <p>Description: 跨域配置
//
* <p>Description: 跨域配置
* <p>Project: chejia-smart
//
* <p>Project: chejia-smart
*
//
*
* @author wbh
//
* @author wbh
* @date 2021-03-18
//
* @date 2021-03-18
*/
//
*/
@Component
//
@Component
public
class
CorsFilter
implements
Filter
{
//
public class CorsFilter implements Filter {
@Override
//
@Override
public
void
doFilter
(
ServletRequest
request
,
ServletResponse
response
,
FilterChain
chain
)
//
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws
IOException
,
ServletException
{
//
throws IOException, ServletException {
HttpServletRequest
httpRequest
=
(
HttpServletRequest
)
request
;
//
HttpServletRequest httpRequest = (HttpServletRequest) request;
HttpServletResponse
httpResponse
=
(
HttpServletResponse
)
response
;
//
HttpServletResponse httpResponse = (HttpServletResponse) response;
//
StringBuffer
headersSb
=
new
StringBuffer
();
//
StringBuffer headersSb = new StringBuffer();
Enumeration
<
String
>
headerNames
=
httpRequest
.
getHeaderNames
();
//
Enumeration<String> headerNames = httpRequest.getHeaderNames();
while
(
headerNames
.
hasMoreElements
())
{
//
while (headerNames.hasMoreElements()) {
headersSb
.
append
(
headerNames
.
nextElement
()).
append
(
", "
);
//
headersSb.append(headerNames.nextElement()).append(", ");
}
//
}
if
(!
StringUtils
.
containsIgnoreCase
(
headersSb
,
HttpHeaders
.
CONTENT_TYPE
))
{
//
if (!StringUtils.containsIgnoreCase(headersSb, HttpHeaders.CONTENT_TYPE)) {
headersSb
.
append
(
HttpHeaders
.
CONTENT_TYPE
).
append
(
", "
);
//
headersSb.append(HttpHeaders.CONTENT_TYPE).append(", ");
}
//
}
if
(!
StringUtils
.
containsIgnoreCase
(
headersSb
,
HttpHeaders
.
AUTHORIZATION
))
{
//
if (!StringUtils.containsIgnoreCase(headersSb, HttpHeaders.AUTHORIZATION)) {
headersSb
.
append
(
HttpHeaders
.
AUTHORIZATION
).
append
(
", "
);
//
headersSb.append(HttpHeaders.AUTHORIZATION).append(", ");
}
//
}
httpResponse
.
addHeader
(
HttpHeaders
.
ACCESS_CONTROL_ALLOW_HEADERS
,
//
httpResponse.addHeader(HttpHeaders.ACCESS_CONTROL_ALLOW_HEADERS,
headersSb
.
toString
().
replaceAll
(
", +$"
,
""
));
//
headersSb.toString().replaceAll(", +$", ""));
//
httpResponse
.
addHeader
(
HttpHeaders
.
ACCESS_CONTROL_ALLOW_CREDENTIALS
,
"true"
);
//
httpResponse.addHeader(HttpHeaders.ACCESS_CONTROL_ALLOW_CREDENTIALS, "true");
httpResponse
.
addHeader
(
HttpHeaders
.
ACCESS_CONTROL_ALLOW_ORIGIN
,
//
httpResponse.addHeader(HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN,
httpRequest
.
getHeader
(
HttpHeaders
.
ORIGIN
));
//
httpRequest.getHeader(HttpHeaders.ORIGIN));
httpResponse
.
addHeader
(
HttpHeaders
.
ACCESS_CONTROL_ALLOW_METHODS
,
//
httpResponse.addHeader(HttpHeaders.ACCESS_CONTROL_ALLOW_METHODS,
httpRequest
.
getMethod
());
//
httpRequest.getMethod());
httpResponse
.
addHeader
(
HttpHeaders
.
ACCESS_CONTROL_EXPOSE_HEADERS
,
"*"
);
//
httpResponse.addHeader(HttpHeaders.ACCESS_CONTROL_EXPOSE_HEADERS, "*");
httpResponse
.
addHeader
(
HttpHeaders
.
ACCESS_CONTROL_MAX_AGE
,
"18000L"
);
//
httpResponse.addHeader(HttpHeaders.ACCESS_CONTROL_MAX_AGE, "18000L");
//
// 放行预检请求(preflight requests)
//
// 放行预检请求(preflight requests)
if
(
httpRequest
.
getMethod
().
equalsIgnoreCase
(
HttpMethod
.
OPTIONS
.
toString
()))
{
//
if (httpRequest.getMethod().equalsIgnoreCase(HttpMethod.OPTIONS.toString())) {
httpResponse
.
setStatus
(
HttpServletResponse
.
SC_OK
);
//
httpResponse.setStatus(HttpServletResponse.SC_OK);
httpResponse
.
getWriter
().
println
(
"OK"
);
//
httpResponse.getWriter().println("OK");
return
;
//
return;
}
//
}
//
chain
.
doFilter
(
request
,
response
);
//
chain.doFilter(request, response);
}
//
}
}
//
}
src/main/java/com/glsx/admin/pojo/BaseDTO.java
View file @
26438a5
package
com
.
glsx
.
admin
.
pojo
;
package
com
.
glsx
.
admin
.
pojo
;
import
java.io.Serializable
;
import
lombok.Data
;
/**
/**
* @author think.wang
* @author think.wang
* @version 1.0.0
* @version 1.0.0
...
@@ -8,7 +11,8 @@ package com.glsx.admin.pojo;
...
@@ -8,7 +11,8 @@ package com.glsx.admin.pojo;
* @Description 公共参数DTO
* @Description 公共参数DTO
* @date 2020/9/4
* @date 2020/9/4
*/
*/
public
class
BaseDTO
{
@Data
public
class
BaseDTO
implements
Serializable
{
/**
/**
* 第几页
* 第几页
...
@@ -20,72 +24,23 @@ public class BaseDTO {
...
@@ -20,72 +24,23 @@ public class BaseDTO {
*/
*/
private
int
pageSize
;
private
int
pageSize
;
/**
///**
* 搜索key
// * 搜索key
*/
// */
private
String
searchKey
;
//private String searchKey;
//
/**
///**
* 排序
// * 排序
*/
// */
private
String
orderBy
;
//private String orderBy;
//
/**
///**
* 查询条件开始时间
// * 查询条件开始时间
*/
// */
private
String
startTime
;
//private String startTime;
//
/**
///**
* 查询条件结束时间
// * 查询条件结束时间
*/
// */
private
String
endTime
;
//private String endTime;
public
int
getPageIndex
()
{
return
pageIndex
;
}
public
void
setPageIndex
(
int
pageIndex
)
{
this
.
pageIndex
=
pageIndex
;
}
public
int
getPageSize
()
{
return
pageSize
;
}
public
void
setPageSize
(
int
pageSize
)
{
this
.
pageSize
=
pageSize
;
}
public
String
getSearchKey
()
{
return
searchKey
;
}
public
void
setSearchKey
(
String
searchKey
)
{
this
.
searchKey
=
searchKey
;
}
public
String
getOrderBy
()
{
return
orderBy
;
}
public
void
setOrderBy
(
String
orderBy
)
{
this
.
orderBy
=
orderBy
;
}
public
String
getStartTime
()
{
return
startTime
;
}
public
void
setStartTime
(
String
startTime
)
{
this
.
startTime
=
startTime
;
}
public
String
getEndTime
()
{
return
endTime
;
}
public
void
setEndTime
(
String
endTime
)
{
this
.
endTime
=
endTime
;
}
}
}
src/main/java/com/glsx/admin/pojo/GroupA.java
deleted
100644 → 0
View file @
e07bf92
package
com
.
glsx
.
admin
.
pojo
;
/**
* @author think.wang
* @version 1.0.0
* @Title GroupA
* @Package com.glsx.admin.pojo
* @Description Hibernate-validator的分组
* @date 2021/3/8
*/
public
interface
GroupA
{
}
src/main/java/com/glsx/admin/pojo/ValidateGroups.java
0 → 100644
View file @
26438a5
package
com
.
glsx
.
admin
.
pojo
;
/**
* <p>Description: 接口参数校验分组
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-05-10
*/
public
interface
ValidateGroups
{
interface
Insert
{}
interface
Delete
{}
interface
Update
{}
interface
Query
{}
}
src/main/java/com/glsx/admin/pojo/request/DeviceOrderValueReq.java
View file @
26438a5
package
com
.
glsx
.
admin
.
pojo
.
request
;
package
com
.
glsx
.
admin
.
pojo
.
request
;
import
lombok.Data
;
import
javax.validation.constraints.NotNull
;
import
javax.validation.constraints.NotNull
;
import
javax.validation.groups.Default
;
import
com.glsx.admin.pojo.ValidateGroups
;
import
lombok.Data
;
/**
/**
* <p>Description:
* <p>Description:
...
@@ -25,7 +24,7 @@ public class DeviceOrderValueReq {
...
@@ -25,7 +24,7 @@ public class DeviceOrderValueReq {
/**
/**
* 关联smart_device_order表中id
* 关联smart_device_order表中id
*/
*/
@NotNull
(
message
=
"orderId不能为空"
,
groups
=
{
Default
.
class
})
@NotNull
(
message
=
"orderId不能为空"
,
groups
=
{
ValidateGroups
.
Query
.
class
})
private
Integer
orderId
;
private
Integer
orderId
;
private
String
deviceStatusCode
;
private
String
deviceStatusCode
;
...
...
src/main/java/com/glsx/admin/pojo/request/ProductReq.java
View file @
26438a5
...
@@ -2,10 +2,9 @@ package com.glsx.admin.pojo.request;
...
@@ -2,10 +2,9 @@ package com.glsx.admin.pojo.request;
import
javax.validation.constraints.NotBlank
;
import
javax.validation.constraints.NotBlank
;
import
javax.validation.constraints.NotNull
;
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
com.glsx.admin.pojo.
ValidateGroups
;
import
lombok.Data
;
import
lombok.Data
;
/**
/**
...
@@ -25,49 +24,49 @@ public class ProductReq extends BaseDTO {
...
@@ -25,49 +24,49 @@ public class ProductReq extends BaseDTO {
/**
/**
* 标识ID
* 标识ID
*/
*/
@NotNull
(
message
=
"id不能为空"
,
groups
=
{
Default
.
class
})
@NotNull
(
message
=
"id不能为空"
,
groups
=
{
ValidateGroups
.
Query
.
class
})
private
Long
id
;
private
Long
id
;
/**
/**
* 产品名称
* 产品名称
*/
*/
@NotBlank
(
message
=
"产品名称不能为空"
,
groups
=
{
GroupA
.
class
})
@NotBlank
(
message
=
"产品名称不能为空"
,
groups
=
{
ValidateGroups
.
Insert
.
class
})
private
String
productName
;
private
String
productName
;
/**
/**
* 图片ID 关联smart_sys_file中id
* 图片ID 关联smart_sys_file中id
*/
*/
@NotNull
(
message
=
"缩略图不能为空"
,
groups
=
{
GroupA
.
class
})
@NotNull
(
message
=
"缩略图不能为空"
,
groups
=
{
ValidateGroups
.
Insert
.
class
})
private
Long
icon
;
private
Long
icon
;
/**
/**
* 产品类型ID 关联smart_product_type中id
* 产品类型ID 关联smart_product_type中id
*/
*/
@NotNull
(
message
=
"产品类型不能为空"
,
groups
=
{
GroupA
.
class
})
@NotNull
(
message
=
"产品类型不能为空"
,
groups
=
{
ValidateGroups
.
Insert
.
class
})
private
Long
typeId
;
private
Long
typeId
;
/**
/**
* 商城产品id
* 商城产品id
*/
*/
@NotBlank
(
message
=
"商品id不能为空"
,
groups
=
{
GroupA
.
class
})
@NotBlank
(
message
=
"商品id不能为空"
,
groups
=
{
ValidateGroups
.
Insert
.
class
})
private
String
shopProductId
;
private
String
shopProductId
;
/**
/**
* 接入平台key 关联smart_sys_code中dict_key
* 接入平台key 关联smart_sys_code中dict_key
*/
*/
@NotBlank
(
message
=
"接入平台不能为空"
,
groups
=
{
GroupA
.
class
})
@NotBlank
(
message
=
"接入平台不能为空"
,
groups
=
{
ValidateGroups
.
Insert
.
class
})
private
String
platformKey
;
private
String
platformKey
;
/**
/**
* 接入平台产品id
* 接入平台产品id
*/
*/
@NotBlank
(
message
=
"产品id不能为空"
,
groups
=
{
GroupA
.
class
})
@NotBlank
(
message
=
"产品id不能为空"
,
groups
=
{
ValidateGroups
.
Insert
.
class
})
private
String
platformProductId
;
private
String
platformProductId
;
/**
/**
* 配网方式key 关联smart_sys_code中dict_key
* 配网方式key 关联smart_sys_code中dict_key
*/
*/
//@NotBlank(message = "配网模式不能为空", groups = {
GroupA
.class})
//@NotBlank(message = "配网模式不能为空", groups = {
ValidateGroups.Insert
.class})
private
String
networkKey
;
private
String
networkKey
;
/**
/**
...
...
src/main/java/com/glsx/admin/pojo/request/ProductTypeReq.java
View file @
26438a5
...
@@ -2,10 +2,9 @@ package com.glsx.admin.pojo.request;
...
@@ -2,10 +2,9 @@ package com.glsx.admin.pojo.request;
import
javax.validation.constraints.NotBlank
;
import
javax.validation.constraints.NotBlank
;
import
javax.validation.constraints.NotNull
;
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
com.glsx.admin.pojo.
ValidateGroups
;
import
lombok.Data
;
import
lombok.Data
;
/**
/**
...
@@ -25,25 +24,25 @@ public class ProductTypeReq extends BaseDTO {
...
@@ -25,25 +24,25 @@ public class ProductTypeReq extends BaseDTO {
/**
/**
* 标识ID
* 标识ID
*/
*/
@NotNull
(
message
=
"id不能为空"
,
groups
=
{
Default
.
class
})
@NotNull
(
message
=
"id不能为空"
,
groups
=
{
ValidateGroups
.
Query
.
class
})
private
Long
id
;
private
Long
id
;
/**
/**
* 类型名称
* 类型名称
*/
*/
@NotBlank
(
message
=
"产品类型名称不能为空"
,
groups
=
{
GroupA
.
class
})
@NotBlank
(
message
=
"产品类型名称不能为空"
,
groups
=
{
ValidateGroups
.
Insert
.
class
})
private
String
typeName
;
private
String
typeName
;
/**
/**
* 类别key 关联smart_sys_code中dict_key
* 类别key 关联smart_sys_code中dict_key
*/
*/
@NotBlank
(
message
=
"分类不能为空"
,
groups
=
{
GroupA
.
class
})
@NotBlank
(
message
=
"分类不能为空"
,
groups
=
{
ValidateGroups
.
Insert
.
class
})
private
String
categoryKey
;
private
String
categoryKey
;
/**
/**
* 商城标签
* 商城标签
*/
*/
@NotBlank
(
message
=
"商城标签不能为空"
,
groups
=
{
GroupA
.
class
})
@NotBlank
(
message
=
"商城标签不能为空"
,
groups
=
{
ValidateGroups
.
Insert
.
class
})
private
String
shopTag
;
private
String
shopTag
;
/**
/**
...
...
src/main/java/com/glsx/admin/pojo/request/SceneTemplateReq.java
View file @
26438a5
package
com
.
glsx
.
admin
.
pojo
.
request
;
package
com
.
glsx
.
admin
.
pojo
.
request
;
import
com.glsx.admin.pojo.BaseDTO
;
import
com.glsx.admin.pojo.GroupA
;
import
lombok.Data
;
import
javax.validation.constraints.NotEmpty
;
import
javax.validation.constraints.NotEmpty
;
import
javax.validation.constraints.NotNull
;
import
javax.validation.constraints.NotNull
;
import
javax.validation.groups.Default
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
import
com.glsx.admin.pojo.BaseDTO
;
import
com.glsx.admin.pojo.ValidateGroups
;
import
lombok.Data
;
/**
/**
* <p>Description:
* <p>Description:
...
@@ -28,37 +26,37 @@ public class SceneTemplateReq extends BaseDTO {
...
@@ -28,37 +26,37 @@ public class SceneTemplateReq extends BaseDTO {
/**
/**
* 标识ID
* 标识ID
*/
*/
@NotNull
(
message
=
"id不能为空"
,
groups
=
{
Default
.
class
})
@NotNull
(
message
=
"id不能为空"
,
groups
=
{
ValidateGroups
.
Query
.
class
})
private
Long
id
;
private
Long
id
;
/**
/**
* 场景名称
* 场景名称
*/
*/
@NotEmpty
(
message
=
"sceneName不能为空"
,
groups
=
{
GroupA
.
class
})
@NotEmpty
(
message
=
"sceneName不能为空"
,
groups
=
{
ValidateGroups
.
Insert
.
class
})
private
String
sceneName
;
private
String
sceneName
;
/**
/**
* 场景类型key 关联smart_sys_code中dict_key
* 场景类型key 关联smart_sys_code中dict_key
*/
*/
@NotEmpty
(
message
=
"typeKey不能为空"
,
groups
=
{
GroupA
.
class
})
@NotEmpty
(
message
=
"typeKey不能为空"
,
groups
=
{
ValidateGroups
.
Insert
.
class
})
private
String
typeKey
;
private
String
typeKey
;
/**
/**
* 场景图标ID 关联smart_sys_file中id
* 场景图标ID 关联smart_sys_file中id
*/
*/
@NotNull
(
message
=
"icon不能为空"
,
groups
=
{
GroupA
.
class
})
@NotNull
(
message
=
"icon不能为空"
,
groups
=
{
ValidateGroups
.
Insert
.
class
})
private
Long
icon
;
private
Long
icon
;
/**
/**
* 场景背景图ID 关联smart_sys_file中id
* 场景背景图ID 关联smart_sys_file中id
*/
*/
@NotNull
(
message
=
"backPic不能为空"
,
groups
=
{
GroupA
.
class
})
@NotNull
(
message
=
"backPic不能为空"
,
groups
=
{
ValidateGroups
.
Insert
.
class
})
private
Long
backPic
;
private
Long
backPic
;
/**
/**
* 列表页面图ID 关联smart_sys_file中id
* 列表页面图ID 关联smart_sys_file中id
*/
*/
@NotNull
(
message
=
"pagePic不能为空"
,
groups
=
{
GroupA
.
class
})
@NotNull
(
message
=
"pagePic不能为空"
,
groups
=
{
ValidateGroups
.
Insert
.
class
})
private
Long
pagePic
;
private
Long
pagePic
;
/**
/**
...
...
src/main/java/com/glsx/admin/pojo/response/ProductResp.java
View file @
26438a5
package
com
.
glsx
.
admin
.
pojo
.
response
;
package
com
.
glsx
.
admin
.
pojo
.
response
;
import
javax.persistence.Transient
;
import
javax.persistence.Transient
;
import
java.io.Serializable
;
import
java.util.Date
;
import
java.util.Date
;
import
com.glsx.admin.pojo.BaseDTO
;
import
lombok.Data
;
import
lombok.Data
;
/**
/**
...
@@ -18,7 +18,7 @@ import lombok.Data;
...
@@ -18,7 +18,7 @@ import lombok.Data;
* 车家智能产品数据表
* 车家智能产品数据表
*/
*/
@Data
@Data
public
class
ProductResp
extends
BaseDTO
{
public
class
ProductResp
implements
Serializable
{
/**
/**
* 图标 url
* 图标 url
*/
*/
...
...
src/main/java/com/glsx/admin/pojo/response/ProductTypeResp.java
View file @
26438a5
package
com
.
glsx
.
admin
.
pojo
.
response
;
package
com
.
glsx
.
admin
.
pojo
.
response
;
import
java.io.Serializable
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
import
com.glsx.admin.pojo.BaseDTO
;
import
lombok.Data
;
import
lombok.Data
;
/**
/**
...
@@ -18,7 +18,7 @@ import lombok.Data;
...
@@ -18,7 +18,7 @@ import lombok.Data;
* 车家智能产品类型表
* 车家智能产品类型表
*/
*/
@Data
@Data
public
class
ProductTypeResp
extends
BaseDTO
{
public
class
ProductTypeResp
implements
Serializable
{
/**
/**
* 一级分类
* 一级分类
*/
*/
...
...
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