✨ 保存属性分组
This commit is contained in:
parent
8a7844fcd8
commit
f95331541b
|
@ -48,8 +48,8 @@ public class AttrController {
|
||||||
|
|
||||||
@Operation(summary = "添加商品属性", description = "添加商品属性")
|
@Operation(summary = "添加商品属性", description = "添加商品属性")
|
||||||
@PostMapping()
|
@PostMapping()
|
||||||
public Result<String> addAttr(@Valid @RequestBody AttrDto dto) {
|
public Result<String> saveAttr(@Valid @RequestBody AttrDto dto) {
|
||||||
attrService.addAttr(dto);
|
attrService.saveAttr(dto);
|
||||||
return Result.success(ResultCodeEnum.ADD_SUCCESS);
|
return Result.success(ResultCodeEnum.ADD_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,4 +43,7 @@ public class AttrDto {
|
||||||
@Schema(name = "showDesc", title = "快速展示【是否展示在介绍上;0-否 1-是】,在sku中仍然可以调整")
|
@Schema(name = "showDesc", title = "快速展示【是否展示在介绍上;0-否 1-是】,在sku中仍然可以调整")
|
||||||
private Integer showDesc;
|
private Integer showDesc;
|
||||||
|
|
||||||
|
@Schema(name = "attrGroupId", title = "属性分组id")
|
||||||
|
private Long attrGroupId;
|
||||||
|
|
||||||
}
|
}
|
|
@ -31,7 +31,7 @@ public interface AttrService extends IService<AttrEntity> {
|
||||||
*
|
*
|
||||||
* @param dto {@link AttrDto} 添加表单
|
* @param dto {@link AttrDto} 添加表单
|
||||||
*/
|
*/
|
||||||
void addAttr(AttrDto dto);
|
void saveAttr(AttrDto dto);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新商品属性
|
* 更新商品属性
|
||||||
|
|
|
@ -5,10 +5,13 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.mall.common.domain.vo.result.PageResult;
|
import com.mall.common.domain.vo.result.PageResult;
|
||||||
import com.mall.product.domain.dto.AttrDto;
|
import com.mall.product.domain.dto.AttrDto;
|
||||||
|
import com.mall.product.domain.entity.AttrAttrgroupRelationEntity;
|
||||||
import com.mall.product.domain.entity.AttrEntity;
|
import com.mall.product.domain.entity.AttrEntity;
|
||||||
import com.mall.product.domain.vo.AttrVo;
|
import com.mall.product.domain.vo.AttrVo;
|
||||||
|
import com.mall.product.mapper.AttrAttrgroupRelationMapper;
|
||||||
import com.mall.product.mapper.AttrMapper;
|
import com.mall.product.mapper.AttrMapper;
|
||||||
import com.mall.product.service.AttrService;
|
import com.mall.product.service.AttrService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
@ -25,8 +28,11 @@ import java.util.List;
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
@Transactional
|
@Transactional
|
||||||
|
@RequiredArgsConstructor
|
||||||
public class AttrServiceImpl extends ServiceImpl<AttrMapper, AttrEntity> implements AttrService {
|
public class AttrServiceImpl extends ServiceImpl<AttrMapper, AttrEntity> implements AttrService {
|
||||||
|
|
||||||
|
private final AttrAttrgroupRelationMapper attrAttrgroupRelationMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* * 商品属性 服务实现类
|
* * 商品属性 服务实现类
|
||||||
*
|
*
|
||||||
|
@ -52,10 +58,17 @@ public class AttrServiceImpl extends ServiceImpl<AttrMapper, AttrEntity> impleme
|
||||||
* @param dto 商品属性添加
|
* @param dto 商品属性添加
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void addAttr(AttrDto dto) {
|
public void saveAttr(AttrDto dto) {
|
||||||
AttrEntity attrEntity = new AttrEntity();
|
AttrEntity attrEntity = new AttrEntity();
|
||||||
BeanUtils.copyProperties(dto, attrEntity);
|
BeanUtils.copyProperties(dto, attrEntity);
|
||||||
|
|
||||||
|
// 保存基本数据
|
||||||
save(attrEntity);
|
save(attrEntity);
|
||||||
|
|
||||||
|
// 保存关联关系
|
||||||
|
AttrAttrgroupRelationEntity attrAttrgroupRelationEntity = new AttrAttrgroupRelationEntity();
|
||||||
|
attrAttrgroupRelationEntity.setAttrGroupId(dto.getAttrGroupId());
|
||||||
|
attrAttrgroupRelationMapper.insert(attrAttrgroupRelationEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue