添加产品分类接口

This commit is contained in:
zhh
2018-04-17 17:32:49 +08:00
parent 0ccc58178e
commit 569508e96f
10 changed files with 323 additions and 9 deletions

View File

@@ -3,6 +3,7 @@ package com.macro.mall.controller;
import com.macro.mall.dto.CommonResult;
import com.macro.mall.dto.PmsBrandParam;
import com.macro.mall.service.PmsBrandService;
import com.macro.mall.validator.FlagValidator;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
@@ -90,7 +91,7 @@ public class PmsBrandController {
@ResponseBody
public Object listBrand(@RequestParam(value = "keyword", required = false) String keyword,
@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
@RequestParam(value = "pageSize", defaultValue = "3") Integer pageSize) {
@RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize) {
return new CommonResult().pageSuccess(brandService.listBrand(keyword, pageNum, pageSize));
}
@@ -118,7 +119,8 @@ public class PmsBrandController {
@ApiOperation(value = "批量更新显示状态")
@RequestMapping(value = "/update/showStatus", method = RequestMethod.POST)
@ResponseBody
public Object updateShowStatus(@RequestParam("ids") List<Long> ids, @RequestParam("showStatus") Integer showStatus) {
public Object updateShowStatus(@RequestParam("ids") List<Long> ids,
@RequestParam("showStatus") Integer showStatus) {
int count = brandService.updateShowStatus(ids, showStatus);
if (count > 0) {
LOGGER.debug("updateShowStatus success:ids={}", ids);
@@ -132,7 +134,8 @@ public class PmsBrandController {
@ApiOperation(value = "批量更新厂家制造商状态")
@RequestMapping(value = "/update/factoryStatus", method = RequestMethod.GET)
@ResponseBody
public Object updateFactoryStatus(@RequestParam("ids") List<Long> ids, @RequestParam("factoryStatus") Integer factoryStatus) {
public Object updateFactoryStatus(@RequestParam("ids") List<Long> ids,
@RequestParam("factoryStatus") Integer factoryStatus) {
int count = brandService.updateFactoryStatus(ids, factoryStatus);
if (count > 0) {
LOGGER.debug("updateFactoryStatus success:{}", ids);

View File

@@ -0,0 +1,88 @@
package com.macro.mall.controller;
import com.macro.mall.dto.CommonResult;
import com.macro.mall.dto.PmsProductCategoryParam;
import com.macro.mall.model.PmsProductCategory;
import com.macro.mall.service.PmsProductCategoryService;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 商品分类模块Controller
*/
@Controller
@RequestMapping("/productCategory")
public class PmsProductCategoryController {
private static final Logger LOGGER = LoggerFactory.getLogger(PmsProductCategoryController.class);
@Autowired
private PmsProductCategoryService productCategoryService;
@ApiOperation("添加产品分类")
@RequestMapping(value = "/create", method = RequestMethod.POST)
@ResponseBody
public Object create(@Validated @RequestBody PmsProductCategoryParam pmsProductCategoryParam, BindingResult result) {
if (result.hasErrors()) {
return new CommonResult().validateFailed(result);
}
int count = productCategoryService.create(pmsProductCategoryParam);
if (count > 0) {
LOGGER.debug("create success {}", pmsProductCategoryParam);
return new CommonResult().success(count);
} else {
LOGGER.debug("create failed {}", pmsProductCategoryParam);
return new CommonResult().failed();
}
}
@ApiOperation("修改商品分类")
@RequestMapping(value = "/update/{id}", method = RequestMethod.POST)
@ResponseBody
public Object update(@PathVariable Long id,
@Validated
@RequestBody PmsProductCategoryParam pmsProductCategoryParam,
BindingResult result) {
if (result.hasErrors()) {
return new CommonResult().validateFailed(result);
}
int count = productCategoryService.update(id, pmsProductCategoryParam);
if (count > 0) {
LOGGER.debug("update success {}", pmsProductCategoryParam);
return new CommonResult().success(count);
} else {
LOGGER.debug("update failed {}", pmsProductCategoryParam);
return new CommonResult().failed();
}
}
@ApiOperation("分页查询商品分类")
@RequestMapping(value = "/list/{parentId}", method = RequestMethod.GET)
@ResponseBody
public Object list(@PathVariable Long parentId,
@RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize,
@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum) {
List<PmsProductCategory> productCategoryList = productCategoryService.list(parentId, pageSize, pageNum);
return new CommonResult().pageSuccess(productCategoryList);
}
@ApiOperation("删除商品分类")
@RequestMapping(value = "/delete/{id}", method = RequestMethod.POST)
@ResponseBody
public Object delete(@PathVariable Long id) {
int count = productCategoryService.delete(id);
if (count > 0) {
LOGGER.debug("delete success id:{}", id);
return new CommonResult().success(count);
} else {
LOGGER.debug("delete failed id:{}", id);
return new CommonResult().failed();
}
}
}

View File

@@ -0,0 +1,12 @@
package com.macro.mall.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
/**
* 商品管理Controller
*/
@Controller
@RequestMapping("/product")
public class PmsProductController {
}