|
|
@@ -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;
|
|
|
@@ -183,7 +184,7 @@ public class EquipmentResourceLibrary extends Controller {
|
|
|
}
|
|
|
|
|
|
QuerySQL sqlFactory = SQLFactory.createQuerySQL(this, sat_sharematerial,
|
|
|
- "sat_sharematerialid", "title", "type", "status", "mailcount", "readcount", "downloadcount", "createdate", "checkdate")
|
|
|
+ "sat_sharematerialid", "title", "type", "status", "mailcount", "readcount", "downloadcount", "createdate", "checkdate", "sat_sharematerial_classids")
|
|
|
.setTableAlias("t1");
|
|
|
sqlFactory.setSiteid(siteid);
|
|
|
sqlFactory.setWhere("classid", 3);
|
|
|
@@ -220,18 +221,20 @@ public class EquipmentResourceLibrary extends Controller {
|
|
|
public String attachmentInsertOrUpdate() throws YosException {
|
|
|
|
|
|
Long linksid = content.getLongValue("linksid");
|
|
|
+ String ownertable = content.getStringValue("ownertable");
|
|
|
+ Long ownerid = content.getLongValue("ownerid");
|
|
|
|
|
|
if (linksid <= 0) {
|
|
|
linksid = createTableID("sys_attachment_links");
|
|
|
InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "sys_attachment_links");
|
|
|
insertSQL.setSiteid(siteid);
|
|
|
insertSQL.setUniqueid(linksid);
|
|
|
- insertSQL.setValue("usetype", "sat_sharematerial");
|
|
|
+ insertSQL.setValue("usetype", ownertable);
|
|
|
insertSQL.setValue("attachmentid", content.getLongValue("attachmentid"));
|
|
|
insertSQL.setValue("jumpurl", content.getStringValue("jumpurl", true));
|
|
|
insertSQL.setValue("sequence", content.getLongValue("sequence"));
|
|
|
- insertSQL.setValue("ownertable", content.getStringValue("ownertable"));
|
|
|
- insertSQL.setValue("ownerid", content.getLongValue("ownerid"));
|
|
|
+ insertSQL.setValue("ownertable", ownertable);
|
|
|
+ insertSQL.setValue("ownerid", ownerid);
|
|
|
insertSQL.insert();
|
|
|
}
|
|
|
if (linksid > 0) {
|
|
|
@@ -264,10 +267,43 @@ public class EquipmentResourceLibrary extends Controller {
|
|
|
}
|
|
|
|
|
|
@API(title = "图片列表", apiversion = R.ID20240407140002.v1.class)
|
|
|
- public String attachmentList() {
|
|
|
+ public String attachmentList() throws YosException {
|
|
|
|
|
|
+ StringBuffer where = new StringBuffer(" 1=1 ");
|
|
|
+ if (content.containsKey("where")) {
|
|
|
+ JSONObject whereObject = content.getJSONObject("where");
|
|
|
+ if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {
|
|
|
+ where.append(" and (");
|
|
|
+ where.append("t1.attachmentid like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+ where.append(")");
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ String ownertable = content.getStringValue("ownertable");
|
|
|
|
|
|
- return getSucReturnObject().setData("").toString();
|
|
|
+ Long ownerid = content.getLongValue("ownerid");
|
|
|
+
|
|
|
+ QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sys_attachment_links").setTableAlias("t1");
|
|
|
+ querySQL.setSiteid(siteid);
|
|
|
+ querySQL.setWhere(where.toString());
|
|
|
+ querySQL.setWhere("ownertable", ownertable);
|
|
|
+ querySQL.setWhere("ownerid", ownerid);
|
|
|
+ querySQL.setWhere("usetype", ownertable);
|
|
|
+
|
|
|
+ querySQL.setPage(pageSize, pageNumber).setOrderBy(pageSorting);
|
|
|
+ Rows rows = querySQL.query();
|
|
|
+
|
|
|
+ ArrayList<Long> ids = rows.toArrayList("attachmentid", new ArrayList<>());
|
|
|
+
|
|
|
+ RowsMap attRowsMap = Attachment.get(this, ids).toRowsMap("attachmentid");
|
|
|
+
|
|
|
+ for (Row row : rows) {
|
|
|
+ row.put("attinfos", attRowsMap.getOrDefault(row.getString("attachmentid"), new Rows()));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ return getSucReturnObject().setData(rows).toString();
|
|
|
}
|
|
|
|
|
|
}
|