Search in sources :

Example 6 with CmsModel

use of com.publiccms.views.pojo.entities.CmsModel in project PublicCMS-preview by sanluan.

the class CmsModelDirective method execute.

@Override
public void execute(RenderHandler handler) throws IOException, Exception {
    String id = handler.getString("id");
    SysSite site = getSite(handler);
    if (CommonUtils.notEmpty(id)) {
        CmsModel entity = modelComponent.getMap(site).get(id);
        if (null != entity) {
            handler.put("object", entity).render();
        }
    } else {
        String[] ids = handler.getStringArray("ids");
        if (CommonUtils.notEmpty(ids)) {
            Map<String, CmsModel> modelMap = modelComponent.getMap(site);
            Map<String, CmsModel> map = new LinkedHashMap<>();
            for (String modelId : ids) {
                map.put(modelId, modelMap.get(modelId));
            }
            handler.put("map", map).render();
        }
    }
}
Also used : CmsModel(com.publiccms.views.pojo.entities.CmsModel) SysSite(com.publiccms.entities.sys.SysSite) LinkedHashMap(java.util.LinkedHashMap)

Example 7 with CmsModel

use of com.publiccms.views.pojo.entities.CmsModel in project PublicCMS-preview by sanluan.

the class ModelComponent method getList.

/**
 * @param site
 * @param parentId
 * @param hasChild
 * @param onlyUrl
 * @param hasImages
 * @param hasFiles
 * @return models list
 */
public List<CmsModel> getList(SysSite site, String parentId, Boolean hasChild, Boolean onlyUrl, Boolean hasImages, Boolean hasFiles) {
    List<CmsModel> modelList = new ArrayList<>();
    Map<String, CmsModel> map = getMap(site);
    for (CmsModel model : map.values()) {
        if ((CommonUtils.empty(parentId) && CommonUtils.empty(model.getParentId()) || CommonUtils.notEmpty(parentId) && parentId.equals(model.getParentId())) || (null != hasChild && hasChild.equals(model.isHasChild())) || (null != onlyUrl && onlyUrl.equals(model.isOnlyUrl())) || (null != hasImages && hasImages.equals(model.isHasImages())) || (null != hasFiles && hasFiles.equals(model.isHasFiles()))) {
            modelList.add(model);
        }
    }
    return modelList;
}
Also used : CmsModel(com.publiccms.views.pojo.entities.CmsModel) ArrayList(java.util.ArrayList)

Example 8 with CmsModel

use of com.publiccms.views.pojo.entities.CmsModel in project PublicCMS-preview by sanluan.

the class CmsModelAdminController method delete.

/**
 * @param id
 * @param request
 * @param session
 * @param model
 * @return view name
 */
@RequestMapping("delete")
public String delete(String id, HttpServletRequest request, HttpSession session, ModelMap model) {
    SysSite site = getSite(request);
    Map<String, CmsModel> modelMap = modelComponent.getMap(site);
    CmsModel entity = modelMap.remove(id);
    if (null != entity) {
        List<CmsModel> modelList = modelComponent.getList(site, entity.getId(), null, null, null, null);
        for (CmsModel m : modelList) {
            m.setParentId(null);
            modelMap.put(m.getId(), m);
        }
        modelComponent.save(site, modelMap);
        logOperateService.save(new LogOperate(site.getId(), getAdminFromSession(session).getId(), LogLoginService.CHANNEL_WEB_MANAGER, "delete.model", RequestUtils.getIpAddress(request), CommonUtils.getDate(), JsonUtils.getString(entity)));
    }
    return TEMPLATE_DONE;
}
Also used : LogOperate(com.publiccms.entities.log.LogOperate) CmsModel(com.publiccms.views.pojo.entities.CmsModel) SysSite(com.publiccms.entities.sys.SysSite) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 9 with CmsModel

use of com.publiccms.views.pojo.entities.CmsModel in project PublicCMS-preview by sanluan.

the class CmsModelAdminController method save.

/**
 * @param entity
 * @param modelId
 * @param request
 * @param session
 * @return view name
 */
@RequestMapping("save")
public String save(@ModelAttribute CmsModel entity, String modelId, HttpServletRequest request, HttpSession session) {
    SysSite site = getSite(request);
    modelComponent.clear(site.getId());
    if (CommonUtils.notEmpty(modelId)) {
        Map<String, CmsModel> modelMap = modelComponent.getMap(site);
        modelMap.remove(modelId);
        modelMap.put(entity.getId(), entity);
        modelComponent.save(site, modelMap);
        logOperateService.save(new LogOperate(site.getId(), getAdminFromSession(session).getId(), LogLoginService.CHANNEL_WEB_MANAGER, "update.model", RequestUtils.getIpAddress(request), CommonUtils.getDate(), JsonUtils.getString(entity)));
    } else {
        Map<String, CmsModel> modelMap = modelComponent.getMap(site);
        modelMap.put(entity.getId(), entity);
        modelComponent.save(site, modelMap);
        logOperateService.save(new LogOperate(site.getId(), getAdminFromSession(session).getId(), LogLoginService.CHANNEL_WEB_MANAGER, "save.model", RequestUtils.getIpAddress(request), CommonUtils.getDate(), JsonUtils.getString(entity)));
    }
    return TEMPLATE_DONE;
}
Also used : LogOperate(com.publiccms.entities.log.LogOperate) CmsModel(com.publiccms.views.pojo.entities.CmsModel) SysSite(com.publiccms.entities.sys.SysSite) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

CmsModel (com.publiccms.views.pojo.entities.CmsModel)9 SysSite (com.publiccms.entities.sys.SysSite)5 LogOperate (com.publiccms.entities.log.LogOperate)4 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)4 ExtendField (com.publiccms.views.pojo.entities.ExtendField)3 File (java.io.File)3 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 TypeReference (com.fasterxml.jackson.core.type.TypeReference)2 CmsCategory (com.publiccms.entities.cms.CmsCategory)2 CmsCategoryModel (com.publiccms.entities.cms.CmsCategoryModel)2 CmsCategoryModelId (com.publiccms.entities.cms.CmsCategoryModelId)2 CmsContent (com.publiccms.entities.cms.CmsContent)2 SysExtendField (com.publiccms.entities.sys.SysExtendField)2 SysUser (com.publiccms.entities.sys.SysUser)2 ResultSet (java.sql.ResultSet)2 Statement (java.sql.Statement)2 SysDept (com.publiccms.entities.sys.SysDept)1 SysDeptCategoryId (com.publiccms.entities.sys.SysDeptCategoryId)1