| New file |
| | |
| | | package com.java110.user.listener.userAttr; |
| | | |
| | | 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.user.dao.IUserAttrServiceDao; |
| | | 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、businessUserAttr:{} 用户属性基本信息节点 |
| | | * 2、businessUserAttrAttr:[{}] 用户属性属性信息节点 |
| | | * 3、businessUserAttrPhoto:[{}] 用户属性照片信息节点 |
| | | * 4、businessUserAttrCerdentials:[{}] 用户属性证件信息节点 |
| | | * 协议地址 :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("deleteUserAttrInfoListener") |
| | | @Transactional |
| | | public class DeleteUserAttrInfoListener extends AbstractUserAttrBusinessServiceDataFlowListener { |
| | | |
| | | private final static Logger logger = LoggerFactory.getLogger(DeleteUserAttrInfoListener.class); |
| | | @Autowired |
| | | IUserAttrServiceDao userAttrServiceDaoImpl; |
| | | |
| | | @Override |
| | | public int getOrder() { |
| | | return 3; |
| | | } |
| | | |
| | | @Override |
| | | public String getBusinessTypeCd() { |
| | | return BusinessTypeConstant.BUSINESS_TYPE_DELETE_USER_ATTR_INFO; |
| | | } |
| | | |
| | | /** |
| | | * 根据删除信息 查出Instance表中数据 保存至business表 (状态写DEL) 方便撤单时直接更新回去 |
| | | * @param dataFlowContext 数据对象 |
| | | * @param business 当前业务对象 |
| | | */ |
| | | @Override |
| | | protected void doSaveBusiness(DataFlowContext dataFlowContext, Business business) { |
| | | JSONObject data = business.getDatas(); |
| | | |
| | | Assert.notEmpty(data,"没有datas 节点,或没有子节点需要处理"); |
| | | |
| | | //处理 businessUserAttr 节点 |
| | | if(data.containsKey(UserAttrPo.class.getSimpleName())){ |
| | | Object _obj = data.get(UserAttrPo.class.getSimpleName()); |
| | | JSONArray businessUserAttrs = null; |
| | | if(_obj instanceof JSONObject){ |
| | | businessUserAttrs = new JSONArray(); |
| | | businessUserAttrs.add(_obj); |
| | | }else { |
| | | businessUserAttrs = (JSONArray)_obj; |
| | | } |
| | | //JSONObject businessUserAttr = data.getJSONObject(UserAttrPo.class.getSimpleName()); |
| | | for (int _userAttrIndex = 0; _userAttrIndex < businessUserAttrs.size();_userAttrIndex++) { |
| | | JSONObject businessUserAttr = businessUserAttrs.getJSONObject(_userAttrIndex); |
| | | doBusinessUserAttr(business, businessUserAttr); |
| | | if(_obj instanceof JSONObject) { |
| | | dataFlowContext.addParamOut("attrId", businessUserAttr.getString("attrId")); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 删除 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> businessUserAttrInfos = userAttrServiceDaoImpl.getBusinessUserAttrInfo(info); |
| | | if( businessUserAttrInfos != null && businessUserAttrInfos.size() >0) { |
| | | for (int _userAttrIndex = 0; _userAttrIndex < businessUserAttrInfos.size();_userAttrIndex++) { |
| | | Map businessUserAttrInfo = businessUserAttrInfos.get(_userAttrIndex); |
| | | flushBusinessUserAttrInfo(businessUserAttrInfo,StatusConstant.STATUS_CD_INVALID); |
| | | userAttrServiceDaoImpl.updateUserAttrInfoInstance(businessUserAttrInfo); |
| | | dataFlowContext.addParamOut("attrId",businessUserAttrInfo.get("attr_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> userAttrInfo = userAttrServiceDaoImpl.getUserAttrInfo(info); |
| | | if(userAttrInfo != null && userAttrInfo.size() > 0){ |
| | | |
| | | //用户属性信息 |
| | | List<Map> businessUserAttrInfos = userAttrServiceDaoImpl.getBusinessUserAttrInfo(delInfo); |
| | | //除非程序出错了,这里不会为空 |
| | | if(businessUserAttrInfos == null || businessUserAttrInfos.size() == 0){ |
| | | throw new ListenerExecuteException(ResponseConstant.RESULT_CODE_INNER_ERROR,"撤单失败(userAttr),程序内部异常,请检查! "+delInfo); |
| | | } |
| | | for (int _userAttrIndex = 0; _userAttrIndex < businessUserAttrInfos.size();_userAttrIndex++) { |
| | | Map businessUserAttrInfo = businessUserAttrInfos.get(_userAttrIndex); |
| | | flushBusinessUserAttrInfo(businessUserAttrInfo,StatusConstant.STATUS_CD_VALID); |
| | | userAttrServiceDaoImpl.updateUserAttrInfoInstance(businessUserAttrInfo); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 处理 businessUserAttr 节点 |
| | | * @param business 总的数据节点 |
| | | * @param businessUserAttr 用户属性节点 |
| | | */ |
| | | private void doBusinessUserAttr(Business business,JSONObject businessUserAttr){ |
| | | |
| | | Assert.jsonObjectHaveKey(businessUserAttr,"attrId","businessUserAttr 节点下没有包含 attrId 节点"); |
| | | |
| | | if(businessUserAttr.getString("attrId").startsWith("-")){ |
| | | throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"attrId 错误,不能自动生成(必须已经存在的attrId)"+businessUserAttr); |
| | | } |
| | | //自动插入DEL |
| | | autoSaveDelBusinessUserAttr(business,businessUserAttr); |
| | | } |
| | | @Override |
| | | public IUserAttrServiceDao getUserAttrServiceDaoImpl() { |
| | | return userAttrServiceDaoImpl; |
| | | } |
| | | |
| | | public void setUserAttrServiceDaoImpl(IUserAttrServiceDao userAttrServiceDaoImpl) { |
| | | this.userAttrServiceDaoImpl = userAttrServiceDaoImpl; |
| | | } |
| | | } |
| New file |
| | |
| | | package com.java110.user.listener.userAttr; |
| | | |
| | | 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.user.dao.IUserAttrServiceDao; |
| | | 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("saveUserAttrInfoListener") |
| | | @Transactional |
| | | public class SaveUserAttrInfoListener extends AbstractUserAttrBusinessServiceDataFlowListener{ |
| | | |
| | | private static Logger logger = LoggerFactory.getLogger(SaveUserAttrInfoListener.class); |
| | | |
| | | @Autowired |
| | | private IUserAttrServiceDao userAttrServiceDaoImpl; |
| | | |
| | | @Override |
| | | public int getOrder() { |
| | | return 0; |
| | | } |
| | | |
| | | @Override |
| | | public String getBusinessTypeCd() { |
| | | return BusinessTypeConstant.BUSINESS_TYPE_SAVE_USER_ATTR_INFO; |
| | | } |
| | | |
| | | /** |
| | | * 保存用户属性信息 business 表中 |
| | | * @param dataFlowContext 数据对象 |
| | | * @param business 当前业务对象 |
| | | */ |
| | | @Override |
| | | protected void doSaveBusiness(DataFlowContext dataFlowContext, Business business) { |
| | | JSONObject data = business.getDatas(); |
| | | Assert.notEmpty(data,"没有datas 节点,或没有子节点需要处理"); |
| | | |
| | | //处理 businessUserAttr 节点 |
| | | if(data.containsKey(UserAttrPo.class.getSimpleName())){ |
| | | Object bObj = data.get(UserAttrPo.class.getSimpleName()); |
| | | JSONArray businessUserAttrs = null; |
| | | if(bObj instanceof JSONObject){ |
| | | businessUserAttrs = new JSONArray(); |
| | | businessUserAttrs.add(bObj); |
| | | }else { |
| | | businessUserAttrs = (JSONArray)bObj; |
| | | } |
| | | //JSONObject businessUserAttr = data.getJSONObject(UserAttrPo.class.getSimpleName()); |
| | | for (int bUserAttrIndex = 0; bUserAttrIndex < businessUserAttrs.size();bUserAttrIndex++) { |
| | | JSONObject businessUserAttr = businessUserAttrs.getJSONObject(bUserAttrIndex); |
| | | doBusinessUserAttr(business, businessUserAttr); |
| | | if(bObj instanceof JSONObject) { |
| | | dataFlowContext.addParamOut("attrId", businessUserAttr.getString("attrId")); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 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> businessUserAttrInfo = userAttrServiceDaoImpl.getBusinessUserAttrInfo(info); |
| | | if( businessUserAttrInfo != null && businessUserAttrInfo.size() >0) { |
| | | reFreshShareColumn(info, businessUserAttrInfo.get(0)); |
| | | userAttrServiceDaoImpl.saveUserAttrInfoInstance(info); |
| | | if(businessUserAttrInfo.size() == 1) { |
| | | dataFlowContext.addParamOut("attrId", businessUserAttrInfo.get(0).get("attr_id")); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 刷 分片字段 |
| | | * |
| | | * @param info 查询对象 |
| | | * @param businessInfo 小区ID |
| | | */ |
| | | private void reFreshShareColumn(Map info, Map businessInfo) { |
| | | |
| | | if (info.containsKey("userId")) { |
| | | return; |
| | | } |
| | | |
| | | if (!businessInfo.containsKey("user_id")) { |
| | | return; |
| | | } |
| | | |
| | | info.put("userId", businessInfo.get("user_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> userAttrInfo = userAttrServiceDaoImpl.getUserAttrInfo(info); |
| | | if(userAttrInfo != null && userAttrInfo.size() > 0){ |
| | | reFreshShareColumn(paramIn, userAttrInfo.get(0)); |
| | | userAttrServiceDaoImpl.updateUserAttrInfoInstance(paramIn); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 处理 businessUserAttr 节点 |
| | | * @param business 总的数据节点 |
| | | * @param businessUserAttr 用户属性节点 |
| | | */ |
| | | private void doBusinessUserAttr(Business business,JSONObject businessUserAttr){ |
| | | |
| | | Assert.jsonObjectHaveKey(businessUserAttr,"attrId","businessUserAttr 节点下没有包含 attrId 节点"); |
| | | |
| | | if(businessUserAttr.getString("attrId").startsWith("-")){ |
| | | //刷新缓存 |
| | | //flushUserAttrId(business.getDatas()); |
| | | |
| | | businessUserAttr.put("attrId",GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_attrId)); |
| | | |
| | | } |
| | | |
| | | businessUserAttr.put("bId",business.getbId()); |
| | | businessUserAttr.put("operate", StatusConstant.OPERATE_ADD); |
| | | //保存用户属性信息 |
| | | userAttrServiceDaoImpl.saveBusinessUserAttrInfo(businessUserAttr); |
| | | |
| | | } |
| | | @Override |
| | | public IUserAttrServiceDao getUserAttrServiceDaoImpl() { |
| | | return userAttrServiceDaoImpl; |
| | | } |
| | | |
| | | public void setUserAttrServiceDaoImpl(IUserAttrServiceDao userAttrServiceDaoImpl) { |
| | | this.userAttrServiceDaoImpl = userAttrServiceDaoImpl; |
| | | } |
| | | } |
| New file |
| | |
| | | package com.java110.user.listener.userAttr; |
| | | |
| | | 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.user.dao.IUserAttrServiceDao; |
| | | 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、businessUserAttr:{} 用户属性基本信息节点 |
| | | * 2、businessUserAttrAttr:[{}] 用户属性属性信息节点 |
| | | * 3、businessUserAttrPhoto:[{}] 用户属性照片信息节点 |
| | | * 4、businessUserAttrCerdentials:[{}] 用户属性证件信息节点 |
| | | * 协议地址 :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("updateUserAttrInfoListener") |
| | | @Transactional |
| | | public class UpdateUserAttrInfoListener extends AbstractUserAttrBusinessServiceDataFlowListener { |
| | | |
| | | private static Logger logger = LoggerFactory.getLogger(UpdateUserAttrInfoListener.class); |
| | | @Autowired |
| | | private IUserAttrServiceDao userAttrServiceDaoImpl; |
| | | |
| | | @Override |
| | | public int getOrder() { |
| | | return 2; |
| | | } |
| | | |
| | | @Override |
| | | public String getBusinessTypeCd() { |
| | | return BusinessTypeConstant.BUSINESS_TYPE_UPDATE_USER_ATTR_INFO; |
| | | } |
| | | |
| | | /** |
| | | * business过程 |
| | | * @param dataFlowContext 上下文对象 |
| | | * @param business 业务对象 |
| | | */ |
| | | @Override |
| | | protected void doSaveBusiness(DataFlowContext dataFlowContext, Business business) { |
| | | |
| | | JSONObject data = business.getDatas(); |
| | | |
| | | Assert.notEmpty(data,"没有datas 节点,或没有子节点需要处理"); |
| | | |
| | | |
| | | //处理 businessUserAttr 节点 |
| | | if(data.containsKey(UserAttrPo.class.getSimpleName())){ |
| | | Object _obj = data.get(UserAttrPo.class.getSimpleName()); |
| | | JSONArray businessUserAttrs = null; |
| | | if(_obj instanceof JSONObject){ |
| | | businessUserAttrs = new JSONArray(); |
| | | businessUserAttrs.add(_obj); |
| | | }else { |
| | | businessUserAttrs = (JSONArray)_obj; |
| | | } |
| | | //JSONObject businessUserAttr = data.getJSONObject(UserAttrPo.class.getSimpleName()); |
| | | for (int _userAttrIndex = 0; _userAttrIndex < businessUserAttrs.size();_userAttrIndex++) { |
| | | JSONObject businessUserAttr = businessUserAttrs.getJSONObject(_userAttrIndex); |
| | | doBusinessUserAttr(business, businessUserAttr); |
| | | if(_obj instanceof JSONObject) { |
| | | dataFlowContext.addParamOut("attrId", businessUserAttr.getString("attrId")); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 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> businessUserAttrInfos = userAttrServiceDaoImpl.getBusinessUserAttrInfo(info); |
| | | if( businessUserAttrInfos != null && businessUserAttrInfos.size() >0) { |
| | | for (int _userAttrIndex = 0; _userAttrIndex < businessUserAttrInfos.size();_userAttrIndex++) { |
| | | Map businessUserAttrInfo = businessUserAttrInfos.get(_userAttrIndex); |
| | | flushBusinessUserAttrInfo(businessUserAttrInfo,StatusConstant.STATUS_CD_VALID); |
| | | userAttrServiceDaoImpl.updateUserAttrInfoInstance(businessUserAttrInfo); |
| | | if(businessUserAttrInfo.size() == 1) { |
| | | dataFlowContext.addParamOut("attrId", businessUserAttrInfo.get("attr_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> userAttrInfo = userAttrServiceDaoImpl.getUserAttrInfo(info); |
| | | if(userAttrInfo != null && userAttrInfo.size() > 0){ |
| | | |
| | | //用户属性信息 |
| | | List<Map> businessUserAttrInfos = userAttrServiceDaoImpl.getBusinessUserAttrInfo(delInfo); |
| | | //除非程序出错了,这里不会为空 |
| | | if(businessUserAttrInfos == null || businessUserAttrInfos.size() == 0){ |
| | | throw new ListenerExecuteException(ResponseConstant.RESULT_CODE_INNER_ERROR,"撤单失败(userAttr),程序内部异常,请检查! "+delInfo); |
| | | } |
| | | for (int _userAttrIndex = 0; _userAttrIndex < businessUserAttrInfos.size();_userAttrIndex++) { |
| | | Map businessUserAttrInfo = businessUserAttrInfos.get(_userAttrIndex); |
| | | flushBusinessUserAttrInfo(businessUserAttrInfo,StatusConstant.STATUS_CD_VALID); |
| | | userAttrServiceDaoImpl.updateUserAttrInfoInstance(businessUserAttrInfo); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 处理 businessUserAttr 节点 |
| | | * @param business 总的数据节点 |
| | | * @param businessUserAttr 用户属性节点 |
| | | */ |
| | | private void doBusinessUserAttr(Business business,JSONObject businessUserAttr){ |
| | | |
| | | Assert.jsonObjectHaveKey(businessUserAttr,"attrId","businessUserAttr 节点下没有包含 attrId 节点"); |
| | | |
| | | if(businessUserAttr.getString("attrId").startsWith("-")){ |
| | | throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"attrId 错误,不能自动生成(必须已经存在的attrId)"+businessUserAttr); |
| | | } |
| | | //自动保存DEL |
| | | autoSaveDelBusinessUserAttr(business,businessUserAttr); |
| | | |
| | | businessUserAttr.put("bId",business.getbId()); |
| | | businessUserAttr.put("operate", StatusConstant.OPERATE_ADD); |
| | | //保存用户属性信息 |
| | | userAttrServiceDaoImpl.saveBusinessUserAttrInfo(businessUserAttr); |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public IUserAttrServiceDao getUserAttrServiceDaoImpl() { |
| | | return userAttrServiceDaoImpl; |
| | | } |
| | | |
| | | public void setUserAttrServiceDaoImpl(IUserAttrServiceDao userAttrServiceDaoImpl) { |
| | | this.userAttrServiceDaoImpl = userAttrServiceDaoImpl; |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | |
| | | package com.java110.dto.user; |
| | | |
| | | import com.java110.dto.PageDto; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | public class UserAttrDto implements Serializable { |
| | | public class UserAttrDto extends PageDto implements Serializable { |
| | | private String attrId; |
| | | private String userId; |
| | | private String specCd; |
| New file |
| | |
| | | package com.java110.po.userAttr; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | public class UserAttrPo implements Serializable { |
| | | |
| | | private String attrId; |
| | | private String specCd; |
| | | private String userId; |
| | | private String value; |
| | | |
| | | public String getAttrId() { |
| | | return attrId; |
| | | } |
| | | |
| | | public void setAttrId(String attrId) { |
| | | this.attrId = attrId; |
| | | } |
| | | |
| | | public String getSpecCd() { |
| | | return specCd; |
| | | } |
| | | |
| | | public void setSpecCd(String specCd) { |
| | | this.specCd = specCd; |
| | | } |
| | | |
| | | public String getUserId() { |
| | | return userId; |
| | | } |
| | | |
| | | public void setUserId(String userId) { |
| | | this.userId = userId; |
| | | } |
| | | |
| | | public String getValue() { |
| | | return value; |
| | | } |
| | | |
| | | public void setValue(String value) { |
| | | this.value = value; |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | private String createTime; |
| | | private String appId; |
| | | private String name; |
| | | //private String appSecret; |
| | | private String appSecret; |
| | | private String statusCd; |
| | | private String weChatId; |
| | | private String bId; |
| | | private String storeId; |
| | | //private String payPassword; |
| | | private String payPassword; |
| | | private String remarks; |
| | | private String objId; |
| | | private String objType; |
| | |
| | | public void setObjTypeName(String objTypeName) { |
| | | this.objTypeName = objTypeName; |
| | | } |
| | | |
| | | public String getAppSecret() { |
| | | return appSecret; |
| | | } |
| | | |
| | | public void setAppSecret(String appSecret) { |
| | | this.appSecret = appSecret; |
| | | } |
| | | |
| | | public String getPayPassword() { |
| | | return payPassword; |
| | | } |
| | | |
| | | public void setPayPassword(String payPassword) { |
| | | this.payPassword = payPassword; |
| | | } |
| | | } |
| | |
| | | package com.java110.core.smo.user; |
| | | |
| | | import com.java110.core.feign.FeignConfiguration; |
| | | import com.java110.dto.user.UserAttrDto; |
| | | import com.java110.dto.user.UserDto; |
| | | import org.springframework.cloud.openfeign.FeignClient; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | |
| | | |
| | | @RequestMapping(value = "/getUserHasPwd", method = RequestMethod.POST) |
| | | List<UserDto> getUserHasPwd(@RequestBody UserDto userDto); |
| | | |
| | | /** |
| | | * 查询用户属性 |
| | | * |
| | | * @param userAttrDto 用户ID |
| | | * 支持 多个查询 |
| | | * @return 用户封装信息 |
| | | */ |
| | | @RequestMapping(value = "/getUserAttrs", method = RequestMethod.POST) |
| | | List<UserAttrDto> getUserAttrs(@RequestBody UserAttrDto userAttrDto); |
| | | } |
| New file |
| | |
| | | package com.java110.core.smo.userAttr; |
| | | |
| | | import com.java110.core.feign.FeignConfiguration; |
| | | import com.java110.dto.user.UserAttrDto; |
| | | 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 IUserAttrInnerServiceSMO |
| | | * @Description 用户属性接口类 |
| | | * @Author wuxw |
| | | * @Date 2019/4/24 9:04 |
| | | * @Version 1.0 |
| | | * add by wuxw 2019/4/24 |
| | | **/ |
| | | @FeignClient(name = "user-service", configuration = {FeignConfiguration.class}) |
| | | @RequestMapping("/userAttrApi") |
| | | public interface IUserAttrInnerServiceSMO { |
| | | |
| | | /** |
| | | * <p>查询小区楼信息</p> |
| | | * |
| | | * @param userAttrDto 数据对象分享 |
| | | * @return UserAttrDto 对象数据 |
| | | */ |
| | | @RequestMapping(value = "/queryUserAttrs", method = RequestMethod.POST) |
| | | List<UserAttrDto> queryUserAttrs(@RequestBody UserAttrDto userAttrDto); |
| | | |
| | | /** |
| | | * 查询<p>小区楼</p>总记录数 |
| | | * |
| | | * @param userAttrDto 数据对象分享 |
| | | * @return 小区下的小区楼记录数 |
| | | */ |
| | | @RequestMapping(value = "/queryUserAttrsCount", method = RequestMethod.POST) |
| | | int queryUserAttrsCount(@RequestBody UserAttrDto userAttrDto); |
| | | } |
| 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="userAttrServiceDaoImpl"> |
| | | |
| | | <!-- 保存用户属性信息 add by wuxw 2018-07-03 --> |
| | | <insert id="saveBusinessUserAttrInfo" parameterType="Map"> |
| | | insert into business_user_attr( |
| | | attr_id,operate,spec_cd,b_id,user_id,value |
| | | ) values ( |
| | | #{attrId},#{operate},#{specCd},#{bId},#{userId},#{value} |
| | | ) |
| | | </insert> |
| | | |
| | | |
| | | <!-- 查询用户属性信息(Business) add by wuxw 2018-07-03 --> |
| | | <select id="getBusinessUserAttrInfo" parameterType="Map" resultType="Map"> |
| | | select t.attr_id,t.attr_id attrId,t.operate,t.spec_cd,t.spec_cd specCd,t.b_id,t.b_id bId,t.user_id,t.user_id userId,t.value |
| | | from business_user_attr t |
| | | where 1 =1 |
| | | <if test="attrId !=null and attrId != ''"> |
| | | and t.attr_id= #{attrId} |
| | | </if> |
| | | <if test="operate !=null and operate != ''"> |
| | | and t.operate= #{operate} |
| | | </if> |
| | | <if test="specCd !=null and specCd != ''"> |
| | | and t.spec_cd= #{specCd} |
| | | </if> |
| | | <if test="bId !=null and bId != ''"> |
| | | and t.b_id= #{bId} |
| | | </if> |
| | | <if test="userId !=null and userId != ''"> |
| | | and t.user_id= #{userId} |
| | | </if> |
| | | <if test="value !=null and value != ''"> |
| | | and t.value= #{value} |
| | | </if> |
| | | |
| | | </select> |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | <!-- 保存用户属性信息至 instance表中 add by wuxw 2018-07-03 --> |
| | | <insert id="saveUserAttrInfoInstance" parameterType="Map"> |
| | | insert into u_user_attr( |
| | | attr_id,spec_cd,status_cd,b_id,user_id,value |
| | | ) select t.attr_id,t.spec_cd,'0',t.b_id,t.user_id,t.value from business_user_attr t where 1=1 |
| | | <if test="attrId !=null and attrId != ''"> |
| | | and t.attr_id= #{attrId} |
| | | </if> |
| | | and t.operate= 'ADD' |
| | | <if test="specCd !=null and specCd != ''"> |
| | | and t.spec_cd= #{specCd} |
| | | </if> |
| | | <if test="bId !=null and bId != ''"> |
| | | and t.b_id= #{bId} |
| | | </if> |
| | | <if test="userId !=null and userId != ''"> |
| | | and t.user_id= #{userId} |
| | | </if> |
| | | <if test="value !=null and value != ''"> |
| | | and t.value= #{value} |
| | | </if> |
| | | |
| | | </insert> |
| | | |
| | | |
| | | |
| | | <!-- 查询用户属性信息 add by wuxw 2018-07-03 --> |
| | | <select id="getUserAttrInfo" parameterType="Map" resultType="Map"> |
| | | select t.attr_id,t.attr_id attrId,t.spec_cd,t.spec_cd specCd,t.status_cd,t.status_cd statusCd,t.b_id,t.b_id bId,t.user_id,t.user_id userId,t.value |
| | | from u_user_attr t |
| | | where 1 =1 |
| | | <if test="attrId !=null and attrId != ''"> |
| | | and t.attr_id= #{attrId} |
| | | </if> |
| | | <if test="specCd !=null and specCd != ''"> |
| | | and t.spec_cd= #{specCd} |
| | | </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="userId !=null and userId != ''"> |
| | | and t.user_id= #{userId} |
| | | </if> |
| | | <if test="value !=null and value != ''"> |
| | | and t.value= #{value} |
| | | </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="updateUserAttrInfoInstance" parameterType="Map"> |
| | | update u_user_attr t set t.status_cd = #{statusCd} |
| | | <if test="newBId != null and newBId != ''"> |
| | | ,t.b_id = #{newBId} |
| | | </if> |
| | | <if test="specCd !=null and specCd != ''"> |
| | | , t.spec_cd= #{specCd} |
| | | </if> |
| | | <if test="userId !=null and userId != ''"> |
| | | , t.user_id= #{userId} |
| | | </if> |
| | | <if test="value !=null and value != ''"> |
| | | , t.value= #{value} |
| | | </if> |
| | | where 1=1 <if test="attrId !=null and attrId != ''"> |
| | | and t.attr_id= #{attrId} |
| | | </if> |
| | | <if test="bId !=null and bId != ''"> |
| | | and t.b_id= #{bId} |
| | | </if> |
| | | |
| | | </update> |
| | | |
| | | <!-- 查询用户属性数量 add by wuxw 2018-07-03 --> |
| | | <select id="queryUserAttrsCount" parameterType="Map" resultType="Map"> |
| | | select count(1) count |
| | | from u_user_attr t |
| | | where 1 =1 |
| | | <if test="attrId !=null and attrId != ''"> |
| | | and t.attr_id= #{attrId} |
| | | </if> |
| | | <if test="specCd !=null and specCd != ''"> |
| | | and t.spec_cd= #{specCd} |
| | | </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="userId !=null and userId != ''"> |
| | | and t.user_id= #{userId} |
| | | </if> |
| | | <if test="value !=null and value != ''"> |
| | | and t.value= #{value} |
| | | </if> |
| | | |
| | | |
| | | </select> |
| | | |
| | | </mapper> |
| | |
| | | <if test="attrId != null and attrId != ''"> |
| | | and u.attr_id = #{attrId} |
| | | </if> |
| | | <if test="specCd != null and specCd != ''"> |
| | | and u.spec_cd = #{specCd} |
| | | </if> |
| | | </select> |
| | | |
| | | |
| | |
| | | { |
| | | "autoMove": false, |
| | | "id": "locationId", |
| | | "name": "communityLocation", |
| | | "desc": "小区位置", |
| | | "shareParam": "communityId", |
| | | "shareColumn": "community_id", |
| | | "shareName": "community", |
| | | "newBusinessTypeCd": "BUSINESS_TYPE_SAVE_LOCATION", |
| | | "updateBusinessTypeCd": "BUSINESS_TYPE_UPDATE_LOCATION", |
| | | "deleteBusinessTypeCd": "BUSINESS_TYPE_DELETE_LOCATION", |
| | | "newBusinessTypeCdValue": "570100030001", |
| | | "updateBusinessTypeCdValue": "570100040001", |
| | | "deleteBusinessTypeCdValue": "570100050001", |
| | | "businessTableName": "business_community_location", |
| | | "tableName": "community_location", |
| | | "autoMove": true, |
| | | "id": "attrId", |
| | | "name": "userAttr", |
| | | "desc": "用户属性", |
| | | "shareParam": "userId", |
| | | "shareColumn": "user_id", |
| | | "shareName": "user", |
| | | "newBusinessTypeCd": "BUSINESS_TYPE_SAVE_USER_ATTR_INFO", |
| | | "updateBusinessTypeCd": "BUSINESS_TYPE_UPDATE_USER_ATTR_INFO", |
| | | "deleteBusinessTypeCd": "BUSINESS_TYPE_DELETE_USER_ATTR_INFO", |
| | | "newBusinessTypeCdValue": "100200030001", |
| | | "updateBusinessTypeCdValue": "100200040001", |
| | | "deleteBusinessTypeCdValue": "100200050001", |
| | | "businessTableName": "business_user_attr", |
| | | "tableName": "u_user_attr", |
| | | "param": { |
| | | "locationId": "location_id", |
| | | "attrId": "attr_id", |
| | | "bId": "b_id", |
| | | "locationName": "location_name", |
| | | "locationType": "location_type", |
| | | "communityId": "community_id", |
| | | "userId": "user_id", |
| | | "specCd": "spec_cd", |
| | | "value": "value", |
| | | "statusCd": "status_cd", |
| | | "operate": "operate" |
| | | }, |
| | | "required": [ |
| | | { |
| | | "code": "locationName", |
| | | "msg": "位置名称不能为空" |
| | | "code": "userId", |
| | | "msg": "用户ID不能为空" |
| | | }, |
| | | { |
| | | "code": "locationType", |
| | | "msg": "位置类型不能为空" |
| | | "code": "specCd", |
| | | "msg": "用户属性不能为空" |
| | | } |
| | | ] |
| | | } |
| New file |
| | |
| | | { |
| | | "autoMove": false, |
| | | "id": "locationId", |
| | | "name": "communityLocation", |
| | | "desc": "小区位置", |
| | | "shareParam": "communityId", |
| | | "shareColumn": "community_id", |
| | | "shareName": "community", |
| | | "newBusinessTypeCd": "BUSINESS_TYPE_SAVE_LOCATION", |
| | | "updateBusinessTypeCd": "BUSINESS_TYPE_UPDATE_LOCATION", |
| | | "deleteBusinessTypeCd": "BUSINESS_TYPE_DELETE_LOCATION", |
| | | "newBusinessTypeCdValue": "570100030001", |
| | | "updateBusinessTypeCdValue": "570100040001", |
| | | "deleteBusinessTypeCdValue": "570100050001", |
| | | "businessTableName": "business_community_location", |
| | | "tableName": "community_location", |
| | | "param": { |
| | | "locationId": "location_id", |
| | | "bId": "b_id", |
| | | "locationName": "location_name", |
| | | "locationType": "location_type", |
| | | "communityId": "community_id", |
| | | "statusCd": "status_cd", |
| | | "operate": "operate" |
| | | }, |
| | | "required": [ |
| | | { |
| | | "code": "locationName", |
| | | "msg": "位置名称不能为空" |
| | | }, |
| | | { |
| | | "code": "locationType", |
| | | "msg": "位置类型不能为空" |
| | | } |
| | | ] |
| | | } |
| | | |
| | |
| | | public static final String BUSINESS_TYPE_RECOVER_USER_INFO = "100100040003"; |
| | | |
| | | /** |
| | | * 保存用户属性信息 |
| | | */ |
| | | public final static String BUSINESS_TYPE_SAVE_USER_ATTR_INFO = "100200030001"; |
| | | |
| | | /** |
| | | * 修改用户属性信息 |
| | | */ |
| | | public final static String BUSINESS_TYPE_UPDATE_USER_ATTR_INFO = "100200040001"; |
| | | |
| | | /** |
| | | * 删除用户属性信息 |
| | | */ |
| | | public final static String BUSINESS_TYPE_DELETE_USER_ATTR_INFO = "100200050001"; |
| | | |
| | | /** |
| | | * 增加业主 |
| | | */ |
| | | public static final String BUSINESS_TYPE_SAVE_OWNER_INFO = "110100030001"; |
| | |
| | | public static final String SERVICE_CODE_QUERY_PARKING_SPACE_CAR = "parkingSpace.queryParkingSpaceCars"; |
| | | |
| | | |
| | | /** |
| | | * 保存或修改用户属性 |
| | | */ |
| | | public static final String SERVICE_CODE_SAVE_UPDATE_USER_ATTR = "user.saveOrUpdateUserAttr"; |
| | | |
| | | } |
| New file |
| | |
| | | package com.java110.utils.constant; |
| | | |
| | | /** |
| | | * 用户属性常量类 |
| | | * Created by wuxw on 2017/5/20. |
| | | */ |
| | | public class ServiceCodeUserAttrConstant { |
| | | |
| | | /** |
| | | * 添加 用户属性 |
| | | */ |
| | | public static final String ADD_USERATTR = "userAttr.saveUserAttr"; |
| | | |
| | | |
| | | /** |
| | | * 修改 用户属性 |
| | | */ |
| | | public static final String UPDATE_USERATTR = "userAttr.updateUserAttr"; |
| | | /** |
| | | * 删除 用户属性 |
| | | */ |
| | | public static final String DELETE_USERATTR = "userAttr.deleteUserAttr"; |
| | | |
| | | |
| | | /** |
| | | * 查询 用户属性 |
| | | */ |
| | | public static final String LIST_USERATTRS = "userAttr.listUserAttrs"; |
| | | |
| | | |
| | | } |
| New file |
| | |
| | | package com.java110.api.bmo.user; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.api.bmo.IApiBaseBMO; |
| | | import com.java110.core.context.DataFlowContext; |
| | | |
| | | public interface IUserAttrBMO extends IApiBaseBMO { |
| | | |
| | | |
| | | /** |
| | | * 添加用户属性 |
| | | * @param paramInJson |
| | | * @param dataFlowContext |
| | | * @return |
| | | */ |
| | | void addUserAttr(JSONObject paramInJson, DataFlowContext dataFlowContext); |
| | | |
| | | /** |
| | | * 添加用户属性信息 |
| | | * |
| | | * @param paramInJson 接口调用放传入入参 |
| | | * @param dataFlowContext 数据上下文 |
| | | * @return 订单服务能够接受的报文 |
| | | */ |
| | | void updateUserAttr(JSONObject paramInJson, DataFlowContext dataFlowContext); |
| | | |
| | | /** |
| | | * 删除用户属性 |
| | | * |
| | | * @param paramInJson 接口调用放传入入参 |
| | | * @param dataFlowContext 数据上下文 |
| | | * @return 订单服务能够接受的报文 |
| | | */ |
| | | void deleteUserAttr(JSONObject paramInJson, DataFlowContext dataFlowContext); |
| | | |
| | | |
| | | |
| | | } |
| New file |
| | |
| | | package com.java110.api.bmo.user.impl; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.api.bmo.ApiBaseBMO; |
| | | import com.java110.api.bmo.user.IUserAttrBMO; |
| | | import com.java110.core.context.DataFlowContext; |
| | | import com.java110.core.smo.userAttr.IUserAttrInnerServiceSMO; |
| | | import com.java110.po.userAttr.UserAttrPo; |
| | | 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("userAttrBMOImpl") |
| | | public class UserAttrBMOImpl extends ApiBaseBMO implements IUserAttrBMO { |
| | | |
| | | @Autowired |
| | | private IUserAttrInnerServiceSMO userAttrInnerServiceSMOImpl; |
| | | |
| | | /** |
| | | * 添加小区信息 |
| | | * |
| | | * @param paramInJson 接口调用放传入入参 |
| | | * @param dataFlowContext 数据上下文 |
| | | * @return 订单服务能够接受的报文 |
| | | */ |
| | | public void addUserAttr(JSONObject paramInJson, DataFlowContext dataFlowContext) { |
| | | |
| | | paramInJson.put("attrId", "-1"); |
| | | UserAttrPo userAttrPo = BeanConvertUtil.covertBean(paramInJson, UserAttrPo.class); |
| | | super.insert(dataFlowContext, userAttrPo, BusinessTypeConstant.BUSINESS_TYPE_SAVE_USER_ATTR_INFO); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 添加活动信息 |
| | | * |
| | | * @param paramInJson 接口调用放传入入参 |
| | | * @param dataFlowContext 数据上下文 |
| | | * @return 订单服务能够接受的报文 |
| | | */ |
| | | public void updateUserAttr(JSONObject paramInJson, DataFlowContext dataFlowContext) { |
| | | UserAttrPo userAttrPo = BeanConvertUtil.covertBean(paramInJson, UserAttrPo.class); |
| | | super.update(dataFlowContext, userAttrPo, BusinessTypeConstant.BUSINESS_TYPE_UPDATE_USER_ATTR_INFO); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 添加小区信息 |
| | | * |
| | | * @param paramInJson 接口调用放传入入参 |
| | | * @param dataFlowContext 数据上下文 |
| | | * @return 订单服务能够接受的报文 |
| | | */ |
| | | public void deleteUserAttr(JSONObject paramInJson, DataFlowContext dataFlowContext) { |
| | | |
| | | UserAttrPo userAttrPo = BeanConvertUtil.covertBean(paramInJson, UserAttrPo.class); |
| | | super.update(dataFlowContext, userAttrPo, BusinessTypeConstant.BUSINESS_TYPE_DELETE_USER_ATTR_INFO); |
| | | } |
| | | |
| | | } |
| | |
| | | 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.store.ISmallWeChatInnerServiceSMO; |
| | | import com.java110.dto.smallWeChat.SmallWeChatDto; |
| | | import com.java110.core.event.service.api.ServiceDataFlowEvent; |
| | | import com.java110.utils.constant.ServiceCodeSmallWeChatConstant; |
| | | import com.java110.utils.util.BeanConvertUtil; |
| | | import com.java110.vo.api.smallWeChat.ApiSmallWeChatDataVo; |
| | |
| | | */ |
| | | @Java110Listener("listSmallWeChatsListener") |
| | | public class ListSmallWeChatsListener extends AbstractServiceApiListener { |
| | | |
| | | private static String OWNER_APP = "992019111758490006"; |
| | | |
| | | @Autowired |
| | | private ISmallWeChatInnerServiceSMO smallWeChatInnerServiceSMOImpl; |
| | |
| | | |
| | | @Override |
| | | protected void doSoService(ServiceDataFlowEvent event, DataFlowContext context, JSONObject reqJson) { |
| | | String appId = event.getDataFlowContext().getRequestHeaders().get("app-id"); |
| | | SmallWeChatDto smallWeChatDto = BeanConvertUtil.covertBean(reqJson, SmallWeChatDto.class); |
| | | 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<>(); |
| | | } |
| | |
| | | ResponseEntity<String> responseEntity = new ResponseEntity<String>(JSONObject.toJSONString(apiSmallWeChatVo), HttpStatus.OK); |
| | | context.setResponseEntity(responseEntity); |
| | | } |
| | | |
| | | private void freshSecure(List<ApiSmallWeChatDataVo> smallWeChats, String appId) { |
| | | if (appId.equals(OWNER_APP)) { |
| | | return; |
| | | } |
| | | |
| | | for (ApiSmallWeChatDataVo apiSmallWeChatDataVo : smallWeChats) { |
| | | apiSmallWeChatDataVo.setAppSecret(""); |
| | | apiSmallWeChatDataVo.setPayPassword(""); |
| | | } |
| | | } |
| | | } |
| New file |
| | |
| | | package com.java110.api.listener.user; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.api.bmo.user.IUserBMO; |
| | | 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.core.factory.DataFlowFactory; |
| | | import com.java110.core.factory.GenerateCodeFactory; |
| | | import com.java110.core.smo.user.IUserInnerServiceSMO; |
| | | import com.java110.dto.file.FileDto; |
| | | import com.java110.dto.file.FileRelDto; |
| | | import com.java110.dto.user.UserAttrDto; |
| | | import com.java110.entity.center.AppService; |
| | | import com.java110.po.file.FileRelPo; |
| | | import com.java110.po.user.UserPo; |
| | | import com.java110.po.userAttr.UserAttrPo; |
| | | import com.java110.utils.constant.BusinessTypeConstant; |
| | | import com.java110.utils.constant.CommonConstant; |
| | | import com.java110.utils.constant.ServiceCodeConstant; |
| | | import com.java110.utils.exception.ListenerExecuteException; |
| | | import com.java110.utils.util.Assert; |
| | | import com.java110.utils.util.BeanConvertUtil; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.http.HttpEntity; |
| | | import org.springframework.http.HttpHeaders; |
| | | import org.springframework.http.HttpMethod; |
| | | import org.springframework.http.HttpStatus; |
| | | import org.springframework.http.ResponseEntity; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 添加或修改用户属性 |
| | | * Created by wuxw on 2018/5/18. |
| | | */ |
| | | @Java110Listener("saveOrUpdateUserAttrListener") |
| | | public class SaveOrUpdateUserAttrListener extends AbstractServiceApiPlusListener { |
| | | |
| | | private final static Logger logger = LoggerFactory.getLogger(SaveOrUpdateUserAttrListener.class); |
| | | |
| | | @Autowired |
| | | private IUserBMO userBMOImpl; |
| | | |
| | | @Autowired |
| | | private IUserInnerServiceSMO userInnerServiceSMOImpl; |
| | | |
| | | |
| | | @Override |
| | | public String getServiceCode() { |
| | | return ServiceCodeConstant.SERVICE_CODE_SAVE_UPDATE_USER_ATTR; |
| | | } |
| | | |
| | | @Override |
| | | public HttpMethod getHttpMethod() { |
| | | return HttpMethod.POST; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public int getOrder() { |
| | | return 0; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | protected void validate(ServiceDataFlowEvent event, JSONObject reqJson) { |
| | | Assert.jsonObjectHaveKey(reqJson, "userId", "请求参数中未包含userId 节点,请确认"); |
| | | //校验json 格式中是否包含 name,email,levelCd,tel |
| | | Assert.jsonObjectHaveKey(reqJson, "specCd", "请求参数中未包含属性 节点,请确认"); |
| | | Assert.jsonObjectHaveKey(reqJson, "value", "请求参数中未包含属性值 节点,请确认"); |
| | | } |
| | | |
| | | @Override |
| | | protected void doSoService(ServiceDataFlowEvent event, DataFlowContext context, JSONObject reqJson) { |
| | | |
| | | UserAttrDto userAttrDto = new UserAttrDto(); |
| | | userAttrDto.setUserId(reqJson.getString("userId")); |
| | | userAttrDto.setSpecCd(reqJson.getString("specCd")); |
| | | List<UserAttrDto> userAttrDtos = userInnerServiceSMOImpl.getUserAttrs(userAttrDto); |
| | | if(userAttrDtos != null && userAttrDtos.size() >0){ |
| | | UserAttrPo userAttrPo = new UserAttrPo(); |
| | | userAttrPo.setUserId(userAttrDtos.get(0).getUserId()); |
| | | userAttrPo.setAttrId(userAttrDtos.get(0).getAttrId()); |
| | | userAttrPo.setSpecCd(reqJson.getString("specCd")); |
| | | userAttrPo.setValue(reqJson.getString("value")); |
| | | super.update(context,userAttrPo,BusinessTypeConstant.BUSINESS_TYPE_UPDATE_USER_ATTR_INFO); |
| | | return; |
| | | } |
| | | |
| | | UserAttrPo userAttrPo = new UserAttrPo(); |
| | | userAttrPo.setUserId(reqJson.getString("userId")); |
| | | userAttrPo.setAttrId("-1"); |
| | | userAttrPo.setSpecCd(reqJson.getString("specCd")); |
| | | userAttrPo.setValue(reqJson.getString("value")); |
| | | super.insert(context,userAttrPo,BusinessTypeConstant.BUSINESS_TYPE_SAVE_USER_ATTR_INFO); |
| | | } |
| | | |
| | | |
| | | private void modifyStaff(JSONObject paramObj, DataFlowContext dataFlowContext) { |
| | | UserPo userPo = BeanConvertUtil.covertBean(builderStaffInfo(paramObj, dataFlowContext), UserPo.class); |
| | | super.update(dataFlowContext, userPo, BusinessTypeConstant.BUSINESS_TYPE_MODIFY_USER_INFO); |
| | | } |
| | | |
| | | /** |
| | | * 构建员工信息 |
| | | * |
| | | * @param paramObj |
| | | * @param dataFlowContext |
| | | * @return |
| | | */ |
| | | private JSONObject builderStaffInfo(JSONObject paramObj, DataFlowContext dataFlowContext) { |
| | | |
| | | //首先根据员工ID查询员工信息,根据员工信息修改相应的数据 |
| | | ResponseEntity responseEntity = null; |
| | | AppService appService = DataFlowFactory.getService(dataFlowContext.getAppId(), ServiceCodeConstant.SERVICE_CODE_QUERY_USER_USERINFO); |
| | | if (appService == null) { |
| | | throw new ListenerExecuteException(1999, "当前没有权限访问" + ServiceCodeConstant.SERVICE_CODE_QUERY_USER_USERINFO); |
| | | |
| | | } |
| | | String requestUrl = appService.getUrl() + "?userId=" + paramObj.getString("userId"); |
| | | HttpHeaders header = new HttpHeaders(); |
| | | header.add(CommonConstant.HTTP_SERVICE.toLowerCase(), ServiceCodeConstant.SERVICE_CODE_QUERY_USER_USERINFO); |
| | | dataFlowContext.getRequestHeaders().put("REQUEST_URL", requestUrl); |
| | | HttpEntity<String> httpEntity = new HttpEntity<String>("", header); |
| | | doRequest(dataFlowContext, appService, httpEntity); |
| | | responseEntity = dataFlowContext.getResponseEntity(); |
| | | |
| | | if (responseEntity.getStatusCode() != HttpStatus.OK) { |
| | | dataFlowContext.setResponseEntity(responseEntity); |
| | | } |
| | | |
| | | JSONObject userInfo = JSONObject.parseObject(responseEntity.getBody().toString()); |
| | | userInfo.putAll(paramObj); |
| | | |
| | | return userInfo; |
| | | } |
| | | |
| | | } |
| | |
| | | package com.java110.front.smo.ownerLogin.impl; |
| | | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.front.smo.AppAbstractComponentSMO; |
| | | import com.java110.front.smo.ownerLogin.IOwnerAppLoginSMO; |
| | | import com.java110.core.context.IPageData; |
| | | import com.java110.core.context.PageData; |
| | | import com.java110.core.factory.AuthenticationFactory; |
| | | import com.java110.front.properties.WechatAuthProperties; |
| | | import com.java110.front.smo.AppAbstractComponentSMO; |
| | | import com.java110.front.smo.ownerLogin.IOwnerAppLoginSMO; |
| | | import com.java110.utils.constant.ServiceConstant; |
| | | import com.java110.utils.exception.SMOException; |
| | | import com.java110.utils.util.Assert; |
| | | import com.java110.utils.util.StringUtil; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | |
| | | @Autowired |
| | | private RestTemplate restTemplate; |
| | | |
| | | @Autowired |
| | | private RestTemplate outRestTemplate; |
| | | |
| | | @Autowired |
| | | private WechatAuthProperties wechatAuthProperties; |
| | | |
| | | @Override |
| | | public ResponseEntity<String> |
| | |
| | | JSONObject loginInfo = JSONObject.parseObject(pd.getReqData()); |
| | | |
| | | loginInfo.put("passwd", AuthenticationFactory.passwdMd5(loginInfo.getString("password"))); |
| | | responseEntity = this.callCenterService(restTemplate, pd, loginInfo.toJSONString(), ServiceConstant.SERVICE_API_URL +"/api/user.service.login", HttpMethod.POST); |
| | | responseEntity = this.callCenterService(restTemplate, pd, loginInfo.toJSONString(), ServiceConstant.SERVICE_API_URL + "/api/user.service.login", HttpMethod.POST); |
| | | if (responseEntity.getStatusCode() != HttpStatus.OK) { |
| | | return responseEntity; |
| | | } |
| | |
| | | pd = PageData.newInstance().builder(userId, "", "", pd.getReqData(), |
| | | "", "", "", "", |
| | | pd.getAppId()); |
| | | responseEntity = this.callCenterService(restTemplate,pd,"", ServiceConstant.SERVICE_API_URL + "/api/owner.listAppUserBindingOwners?userid="+userId,HttpMethod.GET); |
| | | responseEntity = this.callCenterService(restTemplate, pd, "", ServiceConstant.SERVICE_API_URL + "/api/owner.listAppUserBindingOwners?userid=" + userId, HttpMethod.GET); |
| | | |
| | | if (responseEntity.getStatusCode() != HttpStatus.OK) { |
| | | return responseEntity; |
| | |
| | | |
| | | JSONObject ownerInfo = JSONObject.parseObject(responseEntity.getBody().toString()); |
| | | |
| | | if(ownerInfo.getInteger("total") != 1){ |
| | | responseEntity = new ResponseEntity<>("用户未绑定业主",HttpStatus.BAD_REQUEST); |
| | | if (ownerInfo.getInteger("total") != 1) { |
| | | responseEntity = new ResponseEntity<>("用户未绑定业主", HttpStatus.BAD_REQUEST); |
| | | return responseEntity; |
| | | } |
| | | |
| | | JSONObject appUser = ownerInfo.getJSONArray("auditAppUserBindingOwners").getJSONObject(0); |
| | | appUser.put("userId",userId); |
| | | appUser.put("userName",paramIn.getString("username")); |
| | | appUser.put("userId", userId); |
| | | appUser.put("userName", paramIn.getString("username")); |
| | | JSONObject paramOut = new JSONObject(); |
| | | paramOut.put("result", 0); |
| | | paramOut.put("owner", appUser); |
| | | paramOut.put("token", userInfo.getString("token")); |
| | | //pd.setToken(JSONObject.parseObject(responseEntity.getBody()).getString("token")); |
| | | //可能是app 登录 直接返回 |
| | | if (!paramIn.containsKey("code") || StringUtil.isEmpty(paramIn.getString("code"))) { |
| | | return new ResponseEntity<>(paramOut.toJSONString(), HttpStatus.OK); |
| | | } |
| | | //如果code不为空调用微信接口获取openId 刷入到当前用户属性表 |
| | | |
| | | //查询微信信息 |
| | | pd = PageData.newInstance().builder(userId, "", "", pd.getReqData(), |
| | | "", "", "", "", |
| | | pd.getAppId()); |
| | | responseEntity = this.callCenterService(restTemplate, pd, "", |
| | | ServiceConstant.SERVICE_API_URL + "/api/smallWeChat.listSmallWeChats?appId=" |
| | | + paramIn.getString("appId"), HttpMethod.GET); |
| | | |
| | | if (responseEntity.getStatusCode() != HttpStatus.OK) { |
| | | return responseEntity; |
| | | } |
| | | |
| | | JSONArray smallWeChats = ownerInfo.getJSONArray("smallWeChats"); |
| | | String appId = wechatAuthProperties.getAppId(); |
| | | String secret = wechatAuthProperties.getSecret(); |
| | | if (smallWeChats.size() > 0) { |
| | | appId = smallWeChats.getJSONObject(0).getString("appId"); |
| | | secret = smallWeChats.getJSONObject(0).getString("appSecret"); |
| | | } |
| | | |
| | | String code = paramIn.getString("code"); |
| | | String urlString = "?appid={appId}&secret={secret}&js_code={code}&grant_type={grantType}"; |
| | | String response = outRestTemplate.getForObject( |
| | | wechatAuthProperties.getSessionHost() + urlString, String.class, |
| | | appId, |
| | | secret, |
| | | code, |
| | | wechatAuthProperties.getGrantType()); |
| | | |
| | | logger.debug("wechatAuthProperties:" + JSONObject.toJSONString(wechatAuthProperties)); |
| | | |
| | | logger.debug("微信返回报文:" + response); |
| | | |
| | | //Assert.jsonObjectHaveKey(response, "errcode", "返回报文中未包含 错误编码,接口出错"); |
| | | JSONObject responseObj = JSONObject.parseObject(response); |
| | | |
| | | if (responseObj.containsKey("errcode") && !"0".equals(responseObj.getString("errcode"))) { |
| | | throw new IllegalArgumentException("微信验证失败,可能是code失效" + responseObj); |
| | | } |
| | | |
| | | String openId = responseObj.getString("openid"); |
| | | |
| | | JSONObject userAttrInfo = new JSONObject(); |
| | | userAttrInfo.put("userId", userId); |
| | | userAttrInfo.put("specCd", "100201911001");//微信openId |
| | | userAttrInfo.put("value", openId); |
| | | |
| | | //查询微信信息 |
| | | pd = PageData.newInstance().builder(userId, "", "", pd.getReqData(), |
| | | "", "", "", "", |
| | | pd.getAppId()); |
| | | responseEntity = this.callCenterService(restTemplate, pd, userAttrInfo.toJSONString(), |
| | | ServiceConstant.SERVICE_API_URL + "/api/user.saveOrUpdateUserAttr", HttpMethod.POST); |
| | | if(responseEntity.getStatusCode() != HttpStatus.OK){ |
| | | return responseEntity; |
| | | } |
| | | return new ResponseEntity<>(paramOut.toJSONString(), HttpStatus.OK); |
| | | } |
| | | |
| New file |
| | |
| | | package com.java110.user.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 IUserAttrServiceDao { |
| | | |
| | | /** |
| | | * 保存 用户属性信息 |
| | | * @param businessUserAttrInfo 用户属性信息 封装 |
| | | * @throws DAOException 操作数据库异常 |
| | | */ |
| | | void saveBusinessUserAttrInfo(Map businessUserAttrInfo) throws DAOException; |
| | | |
| | | |
| | | |
| | | /** |
| | | * 查询用户属性信息(business过程) |
| | | * 根据bId 查询用户属性信息 |
| | | * @param info bId 信息 |
| | | * @return 用户属性信息 |
| | | * @throws DAOException DAO异常 |
| | | */ |
| | | List<Map> getBusinessUserAttrInfo(Map info) throws DAOException; |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 保存 用户属性信息 Business数据到 Instance中 |
| | | * @param info |
| | | * @throws DAOException DAO异常 |
| | | */ |
| | | void saveUserAttrInfoInstance(Map info) throws DAOException; |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 查询用户属性信息(instance过程) |
| | | * 根据bId 查询用户属性信息 |
| | | * @param info bId 信息 |
| | | * @return 用户属性信息 |
| | | * @throws DAOException DAO异常 |
| | | */ |
| | | List<Map> getUserAttrInfo(Map info) throws DAOException; |
| | | |
| | | |
| | | |
| | | /** |
| | | * 修改用户属性信息 |
| | | * @param info 修改信息 |
| | | * @throws DAOException DAO异常 |
| | | */ |
| | | void updateUserAttrInfoInstance(Map info) throws DAOException; |
| | | |
| | | |
| | | /** |
| | | * 查询用户属性总数 |
| | | * |
| | | * @param info 用户属性信息 |
| | | * @return 用户属性数量 |
| | | */ |
| | | int queryUserAttrsCount(Map info); |
| | | |
| | | } |
| New file |
| | |
| | | package com.java110.user.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.user.dao.IUserAttrServiceDao; |
| | | 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("userAttrServiceDaoImpl") |
| | | //@Transactional |
| | | public class UserAttrServiceDaoImpl extends BaseServiceDao implements IUserAttrServiceDao { |
| | | |
| | | private static Logger logger = LoggerFactory.getLogger(UserAttrServiceDaoImpl.class); |
| | | |
| | | /** |
| | | * 用户属性信息封装 |
| | | * @param businessUserAttrInfo 用户属性信息 封装 |
| | | * @throws DAOException DAO异常 |
| | | */ |
| | | @Override |
| | | public void saveBusinessUserAttrInfo(Map businessUserAttrInfo) throws DAOException { |
| | | businessUserAttrInfo.put("month", DateUtil.getCurrentMonth()); |
| | | // 查询business_user 数据是否已经存在 |
| | | logger.debug("保存用户属性信息 入参 businessUserAttrInfo : {}",businessUserAttrInfo); |
| | | int saveFlag = sqlSessionTemplate.insert("userAttrServiceDaoImpl.saveBusinessUserAttrInfo",businessUserAttrInfo); |
| | | |
| | | if(saveFlag < 1){ |
| | | throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"保存用户属性数据失败:"+ JSONObject.toJSONString(businessUserAttrInfo)); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 查询用户属性信息 |
| | | * @param info bId 信息 |
| | | * @return 用户属性信息 |
| | | * @throws DAOException DAO异常 |
| | | */ |
| | | @Override |
| | | public List<Map> getBusinessUserAttrInfo(Map info) throws DAOException { |
| | | |
| | | logger.debug("查询用户属性信息 入参 info : {}",info); |
| | | |
| | | List<Map> businessUserAttrInfos = sqlSessionTemplate.selectList("userAttrServiceDaoImpl.getBusinessUserAttrInfo",info); |
| | | |
| | | return businessUserAttrInfos; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 保存用户属性信息 到 instance |
| | | * @param info bId 信息 |
| | | * @throws DAOException DAO异常 |
| | | */ |
| | | @Override |
| | | public void saveUserAttrInfoInstance(Map info) throws DAOException { |
| | | logger.debug("保存用户属性信息Instance 入参 info : {}",info); |
| | | |
| | | int saveFlag = sqlSessionTemplate.insert("userAttrServiceDaoImpl.saveUserAttrInfoInstance",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> getUserAttrInfo(Map info) throws DAOException { |
| | | logger.debug("查询用户属性信息 入参 info : {}",info); |
| | | |
| | | List<Map> businessUserAttrInfos = sqlSessionTemplate.selectList("userAttrServiceDaoImpl.getUserAttrInfo",info); |
| | | |
| | | return businessUserAttrInfos; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 修改用户属性信息 |
| | | * @param info 修改信息 |
| | | * @throws DAOException DAO异常 |
| | | */ |
| | | @Override |
| | | public void updateUserAttrInfoInstance(Map info) throws DAOException { |
| | | logger.debug("修改用户属性信息Instance 入参 info : {}",info); |
| | | |
| | | int saveFlag = sqlSessionTemplate.update("userAttrServiceDaoImpl.updateUserAttrInfoInstance",info); |
| | | |
| | | if(saveFlag < 1){ |
| | | throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"修改用户属性信息Instance数据失败:"+ JSONObject.toJSONString(info)); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 查询用户属性数量 |
| | | * @param info 用户属性信息 |
| | | * @return 用户属性数量 |
| | | */ |
| | | @Override |
| | | public int queryUserAttrsCount(Map info) { |
| | | logger.debug("查询用户属性数据 入参 info : {}",info); |
| | | |
| | | List<Map> businessUserAttrInfos = sqlSessionTemplate.selectList("userAttrServiceDaoImpl.queryUserAttrsCount", info); |
| | | if (businessUserAttrInfos.size() < 1) { |
| | | return 0; |
| | | } |
| | | |
| | | return Integer.parseInt(businessUserAttrInfos.get(0).get("count").toString()); |
| | | } |
| | | |
| | | |
| | | } |
| New file |
| | |
| | | package com.java110.user.listener.userAttr; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.core.event.service.AbstractBusinessServiceDataFlowListener; |
| | | import com.java110.entity.center.Business; |
| | | import com.java110.user.dao.IUserAttrServiceDao; |
| | | 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 AbstractUserAttrBusinessServiceDataFlowListener extends AbstractBusinessServiceDataFlowListener { |
| | | private static Logger logger = LoggerFactory.getLogger(AbstractUserAttrBusinessServiceDataFlowListener.class); |
| | | |
| | | |
| | | /** |
| | | * 获取 DAO工具类 |
| | | * |
| | | * @return |
| | | */ |
| | | public abstract IUserAttrServiceDao getUserAttrServiceDaoImpl(); |
| | | |
| | | /** |
| | | * 刷新 businessUserAttrInfo 数据 |
| | | * 主要将 数据库 中字段和 接口传递字段建立关系 |
| | | * |
| | | * @param businessUserAttrInfo |
| | | */ |
| | | protected void flushBusinessUserAttrInfo(Map businessUserAttrInfo, String statusCd) { |
| | | businessUserAttrInfo.put("newBId", businessUserAttrInfo.get("b_id")); |
| | | businessUserAttrInfo.put("attrId", businessUserAttrInfo.get("attr_id")); |
| | | businessUserAttrInfo.put("operate", businessUserAttrInfo.get("operate")); |
| | | businessUserAttrInfo.put("specCd", businessUserAttrInfo.get("spec_cd")); |
| | | businessUserAttrInfo.put("userId", businessUserAttrInfo.get("user_id")); |
| | | businessUserAttrInfo.put("value", businessUserAttrInfo.get("value")); |
| | | businessUserAttrInfo.remove("bId"); |
| | | businessUserAttrInfo.put("statusCd", statusCd); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 当修改数据时,查询instance表中的数据 自动保存删除数据到business中 |
| | | * |
| | | * @param businessUserAttr 用户属性信息 |
| | | */ |
| | | protected void autoSaveDelBusinessUserAttr(Business business, JSONObject businessUserAttr) { |
| | | //自动插入DEL |
| | | Map info = new HashMap(); |
| | | info.put("attrId", businessUserAttr.getString("attrId")); |
| | | info.put("statusCd", StatusConstant.STATUS_CD_VALID); |
| | | List<Map> currentUserAttrInfos = getUserAttrServiceDaoImpl().getUserAttrInfo(info); |
| | | if (currentUserAttrInfos == null || currentUserAttrInfos.size() != 1) { |
| | | throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR, "未找到需要修改数据信息,入参错误或数据有问题,请检查" + info); |
| | | } |
| | | |
| | | Map currentUserAttrInfo = currentUserAttrInfos.get(0); |
| | | |
| | | currentUserAttrInfo.put("bId", business.getbId()); |
| | | |
| | | currentUserAttrInfo.put("attrId", currentUserAttrInfo.get("attr_id")); |
| | | currentUserAttrInfo.put("operate", currentUserAttrInfo.get("operate")); |
| | | currentUserAttrInfo.put("specCd", currentUserAttrInfo.get("spec_cd")); |
| | | currentUserAttrInfo.put("userId", currentUserAttrInfo.get("user_id")); |
| | | currentUserAttrInfo.put("value", currentUserAttrInfo.get("value")); |
| | | |
| | | |
| | | currentUserAttrInfo.put("operate", StatusConstant.OPERATE_DEL); |
| | | getUserAttrServiceDaoImpl().saveBusinessUserAttrInfo(currentUserAttrInfo); |
| | | for (Object key : currentUserAttrInfo.keySet()) { |
| | | if (businessUserAttr.get(key) == null) { |
| | | businessUserAttr.put(key.toString(), currentUserAttrInfo.get(key)); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| New file |
| | |
| | | package com.java110.user.listener.userAttr; |
| | | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.po.userAttr.UserAttrPo; |
| | | 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.user.dao.IUserAttrServiceDao; |
| | | 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、businessUserAttr:{} 用户属性基本信息节点 |
| | | * 2、businessUserAttrAttr:[{}] 用户属性属性信息节点 |
| | | * 3、businessUserAttrPhoto:[{}] 用户属性照片信息节点 |
| | | * 4、businessUserAttrCerdentials:[{}] 用户属性证件信息节点 |
| | | * 协议地址 :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("deleteUserAttrInfoListener") |
| | | @Transactional |
| | | public class DeleteUserAttrInfoListener extends AbstractUserAttrBusinessServiceDataFlowListener { |
| | | |
| | | private final static Logger logger = LoggerFactory.getLogger(DeleteUserAttrInfoListener.class); |
| | | @Autowired |
| | | IUserAttrServiceDao userAttrServiceDaoImpl; |
| | | |
| | | @Override |
| | | public int getOrder() { |
| | | return 3; |
| | | } |
| | | |
| | | @Override |
| | | public String getBusinessTypeCd() { |
| | | return BusinessTypeConstant.BUSINESS_TYPE_DELETE_USER_ATTR_INFO; |
| | | } |
| | | |
| | | /** |
| | | * 根据删除信息 查出Instance表中数据 保存至business表 (状态写DEL) 方便撤单时直接更新回去 |
| | | * @param dataFlowContext 数据对象 |
| | | * @param business 当前业务对象 |
| | | */ |
| | | @Override |
| | | protected void doSaveBusiness(DataFlowContext dataFlowContext, Business business) { |
| | | JSONObject data = business.getDatas(); |
| | | |
| | | Assert.notEmpty(data,"没有datas 节点,或没有子节点需要处理"); |
| | | |
| | | //处理 businessUserAttr 节点 |
| | | if(data.containsKey(UserAttrPo.class.getSimpleName())){ |
| | | Object _obj = data.get(UserAttrPo.class.getSimpleName()); |
| | | JSONArray businessUserAttrs = null; |
| | | if(_obj instanceof JSONObject){ |
| | | businessUserAttrs = new JSONArray(); |
| | | businessUserAttrs.add(_obj); |
| | | }else { |
| | | businessUserAttrs = (JSONArray)_obj; |
| | | } |
| | | //JSONObject businessUserAttr = data.getJSONObject(UserAttrPo.class.getSimpleName()); |
| | | for (int _userAttrIndex = 0; _userAttrIndex < businessUserAttrs.size();_userAttrIndex++) { |
| | | JSONObject businessUserAttr = businessUserAttrs.getJSONObject(_userAttrIndex); |
| | | doBusinessUserAttr(business, businessUserAttr); |
| | | if(_obj instanceof JSONObject) { |
| | | dataFlowContext.addParamOut("attrId", businessUserAttr.getString("attrId")); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 删除 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> businessUserAttrInfos = userAttrServiceDaoImpl.getBusinessUserAttrInfo(info); |
| | | if( businessUserAttrInfos != null && businessUserAttrInfos.size() >0) { |
| | | for (int _userAttrIndex = 0; _userAttrIndex < businessUserAttrInfos.size();_userAttrIndex++) { |
| | | Map businessUserAttrInfo = businessUserAttrInfos.get(_userAttrIndex); |
| | | flushBusinessUserAttrInfo(businessUserAttrInfo,StatusConstant.STATUS_CD_INVALID); |
| | | userAttrServiceDaoImpl.updateUserAttrInfoInstance(businessUserAttrInfo); |
| | | dataFlowContext.addParamOut("attrId",businessUserAttrInfo.get("attr_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> userAttrInfo = userAttrServiceDaoImpl.getUserAttrInfo(info); |
| | | if(userAttrInfo != null && userAttrInfo.size() > 0){ |
| | | |
| | | //用户属性信息 |
| | | List<Map> businessUserAttrInfos = userAttrServiceDaoImpl.getBusinessUserAttrInfo(delInfo); |
| | | //除非程序出错了,这里不会为空 |
| | | if(businessUserAttrInfos == null || businessUserAttrInfos.size() == 0){ |
| | | throw new ListenerExecuteException(ResponseConstant.RESULT_CODE_INNER_ERROR,"撤单失败(userAttr),程序内部异常,请检查! "+delInfo); |
| | | } |
| | | for (int _userAttrIndex = 0; _userAttrIndex < businessUserAttrInfos.size();_userAttrIndex++) { |
| | | Map businessUserAttrInfo = businessUserAttrInfos.get(_userAttrIndex); |
| | | flushBusinessUserAttrInfo(businessUserAttrInfo,StatusConstant.STATUS_CD_VALID); |
| | | userAttrServiceDaoImpl.updateUserAttrInfoInstance(businessUserAttrInfo); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 处理 businessUserAttr 节点 |
| | | * @param business 总的数据节点 |
| | | * @param businessUserAttr 用户属性节点 |
| | | */ |
| | | private void doBusinessUserAttr(Business business,JSONObject businessUserAttr){ |
| | | |
| | | Assert.jsonObjectHaveKey(businessUserAttr,"attrId","businessUserAttr 节点下没有包含 attrId 节点"); |
| | | |
| | | if(businessUserAttr.getString("attrId").startsWith("-")){ |
| | | throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"attrId 错误,不能自动生成(必须已经存在的attrId)"+businessUserAttr); |
| | | } |
| | | //自动插入DEL |
| | | autoSaveDelBusinessUserAttr(business,businessUserAttr); |
| | | } |
| | | @Override |
| | | public IUserAttrServiceDao getUserAttrServiceDaoImpl() { |
| | | return userAttrServiceDaoImpl; |
| | | } |
| | | |
| | | public void setUserAttrServiceDaoImpl(IUserAttrServiceDao userAttrServiceDaoImpl) { |
| | | this.userAttrServiceDaoImpl = userAttrServiceDaoImpl; |
| | | } |
| | | } |
| New file |
| | |
| | | package com.java110.user.listener.userAttr; |
| | | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.po.userAttr.UserAttrPo; |
| | | import com.java110.utils.constant.BusinessTypeConstant; |
| | | import com.java110.utils.constant.StatusConstant; |
| | | import com.java110.utils.util.Assert; |
| | | import com.java110.user.dao.IUserAttrServiceDao; |
| | | 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("saveUserAttrInfoListener") |
| | | @Transactional |
| | | public class SaveUserAttrInfoListener extends AbstractUserAttrBusinessServiceDataFlowListener{ |
| | | |
| | | private static Logger logger = LoggerFactory.getLogger(SaveUserAttrInfoListener.class); |
| | | |
| | | @Autowired |
| | | private IUserAttrServiceDao userAttrServiceDaoImpl; |
| | | |
| | | @Override |
| | | public int getOrder() { |
| | | return 0; |
| | | } |
| | | |
| | | @Override |
| | | public String getBusinessTypeCd() { |
| | | return BusinessTypeConstant.BUSINESS_TYPE_SAVE_USER_ATTR_INFO; |
| | | } |
| | | |
| | | /** |
| | | * 保存用户属性信息 business 表中 |
| | | * @param dataFlowContext 数据对象 |
| | | * @param business 当前业务对象 |
| | | */ |
| | | @Override |
| | | protected void doSaveBusiness(DataFlowContext dataFlowContext, Business business) { |
| | | JSONObject data = business.getDatas(); |
| | | Assert.notEmpty(data,"没有datas 节点,或没有子节点需要处理"); |
| | | |
| | | //处理 businessUserAttr 节点 |
| | | if(data.containsKey(UserAttrPo.class.getSimpleName())){ |
| | | Object bObj = data.get(UserAttrPo.class.getSimpleName()); |
| | | JSONArray businessUserAttrs = null; |
| | | if(bObj instanceof JSONObject){ |
| | | businessUserAttrs = new JSONArray(); |
| | | businessUserAttrs.add(bObj); |
| | | }else { |
| | | businessUserAttrs = (JSONArray)bObj; |
| | | } |
| | | //JSONObject businessUserAttr = data.getJSONObject(UserAttrPo.class.getSimpleName()); |
| | | for (int bUserAttrIndex = 0; bUserAttrIndex < businessUserAttrs.size();bUserAttrIndex++) { |
| | | JSONObject businessUserAttr = businessUserAttrs.getJSONObject(bUserAttrIndex); |
| | | doBusinessUserAttr(business, businessUserAttr); |
| | | if(bObj instanceof JSONObject) { |
| | | dataFlowContext.addParamOut("attrId", businessUserAttr.getString("attrId")); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 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> businessUserAttrInfo = userAttrServiceDaoImpl.getBusinessUserAttrInfo(info); |
| | | if( businessUserAttrInfo != null && businessUserAttrInfo.size() >0) { |
| | | reFreshShareColumn(info, businessUserAttrInfo.get(0)); |
| | | userAttrServiceDaoImpl.saveUserAttrInfoInstance(info); |
| | | if(businessUserAttrInfo.size() == 1) { |
| | | dataFlowContext.addParamOut("attrId", businessUserAttrInfo.get(0).get("attr_id")); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 刷 分片字段 |
| | | * |
| | | * @param info 查询对象 |
| | | * @param businessInfo 小区ID |
| | | */ |
| | | private void reFreshShareColumn(Map info, Map businessInfo) { |
| | | |
| | | if (info.containsKey("userId")) { |
| | | return; |
| | | } |
| | | |
| | | if (!businessInfo.containsKey("user_id")) { |
| | | return; |
| | | } |
| | | |
| | | info.put("userId", businessInfo.get("user_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> userAttrInfo = userAttrServiceDaoImpl.getUserAttrInfo(info); |
| | | if(userAttrInfo != null && userAttrInfo.size() > 0){ |
| | | reFreshShareColumn(paramIn, userAttrInfo.get(0)); |
| | | userAttrServiceDaoImpl.updateUserAttrInfoInstance(paramIn); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 处理 businessUserAttr 节点 |
| | | * @param business 总的数据节点 |
| | | * @param businessUserAttr 用户属性节点 |
| | | */ |
| | | private void doBusinessUserAttr(Business business,JSONObject businessUserAttr){ |
| | | |
| | | Assert.jsonObjectHaveKey(businessUserAttr,"attrId","businessUserAttr 节点下没有包含 attrId 节点"); |
| | | |
| | | if(businessUserAttr.getString("attrId").startsWith("-")){ |
| | | //刷新缓存 |
| | | //flushUserAttrId(business.getDatas()); |
| | | |
| | | businessUserAttr.put("attrId",GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_attrId)); |
| | | |
| | | } |
| | | |
| | | businessUserAttr.put("bId",business.getbId()); |
| | | businessUserAttr.put("operate", StatusConstant.OPERATE_ADD); |
| | | //保存用户属性信息 |
| | | userAttrServiceDaoImpl.saveBusinessUserAttrInfo(businessUserAttr); |
| | | |
| | | } |
| | | @Override |
| | | public IUserAttrServiceDao getUserAttrServiceDaoImpl() { |
| | | return userAttrServiceDaoImpl; |
| | | } |
| | | |
| | | public void setUserAttrServiceDaoImpl(IUserAttrServiceDao userAttrServiceDaoImpl) { |
| | | this.userAttrServiceDaoImpl = userAttrServiceDaoImpl; |
| | | } |
| | | } |
| New file |
| | |
| | | package com.java110.user.listener.userAttr; |
| | | |
| | | 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.userAttr.UserAttrPo; |
| | | import com.java110.user.dao.IUserAttrServiceDao; |
| | | 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、businessUserAttr:{} 用户属性基本信息节点 |
| | | * 2、businessUserAttrAttr:[{}] 用户属性属性信息节点 |
| | | * 3、businessUserAttrPhoto:[{}] 用户属性照片信息节点 |
| | | * 4、businessUserAttrCerdentials:[{}] 用户属性证件信息节点 |
| | | * 协议地址 :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("updateUserAttrInfoListener") |
| | | @Transactional |
| | | public class UpdateUserAttrInfoListener extends AbstractUserAttrBusinessServiceDataFlowListener { |
| | | |
| | | private static Logger logger = LoggerFactory.getLogger(UpdateUserAttrInfoListener.class); |
| | | @Autowired |
| | | private IUserAttrServiceDao userAttrServiceDaoImpl; |
| | | |
| | | @Override |
| | | public int getOrder() { |
| | | return 2; |
| | | } |
| | | |
| | | @Override |
| | | public String getBusinessTypeCd() { |
| | | return BusinessTypeConstant.BUSINESS_TYPE_UPDATE_USER_ATTR_INFO; |
| | | } |
| | | |
| | | /** |
| | | * business过程 |
| | | * |
| | | * @param dataFlowContext 上下文对象 |
| | | * @param business 业务对象 |
| | | */ |
| | | @Override |
| | | protected void doSaveBusiness(DataFlowContext dataFlowContext, Business business) { |
| | | |
| | | JSONObject data = business.getDatas(); |
| | | |
| | | Assert.notEmpty(data, "没有datas 节点,或没有子节点需要处理"); |
| | | |
| | | |
| | | //处理 businessUserAttr 节点 |
| | | if (data.containsKey(UserAttrPo.class.getSimpleName())) { |
| | | Object _obj = data.get(UserAttrPo.class.getSimpleName()); |
| | | JSONArray businessUserAttrs = null; |
| | | if (_obj instanceof JSONObject) { |
| | | businessUserAttrs = new JSONArray(); |
| | | businessUserAttrs.add(_obj); |
| | | } else { |
| | | businessUserAttrs = (JSONArray) _obj; |
| | | } |
| | | //JSONObject businessUserAttr = data.getJSONObject(UserAttrPo.class.getSimpleName()); |
| | | for (int _userAttrIndex = 0; _userAttrIndex < businessUserAttrs.size(); _userAttrIndex++) { |
| | | JSONObject businessUserAttr = businessUserAttrs.getJSONObject(_userAttrIndex); |
| | | doBusinessUserAttr(business, businessUserAttr); |
| | | if (_obj instanceof JSONObject) { |
| | | dataFlowContext.addParamOut("attrId", businessUserAttr.getString("attrId")); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 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> businessUserAttrInfos = userAttrServiceDaoImpl.getBusinessUserAttrInfo(info); |
| | | if (businessUserAttrInfos != null && businessUserAttrInfos.size() > 0) { |
| | | for (int _userAttrIndex = 0; _userAttrIndex < businessUserAttrInfos.size(); _userAttrIndex++) { |
| | | Map businessUserAttrInfo = businessUserAttrInfos.get(_userAttrIndex); |
| | | flushBusinessUserAttrInfo(businessUserAttrInfo, StatusConstant.STATUS_CD_VALID); |
| | | userAttrServiceDaoImpl.updateUserAttrInfoInstance(businessUserAttrInfo); |
| | | if (businessUserAttrInfo.size() == 1) { |
| | | dataFlowContext.addParamOut("attrId", businessUserAttrInfo.get("attr_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> userAttrInfo = userAttrServiceDaoImpl.getUserAttrInfo(info); |
| | | if (userAttrInfo != null && userAttrInfo.size() > 0) { |
| | | |
| | | //用户属性信息 |
| | | List<Map> businessUserAttrInfos = userAttrServiceDaoImpl.getBusinessUserAttrInfo(delInfo); |
| | | //除非程序出错了,这里不会为空 |
| | | if (businessUserAttrInfos == null || businessUserAttrInfos.size() == 0) { |
| | | throw new ListenerExecuteException(ResponseConstant.RESULT_CODE_INNER_ERROR, "撤单失败(userAttr),程序内部异常,请检查! " + delInfo); |
| | | } |
| | | for (int _userAttrIndex = 0; _userAttrIndex < businessUserAttrInfos.size(); _userAttrIndex++) { |
| | | Map businessUserAttrInfo = businessUserAttrInfos.get(_userAttrIndex); |
| | | flushBusinessUserAttrInfo(businessUserAttrInfo, StatusConstant.STATUS_CD_VALID); |
| | | userAttrServiceDaoImpl.updateUserAttrInfoInstance(businessUserAttrInfo); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 处理 businessUserAttr 节点 |
| | | * |
| | | * @param business 总的数据节点 |
| | | * @param businessUserAttr 用户属性节点 |
| | | */ |
| | | private void doBusinessUserAttr(Business business, JSONObject businessUserAttr) { |
| | | |
| | | Assert.jsonObjectHaveKey(businessUserAttr, "attrId", "businessUserAttr 节点下没有包含 attrId 节点"); |
| | | |
| | | if (businessUserAttr.getString("attrId").startsWith("-")) { |
| | | throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR, "attrId 错误,不能自动生成(必须已经存在的attrId)" + businessUserAttr); |
| | | } |
| | | //自动保存DEL |
| | | autoSaveDelBusinessUserAttr(business, businessUserAttr); |
| | | |
| | | businessUserAttr.put("bId", business.getbId()); |
| | | businessUserAttr.put("operate", StatusConstant.OPERATE_ADD); |
| | | //保存用户属性信息 |
| | | userAttrServiceDaoImpl.saveBusinessUserAttrInfo(businessUserAttr); |
| | | |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public IUserAttrServiceDao getUserAttrServiceDaoImpl() { |
| | | return userAttrServiceDaoImpl; |
| | | } |
| | | |
| | | public void setUserAttrServiceDaoImpl(IUserAttrServiceDao userAttrServiceDaoImpl) { |
| | | this.userAttrServiceDaoImpl = userAttrServiceDaoImpl; |
| | | } |
| | | |
| | | |
| | | } |
| New file |
| | |
| | | package com.java110.user.smo.impl; |
| | | |
| | | |
| | | import com.java110.core.base.smo.BaseServiceSMO; |
| | | import com.java110.core.smo.user.IUserInnerServiceSMO; |
| | | import com.java110.core.smo.userAttr.IUserAttrInnerServiceSMO; |
| | | import com.java110.dto.PageDto; |
| | | import com.java110.dto.user.UserAttrDto; |
| | | import com.java110.dto.user.UserDto; |
| | | import com.java110.user.dao.IUserAttrServiceDao; |
| | | import com.java110.utils.util.BeanConvertUtil; |
| | | 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 UserAttrInnerServiceSMOImpl extends BaseServiceSMO implements IUserAttrInnerServiceSMO { |
| | | |
| | | @Autowired |
| | | private IUserAttrServiceDao userAttrServiceDaoImpl; |
| | | |
| | | @Autowired |
| | | private IUserInnerServiceSMO userInnerServiceSMOImpl; |
| | | |
| | | @Override |
| | | public List<UserAttrDto> queryUserAttrs(@RequestBody UserAttrDto userAttrDto) { |
| | | |
| | | //校验是否传了 分页信息 |
| | | |
| | | int page = userAttrDto.getPage(); |
| | | |
| | | if (page != PageDto.DEFAULT_PAGE) { |
| | | userAttrDto.setPage((page - 1) * userAttrDto.getRow()); |
| | | } |
| | | |
| | | List<UserAttrDto> userAttrs = BeanConvertUtil.covertBeanList(userAttrServiceDaoImpl.getUserAttrInfo(BeanConvertUtil.beanCovertMap(userAttrDto)), UserAttrDto.class); |
| | | |
| | | if (userAttrs == null || userAttrs.size() == 0) { |
| | | return userAttrs; |
| | | } |
| | | |
| | | String[] userIds = getUserIds(userAttrs); |
| | | //根据 userId 查询用户信息 |
| | | List<UserDto> users = userInnerServiceSMOImpl.getUserInfo(userIds); |
| | | |
| | | for (UserAttrDto userAttr : userAttrs) { |
| | | refreshUserAttr(userAttr, users); |
| | | } |
| | | return userAttrs; |
| | | } |
| | | |
| | | /** |
| | | * 从用户列表中查询用户,将用户中的信息 刷新到 floor对象中 |
| | | * |
| | | * @param userAttr 小区用户属性信息 |
| | | * @param users 用户列表 |
| | | */ |
| | | private void refreshUserAttr(UserAttrDto userAttr, List<UserDto> users) { |
| | | for (UserDto user : users) { |
| | | if (userAttr.getAttrId().equals(user.getUserId())) { |
| | | BeanConvertUtil.covertBean(user, userAttr); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取批量userId |
| | | * |
| | | * @param userAttrs 小区楼信息 |
| | | * @return 批量userIds 信息 |
| | | */ |
| | | private String[] getUserIds(List<UserAttrDto> userAttrs) { |
| | | List<String> userIds = new ArrayList<String>(); |
| | | for (UserAttrDto userAttr : userAttrs) { |
| | | userIds.add(userAttr.getAttrId()); |
| | | } |
| | | |
| | | return userIds.toArray(new String[userIds.size()]); |
| | | } |
| | | |
| | | @Override |
| | | public int queryUserAttrsCount(@RequestBody UserAttrDto userAttrDto) { |
| | | return userAttrServiceDaoImpl.queryUserAttrsCount(BeanConvertUtil.beanCovertMap(userAttrDto)); |
| | | } |
| | | |
| | | public IUserAttrServiceDao getUserAttrServiceDaoImpl() { |
| | | return userAttrServiceDaoImpl; |
| | | } |
| | | |
| | | public void setUserAttrServiceDaoImpl(IUserAttrServiceDao userAttrServiceDaoImpl) { |
| | | this.userAttrServiceDaoImpl = userAttrServiceDaoImpl; |
| | | } |
| | | |
| | | public IUserInnerServiceSMO getUserInnerServiceSMOImpl() { |
| | | return userInnerServiceSMOImpl; |
| | | } |
| | | |
| | | public void setUserInnerServiceSMOImpl(IUserInnerServiceSMO userInnerServiceSMOImpl) { |
| | | this.userInnerServiceSMOImpl = userInnerServiceSMOImpl; |
| | | } |
| | | } |
| | |
| | | package com.java110.user.smo.impl; |
| | | |
| | | import com.java110.core.smo.user.IUserInnerServiceSMO; |
| | | import com.java110.dto.PageDto; |
| | | import com.java110.dto.user.UserAttrDto; |
| | | import com.java110.utils.constant.StatusConstant; |
| | | import com.java110.utils.util.BeanConvertUtil; |
| | | import com.java110.core.smo.user.IUserInnerServiceSMO; |
| | | import com.java110.dto.user.UserDto; |
| | | import com.java110.user.dao.IUserServiceDao; |
| | | import com.java110.utils.constant.StatusConstant; |
| | | import com.java110.utils.util.BeanConvertUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | |
| | | |
| | | @Autowired |
| | | private IUserServiceDao userServiceDaoImpl; |
| | | |
| | | |
| | | @Override |
| | | public String getUserServiceVersion(@RequestParam("code") String code) { |
| | |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public List<UserAttrDto> getUserAttrs(@RequestBody UserAttrDto userAttrDto) { |
| | | List<UserAttrDto> userAttrDtos = BeanConvertUtil.covertBeanList( |
| | | userServiceDaoImpl.queryUserInfoAttrs(BeanConvertUtil.beanCovertMap(userAttrDto)), UserAttrDto.class); |
| | | return userAttrDtos; |
| | | } |
| | | |
| | | private void freshUserAttrs(List<UserDto> userDtos) { |
| | | |
| | | Map param = null; |
| | | for (UserDto userDto : userDtos) { |
| | | param = new HashMap(); |
| | | param.put("userId",userDto.getUserId()); |
| | | param.put("userId", userDto.getUserId()); |
| | | List<UserAttrDto> userAttrDtos = BeanConvertUtil.covertBeanList(userServiceDaoImpl.queryUserInfoAttrs(param), UserAttrDto.class); |
| | | if(userAttrDtos == null || userAttrDtos.size() == 0){ |
| | | if (userAttrDtos == null || userAttrDtos.size() == 0) { |
| | | continue; |
| | | } |
| | | userDto.setUserAttrs(userAttrDtos); |
| | | for(UserAttrDto userAttrDto : userAttrDtos){ |
| | | for (UserAttrDto userAttrDto : userAttrDtos) { |
| | | //openId 单独出来处理 |
| | | if("100201911001".equals(userAttrDto.getSpecCd())){ |
| | | if ("100201911001".equals(userAttrDto.getSpecCd())) { |
| | | userDto.setOpenId(userAttrDto.getValue()); |
| | | } |
| | | } |