mirror of
https://github.com/CodePhiliaX/Chat2DB.git
synced 2025-07-31 19:52:54 +08:00
Merge branch 'developing' into team
This commit is contained in:
@ -0,0 +1,36 @@
|
||||
package ai.chat2db.server.web.api.controller.sql;
|
||||
|
||||
import ai.chat2db.server.tools.base.wrapper.result.DataResult;
|
||||
import ai.chat2db.server.web.api.aspect.ConnectionInfoAspect;
|
||||
import ai.chat2db.server.web.api.controller.sql.request.SqlFormatRequest;
|
||||
import cn.hutool.db.sql.SqlFormatter;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* SQL Controller
|
||||
*/
|
||||
@ConnectionInfoAspect
|
||||
@RequestMapping("/api/sql")
|
||||
@RestController
|
||||
public class SqlController {
|
||||
|
||||
/**
|
||||
* SQL Format
|
||||
* @param sqlFormatRequest
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/format")
|
||||
public DataResult<String> list(@Valid SqlFormatRequest sqlFormatRequest) {
|
||||
|
||||
String sql = sqlFormatRequest.getSql();
|
||||
try {
|
||||
sql = SqlFormatter.format(sql);
|
||||
} catch (Exception e) {
|
||||
// ignore
|
||||
}
|
||||
return DataResult.of(sql);
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package ai.chat2db.server.web.api.controller.sql.request;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class SqlFormatRequest {
|
||||
|
||||
private String sql;
|
||||
|
||||
private String dbType;
|
||||
}
|
Reference in New Issue
Block a user