|
@@ -93,6 +93,10 @@ public interface StandardlyMapper {
|
|
int updateByIdList(@Param("tableName") String tableName, @Param("pkName") String pkName
|
|
int updateByIdList(@Param("tableName") String tableName, @Param("pkName") String pkName
|
|
, @Param("idList") List<Long> idList, @Param("model") JSONObject models);
|
|
, @Param("idList") List<Long> idList, @Param("model") JSONObject models);
|
|
|
|
|
|
|
|
+ @UpdateProvider(type = SqlProvider.class, method = "updateByForeignKey")
|
|
|
|
+ int updateByForeignKey(@Param("tableName") String tableName, @Param("foreignKeyName") String foreignKeyName
|
|
|
|
+ , @Param("foreignKeyList") List<Long> foreignKeyList, @Param("model") JSONObject models);
|
|
|
|
+
|
|
@Select("select id from ${tableName} where ${akColumnName} = #{akColumnValue}")
|
|
@Select("select id from ${tableName} where ${akColumnName} = #{akColumnValue}")
|
|
Long selectIdByAkColumn(@Param("tableName") String tableName, @Param("akColumnName") String akColumnName, @Param("akColumnValue") String akColumnValue);
|
|
Long selectIdByAkColumn(@Param("tableName") String tableName, @Param("akColumnName") String akColumnName, @Param("akColumnValue") String akColumnValue);
|
|
|
|
|
|
@@ -409,6 +413,35 @@ public interface StandardlyMapper {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public String updateByForeignKey(Map<String, Object> para) {
|
|
|
|
+ String tableName = (String) para.get("tableName");
|
|
|
|
+ String foreignKeyName = (String) para.get("foreignKeyName");
|
|
|
|
+ List<Long> foreignKeyList = (List<Long>) para.get("foreignKeyList");
|
|
|
|
+ JSONObject models = (JSONObject) para.get("model");
|
|
|
|
+
|
|
|
|
+ StringBuilder wholeSql = new StringBuilder();
|
|
|
|
+ wholeSql.append("update ").append(tableName).append(" set ");
|
|
|
|
+ for (Map.Entry<String, Object> entry : models.entrySet()) {
|
|
|
|
+ String key = entry.getKey();
|
|
|
|
+ Object value = entry.getValue();
|
|
|
|
+ wholeSql.append(key).append(covert(EQ, CHAR, key, value)).append(" , ");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ wholeSql = new StringBuilder(StringUtils.substringBeforeLast(wholeSql.toString(), ","));
|
|
|
|
+ wholeSql.append(" where ").append(foreignKeyName).append(" in ( ");
|
|
|
|
+
|
|
|
|
+ for (Long id : foreignKeyList) {
|
|
|
|
+ wholeSql.append(id);
|
|
|
|
+ wholeSql.append(",");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ wholeSql.setCharAt(wholeSql.length() - 1, ')');
|
|
|
|
+ String sqlStr = wholeSql.toString();
|
|
|
|
+ LOGGER.info("批量更新的sql语句为: {}, \r\n 更改的数据为: {}, \r\n foreignKeyList: {}", sqlStr, models, foreignKeyList);
|
|
|
|
+ return sqlStr;
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
public String delete(Map<String, Object> para) {
|
|
public String delete(Map<String, Object> para) {
|
|
Long[] ids = (Long[]) para.get("ids");
|
|
Long[] ids = (Long[]) para.get("ids");
|
|
String tableName = (String) para.get("tableName");
|
|
String tableName = (String) para.get("tableName");
|