perf(代码结构): 优化包路径

master
wayn 4 years ago
parent 08a7ed379e
commit 25c9fdfcab

@ -56,6 +56,20 @@
<groupId>com.wayn</groupId>
<artifactId>waynboot-common</artifactId>
<version>0.0.1-SNAPSHOT</version>
<exclusions>
<exclusion>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
</exclusion>
<exclusion>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-client</artifactId>
</exclusion>
<exclusion>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-high-level-client</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>

@ -2,7 +2,7 @@ package com.wayn.admin.api.controller.shop;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wayn.common.base.BaseController;
import com.wayn.common.base.controller.BaseController;
import com.wayn.common.core.domain.shop.Address;
import com.wayn.common.core.service.shop.IAddressService;
import com.wayn.common.util.R;

@ -2,7 +2,7 @@ package com.wayn.admin.api.controller.shop;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wayn.admin.framework.config.properties.ExpressProperties;
import com.wayn.common.base.BaseController;
import com.wayn.common.base.controller.BaseController;
import com.wayn.common.core.domain.shop.Order;
import com.wayn.common.core.domain.vo.ShipVO;
import com.wayn.common.core.service.shop.IAdminOrderService;

@ -1,7 +1,7 @@
package com.wayn.admin.api.controller.shop;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wayn.common.base.BaseController;
import com.wayn.common.base.controller.BaseController;
import com.wayn.common.core.domain.shop.Banner;
import com.wayn.common.core.service.shop.IBannerService;
import com.wayn.common.util.R;

@ -1,7 +1,7 @@
package com.wayn.admin.api.controller.shop;
import com.wayn.common.base.BaseController;
import com.wayn.common.base.controller.BaseController;
import com.wayn.common.core.domain.shop.Category;
import com.wayn.common.core.service.shop.ICategoryService;
import com.wayn.common.util.R;

@ -1,6 +1,6 @@
package com.wayn.admin.api.controller.shop;
import com.wayn.common.base.BaseController;
import com.wayn.common.base.controller.BaseController;
import com.wayn.common.constant.SysConstants;
import com.wayn.common.core.domain.shop.Channel;
import com.wayn.common.core.service.shop.IChannelService;

@ -2,7 +2,7 @@ package com.wayn.admin.api.controller.shop;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wayn.common.base.BaseController;
import com.wayn.common.base.controller.BaseController;
import com.wayn.common.core.domain.shop.Comment;
import com.wayn.common.core.service.shop.ICommentService;
import com.wayn.common.util.R;

@ -2,8 +2,8 @@ package com.wayn.admin.api.controller.shop;
import com.alibaba.fastjson.JSONObject;
import com.wayn.admin.framework.manager.elastic.service.BaseElasticService;
import com.wayn.common.base.ElasticEntity;
import com.wayn.common.base.entity.ElasticEntity;
import com.wayn.common.base.service.BaseElasticService;
import com.wayn.common.core.domain.shop.Goods;
import com.wayn.common.core.service.shop.IGoodsService;
import com.wayn.common.util.R;

