java110 лет назад: 4
Родитель
Сommit
63c96afbec

+ 26 - 2
java110-db/src/main/resources/mapper/store/SmallWechatV1ServiceDaoImplMapper.xml

@@ -18,9 +18,9 @@
     <!-- 查询微信配置表信息 add by wuxw 2018-07-03 -->
     <select id="getSmallWechatInfo" parameterType="Map" resultType="Map">
         select t.mch_id,t.mch_id mchId,t.status_cd,t.status_cd statusCd,t.store_Id,t.store_Id storeId,t.wechat_type,
-        t.wechat_type wechatType,t.cert_path,t.cert_path certPath,t.appId,t.appId appid,t.appSecret,t.appSecret
+        t.wechat_type wechatType,t.wechat_type weChatType,t.cert_path,t.cert_path certPath,t.appId,t.appId appid,t.appSecret,t.appSecret
         appsecret,
-        t.name,t.obj_id,t.obj_id objId,t.wechat_id,t.wechat_id wechatId,t.pay_password,t.pay_password payPassword,
+        t.name,t.obj_id,t.obj_id objId,t.wechat_id,t.wechat_id wechatId,t.wechat_id weChatId,t.pay_password,t.pay_password payPassword,
         t.obj_type,t.obj_type objType,t.remarks
         from small_wechat t
         where 1 =1
@@ -36,15 +36,24 @@
         <if test="wechatType !=null and wechatType != ''">
             and t.wechat_type= #{wechatType}
         </if>
+        <if test="weChatType !=null and weChatType != ''">
+            and t.wechat_type= #{weChatType}
+        </if>
         <if test="certPath !=null and certPath != ''">
             and t.cert_path= #{certPath}
         </if>
         <if test="appid !=null and appid != ''">
             and t.appId= #{appid}
         </if>
+        <if test="appId !=null and appId != ''">
+            and t.appId= #{appId}
+        </if>
         <if test="appsecret !=null and appsecret != ''">
             and t.appSecret= #{appsecret}
         </if>
+        <if test="appSecret !=null and appSecret != ''">
+            and t.appSecret= #{appSecret}
+        </if>
         <if test="name !=null and name != ''">
             and t.name= #{name}
         </if>
@@ -54,6 +63,9 @@
         <if test="wechatId !=null and wechatId != ''">
             and t.wechat_id= #{wechatId}
         </if>
+        <if test="weChatId !=null and weChatId != ''">
+            and t.wechat_id= #{weChatId}
+        </if>
         <if test="payPassword !=null and payPassword != ''">
             and t.pay_password= #{payPassword}
         </if>
@@ -134,15 +146,24 @@
         <if test="wechatType !=null and wechatType != ''">
             and t.wechat_type= #{wechatType}
         </if>
+        <if test="weChatType !=null and weChatType != ''">
+            and t.wechat_type= #{weChatType}
+        </if>
         <if test="certPath !=null and certPath != ''">
             and t.cert_path= #{certPath}
         </if>
         <if test="appid !=null and appid != ''">
             and t.appId= #{appid}
         </if>
+        <if test="appId !=null and appId != ''">
+            and t.appId= #{appId}
+        </if>
         <if test="appsecret !=null and appsecret != ''">
             and t.appSecret= #{appsecret}
         </if>
+        <if test="appSecret !=null and appSecret != ''">
+            and t.appSecret= #{appSecret}
+        </if>
         <if test="name !=null and name != ''">
             and t.name= #{name}
         </if>
@@ -152,6 +173,9 @@
         <if test="wechatId !=null and wechatId != ''">
             and t.wechat_id= #{wechatId}
         </if>
+        <if test="weChatId !=null and weChatId != ''">
+            and t.wechat_id= #{weChatId}
+        </if>
         <if test="payPassword !=null and payPassword != ''">
             and t.pay_password= #{payPassword}
         </if>

+ 0 - 109
service-api/src/main/java/com/java110/api/listener/smallWeChat/ListSmallWeChatsListener.java

