结构调整
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
package com.macro.mall.controller;
|
||||
|
||||
import com.macro.mall.dto.CommonResult;
|
||||
import com.macro.mall.dto.PmsBrandDto;
|
||||
import com.macro.mall.dto.PmsBrandParam;
|
||||
import com.macro.mall.service.PmsBrandService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -16,6 +17,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
* 品牌功能Controller
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/brand")
|
||||
public class PmsBrandController {
|
||||
@Autowired
|
||||
private PmsBrandService brandService;
|
||||
@@ -23,16 +25,16 @@ public class PmsBrandController {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(PmsBrandController.class);
|
||||
|
||||
@ApiOperation(value = "获取全部品牌列表")
|
||||
@RequestMapping(value = "/brand/listAll", method = RequestMethod.GET)
|
||||
@RequestMapping(value = "/listAll", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public Object getBrandList() {
|
||||
return new CommonResult().success(brandService.listAllBrand());
|
||||
}
|
||||
|
||||
@ApiOperation(value = "添加品牌")
|
||||
@RequestMapping(value = "/brand/create", method = RequestMethod.POST)
|
||||
@RequestMapping(value = "/create", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public Object createBrand(@Validated @RequestBody PmsBrandDto pmsBrand, BindingResult result) {
|
||||
public Object createBrand(@Validated @RequestBody PmsBrandParam pmsBrand, BindingResult result) {
|
||||
if (result.hasErrors()) {
|
||||
return new CommonResult().validateFailed(result.getFieldError().getDefaultMessage());
|
||||
}
|
||||
@@ -49,26 +51,26 @@ public class PmsBrandController {
|
||||
}
|
||||
|
||||
@ApiOperation(value = "更新品牌")
|
||||
@RequestMapping(value = "/brand/update/{id}", method = RequestMethod.POST)
|
||||
@RequestMapping(value = "/update/{id}", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public Object updateBrand(@PathVariable("id") Long id, @Validated @RequestBody PmsBrandDto pmsBrandDto, BindingResult result) {
|
||||
public Object updateBrand(@PathVariable("id") Long id, @Validated @RequestBody PmsBrandParam pmsBrandParam, BindingResult result) {
|
||||
if(result.hasErrors()){
|
||||
return new CommonResult().validateFailed(result.getFieldError().getDefaultMessage());
|
||||
}
|
||||
CommonResult commonResult;
|
||||
int count = brandService.updateBrand(id, pmsBrandDto);
|
||||
int count = brandService.updateBrand(id, pmsBrandParam);
|
||||
if (count == 1) {
|
||||
commonResult = new CommonResult().success(pmsBrandDto);
|
||||
LOGGER.debug("updateBrand success:{}", pmsBrandDto);
|
||||
commonResult = new CommonResult().success(pmsBrandParam);
|
||||
LOGGER.debug("updateBrand success:{}", pmsBrandParam);
|
||||
} else {
|
||||
commonResult = new CommonResult().failed();
|
||||
LOGGER.debug("updateBrand failed:{}", pmsBrandDto);
|
||||
LOGGER.debug("updateBrand failed:{}", pmsBrandParam);
|
||||
}
|
||||
return commonResult;
|
||||
}
|
||||
|
||||
@ApiOperation(value = "删除品牌")
|
||||
@RequestMapping(value = "/brand/delete/{id}", method = RequestMethod.GET)
|
||||
@RequestMapping(value = "/delete/{id}", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public Object deleteBrand(@PathVariable("id") Long id) {
|
||||
int count = brandService.deleteBrand(id);
|
||||
@@ -82,7 +84,7 @@ public class PmsBrandController {
|
||||
}
|
||||
|
||||
@ApiOperation(value = "分页获取品牌列表")
|
||||
@RequestMapping(value = "/brand/list", method = RequestMethod.GET)
|
||||
@RequestMapping(value = "/list", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public Object listBrand(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
|
||||
@RequestParam(value = "pageSize", defaultValue = "3") Integer pageSize) {
|
||||
@@ -90,7 +92,7 @@ public class PmsBrandController {
|
||||
}
|
||||
|
||||
@ApiOperation(value = "根据编号查询品牌信息")
|
||||
@RequestMapping(value = "/brand/{id}", method = RequestMethod.GET)
|
||||
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public Object getBrand(@PathVariable("id") Long id) {
|
||||
return new CommonResult().success(brandService.getBrand(id));
|
||||
|
||||
@@ -10,8 +10,8 @@ import javax.validation.constraints.NotNull;
|
||||
/**
|
||||
* 品牌传递参数
|
||||
*/
|
||||
@ApiModel(value = "PmsBrandDto")
|
||||
public class PmsBrandDto {
|
||||
@ApiModel(value = "PmsBrandParam")
|
||||
public class PmsBrandParam {
|
||||
@ApiModelProperty(value = "品牌名称",required = true)
|
||||
@NotNull(message = "名称不能为空")
|
||||
private String name;
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.macro.mall.service;
|
||||
|
||||
import com.macro.mall.dto.PmsBrandDto;
|
||||
import com.macro.mall.dto.PmsBrandParam;
|
||||
import com.macro.mall.model.PmsBrand;
|
||||
|
||||
import java.util.List;
|
||||
@@ -11,9 +11,9 @@ import java.util.List;
|
||||
public interface PmsBrandService {
|
||||
List<PmsBrand> listAllBrand();
|
||||
|
||||
int createBrand(PmsBrandDto pmsBrandDto);
|
||||
int createBrand(PmsBrandParam pmsBrandParam);
|
||||
|
||||
int updateBrand(Long id, PmsBrandDto pmsBrandDto);
|
||||
int updateBrand(Long id, PmsBrandParam pmsBrandParam);
|
||||
|
||||
int deleteBrand(Long id);
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.macro.mall.service.impl;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.macro.mall.dto.PmsBrandDto;
|
||||
import com.macro.mall.dto.PmsBrandParam;
|
||||
import com.macro.mall.mapper.PmsBrandMapper;
|
||||
import com.macro.mall.model.PmsBrand;
|
||||
import com.macro.mall.model.PmsBrandExample;
|
||||
@@ -26,16 +26,16 @@ public class PmsBrandServiceImpl implements PmsBrandService{
|
||||
}
|
||||
|
||||
@Override
|
||||
public int createBrand(PmsBrandDto pmsBrandDto) {
|
||||
public int createBrand(PmsBrandParam pmsBrandParam) {
|
||||
PmsBrand pmsBrand = new PmsBrand();
|
||||
BeanUtils.copyProperties(pmsBrandDto,pmsBrand);
|
||||
BeanUtils.copyProperties(pmsBrandParam,pmsBrand);
|
||||
return brandMapper.insertSelective(pmsBrand);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateBrand(Long id, PmsBrandDto pmsBrandDto) {
|
||||
public int updateBrand(Long id, PmsBrandParam pmsBrandParam) {
|
||||
PmsBrand pmsBrand = new PmsBrand();
|
||||
BeanUtils.copyProperties(pmsBrandDto,pmsBrand);
|
||||
BeanUtils.copyProperties(pmsBrandParam,pmsBrand);
|
||||
pmsBrand.setId(id);
|
||||
return brandMapper.updateByPrimaryKeySelective(pmsBrand);
|
||||
}
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
<!DOCTYPE web-app PUBLIC
|
||||
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
|
||||
"http://java.sun.com/dtd/web-app_2_3.dtd" >
|
||||
|
||||
<web-app>
|
||||
<display-name>Archetype Created Web Application</display-name>
|
||||
</web-app>
|
||||
@@ -1,5 +0,0 @@
|
||||
<html>
|
||||
<body>
|
||||
<h2>Hello World!</h2>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user