Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
fgqyxxlr
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
yaru
fgqyxxlr
Commits
4bc46c5f
Commit
4bc46c5f
authored
May 31, 2018
by
RuoYi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
swagger 测试方法
parent
8d71859e
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
138 additions
and
21 deletions
+138
-21
src/main/java/com/ruoyi/framework/config/ResourcesConfig.java
+1
-0
src/main/java/com/ruoyi/framework/config/SwaggerConfig.java
+1
-1
src/main/java/com/ruoyi/project/tool/swagger/TestController.java
+136
-0
src/test/java/com/ruoyi/RuoYiApplicationTests.java
+0
-20
No files found.
src/main/java/com/ruoyi/framework/config/ResourcesConfig.java
View file @
4bc46c5f
...
...
@@ -35,6 +35,7 @@ public class ResourcesConfig extends WebMvcConfigurerAdapter
@Override
public
void
addResourceHandlers
(
ResourceHandlerRegistry
registry
)
{
/** 头像上传路径 */
registry
.
addResourceHandler
(
"/profile/**"
).
addResourceLocations
(
"file:"
+
RuoYiConfig
.
getProfile
());
/** swagger配置 */
...
...
src/main/java/com/ruoyi/framework/config/SwaggerConfig.java
View file @
4bc46c5f
...
...
@@ -36,7 +36,7 @@ public class SwaggerConfig
.
apiInfo
(
apiInfo
())
.
select
()
// 指定当前包路径
.
apis
(
RequestHandlerSelectors
.
basePackage
(
"com.ruoyi.project.
system.post.controll
er"
))
.
apis
(
RequestHandlerSelectors
.
basePackage
(
"com.ruoyi.project.
tool.swagg
er"
))
// 扫描所有 .apis(RequestHandlerSelectors.any())
.
paths
(
PathSelectors
.
any
())
.
build
();
...
...
src/main/java/com/ruoyi/project/tool/swagger/TestController.java
0 → 100644
View file @
4bc46c5f
package
com
.
ruoyi
.
project
.
tool
.
swagger
;
import
java.util.ArrayList
;
import
java.util.List
;
import
org.springframework.web.bind.annotation.DeleteMapping
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.PutMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.ruoyi.framework.web.domain.Message
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiOperation
;
/**
* swagger 测试方法
*
* @author ruoyi
*/
@Api
(
"用户信息管理"
)
@RestController
@RequestMapping
(
"/test/*"
)
public
class
TestController
{
private
final
static
List
<
Test
>
testList
=
new
ArrayList
<>();
{
testList
.
add
(
new
Test
(
"1"
,
"admin"
,
"admin123"
));
testList
.
add
(
new
Test
(
"2"
,
"ry"
,
"admin123"
));
}
@ApiOperation
(
"获取列表"
)
@GetMapping
(
"list"
)
public
List
<
Test
>
testList
()
{
return
testList
;
}
@ApiOperation
(
"新增用户"
)
@PostMapping
(
"save"
)
public
Message
save
(
Test
Test
)
{
return
testList
.
add
(
Test
)
?
Message
.
success
()
:
Message
.
error
();
}
@ApiOperation
(
"更新用户"
)
@ApiImplicitParam
(
name
=
"Test"
,
value
=
"单个用户信息"
,
dataType
=
"Test"
)
@PutMapping
(
"update"
)
public
Message
update
(
Test
Test
)
{
return
testList
.
remove
(
Test
)
&&
testList
.
add
(
Test
)
?
Message
.
success
()
:
Message
.
error
();
}
@ApiOperation
(
"删除用户"
)
@ApiImplicitParam
(
name
=
"Tests"
,
value
=
"单个用户信息"
,
dataType
=
"Test"
)
@DeleteMapping
(
"delete"
)
public
Message
delete
(
Test
test
)
{
return
testList
.
remove
(
test
)
?
Message
.
success
()
:
Message
.
error
();
}
}
class
Test
{
private
String
userId
;
private
String
username
;
private
String
password
;
public
Test
()
{
}
public
Test
(
String
userId
,
String
username
,
String
password
)
{
this
.
userId
=
userId
;
this
.
username
=
username
;
this
.
password
=
password
;
}
@Override
public
boolean
equals
(
Object
o
)
{
if
(
this
==
o
)
{
return
true
;
}
if
(
o
==
null
||
getClass
()
!=
o
.
getClass
())
{
return
false
;
}
Test
test
=
(
Test
)
o
;
return
userId
!=
null
?
userId
.
equals
(
test
.
userId
)
:
test
.
userId
==
null
;
}
@Override
public
int
hashCode
()
{
int
result
=
userId
!=
null
?
userId
.
hashCode
()
:
0
;
result
=
31
*
result
+
(
username
!=
null
?
username
.
hashCode
()
:
0
);
result
=
31
*
result
+
(
password
!=
null
?
password
.
hashCode
()
:
0
);
return
result
;
}
public
String
getUserId
()
{
return
userId
;
}
public
void
setUserId
(
String
userId
)
{
this
.
userId
=
userId
;
}
public
String
getUsername
()
{
return
username
;
}
public
void
setUsername
(
String
username
)
{
this
.
username
=
username
;
}
public
String
getPassword
()
{
return
password
;
}
public
void
setPassword
(
String
password
)
{
this
.
password
=
password
;
}
}
src/test/java/com/ruoyi/RuoYiApplicationTests.java
deleted
100644 → 0
View file @
8d71859e
package
com
.
ruoyi
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.test.context.junit4.SpringRunner
;
/**
* 测试类
*/
@RunWith
(
SpringRunner
.
class
)
@SpringBootTest
public
class
RuoYiApplicationTests
{
@Test
public
void
contextLoads
()
{
}
}
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