feat: 增加菜单资源的接口
parent
cc5bba2da3
commit
4c31f61964
@ -0,0 +1,61 @@
|
|||||||
|
package com.shxy.xymanager_admin.controller;
|
||||||
|
|
||||||
|
import com.shxy.xymanager_common.base.BaseController;
|
||||||
|
import com.shxy.xymanager_common.base.ResponseReult;
|
||||||
|
import com.shxy.xymanager_common.entity.TbResource;
|
||||||
|
import com.shxy.xymanager_common.exception.ApiException;
|
||||||
|
import com.shxy.xymanager_service.service.ResourceService;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@Api(tags = {"资源相关接口"})
|
||||||
|
@RequestMapping("resource")
|
||||||
|
@Slf4j
|
||||||
|
public class ResourceController extends BaseController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
ResourceService service;
|
||||||
|
|
||||||
|
@GetMapping("listAll")
|
||||||
|
@ApiOperation("查询全部列表")
|
||||||
|
public ResponseReult<List<TbResource>> listAll() {
|
||||||
|
List<TbResource> result = service.listAll();
|
||||||
|
return ResponseReult.success(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("add")
|
||||||
|
@ApiOperation("新增")
|
||||||
|
public ResponseReult<String> add(@Validated @RequestBody TbResource item) throws Exception {
|
||||||
|
service.add(item);
|
||||||
|
return ResponseReult.success("OK");
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("update")
|
||||||
|
@ApiOperation("更新")
|
||||||
|
public ResponseReult<String> update(@Validated @RequestBody TbResource item) throws Exception {
|
||||||
|
if (item.getId() == null) {
|
||||||
|
throw new ApiException("id不能为空!");
|
||||||
|
}
|
||||||
|
service.update(item);
|
||||||
|
return ResponseReult.success("OK");
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("delete")
|
||||||
|
@ApiOperation("删除")
|
||||||
|
public ResponseReult<String> delete(@Validated @NotNull(message = "id不能为空!") Integer id) throws Exception {
|
||||||
|
if (id == null) {
|
||||||
|
throw new ApiException("id不能为空!");
|
||||||
|
}
|
||||||
|
service.delete(id);
|
||||||
|
return ResponseReult.success("OK");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue