Merge branch 'feature/admin' into preview
commit
904235425f
|
@ -0,0 +1,153 @@
|
||||||
|
package com.mcwl.web.controller.common;
|
||||||
|
|
||||||
|
import com.aliyun.oss.OSS;
|
||||||
|
import com.aliyun.oss.OSSClientBuilder;
|
||||||
|
import com.aliyun.oss.model.GetObjectRequest;
|
||||||
|
import com.aliyun.oss.model.PutObjectRequest;
|
||||||
|
import lombok.extern.log4j.Log4j2;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Oss服务调用
|
||||||
|
*/
|
||||||
|
@Log4j2
|
||||||
|
public class OssUtil {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Endpoint 存储对象概述 阿里云主账号AccessKey,accessKeySecret拥有所有API的访问权限 访问路径前缀 存储对象概述
|
||||||
|
*/
|
||||||
|
private static String endPoint = "oss-cn-beijing.aliyuncs.com";
|
||||||
|
private static String accessKeyId = "LTAI5tSHZZ8wHJRP8X4r9TXT";
|
||||||
|
private static String accessKeySecret = "F82IVNx0IGJ3AnP6gSIfcyql1HCXIH";
|
||||||
|
private static String accessPre = "https://ybl2112.oss-cn-beijing.aliyuncs.com/";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* bucket名称
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private static String bucketName = "ybl2112";
|
||||||
|
|
||||||
|
private static OSS ossClient ;
|
||||||
|
|
||||||
|
static {
|
||||||
|
ossClient = new OSSClientBuilder().build(
|
||||||
|
endPoint,
|
||||||
|
accessKeyId,
|
||||||
|
accessKeySecret);
|
||||||
|
log.info("oss服务连接成功!");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 默认路径上传本地文件
|
||||||
|
* @param filePath
|
||||||
|
*/
|
||||||
|
public static String uploadFile(String filePath){
|
||||||
|
return uploadFileForBucket(bucketName,getOssFilePath(filePath) ,filePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 默认路径上传multipartFile文件
|
||||||
|
* @param multipartFile
|
||||||
|
*/
|
||||||
|
public static String uploadMultipartFile(MultipartFile multipartFile) {
|
||||||
|
return uploadMultipartFile(bucketName,getOssFilePath(multipartFile.getOriginalFilename()),multipartFile);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 上传 multipartFile 类型文件
|
||||||
|
* @param bucketName
|
||||||
|
* @param ossPath
|
||||||
|
* @param multipartFile
|
||||||
|
*/
|
||||||
|
public static String uploadMultipartFile(String bucketName , String ossPath , MultipartFile multipartFile){
|
||||||
|
InputStream inputStream = null;
|
||||||
|
try {
|
||||||
|
inputStream = multipartFile.getInputStream();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
uploadFileInputStreamForBucket(bucketName, ossPath, inputStream);
|
||||||
|
return accessPre+ossPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 使用File上传PutObject上传文件 ** 程序默认使用次方法上传
|
||||||
|
* @param bucketName 实例名称
|
||||||
|
* @param ossPath oss存储路径
|
||||||
|
* @param filePath 本地文件路径
|
||||||
|
*/
|
||||||
|
public static String uploadFileForBucket(String bucketName , String ossPath , String filePath) {
|
||||||
|
// 创建PutObjectRequest对象。
|
||||||
|
PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, ossPath, new File(filePath));
|
||||||
|
|
||||||
|
// 上传
|
||||||
|
ossClient.putObject(putObjectRequest);
|
||||||
|
return accessPre+ossPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 使用文件流上传到指定的bucket实例
|
||||||
|
* @param bucketName 实例名称
|
||||||
|
* @param ossPath oss存储路径
|
||||||
|
* @param filePath 本地文件路径
|
||||||
|
*/
|
||||||
|
public static String uploadFileInputStreamForBucket(String bucketName , String ossPath , String filePath){
|
||||||
|
|
||||||
|
// 填写本地文件的完整路径。如果未指定本地路径,则默认从示例程序所属项目对应本地路径中上传文件流。
|
||||||
|
InputStream inputStream = null;
|
||||||
|
try {
|
||||||
|
inputStream = new FileInputStream(filePath);
|
||||||
|
} catch (FileNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
// 填写Bucket名称和Object完整路径。Object完整路径中不能包含Bucket名称。
|
||||||
|
uploadFileInputStreamForBucket(bucketName, ossPath, inputStream);
|
||||||
|
return accessPre+ossPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void uploadFileInputStreamForBucket(String bucketName , String ossPath , InputStream inputStream ){
|
||||||
|
ossClient.putObject(bucketName, ossPath, inputStream);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 下载
|
||||||
|
* @param ossFilePath
|
||||||
|
* @param filePath
|
||||||
|
*/
|
||||||
|
public static void downloadFile(String ossFilePath , String filePath ){
|
||||||
|
downloadFileForBucket(bucketName , ossFilePath , filePath);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 下载
|
||||||
|
* @param bucketName 实例名称
|
||||||
|
* @param ossFilePath oss存储路径
|
||||||
|
* @param filePath 本地文件路径
|
||||||
|
*/
|
||||||
|
public static void downloadFileForBucket(String bucketName , String ossFilePath , String filePath ){
|
||||||
|
ossClient.getObject(new GetObjectRequest(bucketName, ossFilePath), new File(filePath));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String getOssDefaultPath(){
|
||||||
|
LocalDateTime now = LocalDateTime.now();
|
||||||
|
String url =
|
||||||
|
now.getYear()+"/"+
|
||||||
|
now.getMonth()+"/"+
|
||||||
|
now.getDayOfMonth()+"/"+
|
||||||
|
now.getHour()+"/"+
|
||||||
|
now.getMinute()+"/";
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getOssFilePath(String filePath){
|
||||||
|
String fileSuf = filePath.substring(filePath.indexOf(".") + 1);
|
||||||
|
return getOssDefaultPath() + UUID.randomUUID().toString() + "." + fileSuf;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,16 +1,20 @@
|
||||||
package com.mcwl.web.controller.resource;
|
package com.mcwl.web.controller.resource;
|
||||||
import com.mcwl.common.annotation.Anonymous;
|
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.mcwl.common.core.controller.BaseController;
|
import com.mcwl.common.core.controller.BaseController;
|
||||||
import com.mcwl.common.core.domain.AjaxResult;
|
import com.mcwl.common.core.domain.AjaxResult;
|
||||||
import com.mcwl.common.core.page.TableDataInfo;
|
import com.mcwl.common.core.page.TableDataInfo;
|
||||||
import com.mcwl.common.domain.IdsParam;
|
import com.mcwl.common.domain.IdsParam;
|
||||||
import com.mcwl.resource.domain.MallProduct;
|
import com.mcwl.resource.domain.MallProduct;
|
||||||
import com.mcwl.resource.service.MallProductService;
|
import com.mcwl.resource.service.MallProductService;
|
||||||
|
import com.mcwl.resource.domain.vo.MallProductVo;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* 商品
|
||||||
* @Author:ChenYan
|
* @Author:ChenYan
|
||||||
* @Project:McWl
|
* @Project:McWl
|
||||||
* @Package:com.mcwl.web.controller.resource
|
* @Package:com.mcwl.web.controller.resource
|
||||||
|
@ -83,4 +87,15 @@ public class MallProductController extends BaseController {
|
||||||
return success();
|
return success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查看用户发布的作品
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/selectByUserId")
|
||||||
|
public AjaxResult selectByUserId(@RequestBody MallProductVo mallProductVo){
|
||||||
|
|
||||||
|
Page<MallProduct> mallProductList = mallProductRuleInfoService.selectByUserId(mallProductVo);
|
||||||
|
return AjaxResult.success(mallProductList);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
package com.mcwl.web.controller.resource;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.mcwl.common.core.domain.AjaxResult;
|
||||||
|
import com.mcwl.resource.domain.MallProduct;
|
||||||
|
import com.mcwl.resource.domain.vo.MallProductVo;
|
||||||
|
import com.mcwl.resource.service.MallProductLikeService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 点赞商品
|
||||||
|
* @author DaiZibo
|
||||||
|
* @date 2025/1/2
|
||||||
|
* @apiNote
|
||||||
|
*/
|
||||||
|
|
||||||
|
@RequestMapping("like")
|
||||||
|
@RestController
|
||||||
|
public class MallProductLikeController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private MallProductLikeService mallProductLikeService;
|
||||||
|
|
||||||
|
@PostMapping("/selectByUserLike")
|
||||||
|
public AjaxResult selectByUserLike(@RequestBody MallProductVo mallProductVo){
|
||||||
|
|
||||||
|
Page<MallProduct> mallProductPage = mallProductLikeService.selectByUserLike(mallProductVo);
|
||||||
|
return AjaxResult.success(mallProductPage);
|
||||||
|
}
|
||||||
|
}
|
|
@ -14,13 +14,12 @@ import com.mcwl.system.domain.SysUserThirdAccount;
|
||||||
import com.mcwl.system.service.ISysUserService;
|
import com.mcwl.system.service.ISysUserService;
|
||||||
import com.mcwl.system.service.ISysUserThirdAccountService;
|
import com.mcwl.system.service.ISysUserThirdAccountService;
|
||||||
import com.mcwl.system.service.IWXService;
|
import com.mcwl.system.service.IWXService;
|
||||||
|
import com.mcwl.web.controller.common.OssUtil;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.redis.core.RedisTemplate;
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -60,6 +59,14 @@ public class WXController {
|
||||||
@Resource
|
@Resource
|
||||||
private SysPermissionService permissionService;
|
private SysPermissionService permissionService;
|
||||||
|
|
||||||
|
@Anonymous
|
||||||
|
@PostMapping("/test")
|
||||||
|
public AjaxResult test(@RequestParam MultipartFile file){
|
||||||
|
|
||||||
|
String s = OssUtil.uploadMultipartFile(file);
|
||||||
|
return AjaxResult.success(s);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 扫码登录用uuid生成
|
* 扫码登录用uuid生成
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
package com.mcwl.resource.domain;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import com.mcwl.common.core.domain.BaseEntity;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 作品点赞表
|
||||||
|
*
|
||||||
|
* @author DaiZibo
|
||||||
|
* @date 2025/1/2
|
||||||
|
* @apiNote
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Data
|
||||||
|
public class MallProductLike extends BaseEntity {
|
||||||
|
|
||||||
|
@TableId
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
private Long productId;
|
||||||
|
|
||||||
|
private String createName;
|
||||||
|
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
private Date createTime;
|
||||||
|
}
|
|
@ -0,0 +1,60 @@
|
||||||
|
package com.mcwl.resource.domain.vo;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查看个人发布作品入参
|
||||||
|
*
|
||||||
|
* @author DaiZibo
|
||||||
|
* @date 2025/1/2
|
||||||
|
* @apiNote
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Data
|
||||||
|
public class MallProductVo {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 状态
|
||||||
|
*/
|
||||||
|
private Long status;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 排序
|
||||||
|
*/
|
||||||
|
private Long order;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 开始时间
|
||||||
|
*/
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
|
||||||
|
private Date startTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 结束时间
|
||||||
|
*/
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
|
||||||
|
private Date endTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 页码
|
||||||
|
*/
|
||||||
|
private Integer pageNumber;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 每页条数
|
||||||
|
*/
|
||||||
|
private Integer pageSize;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
package com.mcwl.resource.mapper;
|
||||||
|
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author DaiZibo
|
||||||
|
* @date 2025/1/2
|
||||||
|
* @apiNote
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface MallProductLikeMapper {
|
||||||
|
List<Long> selectByUserId(@Param("userId") Long userId);
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
package com.mcwl.resource.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.mcwl.resource.domain.MallProduct;
|
||||||
|
import com.mcwl.resource.domain.vo.MallProductVo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author DaiZibo
|
||||||
|
* @date 2025/1/2
|
||||||
|
* @apiNote
|
||||||
|
*/
|
||||||
|
|
||||||
|
public interface MallProductLikeService {
|
||||||
|
Page<MallProduct> selectByUserLike(MallProductVo mallProductVo);
|
||||||
|
}
|
|
@ -1,9 +1,10 @@
|
||||||
package com.mcwl.resource.service;
|
package com.mcwl.resource.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.mcwl.common.domain.IdsParam;
|
import com.mcwl.common.domain.IdsParam;
|
||||||
import com.mcwl.resource.domain.MallProduct;
|
import com.mcwl.resource.domain.MallProduct;
|
||||||
import kotlin.Result;
|
import com.mcwl.resource.domain.vo.MallProductVo;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -29,4 +30,7 @@ public interface MallProductService extends IService<MallProduct> {
|
||||||
|
|
||||||
void deleteMallProductByIds(IdsParam ids);
|
void deleteMallProductByIds(IdsParam ids);
|
||||||
|
|
||||||
|
Page<MallProduct> selectByUserId(MallProductVo mallProductVo);
|
||||||
|
|
||||||
|
Page<MallProduct> pageLike(MallProductVo mallProductVo, List<Long> list);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
package com.mcwl.resource.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.mcwl.common.utils.SecurityUtils;
|
||||||
|
import com.mcwl.resource.domain.MallProduct;
|
||||||
|
import com.mcwl.resource.domain.vo.MallProductVo;
|
||||||
|
import com.mcwl.resource.mapper.MallProductLikeMapper;
|
||||||
|
import com.mcwl.resource.service.MallProductLikeService;
|
||||||
|
import com.mcwl.resource.service.MallProductService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author DaiZibo
|
||||||
|
* @date 2025/1/2
|
||||||
|
* @apiNote
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class MallProductLikeServiceImpl implements MallProductLikeService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private MallProductLikeMapper mallProductLikeMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private MallProductService mallProductService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Page<MallProduct> selectByUserLike(MallProductVo mallProductVo) {
|
||||||
|
|
||||||
|
//获取登录人
|
||||||
|
Long userId = SecurityUtils.getUserId();
|
||||||
|
List<Long> list = mallProductLikeMapper.selectByUserId(userId);
|
||||||
|
|
||||||
|
//分页查询作品数据
|
||||||
|
return mallProductService.pageLike(mallProductVo,list);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,12 +1,15 @@
|
||||||
package com.mcwl.resource.service.impl;
|
package com.mcwl.resource.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.mcwl.common.domain.IdsParam;
|
import com.mcwl.common.domain.IdsParam;
|
||||||
|
import com.mcwl.common.utils.SecurityUtils;
|
||||||
import com.mcwl.resource.domain.MallProduct;
|
import com.mcwl.resource.domain.MallProduct;
|
||||||
import com.mcwl.resource.mapper.MallProductMapper;
|
import com.mcwl.resource.mapper.MallProductMapper;
|
||||||
import com.mcwl.resource.service.MallProductService;
|
import com.mcwl.resource.service.MallProductService;
|
||||||
import kotlin.Result;
|
import com.mcwl.resource.domain.vo.MallProductVo;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@ -24,8 +27,6 @@ import java.util.List;
|
||||||
@Service
|
@Service
|
||||||
public class MallProductServiceImpl extends ServiceImpl<MallProductMapper,MallProduct> implements MallProductService {
|
public class MallProductServiceImpl extends ServiceImpl<MallProductMapper,MallProduct> implements MallProductService {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private MallProductMapper postMapper;
|
private MallProductMapper postMapper;
|
||||||
|
|
||||||
|
@ -59,5 +60,55 @@ public class MallProductServiceImpl extends ServiceImpl<MallProductMapper,MallPr
|
||||||
postMapper.deleteBatchIds(ids.getIds());
|
postMapper.deleteBatchIds(ids.getIds());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Page<MallProduct> selectByUserId(MallProductVo mallProductVo) {
|
||||||
|
|
||||||
|
// 创建分页对象
|
||||||
|
Page<MallProduct> mallProductPage = new Page<>(mallProductVo.getPageNumber(), mallProductVo.getPageSize());
|
||||||
|
|
||||||
|
//获取当前登录人ID
|
||||||
|
Long userId = SecurityUtils.getUserId();
|
||||||
|
LambdaQueryWrapper<MallProduct> mallProductLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
|
||||||
|
mallProductLambdaQueryWrapper.eq(MallProduct::getUserId,userId);
|
||||||
|
mallProductLambdaQueryWrapper.eq(MallProduct::getDelFlag,0);
|
||||||
|
|
||||||
|
if (mallProductVo.getStatus() != 0){
|
||||||
|
mallProductLambdaQueryWrapper.eq(MallProduct::getStatus,mallProductVo.getStatus());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mallProductVo.getOrder() == 1){
|
||||||
|
mallProductLambdaQueryWrapper.orderByDesc(MallProduct::getProductId);
|
||||||
|
}else {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// 开始时间和结束时间过滤
|
||||||
|
if (mallProductVo.getStartTime() != null && mallProductVo.getEndTime() != null) {
|
||||||
|
// 查询开始时间和结束时间之间的商品
|
||||||
|
mallProductLambdaQueryWrapper.between(MallProduct::getCreateTime, mallProductVo.getStartTime(), mallProductVo.getEndTime());
|
||||||
|
} else if (mallProductVo.getStartTime() != null) {
|
||||||
|
// 只有开始时间,查询大于等于开始时间的商品
|
||||||
|
mallProductLambdaQueryWrapper.ge(MallProduct::getCreateTime, mallProductVo.getStartTime());
|
||||||
|
} else if (mallProductVo.getEndTime() != null) {
|
||||||
|
// 只有结束时间,查询小于等于结束时间的商品
|
||||||
|
mallProductLambdaQueryWrapper.le(MallProduct::getCreateTime, mallProductVo.getEndTime());
|
||||||
|
}
|
||||||
|
|
||||||
|
return postMapper.selectPage(mallProductPage, mallProductLambdaQueryWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Page<MallProduct> pageLike(MallProductVo mallProductVo, List<Long> list) {
|
||||||
|
|
||||||
|
// 创建分页对象
|
||||||
|
Page<MallProduct> mallProductPage = new Page<>(mallProductVo.getPageNumber(), mallProductVo.getPageSize());
|
||||||
|
|
||||||
|
LambdaQueryWrapper<MallProduct> mallProductLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
mallProductLambdaQueryWrapper.in(MallProduct::getProductId,list);
|
||||||
|
|
||||||
|
return postMapper.selectPage(mallProductPage,mallProductLambdaQueryWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper
|
||||||
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.mcwl.resource.mapper.MallProductLikeMapper">
|
||||||
|
|
||||||
|
|
||||||
|
<select id="selectByUserId" resultType="java.lang.Long">
|
||||||
|
select product_id FROM mall_product_like WHERE user_id = #{userId}
|
||||||
|
</select>
|
||||||
|
</mapper>
|
Loading…
Reference in New Issue