Browse Source

效果图管理

eganwu 1 year ago
parent
commit
b5975695a0

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

@@ -6034,6 +6034,11 @@ public class R {
         }
     }
 
+    public static class ID20240416133702 {
+        public static class v1 {
+        }
+    }
+
 
 }
 

+ 50 - 0
src/custom/restcontroller/system/datacollect/datacollect.java

@@ -0,0 +1,50 @@
+package restcontroller.system.datacollect;
+
+import com.alibaba.fastjson.JSONObject;
+import common.Controller;
+import common.YosException;
+import common.annotation.API;
+import common.data.*;
+import restcontroller.R;
+
+public class datacollect extends Controller {
+    /**
+     * 构造函数
+     *
+     * @param content
+     */
+    public datacollect(JSONObject content) throws YosException {
+        super(content);
+    }
+
+
+    @API(title = "数据收藏", apiversion = R.ID20240416133702.v1.class)
+    public String isCollect() throws YosException {
+        String ownertable = content.getStringValue("ownertable");
+        Long ownerid = content.getLongValue("ownerid");
+
+        QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sys_datacollect");
+        querySQL.setSiteid(siteid);
+        querySQL.setWhere("userid", userid);
+        querySQL.setWhere("ownertable", ownertable);
+        querySQL.setWhere("ownerid", ownerid);
+        Rows rows = querySQL.query();
+        if (rows.isNotEmpty()) {
+            DeleteSQL deleteSQL = SQLFactory.createDeleteSQL(this, "sys_datacollect");
+            deleteSQL.setSiteid(siteid);
+            deleteSQL.setUniqueid(rows.get(0).getLong("sys_datacollectid"));
+            deleteSQL.delete();
+        } else {
+            InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "sys_datacollect");
+            insertSQL.setUniqueid(createTableID("sys_datacollect"));
+            insertSQL.setSiteid(siteid);
+            insertSQL.setValue("userid", userid);
+            insertSQL.setValue("ownertable", ownertable);
+            insertSQL.setValue("ownerid", ownerid);
+            insertSQL.insert();
+        }
+
+        return getSucReturnObject().toString();
+    }
+
+}

+ 43 - 17
src/custom/restcontroller/webmanage/saletool/sharematerial/Renderings.java

@@ -1,5 +1,6 @@
 package restcontroller.webmanage.saletool.sharematerial;
 
