| | |
| | | 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.multipart.MultipartFile;
|
| | | import com.ruoyi.common.constant.UserConstants;
|
| | | import com.ruoyi.common.utils.SecurityUtils;
|
| | | import com.ruoyi.common.utils.ServletUtils;
|
| | | import com.ruoyi.common.utils.StringUtils;
|
| | | import com.ruoyi.common.utils.poi.ExcelUtil;
|
| | | import com.ruoyi.framework.aspectj.lang.annotation.Log;
|
| | | import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
|
| | | import com.ruoyi.framework.security.LoginUser;
|
| | | import com.ruoyi.framework.security.service.TokenService;
|
| | | import com.ruoyi.framework.web.controller.BaseController;
|
| | | import com.ruoyi.framework.web.domain.AjaxResult;
|
| | | import com.ruoyi.framework.web.page.TableDataInfo;
|
| | |
| | | @Autowired
|
| | | private ISysPostService postService;
|
| | |
|
| | | @Autowired
|
| | | private TokenService tokenService;
|
| | |
|
| | | /**
|
| | | * 获取用户列表
|
| | | */
|
| | |
| | | return util.exportExcel(list, "用户数据");
|
| | | }
|
| | |
|
| | | @Log(title = "用户管理", businessType = BusinessType.IMPORT)
|
| | | @PreAuthorize("@ss.hasPermi('system:user:import')")
|
| | | @PostMapping("/importData")
|
| | | public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception
|
| | | {
|
| | | ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
|
| | | List<SysUser> userList = util.importExcel(file.getInputStream());
|
| | | LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
| | | String operName = loginUser.getUsername();
|
| | | String message = userService.importUser(userList, updateSupport, operName);
|
| | | return AjaxResult.success(message);
|
| | | }
|
| | |
|
| | | @GetMapping("/importTemplate")
|
| | | public AjaxResult importTemplate()
|
| | | {
|
| | | ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
|
| | | return util.importTemplateExcel("用户数据");
|
| | | }
|
| | |
|
| | | /**
|
| | | * 根据用户编号获取详细信息
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('system:user:query')")
|
| | | @GetMapping(value = "/{userId}")
|
| | | public AjaxResult getInfo(@PathVariable Long userId)
|
| | | @GetMapping(value = { "/", "/{userId}" })
|
| | | public AjaxResult getInfo(@PathVariable(value = "userId", required = false) Long userId)
|
| | | {
|
| | | AjaxResult ajax = AjaxResult.success(userService.selectUserById(userId));
|
| | | ajax.put("postIds", postService.selectPostListByUserId(userId));
|
| | | ajax.put("roleIds", roleService.selectRoleListByUserId(userId));
|
| | | AjaxResult ajax = AjaxResult.success();
|
| | | ajax.put("roles", roleService.selectRoleAll());
|
| | | ajax.put("posts", postService.selectPostAll());
|
| | | if (StringUtils.isNotNull(userId))
|
| | | {
|
| | | ajax.put(AjaxResult.DATA_TAG, userService.selectUserById(userId));
|
| | | ajax.put("postIds", postService.selectPostListByUserId(userId));
|
| | | ajax.put("roleIds", roleService.selectRoleListByUserId(userId));
|
| | | }
|
| | | return ajax;
|
| | | }
|
| | |
|