导出最新sql,优化首页数据

This commit is contained in:
hupeng
2020-03-07 11:23:18 +08:00
parent 529fc770ee
commit dc1fa321bc
17 changed files with 3324 additions and 6562 deletions

File diff suppressed because one or more lines are too long

View File

@ -1,2 +0,0 @@
ALTER TABLE `yxshop`.`yx_store_order`
ADD COLUMN `extend_order_id` varchar(32) NULL COMMENT '额外订单号' AFTER `order_id`

View File

@ -1,20 +0,0 @@
CREATE TABLE `yx_material` (
`id` varchar(32) COLLATE utf8mb4_bin NOT NULL COMMENT 'PK',
`del_flag` char(2) COLLATE utf8mb4_bin NOT NULL DEFAULT '0' COMMENT '逻辑删除标记0显示1隐藏',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`create_id` varchar(100) CHARACTER SET utf8 DEFAULT NULL COMMENT '创建者ID',
`type` char(2) COLLATE utf8mb4_bin NOT NULL COMMENT '类型1、图片2、视频',
`group_id` varchar(32) COLLATE utf8mb4_bin DEFAULT NULL COMMENT '分组ID',
`name` varchar(200) COLLATE utf8mb4_bin NOT NULL COMMENT '素材名',
`url` varchar(500) COLLATE utf8mb4_bin DEFAULT '' COMMENT '素材链接',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin ROW_FORMAT=DYNAMIC COMMENT='素材库';
CREATE TABLE `yx_material_group` (
`id` varchar(32) COLLATE utf8mb4_bin NOT NULL COMMENT 'PK',
`del_flag` char(2) COLLATE utf8mb4_bin NOT NULL DEFAULT '0' COMMENT '逻辑删除标记0显示1隐藏',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`create_id` varchar(32) CHARACTER SET utf8 DEFAULT NULL COMMENT '创建者ID',
`name` varchar(200) COLLATE utf8mb4_bin NOT NULL COMMENT '分组名',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin ROW_FORMAT=DYNAMIC COMMENT='素材分组';

View File

@ -1,5 +0,0 @@
ALTER TABLE `yshop`.`yx_user`
MODIFY COLUMN `password` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '用户密码跟pwd' AFTER `account`,
MODIFY COLUMN `pwd` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '用户密码' AFTER `password`;
update yx_user set `password`='$2a$10$fP.426qKaTmix50Oln8L.uav55gELhAd0Eg66Av4oG86u8km7D/Ky'

3209
sql/yshop2.0.sql Normal file

File diff suppressed because it is too large Load Diff

47
sql/yx_system_store.sql Normal file
View File

@ -0,0 +1,47 @@
/*
Navicat Premium Data Transfer
Source Server : localhost
Source Server Type : MySQL
Source Server Version : 50723
Source Host : localhost:3306
Source Schema : yxshop
Target Server Type : MySQL
Target Server Version : 50723
File Encoding : 65001
Date: 06/03/2020 21:11:30
*/
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for yx_system_store
-- ----------------------------
DROP TABLE IF EXISTS `yx_system_store`;
CREATE TABLE `yx_system_store` (
`id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`name` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '门店名称',
`introduction` varchar(1000) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '简介',
`phone` char(25) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '手机号码',
`address` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '省市区',
`detailed_address` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '详细地址',
`image` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '门店logo',
`latitude` char(25) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '纬度',
`longitude` char(25) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '经度',
`valid_time` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '核销有效日期',
`day_time` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '每日营业开关时间',
`add_time` int(11) NOT NULL DEFAULT 0 COMMENT '添加时间',
`is_show` tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否显示',
`is_del` tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否删除',
`day_time_end` datetime(0) NULL DEFAULT NULL,
`day_time_start` datetime(0) NULL DEFAULT NULL,
`valid_time_end` datetime(0) NULL DEFAULT NULL,
`valid_time_start` datetime(0) NULL DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE,
INDEX `phone`(`phone`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '门店自提' ROW_FORMAT = Dynamic;
SET FOREIGN_KEY_CHECKS = 1;

42
sql/yx_user_recharge.sql Normal file
View File

@ -0,0 +1,42 @@
/*
Navicat Premium Data Transfer
Source Server : localhost
Source Server Type : MySQL
Source Server Version : 50723
Source Host : localhost:3306
Source Schema : yxshop
Target Server Type : MySQL
Target Server Version : 50723
File Encoding : 65001
Date: 06/03/2020 21:11:57
*/
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for yx_user_recharge
-- ----------------------------
DROP TABLE IF EXISTS `yx_user_recharge`;
CREATE TABLE `yx_user_recharge` (
`id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`uid` int(10) NULL DEFAULT NULL COMMENT '充值用户UID',
`nickname` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '',
`order_id` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '订单号',
`price` decimal(8, 2) NULL DEFAULT NULL COMMENT '充值金额',
`recharge_type` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '充值类型',
`paid` tinyint(1) NULL DEFAULT NULL COMMENT '是否充值',
`pay_time` int(10) NULL DEFAULT NULL COMMENT '充值支付时间',
`add_time` int(12) NULL DEFAULT NULL COMMENT '充值时间',
`refund_price` decimal(10, 2) NULL DEFAULT 0.00 COMMENT '退款金额',
PRIMARY KEY (`id`) USING BTREE,
UNIQUE INDEX `order_id`(`order_id`) USING BTREE,
INDEX `uid`(`uid`) USING BTREE,
INDEX `recharge_type`(`recharge_type`) USING BTREE,
INDEX `paid`(`paid`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 8 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '用户充值表' ROW_FORMAT = Dynamic;
SET FOREIGN_KEY_CHECKS = 1;

File diff suppressed because one or more lines are too long

4
sql/数据库说明.txt Normal file
View File

@ -0,0 +1,4 @@
新项目 直接导入yshop2.0.sql即可
1.9升级到2.0表变化的只有yx_user_recharge_sql、yx_system_store.sql
升级说明这次2.0代码改动地方多,升级需谨慎!!!

View File

@ -4,6 +4,7 @@ import co.yixiang.utils.SpringContextHolder;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.scheduling.annotation.EnableAsync;
@ -16,6 +17,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
@EnableAsync
@SpringBootApplication
@EnableTransactionManagement
@EnableCaching
@MapperScan({"co.yixiang.modules.*.mapper"})
public class ApiRun {

View File

@ -34,6 +34,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;

View File

@ -16,13 +16,13 @@ import co.yixiang.constant.ShopConstants;
import co.yixiang.modules.shop.service.YxStoreProductService;
import co.yixiang.modules.shop.service.YxSystemGroupDataService;
import co.yixiang.utils.FileUtil;
import co.yixiang.utils.RedisUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
@ -50,14 +50,11 @@ public class IndexController {
@AnonymousAccess
@Cacheable(cacheNames = ShopConstants.YSHOP_REDIS_INDEX_KEY)
@GetMapping("/index")
@ApiOperation(value = "首页数据",notes = "首页数据")
public ApiResult<Map<String,Object>> index(){
if(RedisUtil.get(ShopConstants.YSHOP_REDIS_INDEX_KEY) != null){
return ApiResult.ok(RedisUtil.get(ShopConstants.YSHOP_REDIS_INDEX_KEY));
}
Map<String,Object> map = new LinkedHashMap<>();
//banner
map.put("banner",systemGroupDataService.getDatas("routine_home_banner"));
@ -79,10 +76,6 @@ public class IndexController {
//滚动
map.put("roll",systemGroupDataService.getDatas("routine_home_roll_news"));
//缓存
RedisUtil.set(ShopConstants.YSHOP_REDIS_INDEX_KEY,map,ShopConstants.YSHOP_REDIS_INDEX_KEY_EXPIRE);
return ApiResult.ok(map);
}

View File

@ -52,7 +52,7 @@ public interface ShopConstants {
/**
* redis首页键
*/
String YSHOP_REDIS_INDEX_KEY = "yshop_index_data";
String YSHOP_REDIS_INDEX_KEY = "yshop:index_data";
/**
* redis首页过期时间 单位秒

View File

@ -3,6 +3,7 @@ package co.yixiang.modules.shop.rest;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import co.yixiang.aop.log.Log;
import co.yixiang.constant.ShopConstants;
import co.yixiang.exception.BadRequestException;
import co.yixiang.modules.shop.domain.YxStoreProduct;
import co.yixiang.modules.shop.service.YxStoreProductService;
@ -12,6 +13,7 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
@ -46,6 +48,7 @@ public class StoreProductController {
@Log("新增商品")
@ApiOperation(value = "新增商品")
@CacheEvict(cacheNames = ShopConstants.YSHOP_REDIS_INDEX_KEY,allEntries = true)
@PostMapping(value = "/yxStoreProduct")
@PreAuthorize("@el.check('admin','YXSTOREPRODUCT_ALL','YXSTOREPRODUCT_CREATE')")
public ResponseEntity create(@Validated @RequestBody YxStoreProduct resources){
@ -58,6 +61,7 @@ public class StoreProductController {
@Log("修改商品")
@ApiOperation(value = "修改商品")
@CacheEvict(cacheNames = ShopConstants.YSHOP_REDIS_INDEX_KEY,allEntries = true)
@PutMapping(value = "/yxStoreProduct")
@PreAuthorize("@el.check('admin','YXSTOREPRODUCT_ALL','YXSTOREPRODUCT_EDIT')")
public ResponseEntity update(@Validated @RequestBody YxStoreProduct resources){
@ -68,6 +72,7 @@ public class StoreProductController {
@Log("删除商品")
@ApiOperation(value = "删除商品")
@CacheEvict(cacheNames = ShopConstants.YSHOP_REDIS_INDEX_KEY,allEntries = true)
@DeleteMapping(value = "/yxStoreProduct/{id}")
@PreAuthorize("@el.check('admin','YXSTOREPRODUCT_ALL','YXSTOREPRODUCT_DELETE')")
public ResponseEntity delete(@PathVariable Integer id){
@ -77,6 +82,7 @@ public class StoreProductController {
}
@ApiOperation(value = "恢复数据")
@CacheEvict(cacheNames = ShopConstants.YSHOP_REDIS_INDEX_KEY,allEntries = true)
@DeleteMapping(value = "/yxStoreProduct/recovery/{id}")
@PreAuthorize("@el.check('admin','YXSTOREPRODUCT_ALL','YXSTOREPRODUCT_DELETE')")
public ResponseEntity recovery(@PathVariable Integer id){
@ -85,6 +91,7 @@ public class StoreProductController {
}
@ApiOperation(value = "商品上架/下架")
@CacheEvict(cacheNames = ShopConstants.YSHOP_REDIS_INDEX_KEY,allEntries = true)
@PostMapping(value = "/yxStoreProduct/onsale/{id}")
public ResponseEntity onSale(@PathVariable Integer id,@RequestBody String jsonStr){
JSONObject jsonObject = JSON.parseObject(jsonStr);
@ -101,6 +108,7 @@ public class StoreProductController {
}
@ApiOperation(value = "设置保存属性")
@CacheEvict(cacheNames = ShopConstants.YSHOP_REDIS_INDEX_KEY,allEntries = true)
@PostMapping(value = "/yxStoreProduct/setAttr/{id}")
public ResponseEntity setAttr(@PathVariable Integer id,@RequestBody String jsonStr){
yxStoreProductService.createProductAttr(id,jsonStr);
@ -108,6 +116,7 @@ public class StoreProductController {
}
@ApiOperation(value = "清除属性")
@CacheEvict(cacheNames = ShopConstants.YSHOP_REDIS_INDEX_KEY,allEntries = true)
@PostMapping(value = "/yxStoreProduct/clearAttr/{id}")
public ResponseEntity clearAttr(@PathVariable Integer id){
yxStoreProductService.clearProductAttr(id,true);

View File

@ -3,6 +3,7 @@ package co.yixiang.modules.shop.rest;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import co.yixiang.aop.log.Log;
import co.yixiang.constant.ShopConstants;
import co.yixiang.exception.BadRequestException;
import co.yixiang.modules.shop.domain.YxSystemConfig;
import co.yixiang.modules.shop.service.YxSystemConfigService;
@ -14,6 +15,7 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;

View File

@ -3,6 +3,7 @@ package co.yixiang.modules.shop.rest;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import co.yixiang.aop.log.Log;
import co.yixiang.constant.ShopConstants;
import co.yixiang.exception.BadRequestException;
import co.yixiang.modules.shop.domain.YxSystemGroupData;
import co.yixiang.modules.shop.service.YxSystemGroupDataService;
@ -13,6 +14,7 @@ import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
@ -38,6 +40,7 @@ public class SystemGroupDataController {
@Log("查询数据配置")
@ApiOperation(value = "查询数据配置")
@CacheEvict(cacheNames = ShopConstants.YSHOP_REDIS_INDEX_KEY,allEntries = true)
@GetMapping(value = "/yxSystemGroupData")
@PreAuthorize("@el.check('admin','YXSYSTEMGROUPDATA_ALL','YXSYSTEMGROUPDATA_SELECT')")
public ResponseEntity getYxSystemGroupDatas(YxSystemGroupDataQueryCriteria criteria,

View File

@ -3,6 +3,7 @@ package co.yixiang.modules.shop.service.impl;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import co.yixiang.constant.ShopConstants;
import co.yixiang.exception.BadRequestException;
import co.yixiang.modules.shop.domain.YxStoreProduct;
import co.yixiang.modules.shop.domain.YxStoreProductAttr;
@ -17,6 +18,7 @@ import co.yixiang.utils.QueryHelp;
import co.yixiang.utils.ValidationUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;