feature(商品添加): 规格调整连带商品调整
parent
15798cea10
commit
e1e55dc841
@ -0,0 +1,70 @@
|
||||
package cn.iocoder.yudao.module.product.controller.admin.property;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.ProductPropertyPageReqVO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueCreateReqVO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValuePageReqVO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueRespVO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.product.service.property.ProductPropertyValueService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@Api(tags = "管理后台 - 规格值名称")
|
||||
@RestController
|
||||
@RequestMapping("/product/property/value")
|
||||
@Validated
|
||||
public class ProductPropertyValueController {
|
||||
|
||||
@Resource
|
||||
private ProductPropertyValueService productPropertyValueService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@ApiOperation("创建规格名称")
|
||||
@PreAuthorize("@ss.hasPermission('product:property:create')")
|
||||
public CommonResult<Long> createProperty(@Valid @RequestBody ProductPropertyValueCreateReqVO createReqVO) {
|
||||
return success(productPropertyValueService.createPropertyValue(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@ApiOperation("更新规格名称")
|
||||
@PreAuthorize("@ss.hasPermission('product:property:update')")
|
||||
public CommonResult<Boolean> updateProperty(@Valid @RequestBody ProductPropertyValueUpdateReqVO updateReqVO) {
|
||||
productPropertyValueService.updatePropertyValue(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@ApiOperation("删除规格名称")
|
||||
@ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Long.class)
|
||||
@PreAuthorize("@ss.hasPermission('product:property:delete')")
|
||||
public CommonResult<Boolean> deleteProperty(@RequestParam("id") Long id) {
|
||||
productPropertyValueService.deletePropertyValue(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@ApiOperation("获得规格名称")
|
||||
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
|
||||
@PreAuthorize("@ss.hasPermission('product:property:query')")
|
||||
public CommonResult<ProductPropertyValueRespVO> getProperty(@RequestParam("id") Long id) {
|
||||
return success(productPropertyValueService.getPropertyValue(id));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@ApiOperation("获得规格名称分页")
|
||||
@PreAuthorize("@ss.hasPermission('product:property:query')")
|
||||
public CommonResult<PageResult<ProductPropertyValueRespVO>> getPropertyValuePage(@Valid ProductPropertyValuePageReqVO pageVO) {
|
||||
return success(productPropertyValueService.getPropertyValueListPage(pageVO));
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
package cn.iocoder.yudao.module.product.controller.admin.property.vo.property;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
|
||||
@ApiModel("管理后台 - 规格名称 List Request VO")
|
||||
@Data
|
||||
@ToString(callSuper = true)
|
||||
public class ProductPropertyListReqVO {
|
||||
|
||||
@ApiModelProperty(value = "规格名称", example = "颜色")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "状态", required = true, example = "1", notes = "参见 CommonStatusEnum 枚举")
|
||||
private Integer status;
|
||||
|
||||
}
|
||||
@ -0,0 +1,24 @@
|
||||
package cn.iocoder.yudao.module.product.controller.admin.property.vo.property;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@ApiModel("管理后台 - 规格 + 规格值 Response VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class ProductPropertyRespVO extends ProductPropertyBaseVO {
|
||||
|
||||
@ApiModelProperty(value = "规格的编号", required = true, example = "1024")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "创建时间", required = true)
|
||||
private Date createTime;
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,31 @@
|
||||
package cn.iocoder.yudao.module.product.controller.admin.property.vo.value;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import java.util.Date;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@ApiModel("管理后台 - 规格名称值分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class ProductPropertyValuePageReqVO extends PageParam {
|
||||
|
||||
@ApiModelProperty(value = "规格id", example = "1024")
|
||||
private String propertyId;
|
||||
|
||||
@ApiModelProperty(value = "规格值", example = "红色")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "状态", required = true, example = "1", notes = "参见 CommonStatusEnum 枚举")
|
||||
private Integer status;
|
||||
|
||||
}
|
||||
@ -0,0 +1,65 @@
|
||||
package cn.iocoder.yudao.module.product.service.property;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueCreateReqVO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValuePageReqVO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueRespVO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueUpdateReqVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* </p>
|
||||
*
|
||||
* @author LuoWenFeng
|
||||
*/
|
||||
public interface ProductPropertyValueService {
|
||||
|
||||
/**
|
||||
* 创建规格值
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createPropertyValue(ProductPropertyValueCreateReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新规格值
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updatePropertyValue(ProductPropertyValueUpdateReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除规格值
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deletePropertyValue(Long id);
|
||||
|
||||
/**
|
||||
* 获得规格值
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 规格名称
|
||||
*/
|
||||
ProductPropertyValueRespVO getPropertyValue(Long id);
|
||||
|
||||
/**
|
||||
* 获得规格值
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 规格名称
|
||||
*/
|
||||
List<ProductPropertyValueRespVO> getPropertyValueListByPropertyId(List<Long> id);
|
||||
|
||||
/**
|
||||
* 获取规格值 分页
|
||||
*
|
||||
* @param pageReqVO 查询条件
|
||||
* @return
|
||||
*/
|
||||
PageResult<ProductPropertyValueRespVO> getPropertyValueListPage(ProductPropertyValuePageReqVO pageReqVO);
|
||||
}
|
||||
@ -0,0 +1,66 @@
|
||||
package cn.iocoder.yudao.module.product.service.property;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueCreateReqVO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValuePageReqVO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueRespVO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.product.convert.propertyvalue.ProductPropertyValueConvert;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyValueDO;
|
||||
import cn.iocoder.yudao.module.product.dal.mysql.property.ProductPropertyValueMapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* </p>
|
||||
*
|
||||
* @author LuoWenFeng
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class ProductPropertyValueServiceImpl implements ProductPropertyValueService {
|
||||
|
||||
@Resource
|
||||
private ProductPropertyValueMapper productPropertyValueMapper;
|
||||
|
||||
@Override
|
||||
public Long createPropertyValue(ProductPropertyValueCreateReqVO createReqVO) {
|
||||
ProductPropertyValueDO convert = ProductPropertyValueConvert.INSTANCE.convert(createReqVO);
|
||||
productPropertyValueMapper.insert(convert);
|
||||
return convert.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updatePropertyValue(ProductPropertyValueUpdateReqVO updateReqVO) {
|
||||
ProductPropertyValueDO convert = ProductPropertyValueConvert.INSTANCE.convert(updateReqVO);
|
||||
productPropertyValueMapper.updateById(convert);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deletePropertyValue(Long id) {
|
||||
productPropertyValueMapper.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProductPropertyValueRespVO getPropertyValue(Long id) {
|
||||
ProductPropertyValueDO productPropertyValueDO = productPropertyValueMapper.selectOne(new LambdaQueryWrapper<ProductPropertyValueDO>()
|
||||
.eq(ProductPropertyValueDO::getId, id));
|
||||
return ProductPropertyValueConvert.INSTANCE.convert(productPropertyValueDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ProductPropertyValueRespVO> getPropertyValueListByPropertyId(List<Long> id) {
|
||||
return ProductPropertyValueConvert.INSTANCE.convertList(productPropertyValueMapper.selectList("property_id", id));
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<ProductPropertyValueRespVO> getPropertyValueListPage(ProductPropertyValuePageReqVO pageReqVO) {
|
||||
return ProductPropertyValueConvert.INSTANCE.convertPage(productPropertyValueMapper.selectPage(pageReqVO));
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue