Эх сурвалжийг харах

feat(app): 更新客户端登录和赛事项目接口

- 在ClientLoginVo中添加裁判信息字段,移除裁判号码字段
- 新增GameAppRefereeVo视图对象用于裁判信息展示
- 修改getEventList接口方法,添加refereeId参数用于获取裁判负责的赛事列表
- 修改getProjectList接口方法,添加refereeId参数用于获取裁判负责的项目列表
- 更新ToClientController中的eventList和projectList接口路径和参数
- 在登录成功后返回裁判详细信息,包括负责的项目名称列表
- 实现裁判权限控制,只返回裁判负责的赛事和项目数据
zhou 1 өдөр өмнө
parent
commit
7f4c3e3a69

+ 5 - 7
ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/controller/app_client/ToClientController.java

@@ -7,8 +7,6 @@ import org.dromara.common.log.annotation.Log;
 import org.dromara.common.log.enums.BusinessType;
 import org.dromara.system.domain.GameAppEvent;
 import org.dromara.system.domain.GameAppProject;
-import org.dromara.system.domain.GameEvent;
-import org.dromara.system.domain.GameEventProject;
 import org.dromara.system.domain.bo.ClientLoginBo;
 import org.dromara.system.domain.bo.ClientProjectSaveBo;
 import org.dromara.system.domain.bo.ScorePreviewUpdateBo;
