| | |
| | | package com.ruoyi.system.controller; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.io.IOException; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.system.api.model.SysUserRoleVo; |
| | | import com.ruoyi.system.domain.SysUserRole; |
| | | import com.ruoyi.system.service.ISysUserRoleService; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.PutMapping; |
| | | import org.springframework.web.bind.annotation.DeleteMapping; |
| | | import org.springframework.web.bind.annotation.PathVariable; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import com.ruoyi.common.log.annotation.Log; |
| | | import com.ruoyi.common.log.enums.BusinessType; |
| | | import com.ruoyi.common.security.annotation.RequiresPermissions; |
| | |
| | | public AjaxResult remove(@PathVariable Long[] userIds) { |
| | | return toAjax(sysUserRoleService.deleteSysUserRoleByUserIds(userIds)); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 根据用户id获取角色 |
| | | * @param userId |
| | | * @return |
| | | */ |
| | | @PostMapping("/getRoleByUserId") |
| | | public R<List<SysUserRoleVo>> getRoleByUserId(@RequestParam("userId") Long userId){ |
| | | List<SysUserRole> list = sysUserRoleService.list(new LambdaQueryWrapper<SysUserRole>().eq(SysUserRole::getUserId, userId)); |
| | | List<SysUserRoleVo> data = new ArrayList<>(); |
| | | for (SysUserRole sysUserRole : list) { |
| | | SysUserRoleVo vo = new SysUserRoleVo(); |
| | | BeanUtils.copyProperties(sysUserRole, vo); |
| | | data.add(vo); |
| | | } |
| | | return R.ok(data); |
| | | } |
| | | } |