Skip to content

Commit b97cea1

Browse files
committed
分离api
1 parent 1928c27 commit b97cea1

File tree

19 files changed

+28
-322
lines changed

19 files changed

+28
-322
lines changed

api/pom.xml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,17 @@
1717
<artifactId>core</artifactId>
1818
<version>1.0.0-SNAPSHOT</version>
1919
</dependency>
20+
<dependency>
21+
<groupId>org.springframework.boot</groupId>
22+
<artifactId>spring-boot-starter-data-jpa</artifactId>
23+
</dependency>
2024
<dependency>
2125
<groupId>io.springfox</groupId>
2226
<artifactId>springfox-swagger-ui</artifactId>
2327
</dependency>
2428
<dependency>
25-
<groupId>org.springframework.boot</groupId>
26-
<artifactId>spring-boot-starter-data-jpa</artifactId>
29+
<groupId>io.springfox</groupId>
30+
<artifactId>springfox-swagger2</artifactId>
2731
</dependency>
2832
</dependencies>
2933

core/pom.xml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,6 @@
6767
<groupId>org.projectlombok</groupId>
6868
<artifactId>lombok</artifactId>
6969
</dependency>
70-
<dependency>
71-
<groupId>io.springfox</groupId>
72-
<artifactId>springfox-swagger2</artifactId>
73-
</dependency>
7470
<dependency>
7571
<groupId>dom4j</groupId>
7672
<artifactId>dom4j</artifactId>

core/src/main/java/info/xiaomo/core/controller/Result.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package info.xiaomo.core.controller;
22

33
import com.fasterxml.jackson.annotation.JsonInclude;
4-
import io.swagger.annotations.ApiModel;
5-
import io.swagger.annotations.ApiModelProperty;
64
import lombok.Data;
75