@@ -46,9 +44,9 @@ public class ToClientController {
     /**
      * 赛事列表接口 (接口2)
      */
-    @GetMapping("/eventList")
-    public R<List<GameAppEvent>> eventList() {
-        return R.ok(toClientService.getEventList());
+    @GetMapping("/eventList/{refereeId}")
+    public R<List<GameAppEvent>> eventList(@PathVariable Long refereeId) {
+        return R.ok(toClientService.getEventList(refereeId));
     }
 
     /**
@@ -77,8 +75,8 @@ public class ToClientController {
      * 项目列表接口 (接口5)
      */
     @GetMapping("/projectList")
-    public R<List<GameAppProject>> projectList(@RequestParam Long eventId) {
-        return R.ok(toClientService.getProjectList(eventId));
+    public R<List<GameAppProject>> projectList(@RequestParam Long eventId, @RequestParam Long refereeId) {
+        return R.ok(toClientService.getProjectList(eventId, refereeId));
     }
 
     /**

+ 7 - 5
ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/domain/vo/ClientLoginVo.java

@@ -1,6 +1,7 @@
 package org.dromara.system.domain.vo;
 
 import lombok.Data;
+import org.dromara.system.domain.vo.app.GameAppRefereeVo;
 
 @Data
 public class ClientLoginVo {
@@ -10,13 +11,14 @@ public class ClientLoginVo {
      */
     private Boolean success;
 
-    /**
-     * 裁判号码(即账号)
-     */
-    private String refereeNumber;
-    
     /**
      * 提示信息
      */
     private String message;
+
+    /**
+     * 裁判信息
+     */
+    private GameAppRefereeVo refereeInfo;
+
 }

+ 48 - 0
ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/domain/vo/app/GameAppRefereeVo.java

@@ -0,0 +1,48 @@
+package org.dromara.system.domain.vo.app;
+
+import lombok.Data;
+
+import java.io.Serial;
+import java.io.Serializable;
+import java.util.List;
+
+
+/**
+ * 裁判视图对象 game_referee
+ *
+ * @author zlt
+ * @date 2025-07-30
+ */
+@Data
+public class GameAppRefereeVo implements Serializable {
+
+    @Serial
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 裁判ID
+     */
+    private Long refereeId;
+
+    /**
+     * 裁判姓名
+     */
+    private String name;
+
+    /**
+     * 裁判账号
+     */
+    private String account;
+
+    /**
+     * 负责的项目
+     */
+    private List<String> projectNames;
+
+    /**
+     * 备注
+     */
+    private String remark;
+
+
+}

+ 2 - 2
ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/service/app/IToClientService.java

@@ -32,7 +32,7 @@ public interface IToClientService {
     /**
      * 获取赛事列表 (接口2)
      */
-    List<GameAppEvent> getEventList();
+    List<GameAppEvent> getEventList(Long refereeId);
 
     /**
      * 删除赛事 (接口3)
@@ -42,7 +42,7 @@ public interface IToClientService {
     /**
      * 获取项目列表 (接口5)
      */
-    List<GameAppProject> getProjectList(Long eventId);
+    List<GameAppProject> getProjectList(Long eventId, Long refereeId);
 
     /**
      * 获取成绩记录单 (接口6 展示)

+ 34 - 5
ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/service/impl/app/ToClientServiceImpl.java

@@ -1,6 +1,7 @@
 package org.dromara.system.service.impl.app;
 
 import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.json.JSONUtil;
 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.toolkit.Db;
@@ -11,6 +12,7 @@ import org.dromara.system.domain.*;
 import org.dromara.system.domain.bo.*;
 import org.dromara.system.domain.constant.ProjectClassification;
 import org.dromara.system.domain.vo.*;
+import org.dromara.system.domain.vo.app.GameAppRefereeVo;
 import org.dromara.system.mapper.GameAthleteMapper;
 import org.dromara.system.mapper.GameEventMapper;
 import org.dromara.system.mapper.GameEventProjectMapper;
@@ -58,9 +60,19 @@ public class ToClientServiceImpl implements IToClientService {
             vo.setMessage("裁判号码或密码错误");
             return vo;
         }
-
+        vo.setRefereeInfo(BeanUtil.copyProperties(referee, GameAppRefereeVo.class));
+
+        /** 登录成功后,返回裁判相关信息 */
+        List<Long> projectIds = JSONUtil.toList(referee.getProjectList(), Long.class);
+        if (CollectionUtils.isNotEmpty(projectIds)){
+            List<GameEventProject> list = Db.list(Wrappers.lambdaQuery(GameEventProject.class)
+                .select(GameEventProject::getProjectName)
+                .in(GameEventProject::getProjectId, projectIds)
+            );
+            List<String> names = list.stream().map(GameEventProject::getProjectName).toList();
+            vo.getRefereeInfo().setProjectNames(names);
+        }
         vo.setSuccess(true);
-        vo.setRefereeNumber(referee.getAccount());
         vo.setMessage("登录成功");
         return vo;
     }
@@ -204,12 +216,17 @@ public class ToClientServiceImpl implements IToClientService {
         }
     }
 
+    /**
+     * 获取该裁判负责的赛事列表
+     */
     @Override
-    public List<GameAppEvent> getEventList() {
+    public List<GameAppEvent> getEventList(Long refereeId) {
         List<GameEvent> res = gameEventMapper.selectList(Wrappers.lambdaQuery(GameEvent.class)
             .orderByDesc(GameEvent::getCreateTime)
+                .apply("event_id in (select event_id from game_referee where referee_id = {0})", refereeId)
             .select(GameEvent::getEventId, GameEvent::getEventCode, GameEvent::getEventName,
-                GameEvent::getCreateTime));
+                GameEvent::getCreateTime)
+        );
         return res.isEmpty() ? new ArrayList<>() : res.stream().map(e -> {
             GameAppEvent appEvent = BeanUtil.copyProperties(e, GameAppEvent.class);
             appEvent.setId(e.getEventId());
@@ -219,10 +236,22 @@ public class ToClientServiceImpl implements IToClientService {
         }).toList();
     }
 
+    /**
+     * 获取该裁判负责的项目列表
+     */
     @Override
-    public List<GameAppProject> getProjectList(Long eventId) {
+    public List<GameAppProject> getProjectList(Long eventId, Long refereeId) {
+        String list = Db.getObj(Wrappers.lambdaQuery(GameReferee.class)
+            .eq(GameReferee::getRefereeId, refereeId)
+            .select(GameReferee::getProjectList), GameReferee::getProjectList
+        );
+        List<Long> projectIds = JSONUtil.toList(list, Long.class);
+        if (projectIds.isEmpty()){
+            return new ArrayList<>();
+        }
         List<GameEventProject> res = projectMapper.selectList(Wrappers.lambdaQuery(GameEventProject.class)
             .eq(GameEventProject::getEventId, eventId)
+                .in(GameEventProject::getProjectId, projectIds)
             .select(GameEventProject::getProjectId, GameEventProject::getProjectType,
                 GameEventProject::getClassification, GameEventProject::getProjectName,
                 GameEventProject::getStatus)