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 5be3f346
authored
May 13, 2021
by
王能兵
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge branch 'dev' into 'master'
Dev See merge request
!2
2 parents
3ec7c508
11caa975
Hide whitespace changes
Inline
Side-by-side
Showing
34 changed files
with
534 additions
and
386 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/FeignDecoderConfigForR.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/request/SmartSysFileReq.java
src/main/java/com/glsx/admin/pojo/response/ProductResp.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/OrderValueFeignClient.java
src/main/java/com/glsx/admin/remote/ProductConditionFeignClient.java
src/main/java/com/glsx/admin/remote/ProductContentFeignClient.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/SceneTemplateFeignClient.java
src/main/java/com/glsx/admin/remote/SysCodeFeignClient.java
src/main/resources/application.properties
src/main/resources/bootstrap.properties
pom.xml
View file @
5be3f34
...
@@ -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 @
5be3f34
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
0 → 100644
View file @
5be3f34
package
com
.
glsx
.
admin
.
config
;
import
java.io.IOException
;
import
java.lang.reflect.ParameterizedType
;
import
java.lang.reflect.Type
;
import
java.nio.charset.StandardCharsets
;
import
cn.hutool.core.io.IoUtil
;
import
com.alibaba.fastjson.JSON
;
import
com.glsx.admin.exception.ChejiaBusinessException
;
import
com.glsx.admin.exception.ResultEnum
;
import
feign.Response
;
import
feign.codec.Decoder
;
import
lombok.extern.slf4j.Slf4j
;
/**
* <p>Description: feign 自定义解码器
* <p>Project: chejia-smart
* <p>目前实现了 {@link com.glsx.plat.core.web.R} 的解码器 {@link FeignDecoderForR}。</p>
* <p>如果需要定义不同的解码器,则继承此类,并实现此类中所有方法和 {@link FeignParser} 接口。</p>
*
* @param <T> 方法出参类型
* @author wbh
* @date 2021-05-08
*/
@Slf4j
public
abstract
class
FeignDecoder
<
T
>
implements
Decoder
{
@Override
public
Object
decode
(
Response
response
,
Type
type
)
{
Object
result
;
try
{
if
(
response
.
status
()
>=
200
&&
response
.
status
()
<
300
)
{
// 正常返回,解析返回对象
result
=
this
.
handleNormalResponse
(
response
,
type
);
}
else
{
// 非正常返回,抛出异常
this
.
handleErrorResponse
(
response
);
result
=
null
;
}
}
catch
(
ChejiaBusinessException
e
)
{
throw
e
;
}
catch
(
Exception
e
)
{
throw
ChejiaBusinessException
.
create
(
ResultEnum
.
REMOTE_SERVICE_ERROR
);
}
return
result
;
}
/**
* 处理正常返回,即 HTTP 状态码为 2xx
*
* @param response feign 请求
* @param type 方法出参类型
* @return 结果
* @throws IOException 异常
*/
private
Object
handleNormalResponse
(
Response
response
,
Type
type
)
throws
IOException
{
Object
result
;
Response
.
Body
body
=
response
.
body
();
if
(
body
==
null
)
{
result
=
null
;
}
else
{
String
respJson
=
IoUtil
.
read
(
body
.
asReader
(
StandardCharsets
.
UTF_8
));
Type
responseType
=
this
.
getResponseType
();
// 响应对象
T
resp
=
JSON
.
parseObject
(
respJson
,
responseType
);
// 判断出参类型和响应对象类型是否匹配,即响应对象要能赋值给方法出参
boolean
methodTypeMatched
=
type
.
getTypeName
().
equals
(
responseType
.
getTypeName
());
//boolean methodTypeMatched = (type instanceof Class)
// && responseType.isAssignableFrom((Class<?>) type);
if
(
methodTypeMatched
)
{
// 类型匹配:无需进一步解析,直接返回该对象
result
=
resp
;
}
else
{
// 类型不匹配:开始解析响应对象
this
.
ensureResponseSuccess
(
resp
);
result
=
this
.
parseResponse
(
resp
,
type
);
}
}
return
result
;
}
/**
* 处理非正常返回,即 2xx 之外的 HTTP 状态码
*
* @param response feign 请求
* @throws IOException 异常
* @deprecated 貌似捕捉不到 2xx 之外的响应
*/
@Deprecated
private
void
handleErrorResponse
(
Response
response
)
throws
IOException
{
Response
.
Body
body
=
response
.
body
();
if
(
body
==
null
)
{
throw
ChejiaBusinessException
.
create
(
ResultEnum
.
REMOTE_SERVICE_ERROR
);
}
else
{
String
respJson
=
IoUtil
.
read
(
body
.
asReader
(
StandardCharsets
.
UTF_8
));
Type
responseType
=
this
.
getResponseType
();
T
resp
=
JSON
.
parseObject
(
respJson
,
responseType
);
throw
ChejiaBusinessException
.
create
(
this
.
extractCode
(
resp
),
this
.
extractMessage
(
resp
));
}
}
///**
// * 获取响应对象类型
// *
// * @return 类型
// */
//@SuppressWarnings("unchecked")
//private Class<T> getResponseType() {
// ParameterizedType type = (ParameterizedType) this.getClass().getGenericSuperclass();
// return (Class<T>) type.getActualTypeArguments()[0];
//}
/**
* 获取响应对象类型
*
* @return 类型
*/
private
Type
getResponseType
()
{
ParameterizedType
type
=
(
ParameterizedType
)
this
.
getClass
().
getGenericSuperclass
();
return
type
.
getActualTypeArguments
()[
0
];
}
/**
* 解析响应对象中的内容
*
* @param resp 响应对象
* @param type 解析的目标类型
* @return 结果
*/
private
Object
parseResponse
(
T
resp
,
Type
type
)
{
Object
result
=
(
this
.
extractData
(
resp
)
==
null
)
?
null
:
this
.
getParser
(
type
).
parse
(
resp
,
type
);
return
result
;
}
/**
* 获取响应对象解析器
*
* @param type 解析的目标类型
* @return 解析器
*/
protected
abstract
FeignParser
<
T
>
getParser
(
Type
type
);
/**
* 提取响应对象中的状态码
*
* @param resp 响应对象
* @return 结果
*/
protected
abstract
int
extractCode
(
T
resp
);
/**
* 提取响应对象中的信息
*
* @param resp 响应对象
* @return 结果
*/
protected
abstract
String
extractMessage
(
T
resp
);
/**
* 提取响应对象中的数据
*
* @param resp 响应对象
* @return 结果
*/
protected
abstract
Object
extractData
(
T
resp
);
/**
* 确定响应对象的返回是正常的,非正常则抛出异常
*
* @param resp 响应对象
*/
protected
abstract
void
ensureResponseSuccess
(
T
resp
);
/**
* 响应对象解析类,解析成最终需要的方法出参对象
*
* @param <T> 方法出参类型
*/
protected
interface
FeignParser
<
T
>
{
/**
* 解析对象成方法返回对象
*
* @param resp 响应体
* @param type 方法出参类型
* @return 结果
*/
Object
parse
(
T
resp
,
Type
type
);
}
}
src/main/java/com/glsx/admin/config/FeignDecoderConfigForR.java
0 → 100644
View file @
5be3f34
package
com
.
glsx
.
admin
.
config
;
import
feign.codec.Decoder
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.cloud.openfeign.FeignClient
;
import
org.springframework.context.annotation.Bean
;
/**
* <p>Description: feign 解码器配置
* <p>Project: chejia-smart
* <p>为了兼顾灵活性,此类上无需加上 {@link org.springframework.context.annotation.Configuration} 注解,加上该注解则会将 {@link FeignDecoderForR} 设置为默认解码器。
* <p>不加该注解,则只需在 feign 客户端注解 {@link org.springframework.cloud.openfeign.FeignClient} 中配置 {@link FeignClient#configuration()} 属性为此类。
* <p>注意:
*
* @author wbh
* @date 2021-05-08
*/
@Slf4j
//@Configuration
public
class
FeignDecoderConfigForR
{
@Bean
public
Decoder
decoderForR
()
{
return
new
FeignDecoderForR
();
}
}
src/main/java/com/glsx/admin/config/FeignDecoderForR.java
0 → 100644
View file @
5be3f34
package
com
.
glsx
.
admin
.
config
;
import
java.lang.reflect.ParameterizedType
;
import
java.lang.reflect.Type
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.github.pagehelper.Page
;
import
com.github.pagehelper.PageInfo
;
import
com.glsx.admin.exception.ChejiaBusinessException
;
import
com.glsx.admin.exception.ResultEnum
;
import
com.glsx.plat.core.web.R
;
/**
* <p>Description: {@link R} 的 feign 解码器
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-05-08
*/
public
class
FeignDecoderForR
extends
FeignDecoder
<
R
>
{
@Override
protected
FeignParser
<
R
>
getParser
(
Type
type
)
{
return
FeignParserForR
.
getParser
(
type
);
}
@Override
protected
int
extractCode
(
R
resp
)
{
return
resp
.
getCode
();
}
@Override
protected
String
extractMessage
(
R
resp
)
{
return
resp
.
getMessage
();
}
@Override
protected
Object
extractData
(
R
resp
)
{
return
resp
.
getData
();
}
@Override
protected
void
ensureResponseSuccess
(
R
resp
)
{
int
code
=
resp
.
getCode
();
String
message
=
resp
.
getMessage
();
if
(!
ResultEnum
.
SUCCESS
.
getCode
().
equals
(
code
))
{
throw
ChejiaBusinessException
.
create
(
code
,
message
);
}
}
/**
* {@link R} 的响应对象解析器
*/
private
enum
FeignParserForR
implements
FeignParser
<
R
>
{
/**
* 直接按照 type 解析成对应类型的对象
*/
COMMON
(
Object
.
class
)
{
@Override
public
Object
parse
(
R
resp
,
Type
type
)
{
return
JSON
.
parseObject
(
FeignParserForR
.
extractDataJson
(
resp
),
type
);
}
},
/**
* 从 resp 中提取出 {@link PageInfo} 对象
*/
PAGE_HELPER_PAGE_INFO
(
PageInfo
.
class
)
{
@Override
public
Object
parse
(
R
resp
,
Type
type
)
{
JSONObject
dataObj
=
JSON
.
parseObject
(
FeignParserForR
.
extractDataJson
(
resp
));
// 先创造出 PageInfo 对象,再填充数据
PageInfo
<?>
pageInfo
=
PageInfo
.
of
(
dataObj
.
getJSONArray
(
"list"
));
pageInfo
.
setPages
(
dataObj
.
getInteger
(
"totalPages"
));
pageInfo
.
setTotal
(
dataObj
.
getLong
(
"totalElements"
));
return
pageInfo
;
}
},
/**
* 从 resp 中提取出 {@link Page} 对象
*/
PAGE_HELPER_PAGE
(
Page
.
class
)
{
@Override
public
Object
parse
(
R
resp
,
Type
type
)
{
ParameterizedType
parameterizedType
=
(
ParameterizedType
)
type
;
JSONObject
dataObj
=
JSON
.
parseObject
(
FeignParserForR
.
extractDataJson
(
resp
));
// 解析出 Page 对象,再填充数据
Page
<?>
page
=
dataObj
.
getJSONArray
(
"page"
).
toJavaObject
(
type
);
page
.
addAll
(
dataObj
.
getJSONArray
(
"items"
).
toJavaObject
(
parameterizedType
.
getActualTypeArguments
()[
0
]));
return
page
;
}
},
/**
* 从 resp 中提取出 {@link org.springframework.data.domain.Page} 对象
*/
SPRING_PAGE
(
org
.
springframework
.
data
.
domain
.
Page
.
class
)
{
@Override
public
Object
parse
(
R
resp
,
Type
type
)
{
JSONObject
dataObj
=
JSON
.
parseObject
(
FeignParserForR
.
extractDataJson
(
resp
));
// 直接解析吧,分页数据没办法填充
org
.
springframework
.
data
.
domain
.
Page
<?>
page
=
dataObj
.
getJSONArray
(
"list"
)
.
toJavaObject
(
type
);
return
page
;
}
},
;
private
final
Class
<?>
clazz
;
FeignParserForR
(
Class
<?>
clazz
)
{
this
.
clazz
=
clazz
;
}
public
static
FeignParser
<
R
>
getParser
(
Type
type
)
{
// 先赋值为默认解析器,防止下面的循环没有匹配到上面枚举中的任何一个解析器
FeignParser
<
R
>
parser
=
COMMON
;
// 判断是否是泛型出参
if
(
type
instanceof
ParameterizedType
)
{
// 是泛型出参:匹配上面枚举中的解析器
ParameterizedType
parameterizedType
=
(
ParameterizedType
)
type
;
Class
<?>
rawType
=
(
Class
<?>)
parameterizedType
.
getRawType
();
for
(
FeignParserForR
value
:
values
())
{
// 判断当前解析器支持类型是否和方法出参类型匹配
if
(
rawType
.
equals
(
value
.
clazz
))
{
parser
=
value
;
break
;
}
}
}
return
parser
;
}
private
static
String
extractDataJson
(
R
resp
)
{
Object
data
=
resp
.
getData
();
String
dataJson
=
JSON
.
toJSONString
(
data
);
return
dataJson
;
}
}
}
src/main/java/com/glsx/admin/controller/BaseController.java
View file @
5be3f34
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 @
5be3f34
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 @
5be3f34
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
...
@@ -76,7 +74,7 @@ public class ProductController {
...
@@ -76,7 +74,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 +87,7 @@ public class ProductController {
...
@@ -89,7 +87,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 +100,7 @@ public class ProductController {
...
@@ -102,7 +100,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 +116,7 @@ public class ProductController {
...
@@ -118,7 +116,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 +133,7 @@ public class ProductController {
...
@@ -135,7 +133,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 @
5be3f34
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 @
5be3f34
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 @
3ec7c50
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 @
5be3f34
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
deleted
100644 → 0
View file @
3ec7c50
package
com
.
glsx
.
admin
.
exception
;
import
java.util.List
;
import
java.util.concurrent.TimeoutException
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.glsx.plat.common.utils.StringUtils
;
import
com.glsx.plat.core.web.R
;
import
com.netflix.hystrix.exception.HystrixRuntimeException
;
import
feign.FeignException
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.validation.BindException
;
import
org.springframework.validation.FieldError
;
import
org.springframework.web.bind.MethodArgumentNotValidException
;
import
org.springframework.web.bind.ServletRequestBindingException
;
import
org.springframework.web.bind.annotation.ExceptionHandler
;
import
org.springframework.web.bind.annotation.RestControllerAdvice
;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-16
*/
@Slf4j
@RestControllerAdvice
public
class
GlobalExceptionHandler
{
@ExceptionHandler
({
BusinessException
.
class
})
public
R
handleBusinessException
(
BusinessException
e
)
{
log
.
error
(
"!!!! 业务异常"
,
e
);
return
R
.
error
(
e
.
getCode
(),
e
.
getMessage
());
}
@ExceptionHandler
({
ServletRequestBindingException
.
class
,
MethodArgumentNotValidException
.
class
,
BindException
.
class
})
public
R
handleBindException
(
Exception
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
());
}
}
@ExceptionHandler
({
HystrixRuntimeException
.
class
})
public
R
handleHystrixException
(
HystrixRuntimeException
e
)
{
Throwable
cause
=
e
.
getCause
();
if
(
cause
instanceof
FeignException
)
{
FeignException
feignException
=
(
FeignException
)
cause
;
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
{
log
.
error
(
"!!!! Hystrix熔断错误"
,
e
);
return
R
.
error
(
ResultEnum
.
ERROR
.
getCode
(),
ResultEnum
.
ERROR
.
getMessage
());
}
}
@ExceptionHandler
({
FeignException
.
class
})
public
R
handleFeignException
(
FeignException
e
)
{
log
.
error
(
"!!!! 远程服务错误"
,
e
);
String
respMessage
;
if
(
StringUtils
.
isNotBlank
(
e
.
contentUTF8
()))
{
JSONObject
respObj
=
JSON
.
parseObject
(
e
.
contentUTF8
());
respMessage
=
respObj
.
getString
(
"message"
);
}
else
{
respMessage
=
""
;
}
int
code
=
ResultEnum
.
REMOTE_SERVICE_ERROR
.
getCode
();
String
message
=
StringUtils
.
isBlank
(
respMessage
)
?
ResultEnum
.
REMOTE_SERVICE_ERROR
.
getMessage
()
:
respMessage
;
return
R
.
error
(
code
,
message
);
}
@ExceptionHandler
(
Exception
.
class
)
public
R
handleException
(
Exception
e
)
{
log
.
error
(
"!!!! 未知异常"
,
e
);
return
R
.
error
(
ResultEnum
.
ERROR
.
getCode
(),
ResultEnum
.
ERROR
.
getMessage
());
}
}
src/main/java/com/glsx/admin/filter/CorsFilter.java
deleted
100644 → 0
View file @
3ec7c50
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
com.glsx.plat.common.utils.StringUtils
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.HttpMethod
;
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
(!
StringUtils
.
containsIgnoreCase
(
headersSb
,
HttpHeaders
.
CONTENT_TYPE
))
{
headersSb
.
append
(
HttpHeaders
.
CONTENT_TYPE
).
append
(
", "
);
}
if
(!
StringUtils
.
containsIgnoreCase
(
headersSb
,
HttpHeaders
.
AUTHORIZATION
))
{
headersSb
.
append
(
HttpHeaders
.
AUTHORIZATION
).
append
(
", "
);
}
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"
);
// 放行预检请求(preflight requests)
if
(
httpRequest
.
getMethod
().
equalsIgnoreCase
(
HttpMethod
.
OPTIONS
.
toString
()))
{
httpResponse
.
setStatus
(
HttpServletResponse
.
SC_OK
);
httpResponse
.
getWriter
().
println
(
"OK"
);
return
;
}
chain
.
doFilter
(
request
,
response
);
}
}
src/main/java/com/glsx/admin/pojo/BaseDTO.java
View file @
5be3f34
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 @
3ec7c50
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 @
5be3f34
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 @
5be3f34
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 @
5be3f34
...
@@ -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 @
5be3f34
...
@@ -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 @
5be3f34
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/request/SmartSysFileReq.java
View file @
5be3f34
...
@@ -22,6 +22,7 @@ import lombok.Data;
...
@@ -22,6 +22,7 @@ import lombok.Data;
@Data
@Data
@Table
(
name
=
"smart_sys_file"
)
@Table
(
name
=
"smart_sys_file"
)
public
class
SmartSysFileReq
{
public
class
SmartSysFileReq
{
/**
/**
* 标识ID
* 标识ID
*/
*/
...
...
src/main/java/com/glsx/admin/pojo/response/ProductResp.java
View file @
5be3f34
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 @
5be3f34
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
{
/**
/**
* 一级分类
* 一级分类
*/
*/
...
...
src/main/java/com/glsx/admin/remote/IndexFeignClient.java
View file @
5be3f34
package
com
.
glsx
.
admin
.
remote
;
package
com
.
glsx
.
admin
.
remote
;
import
com.glsx.admin.config.FeignDecoderConfigForR
;
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.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
;
@FeignClient
(
name
=
"${feign.server.name}"
,
url
=
"${feign.server.url}"
,
fallback
=
IndexHystrix
.
class
)
@FeignClient
(
name
=
"${feign.server.name}"
,
url
=
"${feign.server.url}"
,
fallback
=
IndexHystrix
.
class
,
configuration
=
FeignDecoderConfigForR
.
class
)
public
interface
IndexFeignClient
{
public
interface
IndexFeignClient
{
@ResponseBody
@ResponseBody
...
...
src/main/java/com/glsx/admin/remote/OrderValueFeignClient.java
View file @
5be3f34
package
com
.
glsx
.
admin
.
remote
;
package
com
.
glsx
.
admin
.
remote
;
import
java.util.List
;
import
com.glsx.admin.config.FeignDecoderConfigForR
;
import
com.glsx.admin.pojo.request.DeviceOrderValueReq
;
import
com.glsx.admin.pojo.request.DeviceOrderValueReq
;
import
com.glsx.admin.pojo.response.DeviceOrderValueResp
;
import
com.glsx.admin.pojo.response.DeviceOrderValueResp
;
import
org.springframework.cloud.openfeign.FeignClient
;
import
org.springframework.cloud.openfeign.FeignClient
;
...
@@ -8,9 +10,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
...
@@ -8,9 +10,8 @@ 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
;
import
java.util.List
;
@FeignClient
(
name
=
"${feign.server.name}"
,
url
=
"${feign.server.url}"
,
configuration
=
FeignDecoderConfigForR
.
class
)
@FeignClient
(
name
=
"${feign.server.name}"
,
url
=
"${feign.server.url}"
)
public
interface
OrderValueFeignClient
{
public
interface
OrderValueFeignClient
{
@ResponseBody
@ResponseBody
...
...
src/main/java/com/glsx/admin/remote/ProductConditionFeignClient.java
View file @
5be3f34
package
com
.
glsx
.
admin
.
remote
;
package
com
.
glsx
.
admin
.
remote
;
import
java.util.List
;
import
com.glsx.admin.config.FeignDecoderConfigForR
;
import
com.glsx.admin.pojo.request.ScenceSupstatusReq
;
import
com.glsx.admin.pojo.request.ScenceSupstatusReq
;
import
com.glsx.admin.pojo.response.ScenceSupstatusResp
;
import
com.glsx.admin.pojo.response.ScenceSupstatusResp
;
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.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
;
import
java.util.List
;
@FeignClient
(
name
=
"${feign.server.name}"
,
url
=
"${feign.server.url}"
,
configuration
=
FeignDecoderConfigForR
.
class
)
@FeignClient
(
name
=
"${feign.server.name}"
,
url
=
"${feign.server.url}"
)
public
interface
ProductConditionFeignClient
{
public
interface
ProductConditionFeignClient
{
@ResponseBody
@ResponseBody
...
...
src/main/java/com/glsx/admin/remote/ProductContentFeignClient.java
View file @
5be3f34
package
com
.
glsx
.
admin
.
remote
;
package
com
.
glsx
.
admin
.
remote
;
import
java.util.List
;
import
com.glsx.admin.config.FeignDecoderConfigForR
;
import
com.glsx.admin.pojo.request.DeviceOrderReq
;
import
com.glsx.admin.pojo.request.DeviceOrderReq
;
import
com.glsx.admin.pojo.response.DeviceOrderResp
;
import
com.glsx.admin.pojo.response.DeviceOrderResp
;
import
org.springframework.cloud.openfeign.FeignClient
;
import
org.springframework.cloud.openfeign.FeignClient
;
...
@@ -8,9 +10,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
...
@@ -8,9 +10,8 @@ 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
;
import
java.util.List
;
@FeignClient
(
name
=
"${feign.server.name}"
,
url
=
"${feign.server.url}"
,
configuration
=
FeignDecoderConfigForR
.
class
)
@FeignClient
(
name
=
"${feign.server.name}"
,
url
=
"${feign.server.url}"
)
public
interface
ProductContentFeignClient
{
public
interface
ProductContentFeignClient
{
@ResponseBody
@ResponseBody
...
...
src/main/java/com/glsx/admin/remote/ProductFeignClient.java
View file @
5be3f34
...
@@ -2,6 +2,7 @@ package com.glsx.admin.remote;
...
@@ -2,6 +2,7 @@ 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.config.FeignDecoderConfigForR
;
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
;
...
@@ -19,7 +20,8 @@ import org.springframework.web.bind.annotation.ResponseBody;
...
@@ -19,7 +20,8 @@ import org.springframework.web.bind.annotation.ResponseBody;
* @author wbh
* @author wbh
* @date 2021-03-16
* @date 2021-03-16
*/
*/
@FeignClient
(
name
=
"${feign.server.name}"
,
url
=
"${feign.server.url}"
)
@FeignClient
(
name
=
"${feign.server.name}"
,
url
=
"${feign.server.url}"
,
configuration
=
FeignDecoderConfigForR
.
class
)
public
interface
ProductFeignClient
{
public
interface
ProductFeignClient
{
@RequestMapping
(
value
=
"/product/getPageList"
,
method
=
{
RequestMethod
.
GET
})
@RequestMapping
(
value
=
"/product/getPageList"
,
method
=
{
RequestMethod
.
GET
})
@ResponseBody
@ResponseBody
...
...
src/main/java/com/glsx/admin/remote/ProductTypeFeignClient.java
View file @
5be3f34
...
@@ -2,6 +2,7 @@ package com.glsx.admin.remote;
...
@@ -2,6 +2,7 @@ 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.config.FeignDecoderConfigForR
;
import
com.glsx.admin.pojo.request.ProductTypeReq
;
import
com.glsx.admin.pojo.request.ProductTypeReq
;
import
com.glsx.admin.pojo.response.ProductTypeResp
;
import
com.glsx.admin.pojo.response.ProductTypeResp
;
import
org.springframework.cloud.openfeign.FeignClient
;
import
org.springframework.cloud.openfeign.FeignClient
;
...
@@ -18,7 +19,8 @@ import org.springframework.web.bind.annotation.ResponseBody;
...
@@ -18,7 +19,8 @@ import org.springframework.web.bind.annotation.ResponseBody;
* @author wbh
* @author wbh
* @date 2021-03-17
* @date 2021-03-17
*/
*/
@FeignClient
(
name
=
"${feign.server.name}"
,
url
=
"${feign.server.url}"
)
@FeignClient
(
name
=
"${feign.server.name}"
,
url
=
"${feign.server.url}"
,
configuration
=
FeignDecoderConfigForR
.
class
)
public
interface
ProductTypeFeignClient
{
public
interface
ProductTypeFeignClient
{
@RequestMapping
(
value
=
"/productType/getPageList"
,
method
=
{
RequestMethod
.
GET
})
@RequestMapping
(
value
=
"/productType/getPageList"
,
method
=
{
RequestMethod
.
GET
})
@ResponseBody
@ResponseBody
...
...
src/main/java/com/glsx/admin/remote/SceneTemplateFeignClient.java
View file @
5be3f34
package
com
.
glsx
.
admin
.
remote
;
package
com
.
glsx
.
admin
.
remote
;
import
java.util.List
;
import
com.github.pagehelper.PageInfo
;
import
com.github.pagehelper.PageInfo
;
import
com.glsx.admin.config.FeignDecoderConfigForR
;
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
org.springframework.cloud.openfeign.FeignClient
;
import
org.springframework.cloud.openfeign.FeignClient
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
java.util.List
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.ResponseBody
;
/**
/**
* <p>Description:
* <p>Description:
...
@@ -15,7 +19,8 @@ import java.util.List;
...
@@ -15,7 +19,8 @@ import java.util.List;
* @author think.wang
* @author think.wang
* @date 2021-03-16
* @date 2021-03-16
*/
*/
@FeignClient
(
name
=
"${feign.server.name}"
,
url
=
"${feign.server.url}"
)
@FeignClient
(
name
=
"${feign.server.name}"
,
url
=
"${feign.server.url}"
,
configuration
=
FeignDecoderConfigForR
.
class
)
public
interface
SceneTemplateFeignClient
{
public
interface
SceneTemplateFeignClient
{
@ResponseBody
@ResponseBody
...
...
src/main/java/com/glsx/admin/remote/SysCodeFeignClient.java
View file @
5be3f34
package
com
.
glsx
.
admin
.
remote
;
package
com
.
glsx
.
admin
.
remote
;
import
java.util.List
;
import
java.util.List
;
import
com.glsx.admin.config.FeignDecoderConfigForR
;
import
com.glsx.admin.pojo.request.SysCodeReq
;
import
com.glsx.admin.pojo.request.SysCodeReq
;
import
com.glsx.admin.pojo.response.SysCodeResp
;
import
com.glsx.admin.pojo.response.SysCodeResp
;
import
org.springframework.cloud.openfeign.FeignClient
;
import
org.springframework.cloud.openfeign.FeignClient
;
...
@@ -16,7 +17,8 @@ import org.springframework.web.bind.annotation.ResponseBody;
...
@@ -16,7 +17,8 @@ import org.springframework.web.bind.annotation.ResponseBody;
* @author think.wang
* @author think.wang
* @date 2021-03-16
* @date 2021-03-16
*/
*/
@FeignClient
(
name
=
"${feign.server.name}"
,
url
=
"${feign.server.url}"
)
@FeignClient
(
name
=
"${feign.server.name}"
,
url
=
"${feign.server.url}"
,
configuration
=
FeignDecoderConfigForR
.
class
)
public
interface
SysCodeFeignClient
{
public
interface
SysCodeFeignClient
{
@ResponseBody
@ResponseBody
@RequestMapping
(
value
=
"/sysCode/getListByCondition"
,
method
=
{
RequestMethod
.
POST
})
@RequestMapping
(
value
=
"/sysCode/getListByCondition"
,
method
=
{
RequestMethod
.
POST
})
...
...
src/main/resources/application.properties
View file @
5be3f34
...
@@ -5,6 +5,10 @@ server.servlet.context-path=/smartAdmin
...
@@ -5,6 +5,10 @@ server.servlet.context-path=/smartAdmin
#\u6307\u5B9Adate\u8F93\u51FA\u683C\u5F0F\u4E3Ayyyy-MM-dd HH:mm:ss
#\u6307\u5B9Adate\u8F93\u51FA\u683C\u5F0F\u4E3Ayyyy-MM-dd HH:mm:ss
spring.jackson.date-
format
=
yyyy-MM-dd HH:mm:ss
spring.jackson.date-
format
=
yyyy-MM-dd HH:mm:ss
spring.jackson.time-
zone
=
GMT+8
spring.jackson.time-
zone
=
GMT+8
spring.jackson.serialization.write-dates-as-
timestamps
=
false
spring.jackson.serialization.fail-on-empty-
beans
=
false
spring.jackson.deserialization.fail-on-ignored-
properties
=
false
spring.jackson.deserialization.fail-on-unknown-
properties
=
false
server.tomcat.uri-
encoding
=
UTF-8
server.tomcat.uri-
encoding
=
UTF-8
spring.messages.encoding
=
UTF-8
spring.messages.encoding
=
UTF-8
...
...
src/main/resources/bootstrap.properties
View file @
5be3f34
...
@@ -2,4 +2,5 @@ spring.application.name=chejia-smart-admin
...
@@ -2,4 +2,5 @@ spring.application.name=chejia-smart-admin
server.port
=
8213
server.port
=
8213
#nacos\u914D\u7F6E
#nacos\u914D\u7F6E
spring.cloud.nacos.config.group
=
DEFAULT_GROUP
spring.cloud.nacos.config.group
=
DEFAULT_GROUP
spring.cloud.nacos.config.server-
addr
=
192.168.0.63:8848
\ No newline at end of file
\ No newline at end of file
#spring.cloud.nacos.config.server-addr=192.168.0.63:8848
spring.cloud.nacos.config.server-
addr
=
192.168.3.206:8848
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