Search in sources :

Example 6 with EasyEntity

use of com.rebuild.core.metadata.easymeta.EasyEntity in project rebuild by getrebuild.

the class MetaFieldController method pageEntityField.

@GetMapping("{entity}/field/{field}")
public ModelAndView pageEntityField(@PathVariable String entity, @PathVariable String field, HttpServletRequest request) {
    ModelAndView mv = createModelAndView("/admin/metadata/field-edit");
    EasyEntity easyEntity = MetaEntityController.setEntityBase(mv, entity);
    Field fieldMeta = easyEntity.getRawMeta().getField(field);
    EasyField easyField = EasyMetaFactory.valueOf(fieldMeta);
    mv.getModel().put("fieldMetaId", easyField.getMetaId());
    mv.getModel().put("fieldName", easyField.getName());
    mv.getModel().put("fieldLabel", easyField.getLabel());
    mv.getModel().put("fieldComments", easyField.getComments());
    mv.getModel().put("fieldType", easyField.getDisplayType(false));
    mv.getModel().put("fieldTypeLabel", easyField.getDisplayType(true));
    mv.getModel().put("fieldNullable", fieldMeta.isNullable());
    mv.getModel().put("fieldCreatable", fieldMeta.isCreatable());
    mv.getModel().put("fieldUpdatable", fieldMeta.isUpdatable());
    mv.getModel().put("fieldRepeatable", fieldMeta.isRepeatable());
    mv.getModel().put("fieldQueryable", fieldMeta.isQueryable());
    mv.getModel().put("fieldBuildin", easyField.isBuiltin());
    mv.getModel().put("fieldDefaultValue", fieldMeta.getDefaultValue());
    mv.getModel().put("isSuperAdmin", UserHelper.isSuperAdmin(getRequestUser(request)));
    // 明细实体
    if (easyEntity.getRawMeta().getMainEntity() != null) {
        Field dtmField = MetadataHelper.getDetailToMainField(easyEntity.getRawMeta());
        mv.getModel().put("isDetailToMainField", dtmField.equals(fieldMeta));
    } else {
        mv.getModel().put("isDetailToMainField", false);
    }
    // 字段类型相关
    Type ft = fieldMeta.getType();
    if (ft == FieldType.REFERENCE || ft == FieldType.REFERENCE_LIST) {
        Entity refEntity = fieldMeta.getReferenceEntity();
        mv.getModel().put("fieldRefentity", refEntity.getName());
        mv.getModel().put("fieldRefentityLabel", EasyMetaFactory.getLabel(refEntity));
    }
    // 扩展配置
    JSONObject extraAttrs = new JSONObject();
    for (Map.Entry<String, Object> e : easyField.getExtraAttrs(true).entrySet()) {
        String name = e.getKey();
        // 排除私有
        if (!name.startsWith("_"))
            extraAttrs.put(name, e.getValue());
    }
    mv.getModel().put("fieldExtConfig", extraAttrs);
    return mv;
}
Also used : EasyEntity(com.rebuild.core.metadata.easymeta.EasyEntity) EasyField(com.rebuild.core.metadata.easymeta.EasyField) Field(cn.devezhao.persist4j.Field) EasyEntity(com.rebuild.core.metadata.easymeta.EasyEntity) Entity(cn.devezhao.persist4j.Entity) DisplayType(com.rebuild.core.metadata.easymeta.DisplayType) FieldType(cn.devezhao.persist4j.dialect.FieldType) Type(cn.devezhao.persist4j.dialect.Type) JSONObject(com.alibaba.fastjson.JSONObject) ModelAndView(org.springframework.web.servlet.ModelAndView) JSONObject(com.alibaba.fastjson.JSONObject) HashMap(java.util.HashMap) Map(java.util.Map) EasyField(com.rebuild.core.metadata.easymeta.EasyField)

Example 7 with EasyEntity

use of com.rebuild.core.metadata.easymeta.EasyEntity in project rebuild by getrebuild.

the class MetaFieldController method page.

@GetMapping("{entity}/fields")
public ModelAndView page(@PathVariable String entity, HttpServletRequest request) {
    ModelAndView mv = createModelAndView("/admin/metadata/fields");
    EasyEntity easyEntity = MetaEntityController.setEntityBase(mv, entity);
    mv.getModel().put("nameField", easyEntity.getRawMeta().getNameField().getName());
    mv.getModel().put("isSuperAdmin", UserHelper.isSuperAdmin(getRequestUser(request)));
    return mv;
}
Also used : EasyEntity(com.rebuild.core.metadata.easymeta.EasyEntity) ModelAndView(org.springframework.web.servlet.ModelAndView)

Example 8 with EasyEntity

use of com.rebuild.core.metadata.easymeta.EasyEntity in project rebuild by getrebuild.

the class AutoFillinController method page.

