Compare commits
3 Commits
2a35ec2152
...
a487ac06f6
Author | SHA1 | Date | |
---|---|---|---|
|
a487ac06f6 | ||
|
00a062331b | ||
|
28bc67b88a |
|
@ -8,12 +8,9 @@ auth:
|
|||
- /swagger-ui.html
|
||||
- /swagger-ui/**
|
||||
- /doc.html
|
||||
- /
|
||||
- /maku/t_user/login
|
||||
- /maku/t_user/updateUser
|
||||
- /maku/t_user/register
|
||||
- /maku/t_user/logout
|
||||
- /user/login
|
||||
- /maku/t_book/list/search
|
||||
- /maku/t_book/{id}
|
||||
- /user/login
|
||||
|
||||
- /maku/t_user/info
|
|
@ -1,5 +1,7 @@
|
|||
package net.maku.maku.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
|
@ -13,13 +15,14 @@ import net.maku.maku.entity.TUserEntity;
|
|||
import net.maku.maku.service.TUserService;
|
||||
import net.maku.maku.query.TUserQuery;
|
||||
import net.maku.maku.vo.TUserVO;
|
||||
import oracle.jdbc.proxy.annotation.Post;
|
||||
import org.springdoc.core.annotations.ParameterObject;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import jakarta.validation.Valid;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
|
@ -37,6 +40,7 @@ public class TUserController {
|
|||
private final TUserService tUserService;
|
||||
private final RedisCache redisCache;
|
||||
|
||||
|
||||
@PostMapping("/register")
|
||||
@Operation(summary = "注册")
|
||||
public ResponseEntity<Result<String>> register(@RequestBody TUserEntity entity) {
|
||||
|
@ -56,7 +60,7 @@ public class TUserController {
|
|||
TUserEntity entity1 = tUserService.login(entity);
|
||||
if(ObjectUtils.isNotNull(entity1)){
|
||||
String token = UUID.randomUUID()+"";
|
||||
redisCache.set(token,entity1);
|
||||
redisCache.set(token, entity1);
|
||||
return Result.ok(token);
|
||||
}else {
|
||||
return Result.error("登录失败");
|
||||
|
@ -64,7 +68,7 @@ public class TUserController {
|
|||
}
|
||||
|
||||
|
||||
@GetMapping("/updateUser")
|
||||
@PutMapping("/updateUser")
|
||||
@Operation(summary = "修改")
|
||||
public Result<TUserVO> updateUser(@RequestBody TUserVO vo){
|
||||
TUserVO tUserVO = tUserService.updateUser(vo);
|
||||
|
@ -72,6 +76,15 @@ public class TUserController {
|
|||
return Result.ok(tUserVO);
|
||||
}
|
||||
|
||||
@GetMapping("/info")
|
||||
@Operation(summary = "用户中心")
|
||||
public Result findByUsername(HttpServletRequest request){
|
||||
String token = request.getHeader("token");
|
||||
TUserEntity entity = (TUserEntity) redisCache.get(token);
|
||||
return Result.ok(entity);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/logout")
|
||||
@Operation(summary = "退出登录")
|
||||
public Result<String> logout(HttpServletRequest request) {
|
||||
|
@ -81,7 +94,7 @@ public class TUserController {
|
|||
redisCache.delete(token);
|
||||
return Result.ok("退出登录");
|
||||
}
|
||||
return Result.error("登录失败");
|
||||
return Result.error("登出失败");
|
||||
}
|
||||
|
||||
@GetMapping("page")
|
||||
|
|
|
@ -78,6 +78,7 @@ public class TUserServiceImpl extends BaseServiceImpl<TUserDao, TUserEntity> imp
|
|||
@Override
|
||||
public TUserVO updateUser(TUserVO vo) {
|
||||
TUserEntity entity = new TUserEntity();
|
||||
entity.setId(vo.getId());
|
||||
entity.setUsername(vo.getUsername());
|
||||
entity.setPassword(vo.getPassword());
|
||||
updateById(entity);
|
||||
|
|
Loading…
Reference in New Issue
Block a user