|
@@ -35,7 +35,7 @@ public class MyResourceController {
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private MatchmakerService matchmakerService;
|
|
private MatchmakerService matchmakerService;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 添加资源信息
|
|
* 添加资源信息
|
|
|
*
|
|
*
|
|
@@ -116,11 +116,11 @@ public class MyResourceController {
|
|
|
// 检查手机号是否已在资源表中存在(检查整个my_resource表,不限制红娘)
|
|
// 检查手机号是否已在资源表中存在(检查整个my_resource表,不限制红娘)
|
|
|
String phone = myResource.getPhone().trim();
|
|
String phone = myResource.getPhone().trim();
|
|
|
String backupPhone = myResource.getBackupPhone() != null ? myResource.getBackupPhone().trim() : null;
|
|
String backupPhone = myResource.getBackupPhone() != null ? myResource.getBackupPhone().trim() : null;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
System.out.println("=== 开始检查手机号重复 ===");
|
|
System.out.println("=== 开始检查手机号重复 ===");
|
|
|
System.out.println("主手机号: " + phone);
|
|
System.out.println("主手机号: " + phone);
|
|
|
System.out.println("备用手机号: " + backupPhone);
|
|
System.out.println("备用手机号: " + backupPhone);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// 检查主手机号是否已存在(使用count更可靠)
|
|
// 检查主手机号是否已存在(使用count更可靠)
|
|
|
QueryWrapper<MyResource> phoneQueryWrapper = new QueryWrapper<>();
|
|
QueryWrapper<MyResource> phoneQueryWrapper = new QueryWrapper<>();
|
|
|
phoneQueryWrapper.eq("phone", phone);
|
|
phoneQueryWrapper.eq("phone", phone);
|
|
@@ -131,7 +131,7 @@ public class MyResourceController {
|
|
|
System.out.println("找到重复的主手机号,资源名称: " + (existingResourceByPhone != null ? existingResourceByPhone.getName() : "未知"));
|
|
System.out.println("找到重复的主手机号,资源名称: " + (existingResourceByPhone != null ? existingResourceByPhone.getName() : "未知"));
|
|
|
return Result.error("手机号 " + phone + " 已被资源\"" + (existingResourceByPhone != null && existingResourceByPhone.getName() != null ? existingResourceByPhone.getName() : "未知") + "\"使用,不能重复添加");
|
|
return Result.error("手机号 " + phone + " 已被资源\"" + (existingResourceByPhone != null && existingResourceByPhone.getName() != null ? existingResourceByPhone.getName() : "未知") + "\"使用,不能重复添加");
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// 检查主手机号是否作为其他资源的备用手机号存在
|
|
// 检查主手机号是否作为其他资源的备用手机号存在
|
|
|
QueryWrapper<MyResource> phoneAsBackupQueryWrapper = new QueryWrapper<>();
|
|
QueryWrapper<MyResource> phoneAsBackupQueryWrapper = new QueryWrapper<>();
|
|
|
phoneAsBackupQueryWrapper.eq("backup_phone", phone);
|
|
phoneAsBackupQueryWrapper.eq("backup_phone", phone);
|
|
@@ -142,7 +142,7 @@ public class MyResourceController {
|
|
|
System.out.println("找到重复的主手机号(作为备用手机号),资源名称: " + (existingResourceByPhoneAsBackup != null ? existingResourceByPhoneAsBackup.getName() : "未知"));
|
|
System.out.println("找到重复的主手机号(作为备用手机号),资源名称: " + (existingResourceByPhoneAsBackup != null ? existingResourceByPhoneAsBackup.getName() : "未知"));
|
|
|
return Result.error("手机号 " + phone + " 已被资源\"" + (existingResourceByPhoneAsBackup != null && existingResourceByPhoneAsBackup.getName() != null ? existingResourceByPhoneAsBackup.getName() : "未知") + "\"作为备用手机号使用,不能重复添加");
|
|
return Result.error("手机号 " + phone + " 已被资源\"" + (existingResourceByPhoneAsBackup != null && existingResourceByPhoneAsBackup.getName() != null ? existingResourceByPhoneAsBackup.getName() : "未知") + "\"作为备用手机号使用,不能重复添加");
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// 检查备用手机号是否已存在(如果提供了备用手机号)
|
|
// 检查备用手机号是否已存在(如果提供了备用手机号)
|
|
|
if (backupPhone != null && !backupPhone.isEmpty()) {
|
|
if (backupPhone != null && !backupPhone.isEmpty()) {
|
|
|
// 检查备用手机号是否作为主手机号存在
|
|
// 检查备用手机号是否作为主手机号存在
|
|
@@ -155,7 +155,7 @@ public class MyResourceController {
|
|
|
System.out.println("找到重复的备用手机号(作为主手机号),资源名称: " + (existingResourceByBackupAsMain != null ? existingResourceByBackupAsMain.getName() : "未知"));
|
|
System.out.println("找到重复的备用手机号(作为主手机号),资源名称: " + (existingResourceByBackupAsMain != null ? existingResourceByBackupAsMain.getName() : "未知"));
|
|
|
return Result.error("备用手机号 " + backupPhone + " 已被资源\"" + (existingResourceByBackupAsMain != null && existingResourceByBackupAsMain.getName() != null ? existingResourceByBackupAsMain.getName() : "未知") + "\"作为主手机号使用,不能重复添加");
|
|
return Result.error("备用手机号 " + backupPhone + " 已被资源\"" + (existingResourceByBackupAsMain != null && existingResourceByBackupAsMain.getName() != null ? existingResourceByBackupAsMain.getName() : "未知") + "\"作为主手机号使用,不能重复添加");
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// 检查备用手机号是否作为备用手机号存在
|
|
// 检查备用手机号是否作为备用手机号存在
|
|
|
QueryWrapper<MyResource> backupPhoneQueryWrapper = new QueryWrapper<>();
|
|
QueryWrapper<MyResource> backupPhoneQueryWrapper = new QueryWrapper<>();
|
|
|
backupPhoneQueryWrapper.eq("backup_phone", backupPhone);
|
|
backupPhoneQueryWrapper.eq("backup_phone", backupPhone);
|
|
@@ -167,9 +167,9 @@ public class MyResourceController {
|
|
|
return Result.error("备用手机号 " + backupPhone + " 已被资源\"" + (existingResourceByBackup != null && existingResourceByBackup.getName() != null ? existingResourceByBackup.getName() : "未知") + "\"使用,不能重复添加");
|
|
return Result.error("备用手机号 " + backupPhone + " 已被资源\"" + (existingResourceByBackup != null && existingResourceByBackup.getName() != null ? existingResourceByBackup.getName() : "未知") + "\"使用,不能重复添加");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
System.out.println("=== 手机号检查通过,没有重复 ===");
|
|
System.out.println("=== 手机号检查通过,没有重复 ===");
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// 根据手机号查询用户表中是否存在该用户
|
|
// 根据手机号查询用户表中是否存在该用户
|
|
|
QueryWrapper<User> userQueryWrapper = new QueryWrapper<>();
|
|
QueryWrapper<User> userQueryWrapper = new QueryWrapper<>();
|
|
|
userQueryWrapper.eq("phone", myResource.getPhone());
|
|
userQueryWrapper.eq("phone", myResource.getPhone());
|
|
@@ -209,7 +209,7 @@ public class MyResourceController {
|
|
|
QueryWrapper<Matchmaker> matchmakerQueryWrapper = new QueryWrapper<>();
|
|
QueryWrapper<Matchmaker> matchmakerQueryWrapper = new QueryWrapper<>();
|
|
|
matchmakerQueryWrapper.eq("user_id", currentUserId);
|
|
matchmakerQueryWrapper.eq("user_id", currentUserId);
|
|
|
Matchmaker matchmaker = matchmakerService.getOne(matchmakerQueryWrapper);
|
|
Matchmaker matchmaker = matchmakerService.getOne(matchmakerQueryWrapper);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
if (matchmaker != null && matchmaker.getMatchmakerId() != null) {
|
|
if (matchmaker != null && matchmaker.getMatchmakerId() != null) {
|
|
|
// 查询到红娘信息,设置matchmaker_id
|
|
// 查询到红娘信息,设置matchmaker_id
|
|
|
myResource.setMatchmakerId(matchmaker.getMatchmakerId());
|
|
myResource.setMatchmakerId(matchmaker.getMatchmakerId());
|
|
@@ -228,11 +228,11 @@ public class MyResourceController {
|
|
|
myResource.setStatus(0);
|
|
myResource.setStatus(0);
|
|
|
System.out.println("设置默认审核状态: 0 (待审核)");
|
|
System.out.println("设置默认审核状态: 0 (待审核)");
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// 判断资源类型(根据isUser字段:1是资源,0是线索)
|
|
// 判断资源类型(根据isUser字段:1是资源,0是线索)
|
|
|
String resourceType = (myResource.getIsUser() != null && myResource.getIsUser() == 1) ? "资源" : "线索";
|
|
String resourceType = (myResource.getIsUser() != null && myResource.getIsUser() == 1) ? "资源" : "线索";
|
|
|
System.out.println("资源类型: " + resourceType + " (isUser=" + myResource.getIsUser() + ")");
|
|
System.out.println("资源类型: " + resourceType + " (isUser=" + myResource.getIsUser() + ")");
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// 保存资源信息和标签关联
|
|
// 保存资源信息和标签关联
|
|
|
boolean success = myResourceService.addResource(myResource, tagIds);
|
|
boolean success = myResourceService.addResource(myResource, tagIds);
|
|
|
if (success) {
|
|
if (success) {
|
|
@@ -241,12 +241,12 @@ public class MyResourceController {
|
|
|
resultData.put("resource", myResource);
|
|
resultData.put("resource", myResource);
|
|
|
resultData.put("resourceType", resourceType);
|
|
resultData.put("resourceType", resourceType);
|
|
|
resultData.put("isUser", myResource.getIsUser());
|
|
resultData.put("isUser", myResource.getIsUser());
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
String successMessage = "资源信息添加成功";
|
|
String successMessage = "资源信息添加成功";
|
|
|
if (resourceType.equals("线索")) {
|
|
if (resourceType.equals("线索")) {
|
|
|
successMessage = "线索信息添加成功";
|
|
successMessage = "线索信息添加成功";
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
return Result.success(successMessage, resultData);
|
|
return Result.success(successMessage, resultData);
|
|
|
} else {
|
|
} else {
|
|
|
return Result.error("资源信息添加失败");
|
|
return Result.error("资源信息添加失败");
|
|
@@ -750,10 +750,10 @@ public class MyResourceController {
|
|
|
return Result.error("查询标签ID列表失败:" + e.getMessage());
|
|
return Result.error("查询标签ID列表失败:" + e.getMessage());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 检查手机号是否已存在(检查整个my_resource表)
|
|
* 检查手机号是否已存在(检查整个my_resource表)
|
|
|
- *
|
|
|
|
|
|
|
+ *
|
|
|
* @param phone 主手机号
|
|
* @param phone 主手机号
|
|
|
* @param backupPhone 备用手机号(可选)
|
|
* @param backupPhone 备用手机号(可选)
|
|
|
* @return 检查结果,如果存在则返回资源信息
|
|
* @return 检查结果,如果存在则返回资源信息
|
|
@@ -769,14 +769,14 @@ public class MyResourceController {
|
|
|
result.put("phoneAsBackupExists", false);
|
|
result.put("phoneAsBackupExists", false);
|
|
|
result.put("backupPhoneAsMainExists", false);
|
|
result.put("backupPhoneAsMainExists", false);
|
|
|
result.put("existingResource", null);
|
|
result.put("existingResource", null);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
String phoneTrimmed = phone != null ? phone.trim() : "";
|
|
String phoneTrimmed = phone != null ? phone.trim() : "";
|
|
|
String backupPhoneTrimmed = backupPhone != null ? backupPhone.trim() : null;
|
|
String backupPhoneTrimmed = backupPhone != null ? backupPhone.trim() : null;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
System.out.println("=== check-phone 接口调用 ===");
|
|
System.out.println("=== check-phone 接口调用 ===");
|
|
|
System.out.println("主手机号: " + phoneTrimmed);
|
|
System.out.println("主手机号: " + phoneTrimmed);
|
|
|
System.out.println("备用手机号: " + backupPhoneTrimmed);
|
|
System.out.println("备用手机号: " + backupPhoneTrimmed);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// 检查主手机号是否已存在(使用count更可靠)
|
|
// 检查主手机号是否已存在(使用count更可靠)
|
|
|
QueryWrapper<MyResource> phoneQueryWrapper = new QueryWrapper<>();
|
|
QueryWrapper<MyResource> phoneQueryWrapper = new QueryWrapper<>();
|
|
|
phoneQueryWrapper.eq("phone", phoneTrimmed);
|
|
phoneQueryWrapper.eq("phone", phoneTrimmed);
|
|
@@ -789,7 +789,7 @@ public class MyResourceController {
|
|
|
System.out.println("找到重复的主手机号,资源名称: " + (existingResourceByPhone != null ? existingResourceByPhone.getName() : "未知"));
|
|
System.out.println("找到重复的主手机号,资源名称: " + (existingResourceByPhone != null ? existingResourceByPhone.getName() : "未知"));
|
|
|
return Result.success(result);
|
|
return Result.success(result);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// 检查主手机号是否作为备用手机号存在
|
|
// 检查主手机号是否作为备用手机号存在
|
|
|
QueryWrapper<MyResource> phoneAsBackupQueryWrapper = new QueryWrapper<>();
|
|
QueryWrapper<MyResource> phoneAsBackupQueryWrapper = new QueryWrapper<>();
|
|
|
phoneAsBackupQueryWrapper.eq("backup_phone", phoneTrimmed);
|
|
phoneAsBackupQueryWrapper.eq("backup_phone", phoneTrimmed);
|
|
@@ -802,7 +802,7 @@ public class MyResourceController {
|
|
|
System.out.println("找到重复的主手机号(作为备用手机号),资源名称: " + (existingResourceByPhoneAsBackup != null ? existingResourceByPhoneAsBackup.getName() : "未知"));
|
|
System.out.println("找到重复的主手机号(作为备用手机号),资源名称: " + (existingResourceByPhoneAsBackup != null ? existingResourceByPhoneAsBackup.getName() : "未知"));
|
|
|
return Result.success(result);
|
|
return Result.success(result);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// 如果提供了备用手机号,检查备用手机号
|
|
// 如果提供了备用手机号,检查备用手机号
|
|
|
if (backupPhoneTrimmed != null && !backupPhoneTrimmed.isEmpty()) {
|
|
if (backupPhoneTrimmed != null && !backupPhoneTrimmed.isEmpty()) {
|
|
|
// 检查备用手机号是否作为主手机号存在
|
|
// 检查备用手机号是否作为主手机号存在
|
|
@@ -817,7 +817,7 @@ public class MyResourceController {
|
|
|
System.out.println("找到重复的备用手机号(作为主手机号),资源名称: " + (existingResourceByBackupAsMain != null ? existingResourceByBackupAsMain.getName() : "未知"));
|
|
System.out.println("找到重复的备用手机号(作为主手机号),资源名称: " + (existingResourceByBackupAsMain != null ? existingResourceByBackupAsMain.getName() : "未知"));
|
|
|
return Result.success(result);
|
|
return Result.success(result);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// 检查备用手机号是否作为备用手机号存在
|
|
// 检查备用手机号是否作为备用手机号存在
|
|
|
QueryWrapper<MyResource> backupPhoneQueryWrapper = new QueryWrapper<>();
|
|
QueryWrapper<MyResource> backupPhoneQueryWrapper = new QueryWrapper<>();
|
|
|
backupPhoneQueryWrapper.eq("backup_phone", backupPhoneTrimmed);
|
|
backupPhoneQueryWrapper.eq("backup_phone", backupPhoneTrimmed);
|
|
@@ -831,7 +831,7 @@ public class MyResourceController {
|
|
|
return Result.success(result);
|
|
return Result.success(result);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
System.out.println("=== check-phone 检查通过,没有重复 ===");
|
|
System.out.println("=== check-phone 检查通过,没有重复 ===");
|
|
|
return Result.success(result);
|
|
return Result.success(result);
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
@@ -839,12 +839,12 @@ public class MyResourceController {
|
|
|
return Result.error("检查手机号失败:" + e.getMessage());
|
|
return Result.error("检查手机号失败:" + e.getMessage());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 批量检查并更新线索用户的注册状态
|
|
* 批量检查并更新线索用户的注册状态
|
|
|
* 定时刷新线索列表中的所有线索用户,根据线索用户的手机号在users表中检索
|
|
* 定时刷新线索列表中的所有线索用户,根据线索用户的手机号在users表中检索
|
|
|
* 如果users表中存在该用户,则更新该线索用户的is_user字段为1和user_id字段
|
|
* 如果users表中存在该用户,则更新该线索用户的is_user字段为1和user_id字段
|
|
|
- *
|
|
|
|
|
|
|
+ *
|
|
|
* @param matchmakerId 红娘ID(可选,如果提供则只检查该红娘的线索)
|
|
* @param matchmakerId 红娘ID(可选,如果提供则只检查该红娘的线索)
|
|
|
* @return 更新结果,包含更新的资源数量
|
|
* @return 更新结果,包含更新的资源数量
|
|
|
*/
|
|
*/
|
|
@@ -856,18 +856,243 @@ public class MyResourceController {
|
|
|
if (matchmakerId != null) {
|
|
if (matchmakerId != null) {
|
|
|
System.out.println("红娘ID: " + matchmakerId);
|
|
System.out.println("红娘ID: " + matchmakerId);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
int updateCount = myResourceService.batchCheckAndUpdateClueRegistrationStatus(matchmakerId);
|
|
int updateCount = myResourceService.batchCheckAndUpdateClueRegistrationStatus(matchmakerId);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
java.util.Map<String, Object> result = new java.util.HashMap<>();
|
|
java.util.Map<String, Object> result = new java.util.HashMap<>();
|
|
|
result.put("updateCount", updateCount);
|
|
result.put("updateCount", updateCount);
|
|
|
result.put("message", "批量检查完成,共更新 " + updateCount + " 条线索用户记录");
|
|
result.put("message", "批量检查完成,共更新 " + updateCount + " 条线索用户记录");
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
return Result.success("批量检查完成", result);
|
|
return Result.success("批量检查完成", result);
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
|
return Result.error("批量检查线索用户注册状态失败:" + e.getMessage());
|
|
return Result.error("批量检查线索用户注册状态失败:" + e.getMessage());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 搜索资源(按姓名或手机号)
|
|
|
|
|
+ * 用于撮合成功审核页面的下拉搜索
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param matchmakerId 红娘ID
|
|
|
|
|
+ * @param keyword 搜索关键词(姓名或手机号)
|
|
|
|
|
+ * @param gender 性别筛选(1-男,2-女,可选)
|
|
|
|
|
+ * @return 匹配的资源列表
|
|
|
|
|
+ */
|
|
|
|
|
+ @GetMapping("/search")
|
|
|
|
|
+ public Result<java.util.List<MyResourceVO>> searchResources(
|
|
|
|
|
+ @RequestParam Integer matchmakerId,
|
|
|
|
|
+ @RequestParam(required = false) String keyword,
|
|
|
|
|
+ @RequestParam(required = false) Integer gender) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ System.out.println("=== 搜索资源 ===");
|
|
|
|
|
+ System.out.println("matchmakerId: " + matchmakerId);
|
|
|
|
|
+ System.out.println("keyword: " + keyword);
|
|
|
|
|
+ System.out.println("gender: " + gender);
|
|
|
|
|
+
|
|
|
|
|
+ java.util.List<MyResourceVO> resources = myResourceService.searchResources(matchmakerId, keyword, gender);
|
|
|
|
|
+
|
|
|
|
|
+ System.out.println("搜索结果数量: " + resources.size());
|
|
|
|
|
+ return Result.success(resources);
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ return Result.error("搜索资源失败:" + e.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 获取资源下拉列表(用于撮合成功审核页面)
|
|
|
|
|
+ * 返回简化的资源信息:resourceId, name, avatarUrl, gender, phone
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param matchmakerId 红娘ID
|
|
|
|
|
+ * @param gender 性别筛选(1-男,2-女)
|
|
|
|
|
+ * @return 资源下拉列表
|
|
|
|
|
+ */
|
|
|
|
|
+ @GetMapping("/dropdown")
|
|
|
|
|
+ public Result<java.util.List<java.util.Map<String, Object>>> getResourceDropdown(
|
|
|
|
|
+ @RequestParam Integer matchmakerId,
|
|
|
|
|
+ @RequestParam(required = false) Integer gender) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ System.out.println("=== 获取资源下拉列表 ===");
|
|
|
|
|
+ System.out.println("matchmakerId: " + matchmakerId);
|
|
|
|
|
+ System.out.println("gender: " + gender);
|
|
|
|
|
+
|
|
|
|
|
+ java.util.List<MyResourceVO> resources = myResourceService.searchResources(matchmakerId, null, gender);
|
|
|
|
|
+
|
|
|
|
|
+ // 转换为简化的下拉列表格式
|
|
|
|
|
+ java.util.List<java.util.Map<String, Object>> dropdown = new java.util.ArrayList<>();
|
|
|
|
|
+ for (MyResourceVO resource : resources) {
|
|
|
|
|
+ java.util.Map<String, Object> item = new java.util.HashMap<>();
|
|
|
|
|
+ item.put("resourceId", resource.getResourceId());
|
|
|
|
|
+ item.put("name", resource.getName());
|
|
|
|
|
+ item.put("avatarUrl", resource.getAvatarUrl());
|
|
|
|
|
+ item.put("gender", resource.getGender());
|
|
|
|
|
+ item.put("phone", resource.getPhone());
|
|
|
|
|
+ item.put("age", resource.getAge());
|
|
|
|
|
+ dropdown.add(item);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ System.out.println("下拉列表数量: " + dropdown.size());
|
|
|
|
|
+ return Result.success(dropdown);
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ return Result.error("获取资源下拉列表失败:" + e.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 获取已注册用户的资源下拉列表(用于撮合成功审核页面)
|
|
|
|
|
+ * 只返回user_id不为空的资源(即已注册为平台用户的资源)
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param matchmakerId 红娘ID
|
|
|
|
|
+ * @param gender 性别筛选(1-男,2-女)
|
|
|
|
|
+ * @return 已注册用户的资源下拉列表
|
|
|
|
|
+ */
|
|
|
|
|
+ @GetMapping("/registered-dropdown")
|
|
|
|
|
+ public Result<java.util.List<java.util.Map<String, Object>>> getRegisteredResourceDropdown(
|
|
|
|
|
+ @RequestParam Integer matchmakerId,
|
|
|
|
|
+ @RequestParam(required = false) Integer gender) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ System.out.println("=== 获取已注册用户资源下拉列表 ===");
|
|
|
|
|
+ System.out.println("matchmakerId: " + matchmakerId);
|
|
|
|
|
+ System.out.println("gender: " + gender);
|
|
|
|
|
+
|
|
|
|
|
+ // 查询资源列表
|
|
|
|
|
+ com.baomidou.mybatisplus.core.conditions.query.QueryWrapper<MyResource> queryWrapper =
|
|
|
|
|
+ new com.baomidou.mybatisplus.core.conditions.query.QueryWrapper<>();
|
|
|
|
|
+ queryWrapper.eq("matchmaker_id", matchmakerId);
|
|
|
|
|
+ // 只查询user_id不为空的资源(已注册用户)
|
|
|
|
|
+ queryWrapper.isNotNull("user_id");
|
|
|
|
|
+
|
|
|
|
|
+ // 性别筛选
|
|
|
|
|
+ if (gender != null) {
|
|
|
|
|
+ queryWrapper.eq("gender", gender);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 按创建时间降序
|
|
|
|
|
+ queryWrapper.orderByDesc("create_time");
|
|
|
|
|
+ queryWrapper.last("LIMIT 100");
|
|
|
|
|
+
|
|
|
|
|
+ java.util.List<MyResource> resources = myResourceService.list(queryWrapper);
|
|
|
|
|
+ System.out.println("查询到已注册资源数量: " + resources.size());
|
|
|
|
|
+
|
|
|
|
|
+ // 转换为简化的下拉列表格式,并查询用户头像
|
|
|
|
|
+ java.util.List<java.util.Map<String, Object>> dropdown = new java.util.ArrayList<>();
|
|
|
|
|
+ for (MyResource resource : resources) {
|
|
|
|
|
+ java.util.Map<String, Object> item = new java.util.HashMap<>();
|
|
|
|
|
+ item.put("resourceId", resource.getResourceId());
|
|
|
|
|
+ item.put("userId", resource.getUserId());
|
|
|
|
|
+ item.put("name", resource.getName());
|
|
|
|
|
+ item.put("gender", resource.getGender());
|
|
|
|
|
+ item.put("phone", resource.getPhone());
|
|
|
|
|
+ item.put("age", resource.getAge());
|
|
|
|
|
+
|
|
|
|
|
+ // 查询用户头像
|
|
|
|
|
+ String avatarUrl = "/static/default-avatar.svg";
|
|
|
|
|
+ if (resource.getUserId() != null) {
|
|
|
|
|
+ com.baomidou.mybatisplus.core.conditions.query.QueryWrapper<User> userQuery =
|
|
|
|
|
+ new com.baomidou.mybatisplus.core.conditions.query.QueryWrapper<>();
|
|
|
|
|
+ userQuery.eq("user_id", resource.getUserId());
|
|
|
|
|
+ User user = userMapper.selectOne(userQuery);
|
|
|
|
|
+ if (user != null && user.getAvatarUrl() != null) {
|
|
|
|
|
+ avatarUrl = user.getAvatarUrl();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ item.put("avatarUrl", avatarUrl);
|
|
|
|
|
+
|
|
|
|
|
+ dropdown.add(item);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ System.out.println("已注册用户下拉列表数量: " + dropdown.size());
|
|
|
|
|
+ return Result.success(dropdown);
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ return Result.error("获取已注册用户资源下拉列表失败:" + e.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 搜索已注册用户的资源(按姓名或手机号)
|
|
|
|
|
+ * 只返回user_id不为空的资源
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param matchmakerId 红娘ID
|
|
|
|
|
+ * @param keyword 搜索关键词(姓名或手机号)
|
|
|
|
|
+ * @param gender 性别筛选(1-男,2-女,可选)
|
|
|
|
|
+ * @return 匹配的已注册用户资源列表
|
|
|
|
|
+ */
|
|
|
|
|
+ @GetMapping("/registered-search")
|
|
|
|
|
+ public Result<java.util.List<java.util.Map<String, Object>>> searchRegisteredResources(
|
|
|
|
|
+ @RequestParam Integer matchmakerId,
|
|
|
|
|
+ @RequestParam(required = false) String keyword,
|
|
|
|
|
+ @RequestParam(required = false) Integer gender) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ System.out.println("=== 搜索已注册用户资源 ===");
|
|
|
|
|
+ System.out.println("matchmakerId: " + matchmakerId);
|
|
|
|
|
+ System.out.println("keyword: " + keyword);
|
|
|
|
|
+ System.out.println("gender: " + gender);
|
|
|
|
|
+
|
|
|
|
|
+ // 构建查询条件
|
|
|
|
|
+ com.baomidou.mybatisplus.core.conditions.query.QueryWrapper<MyResource> queryWrapper =
|
|
|
|
|
+ new com.baomidou.mybatisplus.core.conditions.query.QueryWrapper<>();
|
|
|
|
|
+ queryWrapper.eq("matchmaker_id", matchmakerId);
|
|
|
|
|
+ // 只查询user_id不为空的资源(已注册用户)
|
|
|
|
|
+ queryWrapper.isNotNull("user_id");
|
|
|
|
|
+
|
|
|
|
|
+ // 性别筛选
|
|
|
|
|
+ if (gender != null) {
|
|
|
|
|
+ queryWrapper.eq("gender", gender);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 关键词搜索(姓名或手机号)
|
|
|
|
|
+ if (keyword != null && !keyword.trim().isEmpty()) {
|
|
|
|
|
+ String kw = keyword.trim();
|
|
|
|
|
+ queryWrapper.and(wrapper ->
|
|
|
|
|
+ wrapper.like("name", kw)
|
|
|
|
|
+ .or()
|
|
|
|
|
+ .like("phone", kw)
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 按创建时间降序
|
|
|
|
|
+ queryWrapper.orderByDesc("create_time");
|
|
|
|
|
+ queryWrapper.last("LIMIT 100");
|
|
|
|
|
+
|
|
|
|
|
+ java.util.List<MyResource> resources = myResourceService.list(queryWrapper);
|
|
|
|
|
+ System.out.println("搜索到已注册资源数量: " + resources.size());
|
|
|
|
|
+
|
|
|
|
|
+ // 转换为简化的列表格式,并查询用户头像
|
|
|
|
|
+ java.util.List<java.util.Map<String, Object>> result = new java.util.ArrayList<>();
|
|
|
|
|
+ for (MyResource resource : resources) {
|
|
|
|
|
+ java.util.Map<String, Object> item = new java.util.HashMap<>();
|
|
|
|
|
+ item.put("resourceId", resource.getResourceId());
|
|
|
|
|
+ item.put("userId", resource.getUserId());
|
|
|
|
|
+ item.put("name", resource.getName());
|
|
|
|
|
+ item.put("gender", resource.getGender());
|
|
|
|
|
+ item.put("phone", resource.getPhone());
|
|
|
|
|
+ item.put("age", resource.getAge());
|
|
|
|
|
+
|
|
|
|
|
+ // 查询用户头像
|
|
|
|
|
+ String avatarUrl = "/static/default-avatar.svg";
|
|
|
|
|
+ if (resource.getUserId() != null) {
|
|
|
|
|
+ com.baomidou.mybatisplus.core.conditions.query.QueryWrapper<User> userQuery =
|
|
|
|
|
+ new com.baomidou.mybatisplus.core.conditions.query.QueryWrapper<>();
|
|
|
|
|
+ userQuery.eq("user_id", resource.getUserId());
|
|
|
|
|
+ User user = userMapper.selectOne(userQuery);
|
|
|
|
|
+ if (user != null && user.getAvatarUrl() != null) {
|
|
|
|
|
+ avatarUrl = user.getAvatarUrl();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ item.put("avatarUrl", avatarUrl);
|
|
|
|
|
+
|
|
|
|
|
+ result.add(item);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ System.out.println("搜索结果数量: " + result.size());
|
|
|
|
|
+ return Result.success(result);
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ return Result.error("搜索已注册用户资源失败:" + e.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|