| New file |
| | |
| | | package com.java110.store.listener.wechatMenu; |
| | | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.utils.constant.BusinessTypeConstant; |
| | | import com.java110.utils.constant.ResponseConstant; |
| | | import com.java110.utils.constant.StatusConstant; |
| | | import com.java110.utils.exception.ListenerExecuteException; |
| | | import com.java110.utils.util.Assert; |
| | | import com.java110.core.annotation.Java110Listener; |
| | | import com.java110.core.context.DataFlowContext; |
| | | import com.java110.entity.center.Business; |
| | | import com.java110.store.dao.IWechatMenuServiceDao; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 删除公众号菜单信息 侦听 |
| | | * |
| | | * 处理节点 |
| | | * 1、businessWechatMenu:{} 公众号菜单基本信息节点 |
| | | * 2、businessWechatMenuAttr:[{}] 公众号菜单属性信息节点 |
| | | * 3、businessWechatMenuPhoto:[{}] 公众号菜单照片信息节点 |
| | | * 4、businessWechatMenuCerdentials:[{}] 公众号菜单证件信息节点 |
| | | * 协议地址 :https://github.com/java110/MicroCommunity/wiki/%E5%88%A0%E9%99%A4%E5%95%86%E6%88%B7%E4%BF%A1%E6%81%AF-%E5%8D%8F%E8%AE%AE |
| | | * Created by wuxw on 2018/5/18. |
| | | */ |
| | | @Java110Listener("deleteWechatMenuInfoListener") |
| | | @Transactional |
| | | public class DeleteWechatMenuInfoListener extends AbstractWechatMenuBusinessServiceDataFlowListener { |
| | | |
| | | private final static Logger logger = LoggerFactory.getLogger(DeleteWechatMenuInfoListener.class); |
| | | @Autowired |
| | | IWechatMenuServiceDao wechatMenuServiceDaoImpl; |
| | | |
| | | @Override |
| | | public int getOrder() { |
| | | return 3; |
| | | } |
| | | |
| | | @Override |
| | | public String getBusinessTypeCd() { |
| | | return BusinessTypeConstant.BUSINESS_TYPE_DELETE_WECHAT_MENU; |
| | | } |
| | | |
| | | /** |
| | | * 根据删除信息 查出Instance表中数据 保存至business表 (状态写DEL) 方便撤单时直接更新回去 |
| | | * @param dataFlowContext 数据对象 |
| | | * @param business 当前业务对象 |
| | | */ |
| | | @Override |
| | | protected void doSaveBusiness(DataFlowContext dataFlowContext, Business business) { |
| | | JSONObject data = business.getDatas(); |
| | | |
| | | Assert.notEmpty(data,"没有datas 节点,或没有子节点需要处理"); |
| | | |
| | | //处理 businessWechatMenu 节点 |
| | | if(data.containsKey(WechatMenuPo.class.getSimpleName())){ |
| | | Object _obj = data.get(WechatMenuPo.class.getSimpleName()); |
| | | JSONArray businessWechatMenus = null; |
| | | if(_obj instanceof JSONObject){ |
| | | businessWechatMenus = new JSONArray(); |
| | | businessWechatMenus.add(_obj); |
| | | }else { |
| | | businessWechatMenus = (JSONArray)_obj; |
| | | } |
| | | //JSONObject businessWechatMenu = data.getJSONObject(WechatMenuPo.class.getSimpleName()); |
| | | for (int _wechatMenuIndex = 0; _wechatMenuIndex < businessWechatMenus.size();_wechatMenuIndex++) { |
| | | JSONObject businessWechatMenu = businessWechatMenus.getJSONObject(_wechatMenuIndex); |
| | | doBusinessWechatMenu(business, businessWechatMenu); |
| | | if(_obj instanceof JSONObject) { |
| | | dataFlowContext.addParamOut("wechatMenuId", businessWechatMenu.getString("wechatMenuId")); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 删除 instance数据 |
| | | * @param dataFlowContext 数据对象 |
| | | * @param business 当前业务对象 |
| | | */ |
| | | @Override |
| | | protected void doBusinessToInstance(DataFlowContext dataFlowContext, Business business) { |
| | | String bId = business.getbId(); |
| | | //Assert.hasLength(bId,"请求报文中没有包含 bId"); |
| | | |
| | | //公众号菜单信息 |
| | | Map info = new HashMap(); |
| | | info.put("bId",business.getbId()); |
| | | info.put("operate",StatusConstant.OPERATE_DEL); |
| | | |
| | | //公众号菜单信息 |
| | | List<Map> businessWechatMenuInfos = wechatMenuServiceDaoImpl.getBusinessWechatMenuInfo(info); |
| | | if( businessWechatMenuInfos != null && businessWechatMenuInfos.size() >0) { |
| | | for (int _wechatMenuIndex = 0; _wechatMenuIndex < businessWechatMenuInfos.size();_wechatMenuIndex++) { |
| | | Map businessWechatMenuInfo = businessWechatMenuInfos.get(_wechatMenuIndex); |
| | | flushBusinessWechatMenuInfo(businessWechatMenuInfo,StatusConstant.STATUS_CD_INVALID); |
| | | wechatMenuServiceDaoImpl.updateWechatMenuInfoInstance(businessWechatMenuInfo); |
| | | dataFlowContext.addParamOut("wechatMenuId",businessWechatMenuInfo.get("wechat_menu_id")); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 撤单 |
| | | * 从business表中查询到DEL的数据 将instance中的数据更新回来 |
| | | * @param dataFlowContext 数据对象 |
| | | * @param business 当前业务对象 |
| | | */ |
| | | @Override |
| | | protected void doRecover(DataFlowContext dataFlowContext, Business business) { |
| | | String bId = business.getbId(); |
| | | //Assert.hasLength(bId,"请求报文中没有包含 bId"); |
| | | Map info = new HashMap(); |
| | | info.put("bId",bId); |
| | | info.put("statusCd",StatusConstant.STATUS_CD_INVALID); |
| | | |
| | | Map delInfo = new HashMap(); |
| | | delInfo.put("bId",business.getbId()); |
| | | delInfo.put("operate",StatusConstant.OPERATE_DEL); |
| | | //公众号菜单信息 |
| | | List<Map> wechatMenuInfo = wechatMenuServiceDaoImpl.getWechatMenuInfo(info); |
| | | if(wechatMenuInfo != null && wechatMenuInfo.size() > 0){ |
| | | |
| | | //公众号菜单信息 |
| | | List<Map> businessWechatMenuInfos = wechatMenuServiceDaoImpl.getBusinessWechatMenuInfo(delInfo); |
| | | //除非程序出错了,这里不会为空 |
| | | if(businessWechatMenuInfos == null || businessWechatMenuInfos.size() == 0){ |
| | | throw new ListenerExecuteException(ResponseConstant.RESULT_CODE_INNER_ERROR,"撤单失败(wechatMenu),程序内部异常,请检查! "+delInfo); |
| | | } |
| | | for (int _wechatMenuIndex = 0; _wechatMenuIndex < businessWechatMenuInfos.size();_wechatMenuIndex++) { |
| | | Map businessWechatMenuInfo = businessWechatMenuInfos.get(_wechatMenuIndex); |
| | | flushBusinessWechatMenuInfo(businessWechatMenuInfo,StatusConstant.STATUS_CD_VALID); |
| | | wechatMenuServiceDaoImpl.updateWechatMenuInfoInstance(businessWechatMenuInfo); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 处理 businessWechatMenu 节点 |
| | | * @param business 总的数据节点 |
| | | * @param businessWechatMenu 公众号菜单节点 |
| | | */ |
| | | private void doBusinessWechatMenu(Business business,JSONObject businessWechatMenu){ |
| | | |
| | | Assert.jsonObjectHaveKey(businessWechatMenu,"wechatMenuId","businessWechatMenu 节点下没有包含 wechatMenuId 节点"); |
| | | |
| | | if(businessWechatMenu.getString("wechatMenuId").startsWith("-")){ |
| | | throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"wechatMenuId 错误,不能自动生成(必须已经存在的wechatMenuId)"+businessWechatMenu); |
| | | } |
| | | //自动插入DEL |
| | | autoSaveDelBusinessWechatMenu(business,businessWechatMenu); |
| | | } |
| | | @Override |
| | | public IWechatMenuServiceDao getWechatMenuServiceDaoImpl() { |
| | | return wechatMenuServiceDaoImpl; |
| | | } |
| | | |
| | | public void setWechatMenuServiceDaoImpl(IWechatMenuServiceDao wechatMenuServiceDaoImpl) { |
| | | this.wechatMenuServiceDaoImpl = wechatMenuServiceDaoImpl; |
| | | } |
| | | } |
| New file |
| | |
| | | package com.java110.store.listener.wechatMenu; |
| | | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.utils.constant.BusinessTypeConstant; |
| | | import com.java110.utils.constant.StatusConstant; |
| | | import com.java110.utils.util.Assert; |
| | | import com.java110.store.dao.IWechatMenuServiceDao; |
| | | import com.java110.core.annotation.Java110Listener; |
| | | import com.java110.core.context.DataFlowContext; |
| | | import com.java110.core.factory.GenerateCodeFactory; |
| | | import com.java110.entity.center.Business; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 保存 公众号菜单信息 侦听 |
| | | * Created by wuxw on 2018/5/18. |
| | | */ |
| | | @Java110Listener("saveWechatMenuInfoListener") |
| | | @Transactional |
| | | public class SaveWechatMenuInfoListener extends AbstractWechatMenuBusinessServiceDataFlowListener{ |
| | | |
| | | private static Logger logger = LoggerFactory.getLogger(SaveWechatMenuInfoListener.class); |
| | | |
| | | @Autowired |
| | | private IWechatMenuServiceDao wechatMenuServiceDaoImpl; |
| | | |
| | | @Override |
| | | public int getOrder() { |
| | | return 0; |
| | | } |
| | | |
| | | @Override |
| | | public String getBusinessTypeCd() { |
| | | return BusinessTypeConstant.BUSINESS_TYPE_SAVE_WECHAT_MENU; |
| | | } |
| | | |
| | | /** |
| | | * 保存公众号菜单信息 business 表中 |
| | | * @param dataFlowContext 数据对象 |
| | | * @param business 当前业务对象 |
| | | */ |
| | | @Override |
| | | protected void doSaveBusiness(DataFlowContext dataFlowContext, Business business) { |
| | | JSONObject data = business.getDatas(); |
| | | Assert.notEmpty(data,"没有datas 节点,或没有子节点需要处理"); |
| | | |
| | | //处理 businessWechatMenu 节点 |
| | | if(data.containsKey(WechatMenuPo.class.getSimpleName())){ |
| | | Object bObj = data.get(WechatMenuPo.class.getSimpleName()); |
| | | JSONArray businessWechatMenus = null; |
| | | if(bObj instanceof JSONObject){ |
| | | businessWechatMenus = new JSONArray(); |
| | | businessWechatMenus.add(bObj); |
| | | }else { |
| | | businessWechatMenus = (JSONArray)bObj; |
| | | } |
| | | //JSONObject businessWechatMenu = data.getJSONObject(WechatMenuPo.class.getSimpleName()); |
| | | for (int bWechatMenuIndex = 0; bWechatMenuIndex < businessWechatMenus.size();bWechatMenuIndex++) { |
| | | JSONObject businessWechatMenu = businessWechatMenus.getJSONObject(bWechatMenuIndex); |
| | | doBusinessWechatMenu(business, businessWechatMenu); |
| | | if(bObj instanceof JSONObject) { |
| | | dataFlowContext.addParamOut("wechatMenuId", businessWechatMenu.getString("wechatMenuId")); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * business 数据转移到 instance |
| | | * @param dataFlowContext 数据对象 |
| | | * @param business 当前业务对象 |
| | | */ |
| | | @Override |
| | | protected void doBusinessToInstance(DataFlowContext dataFlowContext, Business business) { |
| | | JSONObject data = business.getDatas(); |
| | | |
| | | Map info = new HashMap(); |
| | | info.put("bId",business.getbId()); |
| | | info.put("operate",StatusConstant.OPERATE_ADD); |
| | | |
| | | //公众号菜单信息 |
| | | List<Map> businessWechatMenuInfo = wechatMenuServiceDaoImpl.getBusinessWechatMenuInfo(info); |
| | | if( businessWechatMenuInfo != null && businessWechatMenuInfo.size() >0) { |
| | | reFreshShareColumn(info, businessWechatMenuInfo.get(0)); |
| | | wechatMenuServiceDaoImpl.saveWechatMenuInfoInstance(info); |
| | | if(businessWechatMenuInfo.size() == 1) { |
| | | dataFlowContext.addParamOut("wechatMenuId", businessWechatMenuInfo.get(0).get("wechat_menu_id")); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 刷 分片字段 |
| | | * |
| | | * @param info 查询对象 |
| | | * @param businessInfo 小区ID |
| | | */ |
| | | private void reFreshShareColumn(Map info, Map businessInfo) { |
| | | |
| | | if (info.containsKey("communityId")) { |
| | | return; |
| | | } |
| | | |
| | | if (!businessInfo.containsKey("community_id")) { |
| | | return; |
| | | } |
| | | |
| | | info.put("communityId", businessInfo.get("community_id")); |
| | | } |
| | | /** |
| | | * 撤单 |
| | | * @param dataFlowContext 数据对象 |
| | | * @param business 当前业务对象 |
| | | */ |
| | | @Override |
| | | protected void doRecover(DataFlowContext dataFlowContext, Business business) { |
| | | String bId = business.getbId(); |
| | | //Assert.hasLength(bId,"请求报文中没有包含 bId"); |
| | | Map info = new HashMap(); |
| | | info.put("bId",bId); |
| | | info.put("statusCd",StatusConstant.STATUS_CD_VALID); |
| | | Map paramIn = new HashMap(); |
| | | paramIn.put("bId",bId); |
| | | paramIn.put("statusCd",StatusConstant.STATUS_CD_INVALID); |
| | | //公众号菜单信息 |
| | | List<Map> wechatMenuInfo = wechatMenuServiceDaoImpl.getWechatMenuInfo(info); |
| | | if(wechatMenuInfo != null && wechatMenuInfo.size() > 0){ |
| | | reFreshShareColumn(paramIn, wechatMenuInfo.get(0)); |
| | | wechatMenuServiceDaoImpl.updateWechatMenuInfoInstance(paramIn); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 处理 businessWechatMenu 节点 |
| | | * @param business 总的数据节点 |
| | | * @param businessWechatMenu 公众号菜单节点 |
| | | */ |
| | | private void doBusinessWechatMenu(Business business,JSONObject businessWechatMenu){ |
| | | |
| | | Assert.jsonObjectHaveKey(businessWechatMenu,"wechatMenuId","businessWechatMenu 节点下没有包含 wechatMenuId 节点"); |
| | | |
| | | if(businessWechatMenu.getString("wechatMenuId").startsWith("-")){ |
| | | //刷新缓存 |
| | | //flushWechatMenuId(business.getDatas()); |
| | | |
| | | businessWechatMenu.put("wechatMenuId",GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_wechatMenuId)); |
| | | |
| | | } |
| | | |
| | | businessWechatMenu.put("bId",business.getbId()); |
| | | businessWechatMenu.put("operate", StatusConstant.OPERATE_ADD); |
| | | //保存公众号菜单信息 |
| | | wechatMenuServiceDaoImpl.saveBusinessWechatMenuInfo(businessWechatMenu); |
| | | |
| | | } |
| | | @Override |
| | | public IWechatMenuServiceDao getWechatMenuServiceDaoImpl() { |
| | | return wechatMenuServiceDaoImpl; |
| | | } |
| | | |
| | | public void setWechatMenuServiceDaoImpl(IWechatMenuServiceDao wechatMenuServiceDaoImpl) { |
| | | this.wechatMenuServiceDaoImpl = wechatMenuServiceDaoImpl; |
| | | } |
| | | } |
| New file |
| | |
| | | package com.java110.store.listener.wechatMenu; |
| | | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.utils.constant.BusinessTypeConstant; |
| | | import com.java110.utils.constant.ResponseConstant; |
| | | import com.java110.utils.constant.StatusConstant; |
| | | import com.java110.utils.exception.ListenerExecuteException; |
| | | import com.java110.utils.util.Assert; |
| | | import com.java110.core.annotation.Java110Listener; |
| | | import com.java110.core.context.DataFlowContext; |
| | | import com.java110.entity.center.Business; |
| | | import com.java110.store.dao.IWechatMenuServiceDao; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 修改公众号菜单信息 侦听 |
| | | * |
| | | * 处理节点 |
| | | * 1、businessWechatMenu:{} 公众号菜单基本信息节点 |
| | | * 2、businessWechatMenuAttr:[{}] 公众号菜单属性信息节点 |
| | | * 3、businessWechatMenuPhoto:[{}] 公众号菜单照片信息节点 |
| | | * 4、businessWechatMenuCerdentials:[{}] 公众号菜单证件信息节点 |
| | | * 协议地址 :https://github.com/java110/MicroCommunity/wiki/%E4%BF%AE%E6%94%B9%E5%95%86%E6%88%B7%E4%BF%A1%E6%81%AF-%E5%8D%8F%E8%AE%AE |
| | | * Created by wuxw on 2018/5/18. |
| | | */ |
| | | @Java110Listener("updateWechatMenuInfoListener") |
| | | @Transactional |
| | | public class UpdateWechatMenuInfoListener extends AbstractWechatMenuBusinessServiceDataFlowListener { |
| | | |
| | | private static Logger logger = LoggerFactory.getLogger(UpdateWechatMenuInfoListener.class); |
| | | @Autowired |
| | | private IWechatMenuServiceDao wechatMenuServiceDaoImpl; |
| | | |
| | | @Override |
| | | public int getOrder() { |
| | | return 2; |
| | | } |
| | | |
| | | @Override |
| | | public String getBusinessTypeCd() { |
| | | return BusinessTypeConstant.BUSINESS_TYPE_UPDATE_WECHAT_MENU; |
| | | } |
| | | |
| | | /** |
| | | * business过程 |
| | | * @param dataFlowContext 上下文对象 |
| | | * @param business 业务对象 |
| | | */ |
| | | @Override |
| | | protected void doSaveBusiness(DataFlowContext dataFlowContext, Business business) { |
| | | |
| | | JSONObject data = business.getDatas(); |
| | | |
| | | Assert.notEmpty(data,"没有datas 节点,或没有子节点需要处理"); |
| | | |
| | | |
| | | //处理 businessWechatMenu 节点 |
| | | if(data.containsKey(WechatMenuPo.class.getSimpleName())){ |
| | | Object _obj = data.get(WechatMenuPo.class.getSimpleName()); |
| | | JSONArray businessWechatMenus = null; |
| | | if(_obj instanceof JSONObject){ |
| | | businessWechatMenus = new JSONArray(); |
| | | businessWechatMenus.add(_obj); |
| | | }else { |
| | | businessWechatMenus = (JSONArray)_obj; |
| | | } |
| | | //JSONObject businessWechatMenu = data.getJSONObject(WechatMenuPo.class.getSimpleName()); |
| | | for (int _wechatMenuIndex = 0; _wechatMenuIndex < businessWechatMenus.size();_wechatMenuIndex++) { |
| | | JSONObject businessWechatMenu = businessWechatMenus.getJSONObject(_wechatMenuIndex); |
| | | doBusinessWechatMenu(business, businessWechatMenu); |
| | | if(_obj instanceof JSONObject) { |
| | | dataFlowContext.addParamOut("wechatMenuId", businessWechatMenu.getString("wechatMenuId")); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * business to instance 过程 |
| | | * @param dataFlowContext 数据对象 |
| | | * @param business 当前业务对象 |
| | | */ |
| | | @Override |
| | | protected void doBusinessToInstance(DataFlowContext dataFlowContext, Business business) { |
| | | |
| | | JSONObject data = business.getDatas(); |
| | | |
| | | Map info = new HashMap(); |
| | | info.put("bId",business.getbId()); |
| | | info.put("operate",StatusConstant.OPERATE_ADD); |
| | | |
| | | //公众号菜单信息 |
| | | List<Map> businessWechatMenuInfos = wechatMenuServiceDaoImpl.getBusinessWechatMenuInfo(info); |
| | | if( businessWechatMenuInfos != null && businessWechatMenuInfos.size() >0) { |
| | | for (int _wechatMenuIndex = 0; _wechatMenuIndex < businessWechatMenuInfos.size();_wechatMenuIndex++) { |
| | | Map businessWechatMenuInfo = businessWechatMenuInfos.get(_wechatMenuIndex); |
| | | flushBusinessWechatMenuInfo(businessWechatMenuInfo,StatusConstant.STATUS_CD_VALID); |
| | | wechatMenuServiceDaoImpl.updateWechatMenuInfoInstance(businessWechatMenuInfo); |
| | | if(businessWechatMenuInfo.size() == 1) { |
| | | dataFlowContext.addParamOut("wechatMenuId", businessWechatMenuInfo.get("wechat_menu_id")); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 撤单 |
| | | * @param dataFlowContext 数据对象 |
| | | * @param business 当前业务对象 |
| | | */ |
| | | @Override |
| | | protected void doRecover(DataFlowContext dataFlowContext, Business business) { |
| | | |
| | | String bId = business.getbId(); |
| | | //Assert.hasLength(bId,"请求报文中没有包含 bId"); |
| | | Map info = new HashMap(); |
| | | info.put("bId",bId); |
| | | info.put("statusCd",StatusConstant.STATUS_CD_VALID); |
| | | Map delInfo = new HashMap(); |
| | | delInfo.put("bId",business.getbId()); |
| | | delInfo.put("operate",StatusConstant.OPERATE_DEL); |
| | | //公众号菜单信息 |
| | | List<Map> wechatMenuInfo = wechatMenuServiceDaoImpl.getWechatMenuInfo(info); |
| | | if(wechatMenuInfo != null && wechatMenuInfo.size() > 0){ |
| | | |
| | | //公众号菜单信息 |
| | | List<Map> businessWechatMenuInfos = wechatMenuServiceDaoImpl.getBusinessWechatMenuInfo(delInfo); |
| | | //除非程序出错了,这里不会为空 |
| | | if(businessWechatMenuInfos == null || businessWechatMenuInfos.size() == 0){ |
| | | throw new ListenerExecuteException(ResponseConstant.RESULT_CODE_INNER_ERROR,"撤单失败(wechatMenu),程序内部异常,请检查! "+delInfo); |
| | | } |
| | | for (int _wechatMenuIndex = 0; _wechatMenuIndex < businessWechatMenuInfos.size();_wechatMenuIndex++) { |
| | | Map businessWechatMenuInfo = businessWechatMenuInfos.get(_wechatMenuIndex); |
| | | flushBusinessWechatMenuInfo(businessWechatMenuInfo,StatusConstant.STATUS_CD_VALID); |
| | | wechatMenuServiceDaoImpl.updateWechatMenuInfoInstance(businessWechatMenuInfo); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 处理 businessWechatMenu 节点 |
| | | * @param business 总的数据节点 |
| | | * @param businessWechatMenu 公众号菜单节点 |
| | | */ |
| | | private void doBusinessWechatMenu(Business business,JSONObject businessWechatMenu){ |
| | | |
| | | Assert.jsonObjectHaveKey(businessWechatMenu,"wechatMenuId","businessWechatMenu 节点下没有包含 wechatMenuId 节点"); |
| | | |
| | | if(businessWechatMenu.getString("wechatMenuId").startsWith("-")){ |
| | | throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"wechatMenuId 错误,不能自动生成(必须已经存在的wechatMenuId)"+businessWechatMenu); |
| | | } |
| | | //自动保存DEL |
| | | autoSaveDelBusinessWechatMenu(business,businessWechatMenu); |
| | | |
| | | businessWechatMenu.put("bId",business.getbId()); |
| | | businessWechatMenu.put("operate", StatusConstant.OPERATE_ADD); |
| | | //保存公众号菜单信息 |
| | | wechatMenuServiceDaoImpl.saveBusinessWechatMenuInfo(businessWechatMenu); |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public IWechatMenuServiceDao getWechatMenuServiceDaoImpl() { |
| | | return wechatMenuServiceDaoImpl; |
| | | } |
| | | |
| | | public void setWechatMenuServiceDaoImpl(IWechatMenuServiceDao wechatMenuServiceDaoImpl) { |
| | | this.wechatMenuServiceDaoImpl = wechatMenuServiceDaoImpl; |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| New file |
| | |
| | | package com.java110.dto.wechatMenu; |
| | | |
| | | import com.java110.dto.PageDto; |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * @ClassName FloorDto |
| | | * @Description 公众号菜单数据层封装 |
| | | * @Author wuxw |
| | | * @Date 2019/4/24 8:52 |
| | | * @Version 1.0 |
| | | * add by wuxw 2019/4/24 |
| | | **/ |
| | | public class WechatMenuDto extends PageDto implements Serializable { |
| | | |
| | | private String pagepath; |
| | | private String appId; |
| | | private String menuLevel; |
| | | private String menuName; |
| | | private String menuType; |
| | | private String menuValue; |
| | | private String communityId; |
| | | private String wechatMenuId; |
| | | |
| | | |
| | | private Date createTime; |
| | | |
| | | private String statusCd = "0"; |
| | | |
| | | |
| | | public String getPagepath() { |
| | | return pagepath; |
| | | } |
| | | public void setPagepath(String pagepath) { |
| | | this.pagepath = pagepath; |
| | | } |
| | | public String getAppId() { |
| | | return appId; |
| | | } |
| | | public void setAppId(String appId) { |
| | | this.appId = appId; |
| | | } |
| | | public String getMenuLevel() { |
| | | return menuLevel; |
| | | } |
| | | public void setMenuLevel(String menuLevel) { |
| | | this.menuLevel = menuLevel; |
| | | } |
| | | public String getMenuName() { |
| | | return menuName; |
| | | } |
| | | public void setMenuName(String menuName) { |
| | | this.menuName = menuName; |
| | | } |
| | | public String getMenuType() { |
| | | return menuType; |
| | | } |
| | | public void setMenuType(String menuType) { |
| | | this.menuType = menuType; |
| | | } |
| | | public String getMenuValue() { |
| | | return menuValue; |
| | | } |
| | | public void setMenuValue(String menuValue) { |
| | | this.menuValue = menuValue; |
| | | } |
| | | public String getCommunityId() { |
| | | return communityId; |
| | | } |
| | | public void setCommunityId(String communityId) { |
| | | this.communityId = communityId; |
| | | } |
| | | public String getWechatMenuId() { |
| | | return wechatMenuId; |
| | | } |
| | | public void setWechatMenuId(String wechatMenuId) { |
| | | this.wechatMenuId = wechatMenuId; |
| | | } |
| | | |
| | | |
| | | public Date getCreateTime() { |
| | | return createTime; |
| | | } |
| | | |
| | | public void setCreateTime(Date createTime) { |
| | | this.createTime = createTime; |
| | | } |
| | | |
| | | public String getStatusCd() { |
| | | return statusCd; |
| | | } |
| | | |
| | | public void setStatusCd(String statusCd) { |
| | | this.statusCd = statusCd; |
| | | } |
| | | } |
| New file |
| | |
| | | package com.java110.po.wechatMenu; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | public class WechatMenuPo implements Serializable { |
| | | |
| | | private String pagepath; |
| | | private String appId; |
| | | private String menuLevel; |
| | | private String menuName; |
| | | private String menuType; |
| | | private String menuValue; |
| | | private String communityId; |
| | | private String wechatMenuId; |
| | | |
| | | public String getPagepath() { |
| | | return pagepath; |
| | | } |
| | | |
| | | public void setPagepath(String pagepath) { |
| | | this.pagepath = pagepath; |
| | | } |
| | | |
| | | public String getAppId() { |
| | | return appId; |
| | | } |
| | | |
| | | public void setAppId(String appId) { |
| | | this.appId = appId; |
| | | } |
| | | |
| | | public String getMenuLevel() { |
| | | return menuLevel; |
| | | } |
| | | |
| | | public void setMenuLevel(String menuLevel) { |
| | | this.menuLevel = menuLevel; |
| | | } |
| | | |
| | | public String getMenuName() { |
| | | return menuName; |
| | | } |
| | | |
| | | public void setMenuName(String menuName) { |
| | | this.menuName = menuName; |
| | | } |
| | | |
| | | public String getMenuType() { |
| | | return menuType; |
| | | } |
| | | |
| | | public void setMenuType(String menuType) { |
| | | this.menuType = menuType; |
| | | } |
| | | |
| | | public String getMenuValue() { |
| | | return menuValue; |
| | | } |
| | | |
| | | public void setMenuValue(String menuValue) { |
| | | this.menuValue = menuValue; |
| | | } |
| | | |
| | | public String getCommunityId() { |
| | | return communityId; |
| | | } |
| | | |
| | | public void setCommunityId(String communityId) { |
| | | this.communityId = communityId; |
| | | } |
| | | |
| | | public String getWechatMenuId() { |
| | | return wechatMenuId; |
| | | } |
| | | |
| | | public void setWechatMenuId(String wechatMenuId) { |
| | | this.wechatMenuId = wechatMenuId; |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | package com.java110.core.factory; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.core.smo.code.ICodeApi; |
| | | import com.java110.utils.cache.MappingCache; |
| | | import com.java110.utils.constant.MappingConstant; |
| | | import com.java110.utils.constant.ResponseConstant; |
| | |
| | | import com.java110.utils.factory.ApplicationContextFactory; |
| | | import com.java110.utils.util.Assert; |
| | | import com.java110.utils.util.DateUtil; |
| | | import com.java110.core.smo.code.ICodeApi; |
| | | import org.springframework.web.client.RestTemplate; |
| | | |
| | | import java.rmi.NoSuchObjectException; |
| | |
| | | public static final String CODE_PREFIX_locationId = "74"; |
| | | public static final String CODE_PREFIX_flowId = "75"; |
| | | public static final String CODE_PREFIX_wssId = "76"; |
| | | |
| | | public static final String CODE_PREFIX_wechatMenuId = "77"; |
| | | |
| | | |
| | | /** |
| New file |
| | |
| | | package com.java110.core.smo.wechatMenu; |
| | | |
| | | import com.java110.core.feign.FeignConfiguration; |
| | | import com.java110.dto.wechatMenu.WechatMenuDto; |
| | | import org.springframework.cloud.openfeign.FeignClient; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestMethod; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @ClassName IWechatMenuInnerServiceSMO |
| | | * @Description 公众号菜单接口类 |
| | | * @Author wuxw |
| | | * @Date 2019/4/24 9:04 |
| | | * @Version 1.0 |
| | | * add by wuxw 2019/4/24 |
| | | **/ |
| | | @FeignClient(name = "store-service", configuration = {FeignConfiguration.class}) |
| | | @RequestMapping("/wechatMenuApi") |
| | | public interface IWechatMenuInnerServiceSMO { |
| | | |
| | | /** |
| | | * <p>查询小区楼信息</p> |
| | | * |
| | | * |
| | | * @param wechatMenuDto 数据对象分享 |
| | | * @return WechatMenuDto 对象数据 |
| | | */ |
| | | @RequestMapping(value = "/queryWechatMenus", method = RequestMethod.POST) |
| | | List<WechatMenuDto> queryWechatMenus(@RequestBody WechatMenuDto wechatMenuDto); |
| | | |
| | | /** |
| | | * 查询<p>小区楼</p>总记录数 |
| | | * |
| | | * @param wechatMenuDto 数据对象分享 |
| | | * @return 小区下的小区楼记录数 |
| | | */ |
| | | @RequestMapping(value = "/queryWechatMenusCount", method = RequestMethod.POST) |
| | | int queryWechatMenusCount(@RequestBody WechatMenuDto wechatMenuDto); |
| | | } |
| New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8" ?> |
| | | <!DOCTYPE mapper |
| | | PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
| | | "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="wechatMenuServiceDaoImpl"> |
| | | |
| | | <!-- 保存公众号菜单信息 add by wuxw 2018-07-03 --> |
| | | <insert id="saveBusinessWechatMenuInfo" parameterType="Map"> |
| | | insert into business_wechat_menu( |
| | | pagepath,operate,app_id,menu_level,menu_name,menu_type,menu_value,b_id,community_id,wechat_menu_id |
| | | ) values ( |
| | | #{pagepath},#{operate},#{appId},#{menuLevel},#{menuName},#{menuType},#{menuValue},#{bId},#{communityId},#{wechatMenuId} |
| | | ) |
| | | </insert> |
| | | |
| | | |
| | | <!-- 查询公众号菜单信息(Business) add by wuxw 2018-07-03 --> |
| | | <select id="getBusinessWechatMenuInfo" parameterType="Map" resultType="Map"> |
| | | select t.pagepath,t.operate,t.app_id,t.app_id appId,t.menu_level,t.menu_level menuLevel,t.menu_name,t.menu_name menuName,t.menu_type,t.menu_type menuType,t.menu_value,t.menu_value menuValue,t.b_id,t.b_id bId,t.community_id,t.community_id communityId,t.wechat_menu_id,t.wechat_menu_id wechatMenuId |
| | | from business_wechat_menu t |
| | | where 1 =1 |
| | | <if test="pagepath !=null and pagepath != ''"> |
| | | and t.pagepath= #{pagepath} |
| | | </if> |
| | | <if test="operate !=null and operate != ''"> |
| | | and t.operate= #{operate} |
| | | </if> |
| | | <if test="appId !=null and appId != ''"> |
| | | and t.app_id= #{appId} |
| | | </if> |
| | | <if test="menuLevel !=null and menuLevel != ''"> |
| | | and t.menu_level= #{menuLevel} |
| | | </if> |
| | | <if test="menuName !=null and menuName != ''"> |
| | | and t.menu_name= #{menuName} |
| | | </if> |
| | | <if test="menuType !=null and menuType != ''"> |
| | | and t.menu_type= #{menuType} |
| | | </if> |
| | | <if test="menuValue !=null and menuValue != ''"> |
| | | and t.menu_value= #{menuValue} |
| | | </if> |
| | | <if test="bId !=null and bId != ''"> |
| | | and t.b_id= #{bId} |
| | | </if> |
| | | <if test="communityId !=null and communityId != ''"> |
| | | and t.community_id= #{communityId} |
| | | </if> |
| | | <if test="wechatMenuId !=null and wechatMenuId != ''"> |
| | | and t.wechat_menu_id= #{wechatMenuId} |
| | | </if> |
| | | |
| | | </select> |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | <!-- 保存公众号菜单信息至 instance表中 add by wuxw 2018-07-03 --> |
| | | <insert id="saveWechatMenuInfoInstance" parameterType="Map"> |
| | | insert into wechat_menu( |
| | | pagepath,app_id,menu_level,menu_name,menu_type,menu_value,status_cd,b_id,community_id,wechat_menu_id |
| | | ) select t.pagepath,t.app_id,t.menu_level,t.menu_name,t.menu_type,t.menu_value,'0',t.b_id,t.community_id,t.wechat_menu_id from business_wechat_menu t where 1=1 |
| | | <if test="pagepath !=null and pagepath != ''"> |
| | | and t.pagepath= #{pagepath} |
| | | </if> |
| | | and t.operate= 'ADD' |
| | | <if test="appId !=null and appId != ''"> |
| | | and t.app_id= #{appId} |
| | | </if> |
| | | <if test="menuLevel !=null and menuLevel != ''"> |
| | | and t.menu_level= #{menuLevel} |
| | | </if> |
| | | <if test="menuName !=null and menuName != ''"> |
| | | and t.menu_name= #{menuName} |
| | | </if> |
| | | <if test="menuType !=null and menuType != ''"> |
| | | and t.menu_type= #{menuType} |
| | | </if> |
| | | <if test="menuValue !=null and menuValue != ''"> |
| | | and t.menu_value= #{menuValue} |
| | | </if> |
| | | <if test="bId !=null and bId != ''"> |
| | | and t.b_id= #{bId} |
| | | </if> |
| | | <if test="communityId !=null and communityId != ''"> |
| | | and t.community_id= #{communityId} |
| | | </if> |
| | | <if test="wechatMenuId !=null and wechatMenuId != ''"> |
| | | and t.wechat_menu_id= #{wechatMenuId} |
| | | </if> |
| | | |
| | | </insert> |
| | | |
| | | |
| | | |
| | | <!-- 查询公众号菜单信息 add by wuxw 2018-07-03 --> |
| | | <select id="getWechatMenuInfo" parameterType="Map" resultType="Map"> |
| | | select t.pagepath,t.app_id,t.app_id appId,t.menu_level,t.menu_level menuLevel,t.menu_name,t.menu_name menuName,t.menu_type,t.menu_type menuType,t.menu_value,t.menu_value menuValue,t.status_cd,t.status_cd statusCd,t.b_id,t.b_id bId,t.community_id,t.community_id communityId,t.wechat_menu_id,t.wechat_menu_id wechatMenuId |
| | | from wechat_menu t |
| | | where 1 =1 |
| | | <if test="pagepath !=null and pagepath != ''"> |
| | | and t.pagepath= #{pagepath} |
| | | </if> |
| | | <if test="appId !=null and appId != ''"> |
| | | and t.app_id= #{appId} |
| | | </if> |
| | | <if test="menuLevel !=null and menuLevel != ''"> |
| | | and t.menu_level= #{menuLevel} |
| | | </if> |
| | | <if test="menuName !=null and menuName != ''"> |
| | | and t.menu_name= #{menuName} |
| | | </if> |
| | | <if test="menuType !=null and menuType != ''"> |
| | | and t.menu_type= #{menuType} |
| | | </if> |
| | | <if test="menuValue !=null and menuValue != ''"> |
| | | and t.menu_value= #{menuValue} |
| | | </if> |
| | | <if test="statusCd !=null and statusCd != ''"> |
| | | and t.status_cd= #{statusCd} |
| | | </if> |
| | | <if test="bId !=null and bId != ''"> |
| | | and t.b_id= #{bId} |
| | | </if> |
| | | <if test="communityId !=null and communityId != ''"> |
| | | and t.community_id= #{communityId} |
| | | </if> |
| | | <if test="wechatMenuId !=null and wechatMenuId != ''"> |
| | | and t.wechat_menu_id= #{wechatMenuId} |
| | | </if> |
| | | order by t.create_time desc |
| | | <if test="page != -1 and page != null "> |
| | | limit #{page}, #{row} |
| | | </if> |
| | | |
| | | </select> |
| | | |
| | | |
| | | |
| | | |
| | | <!-- 修改公众号菜单信息 add by wuxw 2018-07-03 --> |
| | | <update id="updateWechatMenuInfoInstance" parameterType="Map"> |
| | | update wechat_menu t set t.status_cd = #{statusCd} |
| | | <if test="newBId != null and newBId != ''"> |
| | | ,t.b_id = #{newBId} |
| | | </if> |
| | | <if test="pagepath !=null and pagepath != ''"> |
| | | , t.pagepath= #{pagepath} |
| | | </if> |
| | | <if test="appId !=null and appId != ''"> |
| | | , t.app_id= #{appId} |
| | | </if> |
| | | <if test="menuLevel !=null and menuLevel != ''"> |
| | | , t.menu_level= #{menuLevel} |
| | | </if> |
| | | <if test="menuName !=null and menuName != ''"> |
| | | , t.menu_name= #{menuName} |
| | | </if> |
| | | <if test="menuType !=null and menuType != ''"> |
| | | , t.menu_type= #{menuType} |
| | | </if> |
| | | <if test="menuValue !=null and menuValue != ''"> |
| | | , t.menu_value= #{menuValue} |
| | | </if> |
| | | <if test="communityId !=null and communityId != ''"> |
| | | , t.community_id= #{communityId} |
| | | </if> |
| | | where 1=1 <if test="bId !=null and bId != ''"> |
| | | and t.b_id= #{bId} |
| | | </if> |
| | | <if test="wechatMenuId !=null and wechatMenuId != ''"> |
| | | and t.wechat_menu_id= #{wechatMenuId} |
| | | </if> |
| | | |
| | | </update> |
| | | |
| | | <!-- 查询公众号菜单数量 add by wuxw 2018-07-03 --> |
| | | <select id="queryWechatMenusCount" parameterType="Map" resultType="Map"> |
| | | select count(1) count |
| | | from wechat_menu t |
| | | where 1 =1 |
| | | <if test="pagepath !=null and pagepath != ''"> |
| | | and t.pagepath= #{pagepath} |
| | | </if> |
| | | <if test="appId !=null and appId != ''"> |
| | | and t.app_id= #{appId} |
| | | </if> |
| | | <if test="menuLevel !=null and menuLevel != ''"> |
| | | and t.menu_level= #{menuLevel} |
| | | </if> |
| | | <if test="menuName !=null and menuName != ''"> |
| | | and t.menu_name= #{menuName} |
| | | </if> |
| | | <if test="menuType !=null and menuType != ''"> |
| | | and t.menu_type= #{menuType} |
| | | </if> |
| | | <if test="menuValue !=null and menuValue != ''"> |
| | | and t.menu_value= #{menuValue} |
| | | </if> |
| | | <if test="statusCd !=null and statusCd != ''"> |
| | | and t.status_cd= #{statusCd} |
| | | </if> |
| | | <if test="bId !=null and bId != ''"> |
| | | and t.b_id= #{bId} |
| | | </if> |
| | | <if test="communityId !=null and communityId != ''"> |
| | | and t.community_id= #{communityId} |
| | | </if> |
| | | <if test="wechatMenuId !=null and wechatMenuId != ''"> |
| | | and t.wechat_menu_id= #{wechatMenuId} |
| | | </if> |
| | | |
| | | |
| | | </select> |
| | | |
| | | </mapper> |
| | |
| | | { |
| | | "autoMove": true, |
| | | "id": "attrId", |
| | | "name": "smallWechatAttr", |
| | | "desc": "微信属性", |
| | | "id": "wechatMenuId", |
| | | "name": "wechatMenu", |
| | | "desc": "公众号菜单", |
| | | "shareParam": "communityId", |
| | | "shareColumn": "community_id", |
| | | "shareName": "store", |
| | | "newBusinessTypeCd": "BUSINESS_TYPE_SAVE_SMALL_WECHAT_ATTR", |
| | | "updateBusinessTypeCd": "BUSINESS_TYPE_UPDATE_SMALL_WECHAT_ATTR", |
| | | "deleteBusinessTypeCd": "BUSINESS_TYPE_DELETE_SMALL_WECHAT_ATTR", |
| | | "newBusinessTypeCdValue": "221200030001", |
| | | "updateBusinessTypeCdValue": "221200040001", |
| | | "deleteBusinessTypeCdValue": "221200050001", |
| | | "businessTableName": "business_small_wechat_attr", |
| | | "tableName": "small_wechat_attr", |
| | | "newBusinessTypeCd": "BUSINESS_TYPE_SAVE_WECHAT_MENU", |
| | | "updateBusinessTypeCd": "BUSINESS_TYPE_UPDATE_WECHAT_MENU", |
| | | "deleteBusinessTypeCd": "BUSINESS_TYPE_DELETE_WECHAT_MENU", |
| | | "newBusinessTypeCdValue": "221300030001", |
| | | "updateBusinessTypeCdValue": "221300040001", |
| | | "deleteBusinessTypeCdValue": "221300050001", |
| | | "businessTableName": "business_wechat_menu", |
| | | "tableName": "wechat_menu", |
| | | "param": { |
| | | "attrId": "attr_id", |
| | | "wechatId": "wechat_id", |
| | | "wechatMenuId": "wechat_menu_id", |
| | | "menuName": "menu_name", |
| | | "bId": "b_id", |
| | | "specCd": "spec_cd", |
| | | "value": "value", |
| | | "menuType": "menu_type", |
| | | "menuValue": "menu_value", |
| | | "menuLevel": "menu_level", |
| | | "appId": "app_id", |
| | | "pagepath": "pagepath", |
| | | "communityId": "community_id", |
| | | "statusCd": "status_cd", |
| | | "operate": "operate" |
| | | }, |
| | | "required": [ |
| | | { |
| | | "code": "specCd", |
| | | "msg": "规格不能为空" |
| | | "code": "menuName", |
| | | "msg": "菜单名称不能为空" |
| | | }, |
| | | { |
| | | "code": "menuType", |
| | | "msg": "菜单类型不能为空" |
| | | }, |
| | | { |
| | | "code": "menuLevel", |
| | | "msg": "菜单级别不能为空" |
| | | }, |
| | | { |
| | | "code": "menuValue", |
| | | "msg": "菜单值不能为空" |
| | | }, |
| | | { |
| | | "code": "communityId", |
| | | "msg": "小区不能为空" |
| | | }, |
| | | { |
| | | "code": "value", |
| | | "msg": "值不能为空" |
| | | } |
| | | ] |
| | | } |
| New file |
| | |
| | | { |
| | | "autoMove": true, |
| | | "id": "attrId", |
| | | "name": "smallWechatAttr", |
| | | "desc": "微信属性", |
| | | "shareParam": "communityId", |
| | | "shareColumn": "community_id", |
| | | "shareName": "store", |
| | | "newBusinessTypeCd": "BUSINESS_TYPE_SAVE_SMALL_WECHAT_ATTR", |
| | | "updateBusinessTypeCd": "BUSINESS_TYPE_UPDATE_SMALL_WECHAT_ATTR", |
| | | "deleteBusinessTypeCd": "BUSINESS_TYPE_DELETE_SMALL_WECHAT_ATTR", |
| | | "newBusinessTypeCdValue": "221200030001", |
| | | "updateBusinessTypeCdValue": "221200040001", |
| | | "deleteBusinessTypeCdValue": "221200050001", |
| | | "businessTableName": "business_small_wechat_attr", |
| | | "tableName": "small_wechat_attr", |
| | | "param": { |
| | | "attrId": "attr_id", |
| | | "wechatId": "wechat_id", |
| | | "bId": "b_id", |
| | | "specCd": "spec_cd", |
| | | "value": "value", |
| | | "communityId": "community_id", |
| | | "statusCd": "status_cd", |
| | | "operate": "operate" |
| | | }, |
| | | "required": [ |
| | | { |
| | | "code": "specCd", |
| | | "msg": "规格不能为空" |
| | | }, |
| | | { |
| | | "code": "communityId", |
| | | "msg": "小区不能为空" |
| | | }, |
| | | { |
| | | "code": "value", |
| | | "msg": "值不能为空" |
| | | } |
| | | ] |
| | | } |
| | | |
| | |
| | | public static final String BUSINESS_TYPE_DELETE_SMALL_WECHAT_ATTR = "221200050001"; |
| | | |
| | | |
| | | //保存公众号菜单 |
| | | public static final String BUSINESS_TYPE_SAVE_WECHAT_MENU = "221300030001"; |
| | | //修改公众号菜单 |
| | | public static final String BUSINESS_TYPE_UPDATE_WECHAT_MENU = "221300040001"; |
| | | //删除公众号菜单 |
| | | public static final String BUSINESS_TYPE_DELETE_WECHAT_MENU = "221300050001"; |
| | | |
| | | /** |
| | | * 保存商品信息 |
| New file |
| | |
| | | package com.java110.utils.constant; |
| | | |
| | | /** |
| | | * 公众号菜单常量类 |
| | | * Created by wuxw on 2017/5/20. |
| | | */ |
| | | public class ServiceCodeWechatMenuConstant { |
| | | |
| | | /** |
| | | * 添加 公众号菜单 |
| | | */ |
| | | public static final String ADD_WECHATMENU = "smallWeChat.saveWechatMenu"; |
| | | |
| | | |
| | | /** |
| | | * 修改 公众号菜单 |
| | | */ |
| | | public static final String UPDATE_WECHATMENU = "smallWeChat.updateWechatMenu"; |
| | | /** |
| | | * 删除 公众号菜单 |
| | | */ |
| | | public static final String DELETE_WECHATMENU = "smallWeChat.deleteWechatMenu"; |
| | | |
| | | |
| | | /** |
| | | * 查询 公众号菜单 |
| | | */ |
| | | public static final String LIST_WECHATMENUS = "smallWeChat.listWechatMenus"; |
| | | |
| | | |
| | | } |
| New file |
| | |
| | | package com.java110.api.bmo.smallWeChat; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.api.bmo.IApiBaseBMO; |
| | | import com.java110.core.context.DataFlowContext; |
| | | |
| | | public interface IWechatMenuBMO extends IApiBaseBMO { |
| | | |
| | | |
| | | /** |
| | | * 添加公众号菜单 |
| | | * @param paramInJson |
| | | * @param dataFlowContext |
| | | * @return |
| | | */ |
| | | void addWechatMenu(JSONObject paramInJson, DataFlowContext dataFlowContext); |
| | | |
| | | /** |
| | | * 添加公众号菜单信息 |
| | | * |
| | | * @param paramInJson 接口调用放传入入参 |
| | | * @param dataFlowContext 数据上下文 |
| | | * @return 订单服务能够接受的报文 |
| | | */ |
| | | void updateWechatMenu(JSONObject paramInJson, DataFlowContext dataFlowContext); |
| | | |
| | | /** |
| | | * 删除公众号菜单 |
| | | * |
| | | * @param paramInJson 接口调用放传入入参 |
| | | * @param dataFlowContext 数据上下文 |
| | | * @return 订单服务能够接受的报文 |
| | | */ |
| | | void deleteWechatMenu(JSONObject paramInJson, DataFlowContext dataFlowContext); |
| | | |
| | | |
| | | |
| | | } |
| New file |
| | |
| | | package com.java110.api.bmo.smallWeChat.impl; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.api.bmo.ApiBaseBMO; |
| | | import com.java110.api.bmo.smallWeChat.IWechatMenuBMO; |
| | | import com.java110.core.context.DataFlowContext; |
| | | import com.java110.core.smo.wechatMenu.IWechatMenuInnerServiceSMO; |
| | | import com.java110.po.wechatMenu.WechatMenuPo; |
| | | import com.java110.utils.constant.BusinessTypeConstant; |
| | | import com.java110.utils.util.BeanConvertUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | @Service("wechatMenuBMOImpl") |
| | | public class WechatMenuBMOImpl extends ApiBaseBMO implements IWechatMenuBMO { |
| | | |
| | | @Autowired |
| | | private IWechatMenuInnerServiceSMO wechatMenuInnerServiceSMOImpl; |
| | | |
| | | /** |
| | | * 添加小区信息 |
| | | * |
| | | * @param paramInJson 接口调用放传入入参 |
| | | * @param dataFlowContext 数据上下文 |
| | | * @return 订单服务能够接受的报文 |
| | | */ |
| | | public void addWechatMenu(JSONObject paramInJson, DataFlowContext dataFlowContext) { |
| | | |
| | | paramInJson.put("wechatMenuId", "-1"); |
| | | WechatMenuPo wechatMenuPo = BeanConvertUtil.covertBean(paramInJson, WechatMenuPo.class); |
| | | super.insert(dataFlowContext, wechatMenuPo, BusinessTypeConstant.BUSINESS_TYPE_SAVE_WECHAT_MENU); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 添加活动信息 |
| | | * |
| | | * @param paramInJson 接口调用放传入入参 |
| | | * @param dataFlowContext 数据上下文 |
| | | * @return 订单服务能够接受的报文 |
| | | */ |
| | | public void updateWechatMenu(JSONObject paramInJson, DataFlowContext dataFlowContext) { |
| | | WechatMenuPo wechatMenuPo = BeanConvertUtil.covertBean(paramInJson, WechatMenuPo.class); |
| | | super.update(dataFlowContext, wechatMenuPo, BusinessTypeConstant.BUSINESS_TYPE_UPDATE_WECHAT_MENU); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 添加小区信息 |
| | | * |
| | | * @param paramInJson 接口调用放传入入参 |
| | | * @param dataFlowContext 数据上下文 |
| | | * @return 订单服务能够接受的报文 |
| | | */ |
| | | public void deleteWechatMenu(JSONObject paramInJson, DataFlowContext dataFlowContext) { |
| | | |
| | | WechatMenuPo wechatMenuPo = BeanConvertUtil.covertBean(paramInJson, WechatMenuPo.class); |
| | | super.update(dataFlowContext, wechatMenuPo, BusinessTypeConstant.BUSINESS_TYPE_DELETE_WECHAT_MENU); |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | package com.java110.api.listener.smallWeChat; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.api.bmo.smallWeChat.IWechatMenuBMO; |
| | | 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.ServiceCodeWechatMenuConstant; |
| | | import com.java110.utils.util.Assert; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.http.HttpMethod; |
| | | |
| | | |
| | | /** |
| | | * 保存小区侦听 |
| | | * add by wuxw 2019-06-30 |
| | | */ |
| | | @Java110Listener("deleteWechatMenuListener") |
| | | public class DeleteWechatMenuListener extends AbstractServiceApiPlusListener { |
| | | |
| | | @Autowired |
| | | private IWechatMenuBMO wechatMenuBMOImpl; |
| | | |
| | | @Override |
| | | protected void validate(ServiceDataFlowEvent event, JSONObject reqJson) { |
| | | //Assert.hasKeyAndValue(reqJson, "xxx", "xxx"); |
| | | |
| | | Assert.hasKeyAndValue(reqJson, "wechatMenuId", "wechatMenuId不能为空"); |
| | | |
| | | } |
| | | |
| | | @Override |
| | | protected void doSoService(ServiceDataFlowEvent event, DataFlowContext context, JSONObject reqJson) { |
| | | |
| | | wechatMenuBMOImpl.deleteWechatMenu(reqJson, context); |
| | | } |
| | | |
| | | @Override |
| | | public String getServiceCode() { |
| | | return ServiceCodeWechatMenuConstant.DELETE_WECHATMENU; |
| | | } |
| | | |
| | | @Override |
| | | public HttpMethod getHttpMethod() { |
| | | return HttpMethod.POST; |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | 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.smo.wechatMenu.IWechatMenuInnerServiceSMO; |
| | | import com.java110.dto.wechatMenu.WechatMenuDto; |
| | | import com.java110.utils.constant.ServiceCodeWechatMenuConstant; |
| | | import com.java110.utils.util.BeanConvertUtil; |
| | | import com.java110.vo.ResultVo; |
| | | 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("listWechatMenusListener") |
| | | public class ListWechatMenusListener extends AbstractServiceApiListener { |
| | | |
| | | @Autowired |
| | | private IWechatMenuInnerServiceSMO wechatMenuInnerServiceSMOImpl; |
| | | |
| | | @Override |
| | | public String getServiceCode() { |
| | | return ServiceCodeWechatMenuConstant.LIST_WECHATMENUS; |
| | | } |
| | | |
| | | @Override |
| | | public HttpMethod getHttpMethod() { |
| | | return HttpMethod.GET; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public int getOrder() { |
| | | return DEFAULT_ORDER; |
| | | } |
| | | |
| | | |
| | | public IWechatMenuInnerServiceSMO getWechatMenuInnerServiceSMOImpl() { |
| | | return wechatMenuInnerServiceSMOImpl; |
| | | } |
| | | |
| | | public void setWechatMenuInnerServiceSMOImpl(IWechatMenuInnerServiceSMO wechatMenuInnerServiceSMOImpl) { |
| | | this.wechatMenuInnerServiceSMOImpl = wechatMenuInnerServiceSMOImpl; |
| | | } |
| | | |
| | | @Override |
| | | protected void validate(ServiceDataFlowEvent event, JSONObject reqJson) { |
| | | super.validatePageInfo(reqJson); |
| | | } |
| | | |
| | | @Override |
| | | protected void doSoService(ServiceDataFlowEvent event, DataFlowContext context, JSONObject reqJson) { |
| | | |
| | | WechatMenuDto wechatMenuDto = BeanConvertUtil.covertBean(reqJson, WechatMenuDto.class); |
| | | |
| | | int count = wechatMenuInnerServiceSMOImpl.queryWechatMenusCount(wechatMenuDto); |
| | | |
| | | List<WechatMenuDto> wechatMenuDtos = null; |
| | | |
| | | if (count > 0) { |
| | | wechatMenuDtos = wechatMenuInnerServiceSMOImpl.queryWechatMenus(wechatMenuDto); |
| | | } else { |
| | | wechatMenuDtos = new ArrayList<>(); |
| | | } |
| | | |
| | | ResultVo resultVo = new ResultVo((int) Math.ceil((double) count / (double) reqJson.getInteger("row")), count, wechatMenuDtos); |
| | | |
| | | ResponseEntity<String> responseEntity = new ResponseEntity<String>(resultVo.toString(), HttpStatus.OK); |
| | | |
| | | context.setResponseEntity(responseEntity); |
| | | |
| | | } |
| | | } |
| New file |
| | |
| | | package com.java110.api.listener.smallWeChat; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.api.bmo.smallWeChat.IWechatMenuBMO; |
| | | 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.ServiceCodeWechatMenuConstant; |
| | | import com.java110.utils.util.Assert; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.http.HttpMethod; |
| | | |
| | | /** |
| | | * 保存商户侦听 |
| | | * add by wuxw 2019-06-30 |
| | | */ |
| | | @Java110Listener("saveWechatMenuListener") |
| | | public class SaveWechatMenuListener extends AbstractServiceApiPlusListener { |
| | | |
| | | @Autowired |
| | | private IWechatMenuBMO wechatMenuBMOImpl; |
| | | |
| | | @Override |
| | | protected void validate(ServiceDataFlowEvent event, JSONObject reqJson) { |
| | | //Assert.hasKeyAndValue(reqJson, "xxx", "xxx"); |
| | | |
| | | Assert.hasKeyAndValue(reqJson, "menuName", "请求报文中未包含menuName"); |
| | | Assert.hasKeyAndValue(reqJson, "menuType", "请求报文中未包含menuType"); |
| | | Assert.hasKeyAndValue(reqJson, "menuLevel", "请求报文中未包含menuLevel"); |
| | | Assert.hasKeyAndValue(reqJson, "menuValue", "请求报文中未包含menuValue"); |
| | | Assert.hasKeyAndValue(reqJson, "communityId", "请求报文中未包含communityId"); |
| | | |
| | | } |
| | | |
| | | @Override |
| | | protected void doSoService(ServiceDataFlowEvent event, DataFlowContext context, JSONObject reqJson) { |
| | | wechatMenuBMOImpl.addWechatMenu(reqJson, context); |
| | | } |
| | | |
| | | @Override |
| | | public String getServiceCode() { |
| | | return ServiceCodeWechatMenuConstant.ADD_WECHATMENU; |
| | | } |
| | | |
| | | @Override |
| | | public HttpMethod getHttpMethod() { |
| | | return HttpMethod.POST; |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | package com.java110.api.listener.smallWeChat; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.api.bmo.smallWeChat.IWechatMenuBMO; |
| | | 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.ServiceCodeWechatMenuConstant; |
| | | import com.java110.utils.util.Assert; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.http.HttpMethod; |
| | | |
| | | |
| | | /** |
| | | * 保存公众号菜单侦听 |
| | | * add by wuxw 2019-06-30 |
| | | */ |
| | | @Java110Listener("updateWechatMenuListener") |
| | | public class UpdateWechatMenuListener extends AbstractServiceApiPlusListener { |
| | | |
| | | @Autowired |
| | | private IWechatMenuBMO wechatMenuBMOImpl; |
| | | |
| | | @Override |
| | | protected void validate(ServiceDataFlowEvent event, JSONObject reqJson) { |
| | | |
| | | Assert.hasKeyAndValue(reqJson, "wechatMenuId", "wechatMenuId不能为空"); |
| | | Assert.hasKeyAndValue(reqJson, "menuName", "请求报文中未包含menuName"); |
| | | Assert.hasKeyAndValue(reqJson, "menuType", "请求报文中未包含menuType"); |
| | | Assert.hasKeyAndValue(reqJson, "menuLevel", "请求报文中未包含menuLevel"); |
| | | Assert.hasKeyAndValue(reqJson, "menuValue", "请求报文中未包含menuValue"); |
| | | Assert.hasKeyAndValue(reqJson, "communityId", "请求报文中未包含communityId"); |
| | | |
| | | } |
| | | |
| | | @Override |
| | | protected void doSoService(ServiceDataFlowEvent event, DataFlowContext context, JSONObject reqJson) { |
| | | |
| | | wechatMenuBMOImpl.updateWechatMenu(reqJson, context); |
| | | } |
| | | |
| | | @Override |
| | | public String getServiceCode() { |
| | | return ServiceCodeWechatMenuConstant.UPDATE_WECHATMENU; |
| | | } |
| | | |
| | | @Override |
| | | public HttpMethod getHttpMethod() { |
| | | return HttpMethod.POST; |
| | | } |
| | | } |
| New file |
| | |
| | | package com.java110.store.dao; |
| | | |
| | | |
| | | import com.java110.utils.exception.DAOException; |
| | | import com.java110.entity.merchant.BoMerchant; |
| | | import com.java110.entity.merchant.BoMerchantAttr; |
| | | import com.java110.entity.merchant.Merchant; |
| | | import com.java110.entity.merchant.MerchantAttr; |
| | | |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 公众号菜单组件内部之间使用,没有给外围系统提供服务能力 |
| | | * 公众号菜单服务接口类,要求全部以字符串传输,方便微服务化 |
| | | * 新建客户,修改客户,删除客户,查询客户等功能 |
| | | * |
| | | * Created by wuxw on 2016/12/27. |
| | | */ |
| | | public interface IWechatMenuServiceDao { |
| | | |
| | | /** |
| | | * 保存 公众号菜单信息 |
| | | * @param businessWechatMenuInfo 公众号菜单信息 封装 |
| | | * @throws DAOException 操作数据库异常 |
| | | */ |
| | | void saveBusinessWechatMenuInfo(Map businessWechatMenuInfo) throws DAOException; |
| | | |
| | | |
| | | |
| | | /** |
| | | * 查询公众号菜单信息(business过程) |
| | | * 根据bId 查询公众号菜单信息 |
| | | * @param info bId 信息 |
| | | * @return 公众号菜单信息 |
| | | * @throws DAOException DAO异常 |
| | | */ |
| | | List<Map> getBusinessWechatMenuInfo(Map info) throws DAOException; |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 保存 公众号菜单信息 Business数据到 Instance中 |
| | | * @param info |
| | | * @throws DAOException DAO异常 |
| | | */ |
| | | void saveWechatMenuInfoInstance(Map info) throws DAOException; |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 查询公众号菜单信息(instance过程) |
| | | * 根据bId 查询公众号菜单信息 |
| | | * @param info bId 信息 |
| | | * @return 公众号菜单信息 |
| | | * @throws DAOException DAO异常 |
| | | */ |
| | | List<Map> getWechatMenuInfo(Map info) throws DAOException; |
| | | |
| | | |
| | | |
| | | /** |
| | | * 修改公众号菜单信息 |
| | | * @param info 修改信息 |
| | | * @throws DAOException DAO异常 |
| | | */ |
| | | void updateWechatMenuInfoInstance(Map info) throws DAOException; |
| | | |
| | | |
| | | /** |
| | | * 查询公众号菜单总数 |
| | | * |
| | | * @param info 公众号菜单信息 |
| | | * @return 公众号菜单数量 |
| | | */ |
| | | int queryWechatMenusCount(Map info); |
| | | |
| | | } |
| New file |
| | |
| | | package com.java110.store.dao.impl; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.utils.constant.ResponseConstant; |
| | | import com.java110.utils.exception.DAOException; |
| | | import com.java110.utils.util.DateUtil; |
| | | import com.java110.core.base.dao.BaseServiceDao; |
| | | import com.java110.store.dao.IWechatMenuServiceDao; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 公众号菜单服务 与数据库交互 |
| | | * Created by wuxw on 2017/4/5. |
| | | */ |
| | | @Service("wechatMenuServiceDaoImpl") |
| | | //@Transactional |
| | | public class WechatMenuServiceDaoImpl extends BaseServiceDao implements IWechatMenuServiceDao { |
| | | |
| | | private static Logger logger = LoggerFactory.getLogger(WechatMenuServiceDaoImpl.class); |
| | | |
| | | /** |
| | | * 公众号菜单信息封装 |
| | | * @param businessWechatMenuInfo 公众号菜单信息 封装 |
| | | * @throws DAOException DAO异常 |
| | | */ |
| | | @Override |
| | | public void saveBusinessWechatMenuInfo(Map businessWechatMenuInfo) throws DAOException { |
| | | businessWechatMenuInfo.put("month", DateUtil.getCurrentMonth()); |
| | | // 查询business_user 数据是否已经存在 |
| | | logger.debug("保存公众号菜单信息 入参 businessWechatMenuInfo : {}",businessWechatMenuInfo); |
| | | int saveFlag = sqlSessionTemplate.insert("wechatMenuServiceDaoImpl.saveBusinessWechatMenuInfo",businessWechatMenuInfo); |
| | | |
| | | if(saveFlag < 1){ |
| | | throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"保存公众号菜单数据失败:"+ JSONObject.toJSONString(businessWechatMenuInfo)); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 查询公众号菜单信息 |
| | | * @param info bId 信息 |
| | | * @return 公众号菜单信息 |
| | | * @throws DAOException DAO异常 |
| | | */ |
| | | @Override |
| | | public List<Map> getBusinessWechatMenuInfo(Map info) throws DAOException { |
| | | |
| | | logger.debug("查询公众号菜单信息 入参 info : {}",info); |
| | | |
| | | List<Map> businessWechatMenuInfos = sqlSessionTemplate.selectList("wechatMenuServiceDaoImpl.getBusinessWechatMenuInfo",info); |
| | | |
| | | return businessWechatMenuInfos; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 保存公众号菜单信息 到 instance |
| | | * @param info bId 信息 |
| | | * @throws DAOException DAO异常 |
| | | */ |
| | | @Override |
| | | public void saveWechatMenuInfoInstance(Map info) throws DAOException { |
| | | logger.debug("保存公众号菜单信息Instance 入参 info : {}",info); |
| | | |
| | | int saveFlag = sqlSessionTemplate.insert("wechatMenuServiceDaoImpl.saveWechatMenuInfoInstance",info); |
| | | |
| | | if(saveFlag < 1){ |
| | | throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"保存公众号菜单信息Instance数据失败:"+ JSONObject.toJSONString(info)); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 查询公众号菜单信息(instance) |
| | | * @param info bId 信息 |
| | | * @return List<Map> |
| | | * @throws DAOException DAO异常 |
| | | */ |
| | | @Override |
| | | public List<Map> getWechatMenuInfo(Map info) throws DAOException { |
| | | logger.debug("查询公众号菜单信息 入参 info : {}",info); |
| | | |
| | | List<Map> businessWechatMenuInfos = sqlSessionTemplate.selectList("wechatMenuServiceDaoImpl.getWechatMenuInfo",info); |
| | | |
| | | return businessWechatMenuInfos; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 修改公众号菜单信息 |
| | | * @param info 修改信息 |
| | | * @throws DAOException DAO异常 |
| | | */ |
| | | @Override |
| | | public void updateWechatMenuInfoInstance(Map info) throws DAOException { |
| | | logger.debug("修改公众号菜单信息Instance 入参 info : {}",info); |
| | | |
| | | int saveFlag = sqlSessionTemplate.update("wechatMenuServiceDaoImpl.updateWechatMenuInfoInstance",info); |
| | | |
| | | if(saveFlag < 1){ |
| | | throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"修改公众号菜单信息Instance数据失败:"+ JSONObject.toJSONString(info)); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 查询公众号菜单数量 |
| | | * @param info 公众号菜单信息 |
| | | * @return 公众号菜单数量 |
| | | */ |
| | | @Override |
| | | public int queryWechatMenusCount(Map info) { |
| | | logger.debug("查询公众号菜单数据 入参 info : {}",info); |
| | | |
| | | List<Map> businessWechatMenuInfos = sqlSessionTemplate.selectList("wechatMenuServiceDaoImpl.queryWechatMenusCount", info); |
| | | if (businessWechatMenuInfos.size() < 1) { |
| | | return 0; |
| | | } |
| | | |
| | | return Integer.parseInt(businessWechatMenuInfos.get(0).get("count").toString()); |
| | | } |
| | | |
| | | |
| | | } |
| New file |
| | |
| | | package com.java110.store.listener.smallWeChat; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.core.event.service.AbstractBusinessServiceDataFlowListener; |
| | | import com.java110.entity.center.Business; |
| | | import com.java110.store.dao.IWechatMenuServiceDao; |
| | | import com.java110.utils.constant.ResponseConstant; |
| | | import com.java110.utils.constant.StatusConstant; |
| | | import com.java110.utils.exception.ListenerExecuteException; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 公众号菜单 服务侦听 父类 |
| | | * Created by wuxw on 2018/7/4. |
| | | */ |
| | | public abstract class AbstractWechatMenuBusinessServiceDataFlowListener extends AbstractBusinessServiceDataFlowListener { |
| | | private static Logger logger = LoggerFactory.getLogger(AbstractWechatMenuBusinessServiceDataFlowListener.class); |
| | | |
| | | |
| | | /** |
| | | * 获取 DAO工具类 |
| | | * |
| | | * @return |
| | | */ |
| | | public abstract IWechatMenuServiceDao getWechatMenuServiceDaoImpl(); |
| | | |
| | | /** |
| | | * 刷新 businessWechatMenuInfo 数据 |
| | | * 主要将 数据库 中字段和 接口传递字段建立关系 |
| | | * |
| | | * @param businessWechatMenuInfo |
| | | */ |
| | | protected void flushBusinessWechatMenuInfo(Map businessWechatMenuInfo, String statusCd) { |
| | | businessWechatMenuInfo.put("newBId", businessWechatMenuInfo.get("b_id")); |
| | | businessWechatMenuInfo.put("pagepath", businessWechatMenuInfo.get("pagepath")); |
| | | businessWechatMenuInfo.put("operate", businessWechatMenuInfo.get("operate")); |
| | | businessWechatMenuInfo.put("appId", businessWechatMenuInfo.get("app_id")); |
| | | businessWechatMenuInfo.put("menuLevel", businessWechatMenuInfo.get("menu_level")); |
| | | businessWechatMenuInfo.put("menuName", businessWechatMenuInfo.get("menu_name")); |
| | | businessWechatMenuInfo.put("menuType", businessWechatMenuInfo.get("menu_type")); |
| | | businessWechatMenuInfo.put("menuValue", businessWechatMenuInfo.get("menu_value")); |
| | | businessWechatMenuInfo.put("communityId", businessWechatMenuInfo.get("community_id")); |
| | | businessWechatMenuInfo.put("wechatMenuId", businessWechatMenuInfo.get("wechat_menu_id")); |
| | | businessWechatMenuInfo.remove("bId"); |
| | | businessWechatMenuInfo.put("statusCd", statusCd); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 当修改数据时,查询instance表中的数据 自动保存删除数据到business中 |
| | | * |
| | | * @param businessWechatMenu 公众号菜单信息 |
| | | */ |
| | | protected void autoSaveDelBusinessWechatMenu(Business business, JSONObject businessWechatMenu) { |
| | | //自动插入DEL |
| | | Map info = new HashMap(); |
| | | info.put("wechatMenuId", businessWechatMenu.getString("wechatMenuId")); |
| | | info.put("statusCd", StatusConstant.STATUS_CD_VALID); |
| | | List<Map> currentWechatMenuInfos = getWechatMenuServiceDaoImpl().getWechatMenuInfo(info); |
| | | if (currentWechatMenuInfos == null || currentWechatMenuInfos.size() != 1) { |
| | | throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR, "未找到需要修改数据信息,入参错误或数据有问题,请检查" + info); |
| | | } |
| | | |
| | | Map currentWechatMenuInfo = currentWechatMenuInfos.get(0); |
| | | |
| | | currentWechatMenuInfo.put("bId", business.getbId()); |
| | | |
| | | currentWechatMenuInfo.put("pagepath", currentWechatMenuInfo.get("pagepath")); |
| | | currentWechatMenuInfo.put("operate", currentWechatMenuInfo.get("operate")); |
| | | currentWechatMenuInfo.put("appId", currentWechatMenuInfo.get("app_id")); |
| | | currentWechatMenuInfo.put("menuLevel", currentWechatMenuInfo.get("menu_level")); |
| | | currentWechatMenuInfo.put("menuName", currentWechatMenuInfo.get("menu_name")); |
| | | currentWechatMenuInfo.put("menuType", currentWechatMenuInfo.get("menu_type")); |
| | | currentWechatMenuInfo.put("menuValue", currentWechatMenuInfo.get("menu_value")); |
| | | currentWechatMenuInfo.put("communityId", currentWechatMenuInfo.get("community_id")); |
| | | currentWechatMenuInfo.put("wechatMenuId", currentWechatMenuInfo.get("wechat_menu_id")); |
| | | |
| | | |
| | | currentWechatMenuInfo.put("operate", StatusConstant.OPERATE_DEL); |
| | | getWechatMenuServiceDaoImpl().saveBusinessWechatMenuInfo(currentWechatMenuInfo); |
| | | for (Object key : currentWechatMenuInfo.keySet()) { |
| | | if (businessWechatMenu.get(key) == null) { |
| | | businessWechatMenu.put(key.toString(), currentWechatMenuInfo.get(key)); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| New file |
| | |
| | | package com.java110.store.listener.smallWeChat; |
| | | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.po.wechatMenu.WechatMenuPo; |
| | | import com.java110.utils.constant.BusinessTypeConstant; |
| | | import com.java110.utils.constant.ResponseConstant; |
| | | import com.java110.utils.constant.StatusConstant; |
| | | import com.java110.utils.exception.ListenerExecuteException; |
| | | import com.java110.utils.util.Assert; |
| | | import com.java110.core.annotation.Java110Listener; |
| | | import com.java110.core.context.DataFlowContext; |
| | | import com.java110.entity.center.Business; |
| | | import com.java110.store.dao.IWechatMenuServiceDao; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 删除公众号菜单信息 侦听 |
| | | * |
| | | * 处理节点 |
| | | * 1、businessWechatMenu:{} 公众号菜单基本信息节点 |
| | | * 2、businessWechatMenuAttr:[{}] 公众号菜单属性信息节点 |
| | | * 3、businessWechatMenuPhoto:[{}] 公众号菜单照片信息节点 |
| | | * 4、businessWechatMenuCerdentials:[{}] 公众号菜单证件信息节点 |
| | | * 协议地址 :https://github.com/java110/MicroCommunity/wiki/%E5%88%A0%E9%99%A4%E5%95%86%E6%88%B7%E4%BF%A1%E6%81%AF-%E5%8D%8F%E8%AE%AE |
| | | * Created by wuxw on 2018/5/18. |
| | | */ |
| | | @Java110Listener("deleteWechatMenuInfoListener") |
| | | @Transactional |
| | | public class DeleteWechatMenuInfoListener extends AbstractWechatMenuBusinessServiceDataFlowListener { |
| | | |
| | | private final static Logger logger = LoggerFactory.getLogger(DeleteWechatMenuInfoListener.class); |
| | | @Autowired |
| | | IWechatMenuServiceDao wechatMenuServiceDaoImpl; |
| | | |
| | | @Override |
| | | public int getOrder() { |
| | | return 3; |
| | | } |
| | | |
| | | @Override |
| | | public String getBusinessTypeCd() { |
| | | return BusinessTypeConstant.BUSINESS_TYPE_DELETE_WECHAT_MENU; |
| | | } |
| | | |
| | | /** |
| | | * 根据删除信息 查出Instance表中数据 保存至business表 (状态写DEL) 方便撤单时直接更新回去 |
| | | * @param dataFlowContext 数据对象 |
| | | * @param business 当前业务对象 |
| | | */ |
| | | @Override |
| | | protected void doSaveBusiness(DataFlowContext dataFlowContext, Business business) { |
| | | JSONObject data = business.getDatas(); |
| | | |
| | | Assert.notEmpty(data,"没有datas 节点,或没有子节点需要处理"); |
| | | |
| | | //处理 businessWechatMenu 节点 |
| | | if(data.containsKey(WechatMenuPo.class.getSimpleName())){ |
| | | Object _obj = data.get(WechatMenuPo.class.getSimpleName()); |
| | | JSONArray businessWechatMenus = null; |
| | | if(_obj instanceof JSONObject){ |
| | | businessWechatMenus = new JSONArray(); |
| | | businessWechatMenus.add(_obj); |
| | | }else { |
| | | businessWechatMenus = (JSONArray)_obj; |
| | | } |
| | | //JSONObject businessWechatMenu = data.getJSONObject(WechatMenuPo.class.getSimpleName()); |
| | | for (int _wechatMenuIndex = 0; _wechatMenuIndex < businessWechatMenus.size();_wechatMenuIndex++) { |
| | | JSONObject businessWechatMenu = businessWechatMenus.getJSONObject(_wechatMenuIndex); |
| | | doBusinessWechatMenu(business, businessWechatMenu); |
| | | if(_obj instanceof JSONObject) { |
| | | dataFlowContext.addParamOut("wechatMenuId", businessWechatMenu.getString("wechatMenuId")); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 删除 instance数据 |
| | | * @param dataFlowContext 数据对象 |
| | | * @param business 当前业务对象 |
| | | */ |
| | | @Override |
| | | protected void doBusinessToInstance(DataFlowContext dataFlowContext, Business business) { |
| | | String bId = business.getbId(); |
| | | //Assert.hasLength(bId,"请求报文中没有包含 bId"); |
| | | |
| | | //公众号菜单信息 |
| | | Map info = new HashMap(); |
| | | info.put("bId",business.getbId()); |
| | | info.put("operate",StatusConstant.OPERATE_DEL); |
| | | |
| | | //公众号菜单信息 |
| | | List<Map> businessWechatMenuInfos = wechatMenuServiceDaoImpl.getBusinessWechatMenuInfo(info); |
| | | if( businessWechatMenuInfos != null && businessWechatMenuInfos.size() >0) { |
| | | for (int _wechatMenuIndex = 0; _wechatMenuIndex < businessWechatMenuInfos.size();_wechatMenuIndex++) { |
| | | Map businessWechatMenuInfo = businessWechatMenuInfos.get(_wechatMenuIndex); |
| | | flushBusinessWechatMenuInfo(businessWechatMenuInfo,StatusConstant.STATUS_CD_INVALID); |
| | | wechatMenuServiceDaoImpl.updateWechatMenuInfoInstance(businessWechatMenuInfo); |
| | | dataFlowContext.addParamOut("wechatMenuId",businessWechatMenuInfo.get("wechat_menu_id")); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 撤单 |
| | | * 从business表中查询到DEL的数据 将instance中的数据更新回来 |
| | | * @param dataFlowContext 数据对象 |
| | | * @param business 当前业务对象 |
| | | */ |
| | | @Override |
| | | protected void doRecover(DataFlowContext dataFlowContext, Business business) { |
| | | String bId = business.getbId(); |
| | | //Assert.hasLength(bId,"请求报文中没有包含 bId"); |
| | | Map info = new HashMap(); |
| | | info.put("bId",bId); |
| | | info.put("statusCd",StatusConstant.STATUS_CD_INVALID); |
| | | |
| | | Map delInfo = new HashMap(); |
| | | delInfo.put("bId",business.getbId()); |
| | | delInfo.put("operate",StatusConstant.OPERATE_DEL); |
| | | //公众号菜单信息 |
| | | List<Map> wechatMenuInfo = wechatMenuServiceDaoImpl.getWechatMenuInfo(info); |
| | | if(wechatMenuInfo != null && wechatMenuInfo.size() > 0){ |
| | | |
| | | //公众号菜单信息 |
| | | List<Map> businessWechatMenuInfos = wechatMenuServiceDaoImpl.getBusinessWechatMenuInfo(delInfo); |
| | | //除非程序出错了,这里不会为空 |
| | | if(businessWechatMenuInfos == null || businessWechatMenuInfos.size() == 0){ |
| | | throw new ListenerExecuteException(ResponseConstant.RESULT_CODE_INNER_ERROR,"撤单失败(wechatMenu),程序内部异常,请检查! "+delInfo); |
| | | } |
| | | for (int _wechatMenuIndex = 0; _wechatMenuIndex < businessWechatMenuInfos.size();_wechatMenuIndex++) { |
| | | Map businessWechatMenuInfo = businessWechatMenuInfos.get(_wechatMenuIndex); |
| | | flushBusinessWechatMenuInfo(businessWechatMenuInfo,StatusConstant.STATUS_CD_VALID); |
| | | wechatMenuServiceDaoImpl.updateWechatMenuInfoInstance(businessWechatMenuInfo); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 处理 businessWechatMenu 节点 |
| | | * @param business 总的数据节点 |
| | | * @param businessWechatMenu 公众号菜单节点 |
| | | */ |
| | | private void doBusinessWechatMenu(Business business,JSONObject businessWechatMenu){ |
| | | |
| | | Assert.jsonObjectHaveKey(businessWechatMenu,"wechatMenuId","businessWechatMenu 节点下没有包含 wechatMenuId 节点"); |
| | | |
| | | if(businessWechatMenu.getString("wechatMenuId").startsWith("-")){ |
| | | throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"wechatMenuId 错误,不能自动生成(必须已经存在的wechatMenuId)"+businessWechatMenu); |
| | | } |
| | | //自动插入DEL |
| | | autoSaveDelBusinessWechatMenu(business,businessWechatMenu); |
| | | } |
| | | @Override |
| | | public IWechatMenuServiceDao getWechatMenuServiceDaoImpl() { |
| | | return wechatMenuServiceDaoImpl; |
| | | } |
| | | |
| | | public void setWechatMenuServiceDaoImpl(IWechatMenuServiceDao wechatMenuServiceDaoImpl) { |
| | | this.wechatMenuServiceDaoImpl = wechatMenuServiceDaoImpl; |
| | | } |
| | | } |
| New file |
| | |
| | | package com.java110.store.listener.smallWeChat; |
| | | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.core.annotation.Java110Listener; |
| | | import com.java110.core.context.DataFlowContext; |
| | | import com.java110.core.factory.GenerateCodeFactory; |
| | | import com.java110.entity.center.Business; |
| | | import com.java110.po.wechatMenu.WechatMenuPo; |
| | | import com.java110.store.dao.IWechatMenuServiceDao; |
| | | import com.java110.utils.constant.BusinessTypeConstant; |
| | | import com.java110.utils.constant.StatusConstant; |
| | | import com.java110.utils.util.Assert; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 保存 公众号菜单信息 侦听 |
| | | * Created by wuxw on 2018/5/18. |
| | | */ |
| | | @Java110Listener("saveWechatMenuInfoListener") |
| | | @Transactional |
| | | public class SaveWechatMenuInfoListener extends AbstractWechatMenuBusinessServiceDataFlowListener { |
| | | |
| | | private static Logger logger = LoggerFactory.getLogger(SaveWechatMenuInfoListener.class); |
| | | |
| | | @Autowired |
| | | private IWechatMenuServiceDao wechatMenuServiceDaoImpl; |
| | | |
| | | @Override |
| | | public int getOrder() { |
| | | return 0; |
| | | } |
| | | |
| | | @Override |
| | | public String getBusinessTypeCd() { |
| | | return BusinessTypeConstant.BUSINESS_TYPE_SAVE_WECHAT_MENU; |
| | | } |
| | | |
| | | /** |
| | | * 保存公众号菜单信息 business 表中 |
| | | * |
| | | * @param dataFlowContext 数据对象 |
| | | * @param business 当前业务对象 |
| | | */ |
| | | @Override |
| | | protected void doSaveBusiness(DataFlowContext dataFlowContext, Business business) { |
| | | JSONObject data = business.getDatas(); |
| | | Assert.notEmpty(data, "没有datas 节点,或没有子节点需要处理"); |
| | | |
| | | //处理 businessWechatMenu 节点 |
| | | if (data.containsKey(WechatMenuPo.class.getSimpleName())) { |
| | | Object bObj = data.get(WechatMenuPo.class.getSimpleName()); |
| | | JSONArray businessWechatMenus = null; |
| | | if (bObj instanceof JSONObject) { |
| | | businessWechatMenus = new JSONArray(); |
| | | businessWechatMenus.add(bObj); |
| | | } else { |
| | | businessWechatMenus = (JSONArray) bObj; |
| | | } |
| | | //JSONObject businessWechatMenu = data.getJSONObject(WechatMenuPo.class.getSimpleName()); |
| | | for (int bWechatMenuIndex = 0; bWechatMenuIndex < businessWechatMenus.size(); bWechatMenuIndex++) { |
| | | JSONObject businessWechatMenu = businessWechatMenus.getJSONObject(bWechatMenuIndex); |
| | | doBusinessWechatMenu(business, businessWechatMenu); |
| | | if (bObj instanceof JSONObject) { |
| | | dataFlowContext.addParamOut("wechatMenuId", businessWechatMenu.getString("wechatMenuId")); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * business 数据转移到 instance |
| | | * |
| | | * @param dataFlowContext 数据对象 |
| | | * @param business 当前业务对象 |
| | | */ |
| | | @Override |
| | | protected void doBusinessToInstance(DataFlowContext dataFlowContext, Business business) { |
| | | JSONObject data = business.getDatas(); |
| | | |
| | | Map info = new HashMap(); |
| | | info.put("bId", business.getbId()); |
| | | info.put("operate", StatusConstant.OPERATE_ADD); |
| | | |
| | | //公众号菜单信息 |
| | | List<Map> businessWechatMenuInfo = wechatMenuServiceDaoImpl.getBusinessWechatMenuInfo(info); |
| | | if (businessWechatMenuInfo != null && businessWechatMenuInfo.size() > 0) { |
| | | reFreshShareColumn(info, businessWechatMenuInfo.get(0)); |
| | | wechatMenuServiceDaoImpl.saveWechatMenuInfoInstance(info); |
| | | if (businessWechatMenuInfo.size() == 1) { |
| | | dataFlowContext.addParamOut("wechatMenuId", businessWechatMenuInfo.get(0).get("wechat_menu_id")); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 刷 分片字段 |
| | | * |
| | | * @param info 查询对象 |
| | | * @param businessInfo 小区ID |
| | | */ |
| | | private void reFreshShareColumn(Map info, Map businessInfo) { |
| | | |
| | | if (info.containsKey("communityId")) { |
| | | return; |
| | | } |
| | | |
| | | if (!businessInfo.containsKey("community_id")) { |
| | | return; |
| | | } |
| | | |
| | | info.put("communityId", businessInfo.get("community_id")); |
| | | } |
| | | |
| | | /** |
| | | * 撤单 |
| | | * |
| | | * @param dataFlowContext 数据对象 |
| | | * @param business 当前业务对象 |
| | | */ |
| | | @Override |
| | | protected void doRecover(DataFlowContext dataFlowContext, Business business) { |
| | | String bId = business.getbId(); |
| | | //Assert.hasLength(bId,"请求报文中没有包含 bId"); |
| | | Map info = new HashMap(); |
| | | info.put("bId", bId); |
| | | info.put("statusCd", StatusConstant.STATUS_CD_VALID); |
| | | Map paramIn = new HashMap(); |
| | | paramIn.put("bId", bId); |
| | | paramIn.put("statusCd", StatusConstant.STATUS_CD_INVALID); |
| | | //公众号菜单信息 |
| | | List<Map> wechatMenuInfo = wechatMenuServiceDaoImpl.getWechatMenuInfo(info); |
| | | if (wechatMenuInfo != null && wechatMenuInfo.size() > 0) { |
| | | reFreshShareColumn(paramIn, wechatMenuInfo.get(0)); |
| | | wechatMenuServiceDaoImpl.updateWechatMenuInfoInstance(paramIn); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 处理 businessWechatMenu 节点 |
| | | * |
| | | * @param business 总的数据节点 |
| | | * @param businessWechatMenu 公众号菜单节点 |
| | | */ |
| | | private void doBusinessWechatMenu(Business business, JSONObject businessWechatMenu) { |
| | | |
| | | Assert.jsonObjectHaveKey(businessWechatMenu, "wechatMenuId", "businessWechatMenu 节点下没有包含 wechatMenuId 节点"); |
| | | |
| | | if (businessWechatMenu.getString("wechatMenuId").startsWith("-")) { |
| | | //刷新缓存 |
| | | //flushWechatMenuId(business.getDatas()); |
| | | |
| | | businessWechatMenu.put("wechatMenuId", GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_wechatMenuId)); |
| | | |
| | | } |
| | | |
| | | businessWechatMenu.put("bId", business.getbId()); |
| | | businessWechatMenu.put("operate", StatusConstant.OPERATE_ADD); |
| | | //保存公众号菜单信息 |
| | | wechatMenuServiceDaoImpl.saveBusinessWechatMenuInfo(businessWechatMenu); |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public IWechatMenuServiceDao getWechatMenuServiceDaoImpl() { |
| | | return wechatMenuServiceDaoImpl; |
| | | } |
| | | |
| | | public void setWechatMenuServiceDaoImpl(IWechatMenuServiceDao wechatMenuServiceDaoImpl) { |
| | | this.wechatMenuServiceDaoImpl = wechatMenuServiceDaoImpl; |
| | | } |
| | | } |
| New file |
| | |
| | | package com.java110.store.listener.smallWeChat; |
| | | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.core.annotation.Java110Listener; |
| | | import com.java110.core.context.DataFlowContext; |
| | | import com.java110.entity.center.Business; |
| | | import com.java110.po.wechatMenu.WechatMenuPo; |
| | | import com.java110.store.dao.IWechatMenuServiceDao; |
| | | import com.java110.utils.constant.BusinessTypeConstant; |
| | | import com.java110.utils.constant.ResponseConstant; |
| | | import com.java110.utils.constant.StatusConstant; |
| | | import com.java110.utils.exception.ListenerExecuteException; |
| | | import com.java110.utils.util.Assert; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 修改公众号菜单信息 侦听 |
| | | * <p> |
| | | * 处理节点 |
| | | * 1、businessWechatMenu:{} 公众号菜单基本信息节点 |
| | | * 2、businessWechatMenuAttr:[{}] 公众号菜单属性信息节点 |
| | | * 3、businessWechatMenuPhoto:[{}] 公众号菜单照片信息节点 |
| | | * 4、businessWechatMenuCerdentials:[{}] 公众号菜单证件信息节点 |
| | | * 协议地址 :https://github.com/java110/MicroCommunity/wiki/%E4%BF%AE%E6%94%B9%E5%95%86%E6%88%B7%E4%BF%A1%E6%81%AF-%E5%8D%8F%E8%AE%AE |
| | | * Created by wuxw on 2018/5/18. |
| | | */ |
| | | @Java110Listener("updateWechatMenuInfoListener") |
| | | @Transactional |
| | | public class UpdateWechatMenuInfoListener extends AbstractWechatMenuBusinessServiceDataFlowListener { |
| | | |
| | | private static Logger logger = LoggerFactory.getLogger(UpdateWechatMenuInfoListener.class); |
| | | @Autowired |
| | | private IWechatMenuServiceDao wechatMenuServiceDaoImpl; |
| | | |
| | | @Override |
| | | public int getOrder() { |
| | | return 2; |
| | | } |
| | | |
| | | @Override |
| | | public String getBusinessTypeCd() { |
| | | return BusinessTypeConstant.BUSINESS_TYPE_UPDATE_WECHAT_MENU; |
| | | } |
| | | |
| | | /** |
| | | * business过程 |
| | | * |
| | | * @param dataFlowContext 上下文对象 |
| | | * @param business 业务对象 |
| | | */ |
| | | @Override |
| | | protected void doSaveBusiness(DataFlowContext dataFlowContext, Business business) { |
| | | |
| | | JSONObject data = business.getDatas(); |
| | | |
| | | Assert.notEmpty(data, "没有datas 节点,或没有子节点需要处理"); |
| | | |
| | | |
| | | //处理 businessWechatMenu 节点 |
| | | if (data.containsKey(WechatMenuPo.class.getSimpleName())) { |
| | | Object _obj = data.get(WechatMenuPo.class.getSimpleName()); |
| | | JSONArray businessWechatMenus = null; |
| | | if (_obj instanceof JSONObject) { |
| | | businessWechatMenus = new JSONArray(); |
| | | businessWechatMenus.add(_obj); |
| | | } else { |
| | | businessWechatMenus = (JSONArray) _obj; |
| | | } |
| | | //JSONObject businessWechatMenu = data.getJSONObject(WechatMenuPo.class.getSimpleName()); |
| | | for (int _wechatMenuIndex = 0; _wechatMenuIndex < businessWechatMenus.size(); _wechatMenuIndex++) { |
| | | JSONObject businessWechatMenu = businessWechatMenus.getJSONObject(_wechatMenuIndex); |
| | | doBusinessWechatMenu(business, businessWechatMenu); |
| | | if (_obj instanceof JSONObject) { |
| | | dataFlowContext.addParamOut("wechatMenuId", businessWechatMenu.getString("wechatMenuId")); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * business to instance 过程 |
| | | * |
| | | * @param dataFlowContext 数据对象 |
| | | * @param business 当前业务对象 |
| | | */ |
| | | @Override |
| | | protected void doBusinessToInstance(DataFlowContext dataFlowContext, Business business) { |
| | | |
| | | JSONObject data = business.getDatas(); |
| | | |
| | | Map info = new HashMap(); |
| | | info.put("bId", business.getbId()); |
| | | info.put("operate", StatusConstant.OPERATE_ADD); |
| | | |
| | | //公众号菜单信息 |
| | | List<Map> businessWechatMenuInfos = wechatMenuServiceDaoImpl.getBusinessWechatMenuInfo(info); |
| | | if (businessWechatMenuInfos != null && businessWechatMenuInfos.size() > 0) { |
| | | for (int _wechatMenuIndex = 0; _wechatMenuIndex < businessWechatMenuInfos.size(); _wechatMenuIndex++) { |
| | | Map businessWechatMenuInfo = businessWechatMenuInfos.get(_wechatMenuIndex); |
| | | flushBusinessWechatMenuInfo(businessWechatMenuInfo, StatusConstant.STATUS_CD_VALID); |
| | | wechatMenuServiceDaoImpl.updateWechatMenuInfoInstance(businessWechatMenuInfo); |
| | | if (businessWechatMenuInfo.size() == 1) { |
| | | dataFlowContext.addParamOut("wechatMenuId", businessWechatMenuInfo.get("wechat_menu_id")); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 撤单 |
| | | * |
| | | * @param dataFlowContext 数据对象 |
| | | * @param business 当前业务对象 |
| | | */ |
| | | @Override |
| | | protected void doRecover(DataFlowContext dataFlowContext, Business business) { |
| | | |
| | | String bId = business.getbId(); |
| | | //Assert.hasLength(bId,"请求报文中没有包含 bId"); |
| | | Map info = new HashMap(); |
| | | info.put("bId", bId); |
| | | info.put("statusCd", StatusConstant.STATUS_CD_VALID); |
| | | Map delInfo = new HashMap(); |
| | | delInfo.put("bId", business.getbId()); |
| | | delInfo.put("operate", StatusConstant.OPERATE_DEL); |
| | | //公众号菜单信息 |
| | | List<Map> wechatMenuInfo = wechatMenuServiceDaoImpl.getWechatMenuInfo(info); |
| | | if (wechatMenuInfo != null && wechatMenuInfo.size() > 0) { |
| | | |
| | | //公众号菜单信息 |
| | | List<Map> businessWechatMenuInfos = wechatMenuServiceDaoImpl.getBusinessWechatMenuInfo(delInfo); |
| | | //除非程序出错了,这里不会为空 |
| | | if (businessWechatMenuInfos == null || businessWechatMenuInfos.size() == 0) { |
| | | throw new ListenerExecuteException(ResponseConstant.RESULT_CODE_INNER_ERROR, "撤单失败(wechatMenu),程序内部异常,请检查! " + delInfo); |
| | | } |
| | | for (int _wechatMenuIndex = 0; _wechatMenuIndex < businessWechatMenuInfos.size(); _wechatMenuIndex++) { |
| | | Map businessWechatMenuInfo = businessWechatMenuInfos.get(_wechatMenuIndex); |
| | | flushBusinessWechatMenuInfo(businessWechatMenuInfo, StatusConstant.STATUS_CD_VALID); |
| | | wechatMenuServiceDaoImpl.updateWechatMenuInfoInstance(businessWechatMenuInfo); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 处理 businessWechatMenu 节点 |
| | | * |
| | | * @param business 总的数据节点 |
| | | * @param businessWechatMenu 公众号菜单节点 |
| | | */ |
| | | private void doBusinessWechatMenu(Business business, JSONObject businessWechatMenu) { |
| | | |
| | | Assert.jsonObjectHaveKey(businessWechatMenu, "wechatMenuId", "businessWechatMenu 节点下没有包含 wechatMenuId 节点"); |
| | | |
| | | if (businessWechatMenu.getString("wechatMenuId").startsWith("-")) { |
| | | throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR, "wechatMenuId 错误,不能自动生成(必须已经存在的wechatMenuId)" + businessWechatMenu); |
| | | } |
| | | //自动保存DEL |
| | | autoSaveDelBusinessWechatMenu(business, businessWechatMenu); |
| | | |
| | | businessWechatMenu.put("bId", business.getbId()); |
| | | businessWechatMenu.put("operate", StatusConstant.OPERATE_ADD); |
| | | //保存公众号菜单信息 |
| | | wechatMenuServiceDaoImpl.saveBusinessWechatMenuInfo(businessWechatMenu); |
| | | |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public IWechatMenuServiceDao getWechatMenuServiceDaoImpl() { |
| | | return wechatMenuServiceDaoImpl; |
| | | } |
| | | |
| | | public void setWechatMenuServiceDaoImpl(IWechatMenuServiceDao wechatMenuServiceDaoImpl) { |
| | | this.wechatMenuServiceDaoImpl = wechatMenuServiceDaoImpl; |
| | | } |
| | | |
| | | |
| | | } |
| New file |
| | |
| | | package com.java110.store.smo.impl; |
| | | |
| | | |
| | | import com.java110.store.dao.IWechatMenuServiceDao; |
| | | import com.java110.core.smo.wechatMenu.IWechatMenuInnerServiceSMO; |
| | | import com.java110.dto.wechatMenu.WechatMenuDto; |
| | | import com.java110.utils.util.BeanConvertUtil; |
| | | import com.java110.core.base.smo.BaseServiceSMO; |
| | | import com.java110.dto.user.UserDto; |
| | | import com.java110.core.smo.user.IUserInnerServiceSMO; |
| | | import com.java110.dto.PageDto; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @ClassName FloorInnerServiceSMOImpl |
| | | * @Description 公众号菜单内部服务实现类 |
| | | * @Author wuxw |
| | | * @Date 2019/4/24 9:20 |
| | | * @Version 1.0 |
| | | * add by wuxw 2019/4/24 |
| | | **/ |
| | | @RestController |
| | | public class WechatMenuInnerServiceSMOImpl extends BaseServiceSMO implements IWechatMenuInnerServiceSMO { |
| | | |
| | | @Autowired |
| | | private IWechatMenuServiceDao wechatMenuServiceDaoImpl; |
| | | |
| | | @Autowired |
| | | private IUserInnerServiceSMO userInnerServiceSMOImpl; |
| | | |
| | | @Override |
| | | public List<WechatMenuDto> queryWechatMenus(@RequestBody WechatMenuDto wechatMenuDto) { |
| | | |
| | | //校验是否传了 分页信息 |
| | | |
| | | int page = wechatMenuDto.getPage(); |
| | | |
| | | if (page != PageDto.DEFAULT_PAGE) { |
| | | wechatMenuDto.setPage((page - 1) * wechatMenuDto.getRow()); |
| | | } |
| | | |
| | | List<WechatMenuDto> wechatMenus = BeanConvertUtil.covertBeanList(wechatMenuServiceDaoImpl.getWechatMenuInfo(BeanConvertUtil.beanCovertMap(wechatMenuDto)), WechatMenuDto.class); |
| | | |
| | | if (wechatMenus == null || wechatMenus.size() == 0) { |
| | | return wechatMenus; |
| | | } |
| | | |
| | | String[] userIds = getUserIds(wechatMenus); |
| | | //根据 userId 查询用户信息 |
| | | List<UserDto> users = userInnerServiceSMOImpl.getUserInfo(userIds); |
| | | |
| | | for (WechatMenuDto wechatMenu : wechatMenus) { |
| | | refreshWechatMenu(wechatMenu, users); |
| | | } |
| | | return wechatMenus; |
| | | } |
| | | |
| | | /** |
| | | * 从用户列表中查询用户,将用户中的信息 刷新到 floor对象中 |
| | | * |
| | | * @param wechatMenu 小区公众号菜单信息 |
| | | * @param users 用户列表 |
| | | */ |
| | | private void refreshWechatMenu(WechatMenuDto wechatMenu, List<UserDto> users) { |
| | | for (UserDto user : users) { |
| | | if (wechatMenu.getWechatMenuId().equals(user.getUserId())) { |
| | | BeanConvertUtil.covertBean(user, wechatMenu); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取批量userId |
| | | * |
| | | * @param wechatMenus 小区楼信息 |
| | | * @return 批量userIds 信息 |
| | | */ |
| | | private String[] getUserIds(List<WechatMenuDto> wechatMenus) { |
| | | List<String> userIds = new ArrayList<String>(); |
| | | for (WechatMenuDto wechatMenu : wechatMenus) { |
| | | userIds.add(wechatMenu.getWechatMenuId()); |
| | | } |
| | | |
| | | return userIds.toArray(new String[userIds.size()]); |
| | | } |
| | | |
| | | @Override |
| | | public int queryWechatMenusCount(@RequestBody WechatMenuDto wechatMenuDto) { |
| | | return wechatMenuServiceDaoImpl.queryWechatMenusCount(BeanConvertUtil.beanCovertMap(wechatMenuDto)); } |
| | | |
| | | public IWechatMenuServiceDao getWechatMenuServiceDaoImpl() { |
| | | return wechatMenuServiceDaoImpl; |
| | | } |
| | | |
| | | public void setWechatMenuServiceDaoImpl(IWechatMenuServiceDao wechatMenuServiceDaoImpl) { |
| | | this.wechatMenuServiceDaoImpl = wechatMenuServiceDaoImpl; |
| | | } |
| | | |
| | | public IUserInnerServiceSMO getUserInnerServiceSMOImpl() { |
| | | return userInnerServiceSMOImpl; |
| | | } |
| | | |
| | | public void setUserInnerServiceSMOImpl(IUserInnerServiceSMO userInnerServiceSMOImpl) { |
| | | this.userInnerServiceSMOImpl = userInnerServiceSMOImpl; |
| | | } |
| | | } |