From fc7cf89b891a9ac5074daeff59d87e20510f385a Mon Sep 17 00:00:00 2001
From: yujian <yujian>
Date: 星期三, 13 三月 2019 15:22:47 +0800
Subject: [PATCH] Controller 层清理

---
 fanli/src/main/java/com/yeshi/fanli/controller/admin/UserInfoAdminController.java |  413 +++++++++++++++++++++++++++++-----------------------------
 1 files changed, 208 insertions(+), 205 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/admin/UserInfoAdminController.java b/fanli/src/main/java/com/yeshi/fanli/controller/admin/UserInfoAdminController.java
index 8f1ec66..c52afdd 100644
--- a/fanli/src/main/java/com/yeshi/fanli/controller/admin/UserInfoAdminController.java
+++ b/fanli/src/main/java/com/yeshi/fanli/controller/admin/UserInfoAdminController.java
@@ -258,8 +258,9 @@
 		out.print(JsonUtil.loadTrueResult(data));
 	}
 
+
 	/**
-	 * 鏌ヨ鐢ㄦ埛淇℃伅鍒楄〃--鐩稿叧鏁版嵁缁熻
+	 * 鏌ヨ鐢ㄦ埛淇℃伅鍒楄〃   姝e父鐢ㄦ埛/寮傚父鐢ㄦ埛
 	 * 
 	 * @param callback
 	 * @param pageIndex
@@ -442,176 +443,6 @@
 		}
 	}
 
-	/**
-	 * 淇敼鐢ㄦ埛鐨勭姸鎬併�佺瓑绾т俊鎭�
-	 * 
-	 * @param callback
-	 * @param userInfo
-	 * @param out
-	 */
-	@RequestMapping(value = "setInfo")
-	public void setInfo(String callback, UserInfo userInfo, PrintWriter out) {
-		try {
-
-			Long id = userInfo.getId();
-
-			if (id == null) {
-				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇蜂紶閫掓纭暟鎹�"));
-				return;
-			}
-
-			UserInfo currentInfo = userInfoService.selectByPKey(id);
-			if (currentInfo == null) {
-				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇ョ敤鎴峰凡涓嶅瓨鍦�"));
-				return;
-			}
-
-			currentInfo = new UserInfo(id);
-
-			boolean hasChange = false;
-
-			// 绛夌骇淇敼
-			Integer rank = userInfo.getRank();
-			if (rank != null) {
-				hasChange = true;
-				currentInfo.setRank(rank);
-			}
-
-			// 鐘舵�佷慨鏀�
-			Integer state = userInfo.getState();
-			if (state != null) {
-				hasChange = true;
-				currentInfo.setState(state);
-				if (state != null && state == UserInfo.STATE_FORBIDDEN)
-					currentInfo.setStateDesc("绠$悊鍛樺皝绂�");
-			}
-
-			if (hasChange) {
-				userInfoService.updateByPrimaryKeySelective(currentInfo);
-				UserInfo nowUser = userInfoService.selectByPKey(id);
-				if (state != null && state == UserInfo.STATE_FORBIDDEN) {
-					// 鍔犲叆灏佺鐨勮处鍙峰垪琛�
-					ForbiddenUserIdentifyCode forbiddenUserIdentifyCode = new ForbiddenUserIdentifyCode();
-					forbiddenUserIdentifyCode.setType(ForbiddenUserIdentifyCodeTypeEnum.wxUnionId);
-					forbiddenUserIdentifyCode.setIdentifyCode(nowUser.getWxUnionId());
-					forbiddenUserIdentifyCode.setBeiZhu(nowUser.getWxName());
-					try {
-						forbiddenUserIdentifyCodeService.addIdentifyCode(forbiddenUserIdentifyCode);
-					} catch (ForbiddenUserIdentifyCodeException e) {
-						e.printStackTrace();
-					}
-
-					// 鐢佃瘽鍙风爜
-					forbiddenUserIdentifyCode = new ForbiddenUserIdentifyCode();
-					forbiddenUserIdentifyCode.setType(ForbiddenUserIdentifyCodeTypeEnum.phone);
-					forbiddenUserIdentifyCode.setIdentifyCode(nowUser.getPhone());
-					try {
-						forbiddenUserIdentifyCodeService.addIdentifyCode(forbiddenUserIdentifyCode);
-					} catch (ForbiddenUserIdentifyCodeException e) {
-						e.printStackTrace();
-					}
-
-					// 娣樺疂
-					UserExtraTaoBaoInfo taoBao = userExtraTaoBaoInfoService.getByUid(nowUser.getId());
-					if (taoBao != null && !StringUtil.isNullOrEmpty(taoBao.getTaoBaoUid())) {
-						forbiddenUserIdentifyCode = new ForbiddenUserIdentifyCode();
-						forbiddenUserIdentifyCode.setType(ForbiddenUserIdentifyCodeTypeEnum.taobaoUid);
-						forbiddenUserIdentifyCode.setIdentifyCode(taoBao.getTaoBaoUid());
-						try {
-							forbiddenUserIdentifyCodeService.addIdentifyCode(forbiddenUserIdentifyCode);
-						} catch (ForbiddenUserIdentifyCodeException e) {
-							e.printStackTrace();
-						}
-					}
-
-					// 鏌ヨ鏀粯瀹濈粦瀹�
-
-					List<BindingAccount> list = bindingAccountService.getBindingAccountByUid(nowUser.getId());
-					if (list != null)
-						for (BindingAccount ba : list) {
-							forbiddenUserIdentifyCode = new ForbiddenUserIdentifyCode();
-							forbiddenUserIdentifyCode.setType(ForbiddenUserIdentifyCodeTypeEnum.alipayAccount);
-							forbiddenUserIdentifyCode.setIdentifyCode(ba.getAccount());
-							forbiddenUserIdentifyCode.setBeiZhu(ba.getName());
-							try {
-								forbiddenUserIdentifyCodeService.addIdentifyCode(forbiddenUserIdentifyCode);
-							} catch (ForbiddenUserIdentifyCodeException e) {
-								e.printStackTrace();
-							}
-						}
-				} else if (state != null && state == UserInfo.STATE_NORMAL) {
-					// 瑙e皝寰俊
-					ForbiddenUserIdentifyCode forbiddenUserIdentifyCode = forbiddenUserIdentifyCodeService
-							.listByTypeAndIdentifyCode(ForbiddenUserIdentifyCodeTypeEnum.wxUnionId,
-									nowUser.getWxUnionId());
-					if (forbiddenUserIdentifyCode != null)
-						forbiddenUserIdentifyCodeService.delete(forbiddenUserIdentifyCode);
-					// 瑙e皝鎵嬫満
-					forbiddenUserIdentifyCode = forbiddenUserIdentifyCodeService
-							.listByTypeAndIdentifyCode(ForbiddenUserIdentifyCodeTypeEnum.phone, nowUser.getPhone());
-					if (forbiddenUserIdentifyCode != null)
-						forbiddenUserIdentifyCodeService.delete(forbiddenUserIdentifyCode);
-					// 瑙e皝娣樺疂
-					UserExtraTaoBaoInfo taoBao = userExtraTaoBaoInfoService.getByUid(nowUser.getId());
-					if (taoBao != null && !StringUtil.isNullOrEmpty(taoBao.getTaoBaoUid())) {
-						forbiddenUserIdentifyCode = forbiddenUserIdentifyCodeService.listByTypeAndIdentifyCode(
-								ForbiddenUserIdentifyCodeTypeEnum.taobaoUid, taoBao.getTaoBaoUid());
-						if (forbiddenUserIdentifyCode != null)
-							forbiddenUserIdentifyCodeService.delete(forbiddenUserIdentifyCode);
-					}
-					// 瑙e皝鏀粯瀹�
-					List<BindingAccount> list = bindingAccountService.getBindingAccountByUid(nowUser.getId());
-					if (list != null)
-						for (BindingAccount ba : list) {
-							forbiddenUserIdentifyCode = forbiddenUserIdentifyCodeService.listByTypeAndIdentifyCode(
-									ForbiddenUserIdentifyCodeTypeEnum.alipayAccount, ba.getAccount());
-							if (forbiddenUserIdentifyCode != null)
-								forbiddenUserIdentifyCodeService.delete(forbiddenUserIdentifyCode);
-						}
-				}
-
-				JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("淇敼鎴愬姛"));
-			} else {
-				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏃犲彲淇敼鍐呭"));
-			}
-
-		} catch (
-
-		Exception e) {
-			e.printStackTrace();
-			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("淇敼澶辫触"));
-		}
-	}
-
-	/**
-	 * 鍒犻櫎缁戝畾鐨勮处鎴蜂俊鎭細 鏀粯瀹� 寰俊
-	 * 
-	 * @param callback
-	 * @param bindId
-	 * @param out
-	 */
-	@RequestMapping(value = "deleteBindingAccount")
-	public void deleteBindingAccount(String callback, Long bindId, PrintWriter out) {
-		try {
-
-			if (bindId == null) {
-				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇蜂紶閫掓纭暟鎹�"));
-				return;
-			}
-
-			int count = bindingAccountService.deleteByPrimaryKey(bindId);
-
-			if (count > 0) {
-				JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("鍒犻櫎鎴愬姛"));
-			} else {
-				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鍒犻櫎澶辫触"));
-			}
-
-		} catch (Exception e) {
-			e.printStackTrace();
-			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔寮傚父"));
-		}
-	}
 
 	/**
 	 * 
@@ -622,50 +453,72 @@
 	 *            闇�瑕佽В缁戠殑璐︽埛绫诲瀷
 	 */
 	@RequestMapping("unBindUserInfo")
-	public void unBindUserInfo(String callback, Long id, Integer type, PrintWriter out) {
+	public void unBindUserInfo(String callback, Long uid, String typeArray, PrintWriter out) {
 		try {
-
-			if (id == null) {
-				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("涓嶅瓨鍦ㄨ鐢ㄦ埛锛�"));
+			if (typeArray == null) {
+				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("娌℃湁鍙洿鏀圭殑鍐呭"));
+				return;
+			}
+			
+			Gson gson = new Gson();
+			List<Integer> list = gson.fromJson(typeArray, new TypeToken<ArrayList<Integer>>() {}.getType());
+			if (list == null || list.size() == 0) {
+				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("娌℃湁鍙洿鏀圭殑鍐呭"));
+				return;
+			}
+			
+			
+			if (uid == null) {
+				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鐢ㄦ埛id涓嶈兘涓虹┖"));
 				return;
 			}
 
-			if (type == null) {
-				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璐︽埛绫诲瀷涓嶅彲涓虹┖锛�"));
-				return;
-			}
-
-			UserInfo find = userInfoService.getUserById(id);
-
+			UserInfo find = userInfoService.getUserById(uid);
 			if (find == null) {
 				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("涓嶅瓨鍦ㄨ鐢ㄦ埛锛�"));
 				return;
 			}
