Commit a34a95f8 authored by youc's avatar youc
Browse files

Merge branch 'master' of https://gitee.com/youc-project/litemall

parents f9f41412 a697e696
......@@ -3,6 +3,7 @@ package org.linlinjava.litemall.wx.web;
import org.linlinjava.litemall.core.util.ResponseUtil;
import org.linlinjava.litemall.db.domain.LitemallCategory;
import org.linlinjava.litemall.db.service.LitemallCategoryService;
import org.linlinjava.litemall.wx.service.HomeCacheManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
......@@ -80,6 +81,12 @@ public class WxCatalogController {
*/
@GetMapping("all")
public Object queryAll() {
//优先从缓存中读取
if (HomeCacheManager.hasData(HomeCacheManager.CATALOG)) {
return ResponseUtil.ok(HomeCacheManager.getCacheData(HomeCacheManager.CATALOG));
}
// 所有一级分类目录
List<LitemallCategory> l1CatList = categoryService.queryL1();
......@@ -105,6 +112,9 @@ public class WxCatalogController {
data.put("allList", allList);
data.put("currentCategory", currentCategory);
data.put("currentSubCategory", currentSubCategory);
//缓存数据
HomeCacheManager.loadData(HomeCacheManager.CATALOG, data);
return ResponseUtil.ok(data);
}
......
......@@ -10,6 +10,7 @@ import org.linlinjava.litemall.core.validator.Sort;
import org.linlinjava.litemall.db.domain.*;
import org.linlinjava.litemall.db.service.*;
import org.linlinjava.litemall.wx.annotation.LoginUser;
import org.linlinjava.litemall.wx.service.HomeCacheManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
......@@ -54,6 +55,8 @@ public class WxGoodsController {
private LitemallSearchHistoryService searchHistoryService;
@Autowired
private LitemallGoodsSpecificationService goodsSpecificationService;
@Autowired
private LitemallGrouponRulesService rulesService;
/**
......@@ -123,6 +126,9 @@ public class WxGoodsController {
commentList.put("count", commentCount);
commentList.put("data", commentsVo);
//团购信息
List<LitemallGrouponRules> rules = rulesService.queryByGoodsId(id);
// 用户收藏
int userHasCollect = 0;
if (userId != null) {
......@@ -147,10 +153,10 @@ public class WxGoodsController {
data.put("productList", productList);
data.put("attribute", goodsAttributeList);
data.put("brand", brand);
data.put("groupon", rules);
//商品分享图片地址
data.put("shareImage", info.getShareUrl());
return ResponseUtil.ok(data);
}
......@@ -231,7 +237,7 @@ public class WxGoodsController {
@RequestParam(defaultValue = "1") Integer page,
@RequestParam(defaultValue = "10") Integer size,
@Sort(accepts = {"add_time", "retail_price"}) @RequestParam(defaultValue = "add_time") String sort,
@Order @RequestParam(defaultValue = "desc") String order){
@Order @RequestParam(defaultValue = "desc") String order) {
//添加到搜索历史
if (userId != null && !StringUtils.isNullOrEmpty(keyword)) {
......
......@@ -4,12 +4,14 @@ import org.linlinjava.litemall.core.util.ResponseUtil;
import org.linlinjava.litemall.db.domain.*;
import org.linlinjava.litemall.db.service.*;
import org.linlinjava.litemall.core.system.SystemConfig;
import org.linlinjava.litemall.wx.service.HomeCacheManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
......@@ -29,6 +31,20 @@ public class WxHomeController {
private LitemallTopicService topicService;
@Autowired
private LitemallCategoryService categoryService;
@Autowired
private LitemallGrouponRulesService grouponRulesService;
@GetMapping("/cache")
public Object cache(@NotNull String key) {
if (!key.equals("litemall_cache")) {
return ResponseUtil.fail();
}
// 清除缓存
HomeCacheManager.clearAll();
return ResponseUtil.ok("缓存已清除");
}
/**
* app首页
......@@ -52,6 +68,12 @@ public class WxHomeController {
*/
@GetMapping("/index")
public Object index() {
//优先从缓存中读取
if (HomeCacheManager.hasData(HomeCacheManager.INDEX)) {
return ResponseUtil.ok(HomeCacheManager.getCacheData(HomeCacheManager.INDEX));
}
Map<String, Object> data = new HashMap<>();
List<LitemallAd> banner = adService.queryIndex();
......@@ -72,6 +94,26 @@ public class WxHomeController {
List<LitemallTopic> topicList = topicService.queryList(0, SystemConfig.getTopicLimit());
data.put("topicList", topicList);
//优惠专区
List<LitemallGrouponRules> grouponRules = grouponRulesService.queryByIndex(0, 4);
List<LitemallGoods> grouponGoods = new ArrayList<>();
List<Map<String, Object>> grouponList = new ArrayList<>();
for (LitemallGrouponRules rule : grouponRules) {
LitemallGoods goods = goodsService.findById(rule.getGoodsId());
if (goods == null)
continue;
if (!grouponGoods.contains(goods)) {
Map<String, Object> item = new HashMap<>();
item.put("goods", goods);
item.put("groupon_price", goods.getRetailPrice().subtract(rule.getDiscount()));
item.put("groupon_member", rule.getDiscountMember());
grouponList.add(item);
grouponGoods.add(goods);
}
}
data.put("grouponList", grouponList);
List<Map> categoryList = new ArrayList<>();
List<LitemallCategory> catL1List = categoryService.queryL1WithoutRecommend(0, SystemConfig.getCatlogListLimit());
for (LitemallCategory catL1 : catL1List) {
......@@ -96,6 +138,8 @@ public class WxHomeController {
}
data.put("floorGoodsList", categoryList);
//缓存数据
HomeCacheManager.loadData(HomeCacheManager.INDEX, data);
return ResponseUtil.ok(data);
}
}
\ No newline at end of file
This diff is collapsed.
......@@ -4,9 +4,9 @@
// 局域网测试使用
// var WxApiRoot = 'http://192.168.0.101:8080/wx/';
// 云平台部署时使用
var WxApiRoot = 'http://122.152.206.172:8080/wx/';
// var WxApiRoot = 'http://122.152.206.172:8080/wx/';
// 云平台上线时使用
// var WxApiRoot = 'https://www.menethil.com.cn/wx/';
var WxApiRoot = 'https://www.menethil.com.cn/wx/';
module.exports = {
IndexUrl: WxApiRoot + 'home/index', //首页数据接口
......@@ -79,5 +79,9 @@ module.exports = {
UserFormIdCreate: WxApiRoot + 'formid/create', //用户FromId,用于发送模版消息
GroupOn: WxApiRoot + 'groupon/query', //团购API-查询
GroupOnMy: WxApiRoot + 'groupon/my', //团购API-我的团购
GroupOnDetail: WxApiRoot + 'groupon/detail', //团购API-详情
GroupOnJoin: WxApiRoot + 'groupon/join', //团购API-详情
StorageUpload: WxApiRoot + 'storage/upload' //图片上传
};
\ No newline at end of file
'use strict';
Component({
externalClasses: ['custom-class'],
/**
* 组件的属性列表
* 用于组件自定义设置
*/
properties: {
// 颜色状态
type: {
type: String,
value: ''
},
// 自定义颜色
color: {
type: String,
value: ''
},
// 左侧内容
leftText: {
type: String,
value: ''
},
// 右侧内容
rightText: {
type: String,
value: ''
}
}
});
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment