| | |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.ruoyi.chargingPile.api.feignClient.SiteClient; |
| | | import com.ruoyi.chargingPile.api.model.Site; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.other.api.domain.TRoleSite; |
| | | import com.ruoyi.other.service.TRoleSiteService; |
| | |
| | | @Resource |
| | | private TRoleSiteService roleSiteService; |
| | | |
| | | @Resource |
| | | private SiteClient siteClient; |
| | | |
| | | |
| | | |
| | | /** |
| | | * 查询角色站点数据 |
| | | * @param roleId |
| | | * @return |
| | | */ |
| | | @ResponseBody |
| | | @GetMapping("/getSiteIds") |
| | | public R<List<Integer>> getSiteIds(@RequestParam("roleId") Long roleId){ |
| | | @PostMapping("/getSiteIds/{roleId}") |
| | | public R<List<Integer>> getSiteIds(@PathVariable Long roleId){ |
| | | List<TRoleSite> list = roleSiteService.list(new LambdaQueryWrapper<TRoleSite>().eq(TRoleSite::getRoleId, roleId)); |
| | | if(list.size() == 1){ |
| | | Integer siteId = list.get(0).getSiteId(); |
| | | if(0 == siteId){ |
| | | List<Site> data = siteClient.getSiteAll().getData(); |
| | | List<Integer> collect = data.stream().map(Site::getId).collect(Collectors.toList()); |
| | | return R.ok(collect); |
| | | } |
| | | } |
| | | List<Integer> collect = list.stream().map(TRoleSite::getSiteId).collect(Collectors.toList()); |
| | | return R.ok(collect); |
| | | } |
| | | |
| | | /** |
| | | * 添加角色站点数据 |
| | | * @param roleSites |
| | | * @return |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/addRoleSite") |
| | | public R addRoleSite(@RequestBody List<TRoleSite> roleSites){ |
| | | roleSiteService.saveBatch(roleSites); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 删除角色站点数据 |
| | | * @param roleId |
| | | * @return |
| | | */ |
| | | @ResponseBody |
| | | @DeleteMapping("/delRoleSite/{roleId}") |
| | | public R delRoleSite(@PathVariable("roleId") Long roleId){ |
| | | roleSiteService.remove(new LambdaQueryWrapper<TRoleSite>().eq(TRoleSite::getRoleId, roleId)); |
| | | return R.ok(); |
| | | } |
| | | } |
| | | |