mitao
2024-07-09 07c83c163675e24252de05d029cef2eab046e583
finance-admin/src/main/java/com/finance/web/controller/api/TbFieldCategoryController.java
@@ -16,7 +16,14 @@
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
 * <p>
@@ -37,6 +44,7 @@
    /**
     * 添加
     *
     * @param dto 字段分类数据传输对象
     * @return R
     */
@@ -57,6 +65,7 @@
    /**
     * 根据id获取字段分类详情
     *
     * @param id 字段分类id
     * @return R
     */
@@ -77,6 +86,7 @@
    /**
     * 分页条件查询
     *
     * @param query 部门条件查询对象
     * @return PageVO<FieldCategoryDetailVO>
     */
@@ -96,12 +106,16 @@
    /**
     * 隐藏显示操作
     *
     * @param dto 显示隐藏操作数据传输对象
     * @return R
     */
    @PostMapping("/show-hide")
    @ApiOperation("隐藏显示操作")
    public R<Void> showHide(@RequestBody ShowHideDTO dto) {
        if (dto.getId() < 50) {
            throw new ServiceException("固定字段分类,不能操作!");
        }
        try {
            tbFieldCategoryService.showHide(dto);
        } catch (Exception e) {
@@ -116,14 +130,19 @@
    /**
     * 删除分类子节点
     *
     * @param id id
     * @return R
     */
    @DeleteMapping("/delete-children")
    @ApiOperation("编辑页面删除子字段分类")
    public R<Object> deleteChildren(@RequestParam(value = "id") Long id){
        if (id < 50) {
            throw new ServiceException("固定字段分类,不能操作!");
        }
        try {
            tbFieldCategoryService.deleteChildren(id);
        } catch (Exception e) {
            if (e instanceof ServiceException) {
                return R.fail(e.getMessage());
@@ -136,12 +155,16 @@
    /**
     * 删除分类
     *
     * @param id id
     * @return R
     */
    @DeleteMapping("/delete")
    @ApiOperation("列表页面删除分类")
    public R<Void> delete(@RequestParam(value = "id") Long id){
        if (id < 50) {
            throw new ServiceException("固定字段分类,不能操作");
        }
        try {
            tbFieldCategoryService.delete(id);
        } catch (Exception e) {
@@ -156,12 +179,16 @@
    /**
     * 编辑分类
     *
     * @param dto 字段分类更新数据传输对象
     * @return R
     */
    @PutMapping("/edit")
    @ApiOperation("编辑")
    public R<Object> edit(@RequestBody FieldCategoryUpdateDTO dto) {
        if (dto.getId() < 50) {
            throw new ServiceException("固定字段分类,不能操作");
        }
        try {
            tbFieldCategoryService.edit(dto);
        } catch (Exception e) {