规格代码相关改版
This commit is contained in:
@@ -1,21 +1,16 @@
|
||||
package cn.lili.controller.goods;
|
||||
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.enums.ResultUtil;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.goods.entity.dos.CategorySpecification;
|
||||
import cn.lili.modules.goods.entity.vos.CategorySpecificationVO;
|
||||
import cn.lili.modules.goods.entity.vos.GoodsSpecValueVO;
|
||||
import cn.lili.modules.goods.entity.dos.Specification;
|
||||
import cn.lili.modules.goods.service.CategorySpecificationService;
|
||||
import cn.lili.modules.goods.service.SpecificationService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -32,40 +27,14 @@ import java.util.List;
|
||||
public class CategorySpecificationStoreController {
|
||||
@Autowired
|
||||
private CategorySpecificationService categorySpecificationService;
|
||||
@Autowired
|
||||
private SpecificationService specificationService;
|
||||
|
||||
|
||||
@ApiOperation(value = "查询某分类下绑定的规格信息")
|
||||
@GetMapping(value = "/{category_id}")
|
||||
@ApiImplicitParam(name = "category_id", value = "分类id", required = true, dataType = "String", paramType = "path")
|
||||
public List<CategorySpecificationVO> getCategorySpec(@PathVariable("category_id") String categoryId) {
|
||||
public List<Specification> getCategorySpec(@PathVariable("category_id") String categoryId) {
|
||||
return categorySpecificationService.getCategorySpecList(categoryId);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "查询某分类下绑定的规格信息,商品操作使用")
|
||||
@GetMapping(value = "/goods/{category_id}")
|
||||
@ApiImplicitParam(name = "category_id", value = "分类id", required = true, dataType = "String", paramType = "path")
|
||||
public List<GoodsSpecValueVO> getSpec(@PathVariable("category_id") String categoryId) {
|
||||
return specificationService.getGoodsSpecValue(categoryId);
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation(value = "保存某分类下绑定的规格信息")
|
||||
@PostMapping(value = "/{category_id}")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "category_id", value = "分类id", required = true, paramType = "path", dataType = "String"),
|
||||
@ApiImplicitParam(name = "category_specs", value = "规格id数组", required = true, paramType = "query", dataType = "String[]")
|
||||
})
|
||||
public ResultMessage<Object> saveCategoryBrand(@PathVariable("category_id") String categoryId, @RequestParam("category_specs") String[] categorySpecs) {
|
||||
//删除分类规格绑定信息
|
||||
this.categorySpecificationService.remove(new QueryWrapper<CategorySpecification>().eq("category_id", categoryId));
|
||||
//绑定规格信息
|
||||
for (String specId : categorySpecs) {
|
||||
CategorySpecification categoryBrand = new CategorySpecification(categoryId, specId);
|
||||
categorySpecificationService.save(categoryBrand);
|
||||
}
|
||||
return ResultUtil.success();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
package cn.lili.controller.goods;
|
||||
|
||||
|
||||
import cn.lili.common.enums.ResultUtil;
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.goods.entity.dos.SpecValues;
|
||||
import cn.lili.modules.goods.service.SpecValuesService;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 店铺端,规格项管理接口
|
||||
*
|
||||
* @author pikachu
|
||||
* @date 2020-02-18 15:18:56
|
||||
*/
|
||||
@RestController
|
||||
@Api(tags = "店铺端,规格项管理接口")
|
||||
@RequestMapping("/store/goods/spec-values")
|
||||
public class SpecValuesStoreController {
|
||||
@Autowired
|
||||
private SpecValuesService specValuesService;
|
||||
|
||||
@GetMapping(value = "/values/{id}")
|
||||
@ApiImplicitParam(name = "id", value = "规格项ID", required = true, dataType = "String", paramType = "path")
|
||||
@ApiOperation(value = "查询规格值列表")
|
||||
public ResultMessage<IPage<SpecValues>> list(@PathVariable("id") String id, String specVal, PageVO pageVo) {
|
||||
return ResultUtil.data(specValuesService.queryByParams(id, specVal, pageVo));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "保存规格值")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "id", value = "商品规格ID", required = true, paramType = "path"),
|
||||
@ApiImplicitParam(name = "specValue", value = "商品项", required = true, allowMultiple = true, paramType = "query")
|
||||
})
|
||||
@PostMapping(value = "/save/{id}")
|
||||
public ResultMessage<List<SpecValues>> saveSpecValue(@PathVariable("id") String specId,
|
||||
@NotNull(message = "至少添加一个规格值") @RequestParam(value = "spec_value") String[] specValue) {
|
||||
//重新添加
|
||||
List<SpecValues> list = specValuesService.addSpecValue(specId, specValue);
|
||||
return ResultUtil.data(list);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,22 +1,15 @@
|
||||
package cn.lili.controller.goods;
|
||||
|
||||
|
||||
import cn.lili.common.enums.ResultUtil;
|
||||
import cn.lili.common.security.context.UserContext;
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.goods.entity.dos.Specification;
|
||||
import cn.lili.modules.goods.entity.dto.SpecificationSearchParams;
|
||||
import cn.lili.modules.goods.entity.vos.SpecificationVO;
|
||||
import cn.lili.modules.goods.service.SpecificationService;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import cn.lili.modules.goods.service.CategorySpecificationService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -27,35 +20,17 @@ import java.util.List;
|
||||
* @date 2020-02-18 15:18:56
|
||||
*/
|
||||
@RestController
|
||||
@Api(tags = "店铺端,规格管理接口")
|
||||
@Api(tags = "店铺端,规格接口")
|
||||
@RequestMapping("/store/goods/spec")
|
||||
public class SpecificationStoreController {
|
||||
|
||||
@Autowired
|
||||
private SpecificationService specificationService;
|
||||
private CategorySpecificationService categorySpecificationService;
|
||||
|
||||
|
||||
@GetMapping(value = "/page")
|
||||
@ApiOperation(value = "分页获取")
|
||||
public ResultMessage<IPage<Specification>> getByPage(SpecificationSearchParams searchParams, PageVO pageVo) {
|
||||
searchParams.setDeleteFlag(false);
|
||||
return ResultUtil.data(specificationService.getSpecificationByPage(searchParams, pageVo));
|
||||
@GetMapping(value = "/{categoryId}")
|
||||
@ApiOperation(value = "获取分类规格")
|
||||
public List<Specification> getSpecifications(String categoryId) {
|
||||
return categorySpecificationService.getCategorySpecList(categoryId);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@ApiOperation(value = "添加规格")
|
||||
public ResultMessage<Specification> save(@Valid SpecificationVO parameters) {
|
||||
if (parameters.getStoreId() == null) {
|
||||
parameters.setStoreId(UserContext.getCurrentUser().getId());
|
||||
}
|
||||
specificationService.addSpecification(parameters);
|
||||
return ResultUtil.data(parameters);
|
||||
}
|
||||
|
||||
@DeleteMapping(value = "/{ids}")
|
||||
@ApiImplicitParam(name = "ids", value = "规格ID", required = true, dataType = "String", allowMultiple = true, paramType = "path")
|
||||
@ApiOperation(value = "批量删除")
|
||||
public ResultMessage<Object> delAllByIds(@PathVariable List<String> ids) {
|
||||
specificationService.deleteSpecification(ids);
|
||||
return ResultUtil.success();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user