首页水果分页查询
This commit is contained in:
parent
644697bd3b
commit
0736256395
@ -36,7 +36,7 @@ spring:
|
|||||||
redis:
|
redis:
|
||||||
host: 127.0.0.1 #地址
|
host: 127.0.0.1 #地址
|
||||||
port: 6379 #端口
|
port: 6379 #端口
|
||||||
#password: 111111
|
password:
|
||||||
timeout: 10000 # 连接超时时间(毫秒)
|
timeout: 10000 # 连接超时时间(毫秒)
|
||||||
database: 3 #默认数据库
|
database: 3 #默认数据库
|
||||||
jedis:
|
jedis:
|
||||||
|
|||||||
@ -30,7 +30,7 @@ spring:
|
|||||||
redis:
|
redis:
|
||||||
host: 127.0.0.1 #地址
|
host: 127.0.0.1 #地址
|
||||||
port: 6379 #端口
|
port: 6379 #端口
|
||||||
#password: 111111
|
password:
|
||||||
timeout: 10000 # 连接超时时间(毫秒)
|
timeout: 10000 # 连接超时时间(毫秒)
|
||||||
database: 10 #默认数据库
|
database: 10 #默认数据库
|
||||||
jedis:
|
jedis:
|
||||||
|
|||||||
@ -30,7 +30,7 @@ spring:
|
|||||||
redis:
|
redis:
|
||||||
host: 127.0.0.1 #地址
|
host: 127.0.0.1 #地址
|
||||||
port: 6379 #端口
|
port: 6379 #端口
|
||||||
#password: 111111
|
password:
|
||||||
timeout: 10000 # 连接超时时间(毫秒)
|
timeout: 10000 # 连接超时时间(毫秒)
|
||||||
database: 15 #默认数据库
|
database: 15 #默认数据库
|
||||||
jedis:
|
jedis:
|
||||||
|
|||||||
@ -45,7 +45,7 @@ spring:
|
|||||||
redis:
|
redis:
|
||||||
host: 127.0.0.1 #地址
|
host: 127.0.0.1 #地址
|
||||||
port: 6379 #端口
|
port: 6379 #端口
|
||||||
#password: 111111
|
password:
|
||||||
timeout: 30000 # 连接超时时间(毫秒)
|
timeout: 30000 # 连接超时时间(毫秒)
|
||||||
database: 15 #默认数据库
|
database: 15 #默认数据库
|
||||||
jedis:
|
jedis:
|
||||||
|
|||||||
@ -324,6 +324,11 @@ public class Constants {
|
|||||||
public static final int INDEX_LIMIT_DEFAULT = 3; //首页默认list分页条数
|
public static final int INDEX_LIMIT_DEFAULT = 3; //首页默认list分页条数
|
||||||
public static final int INDEX_GOOD_BANNER = 5; //优选推荐
|
public static final int INDEX_GOOD_BANNER = 5; //优选推荐
|
||||||
|
|
||||||
|
//首页水果搜索类型
|
||||||
|
public static final String INDEX_FRUIT_ONGOING = "0"; //首页正在售卖的水果
|
||||||
|
public static final String INDEX_FRUIT_BOOKING = "1"; //首页预售的水果
|
||||||
|
public static final String INDEX_FRUIT_SETTLED = "2"; //首页团购结束的水果
|
||||||
|
|
||||||
public static final String INDEX_BAST_LIMIT = "bastNumber"; //精品推荐个数
|
public static final String INDEX_BAST_LIMIT = "bastNumber"; //精品推荐个数
|
||||||
public static final String INDEX_FIRST_LIMIT = "firstNumber"; //首发新品个数
|
public static final String INDEX_FIRST_LIMIT = "firstNumber"; //首发新品个数
|
||||||
public static final String INDEX_SALES_LIMIT = "promotionNumber"; //促销单品个数
|
public static final String INDEX_SALES_LIMIT = "promotionNumber"; //促销单品个数
|
||||||
|
|||||||
@ -5,6 +5,7 @@ import java.math.BigDecimal;
|
|||||||
import com.baomidou.mybatisplus.annotation.*;
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
@ -166,4 +167,19 @@ public class StoreProduct implements Serializable {
|
|||||||
@ApiModelProperty(value = "商品详情")
|
@ApiModelProperty(value = "商品详情")
|
||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
private String content;
|
private String content;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "开始售卖时间")
|
||||||
|
private LocalDateTime beginTime;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "结束售卖时间")
|
||||||
|
private LocalDateTime endTime;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "搜索类型")
|
||||||
|
private String searchStatus;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "水果规格")
|
||||||
|
private String size;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "水果尺寸")
|
||||||
|
private String dimensions;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -65,4 +65,10 @@ public class IndexProductResponse {
|
|||||||
|
|
||||||
@ApiModelProperty(value = "展示图")
|
@ApiModelProperty(value = "展示图")
|
||||||
private String flatPattern;
|
private String flatPattern;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "规格")
|
||||||
|
private String size;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "水果尺寸")
|
||||||
|
private String dimensions;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -126,9 +126,11 @@ public class FrontTokenComponent {
|
|||||||
*/
|
*/
|
||||||
public String getToken(HttpServletRequest request) {
|
public String getToken(HttpServletRequest request) {
|
||||||
String token = request.getHeader(Constants.HEADER_AUTHORIZATION_KEY);
|
String token = request.getHeader(Constants.HEADER_AUTHORIZATION_KEY);
|
||||||
|
System.out.println("从请求头获取的原始token: " + token);
|
||||||
if (StrUtil.isNotEmpty(token) && token.startsWith(Constants.USER_TOKEN_REDIS_KEY_PREFIX)) {
|
if (StrUtil.isNotEmpty(token) && token.startsWith(Constants.USER_TOKEN_REDIS_KEY_PREFIX)) {
|
||||||
token = token.replace(Constants.USER_TOKEN_REDIS_KEY_PREFIX, "");
|
token = token.replace(Constants.USER_TOKEN_REDIS_KEY_PREFIX, "");
|
||||||
}
|
}
|
||||||
|
System.out.println("处理后的token:" + token);
|
||||||
return token;
|
return token;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,6 +169,7 @@ public class FrontTokenComponent {
|
|||||||
"api/front/bargain/list",
|
"api/front/bargain/list",
|
||||||
"api/front/combination/list",
|
"api/front/combination/list",
|
||||||
"api/front/index/product",
|
"api/front/index/product",
|
||||||
|
"api/front/pagelist/product",
|
||||||
"api/front/combination/index",
|
"api/front/combination/index",
|
||||||
"api/front/bargain/index",
|
"api/front/bargain/index",
|
||||||
"api/front/index/color/config",
|
"api/front/index/color/config",
|
||||||
@ -196,4 +199,23 @@ public class FrontTokenComponent {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//public Boolean check(String token, HttpServletRequest request){
|
||||||
|
// try {
|
||||||
|
// boolean exists = redisUtil.exists(getTokenKey(token));
|
||||||
|
// if(exists){
|
||||||
|
// Integer uid = redisUtil.get(getTokenKey(token));
|
||||||
|
// redisUtil.set(getTokenKey(token), uid, Constants.TOKEN_EXPRESS_MINUTES, TimeUnit.MINUTES);
|
||||||
|
// System.out.println("Token 有效,用户信息已刷新");
|
||||||
|
// return true;
|
||||||
|
// }else{
|
||||||
|
// //判断路由,部分路由不管用户是否登录/token过期都可以访问
|
||||||
|
// boolean isAllowedRoute = checkRouter(RequestUtil.getUri(request));
|
||||||
|
// System.out.println("Token 无效,检查路由:" + isAllowedRoute);
|
||||||
|
// return isAllowedRoute;
|
||||||
|
// }
|
||||||
|
// }catch (Exception e){
|
||||||
|
// System.out.println("Token 验证出现异常:" + e.getMessage());
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -64,7 +64,17 @@ public class IndexController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 热门搜索zzzzzzzvvvv
|
* 首页水果列表
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "首页水果列表")
|
||||||
|
@RequestMapping(value = "/pagelist/product/{searchStatus}", method = RequestMethod.GET)
|
||||||
|
@ApiImplicitParam(name = "searchStatus", value = "搜索类型 【0 售卖中 1 团购结束 】", dataType = "String", required = true)
|
||||||
|
public CommonResult<CommonPage<IndexProductResponse>> getProductList(@PathVariable(value = "searchStatus") String searchStatus, PageParamRequest pageParamRequest) {
|
||||||
|
return CommonResult.success(indexService.findIndexFruitList(searchStatus, pageParamRequest));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 热门搜索
|
||||||
*/
|
*/
|
||||||
@ApiOperation(value = "热门搜索")
|
@ApiOperation(value = "热门搜索")
|
||||||
@RequestMapping(value = "/search/keyword", method = RequestMethod.GET)
|
@RequestMapping(value = "/search/keyword", method = RequestMethod.GET)
|
||||||
@ -72,24 +82,6 @@ public class IndexController {
|
|||||||
return CommonResult.success(indexService.hotKeywords());
|
return CommonResult.success(indexService.hotKeywords());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 热门搜索zzzzzzzvvvv
|
|
||||||
*/
|
|
||||||
@ApiOperation(value = "热门搜索")
|
|
||||||
@RequestMapping(value = "/search/keyword1", method = RequestMethod.GET)
|
|
||||||
public CommonResult<List<HashMap<String, Object>>> hotKeywords11() {
|
|
||||||
return CommonResult.success(indexService.hotKeywords());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 热门搜索zzzzzzzvvvv
|
|
||||||
*/
|
|
||||||
@ApiOperation(value = "热门搜索")
|
|
||||||
@RequestMapping(value = "/search/keyword2", method = RequestMethod.GET)
|
|
||||||
public CommonResult<List<HashMap<String, Object>>> hotKeywords22() {
|
|
||||||
return CommonResult.success(indexService.hotKeywords());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分享配置
|
* 分享配置
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -49,6 +49,14 @@ public interface IndexService{
|
|||||||
*/
|
*/
|
||||||
CommonPage<IndexProductResponse> findIndexProductList(Integer type, PageParamRequest pageParamRequest);
|
CommonPage<IndexProductResponse> findIndexProductList(Integer type, PageParamRequest pageParamRequest);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 首页水果列表
|
||||||
|
* @param searchStatus
|
||||||
|
* @param pageParamRequest
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
CommonPage<IndexProductResponse> findIndexFruitList(String searchStatus, PageParamRequest pageParamRequest);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取颜色配置
|
* 获取颜色配置
|
||||||
* @return SystemConfig
|
* @return SystemConfig
|
||||||
|
|||||||
@ -29,6 +29,7 @@ import org.springframework.stereotype.Service;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* IndexServiceImpl 接口实现
|
* IndexServiceImpl 接口实现
|
||||||
@ -189,6 +190,41 @@ public class IndexServiceImpl implements IndexService {
|
|||||||
return productResponseCommonPage;
|
return productResponseCommonPage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 首页水果列表
|
||||||
|
* @param searchStatus
|
||||||
|
* @param pageParamRequest
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public CommonPage<IndexProductResponse> findIndexFruitList(String searchStatus, PageParamRequest pageParamRequest) {
|
||||||
|
//在0,1,2搜索类型范围类
|
||||||
|
if (!searchStatus.equals(Constants.INDEX_FRUIT_ONGOING)
|
||||||
|
&& !searchStatus.equals(Constants.INDEX_FRUIT_BOOKING)
|
||||||
|
&& !searchStatus.equals(Constants.INDEX_FRUIT_SETTLED)) {
|
||||||
|
return CommonPage.restPage(new ArrayList<>());
|
||||||
|
}
|
||||||
|
//分页查询
|
||||||
|
List<StoreProduct> fruitList = storeProductService.getFruitList(searchStatus, pageParamRequest);
|
||||||
|
//查出来为空
|
||||||
|
if(CollUtil.isEmpty(fruitList)) {
|
||||||
|
return CommonPage.restPage(new ArrayList<>());
|
||||||
|
}
|
||||||
|
//转换为响应对象:将 List<StoreProduct> 转换为 List<IndexProductResponse>
|
||||||
|
List<IndexProductResponse> responseList = fruitList.stream()
|
||||||
|
.map(this::convertToIndexProductResponse)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
// 4. 封装分页响应
|
||||||
|
return CommonPage.restPage(responseList);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 转换方法:StoreProduct -> IndexProductResponse
|
||||||
|
private IndexProductResponse convertToIndexProductResponse(StoreProduct product) {
|
||||||
|
IndexProductResponse response = new IndexProductResponse();
|
||||||
|
BeanUtils.copyProperties(product, response); // 拷贝同名属性
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取颜色配置
|
* 获取颜色配置
|
||||||
* @return SystemConfig
|
* @return SystemConfig
|
||||||
|
|||||||
@ -68,7 +68,8 @@ public class LoginServiceImpl implements LoginService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 校验密码
|
// 校验密码
|
||||||
String password = CrmebUtil.encryptPassword(loginRequest.getPassword(), loginRequest.getPhone());
|
//String password = CrmebUtil.encryptPassword(loginRequest.getPassword(), loginRequest.getPhone());
|
||||||
|
String password = loginRequest.getPassword();
|
||||||
if (!user.getPwd().equals(password)) {
|
if (!user.getPwd().equals(password)) {
|
||||||
throw new CrmebException("密码错误");
|
throw new CrmebException("密码错误");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -154,6 +154,14 @@ public interface StoreProductService extends IService<StoreProduct> {
|
|||||||
*/
|
*/
|
||||||
List<StoreProduct> getIndexProduct(Integer type, PageParamRequest pageParamRequest);
|
List<StoreProduct> getIndexProduct(Integer type, PageParamRequest pageParamRequest);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 首页水果列表
|
||||||
|
* @param searchStatus
|
||||||
|
* @param pageParamRequest
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<StoreProduct> getFruitList(String searchStatus, PageParamRequest pageParamRequest);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取商品移动端列表
|
* 获取商品移动端列表
|
||||||
* @param request 筛选参数
|
* @param request 筛选参数
|
||||||
|
|||||||
@ -1150,6 +1150,26 @@ public class StoreProductServiceImpl extends ServiceImpl<StoreProductDao, StoreP
|
|||||||
return dao.selectList(lambdaQueryWrapper);
|
return dao.selectList(lambdaQueryWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 首页水果列表
|
||||||
|
* @param searchStatus
|
||||||
|
* @param pageParamRequest
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public List<StoreProduct> getFruitList(String searchStatus, PageParamRequest pageParamRequest) {
|
||||||
|
PageHelper.startPage(pageParamRequest.getPage(), pageParamRequest.getLimit());
|
||||||
|
//使用 MyBatis-Plus 的 Lambda 表达式构建动态查询条件,避免硬编码字段名。
|
||||||
|
LambdaQueryWrapper<StoreProduct> lambdaQueryWrapper = Wrappers.lambdaQuery();
|
||||||
|
//选择返回字段,(其他字段不返回),减少数据传输量。
|
||||||
|
lambdaQueryWrapper.select(StoreProduct::getId, StoreProduct::getImage, StoreProduct::getStoreName,
|
||||||
|
StoreProduct::getPrice, StoreProduct::getOtPrice, StoreProduct::getActivity,StoreProduct::getSize,StoreProduct::getDimensions);
|
||||||
|
//根据 type 的值,添加不同的筛选条件(如 is_best=true 表示精品推荐商品)。
|
||||||
|
lambdaQueryWrapper.eq(StoreProduct::getSearchStatus, searchStatus); // where searchStatus = ${searchStatus}
|
||||||
|
//排序
|
||||||
|
lambdaQueryWrapper.orderByDesc(StoreProduct::getBeginTime);
|
||||||
|
return dao.selectList(lambdaQueryWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取商品移动端列表
|
* 获取商品移动端列表
|
||||||
* @param request 筛选参数
|
* @param request 筛选参数
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user