package com.qianwen.smartman.modules.tool.controller; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import java.util.List; import javax.validation.Valid; import com.qianwen.core.boot.ctrl.BladeController; import com.qianwen.core.scanner.modular.annotation.DeleteResource; import com.qianwen.core.scanner.modular.annotation.GetResource; import com.qianwen.core.scanner.modular.annotation.PostResource; import com.qianwen.core.scanner.modular.stereotype.ApiResource; import com.qianwen.core.secure.annotation.PreAuth; import com.qianwen.core.tool.api.R; import com.qianwen.smartman.modules.tool.convert.ToolCategoryConvert; import com.qianwen.smartman.modules.tool.service.IToolCategoryService; import com.qianwen.smartman.modules.tool.vo.ToolCategoryTreeVO; import com.qianwen.smartman.modules.tool.vo.ToolCategoryVO; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RestController; @Api(value = "刀具类型管理", tags = {"刀具类型管理"}) @ApiResource({"blade-tool/tool-category"}) @RestController public class ToolCategoryController extends BladeController { private final IToolCategoryService toolCategoryService; public ToolCategoryController(final IToolCategoryService toolCategoryService) { this.toolCategoryService = toolCategoryService; } @PreAuth @GetResource({"/tree"}) @ApiOperation("刀具类型树") public R> tree() { return R.data(this.toolCategoryService.tree()); } @PreAuth @GetResource({"/list"}) @ApiOperation("刀具类型列表") public R> list() { return R.data(ToolCategoryConvert.INSTANCE.convert(this.toolCategoryService.list())); } @PreAuth @PostResource({"/insert"}) @ApiOperation(value = "刀具类型新增", notes = "传入toolCategoryVO") public R insert(@Valid @RequestBody ToolCategoryVO toolCategoryVO) { return R.data(this.toolCategoryService.save(toolCategoryVO)); } @PreAuth @DeleteResource({"/remove"}) @ApiOperation(value = "刀具类型删除", notes = "传入ids") public R remove(@ApiParam(value = "主键", required = true) @RequestBody List ids) { if (ids.isEmpty()) { return R.status(false); } return R.status(this.toolCategoryService.remove(ids).booleanValue()); } @PreAuth @PostResource({"/updateName"}) @ApiOperation("刀具类型重命名") public R updateName(Long id, String newName) { return R.data(this.toolCategoryService.updateName(id, newName)); } }