Compare commits
36 Commits
xiaoqiantx
...
master
Author | SHA1 | Date | |
---|---|---|---|
|
26d5b51f63 | ||
|
81a7a0e5fd | ||
|
36fc2d5cd4 | ||
|
9f3441b972 | ||
|
06f3fc385c | ||
|
5849bdf4c1 | ||
|
7ef5265f91 | ||
|
39c69b53b9 | ||
|
7571d13450 | ||
|
2dbe52bce6 | ||
|
3982a2c930 | ||
|
0359e93c19 | ||
|
82df411a6d | ||
|
b250a8a8d3 | ||
|
a565e10dd2 | ||
|
65a6d47e61 | ||
|
3ce8d58220 | ||
|
39591d3940 | ||
|
73ce32d5e7 | ||
|
de72338f77 | ||
|
85cd31247c | ||
|
f4f607f971 | ||
|
5e3a15e769 | ||
|
a6719d57a3 | ||
|
646d561a22 | ||
|
f8814cd44c | ||
|
24a9aca4cf | ||
|
15ce750c42 | ||
|
4565daf668 | ||
|
c60d3bdc64 | ||
|
49d75b44e1 | ||
|
d1e6e5e15a | ||
|
3221c3bcc9 | ||
|
34fb667a10 | ||
|
74f977f36e | ||
|
af67f97cb7 |
|
@ -36,11 +36,11 @@ public class SysUserDetailsServiceImpl implements SysUserDetailsService {
|
||||||
if (userDetail.getStatus() == UserStatusEnum.DISABLE.getValue()) {
|
if (userDetail.getStatus() == UserStatusEnum.DISABLE.getValue()) {
|
||||||
userDetail.setEnabled(false);
|
userDetail.setEnabled(false);
|
||||||
}
|
}
|
||||||
|
// 根据用户id获得身份
|
||||||
// 数据权限范围
|
// 数据权限范围
|
||||||
List<Long> dataScopeList = getDataScope(userDetail);
|
List<Long> dataScopeList = getDataScope(userDetail);
|
||||||
userDetail.setDataScopeList(dataScopeList);
|
userDetail.setDataScopeList(dataScopeList);
|
||||||
|
//
|
||||||
// 用户权限列表
|
// 用户权限列表
|
||||||
Set<String> authoritySet = sysMenuService.getUserAuthority(userDetail);
|
Set<String> authoritySet = sysMenuService.getUserAuthority(userDetail);
|
||||||
|
|
||||||
|
|
|
@ -57,6 +57,18 @@ public class RedisCache {
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
public <T> T get(String key, Class<T> clazz) {
|
||||||
|
Object value = redisTemplate.opsForValue().get(key);
|
||||||
|
if (value == null) {
|
||||||
|
return null; // or throw an exception, depending on your requirement
|
||||||
|
}
|
||||||
|
if (clazz.isInstance(value)) {
|
||||||
|
return clazz.cast(value);
|
||||||
|
} else {
|
||||||
|
throw new IllegalStateException("Cached value is not of expected type " + clazz);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public Object get(String key) {
|
public Object get(String key) {
|
||||||
return get(key, NOT_EXPIRE);
|
return get(key, NOT_EXPIRE);
|
||||||
|
|
|
@ -44,12 +44,12 @@ public abstract class BaseEntity implements TransPojo {
|
||||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||||
private LocalDateTime updateTime;
|
private LocalDateTime updateTime;
|
||||||
|
|
||||||
/**
|
// /**
|
||||||
* 版本号
|
// * 版本号
|
||||||
*/
|
// */
|
||||||
@Version
|
// @Version
|
||||||
@TableField(fill = FieldFill.INSERT)
|
// @TableField(fill = FieldFill.INSERT)
|
||||||
private Integer version;
|
// private Integer version;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除标记
|
* 删除标记
|
||||||
|
|
|
@ -38,13 +38,18 @@ public class AuthenticationTokenFilter extends OncePerRequestFilter {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//token 1 admin 2 user
|
||||||
|
//object
|
||||||
|
//ObjectMapper obejct admin.class user.class
|
||||||
// 获取登录用户信息
|
// 获取登录用户信息
|
||||||
|
//从redis中获取信息
|
||||||
UserDetail user = tokenStoreCache.getUser(accessToken);
|
UserDetail user = tokenStoreCache.getUser(accessToken);
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
chain.doFilter(request, response);
|
chain.doFilter(request, response);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
//存入SecurityContextHolder
|
||||||
|
// 获取用户权限信息封装到Authentication中
|
||||||
// 用户存在
|
// 用户存在
|
||||||
Authentication authentication = new UsernamePasswordAuthenticationToken(user, null, user.getAuthorities());
|
Authentication authentication = new UsernamePasswordAuthenticationToken(user, null, user.getAuthorities());
|
||||||
|
|
||||||
|
|
|
@ -8,10 +8,6 @@ auth:
|
||||||
- /swagger-ui.html
|
- /swagger-ui.html
|
||||||
- /swagger-ui/**
|
- /swagger-ui/**
|
||||||
- /doc.html
|
- /doc.html
|
||||||
- /
|
- /maku/**
|
||||||
- /maku/t_user/login
|
|
||||||
- /maku/t_user/updateUser
|
|
||||||
- /maku/t_user/register
|
|
||||||
- /maku/t_user/logout
|
|
||||||
- /maku/t_user/info
|
|
||||||
- /maku/t_user/recharge
|
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
package net.maku.maku.config;
|
||||||
|
|
||||||
|
public class PayConfig {
|
||||||
|
public String generateOrderId() {
|
||||||
|
// 随机生成订单ID的逻辑
|
||||||
|
return "ORDER" + (int) (Math.random() * 1000000000);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean callPaymentService(Integer balance) {
|
||||||
|
// 调用支付服务的逻辑
|
||||||
|
if (balance == null || balance <= 0) {
|
||||||
|
// 如果金额无效,则支付失败
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
Thread.sleep(100000000); // 模拟网络延迟或支付处理时间
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
//假设一直模拟成功
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,12 +1,19 @@
|
||||||
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.exception.ErrorCode;
|
||||||
|
import net.maku.framework.common.exception.ServerException;
|
||||||
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.TBookCollectionConvert;
|
import net.maku.maku.convert.TBookCollectionConvert;
|
||||||
|
import net.maku.maku.dao.TBookCollectionDao;
|
||||||
import net.maku.maku.entity.TBookCollectionEntity;
|
import net.maku.maku.entity.TBookCollectionEntity;
|
||||||
|
import net.maku.maku.entity.TUserEntity;
|
||||||
import net.maku.maku.service.TBookCollectionService;
|
import net.maku.maku.service.TBookCollectionService;
|
||||||
import net.maku.maku.query.TBookCollectionQuery;
|
import net.maku.maku.query.TBookCollectionQuery;
|
||||||
import net.maku.maku.vo.TBookCollectionVO;
|
import net.maku.maku.vo.TBookCollectionVO;
|
||||||
|
@ -15,6 +22,11 @@ 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.LocalDateTime;
|
||||||
|
import java.time.ZoneId;
|
||||||
|
import java.time.ZonedDateTime;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -29,10 +41,24 @@ import java.util.List;
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class TBookCollectionController {
|
public class TBookCollectionController {
|
||||||
private final TBookCollectionService tBookCollectionService;
|
private final TBookCollectionService tBookCollectionService;
|
||||||
@GetMapping("/book/buy")
|
private final TBookCollectionDao bookCollectionDao;
|
||||||
@Operation(summary = "购买书籍")
|
private final RedisCache redisCache;
|
||||||
public Result<List<TBookCollectionVO>> getBookCollectionByUserId(@PathVariable Long id) {
|
|
||||||
return Result.ok(tBookCollectionService.getPhoneByUseId(id));
|
@GetMapping("/mylist")
|
||||||
|
public Result<List<TBookCollectionEntity>> getBookCollectionByUserId(HttpServletRequest request) {
|
||||||
|
String token = request.getHeader("token");
|
||||||
|
TUserEntity entity = (TUserEntity) redisCache.get(token);
|
||||||
|
if(ObjectUtils.isNull(entity)){
|
||||||
|
throw new ServerException(ErrorCode.REFRESH_TOKEN_INVALID);
|
||||||
|
}
|
||||||
|
TUserEntity tUserEntity = (TUserEntity) redisCache.get(token);
|
||||||
|
Integer userId=tUserEntity.getId();
|
||||||
|
LocalDateTime currentTime = LocalDateTime.now();
|
||||||
|
ZoneId zoneId = ZoneId.systemDefault();
|
||||||
|
ZonedDateTime zdt = currentTime.atZone(zoneId);
|
||||||
|
Date date = Date.from(zdt.toInstant());
|
||||||
|
|
||||||
|
return Result.ok(bookCollectionDao.selectBookCollectionByUserId(Long.valueOf(userId)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("page")
|
@GetMapping("page")
|
||||||
|
@ -40,10 +66,8 @@ public class TBookCollectionController {
|
||||||
@PreAuthorize("hasAuthority('maku:t_book_collection:page')")
|
@PreAuthorize("hasAuthority('maku:t_book_collection:page')")
|
||||||
public Result<PageResult<TBookCollectionVO>> page(@ParameterObject @Valid TBookCollectionQuery query){
|
public Result<PageResult<TBookCollectionVO>> page(@ParameterObject @Valid TBookCollectionQuery query){
|
||||||
PageResult<TBookCollectionVO> page = tBookCollectionService.page(query);
|
PageResult<TBookCollectionVO> page = tBookCollectionService.page(query);
|
||||||
|
|
||||||
return Result.ok(page);
|
return Result.ok(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("{id}")
|
@GetMapping("{id}")
|
||||||
@Operation(summary = "信息")
|
@Operation(summary = "信息")
|
||||||
@PreAuthorize("hasAuthority('maku:t_book_collection:info')")
|
@PreAuthorize("hasAuthority('maku:t_book_collection:info')")
|
||||||
|
@ -79,4 +103,44 @@ public class TBookCollectionController {
|
||||||
|
|
||||||
return Result.ok();
|
return Result.ok();
|
||||||
}
|
}
|
||||||
|
@PostMapping("/collection")
|
||||||
|
@Operation(summary = "收藏图书")
|
||||||
|
public Result<String> setbookcollection(HttpServletRequest request, @RequestParam Integer bookId) {
|
||||||
|
String token = request.getHeader("token");
|
||||||
|
TUserEntity entity = (TUserEntity) redisCache.get(token);
|
||||||
|
if (ObjectUtils.isNull(entity)) {
|
||||||
|
throw new ServerException(ErrorCode.REFRESH_TOKEN_INVALID);
|
||||||
|
}
|
||||||
|
|
||||||
|
Integer userId = entity.getId(); // 直接使用已经获取的用户信息
|
||||||
|
boolean isBookAlreadyCollected = tBookCollectionService.isBookAlreadyCollected(userId, bookId);
|
||||||
|
if (isBookAlreadyCollected) {
|
||||||
|
return Result.error("该书已经收藏过,不能重复收藏");
|
||||||
|
}
|
||||||
|
LocalDateTime currentTime = LocalDateTime.now();
|
||||||
|
ZoneId zoneId = ZoneId.systemDefault();
|
||||||
|
ZonedDateTime zdt = currentTime.atZone(zoneId);
|
||||||
|
Date date = Date.from(zdt.toInstant());
|
||||||
|
|
||||||
|
tBookCollectionService.save(userId, bookId, date);
|
||||||
|
|
||||||
|
return Result.ok("收藏图书成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/status")
|
||||||
|
@Operation(summary = "收藏状态")
|
||||||
|
public Result<String> status(HttpServletRequest request,@RequestParam Integer bookId){
|
||||||
|
String token = request.getHeader("token");
|
||||||
|
TUserEntity user = (TUserEntity) redisCache.get(token);
|
||||||
|
if(ObjectUtils.isNull(user)){
|
||||||
|
throw new ServerException(ErrorCode.REFRESH_TOKEN_INVALID);
|
||||||
|
}
|
||||||
|
Integer userId=user.getId();
|
||||||
|
TBookCollectionEntity entity1 = tBookCollectionService.getByBookIdandUserId(bookId,userId);
|
||||||
|
if(entity1 !=null&&entity1.getStatus() !=null&&entity1.getStatus()==1){
|
||||||
|
return Result.ok("已收藏");
|
||||||
|
}else {
|
||||||
|
return Result.ok("未收藏");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,12 +1,19 @@
|
||||||
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.exception.ErrorCode;
|
||||||
|
import net.maku.framework.common.exception.ServerException;
|
||||||
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.TBookCommentConvert;
|
import net.maku.maku.convert.TBookCommentConvert;
|
||||||
|
import net.maku.maku.dao.TBookCommentDao;
|
||||||
import net.maku.maku.entity.TBookCommentEntity;
|
import net.maku.maku.entity.TBookCommentEntity;
|
||||||
|
import net.maku.maku.entity.TUserEntity;
|
||||||
import net.maku.maku.service.TBookCommentService;
|
import net.maku.maku.service.TBookCommentService;
|
||||||
import net.maku.maku.query.TBookCommentQuery;
|
import net.maku.maku.query.TBookCommentQuery;
|
||||||
import net.maku.maku.vo.TBookCommentVO;
|
import net.maku.maku.vo.TBookCommentVO;
|
||||||
|
@ -15,6 +22,11 @@ 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.LocalDateTime;
|
||||||
|
import java.time.ZoneId;
|
||||||
|
import java.time.ZonedDateTime;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -29,6 +41,35 @@ import java.util.List;
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class TBookCommentController {
|
public class TBookCommentController {
|
||||||
private final TBookCommentService tBookCommentService;
|
private final TBookCommentService tBookCommentService;
|
||||||
|
private final RedisCache redisCache;
|
||||||
|
private final TBookCommentDao tBookCommentDao;
|
||||||
|
|
||||||
|
@PostMapping("/manout")
|
||||||
|
@Operation(summary = "评论")
|
||||||
|
public Result setbookcomment(HttpServletRequest request, @RequestParam Integer bookId,@RequestParam String comment) {
|
||||||
|
// 首先验证token的有效性,然后从Redis中获取用户信息
|
||||||
|
String token = request.getHeader("token");
|
||||||
|
TUserEntity entity = (TUserEntity) redisCache.get(token);
|
||||||
|
if(ObjectUtils.isNull(entity)){
|
||||||
|
throw new ServerException(ErrorCode.REFRESH_TOKEN_INVALID);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TUserEntity tUserEntity = (TUserEntity) redisCache.get(token);
|
||||||
|
Integer userId=tUserEntity.getId();
|
||||||
|
LocalDateTime currentTime = LocalDateTime.now();
|
||||||
|
ZoneId zoneId = ZoneId.systemDefault();
|
||||||
|
|
||||||
|
//DATE没有时区二localDateTime有时区,为了将 LocalDateTime 转换为 Date,你需要指定一个时区,因为 Date 是基于UTC的
|
||||||
|
// 将LocalDateTime转换为ZonedDateTime,然后转换为Instant,最后转换为Date
|
||||||
|
ZonedDateTime zdt = currentTime.atZone(zoneId);
|
||||||
|
Date date = Date.from(zdt.toInstant());
|
||||||
|
tBookCommentService.save(userId,bookId,comment,date);
|
||||||
|
return Result.ok("评论成功");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@GetMapping("page")
|
@GetMapping("page")
|
||||||
@Operation(summary = "分页")
|
@Operation(summary = "分页")
|
||||||
|
@ -73,4 +114,17 @@ public class TBookCommentController {
|
||||||
|
|
||||||
return Result.ok();
|
return Result.ok();
|
||||||
}
|
}
|
||||||
|
@GetMapping("/list")
|
||||||
|
@Operation(summary = "查看评论列表")
|
||||||
|
public Result<List<TBookCommentEntity>> list(HttpServletRequest request){
|
||||||
|
String token = request.getHeader("token");
|
||||||
|
TUserEntity entity = (TUserEntity) redisCache.get(token);
|
||||||
|
if(ObjectUtils.isNull(entity)){
|
||||||
|
throw new ServerException(ErrorCode.REFRESH_TOKEN_INVALID);
|
||||||
|
}
|
||||||
|
TUserEntity tUserEntity = (TUserEntity) redisCache.get(token);
|
||||||
|
Integer userId=tUserEntity.getId();
|
||||||
|
return Result.ok(tBookCommentDao.findAll(Long.valueOf(userId)));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,13 +1,22 @@
|
||||||
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.Parameter;
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
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.exception.ErrorCode;
|
||||||
|
import net.maku.framework.common.exception.ServerException;
|
||||||
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.TBookCollectionConvert;
|
||||||
import net.maku.maku.convert.TBookConvert;
|
import net.maku.maku.convert.TBookConvert;
|
||||||
|
import net.maku.maku.entity.TBookCollectionEntity;
|
||||||
import net.maku.maku.entity.TBookEntity;
|
import net.maku.maku.entity.TBookEntity;
|
||||||
|
import net.maku.maku.entity.TUserEntity;
|
||||||
|
import net.maku.maku.service.TBookCollectionService;
|
||||||
import net.maku.maku.service.TBookService;
|
import net.maku.maku.service.TBookService;
|
||||||
import net.maku.maku.query.TBookQuery;
|
import net.maku.maku.query.TBookQuery;
|
||||||
import net.maku.maku.vo.TBookVO;
|
import net.maku.maku.vo.TBookVO;
|
||||||
|
@ -16,6 +25,11 @@ 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.LocalDateTime;
|
||||||
|
import java.time.ZoneId;
|
||||||
|
import java.time.ZonedDateTime;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -30,6 +44,8 @@ import java.util.List;
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class TBookController {
|
public class TBookController {
|
||||||
private final TBookService tBookService;
|
private final TBookService tBookService;
|
||||||
|
private final RedisCache redisCache;
|
||||||
|
private final TBookCollectionService tBookCollectionService;
|
||||||
|
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
@Operation(summary = "列表")
|
@Operation(summary = "列表")
|
||||||
|
@ -50,18 +66,24 @@ public class TBookController {
|
||||||
@GetMapping("/list/search")
|
@GetMapping("/list/search")
|
||||||
@Operation(summary = "根据书名查询书籍")
|
@Operation(summary = "根据书名查询书籍")
|
||||||
@Parameter
|
@Parameter
|
||||||
public Result<TBookEntity> getByName(@RequestParam String bookName){
|
public Result<List<TBookEntity>> getByName(@RequestParam String name){
|
||||||
TBookEntity entity = tBookService.getByName(bookName);
|
List<TBookEntity> entity = tBookService.getByName(name);
|
||||||
return Result.ok(entity);
|
return Result.ok(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@GetMapping("page")
|
@GetMapping("page")
|
||||||
@Operation(summary = "分页")
|
@Operation(summary = "分页")
|
||||||
@PreAuthorize("hasAuthority('maku:t_book:page')")
|
@PreAuthorize("hasAuthority('maku:t_book:page')")
|
||||||
public Result<PageResult<TBookVO>> page(@ParameterObject @Valid TBookQuery query){
|
public Result<PageResult<TBookVO>> page(@ParameterObject @Valid TBookQuery query){
|
||||||
PageResult<TBookVO> page = tBookService.page(query);
|
PageResult<TBookVO> page = tBookService.page(query);
|
||||||
|
|
||||||
return Result.ok(page);
|
return Result.ok(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@GetMapping("{id}")
|
@GetMapping("{id}")
|
||||||
@Operation(summary = "信息")
|
@Operation(summary = "信息")
|
||||||
// @PreAuthorize("hasAuthority('maku:t_book:info')")
|
// @PreAuthorize("hasAuthority('maku:t_book:info')")
|
||||||
|
@ -69,6 +91,7 @@ public class TBookController {
|
||||||
TBookEntity entity = tBookService.getById(id);
|
TBookEntity entity = tBookService.getById(id);
|
||||||
return Result.ok(TBookConvert.INSTANCE.convert(entity));
|
return Result.ok(TBookConvert.INSTANCE.convert(entity));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping
|
@PostMapping
|
||||||
@Operation(summary = "保存")
|
@Operation(summary = "保存")
|
||||||
@PreAuthorize("hasAuthority('maku:t_book:save')")
|
@PreAuthorize("hasAuthority('maku:t_book:save')")
|
||||||
|
|
|
@ -2,6 +2,7 @@ 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.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.utils.PageResult;
|
import net.maku.framework.common.utils.PageResult;
|
||||||
import net.maku.framework.common.utils.Result;
|
import net.maku.framework.common.utils.Result;
|
||||||
|
|
|
@ -1,20 +1,40 @@
|
||||||
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.exception.ErrorCode;
|
||||||
|
import net.maku.framework.common.exception.ServerException;
|
||||||
|
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.TPurchaseDetailsConvert;
|
import net.maku.maku.convert.TPurchaseDetailsConvert;
|
||||||
|
import net.maku.maku.dao.TPurchaseDao;
|
||||||
|
import net.maku.maku.dao.TPurchaseDetailsDao;
|
||||||
import net.maku.maku.entity.TPurchaseDetailsEntity;
|
import net.maku.maku.entity.TPurchaseDetailsEntity;
|
||||||
|
import net.maku.maku.entity.TShoppingTrolleyEntity;
|
||||||
|
import net.maku.maku.entity.TUserEntity;
|
||||||
|
import net.maku.maku.entity.TPurchaseEntity;
|
||||||
|
import net.maku.maku.entity.TUserEntity;
|
||||||
import net.maku.maku.service.TPurchaseDetailsService;
|
import net.maku.maku.service.TPurchaseDetailsService;
|
||||||
import net.maku.maku.query.TPurchaseDetailsQuery;
|
import net.maku.maku.query.TPurchaseDetailsQuery;
|
||||||
|
import net.maku.maku.vo.TPurchaseBookDetailsVo;
|
||||||
|
import net.maku.maku.vo.TPurchaseBookVo;
|
||||||
|
import net.maku.maku.vo.TCardVo;
|
||||||
import net.maku.maku.vo.TPurchaseDetailsVO;
|
import net.maku.maku.vo.TPurchaseDetailsVO;
|
||||||
import org.springdoc.core.annotations.ParameterObject;
|
import org.springdoc.core.annotations.ParameterObject;
|
||||||
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.LocalDateTime;
|
||||||
|
import java.time.ZoneId;
|
||||||
|
import java.time.ZonedDateTime;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -29,6 +49,42 @@ import java.util.List;
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class TPurchaseDetailsController {
|
public class TPurchaseDetailsController {
|
||||||
private final TPurchaseDetailsService tPurchaseDetailsService;
|
private final TPurchaseDetailsService tPurchaseDetailsService;
|
||||||
|
private final RedisCache redisCache;
|
||||||
|
private final TPurchaseDetailsDao tPurchaseDetailsDao;
|
||||||
|
@GetMapping("/a")
|
||||||
|
public Result<List<TPurchaseBookVo>> getBookCollectionByUserId(HttpServletRequest request) {
|
||||||
|
String token = request.getHeader("token");
|
||||||
|
TUserEntity entity = (TUserEntity) redisCache.get(token);
|
||||||
|
if(ObjectUtils.isNull(entity)){
|
||||||
|
throw new ServerException(ErrorCode.REFRESH_TOKEN_INVALID);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TUserEntity tUserEntity = (TUserEntity) redisCache.get(token);
|
||||||
|
Integer userId=tUserEntity.getId();
|
||||||
|
LocalDateTime currentTime = LocalDateTime.now();
|
||||||
|
ZoneId zoneId = ZoneId.systemDefault();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ZonedDateTime zdt = currentTime.atZone(zoneId);
|
||||||
|
Date date = Date.from(zdt.toInstant());
|
||||||
|
|
||||||
|
return Result.ok(tPurchaseDetailsService.selectByUserId(userId));
|
||||||
|
}
|
||||||
|
@PostMapping("/buy")
|
||||||
|
@Operation(summary = "购买")
|
||||||
|
public Result<?> purchaseBook(HttpServletRequest request,@RequestBody TCardVo vo) {
|
||||||
|
String token = request.getHeader("token");
|
||||||
|
TUserEntity entity = (TUserEntity) redisCache.get(token);
|
||||||
|
// boolean isPurchased = tPurchaseDetailsService.purchaseBook(entity);
|
||||||
|
boolean isPurchased = tPurchaseDetailsService.purchaseBook(entity,vo);
|
||||||
|
if (isPurchased) {
|
||||||
|
return Result.ok("购买成功");
|
||||||
|
} else {
|
||||||
|
return Result.error("余额不足,请充值");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@GetMapping("page")
|
@GetMapping("page")
|
||||||
@Operation(summary = "分页")
|
@Operation(summary = "分页")
|
||||||
|
|
|
@ -1,12 +1,19 @@
|
||||||
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.exception.ErrorCode;
|
||||||
|
import net.maku.framework.common.exception.ServerException;
|
||||||
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.TShoppingTrolleyConvert;
|
import net.maku.maku.convert.TShoppingTrolleyConvert;
|
||||||
|
import net.maku.maku.dao.TShoppingTrolleyDao;
|
||||||
import net.maku.maku.entity.TShoppingTrolleyEntity;
|
import net.maku.maku.entity.TShoppingTrolleyEntity;
|
||||||
|
import net.maku.maku.entity.TUserEntity;
|
||||||
import net.maku.maku.service.TShoppingTrolleyService;
|
import net.maku.maku.service.TShoppingTrolleyService;
|
||||||
import net.maku.maku.query.TShoppingTrolleyQuery;
|
import net.maku.maku.query.TShoppingTrolleyQuery;
|
||||||
import net.maku.maku.vo.TShoppingTrolleyVO;
|
import net.maku.maku.vo.TShoppingTrolleyVO;
|
||||||
|
@ -15,6 +22,11 @@ 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.LocalDateTime;
|
||||||
|
import java.time.ZoneId;
|
||||||
|
import java.time.ZonedDateTime;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -28,26 +40,28 @@ import java.util.List;
|
||||||
@Tag(name="")
|
@Tag(name="")
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class TShoppingTrolleyController {
|
public class TShoppingTrolleyController {
|
||||||
|
private final RedisCache redisCache;
|
||||||
private final TShoppingTrolleyService tShoppingTrolleyService;
|
private final TShoppingTrolleyService tShoppingTrolleyService;
|
||||||
|
private final TShoppingTrolleyDao tShoppingTrolleyDao;
|
||||||
@GetMapping("page")
|
@GetMapping("page")
|
||||||
@Operation(summary = "分页")
|
@Operation(summary = "分页")
|
||||||
@PreAuthorize("hasAuthority('maku:t_shopping_trolley:page')")
|
|
||||||
public Result<PageResult<TShoppingTrolleyVO>> page(@ParameterObject @Valid TShoppingTrolleyQuery query){
|
public Result<PageResult<TShoppingTrolleyVO>> page(@ParameterObject @Valid TShoppingTrolleyQuery query){
|
||||||
PageResult<TShoppingTrolleyVO> page = tShoppingTrolleyService.page(query);
|
PageResult<TShoppingTrolleyVO> page = tShoppingTrolleyService.page(query);
|
||||||
|
|
||||||
return Result.ok(page);
|
return Result.ok(page);
|
||||||
}
|
}
|
||||||
|
@GetMapping("/list")
|
||||||
|
@Operation(summary = "列表")
|
||||||
|
public Result<List<TShoppingTrolleyEntity>> list(){
|
||||||
|
return Result.ok(tShoppingTrolleyService.list());
|
||||||
|
}
|
||||||
@GetMapping("{id}")
|
@GetMapping("{id}")
|
||||||
@Operation(summary = "信息")
|
@Operation(summary = "信息")
|
||||||
@PreAuthorize("hasAuthority('maku:t_shopping_trolley:info')")
|
|
||||||
public Result<TShoppingTrolleyVO> get(@PathVariable("id") Long id){
|
public Result<TShoppingTrolleyVO> get(@PathVariable("id") Long id){
|
||||||
TShoppingTrolleyEntity entity = tShoppingTrolleyService.getById(id);
|
TShoppingTrolleyEntity entity = tShoppingTrolleyService.getById(id);
|
||||||
|
|
||||||
return Result.ok(TShoppingTrolleyConvert.INSTANCE.convert(entity));
|
return Result.ok(TShoppingTrolleyConvert.INSTANCE.convert(entity));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping
|
@PostMapping
|
||||||
@Operation(summary = "保存")
|
@Operation(summary = "保存")
|
||||||
@PreAuthorize("hasAuthority('maku:t_shopping_trolley:save')")
|
@PreAuthorize("hasAuthority('maku:t_shopping_trolley:save')")
|
||||||
|
@ -56,7 +70,6 @@ public class TShoppingTrolleyController {
|
||||||
|
|
||||||
return Result.ok();
|
return Result.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping
|
@PutMapping
|
||||||
@Operation(summary = "修改")
|
@Operation(summary = "修改")
|
||||||
@PreAuthorize("hasAuthority('maku:t_shopping_trolley:update')")
|
@PreAuthorize("hasAuthority('maku:t_shopping_trolley:update')")
|
||||||
|
@ -69,9 +82,66 @@ public class TShoppingTrolleyController {
|
||||||
@DeleteMapping
|
@DeleteMapping
|
||||||
@Operation(summary = "删除")
|
@Operation(summary = "删除")
|
||||||
@PreAuthorize("hasAuthority('maku:t_shopping_trolley:delete')")
|
@PreAuthorize("hasAuthority('maku:t_shopping_trolley:delete')")
|
||||||
public Result<String> delete(@RequestBody List<Long> idList){
|
public Result<String> delete( @RequestBody List<Long> idList){
|
||||||
tShoppingTrolleyService.delete(idList);
|
tShoppingTrolleyService.delete(idList);
|
||||||
|
|
||||||
return Result.ok();
|
return Result.ok();
|
||||||
}
|
}
|
||||||
|
@PostMapping("/add")
|
||||||
|
@Operation(summary = "添加购物车")
|
||||||
|
public Result<String> add(HttpServletRequest request, @RequestParam Integer bookId){
|
||||||
|
String token = request.getHeader("token");
|
||||||
|
TUserEntity user = (TUserEntity) redisCache.get(token);
|
||||||
|
if(ObjectUtils.isNull(user)){
|
||||||
|
throw new ServerException(ErrorCode.REFRESH_TOKEN_INVALID);
|
||||||
|
}
|
||||||
|
Integer userId=user.getId();
|
||||||
|
tShoppingTrolleyService.add(userId,bookId);
|
||||||
|
return Result.ok("加入购物车成功");
|
||||||
|
}
|
||||||
|
@GetMapping("/myshop")
|
||||||
|
@Operation(summary = "我的购物车")
|
||||||
|
public Result<List<TShoppingTrolleyEntity>> myshop(HttpServletRequest request){
|
||||||
|
String token = request.getHeader("token");
|
||||||
|
TUserEntity user = (TUserEntity) redisCache.get(token);
|
||||||
|
if(ObjectUtils.isNull(user)){
|
||||||
|
throw new ServerException(ErrorCode.REFRESH_TOKEN_INVALID);
|
||||||
|
}
|
||||||
|
Integer userId=user.getId();
|
||||||
|
List<TShoppingTrolleyEntity> list = tShoppingTrolleyService.myshop(userId);
|
||||||
|
return Result.ok(list);
|
||||||
|
}
|
||||||
|
@GetMapping("/newmyshop")
|
||||||
|
public Result<List<TShoppingTrolleyEntity>> getBookCollectionByUserId(HttpServletRequest request) {
|
||||||
|
String token = request.getHeader("token");
|
||||||
|
TUserEntity entity = (TUserEntity) redisCache.get(token);
|
||||||
|
if(ObjectUtils.isNull(entity)){
|
||||||
|
throw new ServerException(ErrorCode.REFRESH_TOKEN_INVALID);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TUserEntity tUserEntity = (TUserEntity) redisCache.get(token);
|
||||||
|
Integer userId=tUserEntity.getId();
|
||||||
|
LocalDateTime currentTime = LocalDateTime.now();
|
||||||
|
ZoneId zoneId = ZoneId.systemDefault();
|
||||||
|
|
||||||
|
//DATE没有时区二localDateTime有时区,为了将 LocalDateTime 转换为 Date,你需要指定一个时区,因为 Date 是基于UTC的
|
||||||
|
// 将LocalDateTime转换为ZonedDateTime,然后转换为Instant,最后转换为Date
|
||||||
|
ZonedDateTime zdt = currentTime.atZone(zoneId);
|
||||||
|
Date date = Date.from(zdt.toInstant());
|
||||||
|
|
||||||
|
return Result.ok(tShoppingTrolleyDao.selectShoppingTrolleyByUserId(Long.valueOf(userId)));
|
||||||
|
}
|
||||||
|
@DeleteMapping("/clean")
|
||||||
|
@Operation(summary = "清空购物车")
|
||||||
|
public Result<String> clean(HttpServletRequest request){
|
||||||
|
String token = request.getHeader("token");
|
||||||
|
TUserEntity user = (TUserEntity) redisCache.get(token);
|
||||||
|
if(ObjectUtils.isNull(user)){
|
||||||
|
throw new ServerException(ErrorCode.REFRESH_TOKEN_INVALID);
|
||||||
|
}
|
||||||
|
Integer userId=user.getId();
|
||||||
|
tShoppingTrolleyService.clean(userId);
|
||||||
|
return Result.ok("清空购物车成功");
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,8 +1,6 @@
|
||||||
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 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 jakarta.servlet.http.HttpServletRequest;
|
||||||
|
@ -10,6 +8,9 @@ import lombok.AllArgsConstructor;
|
||||||
import net.maku.framework.common.cache.RedisCache;
|
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.framework.security.cache.TokenStoreCache;
|
||||||
|
import net.maku.framework.security.config.PasswordConfig;
|
||||||
|
import net.maku.maku.config.PayConfig;
|
||||||
import net.maku.maku.convert.TUserConvert;
|
import net.maku.maku.convert.TUserConvert;
|
||||||
import net.maku.maku.entity.TBookCollectionEntity;
|
import net.maku.maku.entity.TBookCollectionEntity;
|
||||||
import net.maku.maku.entity.TUserEntity;
|
import net.maku.maku.entity.TUserEntity;
|
||||||
|
@ -43,7 +44,8 @@ import static java.util.Collections.list;
|
||||||
public class TUserController {
|
public class TUserController {
|
||||||
private final TUserService tUserService;
|
private final TUserService tUserService;
|
||||||
private final RedisCache redisCache;
|
private final RedisCache redisCache;
|
||||||
|
private final PasswordConfig passwordEncoder;
|
||||||
|
private final TokenStoreCache tokenStoreCache;
|
||||||
|
|
||||||
@PostMapping("/register")
|
@PostMapping("/register")
|
||||||
@Operation(summary = "注册")
|
@Operation(summary = "注册")
|
||||||
|
@ -52,8 +54,14 @@ public class TUserController {
|
||||||
if (existingUser != null) {
|
if (existingUser != null) {
|
||||||
return ResponseEntity.badRequest().body(Result.error("用户名已存在"));
|
return ResponseEntity.badRequest().body(Result.error("用户名已存在"));
|
||||||
} else {
|
} else {
|
||||||
|
//明文注册
|
||||||
tUserService.save(entity);
|
tUserService.save(entity);
|
||||||
return ResponseEntity.ok(Result.ok("注册成功"));
|
return ResponseEntity.ok(Result.ok("注册成功"));
|
||||||
|
//加密注册
|
||||||
|
// String encryptedPassword = passwordEncoder.passwordEncoder().encode(entity.getPassword());
|
||||||
|
// entity.setPassword(encryptedPassword);
|
||||||
|
// tUserService.save(entity);
|
||||||
|
// return ResponseEntity.ok(Result.ok("注册成功"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,13 +69,30 @@ public class TUserController {
|
||||||
@PostMapping("/login")
|
@PostMapping("/login")
|
||||||
@Operation(summary = "登录")
|
@Operation(summary = "登录")
|
||||||
public Result<String> login(@RequestBody TUserEntity entity){
|
public Result<String> login(@RequestBody TUserEntity entity){
|
||||||
|
//加密登录
|
||||||
|
// TUserEntity entity1 = tUserService.findByUsername(entity.getUsername());
|
||||||
|
// if (entity1 != null) {
|
||||||
|
// // 验证密码是否匹配
|
||||||
|
// boolean isMatch = passwordEncoder.passwordEncoder().matches(entity.getPassword(), entity1.getPassword());
|
||||||
|
// if (isMatch) {
|
||||||
|
// String token = UUID.randomUUID().toString();
|
||||||
|
// redisCache.set(token, entity1);
|
||||||
|
// return Result.ok(token);
|
||||||
|
// } else {
|
||||||
|
// return Result.error("密码错误");
|
||||||
|
// }
|
||||||
|
// }else {
|
||||||
|
// return Result.error("用户不存在");
|
||||||
|
// }
|
||||||
|
|
||||||
|
//明文登录
|
||||||
TUserEntity entity1 = tUserService.login(entity);
|
TUserEntity entity1 = tUserService.login(entity);
|
||||||
if(ObjectUtils.isNotNull(entity1)){
|
if(entity1 != null) {
|
||||||
String token = UUID.randomUUID()+"";
|
String token = UUID.randomUUID().toString();
|
||||||
redisCache.set(token, entity1);
|
redisCache.set(token, entity1);
|
||||||
return Result.ok(token);
|
return Result.ok(token);
|
||||||
}else {
|
}else {
|
||||||
return Result.error("登录失败");
|
return Result.error("用户名不存在");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,17 +115,26 @@ public class TUserController {
|
||||||
|
|
||||||
@GetMapping("/recharge")
|
@GetMapping("/recharge")
|
||||||
@Operation(summary = "充值")
|
@Operation(summary = "充值")
|
||||||
public Result<String> recharge(HttpServletRequest request,@RequestParam(value = "balance",required =false) int balance){
|
public Result<String> recharge(HttpServletRequest request,@RequestParam(value = "balance", required = false) Integer balance){
|
||||||
String token = request.getHeader("token");
|
String token = request.getHeader("token");
|
||||||
TUserEntity entity = (TUserEntity) redisCache.get(token);;
|
TUserEntity entity = (TUserEntity) redisCache.get(token);
|
||||||
int money=entity.getBalance();
|
PayConfig payConfig = new PayConfig();
|
||||||
entity.setBalance(money+balance);
|
String orderId = payConfig.generateOrderId();
|
||||||
tUserService.updateById(entity);
|
boolean paymentResult = payConfig.callPaymentService(balance);
|
||||||
return Result.ok();
|
if (paymentResult) {
|
||||||
|
double money = entity.getBalance();
|
||||||
|
entity.setBalance(money + balance);
|
||||||
|
tUserService.updateById(entity);
|
||||||
|
return Result.ok(orderId+"支付成功");
|
||||||
|
} else {
|
||||||
|
return Result.error("支付失败");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@PostMapping("/logout")
|
|
||||||
|
@PostMapping("/logout")
|
||||||
@Operation(summary = "退出登录")
|
@Operation(summary = "退出登录")
|
||||||
public Result<String> logout(HttpServletRequest request) {
|
public Result<String> logout(HttpServletRequest request) {
|
||||||
String token = request.getHeader("token");
|
String token = request.getHeader("token");
|
||||||
|
|
|
@ -4,6 +4,8 @@ import net.maku.framework.mybatis.dao.BaseDao;
|
||||||
import net.maku.maku.entity.TBookCollectionEntity;
|
import net.maku.maku.entity.TBookCollectionEntity;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
|
@ -12,5 +14,5 @@ import org.apache.ibatis.annotations.Mapper;
|
||||||
*/
|
*/
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface TBookCollectionDao extends BaseDao<TBookCollectionEntity> {
|
public interface TBookCollectionDao extends BaseDao<TBookCollectionEntity> {
|
||||||
|
List<TBookCollectionEntity> selectBookCollectionByUserId(Long id);
|
||||||
}
|
}
|
|
@ -4,6 +4,8 @@ import net.maku.framework.mybatis.dao.BaseDao;
|
||||||
import net.maku.maku.entity.TBookCommentEntity;
|
import net.maku.maku.entity.TBookCommentEntity;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
|
@ -12,5 +14,5 @@ import org.apache.ibatis.annotations.Mapper;
|
||||||
*/
|
*/
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface TBookCommentDao extends BaseDao<TBookCommentEntity> {
|
public interface TBookCommentDao extends BaseDao<TBookCommentEntity> {
|
||||||
|
List<TBookCommentEntity> findAll(Long bookId);
|
||||||
}
|
}
|
|
@ -2,7 +2,11 @@ package net.maku.maku.dao;
|
||||||
|
|
||||||
import net.maku.framework.mybatis.dao.BaseDao;
|
import net.maku.framework.mybatis.dao.BaseDao;
|
||||||
import net.maku.maku.entity.TPurchaseDetailsEntity;
|
import net.maku.maku.entity.TPurchaseDetailsEntity;
|
||||||
|
import net.maku.maku.vo.TPurchaseBookDetailsVo;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -12,5 +16,7 @@ import org.apache.ibatis.annotations.Mapper;
|
||||||
*/
|
*/
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface TPurchaseDetailsDao extends BaseDao<TPurchaseDetailsEntity> {
|
public interface TPurchaseDetailsDao extends BaseDao<TPurchaseDetailsEntity> {
|
||||||
|
List<TPurchaseDetailsEntity> selectBookDetilsByUserId(long id);
|
||||||
|
|
||||||
|
List<TPurchaseBookDetailsVo> selectByDeailsId(@Param("id") Integer id);
|
||||||
}
|
}
|
|
@ -4,6 +4,8 @@ import net.maku.framework.mybatis.dao.BaseDao;
|
||||||
import net.maku.maku.entity.TShoppingTrolleyEntity;
|
import net.maku.maku.entity.TShoppingTrolleyEntity;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
|
@ -12,5 +14,6 @@ import org.apache.ibatis.annotations.Mapper;
|
||||||
*/
|
*/
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface TShoppingTrolleyDao extends BaseDao<TShoppingTrolleyEntity> {
|
public interface TShoppingTrolleyDao extends BaseDao<TShoppingTrolleyEntity> {
|
||||||
|
List<TShoppingTrolleyEntity> selectShoppingTrolleyByUserId(long id);
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,7 +1,6 @@
|
||||||
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.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
|
@ -26,4 +25,6 @@ public class TBookCollectionEntity {
|
||||||
|
|
||||||
private Date updateTime;
|
private Date updateTime;
|
||||||
|
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
}
|
}
|
|
@ -11,7 +11,6 @@ import java.util.Date;
|
||||||
* @author 阿沐 babamu@126.com
|
* @author 阿沐 babamu@126.com
|
||||||
* @since 1.0.0 2024-07-16
|
* @since 1.0.0 2024-07-16
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@TableName("t_book_comment")
|
@TableName("t_book_comment")
|
||||||
public class TBookCommentEntity {
|
public class TBookCommentEntity {
|
||||||
|
@ -24,8 +23,6 @@ public class TBookCommentEntity {
|
||||||
|
|
||||||
private String comment;
|
private String comment;
|
||||||
|
|
||||||
private Integer parentId;
|
|
||||||
|
|
||||||
private Date createTime;
|
private Date createTime;
|
||||||
|
|
||||||
private Date updateTime;
|
private Date updateTime;
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
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 net.maku.framework.mybatis.entity.BaseEntity;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @author 阿沐 babamu@126.com
|
* @author 阿沐 babamu@126.com
|
||||||
* @since 1.0.0 2024-07-16
|
* @since 1.0.0 2024-07-16
|
||||||
|
@ -15,9 +15,9 @@ import java.util.Date;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@TableName("t_book")
|
@TableName("t_book")
|
||||||
public class TBookEntity {
|
public class TBookEntity extends BaseEntity {
|
||||||
@TableId
|
|
||||||
private Integer id;
|
|
||||||
|
|
||||||
private String bookName;
|
private String bookName;
|
||||||
|
|
||||||
|
@ -29,12 +29,11 @@ public class TBookEntity {
|
||||||
|
|
||||||
private String introduction;
|
private String introduction;
|
||||||
|
|
||||||
|
private Integer category;
|
||||||
|
|
||||||
private String description;
|
private String description;
|
||||||
|
|
||||||
private Integer store;
|
private Integer store;
|
||||||
|
|
||||||
private Date createTime;
|
|
||||||
|
|
||||||
private Date updateTime;
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,9 +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;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -22,6 +20,8 @@ public class TPurchaseDetailsEntity {
|
||||||
|
|
||||||
private Integer bookId;
|
private Integer bookId;
|
||||||
|
|
||||||
private BigDecimal price;
|
private double price;
|
||||||
|
|
||||||
|
private double count;
|
||||||
|
|
||||||
}
|
}
|
|
@ -27,4 +27,6 @@ public class TPurchaseEntity {
|
||||||
|
|
||||||
private Date updateTime;
|
private Date updateTime;
|
||||||
|
|
||||||
|
private Integer userId;
|
||||||
|
|
||||||
}
|
}
|
|
@ -22,8 +22,14 @@ public class TShoppingTrolleyEntity {
|
||||||
|
|
||||||
private Integer bookId;
|
private Integer bookId;
|
||||||
|
|
||||||
|
private Integer number;
|
||||||
|
|
||||||
private Date createTime;
|
private Date createTime;
|
||||||
|
|
||||||
private Date updateTime;
|
private Date updateTime;
|
||||||
|
|
||||||
|
private Long creator;
|
||||||
|
private Long updater;
|
||||||
|
private Long deleted;
|
||||||
|
|
||||||
}
|
}
|
|
@ -20,14 +20,19 @@ public class TUserEntity {
|
||||||
|
|
||||||
private String username;
|
private String username;
|
||||||
|
|
||||||
|
|
||||||
private String password;
|
private String password;
|
||||||
|
|
||||||
private String avatar;
|
private String avatar;
|
||||||
|
|
||||||
private int balance;
|
private double balance;
|
||||||
|
|
||||||
private Integer status;
|
private Integer status;
|
||||||
|
|
||||||
|
private String phone;
|
||||||
|
|
||||||
|
private String email;
|
||||||
|
|
||||||
private Date createTime;
|
private Date createTime;
|
||||||
|
|
||||||
private Date updateTime;
|
private Date updateTime;
|
||||||
|
|
|
@ -20,5 +20,6 @@ import java.util.Date;
|
||||||
@Schema(description = "查询")
|
@Schema(description = "查询")
|
||||||
public class TBookQuery extends Query {
|
public class TBookQuery extends Query {
|
||||||
private String author;
|
private String author;
|
||||||
|
private Integer category;
|
||||||
private String bookName;
|
private String bookName;
|
||||||
}
|
}
|
|
@ -6,6 +6,7 @@ import net.maku.maku.vo.TBookCollectionVO;
|
||||||
import net.maku.maku.query.TBookCollectionQuery;
|
import net.maku.maku.query.TBookCollectionQuery;
|
||||||
import net.maku.maku.entity.TBookCollectionEntity;
|
import net.maku.maku.entity.TBookCollectionEntity;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -24,6 +25,9 @@ public interface TBookCollectionService extends BaseService<TBookCollectionEntit
|
||||||
|
|
||||||
void delete(List<Long> idList);
|
void delete(List<Long> idList);
|
||||||
|
|
||||||
List<TBookCollectionVO> getPhoneByUseId(Long id);
|
void save(Integer userId, Integer bookId, Date currentTime);
|
||||||
|
|
||||||
|
TBookCollectionEntity getByBookIdandUserId(Integer bookId, Integer userId);
|
||||||
|
|
||||||
|
boolean isBookAlreadyCollected(Integer userId, Integer bookId);
|
||||||
}
|
}
|
|
@ -6,6 +6,7 @@ import net.maku.maku.vo.TBookCommentVO;
|
||||||
import net.maku.maku.query.TBookCommentQuery;
|
import net.maku.maku.query.TBookCommentQuery;
|
||||||
import net.maku.maku.entity.TBookCommentEntity;
|
import net.maku.maku.entity.TBookCommentEntity;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -23,4 +24,8 @@ public interface TBookCommentService extends BaseService<TBookCommentEntity> {
|
||||||
void update(TBookCommentVO vo);
|
void update(TBookCommentVO vo);
|
||||||
|
|
||||||
void delete(List<Long> idList);
|
void delete(List<Long> idList);
|
||||||
|
|
||||||
|
void save(Integer userId, Integer bookId, String comment, Date date);
|
||||||
|
|
||||||
|
List<TBookCommentEntity> getByBookId(Integer bookId);
|
||||||
}
|
}
|
|
@ -24,5 +24,7 @@ public interface TBookService extends BaseService<TBookEntity> {
|
||||||
|
|
||||||
void delete(List<Long> idList);
|
void delete(List<Long> idList);
|
||||||
|
|
||||||
TBookEntity getByName(String bookName);
|
|
||||||
|
List<TBookEntity> getByName(String name);
|
||||||
|
|
||||||
}
|
}
|
|
@ -2,6 +2,10 @@ package net.maku.maku.service;
|
||||||
|
|
||||||
import net.maku.framework.common.utils.PageResult;
|
import net.maku.framework.common.utils.PageResult;
|
||||||
import net.maku.framework.mybatis.service.BaseService;
|
import net.maku.framework.mybatis.service.BaseService;
|
||||||
|
import net.maku.maku.vo.TPurchaseBookDetailsVo;
|
||||||
|
import net.maku.maku.vo.TPurchaseBookVo;
|
||||||
|
import net.maku.maku.entity.TUserEntity;
|
||||||
|
import net.maku.maku.vo.TCardVo;
|
||||||
import net.maku.maku.vo.TPurchaseDetailsVO;
|
import net.maku.maku.vo.TPurchaseDetailsVO;
|
||||||
import net.maku.maku.query.TPurchaseDetailsQuery;
|
import net.maku.maku.query.TPurchaseDetailsQuery;
|
||||||
import net.maku.maku.entity.TPurchaseDetailsEntity;
|
import net.maku.maku.entity.TPurchaseDetailsEntity;
|
||||||
|
@ -23,4 +27,13 @@ public interface TPurchaseDetailsService extends BaseService<TPurchaseDetailsEnt
|
||||||
void update(TPurchaseDetailsVO vo);
|
void update(TPurchaseDetailsVO vo);
|
||||||
|
|
||||||
void delete(List<Long> idList);
|
void delete(List<Long> idList);
|
||||||
|
|
||||||
|
List<TPurchaseBookVo> selectByUserId(Integer userId);
|
||||||
|
|
||||||
|
// boolean purchaseBook(TUserEntity entity, TPurchaseDetailsVO vo);
|
||||||
|
|
||||||
|
boolean purchaseBook(TUserEntity entity, TCardVo vo);
|
||||||
|
|
||||||
|
// boolean purchaseBook(TUserEntity entity);
|
||||||
|
|
||||||
}
|
}
|
|
@ -2,6 +2,8 @@ package net.maku.maku.service;
|
||||||
|
|
||||||
import net.maku.framework.common.utils.PageResult;
|
import net.maku.framework.common.utils.PageResult;
|
||||||
import net.maku.framework.mybatis.service.BaseService;
|
import net.maku.framework.mybatis.service.BaseService;
|
||||||
|
import net.maku.maku.entity.TPurchaseDetailsEntity;
|
||||||
|
import net.maku.maku.entity.TUserEntity;
|
||||||
import net.maku.maku.vo.TPurchaseVO;
|
import net.maku.maku.vo.TPurchaseVO;
|
||||||
import net.maku.maku.query.TPurchaseQuery;
|
import net.maku.maku.query.TPurchaseQuery;
|
||||||
import net.maku.maku.entity.TPurchaseEntity;
|
import net.maku.maku.entity.TPurchaseEntity;
|
||||||
|
@ -23,4 +25,6 @@ public interface TPurchaseService extends BaseService<TPurchaseEntity> {
|
||||||
void update(TPurchaseVO vo);
|
void update(TPurchaseVO vo);
|
||||||
|
|
||||||
void delete(List<Long> idList);
|
void delete(List<Long> idList);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -6,6 +6,7 @@ import net.maku.maku.vo.TShoppingTrolleyVO;
|
||||||
import net.maku.maku.query.TShoppingTrolleyQuery;
|
import net.maku.maku.query.TShoppingTrolleyQuery;
|
||||||
import net.maku.maku.entity.TShoppingTrolleyEntity;
|
import net.maku.maku.entity.TShoppingTrolleyEntity;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -23,4 +24,13 @@ public interface TShoppingTrolleyService extends BaseService<TShoppingTrolleyEnt
|
||||||
void update(TShoppingTrolleyVO vo);
|
void update(TShoppingTrolleyVO vo);
|
||||||
|
|
||||||
void delete(List<Long> idList);
|
void delete(List<Long> idList);
|
||||||
|
|
||||||
|
void save(Integer userId, Integer bookId, Date date);
|
||||||
|
|
||||||
|
|
||||||
|
TShoppingTrolleyEntity add(Integer userId, Integer bookId);
|
||||||
|
|
||||||
|
List<TShoppingTrolleyEntity> myshop(Integer userId);
|
||||||
|
|
||||||
|
void clean(Integer userId);
|
||||||
}
|
}
|
|
@ -28,4 +28,6 @@ public interface TUserService extends BaseService<TUserEntity> {
|
||||||
|
|
||||||
TUserVO updateUser(TUserVO vo);
|
TUserVO updateUser(TUserVO vo);
|
||||||
|
|
||||||
|
TUserEntity findByUsername(String username);
|
||||||
|
|
||||||
}
|
}
|
|
@ -4,23 +4,20 @@ import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
||||||
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;
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
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.mybatis.service.impl.BaseServiceImpl;
|
import net.maku.framework.mybatis.service.impl.BaseServiceImpl;
|
||||||
import net.maku.maku.convert.TBookCollectionConvert;
|
import net.maku.maku.convert.TBookCollectionConvert;
|
||||||
import net.maku.maku.entity.TBookCollectionEntity;
|
import net.maku.maku.entity.TBookCollectionEntity;
|
||||||
import net.maku.maku.entity.TBookEntity;
|
|
||||||
import net.maku.maku.entity.TUserEntity;
|
|
||||||
import net.maku.maku.query.TBookCollectionQuery;
|
import net.maku.maku.query.TBookCollectionQuery;
|
||||||
import net.maku.maku.service.TUserService;
|
|
||||||
import net.maku.maku.vo.TBookCollectionVO;
|
import net.maku.maku.vo.TBookCollectionVO;
|
||||||
import net.maku.maku.dao.TBookCollectionDao;
|
import net.maku.maku.dao.TBookCollectionDao;
|
||||||
import net.maku.maku.service.TBookCollectionService;
|
import net.maku.maku.service.TBookCollectionService;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -69,9 +66,29 @@ public class TBookCollectionServiceImpl extends BaseServiceImpl<TBookCollectionD
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<TBookCollectionVO> getPhoneByUseId(Long id) {
|
public void save(Integer userId, Integer bookId, Date currentTime) {
|
||||||
return List.of();
|
TBookCollectionEntity entity = new TBookCollectionEntity();
|
||||||
|
entity.setUserId(userId);
|
||||||
|
entity.setBookId(bookId);
|
||||||
|
entity.setCreateTime(currentTime);
|
||||||
|
entity.setStatus(1);
|
||||||
|
this.save(entity);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
}
|
public TBookCollectionEntity getByBookIdandUserId(Integer bookId, Integer userId) {
|
||||||
|
LambdaQueryWrapper<TBookCollectionEntity> wrapper = Wrappers.lambdaQuery();
|
||||||
|
wrapper.eq(TBookCollectionEntity::getBookId, bookId);
|
||||||
|
wrapper.eq(TBookCollectionEntity::getUserId, userId);
|
||||||
|
return baseMapper.selectOne(wrapper);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public boolean isBookAlreadyCollected(Integer userId, Integer bookId) {
|
||||||
|
LambdaQueryWrapper<TBookCollectionEntity> wrapper = Wrappers.lambdaQuery();
|
||||||
|
wrapper.eq(TBookCollectionEntity::getBookId, bookId);
|
||||||
|
wrapper.eq(TBookCollectionEntity::getUserId, userId);
|
||||||
|
wrapper.eq(TBookCollectionEntity::getStatus, 1);
|
||||||
|
return baseMapper.selectCount(wrapper) > 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ import net.maku.maku.service.TBookCommentService;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -40,6 +41,7 @@ public class TBookCommentServiceImpl extends BaseServiceImpl<TBookCommentDao, TB
|
||||||
wrapper.eq(ObjectUtil.isNotNull(query.getUserId()), TBookCommentEntity::getUserId, query.getUserId());
|
wrapper.eq(ObjectUtil.isNotNull(query.getUserId()), TBookCommentEntity::getUserId, query.getUserId());
|
||||||
wrapper.eq(ObjectUtil.isNotNull(query.getBookId()), TBookCommentEntity::getBookId, query.getBookId());
|
wrapper.eq(ObjectUtil.isNotNull(query.getBookId()), TBookCommentEntity::getBookId, query.getBookId());
|
||||||
|
|
||||||
|
|
||||||
return wrapper;
|
return wrapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,4 +65,21 @@ public class TBookCommentServiceImpl extends BaseServiceImpl<TBookCommentDao, TB
|
||||||
removeByIds(idList);
|
removeByIds(idList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void save(Integer userId, Integer bookId, String comment, Date date) {
|
||||||
|
TBookCommentEntity entity = new TBookCommentEntity();
|
||||||
|
entity.setUserId(userId);
|
||||||
|
entity.setBookId(bookId);
|
||||||
|
entity.setComment(comment);
|
||||||
|
entity.setCreateTime(date);
|
||||||
|
baseMapper.insert(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<TBookCommentEntity> getByBookId(Integer bookId) {
|
||||||
|
LambdaQueryWrapper<TBookCommentEntity> wrapper = Wrappers.lambdaQuery();
|
||||||
|
wrapper.eq(TBookCommentEntity::getBookId, bookId);
|
||||||
|
return baseMapper.selectList(wrapper);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,9 +1,11 @@
|
||||||
package net.maku.maku.service.impl;
|
package net.maku.maku.service.impl;
|
||||||
|
|
||||||
|
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;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
|
import net.maku.framework.common.exception.ServerException;
|
||||||
import net.maku.framework.common.utils.PageResult;
|
import net.maku.framework.common.utils.PageResult;
|
||||||
import net.maku.framework.mybatis.service.impl.BaseServiceImpl;
|
import net.maku.framework.mybatis.service.impl.BaseServiceImpl;
|
||||||
import net.maku.maku.convert.TBookConvert;
|
import net.maku.maku.convert.TBookConvert;
|
||||||
|
@ -38,6 +40,7 @@ public class TBookServiceImpl extends BaseServiceImpl<TBookDao, TBookEntity> imp
|
||||||
LambdaQueryWrapper<TBookEntity> wrapper = Wrappers.lambdaQuery();
|
LambdaQueryWrapper<TBookEntity> wrapper = Wrappers.lambdaQuery();
|
||||||
wrapper.like(TBookEntity::getBookName, query.getBookName());
|
wrapper.like(TBookEntity::getBookName, query.getBookName());
|
||||||
wrapper.like(TBookEntity::getAuthor, query.getAuthor());
|
wrapper.like(TBookEntity::getAuthor, query.getAuthor());
|
||||||
|
wrapper.eq(ObjectUtil.isNotNull(query.getCategory()), TBookEntity::getCategory, query.getCategory());
|
||||||
return wrapper;
|
return wrapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,11 +65,14 @@ public class TBookServiceImpl extends BaseServiceImpl<TBookDao, TBookEntity> imp
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TBookEntity getByName(String bookName) {
|
public List<TBookEntity> getByName(String bookName) {
|
||||||
LambdaQueryWrapper<TBookEntity> wrapper = Wrappers.lambdaQuery();
|
LambdaQueryWrapper<TBookEntity> wrapper = Wrappers.lambdaQuery();
|
||||||
wrapper.eq(TBookEntity::getBookName, bookName);
|
wrapper.eq(TBookEntity::getBookName, bookName);
|
||||||
return baseMapper.selectOne(wrapper);
|
List<TBookEntity> tBookEntity = baseMapper.selectList(wrapper);
|
||||||
|
if (ObjectUtil.isNull(tBookEntity)){
|
||||||
|
throw new ServerException("没有找到书籍");
|
||||||
|
}
|
||||||
|
return tBookEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -8,14 +8,24 @@ import lombok.AllArgsConstructor;
|
||||||
import net.maku.framework.common.utils.PageResult;
|
import net.maku.framework.common.utils.PageResult;
|
||||||
import net.maku.framework.mybatis.service.impl.BaseServiceImpl;
|
import net.maku.framework.mybatis.service.impl.BaseServiceImpl;
|
||||||
import net.maku.maku.convert.TPurchaseDetailsConvert;
|
import net.maku.maku.convert.TPurchaseDetailsConvert;
|
||||||
|
import net.maku.maku.dao.TPurchaseDao;
|
||||||
import net.maku.maku.entity.TPurchaseDetailsEntity;
|
import net.maku.maku.entity.TPurchaseDetailsEntity;
|
||||||
|
import net.maku.maku.entity.TPurchaseEntity;
|
||||||
|
import net.maku.maku.entity.TUserEntity;
|
||||||
import net.maku.maku.query.TPurchaseDetailsQuery;
|
import net.maku.maku.query.TPurchaseDetailsQuery;
|
||||||
|
import net.maku.maku.vo.TPurchaseBookDetailsVo;
|
||||||
|
import net.maku.maku.vo.TPurchaseBookVo;
|
||||||
|
import net.maku.maku.service.TUserService;
|
||||||
|
import net.maku.maku.vo.TCardVo;
|
||||||
import net.maku.maku.vo.TPurchaseDetailsVO;
|
import net.maku.maku.vo.TPurchaseDetailsVO;
|
||||||
import net.maku.maku.dao.TPurchaseDetailsDao;
|
import net.maku.maku.dao.TPurchaseDetailsDao;
|
||||||
import net.maku.maku.service.TPurchaseDetailsService;
|
import net.maku.maku.service.TPurchaseDetailsService;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -28,6 +38,10 @@ import java.util.List;
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class TPurchaseDetailsServiceImpl extends BaseServiceImpl<TPurchaseDetailsDao, TPurchaseDetailsEntity> implements TPurchaseDetailsService {
|
public class TPurchaseDetailsServiceImpl extends BaseServiceImpl<TPurchaseDetailsDao, TPurchaseDetailsEntity> implements TPurchaseDetailsService {
|
||||||
|
|
||||||
|
private final TPurchaseDetailsDao tPurchaseDetailsDao;
|
||||||
|
private final TPurchaseDao tPurchaseDao;
|
||||||
|
|
||||||
|
private final TUserService tUserService;
|
||||||
@Override
|
@Override
|
||||||
public PageResult<TPurchaseDetailsVO> page(TPurchaseDetailsQuery query) {
|
public PageResult<TPurchaseDetailsVO> page(TPurchaseDetailsQuery query) {
|
||||||
IPage<TPurchaseDetailsEntity> page = baseMapper.selectPage(getPage(query), getWrapper(query));
|
IPage<TPurchaseDetailsEntity> page = baseMapper.selectPage(getPage(query), getWrapper(query));
|
||||||
|
@ -62,4 +76,74 @@ public class TPurchaseDetailsServiceImpl extends BaseServiceImpl<TPurchaseDetail
|
||||||
removeByIds(idList);
|
removeByIds(idList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<TPurchaseBookVo> selectByUserId(Integer userId) {
|
||||||
|
LambdaQueryWrapper<TPurchaseEntity> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
lambdaQueryWrapper.eq(TPurchaseEntity::getUserId,userId);
|
||||||
|
List<TPurchaseEntity> tPurchaseEntities = tPurchaseDao.selectList(lambdaQueryWrapper);
|
||||||
|
List<TPurchaseBookVo> tPurchaseBookDetailsVos = new ArrayList<>();
|
||||||
|
for (TPurchaseEntity tPurchaseEntity : tPurchaseEntities){
|
||||||
|
TPurchaseBookVo vo = new TPurchaseBookVo();
|
||||||
|
|
||||||
|
// 图书详情
|
||||||
|
BeanUtils.copyProperties(tPurchaseEntity,vo);
|
||||||
|
List<TPurchaseBookDetailsVo> list =tPurchaseDetailsDao.selectByDeailsId(vo.getId());
|
||||||
|
|
||||||
|
vo.setBook_details(list);
|
||||||
|
tPurchaseBookDetailsVos.add(vo);
|
||||||
|
}
|
||||||
|
return tPurchaseBookDetailsVos;
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Override
|
||||||
|
// public boolean purchaseBook(TUserEntity entity, TPurchaseDetailsVO vo) {
|
||||||
|
//
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean purchaseBook(TUserEntity entity,TCardVo vo) {
|
||||||
|
//查询数据库订单表
|
||||||
|
LambdaQueryWrapper<TPurchaseDetailsEntity> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
List<TPurchaseDetailsEntity> list = baseMapper.selectList(
|
||||||
|
wrapper.eq(TPurchaseDetailsEntity::getPurchaseId,entity.getId()));
|
||||||
|
for (int i = 0; i < vo.getBooks().size(); i++){
|
||||||
|
for(int j=0;j<list.size();j++){
|
||||||
|
if(vo.getBooks().get(i).getBookId()==list.get(j).getBookId()){
|
||||||
|
double price = list.get(j).getPrice();
|
||||||
|
double count =list.get(j).getCount();
|
||||||
|
double balance= entity.getBalance();
|
||||||
|
if (balance>=price*count){
|
||||||
|
double newBalance = balance-price*count;
|
||||||
|
entity.setBalance(newBalance);
|
||||||
|
tUserService.updateById(entity);
|
||||||
|
removeById(list.get(j).getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// @Override
|
||||||
|
// public boolean purchaseBook(TUserEntity entity) {
|
||||||
|
// LambdaQueryWrapper<TPurchaseDetailsEntity> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
// wrapper.eq(TPurchaseDetailsEntity::getPurchaseId,entity.getId());
|
||||||
|
// TPurchaseDetailsEntity one =getOne(wrapper);
|
||||||
|
// double price = one.getPrice();
|
||||||
|
// double count =one.getCount();
|
||||||
|
// double balance= entity.getBalance();
|
||||||
|
// if (balance>=price*count){
|
||||||
|
// double newBalance = balance-price*count;
|
||||||
|
// entity.setBalance(newBalance);
|
||||||
|
// tUserService.updateById(entity);
|
||||||
|
// return true;
|
||||||
|
// }
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
|
// return true;}
|
||||||
|
|
||||||
}
|
}
|
|
@ -10,6 +10,7 @@ import net.maku.framework.mybatis.service.impl.BaseServiceImpl;
|
||||||
import net.maku.maku.convert.TPurchaseConvert;
|
import net.maku.maku.convert.TPurchaseConvert;
|
||||||
import net.maku.maku.entity.TPurchaseEntity;
|
import net.maku.maku.entity.TPurchaseEntity;
|
||||||
import net.maku.maku.query.TPurchaseQuery;
|
import net.maku.maku.query.TPurchaseQuery;
|
||||||
|
import net.maku.maku.service.TUserService;
|
||||||
import net.maku.maku.vo.TPurchaseVO;
|
import net.maku.maku.vo.TPurchaseVO;
|
||||||
import net.maku.maku.dao.TPurchaseDao;
|
import net.maku.maku.dao.TPurchaseDao;
|
||||||
import net.maku.maku.service.TPurchaseService;
|
import net.maku.maku.service.TPurchaseService;
|
||||||
|
|
|
@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
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.mybatis.service.impl.BaseServiceImpl;
|
import net.maku.framework.mybatis.service.impl.BaseServiceImpl;
|
||||||
import net.maku.maku.convert.TShoppingTrolleyConvert;
|
import net.maku.maku.convert.TShoppingTrolleyConvert;
|
||||||
import net.maku.maku.entity.TShoppingTrolleyEntity;
|
import net.maku.maku.entity.TShoppingTrolleyEntity;
|
||||||
|
@ -16,6 +17,7 @@ import net.maku.maku.service.TShoppingTrolleyService;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -35,10 +37,10 @@ public class TShoppingTrolleyServiceImpl extends BaseServiceImpl<TShoppingTrolle
|
||||||
return new PageResult<>(TShoppingTrolleyConvert.INSTANCE.convertList(page.getRecords()), page.getTotal());
|
return new PageResult<>(TShoppingTrolleyConvert.INSTANCE.convertList(page.getRecords()), page.getTotal());
|
||||||
}
|
}
|
||||||
|
|
||||||
private LambdaQueryWrapper<TShoppingTrolleyEntity> getWrapper(TShoppingTrolleyQuery query){
|
private LambdaQueryWrapper<TShoppingTrolleyEntity> getWrapper(TShoppingTrolleyQuery query) {
|
||||||
LambdaQueryWrapper<TShoppingTrolleyEntity> wrapper = Wrappers.lambdaQuery();
|
LambdaQueryWrapper<TShoppingTrolleyEntity> wrapper = Wrappers.lambdaQuery();
|
||||||
wrapper.eq(ObjectUtils.isNotNull(query.getUserId()), TShoppingTrolleyEntity::getUserId,query.getUserId());
|
wrapper.eq(ObjectUtils.isNotNull(query.getUserId()), TShoppingTrolleyEntity::getUserId, query.getUserId());
|
||||||
wrapper.eq(ObjectUtils.isNotNull(query.getBookId()),TShoppingTrolleyEntity::getBookId, query.getBookId());
|
wrapper.eq(ObjectUtils.isNotNull(query.getBookId()), TShoppingTrolleyEntity::getBookId, query.getBookId());
|
||||||
return wrapper;
|
return wrapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,4 +64,65 @@ public class TShoppingTrolleyServiceImpl extends BaseServiceImpl<TShoppingTrolle
|
||||||
removeByIds(idList);
|
removeByIds(idList);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
@Override
|
||||||
|
public void save(Integer userId, Integer bookId, Date currentTime) {
|
||||||
|
TShoppingTrolleyEntity entity = new TShoppingTrolleyEntity();
|
||||||
|
entity.setUserId(userId);
|
||||||
|
entity.setBookId(bookId);
|
||||||
|
entity.setCreateTime(currentTime);
|
||||||
|
// 可以根据需要设置其它字段,例如自增id字段和lastModifiedTime字段(如果需要)
|
||||||
|
|
||||||
|
// 假设lastModifiedTime可以为空,可以根据需要设置
|
||||||
|
|
||||||
|
// 使用 MyBatis Plus 的 save 方法保存实体
|
||||||
|
this.save(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TShoppingTrolleyEntity add(Integer userId, Integer bookId) {
|
||||||
|
LambdaQueryWrapper<TShoppingTrolleyEntity> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
queryWrapper.eq(TShoppingTrolleyEntity::getUserId, userId);
|
||||||
|
queryWrapper.eq(TShoppingTrolleyEntity::getBookId, bookId);
|
||||||
|
TShoppingTrolleyEntity existingEntity = baseMapper.selectOne(queryWrapper);
|
||||||
|
|
||||||
|
if (existingEntity != null) {
|
||||||
|
// 如果购物车中已存在该记录,则增加数量
|
||||||
|
Integer number = existingEntity.getNumber();
|
||||||
|
//为空+1,不为空为1
|
||||||
|
existingEntity.setNumber(number != null ? number + 1 : 1);
|
||||||
|
baseMapper.updateById(existingEntity);
|
||||||
|
} else {
|
||||||
|
// 如果购物车中不存在该记录,则创建新记录
|
||||||
|
TShoppingTrolleyEntity newEntity = new TShoppingTrolleyEntity();
|
||||||
|
newEntity.setUserId(userId);
|
||||||
|
newEntity.setBookId(bookId);
|
||||||
|
newEntity.setNumber(1); // 初始数量为1
|
||||||
|
|
||||||
|
baseMapper.insert(newEntity);
|
||||||
|
existingEntity = newEntity; // 返回新创建的实体
|
||||||
|
}
|
||||||
|
|
||||||
|
return existingEntity;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<TShoppingTrolleyEntity> myshop(Integer userId) {
|
||||||
|
LambdaQueryWrapper<TShoppingTrolleyEntity> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
queryWrapper.eq(TShoppingTrolleyEntity::getUserId, userId);
|
||||||
|
return baseMapper.selectList(queryWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void clean(Integer userId) {
|
||||||
|
LambdaQueryWrapper<TShoppingTrolleyEntity> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
queryWrapper.eq(TShoppingTrolleyEntity::getUserId, userId);
|
||||||
|
baseMapper.delete(queryWrapper);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -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;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -28,7 +27,6 @@ import java.util.UUID;
|
||||||
@Service
|
@Service
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class TUserServiceImpl extends BaseServiceImpl<TUserDao, TUserEntity> implements TUserService {
|
public class TUserServiceImpl extends BaseServiceImpl<TUserDao, TUserEntity> implements TUserService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageResult<TUserVO> page(TUserQuery query) {
|
public PageResult<TUserVO> page(TUserQuery query) {
|
||||||
IPage<TUserEntity> page = baseMapper.selectPage(getPage(query), getWrapper(query));
|
IPage<TUserEntity> page = baseMapper.selectPage(getPage(query), getWrapper(query));
|
||||||
|
@ -85,4 +83,16 @@ public class TUserServiceImpl extends BaseServiceImpl<TUserDao, TUserEntity> imp
|
||||||
return vo;
|
return vo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TUserEntity findByUsername(String username) {
|
||||||
|
LambdaQueryWrapper<TUserEntity> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.eq(TUserEntity::getUsername,username);
|
||||||
|
TUserEntity one = getOne(wrapper);
|
||||||
|
if(ObjectUtils.isNotNull(one)) {
|
||||||
|
return one;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -14,7 +14,7 @@ import java.util.Date;
|
||||||
* @since 1.0.0 2024-07-16
|
* @since 1.0.0 2024-07-16
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@Schema(description = "")
|
@Schema(description = "书籍收藏表视图数据")
|
||||||
public class TBookCollectionVO implements Serializable {
|
public class TBookCollectionVO implements Serializable {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@ -22,6 +22,8 @@ public class TBookCollectionVO implements Serializable {
|
||||||
|
|
||||||
private Integer userId;
|
private Integer userId;
|
||||||
|
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
private Integer bookId;
|
private Integer bookId;
|
||||||
|
|
||||||
@JsonFormat(pattern = DateUtils.DATE_TIME_PATTERN)
|
@JsonFormat(pattern = DateUtils.DATE_TIME_PATTERN)
|
||||||
|
|
|
@ -14,7 +14,7 @@ import java.util.Date;
|
||||||
* @since 1.0.0 2024-07-16
|
* @since 1.0.0 2024-07-16
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@Schema(description = "")
|
@Schema(description = "书籍评论表视图数据")
|
||||||
public class TBookCommentVO implements Serializable {
|
public class TBookCommentVO implements Serializable {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@ -26,8 +26,6 @@ public class TBookCommentVO implements Serializable {
|
||||||
|
|
||||||
private String comment;
|
private String comment;
|
||||||
|
|
||||||
private Integer parentId;
|
|
||||||
|
|
||||||
@JsonFormat(pattern = DateUtils.DATE_TIME_PATTERN)
|
@JsonFormat(pattern = DateUtils.DATE_TIME_PATTERN)
|
||||||
private Date createTime;
|
private Date createTime;
|
||||||
|
|
||||||
|
|
|
@ -15,11 +15,11 @@ import java.util.Date;
|
||||||
* @since 1.0.0 2024-07-16
|
* @since 1.0.0 2024-07-16
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@Schema(description = "")
|
@Schema(description = "书本视图数据")
|
||||||
public class TBookVO implements Serializable {
|
public class TBookVO implements Serializable {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private Integer id;
|
private Long id;
|
||||||
|
|
||||||
private String bookName;
|
private String bookName;
|
||||||
|
|
||||||
|
@ -29,6 +29,8 @@ public class TBookVO implements Serializable {
|
||||||
|
|
||||||
private String bookCover;
|
private String bookCover;
|
||||||
|
|
||||||
|
private String category;
|
||||||
|
|
||||||
private String introduction;
|
private String introduction;
|
||||||
|
|
||||||
private String description;
|
private String description;
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
package net.maku.maku.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class TCardVo {
|
||||||
|
private List<TPurchaseDetailsVO> books;
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
package net.maku.maku.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 功能:
|
||||||
|
* 作者:程序员青戈
|
||||||
|
* 日期:2024/7/23 16:44
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class TPurchaseBookDetailsVo {
|
||||||
|
|
||||||
|
private Integer id;
|
||||||
|
private String bookName;
|
||||||
|
private String price;
|
||||||
|
private String bookCover;
|
||||||
|
private String introduction;
|
||||||
|
|
||||||
|
private String count;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
package net.maku.maku.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 功能:
|
||||||
|
* 作者:程序员青戈
|
||||||
|
* 日期:2024/7/23 16:42
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class TPurchaseBookVo {
|
||||||
|
private Integer id;
|
||||||
|
private Date tradingHour;
|
||||||
|
private BigDecimal totalPrice;
|
||||||
|
private List<TPurchaseBookDetailsVo> book_details;
|
||||||
|
}
|
|
@ -14,7 +14,7 @@ import java.math.BigDecimal;
|
||||||
* @since 1.0.0 2024-07-16
|
* @since 1.0.0 2024-07-16
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@Schema(description = "")
|
@Schema(description = "订单详情表视图数据")
|
||||||
public class TPurchaseDetailsVO implements Serializable {
|
public class TPurchaseDetailsVO implements Serializable {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@ -24,7 +24,9 @@ public class TPurchaseDetailsVO implements Serializable {
|
||||||
|
|
||||||
private Integer bookId;
|
private Integer bookId;
|
||||||
|
|
||||||
private BigDecimal price;
|
private double price;
|
||||||
|
|
||||||
|
private Integer count;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -15,7 +15,7 @@ import java.util.Date;
|
||||||
* @since 1.0.0 2024-07-16
|
* @since 1.0.0 2024-07-16
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@Schema(description = "")
|
@Schema(description = "书籍订单表视图数据")
|
||||||
public class TPurchaseVO implements Serializable {
|
public class TPurchaseVO implements Serializable {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ import java.util.Date;
|
||||||
* @since 1.0.0 2024-07-16
|
* @since 1.0.0 2024-07-16
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@Schema(description = "")
|
@Schema(description = "购物车视图数据")
|
||||||
public class TShoppingTrolleyVO implements Serializable {
|
public class TShoppingTrolleyVO implements Serializable {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@ -24,6 +24,8 @@ public class TShoppingTrolleyVO implements Serializable {
|
||||||
|
|
||||||
private Integer bookId;
|
private Integer bookId;
|
||||||
|
|
||||||
|
private Integer number;
|
||||||
|
|
||||||
@JsonFormat(pattern = DateUtils.DATE_TIME_PATTERN)
|
@JsonFormat(pattern = DateUtils.DATE_TIME_PATTERN)
|
||||||
private Date createTime;
|
private Date createTime;
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ import java.util.Date;
|
||||||
* @since 1.0.0 2024-07-16
|
* @since 1.0.0 2024-07-16
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@Schema(description = "")
|
@Schema(description = "用户视图数据")
|
||||||
public class TUserVO implements Serializable {
|
public class TUserVO implements Serializable {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@ -31,6 +31,10 @@ public class TUserVO implements Serializable {
|
||||||
|
|
||||||
private Integer status;
|
private Integer status;
|
||||||
|
|
||||||
|
private String email;
|
||||||
|
|
||||||
|
private String phonne;
|
||||||
|
|
||||||
@JsonFormat(pattern = DateUtils.DATE_TIME_PATTERN)
|
@JsonFormat(pattern = DateUtils.DATE_TIME_PATTERN)
|
||||||
private Date createTime;
|
private Date createTime;
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ spring:
|
||||||
database: 0
|
database: 0
|
||||||
host: localhost
|
host: localhost
|
||||||
port: 6379
|
port: 6379
|
||||||
password: 123456
|
# password: 123456
|
||||||
#timeout: 6000ms # 连接超时时长(毫秒)
|
#timeout: 6000ms # 连接超时时长(毫秒)
|
||||||
datasource:
|
datasource:
|
||||||
dynamic:
|
dynamic:
|
||||||
|
|
|
@ -11,4 +11,16 @@
|
||||||
<result property="updateTime" column="update_time"/>
|
<result property="updateTime" column="update_time"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
|
<select id="selectBookCollectionByUserId" parameterType="map" resultType="map">
|
||||||
|
SELECT
|
||||||
|
(@row_number:=@row_number + 1) AS id,
|
||||||
|
tb.book_name,
|
||||||
|
tb.price,
|
||||||
|
tb.book_cover
|
||||||
|
FROM
|
||||||
|
t_book_collection bc
|
||||||
|
LEFT JOIN `t_book` tb ON bc.book_id=tb.id,
|
||||||
|
(SELECT @row_number := 0) AS dummy
|
||||||
|
WHERE user_id = #{id}
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
|
@ -8,9 +8,22 @@
|
||||||
<result property="userId" column="user_id"/>
|
<result property="userId" column="user_id"/>
|
||||||
<result property="bookId" column="book_id"/>
|
<result property="bookId" column="book_id"/>
|
||||||
<result property="comment" column="comment"/>
|
<result property="comment" column="comment"/>
|
||||||
<result property="parentId" column="parent_id"/>
|
|
||||||
<result property="createTime" column="create_time"/>
|
<result property="createTime" column="create_time"/>
|
||||||
<result property="updateTime" column="update_time"/>
|
<result property="updateTime" column="update_time"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
<select id="findAll" parameterType="map" resultType="map">
|
||||||
|
SELECT
|
||||||
|
tb.book_name,
|
||||||
|
tu.username,
|
||||||
|
tb.book_cover,
|
||||||
|
tc.comment
|
||||||
|
FROM
|
||||||
|
t_book_comment tc
|
||||||
|
LEFT JOIN t_book tb ON tc.book_id = tb.id
|
||||||
|
LEFT JOIN t_user tu ON tc.user_id = tu.id
|
||||||
|
|
||||||
|
WHERE
|
||||||
|
tc.user_id = #{id}
|
||||||
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
|
@ -10,4 +10,35 @@
|
||||||
<result property="price" column="price"/>
|
<result property="price" column="price"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- <select id="selectBookDetilsByUserId" parameterType="map" resultType="map">-->
|
||||||
|
<!-- SELECT-->
|
||||||
|
<!-- (@row_number:=@row_number + 1) AS id,-->
|
||||||
|
<!-- pd.create_time AS trading_hour,-->
|
||||||
|
<!-- pd.price*pd.count As total_price,-->
|
||||||
|
<!-- JSON_ARRAYAGG(-->
|
||||||
|
<!-- JSON_OBJECT(-->
|
||||||
|
<!-- 'id', pd.id,-->
|
||||||
|
<!-- 'book_name', tb.book_name,-->
|
||||||
|
<!-- 'price', pd.price,-->
|
||||||
|
<!-- 'book_cover', tb.book_cover,-->
|
||||||
|
<!-- 'introduction', tb.introduction,-->
|
||||||
|
<!-- 'description', tb.description,-->
|
||||||
|
<!-- 'create_time', pd.create_time,-->
|
||||||
|
<!-- 'update_time', pd.update_time-->
|
||||||
|
<!-- )-->
|
||||||
|
<!-- ) AS book_details-->
|
||||||
|
<!-- FROM t_purchase_details pd-->
|
||||||
|
<!-- LEFT JOIN t_book tb ON pd.book_id=tb.id,-->
|
||||||
|
<!-- (SELECT @row_number := 0) AS dummy-->
|
||||||
|
<!-- WHERE pd.creator=#{id}-->
|
||||||
|
<!-- </select>-->
|
||||||
|
<select id="selectBookDetilsByUserId" parameterType="map" resultType="map">
|
||||||
|
|
||||||
|
</select>
|
||||||
|
<select id="selectByDeailsId" resultType="net.maku.maku.vo.TPurchaseBookDetailsVo">
|
||||||
|
select tb.id,tb.book_name,tb.price,tb.introduction,tb.book_cover,tp.count from t_purchase_details tp
|
||||||
|
LEFT JOIN t_book tb on tp.book_id = tb.id
|
||||||
|
WHERE tp.purchase_id = #{id};
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
|
@ -9,6 +9,23 @@
|
||||||
<result property="bookId" column="book_id"/>
|
<result property="bookId" column="book_id"/>
|
||||||
<result property="createTime" column="create_time"/>
|
<result property="createTime" column="create_time"/>
|
||||||
<result property="updateTime" column="update_time"/>
|
<result property="updateTime" column="update_time"/>
|
||||||
|
<!-- <result property="creator" column="creator"/>-->
|
||||||
|
<!-- <result property="updater" column="updater"/>-->
|
||||||
|
<!-- <result property="deleted" column="deleted"/>-->
|
||||||
|
<result property="number" column="number"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
|
|
||||||
|
<select id="selectShoppingTrolleyByUserId" parameterType="map" resultType="map">
|
||||||
|
SELECT (@row_number:=@row_number + 1) AS id,
|
||||||
|
tb.book_name,
|
||||||
|
tb.price,
|
||||||
|
tb.book_cover,
|
||||||
|
tb.introduction,
|
||||||
|
st.number
|
||||||
|
FROM t_shopping_trolley st
|
||||||
|
LEFT JOIN t_book tb ON st.book_id=tb.id,
|
||||||
|
(SELECT @row_number := 0) AS dummy
|
||||||
|
WHERE st.user_id=#{id}
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
|
@ -14,4 +14,12 @@
|
||||||
<result property="updateTime" column="update_time"/>
|
<result property="updateTime" column="update_time"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- SELECT-->
|
||||||
|
<!-- (@row_number:=@row_number + 1) AS id,-->
|
||||||
|
|
||||||
|
<!-- FROM t_book tb-->
|
||||||
|
<!-- LEFT JOIN t_purchase_details pd ON tb.id=pd-->
|
||||||
|
<!-- (SELECT @row_number := 0) AS dummy-->
|
||||||
|
<!-- WHERE .user_id=#{id}-->
|
||||||
</mapper>
|
</mapper>
|
|
@ -6,6 +6,8 @@ import net.maku.framework.common.excel.ExcelFinishCallBack;
|
||||||
import net.maku.framework.common.excel.LocalDateTimeConverter;
|
import net.maku.framework.common.excel.LocalDateTimeConverter;
|
||||||
import net.maku.framework.common.utils.ExcelUtils;
|
import net.maku.framework.common.utils.ExcelUtils;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||||
|
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
@ -18,6 +20,23 @@ import java.util.List;
|
||||||
* @author eden
|
* @author eden
|
||||||
*/
|
*/
|
||||||
public class EasyExcelTest {
|
public class EasyExcelTest {
|
||||||
|
@Test
|
||||||
|
void IDcTest(){
|
||||||
|
int randomPart = (int) (Math.random() * 1000000000);
|
||||||
|
System.out.println(randomPart);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void bcTest(){
|
||||||
|
PasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
|
||||||
|
String rawpassword = "123456";
|
||||||
|
String encode = passwordEncoder.encode(rawpassword);
|
||||||
|
|
||||||
|
System.out.println(rawpassword);
|
||||||
|
System.out.println(encode);
|
||||||
|
System.out.println(passwordEncoder.matches(rawpassword, encode));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void doImport() {
|
public void doImport() {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user