Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
holmes
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
QA
holmes
Commits
7cbbdd2f
Commit
7cbbdd2f
authored
Apr 09, 2021
by
黎博
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增模块相关接口
parent
57f0575a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
75 additions
and
5 deletions
+75
-5
AutoModuleController.java
...va/cn/qg/holmes/controller/auto/AutoModuleController.java
+74
-5
AutoModule.java
src/main/java/cn/qg/holmes/entity/auto/AutoModule.java
+1
-0
No files found.
src/main/java/cn/qg/holmes/controller/auto/AutoModuleController.java
View file @
7cbbdd2f
package
cn
.
qg
.
holmes
.
controller
.
auto
;
import
cn.qg.holmes.common.JsonResult
;
import
cn.qg.holmes.entity.auto.AutoModule
;
import
cn.qg.holmes.service.auto.AutoModuleService
;
import
cn.qg.holmes.service.auto.ProjectService
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.
CrossOrigin
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.
*
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
* 接口自动化模块controller
...
...
@@ -20,8 +25,72 @@ public class AutoModuleController {
@Autowired
AutoModuleService
autoModuleService
;
@Autowired
ProjectService
projectService
;
/**
* 获取接口自动化模块列表
* @param pageNum 第几页
* @param pageSize 每页第几个
* @return
*/
@GetMapping
(
"/list"
)
public
JsonResult
getAutoModuleList
(
Integer
pageNum
,
Integer
pageSize
)
{
return
null
;
IPage
<
AutoModule
>
autoModuleIPage
=
new
Page
<>(
pageNum
,
pageSize
);
IPage
<
AutoModule
>
autoModuleEntity
=
autoModuleService
.
page
(
autoModuleIPage
);
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"total"
,
autoModuleEntity
.
getTotal
());
map
.
put
(
"list"
,
autoModuleEntity
.
getRecords
());
return
JsonResult
.
buildSuccessResult
(
map
);
}
/**
* 新增模块
* @param autoModule AutoModule实体类
* @return
*/
@PostMapping
(
"/add"
)
public
JsonResult
addAutoModule
(
@RequestBody
AutoModule
autoModule
)
{
QueryWrapper
<
AutoModule
>
queryWrapper
=
new
QueryWrapper
<>();
queryWrapper
.
eq
(
"name"
,
autoModule
.
getName
());
if
(
projectService
.
getById
(
autoModule
.
getProjectId
())
==
null
)
{
return
JsonResult
.
buildErrorStateResult
(
"所选项目不存在!"
,
false
);
}
else
if
(
autoModuleService
.
getOne
(
queryWrapper
)
!=
null
)
{
return
JsonResult
.
buildErrorStateResult
(
"模块已存在!"
,
false
);
}
else
{
return
JsonResult
.
buildSuccessResult
(
autoModuleService
.
save
(
autoModule
));
}
}
/**
* 修改模块
* @param autoModule AutoModule实体类
* @return
*/
@PostMapping
(
"/modify"
)
public
JsonResult
editAutoModule
(
@RequestBody
AutoModule
autoModule
)
{
QueryWrapper
<
AutoModule
>
queryWrapper
=
new
QueryWrapper
<>();
queryWrapper
.
eq
(
"name"
,
autoModule
.
getName
());
queryWrapper
.
ne
(
"id"
,
autoModule
.
getId
());
if
(
autoModuleService
.
getById
(
autoModule
.
getId
())
==
null
)
{
return
JsonResult
.
buildErrorStateResult
(
"模块不存在!"
,
false
);
}
else
if
(
autoModuleService
.
getOne
(
queryWrapper
)
!=
null
)
{
return
JsonResult
.
buildErrorStateResult
(
"该模块名已存在!"
,
false
);
}
else
{
return
JsonResult
.
buildSuccessResult
(
autoModuleService
.
updateById
(
autoModule
));
}
}
/**
* 删除模块
* @param moduleId 模块id
*/
@GetMapping
(
"/delete"
)
public
JsonResult
deleteAutoModule
(
@RequestParam
Integer
moduleId
)
{
if
(
autoModuleService
.
getById
(
moduleId
)
==
null
)
{
return
JsonResult
.
buildErrorStateResult
(
"模块不存在"
,
false
);
}
else
{
return
JsonResult
.
buildSuccessResult
(
autoModuleService
.
removeById
(
moduleId
));
}
}
}
src/main/java/cn/qg/holmes/entity/auto/AutoModule.java
View file @
7cbbdd2f
...
...
@@ -20,6 +20,7 @@ public class AutoModule {
private
String
name
;
private
String
description
;
private
String
domain
;
private
Integer
projectId
;
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
private
Date
createTime
;
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
...
...
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