|
@@ -1,7 +1,9 @@
|
|
|
package com.cnd3b.restcontroller.enterprise.tagentauth;
|
|
package com.cnd3b.restcontroller.enterprise.tagentauth;
|
|
|
|
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.cnd3b.common.Controller;
|
|
import com.cnd3b.common.Controller;
|
|
|
|
|
+import com.cnd3b.common.data.Row;
|
|
|
import com.cnd3b.common.data.Rows;
|
|
import com.cnd3b.common.data.Rows;
|
|
|
import com.cnd3b.common.data.SQLFactory;
|
|
import com.cnd3b.common.data.SQLFactory;
|
|
|
import p2.common.parse.S;
|
|
import p2.common.parse.S;
|
|
@@ -9,6 +11,8 @@ import p2.pao.PaoRemote;
|
|
|
import p2.pao.PaoSetRemote;
|
|
import p2.pao.PaoSetRemote;
|
|
|
import p2.util.P2Exception;
|
|
import p2.util.P2Exception;
|
|
|
|
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
|
+
|
|
|
public class tagentauth extends Controller {
|
|
public class tagentauth extends Controller {
|
|
|
/**
|
|
/**
|
|
|
* 构造函数
|
|
* 构造函数
|
|
@@ -28,19 +32,38 @@ public class tagentauth extends Controller {
|
|
|
//经销商id
|
|
//经销商id
|
|
|
String tagentsid = content.getString("tagentsid");
|
|
String tagentsid = content.getString("tagentsid");
|
|
|
//体系类型
|
|
//体系类型
|
|
|
- String fauthtype = content.getString("fauthtype");
|
|
|
|
|
- if (tagentsid == null || tagentsid.equals("")) {
|
|
|
|
|
- return getErrReturnObject().setErrMsg("经销商id为空").toString();
|
|
|
|
|
|
|
+ JSONArray fauthtype = content.getJSONArray("fauthtype");
|
|
|
|
|
+
|
|
|
|
|
+ ArrayList<String> list = new ArrayList<>();
|
|
|
|
|
+ for (Object obj : fauthtype) {
|
|
|
|
|
+ list.add(obj.toString());
|
|
|
}
|
|
}
|
|
|
- if (fauthtype == null || fauthtype.equals("")) {
|
|
|
|
|
- return getErrReturnObject().setErrMsg("体系类型不能为空").toString();
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ SQLFactory sqlFactory = new SQLFactory(this, "查询体系是否存在");
|
|
|
|
|
+ sqlFactory.addParameter_in("fauthtype", list);
|
|
|
|
|
+ sqlFactory.addParameter("tagentsid", tagentsid);
|
|
|
|
|
+ String sql = sqlFactory.getSQL();
|
|
|
|
|
+ Rows rows = dbConnect.runSqlQuery(sql);
|
|
|
|
|
+
|
|
|
|
|
+ if (!rows.isEmpty()) {
|
|
|
|
|
+ String msg = "";
|
|
|
|
|
+ for (Row row : rows) {
|
|
|
|
|
+ msg = msg + row.getString("fauthtype") + ",";
|
|
|
|
|
+ }
|
|
|
|
|
+ return getErrReturnObject().setErrMsg("新增失败,下列体系已授权:" + msg.substring(0, msg.length() - 1)).toString();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //新增体系
|
|
|
|
|
+ for (Object obj : fauthtype) {
|
|
|
|
|
+ //新增
|
|
|
|
|
+ PaoSetRemote paoSetRemote = getP2ServerSystemPaoSet("tagentauth");
|
|
|
|
|
+ PaoRemote paoRemote = paoSetRemote.addAtEnd();
|
|
|
|
|
+ paoRemote.setValue("tagentsid", tagentsid, 11L);
|
|
|
|
|
+ paoRemote.setValue("fauthtype", obj.toString(), 11L);
|
|
|
|
|
+ paoSetRemote.save();
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
- //新增
|
|
|
|
|
- PaoSetRemote paoSetRemote = getP2ServerSystemPaoSet("tagentauth");
|
|
|
|
|
- PaoRemote paoRemote = paoSetRemote.addAtEnd();
|
|
|
|
|
- paoRemote.setValue("tagentsid", tagentsid, 11L);
|
|
|
|
|
- paoRemote.setValue("fauthtype", fauthtype, 11L);
|
|
|
|
|
- paoSetRemote.save();
|
|
|
|
|
return getSucReturnObject().toString();
|
|
return getSucReturnObject().toString();
|
|
|
}
|
|
}
|
|
|
|
|
|