|
|
@@ -15,6 +15,7 @@
|
|
|
*/
|
|
|
package com.java110.common.cmd.marketSms;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.java110.core.annotation.Java110Cmd;
|
|
|
import com.java110.core.annotation.Java110Transactional;
|
|
|
@@ -23,10 +24,13 @@ import com.java110.core.event.cmd.Cmd;
|
|
|
import com.java110.core.event.cmd.CmdEvent;
|
|
|
import com.java110.core.factory.GenerateCodeFactory;
|
|
|
import com.java110.intf.common.IMarketSmsV1InnerServiceSMO;
|
|
|
+import com.java110.intf.common.IMarketSmsValueV1InnerServiceSMO;
|
|
|
import com.java110.po.marketSms.MarketSmsPo;
|
|
|
+import com.java110.po.marketSmsValue.MarketSmsValuePo;
|
|
|
import com.java110.utils.exception.CmdException;
|
|
|
import com.java110.utils.util.Assert;
|
|
|
import com.java110.utils.util.BeanConvertUtil;
|
|
|
+import com.java110.utils.util.StringUtil;
|
|
|
import com.java110.vo.ResultVo;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.slf4j.Logger;
|
|
|
@@ -52,11 +56,30 @@ public class SaveMarketSmsCmd extends Cmd {
|
|
|
@Autowired
|
|
|
private IMarketSmsV1InnerServiceSMO marketSmsV1InnerServiceSMOImpl;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IMarketSmsValueV1InnerServiceSMO marketSmsValueV1InnerServiceSMOImpl;
|
|
|
+
|
|
|
@Override
|
|
|
public void validate(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) {
|
|
|
Assert.hasKeyAndValue(reqJson, "smsName", "请求报文中未包含smsName");
|
|
|
-Assert.hasKeyAndValue(reqJson, "smsType", "请求报文中未包含smsType");
|
|
|
-Assert.hasKeyAndValue(reqJson, "remark", "请求报文中未包含remark");
|
|
|
+ Assert.hasKeyAndValue(reqJson, "smsType", "请求报文中未包含smsType");
|
|
|
+ Assert.hasKeyAndValue(reqJson, "remark", "请求报文中未包含remark");
|
|
|
+
|
|
|
+ if (!reqJson.containsKey("smsTypeValues")) {
|
|
|
+ throw new CmdException("未包含配置信息");
|
|
|
+ }
|
|
|
+
|
|
|
+ JSONArray smsTypeValues = reqJson.getJSONArray("smsTypeValues");
|
|
|
+
|
|
|
+ if (smsTypeValues == null || smsTypeValues.size() < 1) {
|
|
|
+ throw new CmdException("未包含配置信息");
|
|
|
+ }
|
|
|
+
|
|
|
+ for (int typeIndex = 0; typeIndex < smsTypeValues.size(); typeIndex++) {
|
|
|
+ if (StringUtil.isEmpty(smsTypeValues.getJSONObject(typeIndex).getString("smsValue"))) {
|
|
|
+ throw new CmdException("未填写" + smsTypeValues.getJSONObject(typeIndex).getString("name"));
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|
|
|
@@ -64,7 +87,7 @@ Assert.hasKeyAndValue(reqJson, "remark", "请求报文中未包含remark");
|
|
|
@Java110Transactional
|
|
|
public void doCmd(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) throws CmdException {
|
|
|
|
|
|
- MarketSmsPo marketSmsPo = BeanConvertUtil.covertBean(reqJson, MarketSmsPo.class);
|
|
|
+ MarketSmsPo marketSmsPo = BeanConvertUtil.covertBean(reqJson, MarketSmsPo.class);
|
|
|
marketSmsPo.setSmsId(GenerateCodeFactory.getGeneratorId(CODE_PREFIX_ID));
|
|
|
int flag = marketSmsV1InnerServiceSMOImpl.saveMarketSms(marketSmsPo);
|
|
|
|
|
|
@@ -72,6 +95,22 @@ Assert.hasKeyAndValue(reqJson, "remark", "请求报文中未包含remark");
|
|
|
throw new CmdException("保存数据失败");
|
|
|
}
|
|
|
|
|
|
+ JSONArray smsTypeValues = reqJson.getJSONArray("smsTypeValues");
|
|
|
+
|
|
|
+ JSONObject value = null;
|
|
|
+
|
|
|
+ MarketSmsValuePo marketSmsValuePo = null;
|
|
|
+ for (int typeIndex = 0; typeIndex < smsTypeValues.size(); typeIndex++) {
|
|
|
+ value = smsTypeValues.getJSONObject(typeIndex);
|
|
|
+ marketSmsValuePo = BeanConvertUtil.covertBean(value, MarketSmsValuePo.class);
|
|
|
+ marketSmsValuePo.setValueId(GenerateCodeFactory.getGeneratorId(CODE_PREFIX_ID));
|
|
|
+ marketSmsValuePo.setSmsId(marketSmsPo.getSmsId());
|
|
|
+ flag = marketSmsValueV1InnerServiceSMOImpl.saveMarketSmsValue(marketSmsValuePo);
|
|
|
+ if (flag < 1) {
|
|
|
+ throw new CmdException("保存数据失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
cmdDataFlowContext.setResponseEntity(ResultVo.success());
|
|
|
}
|
|
|
}
|