jeecg接口-从前端传递多个值,后端接收
通过前端传递的三个数据,来查找是否有这条数据。
一、Mapper
-
这是sql语句,通过三个字段找到表中的这一条信息。
resultType可返回任意类型数据,这里得封装好,所以返回的是实体类
<select id="getTest" resultType="org.jeecg.modules.entity.LrPollutionSource">
SELECT * FROM lr_pollution_source
WHERE pollution_name = #{name}
AND pollution_type = #{type}
AND own_street = #{street}
</select>
-
通过获取到的信息保存list
@Param作标识进行判断,传递两个及以上的值就需要用到。
List<LrPollutionSource> getTest(@Param("name") String name, @Param("type") String type, @Param("street") String street);
二、Service
- 通过获取到的信息保存list
List<LrPollutionSource> getTest(String name, String type, String street);
- 返回数据
@Override
public List<LrPollutionSource> getTest(String name, String type, String street) {
return lrPollutionSourceMapper.getTest(name, type, street);
}
三、Controller
从前端传递三个参数,一层一层套着走,通过三个参数获取整条数据。
@AutoLog(value = "test")
@ApiOperation(value = "test", notes = "test")
@GetMapping(value = "/queryList")
public Result<?> queryList(String name , String type , String street) {
List<LrPollutionSource> list = lrPollutionSourceService.getTest(name , type , street);
return Result.OK(list);
}
Debug一下,传递我们需要传递的参数,此时就会拿到我们想要的这一条数据。