feat: 新增Api列表

This commit is contained in:
ClovertaTheTrilobita 2025-04-15 20:55:12 +08:00
parent f1ea269155
commit 80ca4c64ff
4 changed files with 102 additions and 0 deletions

View file

@ -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();
}
}

View 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();
}

View 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;
}
}

View file

@ -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();
}
}