|
|
@@ -0,0 +1,82 @@
|
|
|
+package restcontroller.webmanage.sale.EnterpriseItem;
|
|
|
+
|
|
|
+import beans.data.BatchDeleteErr;
|
|
|
+import beans.itemclass.ItemClass;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import common.Controller;
|
|
|
+import common.YosException;
|
|
|
+import common.annotation.API;
|
|
|
+import common.annotation.CACHEING;
|
|
|
+import common.data.*;
|
|
|
+import restcontroller.R;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+
|
|
|
+
|
|
|
+public class EnterpriseSaleItem extends Controller {
|
|
|
+ public EnterpriseSaleItem(JSONObject content) throws YosException {
|
|
|
+ super(content);
|
|
|
+ }
|
|
|
+
|
|
|
+ @API(title = "新增", apiversion = R.ID2025061813434703.v1.class)
|
|
|
+ public String insert() throws YosException {
|
|
|
+ Long sys_enterpriseid = content.getLong("sys_enterpriseid");
|
|
|
+ JSONArray itemids = content.getJSONArray("itemids");
|
|
|
+ Rows rows =dbConnect.runSqlQuery("select itemid from sys_enterprise_saleclass where sys_enterpriseid="+sys_enterpriseid+" and ifnull(itemid,0)!=0");
|
|
|
+ RowsMap rowsMap = rows.toRowsMap("itemid");
|
|
|
+ ArrayList<String> sqlList = new ArrayList<>();
|
|
|
+ for (Object obj : itemids) {
|
|
|
+ String id = String.valueOf(obj);
|
|
|
+ if(rowsMap.containsKey(id)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "sys_enterprise_saleclass");
|
|
|
+ insertSQL.setValue("sys_enterprise_saleclassid", createTableID("sys_enterprise_saleclass"));
|
|
|
+ insertSQL.setValue("siteid", siteid);
|
|
|
+ insertSQL.setValue("itemid", id);
|
|
|
+ insertSQL.setValue("sys_enterpriseid", sys_enterpriseid);
|
|
|
+ sqlList.add(insertSQL.getSQL());
|
|
|
+ }
|
|
|
+ dbConnect.runSqlUpdate(sqlList);
|
|
|
+
|
|
|
+ return getSucReturnObject().toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ @API(title = "列表", apiversion = R.ID2025061813521903.v1.class)
|
|
|
+ public String queryList() throws YosException {
|
|
|
+ Long sys_enterpriseid = content.getLong("sys_enterpriseid");
|
|
|
+// SQLFactory sqlFactory = new SQLFactory(this, "合作企业营销类别列表", pageSize, pageNumber, pageSorting);
|
|
|
+// sqlFactory.addParameter("siteid", siteid);
|
|
|
+// sqlFactory.addParameter("sys_enterpriseid", sys_enterpriseid);
|
|
|
+// String sql = sqlFactory.getSQL();
|
|
|
+// Rows rows = dbConnect.runSqlQuery(sql);
|
|
|
+
|
|
|
+ QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sys_enterprise_saleclass", "sys_enterprise_saleclassid", "itemid");
|
|
|
+ querySQL.setTableAlias("t1");
|
|
|
+ querySQL.addJoinTable(JOINTYPE.inner, "plm_item", "t3", "t3.itemid = t1.itemid and t3.siteid = t1.siteid","itemno","itemname");
|
|
|
+ querySQL.setSiteid(siteid);
|
|
|
+ querySQL.setWhere("t1.sys_enterpriseid",sys_enterpriseid);
|
|
|
+ querySQL.setWhere("ifnull(t1.itemid,0)!=0");
|
|
|
+ querySQL.setPage(pageSize, pageNumber);
|
|
|
+ querySQL.setOrderBy(pageSorting);
|
|
|
+ Rows rows = querySQL.query();
|
|
|
+
|
|
|
+ return getSucReturnObject().setData(rows).toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ @API(title = "删除", apiversion = R.ID2025061814031603.v1.class)
|
|
|
+ public String delete() throws YosException {
|
|
|
+ JSONArray sys_enterprise_saleclassids = content.getJSONArray("sys_enterprise_saleclassids");
|
|
|
+ ArrayList<String> list = new ArrayList<>();
|
|
|
+ for (Object o : sys_enterprise_saleclassids) {
|
|
|
+ long sys_enterprise_saleclassid = Long.parseLong(o.toString());
|
|
|
+ list.add("delete from sys_enterprise_saleclass where siteid='" + siteid
|
|
|
+ + "' and sys_enterprise_saleclassid=" + sys_enterprise_saleclassid);
|
|
|
+ }
|
|
|
+ dbConnect.runSqlUpdate(list);
|
|
|
+ return getSucReturnObject().toString();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|