Search in sources :

Example 21 with ConfigBean

use of com.rebuild.core.configuration.ConfigBean in project rebuild by getrebuild.

the class FormDesignController method page.

@GetMapping("form-design")
public ModelAndView page(@PathVariable String entity, HttpServletRequest request) {
    ModelAndView mv = createModelAndView("/admin/metadata/form-design");
    MetaEntityController.setEntityBase(mv, entity);
    mv.getModel().put("isSuperAdmin", UserHelper.isSuperAdmin(getRequestUser(request)));
    ConfigBean config = FormsManager.instance.getFormLayout(entity, getRequestUser(request));
    if (config != null) {
        request.setAttribute("FormConfig", config.toJSON());
    }
    return mv;
}
Also used : ModelAndView(org.springframework.web.servlet.ModelAndView) ConfigBean(com.rebuild.core.configuration.ConfigBean) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 22 with ConfigBean

use of com.rebuild.core.configuration.ConfigBean in project rebuild by getrebuild.

the class ListStatsController method gets.

@GetMapping("{entity}/list-stats")
public JSON gets(@PathVariable String entity, HttpServletRequest request) {
    final ID user = getRequestUser(request);
    ConfigBean config = DataListManager.instance.getListStatsField(user, entity);
    JSONObject configJson = config == null ? new JSONObject() : (JSONObject) config.getJSON("config");
    // 可用字段
    JSONArray afields = new JSONArray();
    for (Field field : MetadataSorter.sortFields(MetadataHelper.getEntity(entity), DisplayType.NUMBER, DisplayType.DECIMAL)) {
        afields.add(EasyMetaFactory.toJSON(field));
    }
    configJson.put("fields", afields);
    return configJson;
}
Also used : Field(cn.devezhao.persist4j.Field) JSONObject(com.alibaba.fastjson.JSONObject) JSONArray(com.alibaba.fastjson.JSONArray) ID(cn.devezhao.persist4j.engine.ID) ConfigBean(com.rebuild.core.configuration.ConfigBean)

Example 23 with ConfigBean

use of com.rebuild.core.configuration.ConfigBean in project rebuild by getrebuild.

the class WidgetController method gets.

@GetMapping("widget-charts")
public void gets(@PathVariable String entity, HttpServletRequest request, HttpServletResponse response) {
    ID user = getRequestUser(request);
    ConfigBean config = DataListManager.instance.getWidgetCharts(user, entity);
    writeSuccess(response, config == null ? null : config.toJSON());
}
Also used : ID(cn.devezhao.persist4j.engine.ID) ConfigBean(com.rebuild.core.configuration.ConfigBean) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 24 with ConfigBean

use of com.rebuild.core.configuration.ConfigBean in project rebuild by getrebuild.

the class AdvFilterController method sets.

@PostMapping("advfilter/post")
public RespBody sets(@PathVariable String entity, HttpServletRequest request) {
    final ID user = getRequestUser(request);
    ID filterId = getIdParameter(request, "id");
    String filterName = getParameter(request, "name");
    // 不是自己的就另存为
    if (filterId != null && !UserHelper.isSelf(user, filterId)) {
        if (StringUtils.isBlank(filterName)) {
            ConfigBean o = AdvFilterManager.instance.getAdvFilter(filterId);
            if (o != null) {
                filterName = o.getString("name") + "-" + Language.L("复制");
            }
        }
        filterId = null;
    }
    JSON filter = ServletUtils.getRequestJson(request);
    Record record;
    if (filterId == null) {
        record = EntityHelper.forNew(EntityHelper.FilterConfig, user);
        record.setString("belongEntity", entity);
        if (StringUtils.isBlank(filterName)) {
            filterName = Language.L("查询") + "-" + CalendarUtils.format("MMddHHmm", CalendarUtils.now());
        }
    } else {
        record = EntityHelper.forUpdate(filterId, user);
    }
    record.setString("config", filter.toJSONString());
    putCommonsFields(request, record);
    if (StringUtils.isNotBlank(filterName)) {
        record.setString("filterName", filterName);
    }
    record = Application.getBean(AdvFilterService.class).createOrUpdate(record);
    return RespBody.ok(JSONUtils.toJSONObject("id", record.getPrimary()));
}
Also used : JSON(com.alibaba.fastjson.JSON) Record(cn.devezhao.persist4j.Record) ID(cn.devezhao.persist4j.engine.ID) ConfigBean(com.rebuild.core.configuration.ConfigBean)

Example 25 with ConfigBean

use of com.rebuild.core.configuration.ConfigBean in project rebuild by getrebuild.

the class ProjectManager method getPlansOfProject.

/**
 * 获取项目的任务面板
 *
 * @param projectId
 * @return
 */
public ConfigBean[] getPlansOfProject(ID projectId) {
    Assert.notNull(projectId, "[projectId] cannot be null");
    final String ckey = CKEY_PLANS + projectId;
    ConfigBean[] cached = (ConfigBean[]) Application.getCommonsCache().getx(ckey);
    if (cached == null) {
        Object[][] array = Application.createQueryNoFilter("select configId,planName,flowStatus,flowNexts from ProjectPlanConfig where projectId = ? order by seq").setParameter(1, projectId).array();
        List<ConfigBean> alist = new ArrayList<>();
        for (Object[] o : array) {
            ConfigBean e = new ConfigBean().set("id", o[0]).set("planName", o[1]).set("flowStatus", o[2]);
            if (StringUtils.isNotBlank((String) o[3])) {
                List<ID> nexts = new ArrayList<>();
                for (String s : ((String) o[3]).split(",")) {
                    nexts.add(ID.valueOf(s));
                }
                e.set("flowNexts", nexts);
            }
            alist.add(e);
        }
        cached = alist.toArray(new ConfigBean[0]);
        Application.getCommonsCache().putx(ckey, cached);
    }
    return cached.clone();
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject) ConfigBean(com.rebuild.core.configuration.ConfigBean) ID(cn.devezhao.persist4j.engine.ID)

Aggregations

ConfigBean (com.rebuild.core.configuration.ConfigBean)52 ID (cn.devezhao.persist4j.engine.ID)26 JSONObject (com.alibaba.fastjson.JSONObject)23 JSONArray (com.alibaba.fastjson.JSONArray)16 JSON (com.alibaba.fastjson.JSON)9 GetMapping (org.springframework.web.bind.annotation.GetMapping)9 Entity (cn.devezhao.persist4j.Entity)8 ArrayList (java.util.ArrayList)7 Field (cn.devezhao.persist4j.Field)6 Record (cn.devezhao.persist4j.Record)5 ConfigurationException (com.rebuild.core.configuration.ConfigurationException)5 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)4 ModelAndView (org.springframework.web.servlet.ModelAndView)4 DataSpecificationException (com.rebuild.core.service.DataSpecificationException)2 AdvFilterParser (com.rebuild.core.service.query.AdvFilterParser)2 List (java.util.List)2 Set (java.util.Set)2 Test (org.junit.jupiter.api.Test)2 Permission (cn.devezhao.bizz.privileges.Permission)1 BizzPermission (cn.devezhao.bizz.privileges.impl.BizzPermission)1