Parcourir la source

新增批量查询所属位置(公开)接口

LinWuTai il y a 1 an
Parent
commit
4a17318d2a

+ 10 - 0
ruoyi-admin/src/main/java/com/ruoyi/asset/domain/dto/TbLocationDTO.java

@@ -0,0 +1,10 @@
+package com.ruoyi.asset.domain.dto;
+
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class TbLocationDTO {
+    private List<String> numbers;
+}

+ 2 - 0
ruoyi-admin/src/main/java/com/ruoyi/asset/mapper/TbLocationMapper.java

@@ -22,6 +22,8 @@ public interface TbLocationMapper
 
 
     TbLocation selectTbLocationByNumber(String number);
     TbLocation selectTbLocationByNumber(String number);
 
 
+    List<TbLocation> selectTbLocationListByNumbers(@Param("numbers") List<String> numbers);
+
     /**
     /**
      * 查询所属位置列表
      * 查询所属位置列表
      * 
      * 

+ 2 - 0
ruoyi-admin/src/main/java/com/ruoyi/asset/service/ITbLocationService.java

@@ -31,6 +31,8 @@ public interface ITbLocationService
      */
      */
     TbLocation selectTbLocationByNumber(String number);
     TbLocation selectTbLocationByNumber(String number);
 
 
+    List<TbLocation> selectTbLocationListByNumbers(List<String> numbers);
+
     /**
     /**
      * 查询所属位置列表
      * 查询所属位置列表
      * 
      * 

+ 5 - 0
ruoyi-admin/src/main/java/com/ruoyi/asset/service/impl/TbLocationServiceImpl.java

@@ -52,6 +52,11 @@ public class TbLocationServiceImpl implements ITbLocationService
         return tbLocationMapper.selectTbLocationByNumber(number);
         return tbLocationMapper.selectTbLocationByNumber(number);
     }
     }
 
 
+    @Override
+    public List<TbLocation> selectTbLocationListByNumbers(List<String> numbers) {
+        return tbLocationMapper.selectTbLocationListByNumbers(numbers);
+    }
+
     /**
     /**
      * 查询所属位置列表
      * 查询所属位置列表
      * 
      * 

+ 11 - 7
ruoyi-admin/src/main/java/com/ruoyi/visitor/controller/VController.java

@@ -1,19 +1,20 @@
 package com.ruoyi.visitor.controller;
 package com.ruoyi.visitor.controller;
 
 
 import com.ruoyi.asset.domain.TbAssetInformation;
 import com.ruoyi.asset.domain.TbAssetInformation;
+import com.ruoyi.asset.domain.dto.TbLocationDTO;
 import com.ruoyi.asset.service.ITbAssetInformationService;
 import com.ruoyi.asset.service.ITbAssetInformationService;
 import com.ruoyi.asset.service.ITbLocationService;
 import com.ruoyi.asset.service.ITbLocationService;
 import com.ruoyi.common.core.controller.BaseController;
 import com.ruoyi.common.core.controller.BaseController;
 import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.core.page.TableDataInfo;
 import com.ruoyi.common.core.page.TableDataInfo;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 
 import javax.annotation.Resource;
 import javax.annotation.Resource;
+import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 import java.util.List;
+import java.util.stream.Collectors;
 
 
 @RestController
 @RestController
 @RequestMapping("/visitor")
 @RequestMapping("/visitor")
@@ -36,11 +37,14 @@ public class VController extends BaseController {
     /*
     /*
     *  接口:/visitor/location/{number}
     *  接口:/visitor/location/{number}
     * */
     * */
-    @GetMapping(value = "/location/{number}")
-    public AjaxResult getLocationByNumber(@PathVariable("number") String number)
+    @PostMapping(value = "/location/list")
+    public AjaxResult getLocationByNumber(@RequestBody TbLocationDTO tbLocationDTO)
     {
     {
-        return success(locationService.selectTbLocationByNumber(number));
+        System.out.println(tbLocationDTO.getNumbers());
+        return success(locationService.selectTbLocationListByNumbers(tbLocationDTO.getNumbers()));
     }
     }
 
 
 
 
+
+
 }
 }

+ 10 - 0
ruoyi-admin/src/main/resources/mapper/asset/TbLocationMapper.xml

@@ -104,4 +104,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             #{id}
             #{id}
         </foreach>
         </foreach>
     </delete>
     </delete>
+
+    <select id="selectTbLocationListByNumbers" parameterType="String" resultMap="TbLocationResult">
+        <include refid="selectTbLocationVo"/>
+        <where>
+            number in
+            <foreach item="number" collection="numbers" open="(" separator="," close=")">
+                #{number}
+            </foreach>
+        </where>
+    </select>
 </mapper>
 </mapper>

+ 2 - 2
ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java

@@ -111,9 +111,9 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
                 // 过滤请求
                 // 过滤请求
                 .authorizeRequests()
                 .authorizeRequests()
                 // 对于登录login 注册register 验证码captchaImage 允许匿名访问
                 // 对于登录login 注册register 验证码captchaImage 允许匿名访问
-                .antMatchers("/login", "/register", "/captchaImage","/inventory/inventory/takeStock", "/asset/location/tree").permitAll()
+                .antMatchers("/login", "/register", "/captchaImage","/inventory/inventory/takeStock", "/asset/location/tree","/visitor/**").permitAll()
                 // 静态资源,可匿名访问
                 // 静态资源,可匿名访问
-                .antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**", "/asset/location/code/**","/visitor/list/**").permitAll()
+                .antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**", "/asset/location/code/**").permitAll()
                 .antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll()
                 .antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll()
                 // 除上面外的所有请求全部需要鉴权认证
                 // 除上面外的所有请求全部需要鉴权认证
                 .anyRequest().authenticated()
                 .anyRequest().authenticated()