| | |
| | | package com.mes.userinfo.controller; |
| | | |
| | | |
| | | import com.mes.entity.request.GeneralRequest; |
| | | import com.mes.userinfo.entity.SysUser; |
| | | import com.mes.userinfo.entity.vo.SysUserVO; |
| | | import com.mes.userinfo.service.SysUserService; |
| | | import com.mes.utils.Result; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | * @author zhoush |
| | | * @since 2024-04-11 |
| | | */ |
| | | @Api(description = "用户管理") |
| | | @RestController |
| | | @RequestMapping("/userinfo") |
| | | @RequestMapping("/sys/user") |
| | | public class SysUserController { |
| | | |
| | | @Autowired |
| | | private SysUserService sysUserService; |
| | | |
| | | @ApiOperation("用户登录") |
| | | @PostMapping("/login") |
| | | public Result login(@RequestBody SysUser user) { |
| | | return sysUserService.login(user); |
| | | public Result<Map<String, String>> login(@RequestBody SysUser user) { |
| | | return Result.success(sysUserService.login(user)); |
| | | } |
| | | |
| | | @GetMapping("/hello") |
| | | public Result hello() { |
| | | return Result.success("eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiJlZjMyMjQ4NDcyODE0ZWFlYWRlOTBkYmZjYWFlZmNmZSIsInN1YiI6IjEiLCJpc3MiOiJzZyIsImlhdCI6MTcxMjkwMjI0NCwiZXhwIjoxNzEyOTA1ODQ0fQ.DlJkhkiwjZSqprdLzKaTB3yuyxGukerKeF0FbJK_6HY"); |
| | | @ApiOperation("退出登录") |
| | | @PostMapping("/logout") |
| | | // @PreAuthorize("hasRole('ROLE_admin')") |
| | | @PreAuthorize("hasAuthority('xt:yh')") |
| | | public Result<String> logout() { |
| | | return Result.success(sysUserService.logout()); |
| | | } |
| | | |
| | | @ApiOperation("新增用户信息") |
| | | @PostMapping("/saveUser") |
| | | // @PreAuthorize("hasAuthority('sys:user:save')") |
| | | public Result<String> saveUser(@Validated @RequestBody SysUserVO sysUser) { |
| | | return Result.success(sysUserService.saveUser(sysUser)); |
| | | } |
| | | |
| | | |
| | | @ApiOperation("更新用户信息") |
| | | @PostMapping("/updateUser") |
| | | // @PreAuthorize("hasAuthority('sys:user:update')") |
| | | public Result<SysUserVO> updateUser(@Validated @RequestBody SysUserVO sysUser) { |
| | | return Result.success(sysUserService.updateUser(sysUser)); |
| | | } |
| | | |
| | | @ApiOperation("重置密码") |
| | | @PostMapping("/resetPassword") |
| | | // @PreAuthorize("hasAuthority('sys:user:resetPassword')") |
| | | public Result resetPassword(String userId) { |
| | | return Result.success(sysUserService.resetPassword(Long.parseLong(userId))); |
| | | } |
| | | |
| | | |
| | | @ApiOperation("获取用户列表") |
| | | @PostMapping("/listByUserName") |
| | | // @PreAuthorize("hasAuthority('sys:user:list')") |
| | | public Result<List<SysUserVO>> listByUserName(@RequestBody GeneralRequest request) { |
| | | return Result.success(sysUserService.listByUserName(request)); |
| | | } |
| | | |
| | | @ApiOperation("删除用户信息") |
| | | @PostMapping("/deleteUser") |
| | | // @PreAuthorize("hasAuthority('sys:user:delete')") |
| | | public Result<String> deleteUser(@RequestBody List<Long> ids) { |
| | | return Result.success(sysUserService.deleteUser(ids)); |
| | | } |
| | | |
| | | } |
| | | |