添加画布配置

This commit is contained in:
xuwenbo
2021-02-02 09:21:36 +08:00
parent 92cd40f8fa
commit 7e4cbfb541
11 changed files with 446 additions and 0 deletions

View File

@ -11,4 +11,22 @@ ALTER TABLE yx_store_product_attr_value ADD COLUMN integral INT(10) DEFAULT 0 C
ALTER TABLE yx_store_order ADD COLUMN `pay_integral` decimal(8, 2) UNSIGNED NOT NULL DEFAULT 0.00 COMMENT '支付积分';
-- ----------------------------
-- Table structure for yx_store_canvas
-- ----------------------------
DROP TABLE IF EXISTS `yx_store_canvas`;
CREATE TABLE `yx_store_canvas` (
`canvas_id` bigint(11) NOT NULL AUTO_INCREMENT COMMENT '画布id',
`terminal` tinyint(1) NOT NULL COMMENT '终端 1-小程序 2-H5 3-APP 4-PC',
`json` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '画布json数据',
`type` tinyint(1) NOT NULL DEFAULT 1 COMMENT '类型 1-系统画布 2-自定义页面 3-商家店铺装修',
`name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '名称',
`shop_id` bigint(20) NOT NULL DEFAULT 0 COMMENT '店铺id当type=3的时候值为具体的店铺id其它情况为0',
`create_time` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '创建时间',
`update_time` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '修改时间',
`is_del` tinyint(1) NULL DEFAULT NULL COMMENT '删除标识',
PRIMARY KEY (`canvas_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 11 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '画布信息表' ROW_FORMAT = DYNAMIC;

View File

@ -7346,4 +7346,23 @@ INSERT INTO `yx_wechat_template` VALUES (13, 'pay_success', '订单支付成功
INSERT INTO `yx_wechat_template` VALUES (14, 'recharge_success', '帐户资金变动提醒', '{{first.DATA}}\n变动类型{{keyword1.DATA}}\n变动时间{{keyword2.DATA}}\n变动金额{{keyword3.DATA}}\n{{remark.DATA}}', 'ePF4RS3ONCEuS9AuPyqZ2Th_B-HZ6E1CIpnJRt7ACwI', '2020-06-25 18:54:35', '2020-07-06 15:51:54', 1, 0, NULL);
INSERT INTO `yx_wechat_template` VALUES (15, 'refund_success', '退款进度通知', '', 'jaDVkOdbbk01WcWSxp1_liEQen44-euhj7shxjDvLIc', '2020-07-06 15:53:10', NULL, 0, 0, NULL);
-- ----------------------------
-- Table structure for yx_store_canvas
-- ----------------------------
DROP TABLE IF EXISTS `yx_store_canvas`;
CREATE TABLE `yx_store_canvas` (
`canvas_id` bigint(11) NOT NULL AUTO_INCREMENT COMMENT '画布id',
`terminal` tinyint(1) NOT NULL COMMENT '终端 1-小程序 2-H5 3-APP 4-PC',
`json` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '画布json数据',
`type` tinyint(1) NOT NULL DEFAULT 1 COMMENT '类型 1-系统画布 2-自定义页面 3-商家店铺装修',
`name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '名称',
`shop_id` bigint(20) NOT NULL DEFAULT 0 COMMENT '店铺id当type=3的时候值为具体的店铺id其它情况为0',
`create_time` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '创建时间',
`update_time` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '修改时间',
`is_del` tinyint(1) NULL DEFAULT NULL COMMENT '删除标识',
PRIMARY KEY (`canvas_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 11 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '画布信息表' ROW_FORMAT = DYNAMIC;
SET FOREIGN_KEY_CHECKS = 1;

View File

@ -122,6 +122,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
.antMatchers("/file/**").permitAll()
// 阿里巴巴 druid
.antMatchers("/druid/**").permitAll()
.antMatchers("/api/canvas/**").permitAll()
// 放行OPTIONS请求
.antMatchers(HttpMethod.OPTIONS, "/**").permitAll()

View File

@ -17,6 +17,8 @@ import co.yixiang.enums.ProductEnum;
import co.yixiang.modules.activity.service.YxStoreCombinationService;
import co.yixiang.modules.activity.service.YxStoreSeckillService;
import co.yixiang.modules.activity.vo.YxStoreSeckillQueryVo;
import co.yixiang.modules.canvas.domain.StoreCanvas;
import co.yixiang.modules.canvas.service.StoreCanvasService;
import co.yixiang.modules.mp.service.YxWechatLiveService;
import co.yixiang.modules.product.service.YxStoreProductService;
import co.yixiang.modules.product.vo.YxSystemStoreQueryVo;
@ -39,6 +41,8 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
@ -67,6 +71,15 @@ public class IndexController {
private final YxStoreSeckillService storeSeckillService;
private final YxWechatLiveService wechatLiveService;
private final StoreCanvasService storeCanvasService;
@GetMapping("/getCanvas")
@ApiOperation(value = "读取画布数据")
public ResponseEntity<StoreCanvas> getCanvas(StoreCanvas storeCanvas){
StoreCanvas canvas = storeCanvasService.lambdaQuery().eq(StoreCanvas::getTerminal, storeCanvas.getCanvasId()).one();
return new ResponseEntity<>(canvas, HttpStatus.OK);
}
@Cacheable(cacheNames = ShopConstants.YSHOP_REDIS_INDEX_KEY)
@GetMapping("/index")
@ApiOperation(value = "首页数据",notes = "首页数据")

View File

@ -0,0 +1,54 @@
/**
* Copyright (C) 2018-2020
* All rights reserved, Designed By www.yixiang.co
* 注意:
* 本软件为www.yixiang.co开发研制未经购买不得使用
* 购买后可获得全部源代码禁止转卖、分享、上传到码云、github等开源平台
* 一经发现盗用、分享等行为,将追究法律责任,后果自负
*/
package co.yixiang.modules.canvas.domain;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
import com.baomidou.mybatisplus.annotation.TableName;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import javax.validation.constraints.*;
import co.yixiang.domain.BaseDomain;
/**
* @author yshop
* @date 2021-02-01
*/
@Data
@TableName("yx_store_canvas")
public class StoreCanvas extends BaseDomain {
/** 画布id */
@TableId
private Long canvasId;
/** 终端 1-小程序 2-H5 3-APP 4-PC */
@NotNull
private Integer terminal;
/** 画布json数据 */
private String json;
/** 类型 1-系统画布 2-自定义页面 3-商家店铺装修 */
@NotNull
private Integer type;
/** 名称 */
@NotBlank
private String name;
/** 店铺id当type=3的时候值为具体的店铺id其它情况为0 */
@NotNull
private Long shopId;
public void copy(StoreCanvas source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
}
}

View File

@ -0,0 +1,48 @@
/**
* Copyright (C) 2018-2020
* All rights reserved, Designed By www.yixiang.co
* 注意:
* 本软件为www.yixiang.co开发研制未经购买不得使用
* 购买后可获得全部源代码禁止转卖、分享、上传到码云、github等开源平台
* 一经发现盗用、分享等行为,将追究法律责任,后果自负
*/
package co.yixiang.modules.canvas.service;
import co.yixiang.common.service.BaseService;
import co.yixiang.modules.canvas.domain.StoreCanvas;
import co.yixiang.modules.canvas.service.dto.StoreCanvasDto;
import co.yixiang.modules.canvas.service.dto.StoreCanvasQueryCriteria;
import org.springframework.data.domain.Pageable;
import java.util.Map;
import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import co.yixiang.domain.PageResult;
/**
* @author yshop
* @date 2021-02-01
*/
public interface StoreCanvasService extends BaseService<StoreCanvas>{
/**
* 查询数据分页
* @param criteria 条件
* @param pageable 分页参数
* @return Map<String,Object>
*/
PageResult<StoreCanvasDto> queryAll(StoreCanvasQueryCriteria criteria, Pageable pageable);
/**
* 查询所有数据不分页
* @param criteria 条件参数
* @return List<StoreCanvasDto>
*/
List<StoreCanvas> queryAll(StoreCanvasQueryCriteria criteria);
/**
* 导出数据
* @param all 待导出的数据
* @param response /
* @throws IOException /
*/
void download(List<StoreCanvasDto> all, HttpServletResponse response) throws IOException;
}

View File

@ -0,0 +1,44 @@
/**
* Copyright (C) 2018-2020
* All rights reserved, Designed By www.yixiang.co
* 注意:
* 本软件为www.yixiang.co开发研制未经购买不得使用
* 购买后可获得全部源代码禁止转卖、分享、上传到码云、github等开源平台
* 一经发现盗用、分享等行为,将追究法律责任,后果自负
*/
package co.yixiang.modules.canvas.service.dto;
import lombok.Data;
import java.io.Serializable;
/**
* @author yshop
* @date 2021-02-01
*/
@Data
public class StoreCanvasDto implements Serializable {
/** 画布id */
private Long canvasId;
/** 终端 1-小程序 2-H5 3-APP 4-PC */
private Integer terminal;
/** 画布json数据 */
private String json;
/** 类型 1-系统画布 2-自定义页面 3-商家店铺装修 */
private Integer type;
/** 名称 */
private String name;
/** 店铺id当type=3的时候值为具体的店铺id其它情况为0 */
private Long shopId;
/** 创建时间 */
private String createTime;
/** 修改时间 */
private String updateTime;
}

View File

@ -0,0 +1,21 @@
/**
* Copyright (C) 2018-2020
* All rights reserved, Designed By www.yixiang.co
* 注意:
* 本软件为www.yixiang.co开发研制未经购买不得使用
* 购买后可获得全部源代码禁止转卖、分享、上传到码云、github等开源平台
* 一经发现盗用、分享等行为,将追究法律责任,后果自负
*/
package co.yixiang.modules.canvas.service.dto;
import lombok.Data;
import java.util.List;
import co.yixiang.annotation.Query;
/**
* @author yshop
* @date 2021-02-01
*/
@Data
public class StoreCanvasQueryCriteria{
}

View File

@ -0,0 +1,84 @@
/**
* Copyright (C) 2018-2020
* All rights reserved, Designed By www.yixiang.co
* 注意:
* 本软件为www.yixiang.co开发研制未经购买不得使用
* 购买后可获得全部源代码禁止转卖、分享、上传到码云、github等开源平台
* 一经发现盗用、分享等行为,将追究法律责任,后果自负
*/
package co.yixiang.modules.canvas.service.impl;
import co.yixiang.modules.canvas.domain.StoreCanvas;
import co.yixiang.common.service.impl.BaseServiceImpl;
import lombok.AllArgsConstructor;
import co.yixiang.dozer.service.IGenerator;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import co.yixiang.common.utils.QueryHelpPlus;
import co.yixiang.utils.ValidationUtil;
import co.yixiang.utils.FileUtil;
import co.yixiang.modules.canvas.service.StoreCanvasService;
import co.yixiang.modules.canvas.service.dto.StoreCanvasDto;
import co.yixiang.modules.canvas.service.dto.StoreCanvasQueryCriteria;
import co.yixiang.modules.canvas.service.mapper.StoreCanvasMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
// 默认不使用缓存
//import org.springframework.cache.annotation.CacheConfig;
//import org.springframework.cache.annotation.CacheEvict;
//import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import java.util.List;
import java.util.Map;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import co.yixiang.domain.PageResult;
/**
* @author yshop
* @date 2021-02-01
*/
@Service
@AllArgsConstructor
//@CacheConfig(cacheNames = "storeCanvas")
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
public class StoreCanvasServiceImpl extends BaseServiceImpl<StoreCanvasMapper, StoreCanvas> implements StoreCanvasService {
private final IGenerator generator;
@Override
//@Cacheable
public PageResult<StoreCanvasDto> queryAll(StoreCanvasQueryCriteria criteria, Pageable pageable) {
getPage(pageable);
PageInfo<StoreCanvas> page = new PageInfo<>(queryAll(criteria));
return generator.convertPageInfo(page,StoreCanvasDto.class);
}
@Override
//@Cacheable
public List<StoreCanvas> queryAll(StoreCanvasQueryCriteria criteria){
return baseMapper.selectList(QueryHelpPlus.getPredicate(StoreCanvas.class, criteria));
}
@Override
public void download(List<StoreCanvasDto> all, HttpServletResponse response) throws IOException {
List<Map<String, Object>> list = new ArrayList<>();
for (StoreCanvasDto storeCanvas : all) {
Map<String,Object> map = new LinkedHashMap<>();
map.put("终端 1-小程序 2-H5 3-APP 4-PC", storeCanvas.getTerminal());
map.put("画布json数据", storeCanvas.getJson());
map.put("类型 1-系统画布 2-自定义页面 3-商家店铺装修", storeCanvas.getType());
map.put("名称", storeCanvas.getName());
map.put("店铺id当type=3的时候值为具体的店铺id其它情况为0", storeCanvas.getShopId());
map.put("创建时间", storeCanvas.getCreateTime());
map.put("修改时间", storeCanvas.getUpdateTime());
list.add(map);
}
FileUtil.downloadExcel(list, response);
}
}

View File

@ -0,0 +1,23 @@
/**
* Copyright (C) 2018-2020
* All rights reserved, Designed By www.yixiang.co
* 注意:
* 本软件为www.yixiang.co开发研制未经购买不得使用
* 购买后可获得全部源代码禁止转卖、分享、上传到码云、github等开源平台
* 一经发现盗用、分享等行为,将追究法律责任,后果自负
*/
package co.yixiang.modules.canvas.service.mapper;
import co.yixiang.common.mapper.CoreMapper;
import co.yixiang.modules.canvas.domain.StoreCanvas;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;
/**
* @author yshop
* @date 2021-02-01
*/
@Repository
public interface StoreCanvasMapper extends CoreMapper<StoreCanvas> {
}

View File

@ -0,0 +1,121 @@
/**
* Copyright (C) 2018-2020
* All rights reserved, Designed By www.yixiang.co
* 注意:
* 本软件为www.yixiang.co开发研制未经购买不得使用
* 购买后可获得全部源代码禁止转卖、分享、上传到码云、github等开源平台
* 一经发现盗用、分享等行为,将追究法律责任,后果自负
*/
package co.yixiang.modules.canvas.rest;
import java.util.Arrays;
import cn.hutool.core.util.StrUtil;
import co.yixiang.api.YshopException;
import co.yixiang.constant.ShopConstants;
import co.yixiang.constant.SystemConfigConstants;
import co.yixiang.dozer.service.IGenerator;
import co.yixiang.enums.ShopCommonEnum;
import co.yixiang.tools.domain.QiniuContent;
import co.yixiang.tools.service.LocalStorageService;
import co.yixiang.tools.service.QiNiuService;
import co.yixiang.tools.service.dto.LocalStorageDto;
import co.yixiang.utils.RedisUtils;
import lombok.AllArgsConstructor;
import co.yixiang.logging.aop.log.Log;
import co.yixiang.modules.canvas.domain.StoreCanvas;
import co.yixiang.modules.canvas.service.StoreCanvasService;
import co.yixiang.modules.canvas.service.dto.StoreCanvasQueryCriteria;
import co.yixiang.modules.canvas.service.dto.StoreCanvasDto;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import co.yixiang.domain.PageResult;
import org.springframework.web.multipart.MultipartFile;
/**
* @author yshop
* @date 2021-02-01
*/
@AllArgsConstructor
@Api(tags = "画布管理")
@RestController
@RequestMapping("/api/canvas")
public class StoreCanvasController {
private final StoreCanvasService storeCanvasService;
private final LocalStorageService localStorageService;
private final QiNiuService qiNiuService;
private final RedisUtils redisUtils;
@PostMapping("/saveCanvas")
@Log("新增或修改画布")
@ApiOperation("新增或修改画布")
public ResponseEntity<Object> create(@Validated @RequestBody StoreCanvas resources){
return new ResponseEntity<>(storeCanvasService.saveOrUpdate(resources),HttpStatus.CREATED);
}
@ApiOperation("上传文件")
@PostMapping("/upload")
public ResponseEntity<Object> create(@RequestParam(defaultValue = "") String name,
@RequestParam(defaultValue = "") String type,
@RequestParam("file") MultipartFile file) {
String localUrl = redisUtils.getY(ShopConstants.ADMIN_API_URL);
if(StrUtil.isBlank(type)){
localUrl = redisUtils.getY(SystemConfigConstants.API_URL) + "/api";
}
String mode = redisUtils.getY(SystemConfigConstants.FILE_STORE_MODE);
StringBuilder url = new StringBuilder();
if (ShopCommonEnum.STORE_MODE_1.getValue().toString().equals(mode)) { //存在走本地
if(StrUtil.isBlank(localUrl)){
throw new YshopException("本地上传,请先登陆系统配置后台/移动端API地址");
}
LocalStorageDto localStorageDTO = localStorageService.create(name, file);
if ("".equals(url.toString())) {
url = url.append(localUrl + "/file/" + localStorageDTO.getType() + "/" + localStorageDTO.getRealName());
} else {
url = url.append(","+localUrl + "/file/" + localStorageDTO.getType() + "/" + localStorageDTO.getRealName());
}
} else {//走七牛云
QiniuContent qiniuContent = qiNiuService.upload(file, qiNiuService.find());
if ("".equals(url.toString())) {
url = url.append(qiniuContent.getUrl());
}else{
url = url.append(","+qiniuContent.getUrl());
}
}
Map<String, Object> map = new HashMap<>(2);
map.put("errno", 0);
map.put("link", url);
return new ResponseEntity(map, HttpStatus.CREATED);
}
@GetMapping("/getCanvas")
@ApiOperation(value = "读取画布数据")
public ResponseEntity<StoreCanvas> getCanvas(StoreCanvas storeCanvas){
StoreCanvas canvas = storeCanvasService.lambdaQuery().eq(StoreCanvas::getTerminal, storeCanvas.getCanvasId()).one();
return new ResponseEntity<>(canvas,HttpStatus.OK);
}
@Log("删除画布")
@ApiOperation("删除画布")
@DeleteMapping
public ResponseEntity<Object> deleteAll(@RequestBody Long[] ids) {
Arrays.asList(ids).forEach(id->{
storeCanvasService.removeById(id);
});
return new ResponseEntity<>(HttpStatus.OK);
}
}