eganwu 1 vuosi sitten
vanhempi
commit
f6f47afa3f

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

@@ -5487,6 +5487,11 @@ public class R {
         public static class v1 {
         }
     }
+
+    public static class ID20240313102402 {
+        public static class v1 {
+        }
+    }
 }
 
 

+ 1 - 1
src/custom/restcontroller/webmanage/saletool/notice/SQL/通告板块列表查询.sql

@@ -1 +1 @@
-select sat_notice_classid,classname,issecret,issystem from sat_notice_class where $where$ and siteid=$siteid$ 
+select sat_notice_classid,classname,issecret,issystem,isenable,sequence from sat_notice_class where $where$ and siteid=$siteid$

+ 0 - 23
src/custom/restcontroller/webmanage/saletool/notice/SQL/通告版块新增.sql

@@ -1,23 +0,0 @@
-INSERT INTO sat_notice_class (sat_notice_classid, 
-                                  siteid,
-                                  createby,
-                                  createdate,
-                                  changeby,
-                                  changedate,
-                                  classname,
-                                  issystem,
-                                  issecret)
-VALUES ($sat_notice_classid$,
-        $siteid$,
-        $createby$,
-        CURRENT_TIME,
-        $changeby$,
-        CURRENT_TIME,
-        $classname$,
-        0,
-        $issecret$)
-
-
-
-
-

+ 0 - 7
src/custom/restcontroller/webmanage/saletool/notice/SQL/通告版块更新.sql

@@ -1,7 +0,0 @@
-UPDATE sat_notice_class
-SET classname=$classname$,
-    changedate = CURRENT_TIME,
-    changeby = $changeby$,
-    issystem = 0,
-    issecret = $issecret$
-WHERE sat_notice_classid = $sat_notice_classid$ 

+ 2 - 2
src/custom/restcontroller/webmanage/saletool/notice/notice.java

