| | |
| | | package com.ots.project.system.user.controller; |
| | | |
| | | import com.ots.common.constant.UserConstants; |
| | | import com.ots.common.enums.UserTypeEnum; |
| | | import com.ots.common.utils.StringUtils; |
| | |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.util.List; |
| | | |
| | | @Controller |
| | |
| | | private IRoleService roleService; |
| | | @Autowired |
| | | private IPostService postService; |
| | | |
| | | @RequiresPermissions("system:user:view") |
| | | @GetMapping() |
| | | public String user() { |
| | | return prefix + "/user"; |
| | | } |
| | | |
| | | @RequiresPermissions("system:user:manager:view") |
| | | @GetMapping("/manager") |
| | | public String manager() { |
| | | return prefix + "/usermanager"; |
| | | } |
| | | |
| | | @RequiresPermissions("system:user:list") |
| | | @PostMapping("/list") |
| | | @ResponseBody |
| | | public TableDataInfo list(User user) { |
| | | startPage(); |
| | | user.setUserType(UserTypeEnum.SYS_USER.getUserType()); |
| | | user.setUserType(UserTypeEnum.SYS_USER.getUserType()); |
| | | List<User> list = userService.selectUserList(user); |
| | | return getDataTable(list); |
| | | } |
| | | |
| | | @Log(title = "用户管理", businessType = BusinessType.EXPORT) |
| | | @RequiresPermissions("system:user:export") |
| | | @PostMapping("/export") |
| | |
| | | ExcelUtil<User> util = new ExcelUtil<User>(User.class); |
| | | return util.exportExcel(list, "用户数据"); |
| | | } |
| | | |
| | | @Log(title = "用户管理", businessType = BusinessType.IMPORT) |
| | | @RequiresPermissions("system:user:import") |
| | | @PostMapping("/importData") |
| | |
| | | String message = userService.importUser(userList, updateSupport); |
| | | return AjaxResult.success(message); |
| | | } |
| | | |
| | | @RequiresPermissions("system:user:view") |
| | | @GetMapping("/importTemplate") |
| | | @ResponseBody |
| | |
| | | ExcelUtil<User> util = new ExcelUtil<User>(User.class); |
| | | return util.importTemplateExcel("用户数据"); |
| | | } |
| | | |
| | | |
| | | @GetMapping("/add") |
| | | public String add(ModelMap mmap) { |
| | | mmap.put("roles", roleService.selectRoleAll()); |
| | | mmap.put("posts", postService.selectPostAll()); |
| | | return prefix + "/add"; |
| | | } |
| | | |
| | | |
| | | @RequiresPermissions("system:user:add") |
| | | @Log(title = "用户管理", businessType = BusinessType.INSERT) |
| | | @PostMapping("/add") |
| | |
| | | } |
| | | return toAjax(userService.insertUser(user)); |
| | | } |
| | | |
| | | |
| | | @GetMapping("/edit/{userId}") |
| | | public String edit(@PathVariable("userId") Long userId, ModelMap mmap) { |
| | | mmap.put("user", userService.selectUserById(userId)); |
| | |
| | | mmap.put("posts", postService.selectPostsByUserId(userId)); |
| | | return prefix + "/edit"; |
| | | } |
| | | |
| | | |
| | | @RequiresPermissions("system:user:edit") |
| | | @Log(title = "用户管理", businessType = BusinessType.UPDATE) |
| | | @PostMapping("/edit") |
| | |
| | | } |
| | | return toAjax(userService.updateUser(user)); |
| | | } |
| | | |
| | | @RequiresPermissions("system:user:resetPwd") |
| | | @Log(title = "重置密码", businessType = BusinessType.UPDATE) |
| | | @GetMapping("/resetPwd/{userId}") |
| | |
| | | mmap.put("user", userService.selectUserById(userId)); |
| | | return prefix + "/resetPwd"; |
| | | } |
| | | |
| | | @RequiresPermissions("system:user:resetPwd") |
| | | @Log(title = "重置密码", businessType = BusinessType.UPDATE) |
| | | @PostMapping("/resetPwd") |
| | |
| | | } |
| | | return error(); |
| | | } |
| | | |
| | | @RequiresPermissions("system:user:remove") |
| | | @Log(title = "用户管理", businessType = BusinessType.DELETE) |
| | | @PostMapping("/remove") |
| | |
| | | return error(e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | |
| | | @PostMapping("/checkLoginNameUnique") |
| | | @ResponseBody |
| | | public String checkLoginNameUnique(User user) { |
| | | return userService.checkLoginNameUnique(user.getLoginName()); |
| | | } |
| | | |
| | | |
| | | @PostMapping("/checkPhoneUnique") |
| | | @ResponseBody |
| | | public String checkPhoneUnique(User user) { |
| | | return userService.checkPhoneUnique(user); |
| | | } |
| | | |
| | | |
| | | @PostMapping("/checkEmailUnique") |
| | | @ResponseBody |
| | | public String checkEmailUnique(User user) { |
| | | return userService.checkEmailUnique(user); |
| | | } |
| | | |
| | | |
| | | @Log(title = "用户管理", businessType = BusinessType.UPDATE) |
| | | @RequiresPermissions("system:user:edit") |
| | | @PostMapping("/changeStatus") |
| | |
| | | public AjaxResult changeStatus(User user) { |
| | | return toAjax(userService.changeStatus(user)); |
| | | } |
| | | |
| | | @Log(title = "事中提示语授权", businessType = BusinessType.UPDATE) |
| | | @RequiresPermissions("system:user:hint:auth") |
| | | @GetMapping("/changeHintStatus") |
| | | @ResponseBody |
| | | public AjaxResult changeHintStatus(String userId,Integer type) { |
| | | //type 0取消授权 1授权 |
| | | return toAjax(userService.changeHintStatus(userId,type)); |
| | | } |
| | | } |