Skip to content

Commit

Permalink
chore-openapi-增加相关注释
Browse files Browse the repository at this point in the history
  • Loading branch information
aruis committed Sep 19, 2024
1 parent 6531aaa commit 4373994
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ default PageResult view(Integer page,
throw new QueryException("查询条件%s未配置,查询失败".formatted(k));
}

condition.append(" and %s ".formatted(qi.getField()));
condition.append(" and %s ".formatted(qi.getColumn()));

if (v == null) {
condition.append(" isnull ");
Expand Down Expand Up @@ -201,14 +201,14 @@ default PageResult view(Integer page,
Object b = list.get(1);

if (a == null) {
condition.append(" = %s ".formatted(qi.getField()));
condition.append(" = %s ".formatted(qi.getColumn()));
} else {
condition.append(" >= ? ");
params.add(a);
}

if (b != null) {
condition.append(" and %s ".formatted(qi.getField()));
condition.append(" and %s ".formatted(qi.getColumn()));
condition.append(" <= ? ");
params.add(b);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
package net.ximatai.muyun.model;

import org.eclipse.microprofile.openapi.annotations.media.Schema;

@Schema(description = "数据变更结果")
public class BatchResult {
@Schema(description = "新增数量")
private int create;
@Schema(description = "修改数量")
private int update;
@Schema(description = "删除数量")
private int delete;

public BatchResult() {
Expand Down
7 changes: 7 additions & 0 deletions my-core/src/main/java/net/ximatai/muyun/model/PageResult.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
package net.ximatai.muyun.model;

import org.eclipse.microprofile.openapi.annotations.media.Schema;

import java.util.List;

@Schema(description = "分页结果")
public class PageResult<T> {
@Schema(description = "数据列表")
private List<T> list;
@Schema(description = "总数")
private long total;
@Schema(description = "分页大小")
private long size;
@Schema(description = "页码")
private int page;

public PageResult() {
Expand Down
31 changes: 19 additions & 12 deletions my-core/src/main/java/net/ximatai/muyun/model/QueryItem.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
package net.ximatai.muyun.model;

import org.eclipse.microprofile.openapi.annotations.media.Schema;

@Schema(description = "可以被查询的列")
public class QueryItem {

private String field;
@Schema(description = "列名")
private String column;
@Schema(description = "标题")
private String label;
@Schema(description = "别名")
private String alias;

@Schema(description = "比较类型")
private SymbolType symbolType;

private boolean isMain = true; //ui
Expand All @@ -19,29 +25,30 @@ public class QueryItem {

private Object defaultValue; //ui

public static QueryItem of(String field) {
public static QueryItem of(String column) {
QueryItem item = new QueryItem();
item.field = field;
item.alias = field;
item.column = column;
item.alias = column;
item.symbolType = SymbolType.EQUAL;

if (field.startsWith("t_")) {
if (column.startsWith("t_")) {
item.isDatetime = true;
} else if (field.startsWith("d_")) {
} else if (column.startsWith("d_")) {
item.isDate = true;
} else if (field.startsWith("b_")) {
} else if (column.startsWith("b_")) {
item.isBoolean = true;
}

return item;
}

@Schema(description = "比较类型")
public enum SymbolType {
EQUAL, NOT_EQUAL, LIKE, IN, NOT_IN, RANGE
}

public QueryItem setField(String field) {
this.field = field;
public QueryItem setColumn(String column) {
this.column = column;
return this;
}

Expand Down Expand Up @@ -105,8 +112,8 @@ public QueryItem setDefaultValue(Object defaultValue) {
return this;
}

public String getField() {
return field;
public String getColumn() {
return column;
}

public String getLabel() {
Expand Down
7 changes: 7 additions & 0 deletions my-core/src/main/java/net/ximatai/muyun/model/TreeNode.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
package net.ximatai.muyun.model;

import org.eclipse.microprofile.openapi.annotations.media.Schema;

import java.util.List;

@Schema(description = "树节点")
public class TreeNode {
@Schema(description = "数据id")
private String id;
@Schema(description = "数据标题")
private String label;
@Schema(description = "数据内容")
private Object data;
@Schema(description = "子节点")
private List<TreeNode> children;

public TreeNode() {
Expand Down

0 comments on commit 4373994

Please sign in to comment.