@@ -1,109 +0,0 @@
-package com.java110.api.listener.smallWeChat;
-
-import com.alibaba.fastjson.JSONObject;
-import com.java110.api.listener.AbstractServiceApiListener;
-import com.java110.core.annotation.Java110Listener;
-import com.java110.core.context.DataFlowContext;
-import com.java110.core.event.service.api.ServiceDataFlowEvent;
-import com.java110.core.factory.WechatFactory;
-import com.java110.dto.app.AppDto;
-import com.java110.dto.smallWeChat.SmallWeChatDto;
-import com.java110.intf.store.ISmallWeChatInnerServiceSMO;
-import com.java110.utils.constant.ServiceCodeSmallWeChatConstant;
-import com.java110.utils.util.BeanConvertUtil;
-import com.java110.utils.util.StringUtil;
-import com.java110.vo.api.smallWeChat.ApiSmallWeChatDataVo;
-import com.java110.vo.api.smallWeChat.ApiSmallWeChatVo;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpMethod;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
-
-import java.util.ArrayList;
-import java.util.List;
-
-
-/**
- * 查询小程序配置
- */
-@Java110Listener("listSmallWeChatsListener")
-public class ListSmallWeChatsListener extends AbstractServiceApiListener {
-
-    private static String OWNER_APP = "992019111758490006";
-    private static String OWNER_WECHAT_APP = "992020061452450002";
-
-    @Autowired
-    private ISmallWeChatInnerServiceSMO smallWeChatInnerServiceSMOImpl;
-
-    @Override
-    public String getServiceCode() {
-        return ServiceCodeSmallWeChatConstant.LIST_SMALL_WE_CHATS;
-    }
-
-    @Override
-    public HttpMethod getHttpMethod() {
-        return HttpMethod.GET;
-    }
-
-
-    @Override
-    public int getOrder() {
-        return DEFAULT_ORDER;
-    }
-
-
-    public ISmallWeChatInnerServiceSMO getSmallWeChatInnerServiceSMOImpl() {
-        return smallWeChatInnerServiceSMOImpl;
-    }
-
-    public void setSmallWeChatInnerServiceSMOImpl(ISmallWeChatInnerServiceSMO smallWeChatInnerServiceSMOImpl) {
-        this.smallWeChatInnerServiceSMOImpl = smallWeChatInnerServiceSMOImpl;
-    }
-
-    @Override
-    protected void validate(ServiceDataFlowEvent event, JSONObject reqJson) {
-        super.validatePageInfo(reqJson);
-        //Assert.hasKeyAndValue(reqJson, "communityId", "未包含小区信息");
-    }
-
-    @Override
-    protected void doSoService(ServiceDataFlowEvent event, DataFlowContext context, JSONObject reqJson) {
-        String appId = event.getDataFlowContext().getRequestHeaders().get("app-id");
-        if (StringUtil.isEmpty(appId)) {
-            appId = event.getDataFlowContext().getRequestHeaders().get("app_id");
-        }
-        SmallWeChatDto smallWeChatDto = BeanConvertUtil.covertBean(reqJson, SmallWeChatDto.class);
-        smallWeChatDto.setObjType(SmallWeChatDto.OBJ_TYPE_COMMUNITY);
-        smallWeChatDto.setObjId(reqJson.getString("communityId"));
-        //smallWeChatDto.setWeChatType(reqJson.getString("wechatType"));
-        int count = smallWeChatInnerServiceSMOImpl.querySmallWeChatsCount(smallWeChatDto);
-        List<ApiSmallWeChatDataVo> smallWeChats = null;
-        if (count > 0) {
-            smallWeChats = BeanConvertUtil.covertBeanList(smallWeChatInnerServiceSMOImpl.querySmallWeChats(smallWeChatDto), ApiSmallWeChatDataVo.class);
-            freshSecure(smallWeChats, appId);
-        } else {
-            smallWeChats = new ArrayList<>();
-        }
-        ApiSmallWeChatVo apiSmallWeChatVo = new ApiSmallWeChatVo();
-        apiSmallWeChatVo.setTotal(count);
-        apiSmallWeChatVo.setRecords((int) Math.ceil((double) count / (double) reqJson.getInteger("row")));
-        apiSmallWeChatVo.setSmallWeChats(smallWeChats);
-        ResponseEntity<String> responseEntity = new ResponseEntity<String>(JSONObject.toJSONString(apiSmallWeChatVo), HttpStatus.OK);
-        context.setResponseEntity(responseEntity);
-    }
-
-    private void freshSecure(List<ApiSmallWeChatDataVo> smallWeChats, String appId) {
-//        if (OWNER_APP.equals(appId)) {
-//            return;
-//        }
-
-        for (ApiSmallWeChatDataVo apiSmallWeChatDataVo : smallWeChats) {
-            apiSmallWeChatDataVo.setwId(WechatFactory.getWId(apiSmallWeChatDataVo.getAppId()));
-            if (AppDto.WEB_APP_ID.equals(appId) || AppDto.WECHAT_MALL_APP_ID.equals(appId)) {
-                apiSmallWeChatDataVo.setAppSecret("");
-                apiSmallWeChatDataVo.setPayPassword("");
-            }
-
-        }
-    }
-}

