From d7d9b601b2e4fdb663375993e2cfbdbd363df421 Mon Sep 17 00:00:00 2001
From: Your Name <you@example.com>
Date: 星期二, 11 七月 2023 22:17:37 +0800
Subject: [PATCH] Merge branch 'master' of http://git.homecommunity.cn/supervip/MicroCommunity
---
service-user/src/main/java/com/java110/user/cmd/owner/SaveOwnerCmd.java | 178 +++++++++++++++++++++++++++++++++++++++++++++++------------
1 files changed, 142 insertions(+), 36 deletions(-)
diff --git a/service-user/src/main/java/com/java110/user/cmd/owner/SaveOwnerCmd.java b/service-user/src/main/java/com/java110/user/cmd/owner/SaveOwnerCmd.java
index f144650..a1af135 100644
--- a/service-user/src/main/java/com/java110/user/cmd/owner/SaveOwnerCmd.java
+++ b/service-user/src/main/java/com/java110/user/cmd/owner/SaveOwnerCmd.java
@@ -5,53 +5,109 @@
import com.java110.core.annotation.Java110Cmd;
import com.java110.core.annotation.Java110Transactional;
import com.java110.core.context.ICmdDataFlowContext;
-import com.java110.core.event.cmd.AbstractServiceCmdListener;
+import com.java110.core.event.cmd.Cmd;
import com.java110.core.event.cmd.CmdEvent;
+import com.java110.core.factory.AuthenticationFactory;
import com.java110.core.factory.GenerateCodeFactory;
import com.java110.core.factory.SendSmsFactory;
+import com.java110.core.smo.IPhotoSMO;
+import com.java110.doc.annotation.*;
+import com.java110.dto.account.AccountDto;
+import com.java110.dto.community.CommunityDto;
import com.java110.dto.file.FileDto;
import com.java110.dto.msg.SmsDto;
import com.java110.dto.owner.OwnerDto;
+import com.java110.intf.acct.IAccountInnerServiceSMO;
import com.java110.intf.common.IFileInnerServiceSMO;
import com.java110.intf.common.IFileRelInnerServiceSMO;
import com.java110.intf.common.ISmsInnerServiceSMO;
-import com.java110.intf.user.IOwnerRoomRelV1InnerServiceSMO;
-import com.java110.intf.user.IOwnerV1InnerServiceSMO;
-import com.java110.intf.fee.IFeeConfigInnerServiceSMO;
-import com.java110.intf.user.IOwnerAttrInnerServiceSMO;
-import com.java110.intf.user.IOwnerInnerServiceSMO;
+import com.java110.intf.community.ICommunityInnerServiceSMO;
+import com.java110.intf.community.ICommunityV1InnerServiceSMO;
+import com.java110.intf.user.*;
+import com.java110.po.account.AccountPo;
import com.java110.po.file.FileRelPo;
+import com.java110.po.owner.OwnerAppUserPo;
import com.java110.po.owner.OwnerAttrPo;
import com.java110.po.owner.OwnerPo;
import com.java110.po.owner.OwnerRoomRelPo;
+import com.java110.po.user.UserPo;
import com.java110.utils.cache.MappingCache;
+import com.java110.utils.constant.MappingConstant;
+import com.java110.utils.constant.UserLevelConstant;
import com.java110.utils.exception.CmdException;
+import com.java110.utils.lock.DistributedLock;
import com.java110.utils.util.Assert;
import com.java110.utils.util.BeanConvertUtil;
import com.java110.utils.util.StringUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
+import java.util.ArrayList;
import java.util.List;
+/**
+ * 淇濆瓨 涓氫富
+ */
+@Java110CmdDoc(title = "娣诲姞涓氫富",
+ description = "绗笁鏂圭郴缁燂紝姣斿鎷涘晢绯荤粺鍚屾涓氫富淇℃伅",
+ httpMethod = "post",
+ url = "http://{ip}:{port}/app/owner.saveOwner",
+ resource = "userDoc",
+ author = "鍚村鏂�",
+ serviceCode = "owner.saveOwner",
+ seq = 9
+)
+
+@Java110ParamsDoc(params = {
+ @Java110ParamDoc(name = "communityId", length = 30, remark = "灏忓尯ID"),
+ @Java110ParamDoc(name = "name", length = 64, remark = "涓氫富鍚嶇О"),
+ @Java110ParamDoc(name = "link", length = 11, remark = "涓氫富鎵嬫満鍙�"),
+ @Java110ParamDoc(name = "idCard", length = 30, remark = "涓氫富韬唤璇佸彿"),
+ @Java110ParamDoc(name = "address", length = 512, remark = "鍦板潃"),
+ @Java110ParamDoc(name = "sex", length = 12, remark = "鎬у埆 鐢� 1 濂� 0"),
+ @Java110ParamDoc(name = "ownerTypeCd", length = 12, remark = "涓氫富绫诲瀷 1001 涓氫富 2002 瀹跺涵鎴愬憳 瀹跺涵鎴愬憳 闇�瑕佷紶涓氫富鐨刼wnerId"),
+ @Java110ParamDoc(name = "remark", length = 512, remark = "澶囨敞"),
+ @Java110ParamDoc(name = "ownerId", length = 30, remark = "涓氫富 鏃� 濉啓-1 瀹跺涵鎴愬憳鏃跺~鍐欎笟涓籌D"),
+ @Java110ParamDoc(name = "ownerPhoto", length = -1, remark = "涓氫富浜鸿劯 鐢ㄤ簬鍚屾闂ㄧ 浜鸿劯寮�闂�"),
+})
+
+@Java110ResponseDoc(
+ params = {
+ @Java110ParamDoc(name = "code", type = "int", length = 11, defaultValue = "0", remark = "杩斿洖缂栧彿锛�0 鎴愬姛 鍏朵粬澶辫触"),
+ @Java110ParamDoc(name = "msg", type = "String", length = 250, defaultValue = "鎴愬姛", remark = "鎻忚堪"),
+ }
+)
+
+@Java110ExampleDoc(
+ reqBody = "{\n" +
+ "\t\"name\": \"鐜嬬帇\",\n" +
+ "\t\"age\": \"\",\n" +
+ "\t\"link\": \"18909718888\",\n" +
+ "\t\"address\": \"寮犱笁\",\n" +
+ "\t\"sex\": \"0\",\n" +
+ "\t\"ownerTypeCd\": \"1001\",\n" +
+ "\t\"remark\": \"\",\n" +
+ "\t\"ownerId\": -1,\n" +
+ "\t\"ownerPhoto\": \"\",\n" +
+ "\t\"idCard\": \"\",\n" +
+ "\t\"communityId\": \"2022121921870161\"\n" +
+ "}",
+ resBody = "{\"code\":0,\"msg\":\"鎴愬姛\"}"
+)
@Java110Cmd(serviceCode = "owner.saveOwner")
-public class SaveOwnerCmd extends AbstractServiceCmdListener {
+public class SaveOwnerCmd extends Cmd {
@Autowired
private IOwnerInnerServiceSMO ownerInnerServiceSMOImpl;
-
@Autowired
private ISmsInnerServiceSMO smsInnerServiceSMOImpl;
@Autowired
- private IFileInnerServiceSMO fileInnerServiceSMOImpl;
-
- @Autowired
private IFileRelInnerServiceSMO fileRelInnerServiceSMOImpl;
@Autowired
- private IFeeConfigInnerServiceSMO feeConfigInnerServiceSMOImpl;
+ private IFileInnerServiceSMO fileInnerServiceSMOImpl;
@Autowired
private IOwnerV1InnerServiceSMO ownerV1InnerServiceSMOImpl;
@@ -61,6 +117,21 @@
@Autowired
private IOwnerRoomRelV1InnerServiceSMO ownerRoomRelV1InnerServiceSMOImpl;
+
+ @Autowired
+ private ICommunityV1InnerServiceSMO communityV1InnerServiceSMOImpl;
+
+ @Autowired
+ private IPhotoSMO photoSMOImpl;
+
+ @Autowired
+ private IOwnerAppUserV1InnerServiceSMO ownerAppUserV1InnerServiceSMOImpl;
+
+ @Autowired
+ private ICommunityInnerServiceSMO communityInnerServiceSMOImpl;
+ @Autowired
+ private IUserV1InnerServiceSMO userV1InnerServiceSMOImpl;
+
@Override
public void validate(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) throws CmdException {
@@ -84,7 +155,7 @@
smsDto.setTel(reqJson.getString("link"));
smsDto.setCode(reqJson.getString("msgCode"));
smsDto = smsInnerServiceSMOImpl.validateCode(smsDto);
- if (!smsDto.isSuccess() && "ON".equals(MappingCache.getValue(SendSmsFactory.SMS_SEND_SWITCH))) {
+ if (!smsDto.isSuccess() && "ON".equals(MappingCache.getValue(MappingConstant.SMS_DOMAIN,SendSmsFactory.SMS_SEND_SWITCH))) {
throw new IllegalArgumentException(smsDto.getMsg());
}
}
@@ -116,10 +187,14 @@
}
//鐢熸垚memberId
generateMemberId(reqJson);
+
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);
+ }
int flag = ownerV1InnerServiceSMOImpl.saveOwner(ownerPo);
if (flag < 1) {
throw new CmdException("淇濆瓨涓氫富澶辫触");
@@ -135,34 +210,65 @@
throw new CmdException("淇濆瓨涓氫富鎴垮眿鍏崇郴澶辫触");
}
}
- if (reqJson.containsKey("ownerPhoto") && !StringUtils.isEmpty(reqJson.getString("ownerPhoto"))) {
- FileDto fileDto = new FileDto();
- fileDto.setFileId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_file_id));
- fileDto.setFileName(fileDto.getFileId());
- fileDto.setContext(reqJson.getString("ownerPhoto"));
- fileDto.setSuffix("jpeg");
- fileDto.setCommunityId(reqJson.getString("communityId"));
- String fileName = fileInnerServiceSMOImpl.saveFile(fileDto);
- reqJson.put("ownerPhotoId", fileDto.getFileId());
- reqJson.put("fileSaveName", fileName);
- JSONObject businessUnit = new JSONObject();
- businessUnit.put("fileRelId", "-1");
- businessUnit.put("relTypeCd", "10000");
- businessUnit.put("saveWay", "table");
- businessUnit.put("objId", reqJson.getString("memberId"));
- businessUnit.put("fileRealName", reqJson.getString("ownerPhotoId"));
- businessUnit.put("fileSaveName", reqJson.getString("fileSaveName"));
- FileRelPo fileRelPo = BeanConvertUtil.covertBean(businessUnit, FileRelPo.class);
- flag = fileRelInnerServiceSMOImpl.saveFileRel(fileRelPo);
- if (flag < 1) {
- throw new CmdException("淇濆瓨涓氫富鎴垮眿鍏崇郴澶辫触");
- }
- }
+ //淇濆瓨鐓х墖
+ photoSMOImpl.savePhoto(reqJson.getString("ownerPhoto"),
+ reqJson.getString("memberId"),
+ reqJson.getString("communityId"),
+ "10000");
dealOwnerAttr(reqJson, cmdDataFlowContext);
+
+
+ String autoUser = MappingCache.getValue(MappingConstant.DOMAIN_SYSTEM_SWITCH, "AUTO_GENERATOR_OWNER_USER");
+
+ if (!"ON".equals(autoUser)) {
+ return;
+ }
+
+ CommunityDto communityDto = new CommunityDto();
+ communityDto.setCommunityId(ownerPo.getCommunityId());
+ List<CommunityDto> communityDtos = communityInnerServiceSMOImpl.queryCommunitys(communityDto);
+ Assert.listNotNull(communityDtos, "鏈寘鍚皬鍖轰俊鎭�");
+ CommunityDto tmpCommunityDto = communityDtos.get(0);
+
+ UserPo userPo = new UserPo();
+ userPo.setUserId(GenerateCodeFactory.getUserId());
+ userPo.setName(ownerPo.getName());
+ userPo.setTel(ownerPo.getLink());
+ userPo.setPassword(AuthenticationFactory.passwdMd5(ownerPo.getLink()));
+ userPo.setLevelCd(UserLevelConstant.USER_LEVEL_ORDINARY);
+ userPo.setAge(ownerPo.getAge());
+ userPo.setAddress(ownerPo.getAddress());
+ userPo.setSex(ownerPo.getSex());
+ flag = userV1InnerServiceSMOImpl.saveUser(userPo);
+ if (flag < 1) {
+ throw new CmdException("娉ㄥ唽澶辫触");
+ }
+
+ OwnerAppUserPo ownerAppUserPo = new OwnerAppUserPo();
+ //鐘舵�佺被鍨嬶紝10000 瀹℃牳涓紝12000 瀹℃牳鎴愬姛锛�13000 瀹℃牳澶辫触
+ ownerAppUserPo.setState("12000");
+ ownerAppUserPo.setAppTypeCd("10010");
+ ownerAppUserPo.setAppUserId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_appUserId));
+ ownerAppUserPo.setMemberId(ownerPo.getMemberId());
+ ownerAppUserPo.setCommunityName(tmpCommunityDto.getName());
+ ownerAppUserPo.setCommunityId(ownerPo.getCommunityId());
+ ownerAppUserPo.setAppUserName(ownerPo.getName());
+ ownerAppUserPo.setIdCard(ownerPo.getIdCard());
+ ownerAppUserPo.setAppType("WECHAT");
+ ownerAppUserPo.setLink(ownerPo.getLink());
+ ownerAppUserPo.setUserId(userPo.getUserId());
+ ownerAppUserPo.setOpenId("-1");
+
+ flag = ownerAppUserV1InnerServiceSMOImpl.saveOwnerAppUser(ownerAppUserPo);
+ if (flag < 1) {
+ throw new CmdException("娣诲姞鐢ㄦ埛涓氫富鍏崇郴澶辫触");
+ }
}
+
+
/**
* 鐢熸垚灏忓尯妤糏D
*
--
Gitblit v1.8.0