mirror of
https://github.com/ClovertaTheTrilobita/SanYeCao-WebAPi.git
synced 2026-04-01 23:14:51 +00:00
feat: 新增Api列表
This commit is contained in:
parent
f1ea269155
commit
80ca4c64ff
4 changed files with 102 additions and 0 deletions
|
|
@ -0,0 +1,25 @@
|
||||||
|
package com.cloverta.webapi.controller;
|
||||||
|
|
||||||
|
import com.cloverta.webapi.model.Api;
|
||||||
|
import com.cloverta.webapi.service.ApiListService;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@ResponseStatus(HttpStatus.OK)
|
||||||
|
@RestController
|
||||||
|
public class ApiListController {
|
||||||
|
private final ApiListService apiListService;
|
||||||
|
|
||||||
|
public ApiListController(ApiListService apiListService) {
|
||||||
|
this.apiListService = apiListService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping("/list")
|
||||||
|
public List<Api> getApiLists() {
|
||||||
|
return apiListService.generateApiList();
|
||||||
|
}
|
||||||
|
}
|
||||||
16
src/main/java/com/cloverta/webapi/mapper/ApiMapper.java
Normal file
16
src/main/java/com/cloverta/webapi/mapper/ApiMapper.java
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
package com.cloverta.webapi.mapper;
|
||||||
|
|
||||||
|
import com.cloverta.webapi.model.Api;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Select;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface ApiMapper {
|
||||||
|
|
||||||
|
@Select("SELECT * FROM api_list")
|
||||||
|
List<Api> findAll();
|
||||||
|
|
||||||
|
}
|
||||||
40
src/main/java/com/cloverta/webapi/model/Api.java
Normal file
40
src/main/java/com/cloverta/webapi/model/Api.java
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
package com.cloverta.webapi.model;
|
||||||
|
|
||||||
|
public class Api {
|
||||||
|
private String name;
|
||||||
|
private String url;
|
||||||
|
private String description;
|
||||||
|
private String manual;
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUrl() {
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUrl(String url) {
|
||||||
|
this.url = url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescription(String description) {
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getManual() {
|
||||||
|
return manual;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setManual(String manual) {
|
||||||
|
this.manual = manual;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
package com.cloverta.webapi.service;
|
||||||
|
|
||||||
|
import com.cloverta.webapi.mapper.ApiMapper;
|
||||||
|
import com.cloverta.webapi.model.Api;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class ApiListService {
|
||||||
|
private final ApiMapper apiMapper;
|
||||||
|
|
||||||
|
public ApiListService(ApiMapper apiMapper) {
|
||||||
|
this.apiMapper = apiMapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Api> generateApiList() {
|
||||||
|
return apiMapper.findAll();
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue