Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
ydl-generator
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
余保谷
ydl-generator
Commits
053b02e7
Commit
053b02e7
authored
May 23, 2019
by
flying-cattle
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
返回结果修改
parent
3e852276
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
13 deletions
+41
-13
pom.xml
pom.xml
+1
-1
JsonResult.java
src/main/java/com/github/flying/cattle/mdg/aid/JsonResult.java
+37
-9
AbstractController.ftl
src/main/resources/freemarker/ftl/AbstractController.ftl
+3
-3
No files found.
pom.xml
View file @
053b02e7
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
<groupId>
com.github.flying-cattle
</groupId>
<groupId>
com.github.flying-cattle
</groupId>
<artifactId>
mybatis-dsc-generator
</artifactId>
<artifactId>
mybatis-dsc-generator
</artifactId>
<version>
3.0.
2
.RELEASE
</version>
<version>
3.0.
3
.RELEASE
</version>
<packaging>
jar
</packaging>
<packaging>
jar
</packaging>
<name>
mybatis-dsc-generator
</name>
<name>
mybatis-dsc-generator
</name>
...
...
src/main/java/com/github/flying/cattle/mdg/aid/JsonResult.java
View file @
053b02e7
...
@@ -47,32 +47,47 @@ public class JsonResult<T> implements Serializable{
...
@@ -47,32 +47,47 @@ public class JsonResult<T> implements Serializable{
/**
/**
* <p>返回成功,有数据</p>
* <p>返回成功,有数据</p>
* @param T
* @param message 操作说明
* @return JsonResult<T>
* @param data 对象
* @return JsonResult
*/
*/
public
JsonResult
<
T
>
success
(
T
data
)
{
public
JsonResult
<
T
>
success
(
String
message
,
T
data
)
{
this
.
setCode
(
Const
.
CODE_SUCCESS
);
this
.
setCode
(
Const
.
CODE_SUCCESS
);
this
.
setOperate
(
Const
.
OPERATE_SUCCESS
);
this
.
setOperate
(
Const
.
OPERATE_SUCCESS
);
this
.
setMessage
(
"操作成功!"
);
this
.
setMessage
(
message
);
this
.
setData
(
data
);
this
.
setData
(
data
);
return
this
;
return
this
;
}
}
/**
/**
* <p>返回成功,有数据</p>
* @param data 对象
* @return JsonResult
*/
public
JsonResult
<
T
>
success
(
T
data
)
{
this
.
setCode
(
Const
.
CODE_SUCCESS
);
this
.
setOperate
(
Const
.
OPERATE_SUCCESS
);
this
.
setMessage
(
"操作成功"
);
this
.
setData
(
data
);
return
this
;
}
/**
* <p>返回成功,无数据</p>
* <p>返回成功,无数据</p>
* @param message 操作说明
* @return JsonResult
*/
*/
public
JsonResult
<
T
>
success
()
{
public
JsonResult
<
T
>
success
(
String
message
)
{
this
.
setCode
(
Const
.
CODE_SUCCESS
);
this
.
setCode
(
Const
.
CODE_SUCCESS
);
this
.
setOperate
(
Const
.
OPERATE_SUCCESS
);
this
.
setOperate
(
Const
.
OPERATE_SUCCESS
);
this
.
setMessage
(
"操作成功!"
);
this
.
setMessage
(
message
);
this
.
setData
(
null
);
this
.
setData
(
null
);
return
this
;
return
this
;
}
}
/**
/**
* <p>返回
成功
,无数据</p>
* <p>返回
失败
,无数据</p>
* @param message
* @param message
消息
* @return JsonResult
<T>
* @return JsonResult
*/
*/
public
JsonResult
<
T
>
error
(
String
message
)
{
public
JsonResult
<
T
>
error
(
String
message
)
{
this
.
setCode
(
Const
.
CODE_FAILED
);
this
.
setCode
(
Const
.
CODE_FAILED
);
...
@@ -81,6 +96,19 @@ public class JsonResult<T> implements Serializable{
...
@@ -81,6 +96,19 @@ public class JsonResult<T> implements Serializable{
this
.
setData
(
null
);
this
.
setData
(
null
);
return
this
;
return
this
;
}
}
/**
* <p>返回失败,有数据</p>
* @param message 消息
* @param data 对象
* @return JsonResult
*/
public
JsonResult
<
T
>
error
(
String
message
,
T
data
)
{
this
.
setCode
(
Const
.
CODE_FAILED
);
this
.
setOperate
(
Const
.
OPERATE_FAILED
);
this
.
setMessage
(
message
);
this
.
setData
(
data
);
return
this
;
}
public
JsonResult
(
Throwable
throwable
)
{
public
JsonResult
(
Throwable
throwable
)
{
this
.
operate
=
Const
.
OPERATE_FAILED
;
this
.
operate
=
Const
.
OPERATE_FAILED
;
if
(
throwable
instanceof
NullPointerException
){
if
(
throwable
instanceof
NullPointerException
){
...
...
src/main/resources/freemarker/ftl/AbstractController.ftl
View file @
053b02e7
...
@@ -70,7 +70,7 @@ public class AbstractController<S extends IService<T>,T>{
...
@@ -70,7 +70,7 @@ public class AbstractController<S extends IService<T>,T>{
if
(
null
!=obj) {
if
(
null
!=obj) {
boolean
rsg
=
baseService
.
removeById
(
id
);
boolean
rsg
=
baseService
.
removeById
(
id
);
if
(
rsg
)
{
if
(
rsg
)
{
result
.
success
();
result
.
success
(
"删除成功"
);
}
else
{
}
else
{
result
.
error
(
"删除失败!"
);
result
.
error
(
"删除失败!"
);
}
}
...
@@ -94,7 +94,7 @@ public class AbstractController<S extends IService<T>,T>{
...
@@ -94,7 +94,7 @@ public class AbstractController<S extends IService<T>,T>{
if
(
null
!=entity) {
if
(
null
!=entity) {
boolean
rsg
=
baseService
.
save
(
entity
);
boolean
rsg
=
baseService
.
save
(
entity
);
if
(
rsg
)
{
if
(
rsg
)
{
result
.
success
();
result
.
success
(
"添加成功"
);
}
else
{
}
else
{
result
.
error
(
"添加失败!"
);
result
.
error
(
"添加失败!"
);
}
}
...
@@ -118,7 +118,7 @@ public class AbstractController<S extends IService<T>,T>{
...
@@ -118,7 +118,7 @@ public class AbstractController<S extends IService<T>,T>{
if
(
null
!=entity) {
if
(
null
!=entity) {
boolean
rsg
=
baseService
.
updateById
(
entity
);
boolean
rsg
=
baseService
.
updateById
(
entity
);
if
(
rsg
)
{
if
(
rsg
)
{
result
.
success
();
result
.
success
(
"修改成功"
);
}
else
{
}
else
{
result
.
error
(
"修改失败!"
);
result
.
error
(
"修改失败!"
);
}
}
...
...
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