From 7935724516cb699835da888d59cd5b7bec5c6049 Mon Sep 17 00:00:00 2001
From: wuxw <928255095@qq.com>
Date: 星期四, 12 九月 2024 12:07:29 +0800
Subject: [PATCH] 完成业主功能的优化
---
service-user/src/main/java/com/java110/user/cmd/owner/DeleteOwnerCmd.java | 152 +++++++++++++++++++++++++++++++++++++-------------
1 files changed, 111 insertions(+), 41 deletions(-)
diff --git a/service-user/src/main/java/com/java110/user/cmd/owner/DeleteOwnerCmd.java b/service-user/src/main/java/com/java110/user/cmd/owner/DeleteOwnerCmd.java
index c570ebf..c4a47ad 100644
--- a/service-user/src/main/java/com/java110/user/cmd/owner/DeleteOwnerCmd.java
+++ b/service-user/src/main/java/com/java110/user/cmd/owner/DeleteOwnerCmd.java
@@ -1,34 +1,63 @@
package com.java110.user.cmd.owner;
-import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.java110.core.annotation.Java110Cmd;
import com.java110.core.annotation.Java110Transactional;
+import com.java110.core.context.Environment;
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.dto.RoomDto;
+import com.java110.doc.annotation.*;
+import com.java110.dto.account.AccountDto;
+import com.java110.dto.owner.OwnerAttrDto;
+import com.java110.dto.room.RoomDto;
import com.java110.dto.owner.OwnerAppUserDto;
import com.java110.dto.owner.OwnerCarDto;
import com.java110.dto.owner.OwnerDto;
-import com.java110.intf.user.IOwnerV1InnerServiceSMO;
+import com.java110.intf.acct.IAccountInnerServiceSMO;
+import com.java110.intf.user.*;
import com.java110.intf.community.IRoomInnerServiceSMO;
-import com.java110.intf.user.IOwnerAppUserInnerServiceSMO;
-import com.java110.intf.user.IOwnerAppUserV1InnerServiceSMO;
-import com.java110.intf.user.IOwnerCarInnerServiceSMO;
-import com.java110.intf.user.IOwnerInnerServiceSMO;
+import com.java110.po.account.AccountPo;
import com.java110.po.owner.OwnerAppUserPo;
+import com.java110.po.owner.OwnerAttrPo;
import com.java110.po.owner.OwnerPo;
import com.java110.utils.exception.CmdException;
import com.java110.utils.util.Assert;
import com.java110.utils.util.BeanConvertUtil;
-import com.java110.utils.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
+@Java110CmdDoc(title = "鍒犻櫎涓氫富",
+ description = "绗笁鏂圭郴缁燂紝姣斿鎷涘晢绯荤粺鍒犻櫎涓氫富淇℃伅",
+ httpMethod = "post",
+ url = "http://{ip}:{port}/app/owner.deleteOwner",
+ resource = "userDoc",
+ author = "鍚村鏂�",
+ serviceCode = "owner.deleteOwner",
+ seq = 11)
+
+@Java110ParamsDoc(params = {
+ @Java110ParamDoc(name = "communityId", length = 30, remark = "灏忓尯ID"),
+ @Java110ParamDoc(name = "memberId", length = 30, remark = "涓氫富ID"),
+})
+
+@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\"memberId\": 123123123,\n" +
+ "\t\"communityId\": \"2022121921870161\"\n" +
+ "}",
+ resBody = "{\"code\":0,\"msg\":\"鎴愬姛\"}"
+)
@Java110Cmd(serviceCode = "owner.deleteOwner")
-public class DeleteOwnerCmd extends AbstractServiceCmdListener {
+public class DeleteOwnerCmd extends Cmd {
@Autowired
private IOwnerInnerServiceSMO ownerInnerServiceSMOImpl;
@@ -48,25 +77,18 @@
@Autowired
private IOwnerAppUserV1InnerServiceSMO ownerAppUserV1InnerServiceSMOImpl;
+ @Autowired
+ private IOwnerAttrInnerServiceSMO ownerAttrInnerServiceSMOImpl;
+
+ @Autowired
+ private IAccountInnerServiceSMO accountInnerServiceSMOImpl;
+
@Override
public void validate(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) throws CmdException {
+ Environment.isDevEnv();
Assert.jsonObjectHaveKey(reqJson, "memberId", "璇锋眰鎶ユ枃涓湭鍖呭惈memberId");
Assert.jsonObjectHaveKey(reqJson, "communityId", "璇锋眰鎶ユ枃涓湭鍖呭惈communityId");
- if (!"1001".equals(reqJson.getString("ownerTypeCd"))) { //涓嶆槸涓氫富鎴愬憳涓嶇
- return;
- }
-
- OwnerDto ownerDto = new OwnerDto();
- ownerDto.setOwnerId(reqJson.getString("memberId"));
- ownerDto.setCommunityId(reqJson.getString("communityId"));
- ownerDto.setOwnerTypeCds(new String[]{OwnerDto.OWNER_TYPE_CD_MEMBER, OwnerDto.OWNER_TYPE_CD_RENTING});
-
- List<OwnerDto> ownerDtos = ownerInnerServiceSMOImpl.queryOwnerMembers(ownerDto);
-
- if (ownerDtos != null && ownerDtos.size() > 0) {
- throw new IllegalArgumentException("璇峰厛鍒犻櫎涓氫富涓嬬殑鎴愬憳");
- }
-
+ //todo 濡傛灉鏄笟涓�
if (OwnerDto.OWNER_TYPE_CD_OWNER.equals(reqJson.getString("ownerTypeCd"))) {
//ownerId 鍐欎负 memberId
reqJson.put("ownerId", reqJson.getString("memberId"));
@@ -86,35 +108,83 @@
//灏忓尯妤兼坊鍔犲埌灏忓尯涓�
//ownerBMOImpl.exitCommunityMember(reqJson, context);
}
+ if (!OwnerDto.OWNER_TYPE_CD_OWNER.equals(reqJson.getString("ownerTypeCd"))) { //涓嶆槸涓氫富鎴愬憳涓嶇
+ return;
+ }
+ OwnerDto ownerDto = new OwnerDto();
+ ownerDto.setOwnerId(reqJson.getString("memberId"));
+ ownerDto.setCommunityId(reqJson.getString("communityId"));
+ ownerDto.setOwnerTypeCds(new String[]{OwnerDto.OWNER_TYPE_CD_MEMBER});
+ List<OwnerDto> ownerDtos = ownerInnerServiceSMOImpl.queryOwnerMembers(ownerDto);
+ if (ownerDtos != null && ownerDtos.size() > 0) {
+ throw new IllegalArgumentException("璇峰厛鍒犻櫎涓氫富涓嬬殑鎴愬憳");
+ }
}
@Override
@Java110Transactional
public void doCmd(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) throws CmdException {
- JSONArray businesses = new JSONArray();
-
JSONObject businessOwner = new JSONObject();
businessOwner.put("memberId", reqJson.getString("memberId"));
businessOwner.put("communityId", reqJson.getString("communityId"));
-
OwnerPo ownerPo = BeanConvertUtil.covertBean(businessOwner, OwnerPo.class);
int flag = ownerV1InnerServiceSMOImpl.deleteOwner(ownerPo);
-
if (flag < 1) {
throw new CmdException("鍒犻櫎澶辫触");
}
- if (reqJson.containsKey("ownerTypeCd") && !StringUtil.isEmpty(reqJson.getString("ownerTypeCd")) && reqJson.getString("ownerTypeCd").equals("1001")) {
- OwnerAppUserDto ownerAppUserDto = new OwnerAppUserDto();
- ownerAppUserDto.setMemberId(reqJson.getString("ownerId"));
- //鏌ヨapp鐢ㄦ埛琛�
- List<OwnerAppUserDto> ownerAppUserDtos = ownerAppUserInnerServiceSMOImpl.queryOwnerAppUsers(ownerAppUserDto);
- if (ownerAppUserDtos != null && ownerAppUserDtos.size() > 0) {
- for (OwnerAppUserDto ownerAppUser : ownerAppUserDtos) {
- OwnerAppUserPo ownerAppUserPo = BeanConvertUtil.covertBean(ownerAppUser, OwnerAppUserPo.class);
- flag = ownerAppUserV1InnerServiceSMOImpl.saveOwnerAppUser(ownerAppUserPo);
- if (flag < 1) {
- throw new CmdException("鍒犻櫎澶辫触");
- }
+// if (!OwnerDto.OWNER_TYPE_CD_OWNER.equals(reqJson.getString("ownerTypeCd"))) {
+// return;
+// }
+
+ //鍒犻櫎缁戝畾涓氫富淇℃伅
+ OwnerAppUserDto ownerAppUserDto = new OwnerAppUserDto();
+ ownerAppUserDto.setMemberId(reqJson.getString("memberId"));
+ ownerAppUserDto.setCommunityId(reqJson.getString("communityId"));
+ //鏌ヨapp鐢ㄦ埛琛�
+ List<OwnerAppUserDto> ownerAppUserDtos = ownerAppUserInnerServiceSMOImpl.queryOwnerAppUsers(ownerAppUserDto);
+ if (ownerAppUserDtos == null && ownerAppUserDtos.size() < 1) {
+ return;
+ }
+ for (OwnerAppUserDto ownerAppUser : ownerAppUserDtos) {
+ OwnerAppUserPo ownerAppUserPo = BeanConvertUtil.covertBean(ownerAppUser, OwnerAppUserPo.class);
+ flag = ownerAppUserV1InnerServiceSMOImpl.deleteOwnerAppUser(ownerAppUserPo);
+ if (flag < 1) {
+ throw new CmdException("鍒犻櫎澶辫触");
+ }
+ //todo 搴旇鍒犻櫎鐢ㄦ埛
+// UserPo userPo = new UserPo();
+// userPo.setUserId(ownerAppUser.getUserId());
+// userV1InnerServiceSMOImpl.deleteUser(userPo);
+ }
+
+ //鍒犻櫎涓氫富灞炴�ц〃淇℃伅
+ OwnerAttrDto ownerAttrDto = new OwnerAttrDto();
+ ownerAttrDto.setMemberId(reqJson.getString("memberId"));
+ List<OwnerAttrDto> ownerAttrDtos = ownerAttrInnerServiceSMOImpl.queryOwnerAttrs(ownerAttrDto);
+ if (ownerAttrDtos != null && ownerAttrDtos.size() > 0) {
+ for (OwnerAttrDto ownerAttr : ownerAttrDtos) {
+ OwnerAttrPo ownerAttrPo = new OwnerAttrPo();
+ ownerAttrPo.setAttrId(ownerAttr.getAttrId());
+ ownerAttrPo.setStatusCd("1"); //0 鍙敤锛�1 涓嶅彲鐢�
+ int i = ownerAttrInnerServiceSMOImpl.updateOwnerAttrInfoInstance(ownerAttrPo);
+ if (i < 1) {
+ throw new CmdException("鍒犻櫎涓氫富灞炴�ц〃澶辫触");
+ }
+ }
+ }
+
+ //鍒犻櫎涓氫富璐︽埛淇℃伅
+ AccountDto accountDto = new AccountDto();
+ accountDto.setObjId(reqJson.getString("memberId"));
+ List<AccountDto> accountDtos = accountInnerServiceSMOImpl.queryAccounts(accountDto);
+ if (accountDtos != null && accountDtos.size() > 0) {
+ for (AccountDto account : accountDtos) {
+ AccountPo accountPo = new AccountPo();
+ accountPo.setAcctId(account.getAcctId());
+ accountPo.setStatusCd("1"); //0 鍙敤锛�1 涓嶅彲鐢�
+ int i = accountInnerServiceSMOImpl.updateAccount(accountPo);
+ if (i < 1) {
+ throw new CmdException("鍒犻櫎涓氫富璐︽埛淇℃伅澶辫触");
}
}
}
--
Gitblit v1.8.0