zuy 1 год назад
Родитель
Сommit
c22b187db0

+ 3 - 3
admin-web/package.json

@@ -1,7 +1,7 @@
 {
-	"name": "web",
-	"version": "1.0.2.4.31",
-	"description": "admin",
+	"name": "wash-web",
+	"version": "1.0.1",
+	"description": "洗车应用管理后台工程",
 	"license": "MIT",
 	"scripts": {
 		"dev": "vite --force",

+ 0 - 9
car-wash-jdbc/src/main/java/com/kym/jdbc/BasicData.java

@@ -1,9 +0,0 @@
-package com.kym.jdbc;
-
-import java.io.Serializable;
-
-
-public class BasicData implements Serializable {
-    public String key;
-    public Object value;
-}

+ 0 - 25
car-wash-jdbc/src/main/java/com/kym/jdbc/BasicEntity.java

@@ -1,25 +0,0 @@
-package com.kym.jdbc;
-
-import com.kym.jdbc.annotations.DBF;
-
-import java.io.Serializable;
-import java.util.Date;
-
-/**
- * build by yaop at 2018/12/23 20:56
- *
- * @author zuypeng
- */
-public class BasicEntity implements Serializable {
-    @DBF(comment = "ID")
-    public long id;
-
-    @DBF(comment = "租户ID")
-    public long orgId;
-
-    @DBF(comment = "创建时间")
-    public Date createAt;
-
-    @DBF(comment = "更新时间")
-    public Date updateAt;
-}

+ 1 - 3
car-wash-jdbc/src/main/java/com/kym/jdbc/BasicQuery.java

@@ -8,7 +8,7 @@ public class BasicQuery {
     public static final int SORT_ASC = 1;
     public static final int SORT_DESC = 2;
 
-    public Long orgId;
+    public Long companyId;
 
     @QF(ignore = true)
     public int pageIndex = 1;
@@ -23,8 +23,6 @@ public class BasicQuery {
 
     public String[] excludeFields;
 
-    public boolean skipHook; //跳过钩子
-
 
     public BasicQuery() {
 

+ 0 - 15
car-wash-jdbc/src/main/java/com/kym/jdbc/ExtQuery.java

@@ -1,15 +0,0 @@
-package com.kym.jdbc;
-
-import java.util.List;
-
-public class ExtQuery {
-   public List<ExtQueryWrapper> wrappers;
-   public int joins;
-
-
-    public static class ExtQueryWrapper{
-        public String key;
-        public Object[] values;
-        public int operation;
-    }
-}

+ 0 - 542
car-wash-jdbc/src/main/java/com/kym/jdbc/MBuilder.java

@@ -1,542 +0,0 @@
-package com.kym.jdbc;
-
-import com.kym.DbUtil;
-import com.kym.jdbc.annotations.QF;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.lang.reflect.Array;
-import java.lang.reflect.Field;
-import java.lang.reflect.Modifier;
-import java.sql.Timestamp;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * 查询条件builder,针对非结构化查询数据库mongodb
- *
- * @author asynll
- */
-public class MBuilder extends IBuilder {
-    private static Logger logger = LoggerFactory.getLogger(MBuilder.class);
-
-    private static final String SORT = "Sort";
-    /**
-     * 查询条件
-     */
-    private List<Where> wheres = new LinkedList<>();
-    /**
-     * 分组字段
-     */
-    private List<String> groupBys = new ArrayList<>();
-    /**
-     * 排序map
-     */
-    private static Map<Integer, String> sortMap = new HashMap<>(16);
-    /**
-     * 排序集合,奇数 -升序   偶数-降序  值越大越靠后
-     */
-    private List<String> orderBys = new ArrayList<>();
-    /**
-     * left join xxx  t1 on t1.xx  = l.f1
-     */
-    private List<String> joins = new ArrayList<>();
-    /**
-     * 查询分组  () or/and ()
-     */
-    private List<Group> groups = new ArrayList<>();
-    /**
-     * 分页索引起点
-     */
-    private int limitStart = 0;
-    private int limitDelta = -1;
-    /**
-     * 互斥锁,使用时注意锁索引,否则会增大死锁几率
-     */
-    public boolean forUpdate;
-    /**
-     * 共享锁,不建议使用
-     */
-    public boolean forShare;
-
-
-    private MBuilder() {
-    }
-
-    public static MBuilder build() {
-        sortMap = new HashMap<>();
-        return new MBuilder();
-    }
-
-    public static MBuilder toBuilder(BasicQuery query) {
-        MBuilder builder = new MBuilder();
-        Field[] fields = query.getClass().getFields();
-        for (Field field : fields) {
-            if (Modifier.isStatic(field.getModifiers()) || Modifier.isFinal(field.getModifiers())) {
-                continue;
-            }
-            Object val = DbUtil.getFieldValue(query, field);
-            if (!DbUtil.isEmptyOrNull(val)) {
-                Class<?> type = field.getType();
-                String fieldName = field.getName();
-                if (fieldName.endsWith(SORT) && type.equals(Integer.class)) {
-                    fieldName = fieldName.split(SORT)[0];
-                    int sortValue = DbUtil.null2Int(val);
-                    if (sortValue % 2 == BasicQuery.SORT_ASC) {
-//                        builder.asc(fieldName);
-                        sortMap.put(DbUtil.null2Int(val), String.format(" %s asc ", columnName(fieldName)));
-                    } else {
-//                        builder.desc(fieldName);
-                        sortMap.put(DbUtil.null2Int(val), String.format(" %s desc ", columnName(fieldName)));
-                    }
-
-                } else if (type.equals(String.class)) {
-                    builder.like(field.getName(), val);
-                } else if (type.equals(Integer.class) || type.equals(Short.class) || type.equals(Long.class)) {
-                    builder.eq(field.getName(), val);
-                } else {
-                    boolean annoPersent = field.isAnnotationPresent(QF.class);
-                    if (annoPersent) {
-                        QF qf = field.getAnnotation(QF.class);
-                        String op = qf.op();
-                        String sql = qf.sql();
-                        if (!DbUtil.isEmptyOrNull(op)) {
-                            builder.and(qf.tf(), op, val);
-                        } else if (!DbUtil.isEmptyOrNull(sql)) {
-                            builder.sql(sql, val);
-                        } else if ("sortFields".equals(fieldName)) {
-                            String[] sorts = (String[]) val;
-                            for (String sort : sorts) {
-                                int sortVal = DbUtil.null2Int(DbUtil.getFieldValue(query, sort));
-                                if (sortVal > 0) {
-                                    if (sortVal % 2 == BasicQuery.SORT_ASC) {
-                                        sortMap.put(DbUtil.null2Int(val), String.format(" %s asc ", DbUtil.getColumnName(sort.substring(0, sort.length() - 4))));
-                                    } else {
-                                        sortMap.put(DbUtil.null2Int(sortVal), String.format(" %s desc ", DbUtil.getColumnName(sort.substring(0, sort.length() - 4))));
-                                    }
-                                }
-                               /* if (null!=sortVal) {
-                                    if(BasicQuery.SORT_ASC==Integer.parseInt(sortVal.toString())){
-                                        builder.orderBy(String.format("%s asc ",));
-                                    }else if(BasicQuery.SORT_DESC==Integer.parseInt(sortVal.toString())){
-                                        builder.orderBy(String.format("%s desc ", DbUtil.getColumnName(sort.substring(0, sort.length() - 4))));
-                                    }
-                                }*/
-                            }
-                        } else if ("pageSize".equals(fieldName)) {
-                            int pageSize = (int) val;
-                            if (pageSize > 0) {
-                                int pageIndex = (int) DbUtil.getFieldValue(query, "pageIndex");
-                                builder.limit(Math.max(0, (pageIndex - 1) * pageSize), pageSize);
-                            }
-                        }
-                    }
-                }
-            }
-        }
-
-        if (!DbUtil.isEmptyOrNull(sortMap)) {
-            Set<Integer> integers = sortMap.keySet();
-            List<Integer> sorts = new ArrayList<>(integers);
-            sorts.sort(Comparator.comparingInt(o -> o));
-            sorts.forEach(k -> builder.orderByNative(sortMap.get(k)));
-        }
-        return builder;
-    }
-
-
-    public String toSql() {
-        StringBuilder sbr = new StringBuilder(" and 1=1 ");
-        //where
-        if (!DbUtil.isEmptyOrNull(wheres)) {
-            for (Where wh : wheres) {
-                if (DbUtil.isEmptyOrNull(wh.sql)) {
-                    sbr.append(DbUtil.getColumnName(wh.key)).append(" ").append(wh.op);
-                    String op = wh.op;
-                    Object value = wh.value;
-                    if ("in".equals(op.trim()) || "not in".equals(op.trim())) {
-                        sbr.append("(");
-                        for (int i = 0; i < Array.getLength(value); i++) {
-                            Object v = Array.get(value, i);
-                            if (v.getClass() == String.class) {
-                                sbr.append("'").append(v).append("'");
-                            } else {
-                                sbr.append(v);
-                            }
-                            if (i != Array.getLength(value) - 1) {
-                                sbr.append(",");
-                            }
-                        }
-                        sbr.append(")");
-                    } else {
-                        if (value.getClass() == String.class) {
-                            sbr.append("'").append(value).append("'");
-                        } else if (wh.value.getClass() == Date.class) {
-                            sbr.append("'").append(new Timestamp(((Date) value).getTime())).append("'");
-                        } else {
-                            sbr.append(value);
-                        }
-                    }
-                } else {
-                    //sql
-                    String whereSql = wh.sql;
-                    sbr.append(" (");
-                    List<Object> values = wh.sqlValues;
-                    if (!DbUtil.isEmptyOrNull(values)) {
-                        if (whereSql.contains("?")) {
-                            String regex = "\\?";
-                            for (Object o : values) {
-                                if (o.getClass() == String.class) {
-                                    whereSql = whereSql.replaceFirst(regex, "'" + o + "'");
-                                } else if (o.getClass() == Date.class) {
-                                    whereSql = whereSql.replaceFirst(regex, "'" + (new Timestamp(((Date) o).getTime())) + "'");
-                                } else {
-                                    whereSql = whereSql.replaceFirst(regex, o.toString());
-                                }
-                            }
-                        }
-                    }
-                    sbr.append(whereSql);
-                    sbr.append(") ");
-                }
-            }
-        }
-
-        //group by
-        if (!DbUtil.isEmptyOrNull(groupBys)) {
-            sbr.append(" group by ");
-            groupBys.forEach(group -> sbr.append(group).append(" ,"));
-            sbr.deleteCharAt(sbr.length() - 1);
-        }
-        //order by
-        if (!DbUtil.isEmptyOrNull(orderBys)) {
-            sbr.append(" order by ");
-            orderBys.forEach(order -> sbr.append(order).append(" ,"));
-            sbr.deleteCharAt(sbr.length() - 1);
-        }
-        //limit
-        if (limitDelta > 0) {
-            sbr.append(" limit ");
-            if (limitStart > 0) {
-                sbr.append(limitStart).append(",");
-            }
-            sbr.append(limitDelta);
-        }
-
-        //for update
-        if (forUpdate) {
-            sbr.append(" for update ");
-        }
-
-        if (forShare) {
-            sbr.append(" with share mode ");
-        }
-
-        return sbr.toString();
-    }
-
-    public String toSql(BasicQuery query) {
-        return toBuilder(query).toSql();
-    }
-
-
-    public MBuilder ne(String key, Object value) {
-        return this.and(key, "<>", value);
-    }
-
-    public MBuilder eq(String key, Object value) {
-        return this.and(key, "=", value);
-    }
-
-
-    private MBuilder and(String key, String op, Object value) {
-        Where w = new Where();
-        w.key = key;
-        w.op = " " + op + " ";
-        w.value = value;
-        boolean isExist = false;
-        for (Where where : wheres) {
-            if (where.key.equals(key)) {
-                where.op = op;
-                where.value = value;
-                isExist = true;
-                break;
-            }
-        }
-        if (!isExist) {
-            wheres.add(w);
-        }
-        return this;
-    }
-
-
-    public MBuilder in(String key, Object[] values) {
-        Where w = new Where();
-        w.key = key;
-        w.op = "in";
-        w.value = values;
-        wheres.add(w);
-        return this;
-    }
-
-
-    public MBuilder notIn(String key, Object[] values) {
-        Where w = new Where();
-        w.key = key;
-        w.op = "not in";
-        w.value = values;
-        wheres.add(w);
-        return this;
-    }
-
-    public MBuilder llike(String key, Object value) {
-        return this.and(key, "like", value.toString() + "%");
-    }
-
-    /**
-     * 模糊匹配,不走索引慎重使用
-     */
-    public MBuilder like(String key, Object value) {
-        return this.and(key, "like", "%" + value.toString() + "%");
-    }
-
-    /**
-     * 右匹配,不走索引慎重使用
-     */
-    public MBuilder rlike(String key, Object value) {
-        return this.and(key, "like", "%" + value.toString());
-    }
-
-    public MBuilder lt(String key, Object value) {
-        return this.and(key, "<", value);
-    }
-
-    public MBuilder lte(String key, Object value) {
-        return this.and(key, "<=", value);
-    }
-
-    public MBuilder gte(String key, Object value) {
-        return this.and(key, ">=", value);
-    }
-
-    /**
-     * 大于
-     */
-    public MBuilder gt(String key, Object value) {
-        return this.and(key, ">", value);
-    }
-
-    public MBuilder between(String key, Object start, Object end) {
-        Where w = new Where();
-        w.sql = " " + columnName(key) + " between ? and ? ";
-        w.sqlValues.add(start);
-        w.sqlValues.add(end);
-        wheres.add(w);
-        return this;
-    }
-
-    public MBuilder or(String key, String op, Object value) {
-        Where w = new Where();
-        w.sql = " or (" + columnName(key) + " " + op + " ?)";
-        w.sqlValues.addAll(Collections.singletonList(value));
-        wheres.add(w);
-        return this;
-    }
-
-    public MBuilder or(String sql, Object... values) {
-        Where w = new Where();
-        w.sql = " or (" + sql + " )";
-        w.sqlValues.addAll(Arrays.asList(values));
-        wheres.add(w);
-        return this;
-    }
-
-    /**
-     * 构造sql片段查询条件
-     *
-     * @param sql    sql片段,必须符合数据库语法,缺省参数已?作为通配符
-     * @param values sql缺省参数的值,有序
-     */
-    public MBuilder sql(String sql, Object... values) {
-        Where w = new Where();
-        w.sql = sql;
-        w.sqlValues.addAll(Arrays.asList(values));
-        wheres.add(w);
-        return this;
-    }
-
-    private MBuilder orderByNative(String orderBy) {
-        orderBys.add(orderBy);
-        return this;
-    }
-
-    public MBuilder orderBy(String orderBy) {
-        String[] splits = orderBy.split(" ");
-        StringBuilder sbr = new StringBuilder(" ");
-        for (String split : splits) {
-            sbr.append(columnName(split).trim()).append(" ");
-        }
-        orderBys.add(sbr.toString());
-        return this;
-    }
-
-    public MBuilder asc(String key) {
-        orderBys.add(columnName(key) + " asc ");
-        return this;
-    }
-
-    public MBuilder desc(String key) {
-        orderBys.add(columnName(key) + " desc ");
-        return this;
-    }
-
-    /**
-     * 分组字段,仅在使用聚合函数{@link com.kym.jdbc.ibatis.BoxMapper#selectFunc(Class, String, MBuilder)}时有效
-     */
-    public MBuilder groupBy(String orderBy) {
-        groupBys.add(columnName(orderBy));
-        return this;
-    }
-
-    /**
-     * 分页
-     *
-     * @param pos   分页起点
-     * @param delta 分页条数
-     * @return
-     */
-    public MBuilder limit(int pos, int delta) {
-        limitStart = pos;
-        limitDelta = delta;
-        return this;
-    }
-
-    public MBuilder limit(int delta) {
-        limitStart = 0;
-        limitDelta = delta;
-        return this;
-    }
-
-    public MBuilder forUpdate() {
-        forUpdate = true;
-        return this;
-    }
-
-    public MBuilder forShare() {
-        forShare = true;
-        return this;
-    }
-
-    public MBuilder group(boolean orGroup, List<Where> wheres) {
-        groups.add(new Group(orGroup, wheres));
-        return this;
-    }
-
-
-    public List<String> getOrderBys() {
-        return orderBys;
-    }
-
-    public List<String> getGroupBys() {
-        return groupBys;
-    }
-
-    public int limitStart() {
-        return limitStart;
-    }
-
-    public int limitDelta() {
-        return limitDelta;
-    }
-
-    public List<Where> getWheres() {
-        return wheres;
-    }
-
-
-    private static String columnName(String field) {
-        StringBuilder sbr = new StringBuilder();
-        char[] chars = field.toCharArray();
-        for (char ch : chars) {
-            if (Character.isUpperCase(ch)) {
-                sbr.append("_").append(Character.toLowerCase(ch));
-            } else {
-                sbr.append(ch);
-            }
-        }
-        return sbr.toString();
-    }
-
-    public static class Group {
-        public boolean orConnector;
-        public List<Where> wheres;
-
-        public Group(boolean orConnector, List<Where> wheres) {
-            this.orConnector = orConnector;
-            this.wheres = wheres;
-        }
-
-    }
-
-    public static class Where {
-        public boolean isGroup;
-        public Group group;
-        public String key;
-        public Object value;
-        public String op = "=";
-        public String sql;
-        /**
-         * sql结构化数据库的查询语句
-         */
-        public LinkedList<Object> sqlValues = new LinkedList<>();
-
-        Where() {
-        }
-
-        public Where(String key, Object value, String op) {
-            this.key = key;
-            this.value = value;
-            this.op = op;
-        }
-
-        public Where(String key, Object value, String op, String sql, LinkedList<Object> sqlValues) {
-            this.key = key;
-            this.value = value;
-            this.op = op;
-            this.sql = sql;
-            this.sqlValues = sqlValues;
-        }
-
-        @Override
-        public String toString() {
-            return "Where{" +
-                    "key='" + key + '\'' +
-                    ", value=" + value +
-                    ", op='" + op + '\'' +
-                    ", sql='" + sql + '\'' +
-                    ", sqlValues=" + sqlValues +
-                    '}';
-        }
-    }
-
-    @Override
-    public String toString() {
-        return "Builder{" +
-                "wheres=" + wheres +
-                ", groupBys=" + groupBys +
-                ", orderBys=" + orderBys +
-                ", limitStart=" + limitStart +
-                ", limitDelta=" + limitDelta +
-                ", forUpdate=" + forUpdate +
-                ", forShare=" + forShare +
-                '}';
-    }
-}

+ 8 - 0
pom.xml

@@ -42,6 +42,14 @@
             <groupId>org.slf4j</groupId>
             <artifactId>slf4j-api</artifactId>
         </dependency>
+        <dependency>
+            <groupId>com.fasterxml.jackson.core</groupId>
+            <artifactId>jackson-core</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.fasterxml.jackson.core</groupId>
+            <artifactId>jackson-databind</artifactId>
+        </dependency>
     </dependencies>
 
     <repositories>