86
/**
@@ -20,17 +18,13 @@
2018
* @Copyright(©) 2015 by xiaomo.
2119
*/
2220
@Data
23-
@ApiModel("返回结果")
2421
@JsonInclude(JsonInclude.Include.NON_EMPTY)
2522
public class Result {
2623

27-
@ApiModelProperty(value = "返回码")
2824
private int code;
2925

30-
@ApiModelProperty(value = "返回消息")
3126
private String message;
3227

33-
@ApiModelProperty(value = "返回数据")
3428
private Object data;
3529

3630
/**

mongodb/pom.xml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<project xmlns="http://maven.apache.org/POM/4.0.0"
3-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xmlns="http://maven.apache.org/POM/4.0.0"
44
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
55
<parent>
66
<artifactId>xiaomo</artifactId>
@@ -24,6 +24,10 @@
2424
<groupId>io.springfox</groupId>
2525
<artifactId>springfox-swagger-ui</artifactId>
2626
</dependency>
27+
<dependency>
28+
<groupId>io.springfox</groupId>
29+
<artifactId>springfox-swagger2</artifactId>
30+
</dependency>
2731
</dependencies>
2832
<build>
2933
<plugins>

website/src/main/java/info/xiaomo/website/controller/AdminUserController.java

Lines changed: 0 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@
88
import info.xiaomo.core.untils.RandomUtil;
99
import info.xiaomo.website.model.AdminModel;
1010
import info.xiaomo.website.service.AdminUserService;
11-
import io.swagger.annotations.*;
1211
import org.springframework.beans.factory.annotation.Autowired;
13-
import org.springframework.http.MediaType;
1412
import org.springframework.web.bind.annotation.*;
1513

1614
import java.util.List;
@@ -39,7 +37,6 @@
3937
*/
4038
@RestController
4139
@RequestMapping("/adminUser")
42-
@Api(value = "AdminUserController", description = "后台用户相关api")
4340
public class AdminUserController extends BaseController {
4441

4542
private final AdminUserService service;
@@ -55,15 +52,6 @@ public AdminUserController(AdminUserService service) {
5552
* @return Result
5653
*/
5754
@RequestMapping(value = "login/{userName}/{password}", method = RequestMethod.POST)
58-
@ApiOperation(value = "获取用户信息", notes = "根据用户帐号和密码登录后台", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
59-
@ApiImplicitParams({
60-
@ApiImplicitParam(name = "userName", value = "用户名", required = true, dataType = "Result", paramType = "path"),
61-
@ApiImplicitParam(name = "password", value = "用户名", required = true, dataType = "Result", paramType = "path")
62-
})
63-
@ApiResponses(value = {
64-
@ApiResponse(code = 404, message = "Not Found"),
65-
@ApiResponse(code = 400, message = "No Name Provided"),
66-
})
6755
public Result login(@PathVariable("userName") String userName, @PathVariable("password") String password) {
6856
AdminModel adminModel = service.findAdminUserByUserName(userName);
6957
if (adminModel == null) {
@@ -81,12 +69,7 @@ public Result login(@PathVariable("userName") String userName, @PathVariable("pa
8169
*
8270
* @return Result
8371
*/
84-
@ApiOperation(value = "添加后台用户", notes = "传一个管理员用户模型过来然后保存到数据库", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
8572
@RequestMapping(value = "add", method = RequestMethod.POST)
86-
@ApiResponses(value = {
87-
@ApiResponse(code = 404, message = "Not Found"),
88-
@ApiResponse(code = 400, message = "No Name Provided"),
89-
})
9073
public Result add(@RequestBody AdminModel model) {
9174
AdminModel adminModel = service.findAdminUserByUserName(model.getUserName());
9275
if (adminModel != null) {
@@ -105,15 +88,7 @@ public Result add(@RequestBody AdminModel model) {
10588
* @param id id
10689
* @return Result
10790
*/
108-
@ApiOperation(value = "查找用户", notes = "根据传来的id查找用户并返回", httpMethod = "GET", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
10991
@RequestMapping(value = "findById/{id}", method = RequestMethod.GET)
110-
@ApiImplicitParams({
111-
@ApiImplicitParam(name = "id", value = "后台用户唯一id", required = true, dataType = "Long", paramType = "path")
112-
})
113-
@ApiResponses(value = {
114-
@ApiResponse(code = 404, message = "Not Found"),
115-
@ApiResponse(code = 400, message = "No Name Provided"),
116-
})
11792
public Result findUserById(@PathVariable("id") Long id) {
11893
AdminModel adminModel = service.findAdminUserById(id);
11994
if (adminModel == null) {
@@ -128,15 +103,7 @@ public Result findUserById(@PathVariable("id") Long id) {
128103
* @param userName userName
129104
* @return Result
130105
*/
131-
@ApiOperation(value = "查找用户", notes = "根据传来的用户名查找用户并返回", httpMethod = "GET", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
132106
@RequestMapping(value = "findByName/{userName}", method = RequestMethod.GET)
133-
@ApiImplicitParams({
134-
@ApiImplicitParam(name = "userName", value = "用户名", required = true, dataType = "String", paramType = "path")
135-
})
136-
@ApiResponses(value = {
137-
@ApiResponse(code = 404, message = "Not Found"),
138-
@ApiResponse(code = 400, message = "No Name Provided"),
139-
})
140107
public Result findByName(@PathVariable("userName") String userName) {
141108
AdminModel adminModel = service.findAdminUserByUserName(userName);
142109
if (adminModel == null) {
@@ -152,11 +119,6 @@ public Result findByName(@PathVariable("userName") String userName) {
152119
* @throws UserNotFoundException UserNotFoundException
153120
*/
154121
@RequestMapping(value = "changePassword", method = RequestMethod.POST)
155-
@ApiOperation(value = "修改用户密码", notes = "传来模型验证并修改密码", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
156-
@ApiResponses(value = {
157-
@ApiResponse(code = 404, message = "Not Found"),
158-
@ApiResponse(code = 400, message = "No Name Provided"),
159-
})
160122
public Result changePassword(@RequestBody AdminModel model) throws UserNotFoundException {
161123
AdminModel adminModel = service.findAdminUserByUserName(model.getUserName());
162124
if (adminModel == null) {
@@ -176,11 +138,6 @@ public Result changePassword(@RequestBody AdminModel model) throws UserNotFoundE
176138
* @return 不分页
177139
*/
178140
@RequestMapping(value = "findAll", method = RequestMethod.GET)
179-
@ApiOperation(value = "返回所有用户信息", notes = "不分页", httpMethod = "GET", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
180-
@ApiResponses(value = {
181-
@ApiResponse(code = 404, message = "Not Found"),
182-
@ApiResponse(code = 400, message = "No Name Provided"),
183-
})
184141
public Result getAll() {
185142
List<AdminModel> pages = service.getAdminUsers();
186143
if (pages == null || pages.size() <= 0) {
@@ -197,14 +154,6 @@ public Result getAll() {
197154
* @throws UserNotFoundException UserNotFoundException
198155
*/
199156
@RequestMapping(value = "delete/{id}", method = RequestMethod.GET)
200-
@ApiOperation(value = "删除用户", notes = "根据传入的id删除对应的用户", httpMethod = "GET", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
201-
@ApiImplicitParams({
202-
@ApiImplicitParam(name = "id", value = "用户唯一id", required = true, dataType = "Long", paramType = "path")
203-
})
204-
@ApiResponses(value = {
205-
@ApiResponse(code = 404, message = "Not Found"),
206-
@ApiResponse(code = 400, message = "No Name Provided"),
207-
})
208157
public Result deleteUserById(@PathVariable("id") Long id) throws UserNotFoundException {
209158
AdminModel adminModel = service.findAdminUserById(id);
210159
if (adminModel == null) {
@@ -222,14 +171,6 @@ public Result deleteUserById(@PathVariable("id") Long id) throws UserNotFoundExc
222171
* @throws UserNotFoundException UserNotFoundException
223172
*/
224173
@RequestMapping(value = "update/{userName}", method = RequestMethod.POST)
225-
@ApiOperation(value = "更新用户信息", notes = "根据传入的模型更新用户信息", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
226-
@ApiImplicitParams({
227-
@ApiImplicitParam(name = "userName", value = "用户名", required = true, dataType = "String", paramType = "path")
228-
})
229-
@ApiResponses(value = {
230-
@ApiResponse(code = 404, message = "Not Found"),
231-
@ApiResponse(code = 400, message = "No Name Provided"),
232-
})
233174
public Result update(@PathVariable("userName") String userName) throws UserNotFoundException {
234175
AdminModel adminModel = service.findAdminUserByUserName(userName);
235176
if (adminModel == null) {
@@ -248,14 +189,6 @@ public Result update(@PathVariable("userName") String userName) throws UserNotFo
248189
* @throws UserNotFoundException UserNotFoundException
249190
*/
250191
@RequestMapping(value = "forbid/{id}", method = RequestMethod.GET)
251-
@ApiOperation(value = "封号", notes = "根据传入的id对修改对应帐号状态", httpMethod = "GET", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
252-
@ApiImplicitParams({
253-
@ApiImplicitParam(name = "id", value = "后台用户唯一id", required = true, dataType = "Long", paramType = "path")
254-
})
255-
@ApiResponses(value = {
256-
@ApiResponse(code = 404, message = "Not Found"),
257-
@ApiResponse(code = 400, message = "No Name Provided"),
258-
})
259192
public Result forbid(@PathVariable("id") Long id) throws UserNotFoundException {
260193
AdminModel model = service.findAdminUserById(id);
261194
if (model == null) {

website/src/main/java/info/xiaomo/website/controller/ChangeLogController.java

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,7 @@
55
import info.xiaomo.core.controller.Result;
66
import info.xiaomo.website.model.ChangeLogModel;
77
import info.xiaomo.website.service.ChangeLogService;
8-
import io.swagger.annotations.Api;
9-
import io.swagger.annotations.ApiImplicitParam;
10-
import io.swagger.annotations.ApiImplicitParams;
11-
import io.swagger.annotations.ApiOperation;
128
import org.springframework.beans.factory.annotation.Autowired;
13-
import org.springframework.http.MediaType;
149
import org.springframework.web.bind.annotation.*;
1510

1611
import java.util.List;
@@ -31,7 +26,6 @@
3126
**/
3227
@RestController
3328
@RequestMapping("/changeLog")
34-
@Api(value = "ChangeLogController",description = "更新日志相关api")
3529
public class ChangeLogController extends BaseController {
3630

3731
private final ChangeLogService service;
@@ -47,11 +41,7 @@ public ChangeLogController(ChangeLogService service) {
4741
* @param id id
4842
* @return model
4943
*/
50-
@RequestMapping(value = "findById/{id}",method = RequestMethod.GET)
51-
@ApiOperation(value = "通过id查找", notes = "通过id查找",httpMethod = "GET", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
52-
@ApiImplicitParams({
53-
@ApiImplicitParam(name = "id", value = "唯一id", required = true, dataType = "Long", paramType = "path")
54-
})
44+
@RequestMapping(value = "findById/{id}", method = RequestMethod.GET)
5545
public Result findById(@PathVariable("id") Long id) {
5646
ChangeLogModel changeLogModel = service.findById(id);
5747
if (changeLogModel == null) {
@@ -66,11 +56,7 @@ public Result findById(@PathVariable("id") Long id) {
6656
* @return result
6757
*/
6858
@RequestMapping(value = "findByName/{name}", method = RequestMethod.GET)
69-
@ApiOperation(value = "通过名字查找", notes = "通过名字查找",httpMethod = "GET", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
70-
@ApiImplicitParams({
71-
@ApiImplicitParam(name = "name", value = "更新日志内容", required = true, dataType = "String", paramType = "path")
72-
})
73-
public Result findByName( @PathVariable("name") String name) {
59+
public Result findByName(@PathVariable("name") String name) {
7460
ChangeLogModel model = service.findByName(name);
7561
if (model == null) {
7662
return new Result(Err.NULL_DATA.getCode(), Err.NULL_DATA.getMessage());
@@ -84,7 +70,6 @@ public Result findByName( @PathVariable("name") String name) {
8470
* @return 分页
8571
*/
8672
@RequestMapping(value = "findAll", method = RequestMethod.GET)
87-
@ApiOperation(value = "分页查询更新日志", notes = "分页查询更新日志",httpMethod = "GET", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
8873
public Result findAll() {
8974
List<ChangeLogModel> pages = service.findAll();
9075
if (pages == null || pages.size() <= 0) {
@@ -98,7 +83,6 @@ public Result findAll() {
9883
*
9984
* @return result
10085
*/
101-
@ApiOperation(value = "增加更新日志", notes = "增加更新日志",httpMethod = "POST", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
10286
@RequestMapping(value = "add", method = RequestMethod.POST)
10387
public Result add(@RequestBody ChangeLogModel model) {
10488
ChangeLogModel changeLogModel = service.findByName(model.getName());
@@ -118,7 +102,6 @@ public Result add(@RequestBody ChangeLogModel model) {
118102
*
119103
* @return result
120104
*/
121-
@ApiOperation(value = "修改更新日志", notes = "修改更新日志",httpMethod = "POST", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
122105
@RequestMapping(value = "update", method = RequestMethod.POST)
123106
public Result update(@RequestBody ChangeLogModel model) {
124107
ChangeLogModel changeLogModel = service.findByName(model.getName());
@@ -136,10 +119,6 @@ public Result update(@RequestBody ChangeLogModel model) {
136119
* 删除更新日志
137120
*/
138121
@RequestMapping(value = "delete/{id}", method = RequestMethod.GET)
139-
@ApiOperation(value = "删除更新日志", notes = "删除更新日志",httpMethod = "GET", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
140-
@ApiImplicitParams({
141-
@ApiImplicitParam(name = "id", value = "唯一id", required = true, dataType = "Long", paramType = "path")
142-
})
143122
public Result deleteById(@PathVariable("id") Long id) {
144123
ChangeLogModel changeLogModel = service.findById(id);
145124
if (changeLogModel == null) {

0 commit comments

Comments
 (0)