@@ -37,7 +37,7 @@ public class notice extends Controller {
             insertSQL.setSiteid(siteid);
             insertSQL.setUniqueid(sat_noticeid);
             insertSQL.setValue("title", content.getString("title"));
-            insertSQL.setValue("status", content.getString("status"));
+//            insertSQL.setValue("status", content.getString("status"));
             insertSQL.setValue("publishdate", content.getStringValueForDate("publishdate", "yyyy-MM-dd", "null"));
             insertSQL.setValue("sat_notice_classid", content.getLongValue("sat_notice_classid"));
             insertSQL.setValue("content", content.getString("content", true));
@@ -48,7 +48,7 @@ public class notice extends Controller {
             updateSQL.setSiteid(siteid);
             updateSQL.setUniqueid(sat_noticeid);
             updateSQL.setValue("title", content.getString("title"));
-            updateSQL.setValue("status", content.getString("status"));
+//            updateSQL.setValue("status", content.getString("status"));
             updateSQL.setValue("publishdate", content.getStringValueForDate("publishdate", "yyyy-MM-dd", "null"));
             updateSQL.setValue("sat_notice_classid", content.getLongValue("sat_notice_classid"));
             updateSQL.setValue("content", content.getString("content", true));

+ 52 - 34
src/custom/restcontroller/webmanage/saletool/notice/noticeclass.java

@@ -4,14 +4,17 @@ import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 
 import beans.data.BatchDeleteErr;
+import com.mysql.cj.x.protobuf.MysqlxCrud;
 import common.Controller;
 import common.YosException;
 import common.annotation.API;
 import common.annotation.CACHEING;
 import common.annotation.CACHEING_CLEAN;
 import common.annotation.cm;
+import common.data.InsertSQL;
 import common.data.Rows;
 import common.data.SQLFactory;
+import common.data.UpdateSQL;
 import restcontroller.R;
 
 import java.util.ArrayList;
@@ -31,8 +34,8 @@ public class noticeclass extends Controller {
     @API(title = "通告板块新增修改", apiversion = R.ID20221101094503.v1.class)
     @CACHEING_CLEAN(cms = {@cm(clazz = noticeclass.class, method = {"queryNoticeClass"})})
     public String insertormodify_noticeclass() throws YosException {
-        long sat_notice_classid = content.getLong("sat_notice_classid");
-        String classname = content.getString("classname");
+        long sat_notice_classid = content.getLongValue("sat_notice_classid");
+        String classname = content.getStringValue("classname");
         ArrayList<String> sqllist = new ArrayList<>();
         if (sat_notice_classid <= 0 || dbConnect.runSqlQuery("select sat_notice_classid from sat_notice_class where sat_notice_classid=" + sat_notice_classid).isEmpty()) {
 
@@ -40,26 +43,25 @@ public class noticeclass extends Controller {
             if (!rows.isEmpty() && rows.get(0).getLong("count") > 0) {
                 return getErrReturnObject().setErrMsg("通告板块已存在").toString();
             }
-            SQLFactory sqlAddFactory = new SQLFactory(this, "通告版块新增");
-            sqlAddFactory.addParameter("sat_notice_classid", createTableID("sat_notice_class"));
-            sqlAddFactory.addParameter("siteid", siteid);
-            sqlAddFactory.addParameter("createby", username);
-            sqlAddFactory.addParameter("changeby", username);
-            sqlAddFactory.addParameter("classname", classname);
-            sqlAddFactory.addParameter("issecret", content.getBooleanValue("issecret"));
-            sqllist.add(sqlAddFactory.getSQL());
+            InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "sat_notice_class");
+            insertSQL.setUniqueid(createTableID("sat_notice_class"));
+            insertSQL.setSiteid(siteid);
+            insertSQL.setValue("classname", classname);
+            insertSQL.setValue("isenable", content.getBooleanValue("isenable"));
+            insertSQL.setValue("sequence", content.getLongValue("sequence"));
+            sqllist.add(insertSQL.getSQL());
         } else {
-            Rows rows = dbConnect.runSqlQuery("SELECT COUNT(*) count FROM sat_notice_class WHERE sat_notice_classid!=" + content.getLong("sat_notice_classid") + " and classname = '" + classname + "' and siteid='" + siteid + "'");
+            Rows rows = dbConnect.runSqlQuery("SELECT COUNT(*) count FROM sat_notice_class WHERE sat_notice_classid!=" + sat_notice_classid + " and classname = '" + classname + "' and siteid='" + siteid + "'");
             if (!rows.isEmpty() && rows.get(0).getLong("count") > 0) {
                 return getErrReturnObject().setErrMsg("通告板块已存在").toString();
             }
-            SQLFactory sqlUpdateFactory = new SQLFactory(this, "通告版块更新");
-            sqlUpdateFactory.addParameter("sat_notice_classid", content.getLong("sat_notice_classid"));
-            sqlUpdateFactory.addParameter("siteid", siteid);
-            sqlUpdateFactory.addParameter("changeby", username);
-            sqlUpdateFactory.addParameter("classname", classname);
-            sqlUpdateFactory.addParameter("issecret", content.getBooleanValue("issecret"));
-            sqllist.add(sqlUpdateFactory.getSQL());
+            UpdateSQL updateSQL = SQLFactory.createUpdateSQL(this, "sat_notice_class");
+            updateSQL.setSiteid(siteid);
+            updateSQL.setUniqueid(sat_notice_classid);
+            updateSQL.setValue("classname", classname);
+            updateSQL.setValue("isenable", content.getBooleanValue("isenable"));
+            updateSQL.setValue("sequence", content.getLongValue("sequence"));
+            sqllist.add(updateSQL.getSQL());
         }
         dbConnect.runSqlUpdate(sqllist);
         return getSucReturnObject().toString();
@@ -71,7 +73,6 @@ public class noticeclass extends Controller {
      * @return
      */
     @API(title = "查询", apiversion = R.ID20221101094603.v1.class)
-    @CACHEING
     public String queryNoticeClass() throws YosException {
 
         /*
@@ -90,11 +91,15 @@ public class noticeclass extends Controller {
             if (whereObject.containsKey("issecret") && !"".equals(whereObject.getString("issecret"))) {
                 where = where + " and issecret = '" + whereObject.getString("issecret") + "'";
             }
+
+            if (whereObject.containsKey("isenable") && !"".equals(whereObject.getString("isenable"))) {
+                where = where + " and isenable = '" + whereObject.getString("isenable") + "'";
+            }
         }
         /*
           SQL通告板块查询参数设置并查询
          */
-        SQLFactory factory = new SQLFactory(this, "通告板块列表查询", pageSize, pageNumber, "createdate desc");
+        SQLFactory factory = new SQLFactory(this, "通告板块列表查询", pageSize, pageNumber, "sequence");
         factory.addParameter("siteid", siteid);
         factory.addParameter_SQL("where", where);
         Rows rows = dbConnect.runSqlQuery(factory.getSQL());
@@ -106,36 +111,49 @@ public class noticeclass extends Controller {
     @CACHEING_CLEAN(cms = {@cm(clazz = noticeclass.class, method = {"queryNoticeClass"}), @cm(clazz = notice.class, method = {"queryNoticeList"})})
     public String delete() throws YosException {
         JSONArray sat_notice_classids = content.getJSONArray("sat_notice_classids");
-        BatchDeleteErr batchDeleteErr = BatchDeleteErr.create(this, sat_notice_classids.size());
+        ArrayList<String> sqllist = new ArrayList<>();
         for (Object o : sat_notice_classids) {
             long sat_notice_classid = Long.parseLong(o.toString());
             Rows rowscount = dbConnect.runSqlQuery("select issystem,siteid from sat_notice_class where sat_notice_classid=" + sat_notice_classid);
             if (rowscount.isEmpty()) {
-                batchDeleteErr.addErr(sat_notice_classid, "此通告板块不存在,无法删除");
-                continue;
-            } else {
-                if (rowscount.get(0).getBoolean("issystem")) {
-                    batchDeleteErr.addErr(sat_notice_classid, "该通告板块为系统板块无法删除");
-                    continue;
-                }
+                return getErrReturnObject().setErrMsg("通告板块不存在,无法删除").toString();
+            }
+            if (rowscount.get(0).getBoolean("issystem")) {
+                return getErrReturnObject().setErrMsg("该通告板块为系统板块,无法删除").toString();
             }
             Rows rowssite = dbConnect.runSqlQuery("select sat_notice_classid from sat_notice_class where issystem=1 and siteid='" + rowscount.get(0).getString("siteid") + "'");
             if (rowssite.isEmpty() && !dbConnect.runSqlQuery("select sat_noticeid from sat_notice where sat_notice_classid=" + sat_notice_classid).isEmpty()) {
-                batchDeleteErr.addErr(sat_notice_classid, "该通告板块所属站点不存在系统板块无法删除");
-                continue;
+                return getErrReturnObject().setErrMsg("该通告板块所属站点不存在系统板块无法删除").toString();
+            }
+            if (dbConnect.runSqlQuery("select 1 from sat_notice where sat_notice_classid=" + sat_notice_classid).isNotEmpty()) {
+                return getErrReturnObject().setErrMsg("当前分类已存在通告,不可删除").toString();
             }
-            ArrayList<String> sqllist = new ArrayList<>();
             String deletesql = "DELETE FROM sat_notice_class WHERE sat_notice_classid = '" + sat_notice_classid + "'";
             sqllist.add(deletesql);
             if (!rowssite.isEmpty()) {
                 String updatesql = "update sat_notice set sat_notice_classid=" + rowssite.get(0).getLong("sat_notice_classid") + " where sat_notice_classid = '" + sat_notice_classid + "'";
                 sqllist.add(updatesql);
             }
+        }
+        dbConnect.runSqlUpdate(sqllist);
+        return getSucReturnObject().toString();
 
-            dbConnect.runSqlUpdate(sqllist);
+    }
 
-        }
-        return batchDeleteErr.getReturnObject().toString();
+    @API(title = "删除", apiversion = R.ID20240313102402.v1.class)
+    @CACHEING_CLEAN(cms = {@cm(clazz = noticeclass.class, method = {"queryNoticeClass"}), @cm(clazz = notice.class, method = {"queryNoticeList"})})
+    public String isenadle() throws YosException {
+        JSONArray sat_notice_classids = content.getJSONArray("sat_notice_classids");
+
+        UpdateSQL updateSQL=SQLFactory.createUpdateSQL(this,"sat_notice_class");
+        updateSQL.setSiteid(siteid);
+        updateSQL.setValue("isenable", content.getBooleanValue("isenable"));
+        updateSQL.setWhere("sat_notice_classid ", sat_notice_classids.toArray());
+        updateSQL.update();
 
+
+
+        return getSucReturnObject().toString();
     }
+
 }