|
@@ -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();
|
|
|
+ }
|
|
|
+}
|