-
Notifications
You must be signed in to change notification settings - Fork 70
feat: implement model-driven data API with dynamic SQL operations #290
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
9b6ddf3
ee7219f
611f627
a659ab8
c7f5dbf
925a9dd
21999e0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,117 @@ | ||
| package com.tinyengine.it.dynamic.controller; | ||
|
|
||
| import com.tinyengine.it.common.base.Result; | ||
| import com.tinyengine.it.common.log.SystemControllerLog; | ||
| import com.tinyengine.it.dynamic.dto.DynamicDelete; | ||
| import com.tinyengine.it.dynamic.dto.DynamicInsert; | ||
| import com.tinyengine.it.dynamic.dto.DynamicQuery; | ||
| import com.tinyengine.it.dynamic.dto.DynamicUpdate; | ||
| import com.tinyengine.it.dynamic.service.DynamicService; | ||
| import io.swagger.v3.oas.annotations.Operation; | ||
| import io.swagger.v3.oas.annotations.media.Content; | ||
| import io.swagger.v3.oas.annotations.media.Schema; | ||
| import io.swagger.v3.oas.annotations.responses.ApiResponse; | ||
| import io.swagger.v3.oas.annotations.tags.Tag; | ||
| import jakarta.validation.Valid; | ||
| import lombok.extern.slf4j.Slf4j; | ||
| import org.springframework.beans.factory.annotation.Autowired; | ||
| import org.springframework.validation.annotation.Validated; | ||
| import org.springframework.web.bind.annotation.*; | ||
|
|
||
| import java.util.Map; | ||
|
|
||
| @Validated | ||
| @Slf4j | ||
| @RestController | ||
| @RequestMapping("/platform-center/api") | ||
| @Tag(name = "模型数据") | ||
| public class ModelDataController { | ||
| @Autowired | ||
| private DynamicService dynamicService; | ||
|
|
||
| /** | ||
| * 模型数据查询 | ||
| * | ||
| * @return 返回值 all | ||
| */ | ||
| @Operation(summary = "模型数据查询", description = "模型数据查询", responses = { | ||
| @ApiResponse(responseCode = "200", description = "返回信息", | ||
| content = @Content(mediaType = "application/json",schema = @Schema(implementation = Map.class))), | ||
| @ApiResponse(responseCode = "400", description = "请求失败") | ||
| }) | ||
| @SystemControllerLog(description = "模型数据查询") | ||
| @PostMapping("/model-data/queryApi") | ||
| public Result<Map<String, Object>> query(@RequestBody @Valid DynamicQuery dto) { | ||
| try { | ||
| return Result.success(dynamicService.queryWithPage(dto)); | ||
| } catch (Exception e) { | ||
| log.error("Query failed for table: {}", dto.getNameEn(), e); | ||
| return Result.failed("Query operation failed"); | ||
| } | ||
|
|
||
| } | ||
|
|
||
| /** | ||
| * 新增模型数据 | ||
| * | ||
| * @return 返回值 map | ||
| */ | ||
| @Operation(summary = "新增模型数据", description = "新增模型数据", responses = { | ||
| @ApiResponse(responseCode = "200", description = "返回信息", | ||
| content = @Content(mediaType = "application/json",schema = @Schema(implementation = Map.class))), | ||
| @ApiResponse(responseCode = "400", description = "请求失败") | ||
| }) | ||
| @SystemControllerLog(description = "新增模型数据") | ||
| @PostMapping("/model-data/insertApi") | ||
| public Result<Map<String, Object> > insert(@RequestBody @Valid DynamicInsert dto) { | ||
| try { | ||
| return Result.success(dynamicService.insert(dto)); | ||
| } catch (Exception e) { | ||
| log.error("insert failed for table: {}", dto.getNameEn(), e); | ||
| return Result.failed("insert operation failed"); | ||
| } | ||
|
|
||
| } | ||
|
|
||
| /** | ||
| * 更新模型数据 | ||
| * | ||
| * @return 返回值 map | ||
| */ | ||
| @Operation(summary = "更新模型数据", description = "更新模型数据", responses = { | ||
| @ApiResponse(responseCode = "200", description = "返回信息", | ||
| content = @Content(mediaType = "application/json",schema = @Schema(implementation = Map.class))), | ||
| @ApiResponse(responseCode = "400", description = "请求失败") | ||
| }) | ||
| @SystemControllerLog(description = "更新模型数据") | ||
| @PostMapping("/model-data/updateApi") | ||
| public Result<Map<String, Object> > update(@RequestBody @Valid DynamicUpdate dto) { | ||
| try { | ||
| return Result.success(dynamicService.update(dto)); | ||
| } catch (Exception e) { | ||
| log.error("updateApi failed for table: {}", dto.getNameEn(), e); | ||
| return Result.failed("update operation failed"); | ||
| } | ||
|
|
||
| } | ||
| /** | ||
| * 刪除模型数据 | ||
| * | ||
| * @return 返回值 map | ||
| */ | ||
| @Operation(summary = "刪除模型数据", description = "刪除模型数据", responses = { | ||
| @ApiResponse(responseCode = "200", description = "返回信息", | ||
| content = @Content(mediaType = "application/json",schema = @Schema(implementation = Map.class))), | ||
| @ApiResponse(responseCode = "400", description = "请求失败") | ||
| }) | ||
| @SystemControllerLog(description = "刪除模型数据") | ||
| @PostMapping("/model-data/deleteApi") | ||
| public Result<Map<String, Object> > delete(@RequestBody @Valid DynamicDelete dto) { | ||
| try { | ||
| return Result.success(dynamicService.delete(dto)); | ||
| } catch (Exception e) { | ||
| log.error("deleteApi failed for table: {}", dto.getNameEn(), e); | ||
| return Result.failed("delete operation failed"); | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,107 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| package com.tinyengine.it.dynamic.dao; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import org.apache.ibatis.jdbc.SQL; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import java.util.List; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import java.util.Map; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public class DynamicSqlProvider { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public String select(Map<String, Object> params) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| String tableName = (String) params.get("tableName"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| List<String> fields = (List<String>) params.get("fields"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Map<String, Object> conditions = (Map<String, Object>) params.get("conditions"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Integer pageNum = (Integer) params.get("pageNum"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Integer pageSize = (Integer) params.get("pageSize"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| String orderBy = (String) params.get("orderBy"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| String orderType = (String) params.get("orderType"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| SQL sql = new SQL(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // 选择字段 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (fields != null && !fields.isEmpty()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| for (String field : fields) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sql.SELECT(field); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sql.SELECT("*"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sql.FROM(tableName); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // 条件 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (conditions != null && !conditions.isEmpty()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| for (Map.Entry<String, Object> entry : conditions.entrySet()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (entry.getValue() != null) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sql.WHERE(entry.getKey() + " = #{conditions." + entry.getKey() + "}"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // 排序 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (orderBy != null && !orderBy.isEmpty()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sql.ORDER_BY(orderBy + " " + orderType); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // 分页 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (pageNum != null && pageSize != null) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return sql.toString() + " LIMIT " + (pageNum - 1) * pageSize + ", " + pageSize; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return sql.toString(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+10
to
+51
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Critical: SQL injection vulnerability in select method. Multiple inputs are directly interpolated into the SQL string without parameterization:
While Proposed mitigationAdd validation within the provider itself for defense in depth: public String select(Map<String, Object> params) {
String tableName = (String) params.get("tableName");
+ validateIdentifier(tableName, "tableName");
List<String> fields = (List<String>) params.get("fields");
Map<String, Object> conditions = (Map<String, Object>) params.get("conditions");
Integer pageNum = (Integer) params.get("pageNum");
Integer pageSize = (Integer) params.get("pageSize");
String orderBy = (String) params.get("orderBy");
String orderType = (String) params.get("orderType");
SQL sql = new SQL();
// 选择字段
if (fields != null && !fields.isEmpty()) {
for (String field : fields) {
+ validateIdentifier(field, "field");
sql.SELECT(field);
}
} else {
sql.SELECT("*");
}
// ...
// 排序
if (orderBy != null && !orderBy.isEmpty()) {
+ validateIdentifier(orderBy, "orderBy");
+ if (!"ASC".equalsIgnoreCase(orderType) && !"DESC".equalsIgnoreCase(orderType)) {
+ throw new IllegalArgumentException("Invalid orderType: " + orderType);
+ }
sql.ORDER_BY(orderBy + " " + orderType);
}
// ...
}
+private void validateIdentifier(String identifier, String paramName) {
+ if (identifier == null || !identifier.matches("^[a-zA-Z_][a-zA-Z0-9_]*$")) {
+ throw new IllegalArgumentException("Invalid " + paramName + ": " + identifier);
+ }
+}🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public String insert(Map<String, Object> params) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| String tableName = (String) params.get("tableName"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Map<String, Object> data = (Map<String, Object>) params.get("data"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| SQL sql = new SQL(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sql.INSERT_INTO(tableName); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (data != null && !data.isEmpty()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| for (Map.Entry<String, Object> entry : data.entrySet()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sql.VALUES(entry.getKey(), "#{data." + entry.getKey() + "}"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return sql.toString(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public String update(Map<String, Object> params) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| String tableName = (String) params.get("tableName"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Map<String, Object> data = (Map<String, Object>) params.get("data"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Map<String, Object> conditions = (Map<String, Object>) params.get("conditions"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| SQL sql = new SQL(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sql.UPDATE(tableName); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (data != null && !data.isEmpty()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| for (Map.Entry<String, Object> entry : data.entrySet()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sql.SET(entry.getKey() + " = #{data." + entry.getKey() + "}"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (conditions != null && !conditions.isEmpty()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| for (Map.Entry<String, Object> entry : conditions.entrySet()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sql.WHERE(entry.getKey() + " = #{conditions." + entry.getKey() + "}"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return sql.toString(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+69
to
+90
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. SQL injection risk in update method. Same vulnerability pattern: 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public String delete(Map<String, Object> params) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| String tableName = (String) params.get("tableName"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Map<String, Object> conditions = (Map<String, Object>) params.get("conditions"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| SQL sql = new SQL(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sql.DELETE_FROM(tableName); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (conditions != null && !conditions.isEmpty()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| for (Map.Entry<String, Object> entry : conditions.entrySet()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sql.WHERE(entry.getKey() + " = #{conditions." + entry.getKey() + "}"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return sql.toString(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+92
to
+106
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. SQL injection risk in delete method - potential for mass deletion. The delete method has no safeguard against empty conditions. If Proposed safeguard public String delete(Map<String, Object> params) {
String tableName = (String) params.get("tableName");
Map<String, Object> conditions = (Map<String, Object>) params.get("conditions");
+ if (conditions == null || conditions.isEmpty()) {
+ throw new IllegalArgumentException("Delete operation requires conditions");
+ }
+
SQL sql = new SQL();
sql.DELETE_FROM(tableName);
- if (conditions != null && !conditions.isEmpty()) {
- for (Map.Entry<String, Object> entry : conditions.entrySet()) {
- sql.WHERE(entry.getKey() + " = #{conditions." + entry.getKey() + "}");
- }
+ for (Map.Entry<String, Object> entry : conditions.entrySet()) {
+ sql.WHERE(entry.getKey() + " = #{conditions." + entry.getKey() + "}");
}
return sql.toString();
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,32 @@ | ||||||||||||||
| package com.tinyengine.it.dynamic.dao; | ||||||||||||||
|
|
||||||||||||||
| import com.alibaba.fastjson.JSONObject; | ||||||||||||||
| import org.apache.ibatis.annotations.*; | ||||||||||||||
| import org.springframework.stereotype.Repository; | ||||||||||||||
|
|
||||||||||||||
| import java.util.List; | ||||||||||||||
| import java.util.Map; | ||||||||||||||
|
|
||||||||||||||
| @Repository | ||||||||||||||
| @Mapper | ||||||||||||||
| public interface ModelDataDao { | ||||||||||||||
|
|
||||||||||||||
| @SelectProvider(type = DynamicSqlProvider.class, method = "select") | ||||||||||||||
| List<JSONObject> select(Map<String, Object> params); | ||||||||||||||
|
|
||||||||||||||
| @InsertProvider(type = DynamicSqlProvider.class, method = "insert") | ||||||||||||||
| @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") | ||||||||||||||
| Long insert(Map<String, Object> params); | ||||||||||||||
|
Comment on lines
+17
to
+19
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Incorrect return type for insert method. The Proposed fix `@InsertProvider`(type = DynamicSqlProvider.class, method = "insert")
`@Options`(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
- Long insert(Map<String, Object> params);
+ int insert(Map<String, Object> params);📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||
|
|
||||||||||||||
| @UpdateProvider(type = DynamicSqlProvider.class, method = "update") | ||||||||||||||
| Integer update(Map<String, Object> params); | ||||||||||||||
|
|
||||||||||||||
| @DeleteProvider(type = DynamicSqlProvider.class, method = "delete") | ||||||||||||||
| Integer delete(Map<String, Object> params); | ||||||||||||||
|
|
||||||||||||||
| @Select("SELECT COLUMN_NAME, DATA_TYPE, COLUMN_COMMENT " + | ||||||||||||||
| "FROM INFORMATION_SCHEMA.COLUMNS " + | ||||||||||||||
| "WHERE TABLE_NAME = #{tableName} AND TABLE_SCHEMA = DATABASE()") | ||||||||||||||
| List<Map<String, Object>> getTableStructure(String tableName); | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| package com.tinyengine.it.dynamic.dto; | ||
|
|
||
| import lombok.Data; | ||
|
|
||
| import java.util.Map; | ||
|
|
||
| @Data | ||
| public class DynamicDelete { | ||
| private String nameEn; | ||
| private Integer id; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| package com.tinyengine.it.dynamic.dto; | ||
|
|
||
| import lombok.Data; | ||
|
|
||
| import java.util.Map; | ||
| @Data | ||
| public class DynamicInsert { | ||
| private String nameEn; | ||
| private Map<String, Object> params; // 插入/更新数据 | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| package com.tinyengine.it.dynamic.dto; | ||
|
|
||
| import lombok.Data; | ||
|
|
||
| import java.util.List; | ||
| import java.util.Map; | ||
|
|
||
| @Data | ||
| public class DynamicQuery { | ||
|
|
||
| private String nameEn; // 表名 | ||
| private String nameCh; // 表中文名 | ||
| private List<String> fields; // 查询字段 | ||
| private Map<String, Object> params; // 查询条件 | ||
| private Integer currentPage = 1; // 页码 | ||
| private Integer pageSize = 10; // 每页大小 | ||
| private String orderBy; // 排序字段 | ||
| private String orderType = "ASC"; // 排序方式 | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| package com.tinyengine.it.dynamic.dto; | ||
|
|
||
| import lombok.Data; | ||
|
|
||
| import java.util.Map; | ||
| @Data | ||
| public class DynamicUpdate { | ||
| private String nameEn; | ||
| private Map<String, Object> data; | ||
| private Map<String, Object> params;// 查询条件 | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
分页参数要做下校验
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已赋值默认值