| | |
| | | package com.zy.asrs.controller; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.core.annotations.ManagerAuth; |
| | | import com.core.common.R; |
| | | import com.core.controller.AbstractBaseController; |
| | |
| | | public R getData() { |
| | | // 1. 获取所有站点 |
| | | List<BasStation> stations = basStationService |
| | | .selectList(new EntityWrapper<BasStation>().orderBy("station_id", true)); |
| | | .list(new QueryWrapper<BasStation>().orderBy(true, true, "station_id")); |
| | | |
| | | // 2. 获取所有电视机 (按名称排序) |
| | | List<TvDevice> tvs = tvDeviceService.selectList(new EntityWrapper<TvDevice>().orderBy("name", true)); |
| | | List<TvDevice> tvs = tvDeviceService.list(new QueryWrapper<TvDevice>().orderBy(true, true, "name")); |
| | | |
| | | // 3. 获取所有绑定关系 |
| | | List<BasStationTv> relations = basStationTvService.selectList(new EntityWrapper<>()); |
| | | List<BasStationTv> relations = basStationTvService.list(new QueryWrapper<>()); |
| | | |
| | | Map<String, Object> data = new HashMap<>(); |
| | | data.put("stations", stations); |
| | |
| | | |
| | | // 全量替换策略:先删除所有旧关系,再插入新关系 |
| | | // 注意:这里没有事务控制,如果要求严格一致性,建议在Service层加@Transactional |
| | | basStationTvService.delete(new EntityWrapper<>()); |
| | | basStationTvService.remove(new QueryWrapper<>()); |
| | | |
| | | if (relations != null && !relations.isEmpty()) { |
| | | basStationTvService.insertBatch(relations); |
| | | basStationTvService.saveBatch(relations); |
| | | } |
| | | |
| | | return R.ok(); |