yshop2.0.2,修复issue#I1B8RB,#I1B49Y,#I1BASM,#I1B9O7,#I1B9ED
This commit is contained in:
@ -13,4 +13,6 @@ public interface YxStoreCategoryRepository extends JpaRepository<YxStoreCategory
|
||||
@Query(value = "select cate_name from yx_store_category where id = ?1",nativeQuery = true)
|
||||
String findNameById(Integer id);
|
||||
|
||||
YxStoreCategory findByPid(Integer pid);
|
||||
|
||||
}
|
@ -6,6 +6,8 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.data.jpa.repository.Modifying;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author hupeng
|
||||
* @date 2019-10-04
|
||||
@ -18,4 +20,6 @@ public interface YxStoreProductRepository extends JpaRepository<YxStoreProduct,
|
||||
@Modifying
|
||||
@Query(value = "update yx_store_product set is_del = ?1 where id = ?2",nativeQuery = true)
|
||||
void updateDel(int status, int id);
|
||||
|
||||
List<YxStoreProduct> findByCateId(String cateId);
|
||||
}
|
@ -87,9 +87,12 @@ public class StoreCategoryController {
|
||||
@ApiOperation(value = "删除商品分类")
|
||||
@DeleteMapping(value = "/yxStoreCategory/{id}")
|
||||
@PreAuthorize("@el.check('admin','YXSTORECATEGORY_ALL','YXSTORECATEGORY_DELETE')")
|
||||
public ResponseEntity delete(@PathVariable Integer id){
|
||||
public ResponseEntity delete(@PathVariable String id){
|
||||
//if(StrUtil.isNotEmpty("22")) throw new BadRequestException("演示环境禁止操作");
|
||||
yxStoreCategoryService.delete(id);
|
||||
String[] ids = id.split(",");
|
||||
for (String newId: ids) {
|
||||
yxStoreCategoryService.delete(Integer.valueOf(newId));
|
||||
}
|
||||
return new ResponseEntity(HttpStatus.OK);
|
||||
}
|
||||
}
|
@ -96,7 +96,6 @@ public class StoreProductController {
|
||||
public ResponseEntity onSale(@PathVariable Integer id,@RequestBody String jsonStr){
|
||||
JSONObject jsonObject = JSON.parseObject(jsonStr);
|
||||
int status = Integer.valueOf(jsonObject.get("status").toString());
|
||||
//System.out.println(status);
|
||||
yxStoreProductService.onSale(id,status);
|
||||
return new ResponseEntity(HttpStatus.OK);
|
||||
}
|
||||
|
@ -1,8 +1,11 @@
|
||||
package co.yixiang.modules.shop.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import co.yixiang.exception.BadRequestException;
|
||||
import co.yixiang.modules.shop.domain.YxStoreCategory;
|
||||
import co.yixiang.modules.shop.domain.YxStoreProduct;
|
||||
import co.yixiang.modules.shop.repository.YxStoreCategoryRepository;
|
||||
import co.yixiang.modules.shop.repository.YxStoreProductRepository;
|
||||
import co.yixiang.modules.shop.service.YxStoreCategoryService;
|
||||
import co.yixiang.modules.shop.service.dto.YxStoreCategoryDTO;
|
||||
import co.yixiang.modules.shop.service.dto.YxStoreCategoryQueryCriteria;
|
||||
@ -31,13 +34,16 @@ import java.util.stream.Collectors;
|
||||
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
|
||||
public class YxStoreCategoryServiceImpl implements YxStoreCategoryService {
|
||||
|
||||
|
||||
private final YxStoreCategoryRepository yxStoreCategoryRepository;
|
||||
private final YxStoreProductRepository yxStoreProductRepository;
|
||||
|
||||
private final YxStoreCategoryMapper yxStoreCategoryMapper;
|
||||
|
||||
public YxStoreCategoryServiceImpl(YxStoreCategoryRepository yxStoreCategoryRepository, YxStoreCategoryMapper yxStoreCategoryMapper) {
|
||||
public YxStoreCategoryServiceImpl(YxStoreCategoryRepository yxStoreCategoryRepository,
|
||||
YxStoreProductRepository yxStoreProductRepository,
|
||||
YxStoreCategoryMapper yxStoreCategoryMapper) {
|
||||
this.yxStoreCategoryRepository = yxStoreCategoryRepository;
|
||||
this.yxStoreProductRepository = yxStoreProductRepository;
|
||||
this.yxStoreCategoryMapper = yxStoreCategoryMapper;
|
||||
}
|
||||
|
||||
@ -92,6 +98,12 @@ public class YxStoreCategoryServiceImpl implements YxStoreCategoryService {
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void delete(Integer id) {
|
||||
YxStoreCategory storeCategory = yxStoreCategoryRepository.findByPid(id);
|
||||
if(storeCategory != null) throw new BadRequestException("请先删除子类");
|
||||
|
||||
List<YxStoreProduct> storeProduct = yxStoreProductRepository.findByCateId(String.valueOf(id));
|
||||
if(!storeProduct.isEmpty()) throw new BadRequestException("此分类下有商品,不能删除");
|
||||
|
||||
yxStoreCategoryRepository.deleteById(id);
|
||||
}
|
||||
|
||||
|
@ -49,10 +49,13 @@ public class YxStoreProductReplyServiceImpl implements YxStoreProductReplyServic
|
||||
,pageable);
|
||||
List<YxStoreProductReplyDTO> productReplyDTOS = new ArrayList<>();
|
||||
for (YxStoreProductReply reply : page.getContent()) {
|
||||
|
||||
YxStoreProductReplyDTO productReplyDTO = yxStoreProductReplyMapper.toDto(reply);
|
||||
productReplyDTO.setUsername(userService.findById(reply.getUid()).getAccount());
|
||||
productReplyDTO.setProductName(productService.findById(reply.getProductId()).getStoreName());
|
||||
try{
|
||||
productReplyDTO.setUsername(userService.findById(reply.getUid()).getAccount());
|
||||
productReplyDTO.setProductName(productService.findById(reply.getProductId()).getStoreName());
|
||||
}catch (Exception e){
|
||||
continue;
|
||||
}
|
||||
productReplyDTOS.add(productReplyDTO);
|
||||
}
|
||||
Map<String,Object> map = new LinkedHashMap<>(2);
|
||||
|
@ -119,6 +119,7 @@ public class YxStoreProductServiceImpl implements YxStoreProductService {
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void recovery(Integer id) {
|
||||
yxStoreProductRepository.updateDel(0,id);
|
||||
yxStoreProductRepository.updateOnsale(0,id);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user