Compare commits
No commits in common. "1289e2a378a0ca435d6698bb35451203869c8303" and "1b78494bfe2677c15ea78a737b504433ef9a5d3b" have entirely different histories.
1289e2a378
...
1b78494bfe
|
@ -8,8 +8,4 @@ auth:
|
||||||
- /swagger-ui.html
|
- /swagger-ui.html
|
||||||
- /swagger-ui/**
|
- /swagger-ui/**
|
||||||
- /doc.html
|
- /doc.html
|
||||||
- /
|
- /
|
||||||
- /maku/t_user/login
|
|
||||||
- /maku/t_user/updateUser
|
|
||||||
- /maku/t_user/register
|
|
||||||
- /maku/t_user/logout
|
|
|
@ -1,7 +1,6 @@
|
||||||
package net.maku.maku.controller;
|
package net.maku.maku.controller;
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import net.maku.framework.common.utils.PageResult;
|
import net.maku.framework.common.utils.PageResult;
|
||||||
|
@ -31,23 +30,6 @@ import java.util.List;
|
||||||
public class TBookController {
|
public class TBookController {
|
||||||
private final TBookService tBookService;
|
private final TBookService tBookService;
|
||||||
|
|
||||||
@GetMapping("/list")
|
|
||||||
@Operation(summary = "列表")
|
|
||||||
public Result<List<TBookEntity>> list() {
|
|
||||||
List<TBookEntity> list = tBookService.list();
|
|
||||||
|
|
||||||
return Result.ok(list);
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("")
|
|
||||||
@Operation(summary = "书籍")
|
|
||||||
@Parameter
|
|
||||||
public Result<TBookEntity> getById(@PathVariable Long id){
|
|
||||||
TBookEntity entity = tBookService.getById(id);
|
|
||||||
|
|
||||||
return Result.ok(entity);
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("page")
|
@GetMapping("page")
|
||||||
@Operation(summary = "分页")
|
@Operation(summary = "分页")
|
||||||
@PreAuthorize("hasAuthority('maku:t_book:page')")
|
@PreAuthorize("hasAuthority('maku:t_book:page')")
|
||||||
|
|
|
@ -1,11 +1,8 @@
|
||||||
package net.maku.maku.controller;
|
package net.maku.maku.controller;
|
||||||
|
|
||||||
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;
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import net.maku.framework.common.cache.RedisCache;
|
|
||||||
import net.maku.framework.common.utils.PageResult;
|
import net.maku.framework.common.utils.PageResult;
|
||||||
import net.maku.framework.common.utils.Result;
|
import net.maku.framework.common.utils.Result;
|
||||||
import net.maku.maku.convert.TUserConvert;
|
import net.maku.maku.convert.TUserConvert;
|
||||||
|
@ -13,9 +10,7 @@ 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.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
@ -23,7 +18,7 @@ import jakarta.validation.Valid;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @author 阿沐 babamu@126.com
|
* @author 阿沐 babamu@126.com
|
||||||
* @since 1.0.0 2024-07-16
|
* @since 1.0.0 2024-07-16
|
||||||
|
@ -34,55 +29,6 @@ import java.util.List;
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class TUserController {
|
public class TUserController {
|
||||||
private final TUserService tUserService;
|
private final TUserService tUserService;
|
||||||
private final RedisCache redisCache;
|
|
||||||
|
|
||||||
@PostMapping("/register")
|
|
||||||
@Operation(summary = "注册")
|
|
||||||
public ResponseEntity<Result<String>> register(@RequestBody TUserEntity entity) {
|
|
||||||
TUserEntity existingUser = tUserService.login(entity);
|
|
||||||
if (existingUser != null) {
|
|
||||||
return ResponseEntity.badRequest().body(Result.error("用户名已存在"));
|
|
||||||
} else {
|
|
||||||
tUserService.save(entity);
|
|
||||||
return ResponseEntity.ok(Result.ok("注册成功"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@PostMapping("/login")
|
|
||||||
@Operation(summary = "登录")
|
|
||||||
public Result login(@RequestBody TUserEntity entity){
|
|
||||||
TUserEntity entity1 = tUserService.login(entity);
|
|
||||||
if(ObjectUtils.isNotNull(entity1)){
|
|
||||||
return Result.ok(entity1);
|
|
||||||
}else {
|
|
||||||
return Result.error("登录失败");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@GetMapping("/updateUser")
|
|
||||||
@Operation(summary = "修改")
|
|
||||||
public Result<TUserVO> updateUser(@RequestBody TUserVO vo){
|
|
||||||
TUserVO tUserVO = tUserService.updateUser(vo);
|
|
||||||
|
|
||||||
return Result.ok(tUserVO);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/logout")
|
|
||||||
@Operation(summary = "退出登录")
|
|
||||||
public Result<String> logout(HttpServletRequest request) {
|
|
||||||
String token = request.getHeader("token");
|
|
||||||
if (token == null) {
|
|
||||||
return Result.error("token为空");
|
|
||||||
}
|
|
||||||
Object o = redisCache.get(token);
|
|
||||||
if (o != null) {
|
|
||||||
redisCache.delete(token);
|
|
||||||
return Result.ok("退出登录");
|
|
||||||
}
|
|
||||||
return Result.error("登录失败");
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("page")
|
@GetMapping("page")
|
||||||
@Operation(summary = "分页")
|
@Operation(summary = "分页")
|
||||||
|
@ -128,6 +74,4 @@ public class TUserController {
|
||||||
|
|
||||||
return Result.ok();
|
return Result.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
package net.maku.maku.entity;
|
package net.maku.maku.entity;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
import com.baomidou.mybatisplus.annotation.*;
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
|
@ -23,5 +23,4 @@ public interface TBookService extends BaseService<TBookEntity> {
|
||||||
void update(TBookVO vo);
|
void update(TBookVO vo);
|
||||||
|
|
||||||
void delete(List<Long> idList);
|
void delete(List<Long> idList);
|
||||||
|
|
||||||
}
|
}
|
|
@ -23,9 +23,4 @@ public interface TUserService extends BaseService<TUserEntity> {
|
||||||
void update(TUserVO vo);
|
void update(TUserVO vo);
|
||||||
|
|
||||||
void delete(List<Long> idList);
|
void delete(List<Long> idList);
|
||||||
|
|
||||||
TUserEntity login(TUserEntity entity);
|
|
||||||
|
|
||||||
TUserVO updateUser(TUserVO vo);
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
package net.maku.maku.service.impl;
|
package net.maku.maku.service.impl;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
@ -17,7 +17,6 @@ import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -38,7 +37,8 @@ public class TUserServiceImpl extends BaseServiceImpl<TUserDao, TUserEntity> imp
|
||||||
|
|
||||||
private LambdaQueryWrapper<TUserEntity> getWrapper(TUserQuery query){
|
private LambdaQueryWrapper<TUserEntity> getWrapper(TUserQuery query){
|
||||||
LambdaQueryWrapper<TUserEntity> wrapper = Wrappers.lambdaQuery();
|
LambdaQueryWrapper<TUserEntity> wrapper = Wrappers.lambdaQuery();
|
||||||
|
wrapper.like(TUserEntity::getUsername, query.getUsername());
|
||||||
|
wrapper.eq(ObjectUtil.isNotNull(query.getStatus()), TUserEntity::getStatus, query.getStatus());
|
||||||
return wrapper;
|
return wrapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,28 +62,4 @@ public class TUserServiceImpl extends BaseServiceImpl<TUserDao, TUserEntity> imp
|
||||||
removeByIds(idList);
|
removeByIds(idList);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public TUserEntity login(TUserEntity entity) {
|
|
||||||
LambdaQueryWrapper<TUserEntity> wrapper = new LambdaQueryWrapper<>();
|
|
||||||
wrapper.eq(TUserEntity::getUsername, entity.getUsername());
|
|
||||||
wrapper.eq(TUserEntity::getPassword, entity.getPassword());
|
|
||||||
TUserEntity one = getOne(wrapper);
|
|
||||||
if(ObjectUtils.isNotNull(one)) {
|
|
||||||
UUID uuid = UUID.randomUUID();
|
|
||||||
one.setAvatar(uuid.toString());
|
|
||||||
updateById(one);
|
|
||||||
return one;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TUserVO updateUser(TUserVO vo) {
|
|
||||||
TUserEntity entity = new TUserEntity();
|
|
||||||
entity.setUsername(vo.getUsername());
|
|
||||||
entity.setPassword(vo.getPassword());
|
|
||||||
updateById(entity);
|
|
||||||
return vo;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -4,7 +4,7 @@ spring:
|
||||||
database: 0
|
database: 0
|
||||||
host: 127.0.0.1
|
host: 127.0.0.1
|
||||||
port: 6379
|
port: 6379
|
||||||
password: 123456
|
# password: wxbc5b16589b8f183e
|
||||||
#timeout: 6000ms # 连接超时时长(毫秒)
|
#timeout: 6000ms # 连接超时时长(毫秒)
|
||||||
datasource:
|
datasource:
|
||||||
dynamic:
|
dynamic:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user