@ -1,7 +1,7 @@
package com.wayn.admin.api.controller.shop;
import com.wayn.common.base.BaseController;
import com.wayn.common.base.controller.BaseController;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@ -2,10 +2,10 @@ package com.wayn.admin.api.controller.shop;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wayn.admin.framework.manager.elastic.service.BaseElasticService;
import com.wayn.admin.framework.redis.RedisCache;
import com.wayn.common.base.BaseController;
import com.wayn.common.base.ElasticEntity;
import com.wayn.common.base.controller.BaseController;
import com.wayn.common.base.entity.ElasticEntity;
import com.wayn.common.base.service.BaseElasticService;
import com.wayn.common.constant.SysConstants;
import com.wayn.common.core.domain.shop.Goods;
import com.wayn.common.core.domain.vo.GoodsSaveRelatedVO;
@ -35,8 +35,6 @@ import java.util.concurrent.TimeUnit;
@RequestMapping("/shop/goods")
public class GoodsController extends BaseController {
private static final String GOODS_INDEX = "goods";
private static final String REDIS_GOODS_INDEX = "es_goods";
@Autowired
private IGoodsService iGoodsService;
@Autowired
@ -72,14 +70,14 @@ public class GoodsController extends BaseController {
@PostMapping("syncEs")
public R syncEs() {
if (redisCache.getCacheObject(REDIS_GOODS_INDEX) != null) {
if (redisCache.getCacheObject(SysConstants.REDIS_GOODS_INDEX) != null) {
return R.error("正在同步,请稍等");
}
boolean flag = false;
redisCache.setCacheObject(REDIS_GOODS_INDEX, true, 3, TimeUnit.MINUTES);
baseElasticService.deleteIndex(GOODS_INDEX);
redisCache.setCacheObject(SysConstants.REDIS_GOODS_INDEX, true, 3, TimeUnit.MINUTES);
baseElasticService.deleteIndex(SysConstants.GOODS_INDEX);
InputStream inputStream = this.getClass().getResourceAsStream(SysConstants.ES_INDEX_GOODS_FILENAME);
if (baseElasticService.createIndex(GOODS_INDEX, FileUtils.getContent(inputStream))) {
if (baseElasticService.createIndex(SysConstants.GOODS_INDEX, FileUtils.getContent(inputStream))) {
List<Goods> list = iGoodsService.list();
List<ElasticEntity> entities = new ArrayList<>();
for (Goods goods : list) {
@ -96,7 +94,7 @@ public class GoodsController extends BaseController {
entities.add(elasticEntity);
}
flag = baseElasticService.insertBatch("goods", entities);
redisCache.deleteObject(REDIS_GOODS_INDEX);
redisCache.deleteObject(SysConstants.REDIS_GOODS_INDEX);
}
return R.result(flag);
}

@ -1,7 +1,7 @@
package com.wayn.admin.api.controller.shop;
import com.wayn.common.base.BaseController;
import com.wayn.common.base.controller.BaseController;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@ -1,7 +1,7 @@
package com.wayn.admin.api.controller.shop;
import com.wayn.common.base.BaseController;
import com.wayn.common.base.controller.BaseController;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@ -2,7 +2,7 @@ package com.wayn.admin.api.controller.shop;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wayn.common.base.BaseController;
import com.wayn.common.base.controller.BaseController;
import com.wayn.common.core.domain.shop.Member;
import com.wayn.common.core.service.shop.IMemberService;
import com.wayn.common.util.R;

@ -2,7 +2,7 @@ package com.wayn.admin.api.controller.system;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wayn.common.base.BaseController;
import com.wayn.common.base.controller.BaseController;
import com.wayn.common.constant.SysConstants;
import com.wayn.common.core.domain.system.Dict;
import com.wayn.common.core.service.system.IDictService;

@ -2,7 +2,7 @@ package com.wayn.admin.api.controller.system;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wayn.admin.framework.config.WaynConfig;
import com.wayn.common.base.BaseController;
import com.wayn.common.base.controller.BaseController;
import com.wayn.common.constant.SysConstants;
import com.wayn.common.core.domain.system.Dict;
import com.wayn.common.core.service.system.IDictService;

@ -1,7 +1,7 @@
package com.wayn.admin.api.controller.system;
import com.wayn.admin.framework.security.service.TokenService;
import com.wayn.common.base.BaseController;
import com.wayn.common.base.controller.BaseController;
import com.wayn.common.constant.SysConstants;
import com.wayn.common.core.domain.system.Menu;
import com.wayn.common.core.model.LoginUserDetail;

@ -2,7 +2,7 @@ package com.wayn.admin.api.controller.system;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wayn.admin.framework.config.WaynConfig;
import com.wayn.common.base.BaseController;
import com.wayn.common.base.controller.BaseController;
import com.wayn.common.constant.SysConstants;
import com.wayn.common.core.domain.system.Role;
import com.wayn.common.core.service.system.IRoleService;

@ -4,7 +4,7 @@ import cn.afterturn.easypoi.excel.entity.ImportParams;
import cn.afterturn.easypoi.excel.imports.ExcelImportService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wayn.admin.framework.config.WaynConfig;
import com.wayn.common.base.BaseController;
import com.wayn.common.base.controller.BaseController;
import com.wayn.common.constant.SysConstants;
import com.wayn.common.core.domain.system.User;
import com.wayn.common.core.service.system.IRoleService;

@ -164,6 +164,33 @@
<artifactId>weixin-java-pay</artifactId>
<version>3.8.0</version>
</dependency>
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-high-level-client</artifactId>
<version>7.4.2</version>
<exclusions>
<exclusion>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
</exclusion>
<exclusion>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-client</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>7.4.2</version>
</dependency>
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-client</artifactId>
<version>7.4.2</version>
</dependency>
</dependencies>
<build>

@ -1,4 +1,4 @@
package com.wayn.common.base;
package com.wayn.common.base.controller;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;

@ -1,4 +1,4 @@
package com.wayn.common.base;
package com.wayn.common.base.entity;
import cn.afterturn.easypoi.excel.annotation.Excel;
import com.baomidou.mybatisplus.annotation.TableField;

@ -1,4 +1,4 @@
package com.wayn.common.base;
package com.wayn.common.base.entity;
import cn.afterturn.easypoi.excel.annotation.Excel;
import com.baomidou.mybatisplus.annotation.TableField;

@ -1,13 +1,13 @@
package com.wayn.admin.framework.manager.elastic.service;
package com.wayn.common.base.service;
import com.alibaba.fastjson.JSON;
import com.wayn.common.base.ElasticEntity;
import com.wayn.common.base.entity.ElasticEntity;
import lombok.extern.slf4j.Slf4j;
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest;
import org.elasticsearch.action.bulk.BulkItemResponse;
import org.elasticsearch.action.bulk.BulkRequest;
import org.elasticsearch.action.bulk.BulkResponse;
import org.elasticsearch.action.delete.DeleteRequest;
import org.elasticsearch.action.delete.DeleteResponse;
import org.elasticsearch.action.index.IndexRequest;
import org.elasticsearch.action.index.IndexResponse;
import org.elasticsearch.action.search.MultiSearchRequest;
@ -108,27 +108,26 @@ public class BaseElasticService {
* @param idxName index
* @param entity
*/
public String insertOrUpdateOne(String idxName, ElasticEntity entity) {
public boolean insertOrUpdateOne(String idxName, ElasticEntity entity) {
IndexRequest request = new IndexRequest(idxName);
log.error("Data : id={},entity={}", entity.getId(), JSON.toJSONString(entity.getData()));
request.id(entity.getId());
request.source(entity.getData(), XContentType.JSON);
// request.source(JSON.toJSONString(entity.getData()), XContentType.JSON);
String result = null;
try {
IndexResponse indexResponse = restHighLevelClient.index(request, RequestOptions.DEFAULT);
ReplicationResponse.ShardInfo shardInfo = indexResponse.getShardInfo();
if (shardInfo.getFailed() > 0) {
for (ReplicationResponse.ShardInfo.Failure failure :
shardInfo.getFailures()) {
return failure.reason();
log.error(failure.reason());
}
return false;
}
result = indexResponse.getId();
} catch (Exception e) {
throw new RuntimeException(e);
}
return result;
return true;
}
@ -144,10 +143,8 @@ public class BaseElasticService {
.source(item.getData(), XContentType.JSON)));
try {
BulkResponse bulkResponse = restHighLevelClient.bulk(request, RequestOptions.DEFAULT);
for (BulkItemResponse bulkItemResponse : bulkResponse) {
if (bulkResponse.hasFailures()) {
return false;
}
if (bulkResponse.hasFailures()) {
return false;
}
} catch (Exception e) {
throw new RuntimeException(e);
@ -171,6 +168,32 @@ public class BaseElasticService {
}
}
/**
*
* @param idxName
* @param id ID
* @return boolean
*/
public boolean delete(String idxName, String id) {
DeleteRequest request = new DeleteRequest(
idxName, id);
try {
DeleteResponse deleteResponse = restHighLevelClient.delete(
request, RequestOptions.DEFAULT);
ReplicationResponse.ShardInfo shardInfo = deleteResponse.getShardInfo();
if (shardInfo.getFailed() > 0) {
for (ReplicationResponse.ShardInfo.Failure failure :
shardInfo.getFailures()) {
log.error(failure.reason());
}
return false;
}
} catch (Exception e) {
throw new RuntimeException(e);
}
return true;
}
/**
* @param idxName index
* @param builder

@ -78,4 +78,7 @@ public class SysConstants {
*/
public static String ES_INDEX_GOODS_FILENAME = "/es/index/goods";
public static final String GOODS_INDEX = "goods";
public static final String REDIS_GOODS_INDEX = "es_goods";
}

@ -3,7 +3,7 @@ package com.wayn.common.core.domain.shop;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.wayn.common.base.ShopBaseEntity;
import com.wayn.common.base.entity.ShopBaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;

@ -3,7 +3,7 @@ package com.wayn.common.core.domain.shop;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.wayn.common.base.ShopBaseEntity;
import com.wayn.common.base.entity.ShopBaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;

@ -3,7 +3,7 @@ package com.wayn.common.core.domain.shop;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.wayn.common.base.ShopBaseEntity;
import com.wayn.common.base.entity.ShopBaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;

@ -3,7 +3,7 @@ package com.wayn.common.core.domain.shop;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.wayn.common.base.ShopBaseEntity;
import com.wayn.common.base.entity.ShopBaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;

@ -3,7 +3,7 @@ package com.wayn.common.core.domain.shop;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.wayn.common.base.ShopBaseEntity;
import com.wayn.common.base.entity.ShopBaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;

@ -5,7 +5,7 @@ import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import com.wayn.common.base.ShopBaseEntity;
import com.wayn.common.base.entity.ShopBaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;

@ -3,7 +3,7 @@ package com.wayn.common.core.domain.shop;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.wayn.common.base.ShopBaseEntity;
import com.wayn.common.base.entity.ShopBaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;

@ -5,7 +5,7 @@ import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import com.wayn.common.base.ShopBaseEntity;
import com.wayn.common.base.entity.ShopBaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;

@ -3,7 +3,7 @@ package com.wayn.common.core.domain.shop;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.wayn.common.base.ShopBaseEntity;
import com.wayn.common.base.entity.ShopBaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;

@ -5,7 +5,7 @@ import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import com.wayn.common.base.ShopBaseEntity;
import com.wayn.common.base.entity.ShopBaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;

@ -3,7 +3,7 @@ package com.wayn.common.core.domain.shop;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.wayn.common.base.ShopBaseEntity;
import com.wayn.common.base.entity.ShopBaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;

@ -4,7 +4,7 @@ import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.wayn.common.base.ShopBaseEntity;
import com.wayn.common.base.entity.ShopBaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;

@ -4,7 +4,7 @@ import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.wayn.common.base.ShopBaseEntity;
import com.wayn.common.base.entity.ShopBaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;

@ -4,7 +4,7 @@ import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.wayn.common.base.BaseEntity;
import com.wayn.common.base.entity.BaseEntity;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import lombok.EqualsAndHashCode;

@ -4,7 +4,7 @@ import cn.afterturn.easypoi.excel.annotation.Excel;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.wayn.common.base.BaseEntity;
import com.wayn.common.base.entity.BaseEntity;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import lombok.EqualsAndHashCode;

@ -4,7 +4,7 @@ import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.wayn.common.base.BaseEntity;
import com.wayn.common.base.entity.BaseEntity;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import lombok.EqualsAndHashCode;

@ -5,7 +5,7 @@ import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.wayn.common.base.BaseEntity;
import com.wayn.common.base.entity.BaseEntity;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import lombok.EqualsAndHashCode;

@ -5,7 +5,7 @@ import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.wayn.common.base.BaseEntity;
import com.wayn.common.base.entity.BaseEntity;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import lombok.EqualsAndHashCode;

@ -4,12 +4,15 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wayn.common.base.entity.ElasticEntity;
import com.wayn.common.base.service.BaseElasticService;
import com.wayn.common.constant.SysConstants;
import com.wayn.common.core.domain.shop.*;
import com.wayn.common.core.domain.vo.GoodsSaveRelatedVO;
import com.wayn.common.core.domain.vo.SearchVO;
import com.wayn.common.core.mapper.shop.GoodsMapper;
import com.wayn.common.core.service.shop.*;
import com.wayn.common.exception.BusinessException;
import com.wayn.common.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -44,6 +47,9 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
@Autowired
private ICategoryService iCategoryService;
@Autowired
private BaseElasticService baseElasticService;
@Override
public IPage<Goods> listPage(Page<Goods> page, Goods goods) {
return goodsMapper.selectGoodsListPage(page, goods);
@ -109,7 +115,12 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
goodsProduct.setCreateTime(new Date());
}
// 判断启用默认选中的规格是否超过一个
if (Arrays.stream(products).filter(GoodsProduct::getDefaultSelected).count() > 1) {
if (Arrays.stream(products).filter(goodsProduct -> {
if (goodsProduct.getDefaultSelected() == null) {
return false;
}
return goodsProduct.getDefaultSelected();
}).count() > 1) {
return R.error("商品规格只能选择一个启用默认选中");
}
@ -119,6 +130,22 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
iGoodsAttributeService.saveBatch(Arrays.asList(attributes));
// 保存商品货品
iGoodsProductService.saveBatch(Arrays.asList(products));
// 同步es
ElasticEntity elasticEntity = new ElasticEntity();
elasticEntity.setId(goods.getId().toString());
Map<String, Object> map = new HashMap<>();
map.put("id", goods.getId());
map.put("name", goods.getName());
map.put("countPrice", goods.getCounterPrice());
map.put("retailPrice", goods.getRetailPrice());
map.put("keyword", goods.getKeywords());
map.put("isOnSale", goods.getIsOnSale());
elasticEntity.setData(map);
boolean one = baseElasticService.insertOrUpdateOne(SysConstants.GOODS_INDEX, elasticEntity);
if (!one) {
throw new BusinessException("创建商品同步es失败");
}
return R.success();
}
@ -139,6 +166,11 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
iGoodsSpecificationService.remove(new QueryWrapper<GoodsSpecification>().eq("goods_id", goodsId));
iGoodsAttributeService.remove(new QueryWrapper<GoodsAttribute>().eq("goods_id", goodsId));
iGoodsProductService.remove(new QueryWrapper<GoodsProduct>().eq("goods_id", goodsId));
// 同步es
boolean one = baseElasticService.delete(SysConstants.GOODS_INDEX, goodsId.toString());
if (!one) {
throw new BusinessException("删除商品同步es失败");
}
return true;
}
@ -195,6 +227,21 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
iGoodsAttributeService.saveBatch(insertAttributes);
// 更新商品货品
iGoodsProductService.updateBatchById(Arrays.asList(products));
// 同步es
ElasticEntity elasticEntity = new ElasticEntity();
elasticEntity.setId(goods.getId().toString());
Map<String, Object> map = new HashMap<>();
map.put("id", goods.getId());
map.put("name", goods.getName());
map.put("countPrice", goods.getCounterPrice());
map.put("retailPrice", goods.getRetailPrice());
map.put("keyword", goods.getKeywords());
map.put("isOnSale", goods.getIsOnSale());
elasticEntity.setData(map);
boolean one = baseElasticService.insertOrUpdateOne(SysConstants.GOODS_INDEX, elasticEntity);
if (!one) {
throw new BusinessException("创建商品同步es失败");
}
return R.success();
}

@ -1,7 +1,7 @@
package com.wayn.common.util;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.wayn.common.base.BaseEntity;
import com.wayn.common.base.entity.BaseEntity;
import org.apache.commons.lang3.StringUtils;
import java.lang.reflect.Field;

@ -56,6 +56,20 @@
<groupId>com.wayn</groupId>
<artifactId>waynboot-common</artifactId>
<version>0.0.1-SNAPSHOT</version>
<exclusions>
<exclusion>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
</exclusion>
<exclusion>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-client</artifactId>
</exclusion>
<exclusion>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-high-level-client</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>

@ -2,7 +2,7 @@ package com.wayn.mobile.api.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.wayn.common.base.BaseController;
import com.wayn.common.base.controller.BaseController;
import com.wayn.common.util.R;
import com.wayn.mobile.api.domain.Cart;
import com.wayn.mobile.api.service.ICartService;

@ -2,7 +2,7 @@ package com.wayn.mobile.api.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wayn.common.base.BaseController;
import com.wayn.common.base.controller.BaseController;
import com.wayn.common.core.domain.shop.Category;
import com.wayn.common.core.domain.shop.Goods;
import com.wayn.common.core.domain.vo.VanTreeSelectVo;

@ -1,7 +1,7 @@
package com.wayn.mobile.api.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wayn.common.base.BaseController;
import com.wayn.common.base.controller.BaseController;
import com.wayn.common.core.domain.shop.Goods;
import com.wayn.common.util.R;
import com.wayn.mobile.api.service.IHomeService;

@ -2,7 +2,7 @@ package com.wayn.mobile.api.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wayn.common.base.BaseController;
import com.wayn.common.base.controller.BaseController;
import com.wayn.common.core.domain.shop.Order;
import com.wayn.common.core.domain.vo.OrderVO;
import com.wayn.common.util.R;

@ -1,7 +1,7 @@
package com.wayn.mobile.api.controller;
import com.wayn.common.base.BaseController;
import com.wayn.common.base.controller.BaseController;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@ -3,7 +3,7 @@ package com.wayn.mobile.api.controller;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wayn.common.base.BaseController;
import com.wayn.common.base.controller.BaseController;
import com.wayn.common.core.domain.shop.Goods;
import com.wayn.common.core.domain.vo.SearchVO;
import com.wayn.common.core.service.shop.IGoodsService;

@ -2,7 +2,7 @@ package com.wayn.mobile.api.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.wayn.common.base.BaseController;
import com.wayn.common.base.controller.BaseController;
import com.wayn.common.util.R;
import com.wayn.mobile.api.domain.SearchHistory;
import com.wayn.mobile.api.service.ISearchHistoryService;

@ -1,7 +1,7 @@
package com.wayn.mobile.api.controller;
import com.wayn.common.base.BaseController;
import com.wayn.common.base.controller.BaseController;
import com.wayn.common.util.R;
import com.wayn.mobile.api.service.ISeckillService;
import org.springframework.beans.factory.annotation.Autowired;

@ -1,7 +1,7 @@
package com.wayn.mobile.framework.manager.service;
import com.alibaba.fastjson.JSON;
import com.wayn.common.base.ElasticEntity;
import com.wayn.common.base.entity.ElasticEntity;
import lombok.extern.slf4j.Slf4j;
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest;
import org.elasticsearch.action.bulk.BulkRequest;

Loading…
Cancel
Save