修复主键重名问题
This commit is contained in:
@@ -13,6 +13,8 @@ import org.springframework.validation.BindingResult;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 品牌功能Controller
|
||||
*/
|
||||
@@ -54,7 +56,7 @@ public class PmsBrandController {
|
||||
@RequestMapping(value = "/update/{id}", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public Object updateBrand(@PathVariable("id") Long id, @Validated @RequestBody PmsBrandParam pmsBrandParam, BindingResult result) {
|
||||
if(result.hasErrors()){
|
||||
if (result.hasErrors()) {
|
||||
return new CommonResult().validateFailed(result.getFieldError().getDefaultMessage());
|
||||
}
|
||||
CommonResult commonResult;
|
||||
@@ -75,20 +77,21 @@ public class PmsBrandController {
|
||||
public Object deleteBrand(@PathVariable("id") Long id) {
|
||||
int count = brandService.deleteBrand(id);
|
||||
if (count == 1) {
|
||||
LOGGER.debug("deleteBrand success :id={}", id);
|
||||
LOGGER.debug("deleteBrand success:id={}", id);
|
||||
return new CommonResult().success(null);
|
||||
} else {
|
||||
LOGGER.debug("deleteBrand failed :id={}", id);
|
||||
LOGGER.debug("deleteBrand failed:id={}", id);
|
||||
return new CommonResult().failed();
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation(value = "分页获取品牌列表")
|
||||
@ApiOperation(value = "根据品牌名称分页获取品牌列表")
|
||||
@RequestMapping(value = "/list", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public Object listBrand(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
|
||||
public Object listBrand(@RequestParam(value = "keyword", required = false) String keyword,
|
||||
@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
|
||||
@RequestParam(value = "pageSize", defaultValue = "3") Integer pageSize) {
|
||||
return new CommonResult().pageSuccess(brandService.listBrand(pageNum, pageSize));
|
||||
return new CommonResult().pageSuccess(brandService.listBrand(keyword, pageNum, pageSize));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "根据编号查询品牌信息")
|
||||
@@ -97,4 +100,32 @@ public class PmsBrandController {
|
||||
public Object getBrand(@PathVariable("id") Long id) {
|
||||
return new CommonResult().success(brandService.getBrand(id));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "批量删除品牌")
|
||||
@RequestMapping(value = "/delete/batch", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public Object deleteBrandBatch(@RequestParam("ids") List<Long> ids) {
|
||||
int count = brandService.deleteBrand(ids);
|
||||
if (count > 0) {
|
||||
LOGGER.debug("deleteBrandBatch success:ids={}", ids);
|
||||
return new CommonResult().success(count);
|
||||
} else {
|
||||
LOGGER.debug("deleteBrandBatch failed:ids={}", ids);
|
||||
return new CommonResult().failed();
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation(value = "批量更新显示状态")
|
||||
@RequestMapping(value = "/update/showStatus", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
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);
|
||||
return new CommonResult().success(count);
|
||||
} else {
|
||||
LOGGER.debug("updateShowStatus failed:ids={}", ids);
|
||||
return new CommonResult().failed();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user