From c676add07728e6622c08f91ca05a790bad6b11fb Mon Sep 17 00:00:00 2001
From: Your Name <you@example.com>
Date: 星期二, 21 二月 2023 23:58:51 +0800
Subject: [PATCH] 优化考勤功能
---
service-common/src/main/java/com/java110/common/cmd/marketSms/SaveMarketSmsCmd.java | 45 ++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 42 insertions(+), 3 deletions(-)
diff --git a/service-common/src/main/java/com/java110/common/cmd/marketSms/SaveMarketSmsCmd.java b/service-common/src/main/java/com/java110/common/cmd/marketSms/SaveMarketSmsCmd.java
index 742faa5..dfc56f8 100644
--- a/service-common/src/main/java/com/java110/common/cmd/marketSms/SaveMarketSmsCmd.java
+++ b/service-common/src/main/java/com/java110/common/cmd/marketSms/SaveMarketSmsCmd.java
@@ -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.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 @@
@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 @@
@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 @@
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());
}
}
--
Gitblit v1.8.0