Merge remote-tracking branch 'origin/master'
# Conflicts: # maku-framework/src/main/resources/auth.yml # maku-server/src/main/java/net/maku/maku/controller/TUserController.java
This commit is contained in:
commit
82df411a6d
|
@ -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);
|
||||||
|
|
||||||
|
|
|
@ -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,17 +41,33 @@ import java.util.List;
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class TBookCollectionController {
|
public class TBookCollectionController {
|
||||||
private final TBookCollectionService tBookCollectionService;
|
private final TBookCollectionService tBookCollectionService;
|
||||||
|
private final TBookCollectionDao bookCollectionDao;
|
||||||
|
private final RedisCache redisCache;
|
||||||
|
|
||||||
|
@GetMapping("/mylist")
|
||||||
|
public 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 bookCollectionDao.selectBookCollectionByUserId(Long.valueOf(userId));
|
||||||
|
}
|
||||||
|
|
||||||
@GetMapping("page")
|
@GetMapping("page")
|
||||||
@Operation(summary = "分页")
|
@Operation(summary = "分页")
|
||||||
@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')")
|
||||||
|
@ -75,4 +103,48 @@ 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(); // 直接使用已经获取的用户信息
|
||||||
|
|
||||||
|
// Check if the book has already been collected by the user
|
||||||
|
boolean isBookAlreadyCollected = tBookCollectionService.isBookAlreadyCollected(userId, bookId);
|
||||||
|
if (isBookAlreadyCollected) {
|
||||||
|
return Result.error("该书已经收藏过,不能重复收藏");
|
||||||
|
}
|
||||||
|
|
||||||
|
// If not already collected, proceed with saving the collection record
|
||||||
|
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,10 +1,13 @@
|
||||||
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 jakarta.servlet.http.HttpServletRequest;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import net.maku.framework.common.cache.RedisCache;
|
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;
|
||||||
|
@ -44,10 +47,12 @@ public class TBookCommentController {
|
||||||
public Result setbookcomment(HttpServletRequest request, @RequestParam Integer bookId,@RequestParam String comment) {
|
public Result setbookcomment(HttpServletRequest request, @RequestParam Integer bookId,@RequestParam String comment) {
|
||||||
// 首先验证token的有效性,然后从Redis中获取用户信息
|
// 首先验证token的有效性,然后从Redis中获取用户信息
|
||||||
String token = request.getHeader("token");
|
String token = request.getHeader("token");
|
||||||
if(token==null || token.isEmpty()){
|
TUserEntity entity = (TUserEntity) redisCache.get(token);
|
||||||
return Result.error("token is error");
|
if(ObjectUtils.isNull(entity)){
|
||||||
|
throw new ServerException(ErrorCode.REFRESH_TOKEN_INVALID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TUserEntity tUserEntity = (TUserEntity) redisCache.get(token);
|
TUserEntity tUserEntity = (TUserEntity) redisCache.get(token);
|
||||||
Integer userId=tUserEntity.getId();
|
Integer userId=tUserEntity.getId();
|
||||||
LocalDateTime currentTime = LocalDateTime.now();
|
LocalDateTime currentTime = LocalDateTime.now();
|
||||||
|
@ -107,4 +112,11 @@ public class TBookCommentController {
|
||||||
|
|
||||||
return Result.ok();
|
return Result.ok();
|
||||||
}
|
}
|
||||||
|
@GetMapping("/list/{bookId}")
|
||||||
|
@Operation(summary = "查看评论列表")
|
||||||
|
public Result<List<TBookCommentEntity>> list(@PathVariable Integer bookId){
|
||||||
|
|
||||||
|
return Result.ok(tBookCommentService.getByBookId(bookId));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,15 +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.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 jakarta.servlet.http.HttpServletRequest;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import net.maku.framework.common.cache.RedisCache;
|
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.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.entity.TUserEntity;
|
||||||
import net.maku.maku.service.TBookCollectionService;
|
import net.maku.maku.service.TBookCollectionService;
|
||||||
|
@ -67,25 +71,7 @@ public class TBookController {
|
||||||
return Result.ok(entity);
|
return Result.ok(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/collection")
|
|
||||||
@Operation(summary = "收藏图书")
|
|
||||||
public Result<String> setbookcollection(HttpServletRequest request, @RequestParam Integer bookId) {
|
|
||||||
// 首先验证token的有效性,然后从Redis中获取用户信息
|
|
||||||
String token = request.getHeader("token");
|
|
||||||
if(token==null || token.isEmpty()){
|
|
||||||
return Result.error("token is error");
|
|
||||||
}
|
|
||||||
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());
|
|
||||||
tBookCollectionService.save(userId,bookId,date);
|
|
||||||
return Result.ok("收藏图书成功");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,13 @@
|
||||||
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 jakarta.servlet.http.HttpServletRequest;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import net.maku.framework.common.cache.RedisCache;
|
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;
|
||||||
|
@ -42,10 +45,12 @@ public class TShoppingTrolleyController {
|
||||||
public Result setshoppingtrolly(HttpServletRequest request, @RequestParam Integer bookId) {
|
public Result setshoppingtrolly(HttpServletRequest request, @RequestParam Integer bookId) {
|
||||||
// 首先验证token的有效性,然后从Redis中获取用户信息
|
// 首先验证token的有效性,然后从Redis中获取用户信息
|
||||||
String token = request.getHeader("token");
|
String token = request.getHeader("token");
|
||||||
if(token==null || token.isEmpty()){
|
TUserEntity entity = (TUserEntity) redisCache.get(token);
|
||||||
return Result.error("token is error");
|
if(ObjectUtils.isNull(entity)){
|
||||||
|
throw new ServerException(ErrorCode.REFRESH_TOKEN_INVALID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TUserEntity tUserEntity = (TUserEntity) redisCache.get(token);
|
TUserEntity tUserEntity = (TUserEntity) redisCache.get(token);
|
||||||
Integer userId=tUserEntity.getId();
|
Integer userId=tUserEntity.getId();
|
||||||
LocalDateTime currentTime = LocalDateTime.now();
|
LocalDateTime currentTime = LocalDateTime.now();
|
||||||
|
@ -75,7 +80,6 @@ public class TShoppingTrolleyController {
|
||||||
}
|
}
|
||||||
@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);
|
||||||
|
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
|
@ -25,4 +25,6 @@ public class TBookCollectionEntity {
|
||||||
|
|
||||||
private Date updateTime;
|
private Date updateTime;
|
||||||
|
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
}
|
}
|
|
@ -20,6 +20,7 @@ public class TUserEntity {
|
||||||
|
|
||||||
private String username;
|
private String username;
|
||||||
|
|
||||||
|
|
||||||
private String password;
|
private String password;
|
||||||
|
|
||||||
private String avatar;
|
private String avatar;
|
||||||
|
@ -28,6 +29,10 @@ public class TUserEntity {
|
||||||
|
|
||||||
private Integer status;
|
private Integer status;
|
||||||
|
|
||||||
|
private String phone;
|
||||||
|
|
||||||
|
private String email;
|
||||||
|
|
||||||
private Date createTime;
|
private Date createTime;
|
||||||
|
|
||||||
private Date updateTime;
|
private Date updateTime;
|
||||||
|
|
|
@ -26,4 +26,8 @@ public interface TBookCollectionService extends BaseService<TBookCollectionEntit
|
||||||
void delete(List<Long> idList);
|
void delete(List<Long> idList);
|
||||||
|
|
||||||
void save(Integer userId, Integer bookId, Date currentTime);
|
void save(Integer userId, Integer bookId, Date currentTime);
|
||||||
|
|
||||||
|
TBookCollectionEntity getByBookIdandUserId(Integer bookId, Integer userId);
|
||||||
|
|
||||||
|
boolean isBookAlreadyCollected(Integer userId, Integer bookId);
|
||||||
}
|
}
|
|
@ -26,4 +26,6 @@ public interface TBookCommentService extends BaseService<TBookCommentEntity> {
|
||||||
void delete(List<Long> idList);
|
void delete(List<Long> idList);
|
||||||
|
|
||||||
void save(Integer userId, Integer bookId, String comment, Date date);
|
void save(Integer userId, Integer bookId, String comment, Date date);
|
||||||
|
|
||||||
|
List<TBookCommentEntity> getByBookId(Integer bookId);
|
||||||
}
|
}
|
|
@ -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.TBookCollectionConvert;
|
import net.maku.maku.convert.TBookCollectionConvert;
|
||||||
import net.maku.maku.entity.TBookCollectionEntity;
|
import net.maku.maku.entity.TBookCollectionEntity;
|
||||||
|
@ -70,15 +71,23 @@ public class TBookCollectionServiceImpl extends BaseServiceImpl<TBookCollectionD
|
||||||
entity.setUserId(userId);
|
entity.setUserId(userId);
|
||||||
entity.setBookId(bookId);
|
entity.setBookId(bookId);
|
||||||
entity.setCreateTime(currentTime);
|
entity.setCreateTime(currentTime);
|
||||||
// 可以根据需要设置其它字段,例如自增id字段和lastModifiedTime字段(如果需要)
|
|
||||||
|
|
||||||
// 假设lastModifiedTime可以为空,可以根据需要设置
|
|
||||||
|
|
||||||
|
|
||||||
// 使用 MyBatis Plus 的 save 方法保存实体
|
|
||||||
this.save(entity);
|
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);
|
||||||
|
return baseMapper.selectCount(wrapper) > 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -75,4 +75,11 @@ public class TBookCommentServiceImpl extends BaseServiceImpl<TBookCommentDao, TB
|
||||||
baseMapper.insert(entity);
|
baseMapper.insert(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<TBookCommentEntity> getByBookId(Integer bookId) {
|
||||||
|
LambdaQueryWrapper<TBookCommentEntity> wrapper = Wrappers.lambdaQuery();
|
||||||
|
wrapper.eq(TBookCommentEntity::getBookId, bookId);
|
||||||
|
return baseMapper.selectList(wrapper);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -37,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,5 +100,9 @@ public class TShoppingTrolleyServiceImpl extends BaseServiceImpl<TShoppingTrolle
|
||||||
return newEntity;
|
return newEntity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -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)
|
||||||
|
|
|
@ -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;
|
||||||
|
|
||||||
|
|
|
@ -11,4 +11,11 @@
|
||||||
<result property="updateTime" column="update_time"/>
|
<result property="updateTime" column="update_time"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
|
<select id="selectBookCollectionByUserId" resultMap="tBookCollectionMap" parameterType="java.lang.Long">
|
||||||
|
SELECT *
|
||||||
|
FROM
|
||||||
|
t_book_collection bc
|
||||||
|
LEFT JOIN `t_book` tb ON bc.book_id=tb.id
|
||||||
|
WHERE user_id = #{id}
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
|
@ -14,4 +14,5 @@
|
||||||
<result property="updateTime" column="update_time"/>
|
<result property="updateTime" column="update_time"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
Loading…
Reference in New Issue
Block a user