Browse Source

获取指定位置的广告信息

eganwu 1 year ago
parent
commit
06b59efe0c

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

@@ -6185,6 +6185,11 @@ public class R {
         }
     }
 
+    public static class ID20240426154302 {
+        public static class v1 {
+        }
+    }
+
 
 }
 

+ 29 - 0
src/custom/restcontroller/common/adspace/adspace.java

@@ -1,12 +1,15 @@
 package restcontroller.common.adspace;
 
+import beans.attachment.Attachment;
 import beans.user.User;
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import common.Controller;
 import common.YosException;
 import common.annotation.API;
 import common.data.*;
 import common.parameter.parameter;
+import restcontroller.R;
 
 import java.util.ArrayList;
 
@@ -44,4 +47,30 @@ public class adspace extends Controller {
         }
         return getSucReturnObject().setData(adspacerows).toString();
     }
+
+
+    @API(title = "获取指定位置的广告信息", apiversion = R.ID20240426154302.v1.class)
+    public String query() throws YosException {
+
+        String systemclient = content.getStringValue("systemclient");
+        JSONArray locations = content.getJSONArray("locations");
+
+        QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sys_ad")
+                .setTableAlias("t1");
+        querySQL.addJoinTable(JOINTYPE.left, "sys_adspace", "t2", "t2.sys_adspaceid=t1.sys_adspaceid"
+                , "location");
+        querySQL.setSiteid(siteid);
+        querySQL.setWhere("t2.systemclient='" + systemclient + "'");
+        querySQL.setWhere("t2.isused=1");
+        querySQL.setWhere("t2.location", locations);
+        querySQL.setDataAuth(true);
+        Rows adRows = querySQL.query();
+        RowsMap attinfosRowsMap = Attachment.get(this, "sys_ad", adRows.toArrayList("sys_adid", new ArrayList<>()));
+        for (Row row : adRows) {
+            row.put("attinfos", attinfosRowsMap.getOrDefault(row.getString("sys_adid"), new Rows()));
+        }
+
+        return getSucReturnObject().setData(adRows.toRowsMap("location")).toString();
+    }
+
 }

+ 16 - 16
src/custom/restcontroller/webmanage/saletool/store/Store.java

@@ -193,22 +193,22 @@ public class Store extends Controller {
         long sa_storeid = detailRow.getLong("sa_storeid");
         detailRow.put("attinfos", Attachment.get(this, "sa_store", sa_storeid));
 
-        Rows adspaceRows = dbConnect.runSqlQuery("SELECT * from sys_adspace WHERE systemclient='wechatsaletool' and isused=1");
-
-        for (Row adspaceRow : adspaceRows) {
-            Long sys_adspaceid = adspaceRow.getLong("sys_adspaceid");
-            querySQL = SQLFactory.createQuerySQL(this, "sys_ad")
-                    .setTableAlias("t1");
-            querySQL.setSiteid(siteid);
-            querySQL.setWhere("sys_adspaceid", sys_adspaceid);
-            querySQL.setDataAuth(true);
-            Rows adRows = querySQL.query();
-            RowsMap attinfosRowsMap = Attachment.get(this, "sys_ad", adRows.toArrayList("sys_adid", new ArrayList<>()));
-            for (Row row : adRows) {
-                row.put("attinfos", attinfosRowsMap.getOrDefault(row.getString("sys_adid"), new Rows()));
-            }
-            detailRow.put("ad_" + adspaceRow.getString("location"), adRows);
-        }
+//        Rows adspaceRows = dbConnect.runSqlQuery("SELECT * from sys_adspace WHERE systemclient='wechatsaletool' and isused=1");
+
+//        for (Row adspaceRow : adspaceRows) {
+//            Long sys_adspaceid = adspaceRow.getLong("sys_adspaceid");
+//            querySQL = SQLFactory.createQuerySQL(this, "sys_ad")
+//                    .setTableAlias("t1");
+//            querySQL.setSiteid(siteid);
+//            querySQL.setWhere("sys_adspaceid", sys_adspaceid);
+//            querySQL.setDataAuth(true);
+//            Rows adRows = querySQL.query();
+//            RowsMap attinfosRowsMap = Attachment.get(this, "sys_ad", adRows.toArrayList("sys_adid", new ArrayList<>()));
+//            for (Row row : adRows) {
+//                row.put("attinfos", attinfosRowsMap.getOrDefault(row.getString("sys_adid"), new Rows()));
+//            }
+//            detailRow.put("ad_" + adspaceRow.getString("location"), adRows);
+//        }
 
         addHistory(sa_storeid);