From 89eeb1655ab3a342fe9b19986e4aa5e58cf39575 Mon Sep 17 00:00:00 2001
From: java110 <928255095@qq.com>
Date: 星期一, 28 二月 2022 19:15:19 +0800
Subject: [PATCH] 完成物业公司添加功能

---
 service-store/src/main/java/com/java110/store/api/StoreApi.java |  107 ++++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 80 insertions(+), 27 deletions(-)

diff --git a/service-store/src/main/java/com/java110/store/api/StoreApi.java b/service-store/src/main/java/com/java110/store/api/StoreApi.java
old mode 100644
new mode 100755
index 6f9fb6d..4354f5c
--- a/service-store/src/main/java/com/java110/store/api/StoreApi.java
+++ b/service-store/src/main/java/com/java110/store/api/StoreApi.java
@@ -1,16 +1,37 @@
+/*
+ * Copyright 2017-2020 鍚村鏂� and java110 team.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 package com.java110.store.api;
 
 import com.alibaba.fastjson.JSONObject;
-import com.java110.utils.constant.ResponseConstant;
-import com.java110.utils.exception.InitConfigDataException;
-import com.java110.utils.exception.InitDataFlowContextException;
 import com.java110.core.base.controller.BaseController;
 import com.java110.core.context.BusinessServiceDataFlow;
 import com.java110.core.factory.DataTransactionFactory;
+import com.java110.po.store.StorePo;
+import com.java110.store.bmo.store.IUpdateStoreStateBMO;
 import com.java110.store.smo.IStoreServiceSMO;
+import com.java110.utils.cache.MappingCache;
+import com.java110.utils.constant.ResponseConstant;
+import com.java110.utils.exception.InitConfigDataException;
+import com.java110.utils.exception.InitDataFlowContextException;
+import com.java110.utils.util.Assert;
+import com.java110.vo.ResultVo;
 import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import com.java110.core.log.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.ResponseEntity;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
@@ -21,7 +42,8 @@
 import java.util.Map;
 
 /**
- * 鐢ㄦ埛鏈嶅姟绫�
+ * 鍟嗘埛瀵瑰鎺ュ彛绫�
+ * 涓昏鍖呭惈 鍟嗘埛鐩稿叧鎺ュ彛淇℃伅
  * Created by wuxw on 2018/5/14.
  */
 @RestController
@@ -29,20 +51,24 @@
     private final static Logger logger = LoggerFactory.getLogger(StoreApi.class);
 
     @Autowired
+    private IUpdateStoreStateBMO updateStoreStateBMOImpl;
+
+    @Autowired
     IStoreServiceSMO storeServiceSMOImpl;
 
-    @RequestMapping(path = "/storeApi/service",method= RequestMethod.GET)
+    @RequestMapping(path = "/storeApi/service", method = RequestMethod.GET)
     public String serviceGet(HttpServletRequest request) {
-        return DataTransactionFactory.createBusinessResponseJson(ResponseConstant.RESULT_CODE_ERROR,"涓嶆敮鎸丟et鏂规硶璇锋眰").toJSONString();
+        return DataTransactionFactory.createBusinessResponseJson(ResponseConstant.RESULT_CODE_ERROR, "涓嶆敮鎸丟et鏂规硶璇锋眰").toJSONString();
     }
 
     /**
      * 鍟嗘埛鏈嶅姟缁熶竴澶勭悊鎺ュ彛
+     *
      * @param orderInfo
      * @param request
      * @return
      */
