|
|
@@ -0,0 +1,93 @@
|
|
|
+package com.cnd3b.restcontroller.enterprise.bannermag;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.cnd3b.common.Controller;
|
|
|
+import com.cnd3b.common.D3bException;
|
|
|
+import com.cnd3b.common.data.Row;
|
|
|
+import com.cnd3b.common.data.Rows;
|
|
|
+import com.cnd3b.common.data.RowsMap;
|
|
|
+import com.cnd3b.common.data.SQLFactory;
|
|
|
+import p2.pao.PaoRemote;
|
|
|
+import p2.pao.PaoSetRemote;
|
|
|
+import p2.util.P2Exception;
|
|
|
+
|
|
|
+public class bannermag extends Controller {
|
|
|
+ public bannermag(JSONObject content) {
|
|
|
+ super(content);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 轮播位查询
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public String query_bannerlocationlist() {
|
|
|
+ SQLFactory locationSQL = new SQLFactory(this, "轮播广告位查询");
|
|
|
+ locationSQL.addParameter("siteid", siteid);
|
|
|
+ Rows locationrows = dbConnect.runSqlQuery(locationSQL.getSQL());
|
|
|
+
|
|
|
+ SQLFactory bannerSQl = new SQLFactory(this, "轮播广告查询");
|
|
|
+ bannerSQl.addParameter("siteid", siteid);
|
|
|
+ bannerSQl.addParameter_in("tbannerlocationid", locationrows.toArrayList("tbannerlocationid"));
|
|
|
+ RowsMap bannermap = dbConnect.runSqlQuery(bannerSQl.getSQL()).toRowsMap("tbannerlocationid");
|
|
|
+ for (Row locationrow : locationrows) {
|
|
|
+ Rows bannerRows = bannermap.get(locationrow.getString("tbannerlocationid"));
|
|
|
+ for (Row bannerrow : bannerRows) {
|
|
|
+ bannerrow.put("attinfos", getAttachmentUrl("tbannerlocation", bannerrow.getString("tbannerlocationid")));
|
|
|
+ }
|
|
|
+ locationrow.put("banner", bannerRows);
|
|
|
+ }
|
|
|
+ return getSucReturnObject().setData(locationrows).saveToDataPool(10).toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增或修改轮播图
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ * @throws P2Exception
|
|
|
+ */
|
|
|
+ public String insertormodify_bannermag() throws D3bException, P2Exception {
|
|
|
+ long tbannerlocationid = content.getLong("tbannerlocationid");
|
|
|
+ long tbannermagid = content.getLong("tbannermagid");//新增传0
|
|
|
+ boolean fisused = content.getBooleanValue("fisused");
|
|
|
+ String fhyperlink = content.getString("fhyperlink", "tbannermag.fhyperlink", "广告链接URL");
|
|
|
+ String flinktype = content.getString("flinktype");
|
|
|
+ String fdatatable = content.getString("fdatatable");
|
|
|
+ long fdataid = content.getLongValue("fdataid");
|
|
|
+
|
|
|
+ PaoSetRemote tbannermagSet = getP2ServerSystemPaoSet("tbannermag", "siteid='" + siteid + "' and tbannermagid='" + tbannermagid + "'");
|
|
|
+ PaoRemote tbannermag = null;
|
|
|
+ if (tbannermagid <= 0 || tbannermagSet.isEmpty()) {
|
|
|
+ tbannermag = tbannermagSet.addAtEnd();
|
|
|
+ tbannermag.setValue("tbannerlocationid", tbannerlocationid, 11L);//企业ID
|
|
|
+ tbannermag.setValue("siteid", siteid, 11L);//企业ID
|
|
|
+ tbannermag.setValue("createby", username, 11L);//录入人
|
|
|
+ tbannermag.setValue("createdate", sysdate, 11L);//录入时间
|
|
|
+ } else {
|
|
|
+ tbannermag = tbannermagSet.getPao(0);
|
|
|
+ }
|
|
|
+ tbannermag.setValue("fisused", fisused, 11L);//是否启用
|
|
|
+ tbannermag.setValue("flinktype", flinktype, 11L);//链接类型
|
|
|
+ if ("DATA".equals(flinktype)) {
|
|
|
+ tbannermag.setValue("fdatatable", fdatatable, 11L);//公告内容
|
|
|
+ tbannermag.setValue("fdataid", fdataid, 11L);//是否私密
|
|
|
+ } else if ("URL".equals(flinktype)) {
|
|
|
+ tbannermag.setValue("fhyperlink", fhyperlink, 11L);//广告链接url
|
|
|
+ }
|
|
|
+ tbannermag.setValue("changeby", username, 11L);//修改人
|
|
|
+ tbannermag.setValue("changedate", sysdate, 11L);//修改时间
|
|
|
+ tbannermagSet.save();
|
|
|
+ return getSucReturnObject().toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ public String delete_bannermag() throws P2Exception {
|
|
|
+ long tbannerlocationid = content.getLong("tbannerlocationid");
|
|
|
+ long tbannermagid = content.getLong("tbannermagid");//新增传0
|
|
|
+ String status = dbConnect.runSqlUpdate("delete from tbannermag where siteid='" + siteid + "' and tbannerlocationid='" + tbannerlocationid + "' and tbannermagid='" + tbannermagid + "'");
|
|
|
+ if ("true".equals(status)) {
|
|
|
+ return getSucReturnObject().toString();
|
|
|
+ } else {
|
|
|
+ return getErrReturnObject().setErrMsg(status).toString();
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|