From d5657d8d236e97be9b953709a5856df78b595f65 Mon Sep 17 00:00:00 2001 From: zhonghua Date: Thu, 9 Apr 2026 11:34:40 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=A1=A8=E5=8D=95=E6=8F=90=E4=BA=A4?= =?UTF-8?q?=E5=89=8D=E5=8E=BB=E9=99=A4=E9=A6=96=E5=B0=BE=E7=A9=BA=E6=A0=BC?= =?UTF-8?q?=EF=BC=9B=E8=AF=84=E5=A7=94=E6=80=A7=E5=88=AB=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=E4=B8=8E=E6=8C=81=E4=B9=85=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Made-with: Cursor --- .../impl/JudgesManagementServiceImpl.java | 24 ++ frontend/src/views/contests/Create.vue | 15 ++ frontend/src/views/contests/judges/Index.vue | 9 + frontend/src/views/contests/notices/Index.vue | 206 ++++++++---------- frontend/src/views/contests/reviews/Index.vue | 11 + 5 files changed, 153 insertions(+), 112 deletions(-) diff --git a/backend-java/src/main/java/com/competition/modules/biz/judge/service/impl/JudgesManagementServiceImpl.java b/backend-java/src/main/java/com/competition/modules/biz/judge/service/impl/JudgesManagementServiceImpl.java index 4872c29..d4ecf97 100644 --- a/backend-java/src/main/java/com/competition/modules/biz/judge/service/impl/JudgesManagementServiceImpl.java +++ b/backend-java/src/main/java/com/competition/modules/biz/judge/service/impl/JudgesManagementServiceImpl.java @@ -103,6 +103,21 @@ public class JudgesManagementServiceImpl implements IJudgesManagementService { } } + /** 与前端约定:male / female */ + private static String normalizeJudgeGender(Object raw) { + if (raw == null) { + return null; + } + String g = raw.toString().trim(); + if (g.isEmpty()) { + return null; + } + if ("male".equals(g) || "female".equals(g)) { + return g; + } + return null; + } + /** * 将 SysUser 转为前端需要的 Map */ @@ -115,6 +130,7 @@ public class JudgesManagementServiceImpl implements IJudgesManagementService { map.put("email", user.getEmail()); map.put("phone", user.getPhone()); map.put("organization", user.getOrganization()); + map.put("gender", user.getGender()); map.put("avatar", user.getAvatar()); map.put("status", user.getStatus()); map.put("userSource", user.getUserSource()); @@ -134,6 +150,7 @@ public class JudgesManagementServiceImpl implements IJudgesManagementService { String email = (String) params.get("email"); String phone = (String) params.get("phone"); String organization = (String) params.get("organization"); + String gender = normalizeJudgeGender(params.get("gender")); if (username == null || username.isBlank()) { throw BusinessException.of(ErrorCode.BAD_REQUEST, "用户名不能为空"); @@ -141,6 +158,9 @@ public class JudgesManagementServiceImpl implements IJudgesManagementService { if (password == null || password.isBlank()) { throw BusinessException.of(ErrorCode.BAD_REQUEST, "密码不能为空"); } + if (gender == null) { + throw BusinessException.of(ErrorCode.BAD_REQUEST, "请选择性别"); + } Long currentTenantId = SecurityUtil.getCurrentTenantId(); @@ -161,6 +181,7 @@ public class JudgesManagementServiceImpl implements IJudgesManagementService { user.setEmail(email); user.setPhone(phone); user.setOrganization(organization); + user.setGender(gender); user.setUserSource(UserSource.ADMIN_CREATED.getValue()); user.setUserType(UserType.ADULT.getValue()); user.setStatus(CommonStatus.ENABLED.getValue()); @@ -269,6 +290,9 @@ public class JudgesManagementServiceImpl implements IJudgesManagementService { if (params.containsKey("organization")) { user.setOrganization((String) params.get("organization")); } + if (params.containsKey("gender")) { + user.setGender(normalizeJudgeGender(params.get("gender"))); + } if (params.containsKey("password")) { String newPassword = (String) params.get("password"); if (newPassword != null && !newPassword.isBlank()) { diff --git a/frontend/src/views/contests/Create.vue b/frontend/src/views/contests/Create.vue index a56be82..1cddee5 100644 --- a/frontend/src/views/contests/Create.vue +++ b/frontend/src/views/contests/Create.vue @@ -244,6 +244,20 @@ const fetchReviewRules = async () => { } catch { /* */ } } +/** 提交前对字符串字段 trim,再参与校验与保存,避免首尾空格导致误判或脏数据 */ +function trimContestFormStrings() { + form.organizers = String(form.organizers ?? "").trim() + form.coOrganizers = String(form.coOrganizers ?? "").trim() + form.sponsors = String(form.sponsors ?? "").trim() + form.contestName = String(form.contestName ?? "").trim() + if (typeof form.content === "string") form.content = form.content.trim() + if (Array.isArray(form.targetCities)) { + form.targetCities = form.targetCities + .map((c) => String(c ?? "").trim()) + .filter((c) => c.length > 0) + } +} + const rules = { contestName: [{ required: true, message: "请输入活动名称", trigger: "blur" }], contestType: [{ required: true, message: "请选择活动类型", trigger: "change" }], @@ -413,6 +427,7 @@ const loadContestData = async () => { const handleSubmit = async () => { try { + trimContestFormStrings() await formRef.value?.validate() submitLoading.value = true diff --git a/frontend/src/views/contests/judges/Index.vue b/frontend/src/views/contests/judges/Index.vue index 6478cc9..e513ac4 100644 --- a/frontend/src/views/contests/judges/Index.vue +++ b/frontend/src/views/contests/judges/Index.vue @@ -334,6 +334,14 @@ const form = reactive<{ password: "", }) +/** 提交前对文本字段 trim,再参与校验与保存 */ +function trimJudgeFormStrings() { + form.username = String(form.username ?? "").trim() + form.nickname = String(form.nickname ?? "").trim() + form.organization = String(form.organization ?? "").trim() + form.phone = String(form.phone ?? "").trim() +} + // 表单验证规则 const rules = computed(() => ({ username: isEditing.value @@ -511,6 +519,7 @@ const handleBatchDelete = async () => { // 提交表单 const handleSubmit = async () => { try { + trimJudgeFormStrings() await formRef.value?.validate() submitLoading.value = true diff --git a/frontend/src/views/contests/notices/Index.vue b/frontend/src/views/contests/notices/Index.vue index 81b271c..e60ce3e 100644 --- a/frontend/src/views/contests/notices/Index.vue +++ b/frontend/src/views/contests/notices/Index.vue @@ -4,12 +4,10 @@ @@ -18,48 +16,38 @@ - + - + 已发布 未发布 - + - + 搜索 - + 重置 - +