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