@RequestMapping("{field}/auto-fillin")
public ModelAndView page(@PathVariable String entity, @PathVariable String field) {
    ModelAndView mv = createModelAndView("/admin/metadata/auto-fillin");
    EasyEntity easyEntity = MetaEntityController.setEntityBase(mv, entity);
    Field fieldMeta = easyEntity.getRawMeta().getField(field);
    mv.getModel().put("fieldName", fieldMeta.getName());
    mv.getModel().put("referenceEntity", fieldMeta.getReferenceEntity().getName());
    mv.getModel().put("referenceEntityLabel", EasyMetaFactory.getLabel(fieldMeta.getReferenceEntity()));
    return mv;
}
Also used : EasyEntity(com.rebuild.core.metadata.easymeta.EasyEntity) Field(cn.devezhao.persist4j.Field) ModelAndView(org.springframework.web.servlet.ModelAndView) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 9 with EasyEntity

use of com.rebuild.core.metadata.easymeta.EasyEntity in project rebuild by getrebuild.

the class MetaEntityController method pageAdvanced.

@GetMapping("entity/{entity}/advanced")
public ModelAndView pageAdvanced(@PathVariable String entity, HttpServletRequest request) {
    ModelAndView mv = createModelAndView("/admin/metadata/entity-advanced");
    mv.getModel().put("isSuperAdmin", UserHelper.isSuperAdmin(getRequestUser(request)));
    EasyEntity easyEntity = setEntityBase(mv, entity);
    // 扩展配置
    mv.getModel().put("entityExtConfig", easyEntity.getExtraAttrs(true));
    boolean isDetail = easyEntity.getRawMeta().getMainEntity() != null;
    boolean isBizz = MetadataHelper.isBizzEntity(easyEntity.getRawMeta());
    mv.getModel().put("useListMode", !(isDetail || isBizz));
    return mv;
}
Also used : EasyEntity(com.rebuild.core.metadata.easymeta.EasyEntity) ModelAndView(org.springframework.web.servlet.ModelAndView)

Example 10 with EasyEntity

use of com.rebuild.core.metadata.easymeta.EasyEntity in project rebuild by getrebuild.

the class FeedsListController method buildItem.

private JSONObject buildItem(Object[] o, ID user) {
    JSONObject item = formatBase(o, user);
    FeedsScope scope = FeedsScope.parse((String) o[7]);
    item.put("scopeRaw", o[7]);
    if (scope == FeedsScope.GROUP) {
        Team team = Application.getUserStore().getTeam(ID.valueOf((String) o[7]));
        item.put("scope", new Object[] { team.getIdentity(), team.getName() });
    } else {
        item.put("scope", Language.L(scope.getName()));
    }
    item.put("type", o[8]);
    item.put("numComments", FeedsHelper.getNumOfComment((ID) o[0]));
    // 相关记录
    ID related = (ID) o[9];
    if (related != null && MetadataHelper.containsEntity(related.getEntityCode())) {
        EasyEntity entity = EasyMetaFactory.valueOf(related.getEntityCode());
        String nameValue = FieldValueHelper.getLabelNotry(related);
        JSONObject mixValue = FieldValueHelper.wrapMixValue(related, nameValue);
        mixValue.put("icon", entity.getIcon());
        mixValue.put("entityLabel", entity.getLabel());
        item.put("relatedRecord", mixValue);
    }
    // 更多内容
    if (o[10] != null) {
        item.put("contentMore", JSON.parse((String) o[10]));
    }
    return item;
}
Also used : EasyEntity(com.rebuild.core.metadata.easymeta.EasyEntity) JSONObject(com.alibaba.fastjson.JSONObject) FeedsScope(com.rebuild.core.service.feeds.FeedsScope) Team(cn.devezhao.bizz.security.member.Team) ID(cn.devezhao.persist4j.engine.ID)

Aggregations

EasyEntity (com.rebuild.core.metadata.easymeta.EasyEntity)16 Entity (cn.devezhao.persist4j.Entity)6 ModelAndView (org.springframework.web.servlet.ModelAndView)6 Field (cn.devezhao.persist4j.Field)5 ID (cn.devezhao.persist4j.engine.ID)5 JSONObject (com.alibaba.fastjson.JSONObject)5 JSONArray (com.alibaba.fastjson.JSONArray)3 ArrayList (java.util.ArrayList)3 EasyField (com.rebuild.core.metadata.easymeta.EasyField)2 CopyEntity (com.rebuild.core.metadata.impl.CopyEntity)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 GetMapping (org.springframework.web.bind.annotation.GetMapping)2 Permission (cn.devezhao.bizz.privileges.Permission)1 Team (cn.devezhao.bizz.security.member.Team)1 Record (cn.devezhao.persist4j.Record)1 FieldType (cn.devezhao.persist4j.dialect.FieldType)1 Type (cn.devezhao.persist4j.dialect.Type)1 BaseMeta (cn.devezhao.persist4j.metadata.BaseMeta)1 JSON (com.alibaba.fastjson.JSON)1