+ 0 - 49
service-api/src/main/java/com/java110/api/listener/smallWeChat/UpdateSmallWeChatListener.java

@@ -1,49 +0,0 @@
-package com.java110.api.listener.smallWeChat;
-
-import com.alibaba.fastjson.JSONObject;
-import com.java110.api.bmo.smallWeChat.ISmallWeChatBMO;
-import com.java110.api.listener.AbstractServiceApiPlusListener;
-import com.java110.core.annotation.Java110Listener;
-import com.java110.core.context.DataFlowContext;
-import com.java110.core.event.service.api.ServiceDataFlowEvent;
-import com.java110.utils.constant.ServiceCodeSmallWeChatConstant;
-import com.java110.utils.util.Assert;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpMethod;
-
-
-/**
- * 修改小程序配置
- */
-@Java110Listener("updateSmallWeChatListener")
-public class UpdateSmallWeChatListener extends AbstractServiceApiPlusListener {
-
-    @Autowired
-    private ISmallWeChatBMO smallWeChatBMOImpl;
-
-    @Override
-    protected void validate(ServiceDataFlowEvent event, JSONObject reqJson) {
-        Assert.hasKeyAndValue(reqJson, "weChatId", "weChatId不能为空");
-        Assert.hasKeyAndValue(reqJson, "name", "请求报文中未包含name");
-        Assert.hasKeyAndValue(reqJson, "appId", "请求报文中未包含appId");
-        Assert.hasKeyAndValue(reqJson, "appSecret", "请求报文中未包含appSecret");
-        Assert.hasKeyAndValue(reqJson, "payPassword", "请求报文中未包含payPassword");
-    }
-
-    @Override
-    protected void doSoService(ServiceDataFlowEvent event, DataFlowContext context, JSONObject reqJson) {
-        smallWeChatBMOImpl.updateSmallWeChat(reqJson, context);
-    }
-
-    @Override
-    public String getServiceCode() {
-        return ServiceCodeSmallWeChatConstant.UPDATE_SMALL_WE_CHAT;
-    }
-
-    @Override
-    public HttpMethod getHttpMethod() {
-        return HttpMethod.POST;
-    }
-
-
-}

+ 40 - 15
service-store/src/main/java/com/java110/store/cmd/smallWechat/ListSmallWechatCmd.java

@@ -22,12 +22,17 @@ import com.java110.core.context.ICmdDataFlowContext;
 import com.java110.core.event.cmd.AbstractServiceCmdListener;
 import com.java110.core.event.cmd.CmdEvent;
 import com.java110.core.factory.GenerateCodeFactory;
+import com.java110.core.factory.WechatFactory;
+import com.java110.dto.app.AppDto;
 import com.java110.intf.store.ISmallWechatV1InnerServiceSMO;
 import com.java110.po.smallWechat.SmallWechatPo;
 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 com.java110.vo.api.smallWeChat.ApiSmallWeChatDataVo;
+import com.java110.vo.api.smallWeChat.ApiSmallWeChatVo;
 import org.springframework.beans.factory.annotation.Autowired;
 import com.java110.dto.smallWeChat.SmallWeChatDto;
 import java.util.List;
