eganwu 1 年間 前
コミット
d36a37123d

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

@@ -6075,6 +6075,21 @@ public class R {
         }
     }
 
+    public static class ID20240417161502 {
+        public static class v1 {
+        }
+    }
+
+    public static class ID20240417161602 {
+        public static class v1 {
+        }
+    }
+
+    public static class ID20240417161702 {
+        public static class v1 {
+        }
+    }
+
 }
 
 

+ 92 - 0
src/custom/restcontroller/system/datacomment/datacomment.java

@@ -0,0 +1,92 @@
+package restcontroller.system.datacomment;
+
+import com.alibaba.fastjson.JSONObject;
+import common.Controller;
+import common.YosException;
+import common.annotation.API;
+import common.data.*;
+import restcontroller.R;
+
+/**
+ * 用户评论
+ */
+public class datacomment extends Controller {
+    /**
+     * 构造函数
+     *
+     * @param content
+     */
+    public datacomment(JSONObject content) throws YosException {
+        super(content);
+    }
+
+    @API(title = "评论新增", apiversion = R.ID20240417161502.v1.class)
+    public String insert() throws YosException {
+        String ownertable = content.getStringValue("ownertable");
+        Long ownerid = content.getLongValue("ownerid");
+
+        InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "sys_datacomment");
+        insertSQL.setSiteid(siteid);
+        insertSQL.setUniqueid(createTableID("sys_datacomment"));
+        insertSQL.setValue("ownertable", ownertable);
+        insertSQL.setValue("ownerid", ownerid);
+        insertSQL.setValue("userid", userid);
+        insertSQL.setValue("name", username);
+        insertSQL.setValue("content", content.getStringValue("contentstr"));
+        insertSQL.insert();
+
+        if (ownertable.equals("sat_sharematerial")) {
+            updateSharematerial(ownerid);
+        }
+        return list();
+    }
+
+    @API(title = "评论删除", apiversion = R.ID20240417161602.v1.class)
+    public String delete() throws YosException {
+
+        Long sys_datacommentid = content.getLongValue("sys_datacommentid");
+        String ownertable = content.getStringValue("ownertable");
+        Long ownerid = content.getLongValue("ownerid");
+
+        DeleteSQL deleteSQL = SQLFactory.createDeleteSQL(this, "sys_datacomment");
+        deleteSQL.setSiteid(siteid);
+        deleteSQL.setUniqueid(sys_datacommentid);
+        deleteSQL.delete();
+
+        if (ownertable.equals("sat_sharematerial")) {
+            updateSharematerial(ownerid);
+        }
+
+        return getSucReturnObject().toString();
+    }
+
+    @API(title = "评论列表", apiversion = R.ID20240417161702.v1.class)
+    public String list() throws YosException {
+        String ownertable = content.getStringValue("ownertable");
+        Long ownerid = content.getLongValue("ownerid");
+
+        QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sys_datacomment").setTableAlias("t1");
+        querySQL.setSiteid(siteid);
+        querySQL.setWhere("ownertable", ownertable);
+        querySQL.setWhere("ownerid", ownerid);
+        querySQL.setPage(pageSize, pageNumber).setOrderBy("t1.createdate desc");
+        Rows rows = querySQL.query();
+        for (Row row : rows) {
+            row.put("headpic", getHeadPic(row.getLong("userid")));
+        }
+
+        return getSucReturnObject().setData(rows).toString();
+    }
+
+    public void updateSharematerial(Long ownerid) throws YosException {
+        Row row = dbConnect.runSqlQuery(0, "SELECT count(*) count from sys_datacomment WHERE ownertable='sat_sharematerial' and ownerid=" + ownerid + "  and siteid='" + siteid + "'");
+
+        UpdateSQL updateSQL = SQLFactory.createUpdateSQL(this, "sat_sharematerial");
+        updateSQL.setSiteid(siteid);
+        updateSQL.setUniqueid(ownerid);
+
+        updateSQL.setValue("commentcount", row.getLong("count"));
+
+        updateSQL.update();
+    }
+}

+ 10 - 2
src/custom/restcontroller/webmanage/saletool/sharematerial/DesignPic.java

@@ -90,14 +90,15 @@ public class DesignPic extends Controller {
         String ownertable = "sat_sharematerial";
 
         QuerySQL querySQ = SQLFactory.createQuerySQL(this, "sat_sharematerial",
-                        "sat_sharematerialid", "createby", "createdate", "changeby", "changedate", "checkby", "checkdate", "sys_enterpriseid", "title", "type", "sequence", "status"
+                        "sat_sharematerialid", "createuserid", "createby", "createdate", "changeby", "changedate", "checkby", "checkdate", "sys_enterpriseid", "title", "type", "sequence", "status"
                         , "title_c", "renderingsclass", "isnationwide", "collectcount", "likecount", "commentcount", "panoramaurl")
                 .setTableAlias("t1");
         querySQ.addJoinTable(JOINTYPE.left, "sys_datacollect", "t2", "t2.siteid=t1.siteid and t2.ownertable='sat_sharematerial' and type=1 and t2.ownerid=t1.sat_sharematerialid and t2.userid='" + userid + "'");
         querySQ.addJoinTable(JOINTYPE.left, "sys_enterprise", "t3", "t3.sys_enterpriseid=t1.sys_enterpriseid and t3.siteid=t1.siteid"
                 , "enterprisename");
-
+        querySQ.addJoinTable(JOINTYPE.left, "sys_datacollect", "t4", "t4.siteid=t1.siteid and t4.ownertable='sat_sharematerial' and type=2 and t4.ownerid=t1.sat_sharematerialid and t4.userid='" + userid + "'");
         querySQ.addQueryFields("iscollect", "CASE WHEN t2.sys_datacollectid>0 THEN 1 ELSE 0 END");
+        querySQ.addQueryFields("islike", "CASE WHEN t2.sys_datacollectid>0 THEN 1 ELSE 0 END");
         querySQ.setSiteid(siteid);
         querySQ.setWhere("sat_sharematerialid", sat_sharematerialid);
 
@@ -152,6 +153,13 @@ public class DesignPic extends Controller {
         }
 
         detailRow.put("attinfos_pic", attachmentRows);
+        detailRow.put("headpic", getHeadPic(detailRow.getLong("createuserid")));
+
+        if (StringUtils.isBlank(detailRow.getString("areaname"))) {
+            detailRow.put("enterprisename_area", detailRow.getString("enterprisename"));
+        } else {
+            detailRow.put("enterprisename_area", detailRow.getString("enterprisename") + "(" + detailRow.getString("areaname") + ")");
+        }
 
 
         return getSucReturnObject().setData(detailRow).toString();