-    @RequestMapping(path = "/storeApi/service",method= RequestMethod.POST)
+    @RequestMapping(path = "/storeApi/service", method = RequestMethod.POST)
     public String servicePost(@RequestBody String orderInfo, HttpServletRequest request) {
         BusinessServiceDataFlow businessServiceDataFlow = null;
         JSONObject responseJson = null;
@@ -53,24 +79,26 @@
             preValiateOrderInfo(orderInfo);
             businessServiceDataFlow = this.writeDataToDataFlowContext(orderInfo, headers);
             responseJson = storeServiceSMOImpl.service(businessServiceDataFlow);
-        }catch (InitDataFlowContextException e){
-            logger.error("璇锋眰鎶ユ枃閿欒,鍒濆鍖� BusinessServiceDataFlow澶辫触"+orderInfo,e);
-            responseJson = DataTransactionFactory.createNoBusinessTypeBusinessResponseJson(orderInfo,ResponseConstant.RESULT_PARAM_ERROR,e.getMessage(),null);
-        }catch (InitConfigDataException e){
-            logger.error("璇锋眰鎶ユ枃閿欒,鍔犺浇閰嶇疆淇℃伅澶辫触"+orderInfo,e);
-            responseJson = DataTransactionFactory.createNoBusinessTypeBusinessResponseJson(orderInfo,ResponseConstant.RESULT_PARAM_ERROR,e.getMessage(),null);
-        }catch (Exception e){
-            logger.error("璇锋眰璁㈠崟寮傚父",e);
-            responseJson = DataTransactionFactory.createBusinessResponseJson(businessServiceDataFlow,ResponseConstant.RESULT_CODE_ERROR,e.getMessage()+e,
+        } catch (InitDataFlowContextException e) {
+            logger.error("璇锋眰鎶ユ枃閿欒,鍒濆鍖� BusinessServiceDataFlow澶辫触" + orderInfo, e);
+            responseJson = DataTransactionFactory.createNoBusinessTypeBusinessResponseJson(orderInfo, ResponseConstant.RESULT_PARAM_ERROR, e.getMessage(), null);
+        } catch (InitConfigDataException e) {
+            logger.error("璇锋眰鎶ユ枃閿欒,鍔犺浇閰嶇疆淇℃伅澶辫触" + orderInfo, e);
+            responseJson = DataTransactionFactory.createNoBusinessTypeBusinessResponseJson(orderInfo, ResponseConstant.RESULT_PARAM_ERROR, e.getMessage(), null);
+        } catch (Exception e) {
+            logger.error("璇锋眰璁㈠崟寮傚父", e);
+            responseJson = DataTransactionFactory.createBusinessResponseJson(businessServiceDataFlow, ResponseConstant.RESULT_CODE_ERROR, e.getMessage() + e,
                     null);
-        }finally {
-            logger.debug("storeApi 璇锋眰鎶ユ枃{},杩斿洖鎶ユ枃锛歿}",orderInfo,responseJson.toJSONString());
-            return responseJson.toJSONString();
+        } finally {
+            logger.debug("storeApi 璇锋眰鎶ユ枃{},杩斿洖鎶ユ枃锛歿}", orderInfo, responseJson.toJSONString());
         }
+        
+        return responseJson.toJSONString();
     }
 
     /**
      * 杩欓噷棰勬牎楠岋紝璇锋眰鎶ユ枃涓笉鑳芥湁 dataFlowId
+     *
      * @param orderInfo
      */
     private void preValiateOrderInfo(String orderInfo) {
@@ -81,17 +109,18 @@
 
     /**
      * 鑾峰彇璇锋眰淇℃伅
+     *
      * @param request
      * @param headers
      * @throws RuntimeException
      */
-    private void getRequestInfo(HttpServletRequest request,Map headers) throws Exception{
-        try{
-            super.initHeadParam(request,headers);
-            super.initUrlParam(request,headers);
-        }catch (Exception e){
-            logger.error("鍔犺浇澶翠俊鎭け璐�",e);
-            throw new InitConfigDataException(ResponseConstant.RESULT_PARAM_ERROR,"鍔犺浇澶翠俊鎭け璐�");
+    private void getRequestInfo(HttpServletRequest request, Map headers) throws Exception {
+        try {
+            super.initHeadParam(request, headers);
+            super.initUrlParam(request, headers);
+        } catch (Exception e) {
+            logger.error("鍔犺浇澶翠俊鎭け璐�", e);
+            throw new InitConfigDataException(ResponseConstant.RESULT_PARAM_ERROR, "鍔犺浇澶翠俊鎭け璐�");
         }
     }
 
@@ -102,4 +131,28 @@
     public void setStoreServiceSMOImpl(IStoreServiceSMO storeServiceSMOImpl) {
         this.storeServiceSMOImpl = storeServiceSMOImpl;
     }
+
+    /**
+     * 淇敼鍟嗘埛鐘舵��
+     *
+     * @param reqJson 璇锋眰瀵硅薄
+     * @return
+     */
+    @RequestMapping(value = "/storeApi/updateStoreState", method = RequestMethod.POST)
+    public ResponseEntity<String> updateStoreState(@RequestBody JSONObject reqJson) {
+
+        String env = MappingCache.getValue("HC_ENV");
+
+        if (!"PROD".equals(env)) {
+            return ResultVo.error("婕旂ず鐜锛屼笉鍏佽鎿嶄綔");
+        }
+
+        Assert.hasKeyAndValue(reqJson, "storeId", "鏈寘鍚晢鎴蜂俊鎭�");
+        Assert.hasKeyAndValue(reqJson, "state", "鏈寘鍚晢鎴风姸鎬�");
+
+        StorePo storePo = new StorePo();
+        storePo.setStoreId(reqJson.getString("storeId"));
+        storePo.setState(reqJson.getString("state"));
+        return updateStoreStateBMOImpl.update(storePo);
+    }
 }

--
Gitblit v1.8.0