All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.yiuman.citrus.system.rest.ResourceController Maven / Gradle / Ivy

package com.github.yiuman.citrus.system.rest;

import com.github.yiuman.citrus.support.crud.rest.BaseCrudController;
import com.github.yiuman.citrus.support.model.DialogView;
import com.github.yiuman.citrus.support.model.Page;
import com.github.yiuman.citrus.support.utils.Buttons;
import com.github.yiuman.citrus.system.dto.ResourceDto;
import com.github.yiuman.citrus.system.dto.ResourceQuery;
import com.github.yiuman.citrus.system.service.ResourceService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 资源控制器
 *
 * @author yiuman
 * @date 2020/4/6
 */
@RestController
@RequestMapping("/rest/resources")
public class ResourceController extends BaseCrudController {

    private final ResourceService resourceService;

    public ResourceController(ResourceService resourceService) {
        this.resourceService = resourceService;
        setParamClass(ResourceQuery.class);
    }

    @Override
    protected ResourceService getService() {
        return resourceService;
    }

    @Override
    protected Page createPage() throws Exception {
        Page page = super.createPage();
        page.addHeader("资源名", "resourceName");
        page.addHeader("资源类型", "typeText", (entity) -> {
            String typeString = "";
            if (entity.getType() != null && entity.getType() == 0) {
                typeString = "菜单";
            }
            return typeString;
        });
        page.addHeader("资源路径", "path");
        page.addWidget("资源名", "resourceName");
        page.addButton(Buttons.defaultButtonsWithMore());
        page.addActions(Buttons.defaultActions());
        return page;
    }

    @Override
    protected DialogView createDialogView() throws Exception {
        DialogView dialogView = new DialogView();
        dialogView.addEditField("资源名", "resourceName");
        dialogView.addEditField("资源路径", "path");
        return dialogView;
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy