|
|
|
@ -9,6 +9,8 @@
|
|
|
|
|
package co.yixiang.modules.product.rest; |
|
|
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
|
|
import cn.iocoder.yudao.framework.common.exception.YshopException; |
|
|
|
|
import co.yixiang.constant.ShopConstants; |
|
|
|
|
import co.yixiang.dozer.service.IGenerator; |
|
|
|
|
import co.yixiang.enums.ShopCommonEnum; |
|
|
|
@ -17,9 +19,14 @@ import co.yixiang.logging.aop.log.Log;
|
|
|
|
|
import co.yixiang.modules.aop.ForbidSubmit; |
|
|
|
|
import co.yixiang.modules.category.domain.YxStoreCategory; |
|
|
|
|
import co.yixiang.modules.category.service.YxStoreCategoryService; |
|
|
|
|
import co.yixiang.modules.evaluation.domain.YxEvaluation; |
|
|
|
|
import co.yixiang.modules.evaluation.service.mapper.YxEvaluationMapper; |
|
|
|
|
import co.yixiang.modules.hotList.domain.YxStoreHotList; |
|
|
|
|
import co.yixiang.modules.hotList.service.mapper.YxStoreHotListMapper; |
|
|
|
|
import co.yixiang.modules.product.domain.YxStoreProduct; |
|
|
|
|
import co.yixiang.modules.product.domain.YxStoreProductAttrResult; |
|
|
|
|
import co.yixiang.modules.product.domain.YxStoreProductAttrValue; |
|
|
|
|
import co.yixiang.modules.product.domain.YxStoreProductRelation; |
|
|
|
|
import co.yixiang.modules.product.service.YxStoreProductAttrResultService; |
|
|
|
|
import co.yixiang.modules.product.service.YxStoreProductAttrValueService; |
|
|
|
|
import co.yixiang.modules.product.service.YxStoreProductRuleService; |
|
|
|
@ -37,6 +44,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
|
|
import io.swagger.annotations.Api; |
|
|
|
|
import io.swagger.annotations.ApiOperation; |
|
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
import org.springframework.cache.annotation.CacheEvict; |
|
|
|
|
import org.springframework.data.domain.Pageable; |
|
|
|
|
import org.springframework.http.HttpStatus; |
|
|
|
@ -63,6 +71,10 @@ import java.util.stream.Collectors;
|
|
|
|
|
@RequestMapping("api") |
|
|
|
|
public class StoreProductController { |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
private YxStoreHotListMapper yxStoreHotListMapper; |
|
|
|
|
@Autowired |
|
|
|
|
private YxEvaluationMapper yxEvaluationMapper; |
|
|
|
|
private final YxStoreProductService yxStoreProductService; |
|
|
|
|
private final YxStoreCategoryService yxStoreCategoryService; |
|
|
|
|
private final YxShippingTemplatesService yxShippingTemplatesService; |
|
|
|
@ -120,6 +132,24 @@ public class StoreProductController {
|
|
|
|
|
@PreAuthorize("@ss.hasAnyPermissions('admin','YXSTOREPRODUCT_ALL','YXSTOREPRODUCT_DELETE')") |
|
|
|
|
public ResponseEntity delete(@PathVariable Long id){ |
|
|
|
|
//这里增加评测/热榜判断
|
|
|
|
|
Long count = yxEvaluationMapper |
|
|
|
|
.selectCount(Wrappers.<YxEvaluation>lambdaQuery() |
|
|
|
|
.eq(YxEvaluation::getIsShow,1) |
|
|
|
|
.eq(YxEvaluation::getProduct,id)); |
|
|
|
|
//此商品关联有评测
|
|
|
|
|
if(count > 0) { |
|
|
|
|
//不能删除
|
|
|
|
|
throw new YshopException("当前商品已绑定评测,不能被删除"); |
|
|
|
|
} |
|
|
|
|
Long count1 = yxStoreHotListMapper |
|
|
|
|
.selectCount(Wrappers.<YxStoreHotList>lambdaQuery() |
|
|
|
|
.eq(YxStoreHotList::getIsShow,1) |
|
|
|
|
.like(YxStoreHotList::getProductList,id)); |
|
|
|
|
//此商品被热门榜单绑定,不能删除
|
|
|
|
|
if(count1 > 0) { |
|
|
|
|
//不能删除
|
|
|
|
|
throw new YshopException("当前商品已绑定热门榜单,不能被删除"); |
|
|
|
|
} |
|
|
|
|
yxStoreProductService.removeById(id); |
|
|
|
|
return new ResponseEntity(HttpStatus.OK); |
|
|
|
|
} |
|
|
|
@ -130,6 +160,7 @@ public class StoreProductController {
|
|
|
|
|
@CacheEvict(cacheNames = ShopConstants.ZSW_REDIS_INDEX_KEY,allEntries = true) |
|
|
|
|
@PostMapping(value = "/yxStoreProduct/onsale/{id}") |
|
|
|
|
public ResponseEntity onSale(@PathVariable Long id,@RequestBody String jsonStr){ |
|
|
|
|
|
|
|
|
|
JSONObject jsonObject = JSON.parseObject(jsonStr); |
|
|
|
|
Integer status = jsonObject.getInteger("status"); |
|
|
|
|
yxStoreProductService.onSale(id,status); |
|
|
|
|