fix(运维端需求):获取景区设备列表接口实现
This commit is contained in:
+16
@@ -75,4 +75,20 @@ public class TourismController {
|
||||
boolean result = tourismService.removeById(tourism);
|
||||
return result ? Result.succeed(tourism, "操作成功") : Result.failed("操作失败");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取景区设备列表
|
||||
* 通过景区下的二维码信息查询二维码绑定的设备
|
||||
*/
|
||||
@Operation(summary = "获取景区设备列表")
|
||||
@GetMapping("/{tourismId}/devices")
|
||||
public Result getTourismDevices(@PathVariable("tourismId") Long tourismId) {
|
||||
try {
|
||||
var devices = tourismService.getDevicesByTourismId(tourismId);
|
||||
return Result.succeed(devices, "获取景区设备列表成功");
|
||||
} catch (Exception e) {
|
||||
log.error("获取景区设备列表失败", e);
|
||||
return Result.failed("获取景区设备列表失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,4 +32,12 @@ public interface TourismMapper extends SuperMapper<Tourism> {
|
||||
// ID查询
|
||||
Tourism getTourismById(@Param("id") Long id);
|
||||
|
||||
/**
|
||||
* 获取景区设备列表
|
||||
* 通过景区下的二维码信息查询二维码绑定的设备
|
||||
* @param tourismId 景区ID
|
||||
* @return 设备列表
|
||||
*/
|
||||
List<Map<String, Object>> getDevicesByTourismId(@Param("tourismId") Long tourismId);
|
||||
|
||||
}
|
||||
|
||||
@@ -35,5 +35,13 @@ public interface ITourismService extends ISuperService<Tourism> {
|
||||
* @return
|
||||
*/
|
||||
Tourism getTourismById(Long id);
|
||||
|
||||
/**
|
||||
* 获取景区设备列表
|
||||
* 通过景区下的二维码信息查询二维码绑定的设备
|
||||
* @param tourismId 景区ID
|
||||
* @return 设备列表
|
||||
*/
|
||||
java.util.List<java.util.Map<String, Object>> getDevicesByTourismId(Long tourismId);
|
||||
}
|
||||
|
||||
|
||||
+5
@@ -47,4 +47,9 @@ public class TourismServiceImpl extends SuperServiceImpl<TourismMapper, Tourism>
|
||||
return baseMapper.getTourismById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String, Object>> getDevicesByTourismId(Long tourismId) {
|
||||
return baseMapper.getDevicesByTourismId(tourismId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,4 +17,23 @@
|
||||
INSERT INTO tourisms (tourism_no, tourism_name, tourism_address,tourism_phone)
|
||||
VALUES (#{tourismNo}, #{tourismName}, #{tourismAddress},#{tourismPhone})
|
||||
</insert>
|
||||
|
||||
<!-- 获取景区设备列表 -->
|
||||
<select id="getDevicesByTourismId" resultType="java.util.Map">
|
||||
SELECT DISTINCT
|
||||
q.device_sn as deviceSn,
|
||||
q.name as qrcodeName,
|
||||
q.code_id as qrcodeId,
|
||||
q.price as qrcodePrice,
|
||||
q.status as qrcodeStatus,
|
||||
q.create_time as qrcodeCreateTime,
|
||||
t.tourism_name as tourismName,
|
||||
t.tourism_address as tourismAddress
|
||||
FROM qrcodes q
|
||||
LEFT JOIN tourisms t ON q.tourism_id = t.id
|
||||
WHERE q.tourism_id = #{tourismId}
|
||||
AND q.is_del = 0
|
||||
AND t.is_del = 0
|
||||
ORDER BY q.create_time DESC
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user