Ver Fonte

装备资源库管理

eganwu há 1 ano atrás
pai
commit
8b899cfe32

+ 17 - 13
src/custom/restcontroller/webmanage/saletool/sharematerial/EquipmentResourceLibrary.java

@@ -219,44 +219,48 @@ public class EquipmentResourceLibrary extends Controller {
     @API(title = "图片新增或编辑", apiversion = R.ID20240407135802.v1.class)
     public String attachmentInsertOrUpdate() throws YosException {
 
-        Long sys_attachment_linksid = content.getLongValue("sys_attachment_linksid");
+        Long linksid = content.getLongValue("linksid");
 
-        if (sys_attachment_linksid <= 0) {
-            sys_attachment_linksid = createTableID("sys_attachment_links");
+        if (linksid <= 0) {
+            linksid = createTableID("sys_attachment_links");
             InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "sys_attachment_links");
             insertSQL.setSiteid(siteid);
-            insertSQL.setUniqueid(sys_attachment_linksid);
+            insertSQL.setUniqueid(linksid);
             insertSQL.setValue("usetype", "sat_sharematerial");
-            insertSQL.setValue("linksid", 0);
             insertSQL.setValue("attachmentid", content.getLongValue("attachmentid"));
             insertSQL.setValue("jumpurl", content.getStringValue("jumpurl", true));
-            insertSQL.setValue("sequence", content.getLongValue("attachmentid"));
+            insertSQL.setValue("sequence", content.getLongValue("sequence"));
             insertSQL.setValue("ownertable", content.getStringValue("ownertable"));
             insertSQL.setValue("ownerid", content.getLongValue("ownerid"));
             insertSQL.insert();
         }
-        if (sys_attachment_linksid > 0) {
+        if (linksid > 0) {
             UpdateSQL updateSQL = SQLFactory.createUpdateSQL(this, "sys_attachment_links");
             updateSQL.setSiteid(siteid);
-            updateSQL.setUniqueid(sys_attachment_linksid);
+            updateSQL.setUniqueid(linksid);
             updateSQL.setValue("jumpurl", content.getStringValue("jumpurl", true));
-            updateSQL.setValue("sequence", content.getLongValue("attachmentid"));
+            updateSQL.setValue("sequence", content.getLongValue("sequence"));
             updateSQL.update();
         }
 
-        String sql ="SELECT * from sys_attachment_links WHERE sys_attachment_linksid=" + sys_attachment_linksid + " and siteid='" + siteid + "'";
+        String sql = "SELECT * from sys_attachment_links WHERE linksid=" + linksid + " and siteid='" + siteid + "'";
 
         Rows rows = dbConnect.runSqlQuery(sql);
 
 
-        return getSucReturnObject().setData(rows.get(0)).toString();
+        return getSucReturnObject().setData(rows.isNotEmpty() ? rows.get(0) : new Row()).toString();
     }
 
     @API(title = "图片删除", apiversion = R.ID20240407135902.v1.class)
-    public String attachmentDelete() {
+    public String attachmentDelete() throws YosException {
 
+        JSONArray linksids = content.getJSONArray("linksids");
+        DeleteSQL deleteSQL = SQLFactory.createDeleteSQL(this, "sys_attachment_links");
+        deleteSQL.setSiteid(siteid);
+        deleteSQL.setWhere("linksid", linksids);
+        deleteSQL.delete();
 
-        return getSucReturnObject().setData("").toString();
+        return getSucReturnObject().toString();
     }
 
     @API(title = "图片列表", apiversion = R.ID20240407140002.v1.class)

+ 11 - 1
src/custom/restcontroller/webmanage/saletool/sharematerial/sharematerialClass.java

@@ -70,10 +70,20 @@ public class sharematerialClass extends Controller {
     public String delete() throws YosException {
 
         JSONArray sat_sharematerial_classids = content.getJSONArray("sat_sharematerial_classids");
+        StringBuffer where = new StringBuffer(" 1=1 ");
+        if (sat_sharematerial_classids.size() > 0) {
+            where.append(" and (1=2");
+            for (Object obj : sat_sharematerial_classids) {
+                where.append(" or (");
+                where.append("JSON_CONTAINS(sat_sharematerial_classids,'" + obj + "')");
+                where.append(")");
+            }
+            where.append(")");
+        }
 
         QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sat_sharematerial");
         querySQL.setSiteid(siteid);
-        querySQL.setWhere("sat_sharematerial_classid", sat_sharematerial_classids);
+        querySQL.setWhere(where.toString());
         Rows rows = querySQL.query();
         if (rows.isNotEmpty()) {
             return getErrReturnObject().setErrMsg("当前分类已使用,无法删除").toString();