|
@@ -6,6 +6,7 @@ import com.boman.common.core.utils.obj.ObjectUtils;
|
|
|
import com.boman.web.core.constant.FormDataConstant;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.ibatis.annotations.*;
|
|
|
+import org.apache.ibatis.annotations.Param;
|
|
|
import org.apache.ibatis.jdbc.SQL;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
@@ -162,7 +163,15 @@ public interface StandardlyMapper {
|
|
|
, @Param("condition") JSONObject condition
|
|
|
, @Param("packCondition") JSONObject packCondition);
|
|
|
|
|
|
-
|
|
|
+ /**
|
|
|
+ * 功能描述: 根据tableName和map(属性名和属性值)进行查查
|
|
|
+ * {@link SqlProvider#selectByMap(java.util.Map)}
|
|
|
+ * @param tableName tableName
|
|
|
+ * @param param 属性名和属性值
|
|
|
+ * @return java.util.List<com.alibaba.fastjson.JSONObject>
|
|
|
+ */
|
|
|
+ @SelectProvider(type = SqlProvider.class, method = "selectByMap")
|
|
|
+ List<JSONObject> selectByMap(@Param("tableName") String tableName, @Param("param") Map<String, Object> param);
|
|
|
|
|
|
|
|
|
public static class SqlProvider {
|
|
@@ -515,7 +524,7 @@ public interface StandardlyMapper {
|
|
|
}
|
|
|
wholeSql.append(StringUtils.substringBeforeLast(showDataSql.toString(), ","));
|
|
|
//
|
|
|
- wholeSql.append(showDataSql).append(" from ").append(tableName);
|
|
|
+ wholeSql.append(" from ").append(tableName);
|
|
|
// 条件
|
|
|
packCondition(packCondition, wholeSql);
|
|
|
|
|
@@ -529,6 +538,21 @@ public interface StandardlyMapper {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ public String selectByMap(Map<String, Object> para) {
|
|
|
+ Map<String, Object> param = (Map<String, Object>) para.get("param");
|
|
|
+ String tableName = (String) para.get("tableName");
|
|
|
+
|
|
|
+ StringBuilder wholeSql = new StringBuilder();
|
|
|
+ wholeSql.append("select * from ").append(tableName).append(" where ");
|
|
|
+ for (Map.Entry<String, Object> entry : param.entrySet()) {
|
|
|
+ wholeSql.append(entry.getKey()).append(" = ").append(entry.getValue()).append(" and ");
|
|
|
+ }
|
|
|
+
|
|
|
+ String result = StringUtils.substringBeforeLast(wholeSql.toString(), "and");
|
|
|
+ LOGGER.info("查询拼出的sql语句为:{}", result);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
public String selectByIdList(Map<String, Object> para) {
|
|
|
String tableName = (String) para.get("tableName");
|
|
|
String pkName = (String) para.get("pkName");
|