| | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.core.annotation.Java110Cmd; |
| | | import com.java110.core.annotation.Java110Transactional; |
| | | import com.java110.core.context.CmdContextUtils; |
| | | import com.java110.core.context.ICmdDataFlowContext; |
| | | import com.java110.core.event.cmd.Cmd; |
| | | import com.java110.core.event.cmd.CmdEvent; |
| | |
| | | import com.java110.utils.exception.CmdException; |
| | | import com.java110.utils.util.Assert; |
| | | import com.java110.utils.util.BeanConvertUtil; |
| | | import com.java110.utils.util.ListUtil; |
| | | import com.java110.utils.util.StringUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | |
| | |
| | | @Override |
| | | public void validate(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException, ParseException { |
| | | Assert.jsonObjectHaveKey(reqJson, "name", "请求报文中未包含name"); |
| | | Assert.jsonObjectHaveKey(reqJson, "userId", "请求报文中未包含userId"); |
| | | Assert.jsonObjectHaveKey(reqJson, "age", "请求报文中未包含age"); |
| | | Assert.jsonObjectHaveKey(reqJson, "link", "请求报文中未包含link"); |
| | | Assert.jsonObjectHaveKey(reqJson, "sex", "请求报文中未包含sex"); |
| | | Assert.jsonObjectHaveKey(reqJson, "ownerId", "请求报文中未包含业主"); |
| | | |
| | | Assert.jsonObjectHaveKey(reqJson, "communityId", "请求报文中未包含communityId"); |
| | | |
| | | if (reqJson.containsKey("ownerPhotoUrl")) { |
| | | String ownerPhotoUrl = reqJson.getString("ownerPhotoUrl"); |
| | | if (!StringUtil.isEmpty(ownerPhotoUrl) && ownerPhotoUrl.length() > 500) { |
| | | throw new CmdException("图片地址太长"); |
| | | } |
| | | } |
| | | |
| | | //todo 验证吗校验 |
| | | if (reqJson.containsKey("msgCode")) { |
| | |
| | | @Override |
| | | @Java110Transactional |
| | | public void doCmd(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException, ParseException { |
| | | String userId = CmdContextUtils.getUserId(context); |
| | | |
| | | //todo 生成memberId |
| | | generateMemberId(reqJson); |
| | | String memberId = GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_ownerId); |
| | | reqJson.put("memberId", memberId); |
| | | |
| | | JSONObject businessOwner = new JSONObject(); |
| | | businessOwner.putAll(reqJson); |
| | | businessOwner.put("state", "2000"); |
| | | OwnerPo ownerPo = BeanConvertUtil.covertBean(businessOwner, OwnerPo.class); |
| | | if (reqJson.containsKey("age") && StringUtil.isEmpty(reqJson.getString("age"))) { |
| | | ownerPo.setAge(null); |
| | | } |
| | | OwnerPo ownerPo = BeanConvertUtil.covertBean(reqJson, OwnerPo.class); |
| | | |
| | | String ownerPhotoUrl = reqJson.getString("ownerPhotoUrl"); |
| | | ownerPo.setFaceUrl(ownerPhotoUrl); |
| | | ownerPo.setAge("0"); |
| | | ownerPo.setUserId(userId); |
| | | ownerPo.setState(OwnerDto.STATE_FINISH); |
| | | ownerPo.setPersonType(OwnerDto.PERSON_TYPE_PERSON); |
| | | ownerPo.setOwnerTypeCd(OwnerDto.OWNER_TYPE_CD_MEMBER); |
| | | int flag = ownerV1InnerServiceSMOImpl.saveOwner(ownerPo); |
| | | if (flag < 1) { |
| | | throw new CmdException("保存业主失败"); |
| | | } |
| | | |
| | | //todo 保存照片 |
| | | photoSMOImpl.savePhoto(reqJson.getString("ownerPhoto"), |
| | | reqJson.getString("memberId"), |
| | | reqJson.getString("communityId"), |
| | | "10000"); |
| | | |
| | | //todo 保存属性 |
| | | dealOwnerAttr(reqJson, context); |
| | |
| | | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 生成小区楼ID |
| | | * |
| | | * @param paramObj 请求入参数据 |
| | | */ |
| | | private void generateMemberId(JSONObject paramObj) { |
| | | String memberId = GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_ownerId); |
| | | paramObj.put("memberId", memberId); |
| | | |
| | | } |
| | | |
| | | private void dealOwnerAttr(JSONObject paramObj, ICmdDataFlowContext cmdDataFlowContext) { |
| | | |