Skip to content

Commit

Permalink
分类 启用/禁用
Browse files Browse the repository at this point in the history
  • Loading branch information
Q-1515 committed Jul 21, 2022
1 parent b1494aa commit 65c7982
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public R<String> deleteById(Long id) {

/**
* 修改分类
*
* @param categoryDTO 修改id 修改name 修改sort
* @return success
*/
Expand All @@ -78,5 +79,20 @@ public R<String> update(@RequestBody CategoryDTO categoryDTO) {
return R.success("分类修改成功");
}

/**
* 启用/禁用 分类
*
* @param status 状态码
* @param id 分类id
* @return success
*/
@PostMapping("/status/{status}")
@ApiOperation("分类 启用/禁用")
public R<String> startOrStop(@PathVariable Integer status, Long id) {
log.info("分类 启用/禁用:{},{}", status,id);
categoryService.startOrStop(status,id);
return R.success("状态更新成功");
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,7 @@ public interface CategoryService {

//修改分类
void update(CategoryDTO categoryDTO);

//启用/禁用 分类
void startOrStop(Integer status, Long id);
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,24 @@ public void deleteById(Long id) {
public void update(CategoryDTO categoryDTO) {
//拷贝数据
Category category = new Category();
BeanUtils.copyProperties(categoryDTO,category);
BeanUtils.copyProperties(categoryDTO, category);

categoryMapper.update(category);

}

/**
* 启用/禁用 分类
*
* @param status 状态码
* @param id 分类id
*/
public void startOrStop(Integer status, Long id) {
Category category = Category.builder()
.id(id)
.status(status)
.build();

categoryMapper.update(category);
}
}

0 comments on commit 65c7982

Please sign in to comment.