商品分类添加修改无效

This commit is contained in:
xuwenbo
2020-05-18 18:53:02 +08:00
parent 3c89dfcc5a
commit 34a1a4ad1f
5 changed files with 37 additions and 7 deletions

View File

@ -7,6 +7,7 @@
* 一经发现盗用、分享等行为,将追究法律责任,后果自负
*/
package co.yixiang.modules.shop.domain;
import co.yixiang.annotation.Query;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
@ -167,6 +168,9 @@ public class YxStoreProduct implements Serializable {
/** 淘宝京东1688类型 */
private String soureLink;
@TableField(exist = false)
private YxStoreCategory storeCategory;
public void copy(YxStoreProduct source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));

View File

@ -63,7 +63,7 @@ public class StoreProductController {
resources.setAddTime(OrderUtil.getSecondTimestampTwo());
if(ObjectUtil.isEmpty(resources.getGiveIntegral())) resources.setGiveIntegral(BigDecimal.ZERO);
if(ObjectUtil.isEmpty(resources.getCost())) resources.setCost(BigDecimal.ZERO);
return new ResponseEntity(yxStoreProductService.save(resources),HttpStatus.CREATED);
return new ResponseEntity(yxStoreProductService.saveProduct(resources),HttpStatus.CREATED);
}
@Log("修改商品")
@ -73,7 +73,7 @@ public class StoreProductController {
@PreAuthorize("@el.check('admin','YXSTOREPRODUCT_ALL','YXSTOREPRODUCT_EDIT')")
public ResponseEntity update(@Validated @RequestBody YxStoreProduct resources){
//if(StrUtil.isNotEmpty("22")) throw new BadRequestException("演示环境禁止操作");
yxStoreProductService.saveOrUpdate(resources);
yxStoreProductService.updateProduct(resources);
return new ResponseEntity(HttpStatus.NO_CONTENT);
}

View File

@ -47,6 +47,8 @@ public interface YxStoreProductService extends BaseService<YxStoreProduct>{
*/
void download(List<YxStoreProductDto> all, HttpServletResponse response) throws IOException;
YxStoreProduct saveProduct(YxStoreProduct storeProduct);
void recovery(Integer id);
void onSale(Integer id, int status);
@ -60,4 +62,6 @@ public interface YxStoreProductService extends BaseService<YxStoreProduct>{
void setResult(Map<String, Object> map,Integer id);
String getStoreProductAttrResult(Integer id);
void updateProduct(YxStoreProduct resources);
}

View File

@ -126,4 +126,6 @@ public class YxStoreProductDto implements Serializable {
/** 淘宝京东1688类型 */
private String soureLink;
private YxStoreCategorySmallDto storeCategory;
}

View File

@ -17,9 +17,7 @@ import co.yixiang.common.service.impl.BaseServiceImpl;
import co.yixiang.modules.shop.domain.YxStoreProductAttr;
import co.yixiang.modules.shop.domain.YxStoreProductAttrResult;
import co.yixiang.modules.shop.domain.YxStoreProductAttrValue;
import co.yixiang.modules.shop.service.YxStoreProductAttrResultService;
import co.yixiang.modules.shop.service.YxStoreProductAttrService;
import co.yixiang.modules.shop.service.YxStoreProductAttrValueService;
import co.yixiang.modules.shop.service.*;
import co.yixiang.modules.shop.service.dto.*;
import co.yixiang.utils.*;
import com.alibaba.fastjson.JSON;
@ -29,8 +27,8 @@ import lombok.AllArgsConstructor;
import co.yixiang.dozer.service.IGenerator;
import com.github.pagehelper.PageInfo;
import co.yixiang.common.utils.QueryHelpPlus;
import co.yixiang.modules.shop.service.YxStoreProductService;
import co.yixiang.modules.shop.service.mapper.StoreProductMapper;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
@ -60,6 +58,8 @@ public class YxStoreProductServiceImpl extends BaseServiceImpl<StoreProductMappe
private final StoreProductMapper storeProductMapper;
private final YxStoreCategoryService yxStoreCategoryService;
private final YxStoreProductAttrService yxStoreProductAttrService;
private final YxStoreProductAttrValueService yxStoreProductAttrValueService;
@ -80,7 +80,14 @@ public class YxStoreProductServiceImpl extends BaseServiceImpl<StoreProductMappe
@Override
//@Cacheable
public List<YxStoreProduct> queryAll(YxStoreProductQueryCriteria criteria){
return baseMapper.selectList(QueryHelpPlus.getPredicate(YxStoreProduct.class, criteria));
List<YxStoreProduct> yxStoreProductList = baseMapper.selectList(QueryHelpPlus.getPredicate(YxStoreProduct.class, criteria));
List<YxStoreProduct> storeProductList = yxStoreProductList.stream().map(i ->{
YxStoreProduct yxStoreProduct = new YxStoreProduct();
BeanUtils.copyProperties(i,yxStoreProduct);
yxStoreProduct.setStoreCategory(yxStoreCategoryService.getById(i.getCateId()));
return yxStoreProduct;
}).collect(Collectors.toList());
return storeProductList;
}
@ -129,6 +136,13 @@ public class YxStoreProductServiceImpl extends BaseServiceImpl<StoreProductMappe
FileUtil.downloadExcel(list, response);
}
@Override
public YxStoreProduct saveProduct(YxStoreProduct storeProduct) {
storeProduct.setCateId(storeProduct.getStoreCategory().getId().toString());
this.save(storeProduct);
return storeProduct;
}
@Override
public void recovery(Integer id) {
storeProductMapper.updateDel(0,id);
@ -250,6 +264,12 @@ public class YxStoreProductServiceImpl extends BaseServiceImpl<StoreProductMappe
return yxStoreProductAttrResult.getResult();
}
@Override
public void updateProduct(YxStoreProduct resources) {
resources.setCateId(resources.getStoreCategory().getId().toString());
this.saveOrUpdate(resources);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void clearProductAttr(Integer id,boolean isActice) {