Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
I
indicators
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhangkb
indicators
Commits
881a6658
Commit
881a6658
authored
Aug 03, 2020
by
zhangkb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
自定义异常
parent
67c93692
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
6 deletions
+18
-6
IndCatalogCtrl.java
...om/keymobile/indicators/api/hytobacco/IndCatalogCtrl.java
+2
-2
ApiException.java
...java/com/keymobile/indicators/exception/ApiException.java
+11
-0
IndCatalogService.java
...obile/indicators/service/hytobacco/IndCatalogService.java
+5
-4
No files found.
src/main/java/com/keymobile/indicators/api/hytobacco/IndCatalogCtrl.java
View file @
881a6658
...
...
@@ -12,6 +12,7 @@ import org.springframework.web.bind.annotation.ResponseStatus;
import
org.springframework.web.bind.annotation.RestController
;
import
com.keymobile.indicators.constant.Constants
;
import
com.keymobile.indicators.exception.ApiException
;
import
com.keymobile.indicators.model.entity.indicators.DriveIndCatalog
;
import
com.keymobile.indicators.model.entity.indicators.IndCatalog
;
import
com.keymobile.indicators.service.hytobacco.DriveIndCatalogService
;
...
...
@@ -31,9 +32,8 @@ public class IndCatalogCtrl {
private
DriveIndCatalogService
driveIndCatalogService
;
@ApiOperation
(
value
=
"新建基础指标目录"
,
notes
=
"新建基础指标目录"
)
@ResponseStatus
(
value
=
HttpStatus
.
INTERNAL_SERVER_ERROR
)
@PostMapping
(
value
=
"/createBaseIndCatalog"
)
public
Integer
createBaseIndCatalog
(
@RequestBody
IndCatalog
indCatalog
)
throws
Exception
{
public
Integer
createBaseIndCatalog
(
@RequestBody
IndCatalog
indCatalog
)
throws
Api
Exception
{
String
message
=
null
;
if
(
indCatalog
.
getId
()==
null
)
{
message
=
"新增基础项目录:{}"
;
...
...
src/main/java/com/keymobile/indicators/exception/ApiException.java
0 → 100644
View file @
881a6658
package
com
.
keymobile
.
indicators
.
exception
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.web.bind.annotation.ResponseStatus
;
@ResponseStatus
(
value
=
HttpStatus
.
INTERNAL_SERVER_ERROR
)
public
class
ApiException
extends
Exception
{
public
ApiException
(
String
msg
)
{
super
(
msg
);
}
}
src/main/java/com/keymobile/indicators/service/hytobacco/IndCatalogService.java
View file @
881a6658
...
...
@@ -11,6 +11,7 @@ import org.slf4j.LoggerFactory;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
com.keymobile.indicators.exception.ApiException
;
import
com.keymobile.indicators.model.entity.indicators.IndCatalog
;
import
com.keymobile.indicators.model.mapper.indicators.BaseIndDefMapper
;
import
com.keymobile.indicators.model.mapper.indmapper.IndCatalogMapper
;
...
...
@@ -24,11 +25,11 @@ public class IndCatalogService {
@Autowired
private
BaseIndDefMapper
baseIndDefMapper
;
public
IndCatalog
saveOrUpdate
(
IndCatalog
indCatalog
)
throws
Exception
{
public
IndCatalog
saveOrUpdate
(
IndCatalog
indCatalog
)
throws
Api
Exception
{
if
(
indCatalog
.
getId
()==
null
)
{
//新增
if
(!
indCatalogMapper
.
findIsExist
(
indCatalog
.
getCatalogName
(),
indCatalog
.
getParentId
(),
indCatalog
.
getCode
()).
isEmpty
())
{
throw
new
Exception
(
"存在同名目录"
);
throw
new
Api
Exception
(
"存在同名目录"
);
}
//保存
indCatalogMapper
.
insert
(
indCatalog
);
...
...
@@ -36,7 +37,7 @@ public class IndCatalogService {
List
<
IndCatalog
>
dbList
=
indCatalogMapper
.
findIsExist
(
indCatalog
.
getCatalogName
(),
indCatalog
.
getParentId
(),
indCatalog
.
getCode
());
if
(!
dbList
.
isEmpty
()
&&
!
dbList
.
get
(
0
).
getId
().
equals
(
indCatalog
.
getId
()))
{
throw
new
Exception
(
"存在同名目录"
);
throw
new
Api
Exception
(
"存在同名目录"
);
}
}
//获取parentId拼接idPath
...
...
@@ -46,7 +47,7 @@ public class IndCatalogService {
}
else
{
IndCatalog
parentIndCatalog
=
indCatalogMapper
.
selectByPrimaryKey
(
indCatalog
.
getParentId
());
if
(
parentIndCatalog
==
null
)
{
throw
new
Exception
(
"父节点不存在:parent catalog is not exist"
);
throw
new
Api
Exception
(
"父节点不存在:parent catalog is not exist"
);
}
else
{
indCatalog
.
setIdPath
(
parentIndCatalog
.
getIdPath
()+
indCatalog
.
getId
()+
";"
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment