ApiMgrController.java
1.77 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
package com.glsx.controller;
import cn.com.glsx.openplatform.model.PlatformApi;
import cn.com.glsx.openplatform.service.ApiMgrService;
import cn.com.glsx.openplatform.vo.R;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.oreframework.web.ui.Pagination;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
//@Api
@RestController
@RequestMapping(value = "/apimgr")
public class ApiMgrController {
/**
* 日志
*/
private final static Logger LOGGER = LoggerFactory.getLogger(ApiMgrController.class);
@Autowired
private ApiMgrService apiMgrService;
@RequestMapping(value = "/getApiMgrList", method = RequestMethod.GET)
@ResponseBody
public R getApiMgrList(Pagination pagination) {
//PageHelper注入分页和要分页的查询之前不能有其它查询,不然分页到第一个查询上面
Page<PlatformApi> page = PageHelper.startPage(pagination.getCurrentPage(), pagination.getPageSize(), true);
List<PlatformApi> apiMgrList = apiMgrService.getApiMgrList();
return R.ok().putPageData(page, apiMgrList);
}
@RequestMapping(value = "/startandstop", method = RequestMethod.GET)
@ResponseBody
public R startAndStop(int id, int status) {
int num = apiMgrService.startAndStop(id, status);
if (num == 0) {
return R.error("API使用状态修改失败");
}
return R.ok("API使用状态修改成功");
}
}