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

根据vciid查询客户端用户集合

bmmx 1 жил өмнө
parent
commit
3c0879d35e

+ 4 - 4
src/main/java/com/om/controller/admin/VciInfoController.java

@@ -60,10 +60,10 @@ public class VciInfoController {
         return vciInfoService.getList();
     }
 
-    @GetMapping("getListByUserId")
-    @ApiOperation("根据用户id获取vci设备列表")
-    public Result<List<UserVciVO>> getListByUserId(@RequestParam Integer userId){
-        return vciInfoService.getListByUserId(userId);
+    @GetMapping("getUserList")
+    @ApiOperation("根据vciid获取用户列表")
+    public Result<List<UserVciVO>> getUserList(@RequestParam Integer vciId){
+        return vciInfoService.getUserList(vciId);
     }
 
     @PostMapping("getPageList")

+ 1 - 1
src/main/java/com/om/service/IVciInfoService.java

@@ -31,7 +31,7 @@ public interface IVciInfoService extends IService<VciInfo> {
 
     Result getList();
 
-    Result<List<UserVciVO>> getListByUserId(Integer userId);
+    Result<List<UserVciVO>> getUserList(Integer vciId);
 
     Result<VciQueryPageVO> getPageList(VciQueryPageDTO dto);
 

+ 7 - 7
src/main/java/com/om/service/impl/VciInfoServiceImpl.java

@@ -132,15 +132,13 @@ public class VciInfoServiceImpl extends ServiceImpl<VciInfoMapper, VciInfo> impl
     }
 
     @Override
-    public Result<List<UserVciVO>> getListByUserId(Integer userId) {
-        //根据userId查询用户
-        User user = userMapper.selectById(userId);
-        if (BeanUtil.isEmpty(user)){
-            throw new BadReqException("该用户不存在");
+    public Result<List<UserVciVO>> getUserList(Integer vciId) {
+        VciInfo vciInfo = this.getById(vciId);
+        if (BeanUtil.isEmpty(vciInfo)){
+            throw new BadReqException("该vci不存在");
         }
-
         List<UserVci> list = userVciService.lambdaQuery()
-                .eq(UserVci::getUserId, userId)
+                .eq(UserVci::getVciInfoId, vciId)
                 .list();
 
         if (CollectionUtil.isEmpty(list)){
@@ -148,6 +146,8 @@ public class VciInfoServiceImpl extends ServiceImpl<VciInfoMapper, VciInfo> impl
         }
         List<UserVciVO> vos= new ArrayList<>();
         for (UserVci userVci : list) {
+            Integer userId = userVci.getUserId();
+            User user = userMapper.selectById(userId);
             UserVciVO userVciVO = BeanUtil.copyProperties(userVci, UserVciVO.class);
             userVciVO.setUsername(user.getUsername());
             vos.add(userVciVO);