|
@@ -1,5 +1,6 @@
|
|
|
package restcontroller.webmanage.saletool.sharematerial;
|
|
|
|
|
|
+import beans.attachment.Attachment;
|
|
|
import beans.time.Time;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
@@ -9,6 +10,8 @@ import common.annotation.API;
|
|
|
import common.data.*;
|
|
|
import restcontroller.R;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
+
|
|
|
public class LongPicText extends Controller {
|
|
|
/**
|
|
|
* 构造函数
|
|
@@ -93,6 +96,9 @@ public class LongPicText extends Controller {
|
|
|
Rows attRows = getAttachmentUrl("sat_sharematerial", sat_sharematerialid);
|
|
|
detailRow.put("attinfos", attRows);
|
|
|
|
|
|
+ detailRow.put("shareurl", "/pages/product/ctw/share?id=" + sat_sharematerialid);
|
|
|
+ detailRow.put("noshareurl", "/pages/product/ctw/noshare?id=" + sat_sharematerialid);
|
|
|
+
|
|
|
|
|
|
return getSucReturnObject().setData(detailRow).toString();
|
|
|
}
|
|
@@ -122,33 +128,107 @@ public class LongPicText extends Controller {
|
|
|
return getSucReturnObject().toString();
|
|
|
}
|
|
|
|
|
|
+ @API(title = "长图文图片列表", apiversion = R.ID20240329145502.v1.class)
|
|
|
+ public String piclist() throws YosException {
|
|
|
+
|
|
|
+ Long sat_sharematerialid = content.getLongValue("sat_sharematerialid");
|
|
|
+ Rows rows = dbConnect.runSqlQuery("SELECT * from sat_sharematerial WHERE sat_sharematerialid=" + sat_sharematerialid + " and siteid='" + siteid + "'");
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ JSONArray jsonArray = new JSONArray();
|
|
|
+ if (rows.isNotEmpty()) {
|
|
|
+ jsonObject = rows.get(0).getJSONObject("sharepagecontrol");
|
|
|
+ jsonArray = jsonObject.getJSONArray("pics");
|
|
|
+ }
|
|
|
+
|
|
|
+ ArrayList<Long> ids = new ArrayList<>();
|
|
|
+ for (Object o : jsonArray) {
|
|
|
+ JSONObject jsonObject1 = (JSONObject) o;
|
|
|
+ ids.add(jsonObject1.getLongValue("attchementid"));
|
|
|
+ }
|
|
|
+
|
|
|
+ RowsMap attRowsMap = Attachment.get(this, ids).toRowsMap("attachmentid");
|
|
|
+ for (Object object:jsonArray) {
|
|
|
+ JSONObject jsonObject1= (JSONObject) object;
|
|
|
+ jsonObject1.put("attinfos",attRowsMap.getOrDefault(jsonObject1.getString("attchementid"),new Rows()));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ return getSucReturnObject().setData(jsonArray).toString();
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
@API(title = "长图文绑定图片信息", apiversion = R.ID20240329131902.v1.class)
|
|
|
public String updatePicInfo() throws YosException {
|
|
|
|
|
|
Long sat_sharematerialid = content.getLongValue("sat_sharematerialid");
|
|
|
+ Long attchementid = content.getLongValue("attchementid");
|
|
|
|
|
|
Rows rows = dbConnect.runSqlQuery("SELECT * from sat_sharematerial WHERE sat_sharematerialid=" + sat_sharematerialid + " and siteid='" + siteid + "'");
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
JSONArray jsonArray = new JSONArray();
|
|
|
if (rows.isNotEmpty()) {
|
|
|
jsonObject = rows.get(0).getJSONObject("sharepagecontrol");
|
|
|
- jsonArray = rows.get(0).getJSONArray("pics");
|
|
|
+ jsonArray = jsonObject.getJSONArray("pics");
|
|
|
}
|
|
|
+ JSONArray newjsonArray = getTempJSONArray(jsonArray, String.valueOf(attchementid));
|
|
|
|
|
|
+ JSONObject object = new JSONObject();
|
|
|
+ object.put("attchementid", attchementid);
|
|
|
+ object.put("url", content.getStringValue("url"));
|
|
|
+ object.put("sequence", content.getIntValue("sequence"));
|
|
|
+ newjsonArray.add(object);
|
|
|
+ jsonObject.put("pics", newjsonArray);
|
|
|
|
|
|
UpdateSQL updateSQL = SQLFactory.createUpdateSQL(this, "sat_sharematerial");
|
|
|
updateSQL.setSiteid(siteid);
|
|
|
updateSQL.setUniqueid(sat_sharematerialid);
|
|
|
|
|
|
updateSQL.setValue("sharepagecontrol", jsonObject);
|
|
|
+ System.err.println(updateSQL.getSQL());
|
|
|
updateSQL.update();
|
|
|
|
|
|
- return getSucReturnObject().toString();
|
|
|
+
|
|
|
+ return detail();
|
|
|
}
|
|
|
|
|
|
@API(title = "长图文解绑图片信息", apiversion = R.ID20240329132002.v1.class)
|
|
|
- public String deletePicInfo() {
|
|
|
- return getSucReturnObject().toString();
|
|
|
+ public String deletePicInfo() throws YosException {
|
|
|
+
|
|
|
+ Long sat_sharematerialid = content.getLongValue("sat_sharematerialid");
|
|
|
+ Long attchementid = content.getLongValue("attchementid");
|
|
|
+
|
|
|
+ Rows rows = dbConnect.runSqlQuery("SELECT * from sat_sharematerial WHERE sat_sharematerialid=" + sat_sharematerialid + " and siteid='" + siteid + "'");
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ JSONArray jsonArray = new JSONArray();
|
|
|
+ if (rows.isNotEmpty()) {
|
|
|
+ jsonObject = rows.get(0).getJSONObject("sharepagecontrol");
|
|
|
+ jsonArray = jsonObject.getJSONArray("pics");
|
|
|
+ }
|
|
|
+ jsonObject.put("pics", getTempJSONArray(jsonArray, String.valueOf(attchementid)));
|
|
|
+
|
|
|
+
|
|
|
+ UpdateSQL updateSQL = SQLFactory.createUpdateSQL(this, "sat_sharematerial");
|
|
|
+ updateSQL.setSiteid(siteid);
|
|
|
+ updateSQL.setUniqueid(sat_sharematerialid);
|
|
|
+
|
|
|
+ updateSQL.setValue("sharepagecontrol", jsonObject);
|
|
|
+ System.err.println(updateSQL.getSQL());
|
|
|
+ updateSQL.update();
|
|
|
+
|
|
|
+ return detail();
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ public JSONArray getTempJSONArray(JSONArray jsonArray, String attchementid) throws YosException {
|
|
|
+ JSONArray temp = new JSONArray();
|
|
|
+ for (Object object : jsonArray) {
|
|
|
+ JSONObject temp_object = (JSONObject) object;
|
|
|
+ if (!temp_object.getString("attchementid").equals(attchementid)) {
|
|
|
+ temp.add(object);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return temp;
|
|
|
+ }
|
|
|
+
|
|
|
}
|