Просмотр исходного кода

优化商户限制登录功能

java110 лет назад: 5
Родитель
Сommit
843adf9e3b

+ 9 - 0
java110-bean/src/main/java/com/java110/po/store/StorePo.java

@@ -21,6 +21,7 @@ public class StorePo implements Serializable {
     private String nearbyLandmarks;
     private String mapX;
     private String mapY;
+    private String state;
 
     public String getStoreId() {
         return storeId;
@@ -93,4 +94,12 @@ public class StorePo implements Serializable {
     public void setMapY(String mapY) {
         this.mapY = mapY;
     }
+
+    public String getState() {
+        return state;
+    }
+
+    public void setState(String state) {
+        this.state = state;
+    }
 }

+ 40 - 2
java110-db/src/main/resources/mapper/store/StoreServiceDaoImplMapper.xml

@@ -563,7 +563,8 @@
 
     <!--查询员工和商户信息-->
     <select id="getStoreUserInfo" parameterType="Map" resultType="Map">
-        select s.store_id,s.store_id storeId,s.b_id,s.user_id,s.user_id userId,s.name,s.address,s.tel,s.store_type_cd,s.store_type_cd storeTypeCd,
+        select s.store_id,s.store_id storeId,s.b_id,s.user_id,s.user_id
+        userId,s.name,s.address,s.tel,s.store_type_cd,s.store_type_cd storeTypeCd,
         s.nearby_landmarks,s.map_x,s.map_y,s.create_time,su.store_user_id,su.rel_cd,s.state
         from s_store s
         left join s_store_user su on s.store_id=su.store_id and su.status_cd = '0'
@@ -583,7 +584,7 @@
 
 
     <select id="getStoreStaffs" parameterType="Map" resultType="Map">
-        select t.name storeName,t.address,su.user_id staffId , t.store_id storeId,t.create_time createTime
+        select t.name storeName,t.address,su.user_id staffId , t.store_id storeId,t.create_time createTime,t.state
         from s_store t
         inner join s_store_user su on t.store_id = su.store_id and su.status_cd = '0'
         <if test="relCd != null and relCd != ''">
@@ -620,4 +621,41 @@
         </if>
         and t.status_cd = '0'
     </select>
+
+    <!-- 修改商户信息 add by wuxw 2018-07-03 -->
+    <update id="updateStore" parameterType="Map">
+        update s_store s
+        <set>
+            <if test="userId != null and userId != ''">
+                s.user_id = #{userId},
+            </if>
+            <if test="name != null and name != ''">
+                s.name = #{name},
+            </if>
+            <if test="address != null and address != ''">
+                s.address = #{address},
+            </if>
+            <if test="tel != null and tel != ''">
+                s.tel = #{tel},
+            </if>
+            <if test="storeTypeCd != null and storeTypeCd != ''">
+                s.store_type_cd = #{storeTypeCd},
+            </if>
+            <if test="nearbyLandmarks != null and nearbyLandmarks != ''">
+                s.nearby_landmarks = #{nearbyLandmarks},
+            </if>
+            <if test="mapX != null and mapX != ''">
+                s.map_x = #{mapX},
+            </if>
+            <if test="mapY != null and mapY != ''">
+                s.map_y = #{mapY},
+            </if>
+            <if test="state != null and state != ''">
+                s.state = #{state},
+            </if>
+        </set>
+        where 1=1
+        and s.store_id = #{storeId}
+        and s.status_cd = '0'
+    </update>
 </mapper>

+ 9 - 0
java110-interface/src/main/java/com/java110/intf/store/IStoreInnerServiceSMO.java

@@ -4,6 +4,7 @@ import com.java110.config.feign.FeignConfiguration;
 import com.java110.dto.store.StoreAttrDto;
 import com.java110.dto.store.StoreDto;
 import com.java110.dto.store.StoreUserDto;
+import com.java110.po.store.StorePo;
 import org.springframework.cloud.openfeign.FeignClient;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -28,6 +29,14 @@ public interface IStoreInnerServiceSMO {
     @RequestMapping(value = "/getStoreCount", method = RequestMethod.POST)
     public int getStoreCount(@RequestBody StoreDto storeDto);
 
+    /**
+     * 修改商户信息
+     * @param storePo
+     * @return
+     */
+    @RequestMapping(value = "/updateStore", method = RequestMethod.POST)
+    public int updateStore(@RequestBody StorePo storePo);
+
     /**
      * 查询员工和员工所属商户信息
      *

+ 15 - 0
service-store/src/main/java/com/java110/store/StoreServiceApplicationStart.java

@@ -1,3 +1,18 @@
+/*
+ * 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;
 
 import com.java110.core.annotation.Java110ListenerDiscovery;

+ 69 - 25
service-store/src/main/java/com/java110/store/api/StoreApi.java

@@ -1,16 +1,35 @@
+/*
+ * 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.constant.ResponseConstant;
+import com.java110.utils.exception.InitConfigDataException;
+import com.java110.utils.exception.InitDataFlowContextException;
+import com.java110.utils.util.Assert;
 import org.slf4j.Logger;
 import org.slf4j.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,28 +40,33 @@ import java.util.HashMap;
 import java.util.Map;
 
 /**
- * 用户服务类
+ * 商户对外接口类
+ * 主要包含 商户相关接口信息
  * Created by wuxw on 2018/5/14.
  */
 @RestController
 public class StoreApi extends BaseController {
     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,"不支持Get方法请求").toJSONString();
+        return DataTransactionFactory.createBusinessResponseJson(ResponseConstant.RESULT_CODE_ERROR, "不支持Get方法请求").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 +77,25 @@ public class StoreApi extends BaseController {
             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());
+        } finally {
+            logger.debug("storeApi 请求报文{},返回报文:{}", orderInfo, responseJson.toJSONString());
             return responseJson.toJSONString();
         }
     }
 
     /**
      * 这里预校验,请求报文中不能有 dataFlowId
+     *
      * @param orderInfo
      */
     private void preValiateOrderInfo(String orderInfo) {
@@ -81,17 +106,18 @@ public class StoreApi extends BaseController {
 
     /**
      * 获取请求信息
+     *
      * @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 +128,22 @@ public class StoreApi extends BaseController {
     public void setStoreServiceSMOImpl(IStoreServiceSMO storeServiceSMOImpl) {
         this.storeServiceSMOImpl = storeServiceSMOImpl;
     }
+
+    /**
+     * 修改商户状态
+     *
+     * @param reqJson 请求对象
+     * @return
+     */
+    @RequestMapping(value = "/storeApi/updateStoreState", method = RequestMethod.GET)
+    public ResponseEntity<String> updateStoreState(@RequestBody JSONObject reqJson) {
+
+        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);
+    }
 }

+ 36 - 0
service-store/src/main/java/com/java110/store/bmo/store/IUpdateStoreStateBMO.java

@@ -0,0 +1,36 @@
+/*
+ * 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.bmo.store;
+
+import com.java110.dto.store.StoreUserDto;
+import com.java110.po.store.StorePo;
+import org.springframework.http.ResponseEntity;
+
+/**
+ * 商户状态修改
+ * <p>
+ * add by 吴学文 2021-01-03
+ **/
+public interface IUpdateStoreStateBMO {
+
+    /**
+     * 查询商户员工
+     *
+     * @param storePo
+     * @return
+     */
+    ResponseEntity<String> update(StorePo storePo);
+}

+ 35 - 0
service-store/src/main/java/com/java110/store/bmo/store/impl/UpdateStoreStateBMOImpl.java

@@ -0,0 +1,35 @@
+package com.java110.store.bmo.store.impl;
+
+import com.java110.core.annotation.Java110Transactional;
+import com.java110.intf.store.IStoreInnerServiceSMO;
+import com.java110.po.store.StorePo;
+import com.java110.store.bmo.store.IUpdateStoreStateBMO;
+import com.java110.vo.ResultVo;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Service;
+
+/**
+ * @ClassName GetStoreStaffBMOImpl
+ * @Description TODO
+ * @Author wuxw
+ * @Date 2021/1/1 17:41
+ * @Version 1.0
+ * add by wuxw 2021/1/1
+ **/
+@Service(value = "updateStoreStateBMOImpl")
+public class UpdateStoreStateBMOImpl implements IUpdateStoreStateBMO {
+
+    @Autowired
+    private IStoreInnerServiceSMO storeInnerServiceSMOImpl;
+
+    @Override
+    @Java110Transactional
+    public ResponseEntity<String> update(StorePo storePo) {
+        int flag = storeInnerServiceSMOImpl.updateStore(storePo);
+        if (flag > 0) {
+            return ResultVo.success();
+        }
+        return ResultVo.error("修改状态失败");
+    }
+}

+ 8 - 0
service-store/src/main/java/com/java110/store/dao/IStoreServiceDao.java

@@ -307,4 +307,12 @@ public interface IStoreServiceDao {
      * @return
      */
     int getStoreStaffCount(Map beanCovertMap) throws DAOException;
+
+    /**
+     * 修改商户信息
+     *
+     * @param info
+     * @return
+     */
+    int updateStore(Map info) throws DAOException;
 }

+ 13 - 0
service-store/src/main/java/com/java110/store/dao/impl/StoreServiceDaoImpl.java

@@ -576,4 +576,17 @@ public class StoreServiceDaoImpl extends BaseServiceDao implements IStoreService
         }
         return Integer.parseInt(storeUserInfos.get(0).get("count").toString());
     }
