Browse Source

图片批量新增

eganwu 1 year ago
parent
commit
97a63f035f

+ 5 - 0
src/custom/restcontroller/R.java

@@ -6180,6 +6180,11 @@ public class R {
         }
     }
 
+    public static class ID20240425102102 {
+        public static class v1 {
+        }
+    }
+
 
 }
 

+ 35 - 5
src/custom/restcontroller/webmanage/saletool/sharematerial/EquipmentResourceLibrary.java

@@ -64,7 +64,7 @@ public class EquipmentResourceLibrary extends Controller {
 
             sqlFactory.insert();
             content.put("sat_sharematerialid", sat_sharematerialid);
-        }else  {
+        } else {
             UpdateSQL sqlFactory = SQLFactory.createUpdateSQL(this, sat_sharematerial);
             sqlFactory.setUniqueid(sat_sharematerialid);
             sqlFactory.setSiteid(siteid);
@@ -93,7 +93,7 @@ public class EquipmentResourceLibrary extends Controller {
         QuerySQL sqlFactory = SQLFactory.createQuerySQL(this, sat_sharematerial
                         , "sat_sharematerialid", "type", "status", "sequence", "title", "canshared_c", "candownload_c", "candownload"
                         , "sat_sharematerial_classids", "mailcount", "canshared", "downloadcount", "isqrcode", "qrcodecontent", "sharecount", "readcount"
-                        , "createby", "createdate", "checkby", "checkdate", "changeby", "changedate","ispicture")
+                        , "createby", "createdate", "checkby", "checkdate", "changeby", "changedate", "ispicture")
                 .setTableAlias("t1");
         sqlFactory.setUniqueid(sat_sharematerialid);
         sqlFactory.setSiteid(siteid);
@@ -120,7 +120,7 @@ public class EquipmentResourceLibrary extends Controller {
         if (rows.isNotEmpty()) {
             detailRow = rows.get(0);
             Rows attRows = getAttachmentUrl("sat_sharematerial", sat_sharematerialid);
-            attRows.sortby("sequence","linksid");
+            attRows.sortby("sequence", "linksid");
             detailRow.put("attinfos", attRows);
             detailRow.putIfAbsent("checkdate", "");
             if (detailRow.getInteger("type") == 1) {
@@ -238,7 +238,7 @@ public class EquipmentResourceLibrary extends Controller {
         QuerySQL sqlFactory = SQLFactory.createQuerySQL(this, sat_sharematerial,
                         "sat_sharematerialid", "title", "type", "status", "mailcount",
                         "readcount", "downloadcount", "createdate", "checkdate",
-                        "sat_sharematerial_classids","ispicture")
+                        "sat_sharematerial_classids", "ispicture")
                 .setTableAlias("t1");
         sqlFactory.setSiteid(siteid);
         sqlFactory.setWhere("classid", 3);
@@ -254,7 +254,7 @@ public class EquipmentResourceLibrary extends Controller {
         RowsMap RowsMap = getAttachmentUrl(sat_sharematerial, ids);
         for (Row row : rows) {
             Rows attRows = RowsMap.getOrDefault(row.getString("sat_sharematerialid"), new Rows());
-            attRows.sortby("sequence","linksid");
+            attRows.sortby("sequence", "linksid");
             row.put("attinfos", attRows);
             row.putIfAbsent("checkdate", "");
             if (row.getInteger("type") == 1) {
@@ -312,6 +312,36 @@ public class EquipmentResourceLibrary extends Controller {
         return getSucReturnObject().setData(rows.isNotEmpty() ? rows.get(0) : new Row()).toString();
     }
 
+    @API(title = "图片批量新增", apiversion = R.ID20240425102102.v1.class)
+    public String attachmentInserts() throws YosException {
+
+        String ownertable = content.getStringValue("ownertable");
+        Long ownerid = content.getLongValue("ownerid");
+
+        JSONArray jsonArray = content.getJSONArray("items");
+        ArrayList<String> listSql = new ArrayList<>();
+        for (Object obj : jsonArray) {
+            if (obj instanceof JSONObject) {
+                JSONObject jsonObject = (JSONObject) obj;
+                InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "sys_attachment_links");
+                insertSQL.setSiteid(siteid);
+                insertSQL.setUniqueid(createTableID("sys_attachment_links"));
+                insertSQL.setValue("usetype", ownertable);
+                insertSQL.setValue("attachmentid", jsonObject.getLongValue("attachmentid"));
+                insertSQL.setValue("jumpurl", jsonObject.getStringValue("jumpurl", true));
+                insertSQL.setValue("sequence", jsonObject.getLongValue("sequence"));
+                insertSQL.setValue("ownertable", ownertable);
+                insertSQL.setValue("ownerid", ownerid);
+                listSql.add(insertSQL.getSQL());
+            }
+        }
+
+        dbConnect.runSqlUpdate(listSql);
+
+
+        return getSucReturnObject().toString();
+    }
+
     @API(title = "图片删除", apiversion = R.ID20240407135902.v1.class)
     public String attachmentDelete() throws YosException {