+import beans.attachment.Attachment;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import common.Controller;
@@ -76,9 +77,12 @@ public class Renderings extends Controller {
     @API(title = "效果图详情", apiversion = R.ID20240415164302.v1.class)
     public String detail() throws YosException {
         Long sat_sharematerialid = content.getLongValue("sat_sharematerialid");
+        String ownertable = "sat_sharematerial";
 
         QuerySQL querySQ = SQLFactory.createQuerySQL(this, "sat_sharematerial")
                 .setTableAlias("t1");
+        querySQ.addJoinTable(JOINTYPE.left, "sys_datacollect", "t2", "t2.siteid=t1.siteid and t2.ownertable='sat_sharematerial' and t2.ownerid=t1.sat_sharematerialid and t2.userid='" + userid + "'");
+        querySQ.addQueryFields("iscollect", "CASE WHEN t2.sys_datacollectid>0 THEN 1 ELSE 0 END");
         querySQ.setSiteid(siteid);
         querySQ.setWhere("sat_sharematerialid", sat_sharematerialid);
 
@@ -96,6 +100,32 @@ public class Renderings extends Controller {
             detailRow.put("ispanorama", 1);
         }
 
+        QuerySQL attachmentQuery = SQLFactory.createQuerySQL(this, "sys_attachment_links").setTableAlias("t1");
+        attachmentQuery.setSiteid(detailRow.getString("siteid"));
+        attachmentQuery.setWhere("ownertable", ownertable);
+        attachmentQuery.setWhere("ownerid", sat_sharematerialid);
+        attachmentQuery.setWhere("usetype", ownertable);
+        attachmentQuery.setOrderBy("t1.sequence");
+        Rows attachmentRows = attachmentQuery.query();
+
+
+        ArrayList<Long> ids = attachmentRows.toArrayList("attachmentid", new ArrayList<>());
+
+        RowsMap attRowsMap = Attachment.get(this, ids).toRowsMap("attachmentid");
+
+        for (Row row : attachmentRows) {
+            Rows attPicRows = new Rows();
+            Rows tempAttRows = attRowsMap.getOrDefault(row.getString("attachmentid"), new Rows());
+            for (Row tempAttRow : tempAttRows) {
+                if (tempAttRow.getString("usetype").equals(ownertable)) {
+                    attPicRows.add(tempAttRow);
+                }
+            }
+            row.put("attinfos", attPicRows);
+        }
+
+        detailRow.put("attinfos_pic", attachmentRows);
+
 
         return getSucReturnObject().setData(detailRow).toString();
     }
@@ -142,15 +172,15 @@ public class Renderings extends Controller {
                 where.append(")");
             }
             if (whereObject.containsKey("ispanorama") && !"".equals(whereObject.getString("ispanorama"))) {
-               if(whereObject.getString("ispanorama").equals("1")){
-                   where.append(" and (");
-                   where.append("LENGTH(t1.panoramaurl)>0  ");
-                   where.append(")");
-               }else{
-                   where.append(" and (");
-                   where.append("LENGTH(t1.panoramaurl)=0 or t1.panoramaurl is null ");
-                   where.append(")");
-               }
+                if (whereObject.getString("ispanorama").equals("1")) {
+                    where.append(" and (");
+                    where.append("LENGTH(t1.panoramaurl)>0  ");
+                    where.append(")");
+                } else {
+                    where.append(" and (");
+                    where.append("LENGTH(t1.panoramaurl)=0 or t1.panoramaurl is null ");
+                    where.append(")");
+                }
             }
             if (whereObject.containsKey("renderingstype") && !"".equals(whereObject.getString("renderingstype"))) {
                 where.append(" and (");
@@ -160,19 +190,19 @@ public class Renderings extends Controller {
 
             if (whereObject.containsKey("style") && !"".equals(whereObject.getString("style"))) {
                 where.append(" and (");
-                where.append("JSON_CONTAINS(t1.renderingsclass->'$.style', '\""+whereObject.getString("style")+"\"')");
+                where.append("JSON_CONTAINS(t1.renderingsclass->'$.style', '\"" + whereObject.getString("style") + "\"')");
                 where.append(")");
 
             }
             if (whereObject.containsKey("space") && !"".equals(whereObject.getString("space"))) {
                 where.append(" and (");
-                where.append("JSON_CONTAINS(t1.renderingsclass->'$.space', '\""+whereObject.getString("space")+"\"')");
+                where.append("JSON_CONTAINS(t1.renderingsclass->'$.space', '\"" + whereObject.getString("space") + "\"')");
                 where.append(")");
 
             }
             if (whereObject.containsKey("spec") && !"".equals(whereObject.getString("spec"))) {
                 where.append(" and (");
-                where.append("JSON_CONTAINS(t1.renderingsclass->'$.spec', '\""+whereObject.getString("spec")+"\"')");
+                where.append("JSON_CONTAINS(t1.renderingsclass->'$.spec', '\"" + whereObject.getString("spec") + "\"')");
                 where.append(")");
 
             }
@@ -180,18 +210,14 @@ public class Renderings extends Controller {
 
         }
 
-        boolean isDataAuth = content.getBooleanValue("isDataAuth");
 
         QuerySQL sqlFactory = SQLFactory.createQuerySQL(this, sat_sharematerial,
-                        "sat_sharematerialid", "title", "status", "renderingstype", "readcount", "sequence", "createdate", "checkdate","renderingsclass")
+                        "sat_sharematerialid", "title", "status", "renderingstype", "readcount", "readcount_start", "sequence", "createdate", "checkdate", "renderingsclass")
                 .setTableAlias("t1");
         sqlFactory.setSiteid(siteid);
         sqlFactory.setWhere("classid", 4);
         sqlFactory.setWhere(where.toString());
         sqlFactory.setOrderBy(pageSorting).setPage(pageSize, pageNumber);
-        if (isDataAuth) {
-            sqlFactory.setDataAuth(true);
-        }
         Rows rows = sqlFactory.query();
 
         ArrayList<Long> ids = rows.toArrayList("sat_sharematerialid", new ArrayList<>());