Merge remote-tracking branch 'origin/master'
# Conflicts: # maku-framework/src/main/resources/auth.yml # maku-server/src/main/java/net/maku/maku/controller/TBookController.java
This commit is contained in:
commit
74f977f36e
|
@ -77,12 +77,11 @@ public class TBookCommentController {
|
||||||
return Result.ok(TBookCommentConvert.INSTANCE.convert(entity));
|
return Result.ok(TBookCommentConvert.INSTANCE.convert(entity));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping
|
@PostMapping("/comment")
|
||||||
@Operation(summary = "保存")
|
@Operation(summary = "保存")
|
||||||
@PreAuthorize("hasAuthority('maku:t_book_comment:save')")
|
@PreAuthorize("hasAuthority('maku:t_book_comment:save')")
|
||||||
public Result<String> save(@RequestBody TBookCommentVO vo){
|
public Result<String> save(@RequestBody TBookCommentVO vo){
|
||||||
tBookCommentService.save(vo);
|
tBookCommentService.save(vo);
|
||||||
|
|
||||||
return Result.ok();
|
return Result.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package net.maku.maku.controller;
|
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 com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
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.service.TUserService;
|
||||||
import net.maku.maku.query.TUserQuery;
|
import net.maku.maku.query.TUserQuery;
|
||||||
import net.maku.maku.vo.TUserVO;
|
import net.maku.maku.vo.TUserVO;
|
||||||
import oracle.jdbc.proxy.annotation.Post;
|
|
||||||
import org.springdoc.core.annotations.ParameterObject;
|
import org.springdoc.core.annotations.ParameterObject;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
|
|
||||||
|
import java.time.Duration;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@ -37,6 +40,7 @@ public class TUserController {
|
||||||
private final TUserService tUserService;
|
private final TUserService tUserService;
|
||||||
private final RedisCache redisCache;
|
private final RedisCache redisCache;
|
||||||
|
|
||||||
|
|
||||||
@PostMapping("/register")
|
@PostMapping("/register")
|
||||||
@Operation(summary = "注册")
|
@Operation(summary = "注册")
|
||||||
public ResponseEntity<Result<String>> register(@RequestBody TUserEntity entity) {
|
public ResponseEntity<Result<String>> register(@RequestBody TUserEntity entity) {
|
||||||
|
@ -56,7 +60,7 @@ public class TUserController {
|
||||||
TUserEntity entity1 = tUserService.login(entity);
|
TUserEntity entity1 = tUserService.login(entity);
|
||||||
if(ObjectUtils.isNotNull(entity1)){
|
if(ObjectUtils.isNotNull(entity1)){
|
||||||
String token = UUID.randomUUID()+"";
|
String token = UUID.randomUUID()+"";
|
||||||
redisCache.set(token,entity1);
|
redisCache.set(token, entity1);
|
||||||
return Result.ok(token);
|
return Result.ok(token);
|
||||||
}else {
|
}else {
|
||||||
return Result.error("登录失败");
|
return Result.error("登录失败");
|
||||||
|
@ -64,7 +68,7 @@ public class TUserController {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@GetMapping("/updateUser")
|
@PutMapping("/updateUser")
|
||||||
@Operation(summary = "修改")
|
@Operation(summary = "修改")
|
||||||
public Result<TUserVO> updateUser(@RequestBody TUserVO vo){
|
public Result<TUserVO> updateUser(@RequestBody TUserVO vo){
|
||||||
TUserVO tUserVO = tUserService.updateUser(vo);
|
TUserVO tUserVO = tUserService.updateUser(vo);
|
||||||
|
@ -72,6 +76,15 @@ public class TUserController {
|
||||||
return Result.ok(tUserVO);
|
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")
|
@PostMapping("/logout")
|
||||||
@Operation(summary = "退出登录")
|
@Operation(summary = "退出登录")
|
||||||
public Result<String> logout(HttpServletRequest request) {
|
public Result<String> logout(HttpServletRequest request) {
|
||||||
|
@ -81,7 +94,7 @@ public class TUserController {
|
||||||
redisCache.delete(token);
|
redisCache.delete(token);
|
||||||
return Result.ok("退出登录");
|
return Result.ok("退出登录");
|
||||||
}
|
}
|
||||||
return Result.error("登录失败");
|
return Result.error("登出失败");
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("page")
|
@GetMapping("page")
|
||||||
|
|
|
@ -24,5 +24,5 @@ public interface TBookService extends BaseService<TBookEntity> {
|
||||||
|
|
||||||
void delete(List<Long> idList);
|
void delete(List<Long> idList);
|
||||||
|
|
||||||
TBookEntity getByName(String name);
|
TBookEntity getByName(String bookName);
|
||||||
}
|
}
|
|
@ -62,9 +62,9 @@ public class TBookServiceImpl extends BaseServiceImpl<TBookDao, TBookEntity> imp
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TBookEntity getByName(String name) {
|
public TBookEntity getByName(String bookName) {
|
||||||
LambdaQueryWrapper<TBookEntity> wrapper = Wrappers.lambdaQuery();
|
LambdaQueryWrapper<TBookEntity> wrapper = Wrappers.lambdaQuery();
|
||||||
wrapper.eq(TBookEntity::getBookName, name);
|
wrapper.eq(TBookEntity::getBookName, bookName);
|
||||||
return baseMapper.selectOne(wrapper);
|
return baseMapper.selectOne(wrapper);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,6 +78,7 @@ public class TUserServiceImpl extends BaseServiceImpl<TUserDao, TUserEntity> imp
|
||||||
@Override
|
@Override
|
||||||
public TUserVO updateUser(TUserVO vo) {
|
public TUserVO updateUser(TUserVO vo) {
|
||||||
TUserEntity entity = new TUserEntity();
|
TUserEntity entity = new TUserEntity();
|
||||||
|
entity.setId(vo.getId());
|
||||||
entity.setUsername(vo.getUsername());
|
entity.setUsername(vo.getUsername());
|
||||||
entity.setPassword(vo.getPassword());
|
entity.setPassword(vo.getPassword());
|
||||||
updateById(entity);
|
updateById(entity);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user