+
+    /**
+     * 修改 商户信息
+     *
+     * @param info
+     * @return
+     * @throws DAOException
+     */
+    @Override
+    public int updateStore(Map info) throws DAOException {
+        int saveFlag = sqlSessionTemplate.update("storeServiceDaoImpl.updateStore", info);
+        return saveFlag;
+    }
 }

+ 6 - 0
service-store/src/main/java/com/java110/store/smo/impl/StoreInnerServiceSMOImpl.java

@@ -9,6 +9,7 @@ import com.java110.dto.store.StoreUserDto;
 import com.java110.dto.user.UserDto;
 import com.java110.intf.store.IStoreInnerServiceSMO;
 import com.java110.intf.user.IUserInnerServiceSMO;
+import com.java110.po.store.StorePo;
 import com.java110.store.dao.IStoreServiceDao;
 import com.java110.utils.util.BeanConvertUtil;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -71,6 +72,11 @@ public class StoreInnerServiceSMOImpl extends BaseServiceSMO implements IStoreIn
         return storeServiceDaoImpl.getStoreCount(BeanConvertUtil.beanCovertMap(storeDto));
     }
 
+    @Override
+    public int updateStore(@RequestBody StorePo storePo) {
+        return storeServiceDaoImpl.updateStore(BeanConvertUtil.beanCovertMap(storePo));
+    }
+
     /**
      * 查询员工和员工所属商户信息
      *