-
-			String openid = find.getOpenid();
-			String wxUnionId = find.getWxUnionId();
-			String phone = find.getPhone();
-			if (1 == type) {
-				if (StringUtil.isNullOrEmpty(openid)) {
-					JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("褰撳墠鐢ㄦ埛鏈粦瀹氭敮浠樺疂锛�"));
+			
+			
+			for (Integer type: list) {
+				String openid = find.getOpenid();
+				String wxUnionId = find.getWxUnionId();
+				String phone = find.getPhone();
+				if (1 == type) {
+					if (StringUtil.isNullOrEmpty(openid)) {
+						JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("褰撳墠鐢ㄦ埛鏈粦瀹氭窐瀹濓紒"));
+						return;
+					} else {
+						userInfoService.deleteBindInfo(find, type);
+					}
+				} else if (2 == type) {
+					if (StringUtil.isNullOrEmpty(wxUnionId)) {
+						JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("褰撳墠鐢ㄦ埛鏈粦瀹氬井淇★紒"));
+						return;
+					} else {
+						userInfoService.deleteBindInfo(find, type);
+					}
+				} else if (3 == type) {
+					if (StringUtil.isNullOrEmpty(phone)) {
+						JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("褰撳墠鐢ㄦ埛鏈粦瀹氭墜鏈哄彿锛�"));
+						return;
+					} else {
+						userInfoService.deleteBindInfo(find, type);
+					}
+				} else if (4 == type) {
+					// 鏌ヨ鏀粯瀹濈粦瀹�
+					BindingAccount account = bindingAccountService.getBindingAccountByUidAndType(uid, BindingAccount.TYPE_ALIPAY);
+					if (account == null) {
+						JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("褰撳墠鐢ㄦ埛鏈粦瀹氭敮浠樺疂锛�"));
+						return;
+					} else {
+						bindingAccountService.deleteBindingAccount(account);
+					}
+				} else {
+					JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璐︽埛绫诲瀷涓嶅尮閰嶏紒"));
 					return;
 				}