@@ -48,7 +53,7 @@ import org.slf4j.LoggerFactory;
  * 温馨提示:如果您对此文件进行修改 请不要删除原有作者及注释信息,请补充您的 修改的原因以及联系邮箱如下
  * // modify by 张三 at 2021-09-12 第10行在某种场景下存在某种bug 需要修复,注释10至20行 加入 20行至30行
  */
-@Java110Cmd(serviceCode = "smallWechat.listSmallWechat")
+@Java110Cmd(serviceCode = "smallWeChat.listSmallWeChats")
 public class ListSmallWechatCmd extends AbstractServiceCmdListener {
 
   private static Logger logger = LoggerFactory.getLogger(ListSmallWechatCmd.class);
@@ -63,22 +68,42 @@ public class ListSmallWechatCmd extends AbstractServiceCmdListener {
     @Override
     public void doCmd(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) throws CmdException {
 
-           SmallWeChatDto smallWechatDto = BeanConvertUtil.covertBean(reqJson, SmallWeChatDto.class);
-
-           int count = smallWechatV1InnerServiceSMOImpl.querySmallWechatsCount(smallWechatDto);
-
-           List<SmallWeChatDto> smallWechatDtos = null;
-
-           if (count > 0) {
-               smallWechatDtos = smallWechatV1InnerServiceSMOImpl.querySmallWechats(smallWechatDto);
-           } else {
-               smallWechatDtos = new ArrayList<>();
-           }
+        String appId = cmdDataFlowContext.getReqHeaders().get("app-id");
+        if (StringUtil.isEmpty(appId)) {
+            appId = cmdDataFlowContext.getReqHeaders().get("app-id");
+        }
+        SmallWeChatDto smallWeChatDto = BeanConvertUtil.covertBean(reqJson, SmallWeChatDto.class);
+        smallWeChatDto.setObjType(SmallWeChatDto.OBJ_TYPE_COMMUNITY);
+        smallWeChatDto.setObjId(reqJson.getString("communityId"));
+        //smallWeChatDto.setWeChatType(reqJson.getString("wechatType"));
+        int count = smallWechatV1InnerServiceSMOImpl.querySmallWechatsCount(smallWeChatDto);
+        List<ApiSmallWeChatDataVo> smallWeChats = null;
+        if (count > 0) {
+            smallWeChats = BeanConvertUtil.covertBeanList(smallWechatV1InnerServiceSMOImpl.querySmallWechats(smallWeChatDto), ApiSmallWeChatDataVo.class);
+            freshSecure(smallWeChats, appId);
+        } else {
+            smallWeChats = new ArrayList<>();
+        }
+        ApiSmallWeChatVo apiSmallWeChatVo = new ApiSmallWeChatVo();
+        apiSmallWeChatVo.setTotal(count);
+        apiSmallWeChatVo.setRecords((int) Math.ceil((double) count / (double) reqJson.getInteger("row")));
+        apiSmallWeChatVo.setSmallWeChats(smallWeChats);
+        ResponseEntity<String> responseEntity = new ResponseEntity<String>(JSONObject.toJSONString(apiSmallWeChatVo), HttpStatus.OK);
+        cmdDataFlowContext.setResponseEntity(responseEntity);
+    }
 
-           ResultVo resultVo = new ResultVo((int) Math.ceil((double) count / (double) reqJson.getInteger("row")), count, smallWechatDtos);
+    private void freshSecure(List<ApiSmallWeChatDataVo> smallWeChats, String appId) {
+//        if (OWNER_APP.equals(appId)) {
+//            return;
+//        }
 
-           ResponseEntity<String> responseEntity = new ResponseEntity<String>(resultVo.toString(), HttpStatus.OK);
+        for (ApiSmallWeChatDataVo apiSmallWeChatDataVo : smallWeChats) {
+            apiSmallWeChatDataVo.setwId(WechatFactory.getWId(apiSmallWeChatDataVo.getAppId()));
+            if (AppDto.WEB_APP_ID.equals(appId) || AppDto.WECHAT_MALL_APP_ID.equals(appId)) {
+                apiSmallWeChatDataVo.setAppSecret("");
+                apiSmallWeChatDataVo.setPayPassword("");
+            }
 
-           cmdDataFlowContext.setResponseEntity(responseEntity);
+        }
     }
 }

+ 2 - 2
service-store/src/main/java/com/java110/store/cmd/smallWechat/SaveSmallWechatCmd.java

@@ -68,7 +68,6 @@ public class SaveSmallWechatCmd extends AbstractServiceCmdListener {
         Assert.hasKeyAndValue(reqJson, "appId", "请求报文中未包含appId");
         Assert.hasKeyAndValue(reqJson, "appSecret", "请求报文中未包含appSecret");
         Assert.hasKeyAndValue(reqJson, "payPassword", "请求报文中未包含payPassword");
-        Assert.hasKeyAndValue(reqJson, "weChatType", "请求报文中未包含weChatType");
         Assert.hasKeyAndValue(reqJson, "objId", "请求报文中未包含objId(小区id)");
         Assert.hasKeyAndValue(reqJson, "weChatType", "请求报文中未包含类型");
 
@@ -83,10 +82,11 @@ public class SaveSmallWechatCmd extends AbstractServiceCmdListener {
         }
 
         String wechatId = GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_weChatId);
-        reqJson.put("weChatId", wechatId);
+        reqJson.put("wechatId", wechatId);
         reqJson.put("objType", SmallWeChatDto.OBJ_TYPE_COMMUNITY);
         SmallWechatPo smallWechatPo = BeanConvertUtil.covertBean(reqJson, SmallWechatPo.class);
         smallWechatPo.setWechatId(GenerateCodeFactory.getGeneratorId(CODE_PREFIX_ID));
+        smallWechatPo.setWechatType(reqJson.getString("weChatType"));
         int flag = smallWechatV1InnerServiceSMOImpl.saveSmallWechat(smallWechatPo);
 
         if (flag < 1) {

+ 7 - 3
service-store/src/main/java/com/java110/store/cmd/smallWechat/UpdateSmallWechatCmd.java

@@ -43,7 +43,7 @@ import org.slf4j.LoggerFactory;
  * 温馨提示:如果您对此文件进行修改 请不要删除原有作者及注释信息,请补充您的 修改的原因以及联系邮箱如下
  * // modify by 张三 at 2021-09-12 第10行在某种场景下存在某种bug 需要修复,注释10至20行 加入 20行至30行
  */
-@Java110Cmd(serviceCode = "smallWechat.updateSmallWechat")
+@Java110Cmd(serviceCode = "smallWeChat.updateSmallWeChat")
 public class UpdateSmallWechatCmd extends AbstractServiceCmdListener {
 
   private static Logger logger = LoggerFactory.getLogger(UpdateSmallWechatCmd.class);
@@ -54,8 +54,11 @@ public class UpdateSmallWechatCmd extends AbstractServiceCmdListener {
 
     @Override
     public void validate(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) {
-        Assert.hasKeyAndValue(reqJson, "wechatId", "wechatId不能为空");
-Assert.hasKeyAndValue(reqJson, "objId", "objId不能为空");
+        Assert.hasKeyAndValue(reqJson, "wechatId", "weChatId不能为空");
+        Assert.hasKeyAndValue(reqJson, "name", "请求报文中未包含name");
+        Assert.hasKeyAndValue(reqJson, "appId", "请求报文中未包含appId");
+        Assert.hasKeyAndValue(reqJson, "appSecret", "请求报文中未包含appSecret");
+        Assert.hasKeyAndValue(reqJson, "payPassword", "请求报文中未包含payPassword");
 
     }
 
@@ -64,6 +67,7 @@ Assert.hasKeyAndValue(reqJson, "objId", "objId不能为空");
     public void doCmd(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) throws CmdException {
 
        SmallWechatPo smallWechatPo = BeanConvertUtil.covertBean(reqJson, SmallWechatPo.class);
+       smallWechatPo.setWechatType(reqJson.getString("weChatType"));
         int flag = smallWechatV1InnerServiceSMOImpl.updateSmallWechat(smallWechatPo);
 
         if (flag < 1) {