mirror of
https://github.com/CodePhiliaX/Chat2DB.git
synced 2025-07-29 10:43:06 +08:00
Complete the datasource code
This commit is contained in:
@ -22,6 +22,10 @@
|
||||
<groupId>ai.chat2db</groupId>
|
||||
<artifactId>chat2db-server-domain-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
@ -0,0 +1,42 @@
|
||||
|
||||
package ai.chat2db.server.common.api.controller;
|
||||
|
||||
import ai.chat2db.server.common.api.controller.converter.EnvironmentCommonConverter;
|
||||
import ai.chat2db.server.common.api.controller.vo.SimpleEnvironmentVO;
|
||||
import ai.chat2db.server.domain.api.param.EnvironmentPageQueryParam;
|
||||
import ai.chat2db.server.domain.api.service.EnvironmentService;
|
||||
import ai.chat2db.server.tools.base.wrapper.result.ListResult;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* Some general data queries
|
||||
*
|
||||
* @author Jiaju Zhuang
|
||||
*/
|
||||
@RequestMapping("/api/common")
|
||||
@RestController
|
||||
public class CommonCommonController {
|
||||
|
||||
@Resource
|
||||
private EnvironmentService environmentService;
|
||||
@Resource
|
||||
private EnvironmentCommonConverter environmentCommonConverter;
|
||||
|
||||
/**
|
||||
* Query all environments
|
||||
*
|
||||
* @return
|
||||
* @version 2.1.0
|
||||
*/
|
||||
@GetMapping("/environment/list_all")
|
||||
public ListResult<SimpleEnvironmentVO> environmentList() {
|
||||
EnvironmentPageQueryParam environmentPageQueryParam = new EnvironmentPageQueryParam();
|
||||
environmentPageQueryParam.setPageSize(Integer.MIN_VALUE);
|
||||
return ListResult.of(
|
||||
environmentCommonConverter.dto2vo(environmentService.pageQuery(environmentPageQueryParam).getData()));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package ai.chat2db.server.common.api.controller.converter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import ai.chat2db.server.common.api.controller.vo.SimpleEnvironmentVO;
|
||||
import ai.chat2db.server.domain.api.model.Environment;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.mapstruct.Mapper;
|
||||
|
||||
/**
|
||||
* converter
|
||||
*
|
||||
* @author Jiaju Zhuang
|
||||
*/
|
||||
@Slf4j
|
||||
@Mapper(componentModel = "spring")
|
||||
public abstract class EnvironmentCommonConverter {
|
||||
|
||||
|
||||
/**
|
||||
* convert
|
||||
*
|
||||
* @param list
|
||||
* @return
|
||||
*/
|
||||
public abstract List<SimpleEnvironmentVO> dto2vo(List<Environment> list);
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
|
||||
package ai.chat2db.server.common.api.controller.request;
|
||||
|
||||
import ai.chat2db.server.tools.base.wrapper.request.PageQueryRequest;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* Common pagination query
|
||||
*
|
||||
* @author Jiaju Zhuang
|
||||
*/
|
||||
@Data
|
||||
public class CommonPageQueryRequest extends PageQueryRequest {
|
||||
|
||||
/**
|
||||
* searchKey
|
||||
*/
|
||||
private String searchKey;
|
||||
}
|
@ -19,7 +19,7 @@ import lombok.experimental.SuperBuilder;
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class EnvironmentVO implements Serializable {
|
||||
public class SimpleEnvironmentVO implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = EasyToolsConstant.SERIAL_VERSION_UID;
|
Reference in New Issue
Block a user