From 372ac7412cc0b02bbd08730bbb4152f3af32a9d2 Mon Sep 17 00:00:00 2001
From: Your Name <you@example.com>
Date: 星期四, 26 一月 2023 02:11:30 +0800
Subject: [PATCH] 优化代码

---
 service-user/src/main/java/com/java110/user/cmd/owner/EditOwnerCarCmd.java |   18 ++++++++++++++----
 1 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/service-user/src/main/java/com/java110/user/cmd/owner/EditOwnerCarCmd.java b/service-user/src/main/java/com/java110/user/cmd/owner/EditOwnerCarCmd.java
index 40ea417..1844ce2 100644
--- a/service-user/src/main/java/com/java110/user/cmd/owner/EditOwnerCarCmd.java
+++ b/service-user/src/main/java/com/java110/user/cmd/owner/EditOwnerCarCmd.java
@@ -19,9 +19,8 @@
 import com.java110.core.annotation.Java110Cmd;
 import com.java110.core.annotation.Java110Transactional;
 import com.java110.core.context.ICmdDataFlowContext;
-import com.java110.core.event.cmd.AbstractServiceCmdListener;
+import com.java110.core.event.cmd.Cmd;
 import com.java110.core.event.cmd.CmdEvent;
-import com.java110.core.factory.GenerateCodeFactory;
 import com.java110.core.log.LoggerFactory;
 import com.java110.dto.owner.OwnerCarDto;
 import com.java110.intf.user.IOwnerCarV1InnerServiceSMO;
@@ -29,11 +28,13 @@
 import com.java110.utils.exception.CmdException;
 import com.java110.utils.util.Assert;
 import com.java110.utils.util.BeanConvertUtil;
+import com.java110.utils.util.DateUtil;
 import com.java110.utils.util.StringUtil;
 import com.java110.vo.ResultVo;
 import org.slf4j.Logger;
 import org.springframework.beans.factory.annotation.Autowired;
 
+import java.util.Date;
 import java.util.List;
 
 /**
@@ -47,7 +48,7 @@
  * // modify by 寮犱笁 at 2021-09-12 绗�10琛屽湪鏌愮鍦烘櫙涓嬪瓨鍦ㄦ煇绉峛ug 闇�瑕佷慨澶嶏紝娉ㄩ噴10鑷�20琛� 鍔犲叆 20琛岃嚦30琛�
  */
 @Java110Cmd(serviceCode = "owner.editOwnerCar")
-public class EditOwnerCarCmd extends AbstractServiceCmdListener {
+public class EditOwnerCarCmd extends Cmd {
 
     private static Logger logger = LoggerFactory.getLogger(EditOwnerCarCmd.class);
 
@@ -68,6 +69,7 @@
         OwnerCarDto ownerCarDto = new OwnerCarDto();
         ownerCarDto.setMemberId(reqJson.getString("memberId"));
         ownerCarDto.setCommunityId(reqJson.getString("communityId"));
+        ownerCarDto.setCarId(reqJson.getString("carId"));
         List<OwnerCarDto> ownerCarDtos = ownerCarV1InnerServiceSMOImpl.queryOwnerCars(ownerCarDto);
 
         Assert.listOnlyOne(ownerCarDtos, "鏈壘鍒拌溅杈嗕俊鎭�");
@@ -84,8 +86,16 @@
     @Java110Transactional
     public void doCmd(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) throws CmdException {
 
+        if (!reqJson.containsKey("leaseType")) {
+            reqJson.put("leaseType", OwnerCarDto.LEASE_TYPE_MONTH);
+        }
+
+        if (!OwnerCarDto.LEASE_TYPE_MONTH.equals(reqJson.getString("leaseType"))) {
+            reqJson.put("startTime", DateUtil.getFormatTimeString(new Date(), DateUtil.DATE_FORMATE_STRING_B));
+            reqJson.put("endTime", "2037-01-01");
+        }
+
         OwnerCarPo ownerCarPo = BeanConvertUtil.covertBean(reqJson, OwnerCarPo.class);
-        ownerCarPo.setMemberId(GenerateCodeFactory.getGeneratorId(CODE_PREFIX_ID));
         int flag = ownerCarV1InnerServiceSMOImpl.updateOwnerCar(ownerCarPo);
 
         if (flag < 1) {

--
Gitblit v1.8.0