TestController.java
3.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
package com.huaheng.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.huaheng.framework.web.controller.BaseController;
import com.huaheng.framework.web.domain.AjaxResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
/**
* swagger 测试方法
*
* @author huaheng
*/
@Api("用户信息管理")
@RestController
@RequestMapping("/test/*")
public class TestController extends BaseController
{
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 AjaxResult save(Test test)
{
return testList.add(test) ? success() : error();
}
@ApiOperation("更新用户")
@ApiImplicitParam(name = "Test", value = "单个用户信息", dataType = "Test")
@PutMapping("update")
public AjaxResult update(Test test)
{
return testList.remove(test) && testList.add(test) ? success() : error();
}
@ApiOperation("删除用户")
@ApiImplicitParam(name = "Tests", value = "单个用户信息", dataType = "Test")
@DeleteMapping("delete")
public AjaxResult delete(Test test)
{
return testList.remove(test) ? success() : 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;
}
}