Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
open-source
/
chejia-smart-service
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit ba22447c
authored
Mar 17, 2021
by
tyfanchz
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
调整代码
1 parent
502ccc7a
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
20 additions
and
44 deletions
src/main/java/com/glsx/smart/dao/entity/SmartProduct.java
src/main/java/com/glsx/smart/dao/entity/SmartProductType.java
src/main/java/com/glsx/smart/exception/GlobalExceptionHandler.java
src/main/resources/mapper/SmartProductMapper.xml
src/main/resources/mapper/SmartProductTypeMapper.xml
src/main/java/com/glsx/smart/dao/entity/SmartProduct.java
View file @
ba22447
...
@@ -37,18 +37,6 @@ public class SmartProduct extends BaseDTO {
...
@@ -37,18 +37,6 @@ public class SmartProduct extends BaseDTO {
@Transient
@Transient
private
String
typeName
;
private
String
typeName
;
/**
* 接入平台名称
*/
@Transient
private
String
platformName
;
/**
* 配网模式名称
*/
@Transient
private
String
networkName
;
/**
/**
* 标识ID
* 标识ID
...
...
src/main/java/com/glsx/smart/dao/entity/SmartProductType.java
View file @
ba22447
...
@@ -4,7 +4,6 @@ import javax.persistence.GeneratedValue;
...
@@ -4,7 +4,6 @@ import javax.persistence.GeneratedValue;
import
javax.persistence.GenerationType
;
import
javax.persistence.GenerationType
;
import
javax.persistence.Id
;
import
javax.persistence.Id
;
import
javax.persistence.Table
;
import
javax.persistence.Table
;
import
javax.persistence.Transient
;
import
javax.validation.constraints.NotBlank
;
import
javax.validation.constraints.NotBlank
;
import
java.util.Date
;
import
java.util.Date
;
import
com.glsx.smart.pojo.BaseDTO
;
import
com.glsx.smart.pojo.BaseDTO
;
...
@@ -26,19 +25,6 @@ import lombok.Data;
...
@@ -26,19 +25,6 @@ import lombok.Data;
@Table
(
name
=
"smart_product_type"
)
@Table
(
name
=
"smart_product_type"
)
public
class
SmartProductType
extends
BaseDTO
{
public
class
SmartProductType
extends
BaseDTO
{
/**
/**
* 一级分类名
*/
@Transient
private
String
categoryName1
;
/**
* 二级分类名
*/
@Transient
private
String
categoryName2
;
/**
* 标识ID
* 标识ID
*/
*/
@Id
@Id
...
...
src/main/java/com/glsx/smart/exception/GlobalExceptionHandler.java
View file @
ba22447
package
com
.
glsx
.
smart
.
exception
;
package
com
.
glsx
.
smart
.
exception
;
import
org.slf4j.Logger
;
import
lombok.extern.slf4j.Slf4j
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.validation.BindException
;
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.ExceptionHandler
;
import
org.springframework.web.bind.annotation.RestControllerAdvice
;
import
org.springframework.web.bind.annotation.RestControllerAdvice
;
...
@@ -12,17 +14,25 @@ import org.springframework.web.bind.annotation.RestControllerAdvice;
...
@@ -12,17 +14,25 @@ import org.springframework.web.bind.annotation.RestControllerAdvice;
* @author wbh
* @author wbh
* @date 2021-03-16
* @date 2021-03-16
*/
*/
@Slf4j
@RestControllerAdvice
@RestControllerAdvice
public
class
GlobalExceptionHandler
{
public
class
GlobalExceptionHandler
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
this
.
getClass
());
@ExceptionHandler
({
BusinessException
.
class
})
public
String
handleBusinessException
(
BusinessException
e
)
{
log
.
error
(
"!!!! 业务异常"
,
e
);
return
e
.
getMessage
();
}
@ExceptionHandler
(
BusinessException
.
class
)
@ExceptionHandler
({
ServletRequestBindingException
.
class
,
MethodArgumentNotValidException
.
class
,
public
void
handleBusinessException
(
BusinessException
e
)
{
BindException
.
class
})
logger
.
error
(
"!!!! 业务异常"
,
e
);
public
String
handleBindException
(
Exception
e
)
{
log
.
error
(
"!!!! 参数错误"
,
e
);
return
ResultEnum
.
PARAM_ERROR
.
getMessage
();
}
}
@ExceptionHandler
(
Exception
.
class
)
@ExceptionHandler
(
Exception
.
class
)
public
void
handleException
(
Exception
e
)
{
public
String
handleException
(
Exception
e
)
{
logger
.
error
(
"!!!! 未知异常"
,
e
);
log
.
error
(
"!!!! 未知异常"
,
e
);
return
ResultEnum
.
ERROR
.
getMessage
();
}
}
}
}
src/main/resources/mapper/SmartProductMapper.xml
View file @
ba22447
...
@@ -31,14 +31,10 @@
...
@@ -31,14 +31,10 @@
sp.platform_product_id, sp.network_key, sp.status, sp.remark, sp.create_time,
sp.platform_product_id, sp.network_key, sp.status, sp.remark, sp.create_time,
sp.create_by, sp.update_time, sp.update_by,
sp.create_by, sp.update_time, sp.update_by,
ssf.url iconUrl,
ssf.url iconUrl,
spt.type_name typeName,
spt.type_name typeName
sscp.dict_value platformName,
sscn.dict_value networkName
from smart_product sp
from smart_product sp
left join smart_sys_file ssf on ssf.id = sp.icon
left join smart_sys_file ssf on ssf.id = sp.icon
left join smart_product_type spt on spt.id = sp.type_id
left join smart_product_type spt on spt.id = sp.type_id
left join smart_sys_code sscp on sscp.dict_key = sp.platform_key
left join smart_sys_code sscn on sscn.dict_key = sp.network_key
<where>
<where>
<if
test=
"productName != null and productName != ''"
>
<if
test=
"productName != null and productName != ''"
>
and sp.product_name like concat('%', #{productName,jdbcType=VARCHAR}, '%')
and sp.product_name like concat('%', #{productName,jdbcType=VARCHAR}, '%')
...
...
src/main/resources/mapper/SmartProductTypeMapper.xml
View file @
ba22447
...
@@ -23,12 +23,8 @@
...
@@ -23,12 +23,8 @@
<select
id=
"getList"
resultMap=
"BaseResultMap"
>
<select
id=
"getList"
resultMap=
"BaseResultMap"
>
select spt.id, spt.type_name, spt.category_key, spt.shop_tag, spt.remark, spt.create_time,
select spt.id, spt.type_name, spt.category_key, spt.shop_tag, spt.remark, spt.create_time,
spt.create_by, spt.update_time, spt.update_by,
spt.create_by, spt.update_time, spt.update_by
ssc2.dict_value categoryName2,
ssc1.dict_value categoryName1
from smart_product_type spt
from smart_product_type spt
left join smart_sys_code ssc2 on ssc2.dict_key = spt.category_key
left join smart_sys_code ssc1 on ssc1.dict_key = ssc2.parent_key
<where>
<where>
<if
test=
"typeName != null and typeName != ''"
>
<if
test=
"typeName != null and typeName != ''"
>
and spt.type_name like concat('%', #{typeName,jdbcType=VARCHAR}, '%')
and spt.type_name like concat('%', #{typeName,jdbcType=VARCHAR}, '%')
...
...
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