-			} else if (2 == type) {
-				if (StringUtil.isNullOrEmpty(wxUnionId)) {
-					JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("褰撳墠鐢ㄦ埛鏈粦瀹氬井淇★紒"));
-					return;
-				}
-			} else if (3 == type) {
-				if (StringUtil.isNullOrEmpty(phone)) {
-					JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("褰撳墠鐢ㄦ埛鏈粦瀹氭墜鏈哄彿锛�"));
-					return;
-				}
-			} else {
-				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璐︽埛绫诲瀷鏈夎锛�"));
-				return;
 			}
-
-			userInfoService.deleteBindInfo(find, type);
 
 			JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("瑙g粦鎴愬姛"));
 
@@ -1273,6 +1126,157 @@
 	}
 
 	
+
+	/**
+	 * 灏佺鐢ㄦ埛ID
+	 * @param callback
+	 * @param uid
+	 * @param out
+	 */
+	@RequestMapping(value = "forbiddenUser")
+	public void forbiddenUser(String callback, Long uid, PrintWriter out) {
+		try {
+
+			if (uid == null) {
+				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇蜂紶閫掓纭暟鎹�"));
+				return;
+			}
+
+			UserInfo currentInfo = userInfoService.selectByPKey(uid);
+			if (currentInfo == null) {
+				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇ョ敤鎴峰凡涓嶅瓨鍦�"));
+				return;
+			}
+
+			currentInfo.setState(UserInfo.STATE_FORBIDDEN);
+			currentInfo.setStateDesc("绠$悊鍛樺皝绂�");
+			userInfoService.updateByPrimaryKeySelective(currentInfo);
+			
+			// 鍔犲叆灏佺鐨勮处鍙峰垪琛�
+			ForbiddenUserIdentifyCode forbiddenUserIdentifyCode = new ForbiddenUserIdentifyCode();
+			forbiddenUserIdentifyCode.setType(ForbiddenUserIdentifyCodeTypeEnum.wxUnionId);
+			forbiddenUserIdentifyCode.setIdentifyCode(currentInfo.getWxUnionId());
+			forbiddenUserIdentifyCode.setBeiZhu(currentInfo.getWxName());
+			try {
+				forbiddenUserIdentifyCodeService.addIdentifyCode(forbiddenUserIdentifyCode);
+			} catch (ForbiddenUserIdentifyCodeException e) {
+				e.printStackTrace();
+			}
+
+			// 鐢佃瘽鍙风爜
+			forbiddenUserIdentifyCode = new ForbiddenUserIdentifyCode();
+			forbiddenUserIdentifyCode.setType(ForbiddenUserIdentifyCodeTypeEnum.phone);
+			forbiddenUserIdentifyCode.setIdentifyCode(currentInfo.getPhone());
+			try {
+				forbiddenUserIdentifyCodeService.addIdentifyCode(forbiddenUserIdentifyCode);
+			} catch (ForbiddenUserIdentifyCodeException e) {
+				e.printStackTrace();
+			}
+
+			// 娣樺疂
+			UserExtraTaoBaoInfo taoBao = userExtraTaoBaoInfoService.getByUid(uid);
+			if (taoBao != null && !StringUtil.isNullOrEmpty(taoBao.getTaoBaoUid())) {
+				forbiddenUserIdentifyCode = new ForbiddenUserIdentifyCode();
+				forbiddenUserIdentifyCode.setType(ForbiddenUserIdentifyCodeTypeEnum.taobaoUid);
+				forbiddenUserIdentifyCode.setIdentifyCode(taoBao.getTaoBaoUid());
+				try {
+					forbiddenUserIdentifyCodeService.addIdentifyCode(forbiddenUserIdentifyCode);
+				} catch (ForbiddenUserIdentifyCodeException e) {
+					e.printStackTrace();
+				}
+			}
+
+			// 鏌ヨ鏀粯瀹濈粦瀹�
+
+			List<BindingAccount> list = bindingAccountService.getBindingAccountByUid(uid);
+			if (list != null) {
+				for (BindingAccount ba : list) {
+					forbiddenUserIdentifyCode = new ForbiddenUserIdentifyCode();
+					forbiddenUserIdentifyCode.setType(ForbiddenUserIdentifyCodeTypeEnum.alipayAccount);
+					forbiddenUserIdentifyCode.setIdentifyCode(ba.getAccount());
+					forbiddenUserIdentifyCode.setBeiZhu(ba.getName());
+					try {
+						forbiddenUserIdentifyCodeService.addIdentifyCode(forbiddenUserIdentifyCode);
+					} catch (ForbiddenUserIdentifyCodeException e) {
+						e.printStackTrace();
+					}
+				}
+			}
+			
+			JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("鐢ㄦ埛灏佺鎴愬姛"));
+			
+		} catch (Exception e) {
+			e.printStackTrace();
+			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔澶辫触"));
+		}
+	}
+	
+	
+	/**
+	 * 瑙i櫎灏佺鐢ㄦ埛ID
+	 * @param callback
+	 * @param uid
+	 * @param out
+	 */
+	@RequestMapping(value = "relieveForbiddenUser")
+	public void relieveForbiddenUser(String callback, Long uid, PrintWriter out) {
+		try {
+
+			if (uid == null) {
+				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇蜂紶閫掓纭暟鎹�"));
+				return;
+			}
+
+			UserInfo currentInfo = userInfoService.selectByPKey(uid);
+			if (currentInfo == null) {
+				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇ョ敤鎴峰凡涓嶅瓨鍦�"));
+				return;
+			}
+
+			currentInfo.setState(UserInfo.STATE_NORMAL);
+			currentInfo.setStateDesc("绠$悊鍛樺凡瑙e皝");
+			userInfoService.updateByPrimaryKeySelective(currentInfo);
+
+			// 瑙e皝寰俊
+			ForbiddenUserIdentifyCode forbiddenUserIdentifyCode = forbiddenUserIdentifyCodeService
+					.listByTypeAndIdentifyCode(ForbiddenUserIdentifyCodeTypeEnum.wxUnionId, currentInfo.getWxUnionId());
+			if (forbiddenUserIdentifyCode != null)
+				forbiddenUserIdentifyCodeService.delete(forbiddenUserIdentifyCode);
+
+			// 瑙e皝鎵嬫満
+			forbiddenUserIdentifyCode = forbiddenUserIdentifyCodeService
+					.listByTypeAndIdentifyCode(ForbiddenUserIdentifyCodeTypeEnum.phone, currentInfo.getPhone());
+			if (forbiddenUserIdentifyCode != null)
+				forbiddenUserIdentifyCodeService.delete(forbiddenUserIdentifyCode);
+
+			// 瑙e皝娣樺疂
+			UserExtraTaoBaoInfo taoBao = userExtraTaoBaoInfoService.getByUid(uid);
+			if (taoBao != null && !StringUtil.isNullOrEmpty(taoBao.getTaoBaoUid())) {
+				forbiddenUserIdentifyCode = forbiddenUserIdentifyCodeService
+						.listByTypeAndIdentifyCode(ForbiddenUserIdentifyCodeTypeEnum.taobaoUid, taoBao.getTaoBaoUid());
+				if (forbiddenUserIdentifyCode != null)
+					forbiddenUserIdentifyCodeService.delete(forbiddenUserIdentifyCode);
+			}
+
+			// 瑙e皝鏀粯瀹�
+			List<BindingAccount> list = bindingAccountService.getBindingAccountByUid(uid);
+			if (list != null) {
+				for (BindingAccount ba : list) {
+					forbiddenUserIdentifyCode = forbiddenUserIdentifyCodeService.listByTypeAndIdentifyCode(
+							ForbiddenUserIdentifyCodeTypeEnum.alipayAccount, ba.getAccount());
+					if (forbiddenUserIdentifyCode != null)
+						forbiddenUserIdentifyCodeService.delete(forbiddenUserIdentifyCode);
+				}
+			}
+
+			JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("鐢ㄦ埛瑙e皝鎴愬姛"));
+
+		} catch (Exception e) {
+			e.printStackTrace();
+			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔澶辫触"));
+		}
+	}
+	
 	
 	/**
 	 * 鐢ㄦ埛璐﹀彿- 灏佺/瑙e皝 
@@ -1299,7 +1303,6 @@
 			e.printStackTrace();
 			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔寮傚父"));
 		}
-		
 	}
 	
 }

--
Gitblit v1.8.0