Search in sources :

Example 1 with CmsWord

use of com.publiccms.entities.cms.CmsWord in project PublicCMS-preview by sanluan.

the class CmsWordAdminController method save.

/**
 * @param entity
 * @param request
 * @param session
 * @param model
 * @return view name
 */
@RequestMapping("save")
public String save(CmsWord entity, HttpServletRequest request, HttpSession session, ModelMap model) {
    SysSite site = getSite(request);
    if (null != entity.getId()) {
        CmsWord oldEntity = service.getEntity(entity.getId());
        if (null == oldEntity || ControllerUtils.verifyNotEquals("siteId", site.getId(), oldEntity.getSiteId(), model)) {
            return TEMPLATE_ERROR;
        }
        entity = service.update(entity.getId(), entity, ignoreProperties);
        if (null != entity) {
            logOperateService.save(new LogOperate(entity.getSiteId(), getAdminFromSession(session).getId(), LogLoginService.CHANNEL_WEB_MANAGER, "update.word", RequestUtils.getIpAddress(request), CommonUtils.getDate(), JsonUtils.getString(entity)));
        }
    } else {
        entity.setSiteId(site.getId());
        service.save(entity);
        logOperateService.save(new LogOperate(site.getId(), getAdminFromSession(session).getId(), LogLoginService.CHANNEL_WEB_MANAGER, "save.word", RequestUtils.getIpAddress(request), CommonUtils.getDate(), JsonUtils.getString(entity)));
    }
    return TEMPLATE_DONE;
}
Also used : LogOperate(com.publiccms.entities.log.LogOperate) CmsWord(com.publiccms.entities.cms.CmsWord) SysSite(com.publiccms.entities.sys.SysSite) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with CmsWord

use of com.publiccms.entities.cms.CmsWord in project PublicCMS-preview by sanluan.

the class CmsWordAdminController method show.

/**
 * @param id
 * @param request
 * @param session
 * @param model
 * @return view name
 */
@RequestMapping("show")
public String show(Long id, HttpServletRequest request, HttpSession session, ModelMap model) {
    SysSite site = getSite(request);
    CmsWord entity = service.getEntity(id);
    if (null != entity) {
        if (ControllerUtils.verifyNotEquals("siteId", site.getId(), entity.getSiteId(), model)) {
            return TEMPLATE_ERROR;
        }
        service.updateStatus(id, false);
        logOperateService.save(new LogOperate(site.getId(), getAdminFromSession(session).getId(), LogLoginService.CHANNEL_WEB_MANAGER, "show.word", RequestUtils.getIpAddress(request), CommonUtils.getDate(), JsonUtils.getString(entity)));
    }
    return TEMPLATE_DONE;
}
Also used : LogOperate(com.publiccms.entities.log.LogOperate) CmsWord(com.publiccms.entities.cms.CmsWord) SysSite(com.publiccms.entities.sys.SysSite) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with CmsWord

use of com.publiccms.entities.cms.CmsWord in project PublicCMS-preview by sanluan.

the class CmsWordAdminController method delete.

/**
 * @param id
 * @param request
 * @param session
 * @param model
 * @return view name
 */
@RequestMapping("delete")
public String delete(Long id, HttpServletRequest request, HttpSession session, ModelMap model) {
    SysSite site = getSite(request);
    CmsWord entity = service.getEntity(id);
    if (null != entity) {
        if (ControllerUtils.verifyNotEquals("siteId", site.getId(), entity.getSiteId(), model)) {
            return TEMPLATE_ERROR;
        }
        service.delete(id);
        logOperateService.save(new LogOperate(site.getId(), getAdminFromSession(session).getId(), LogLoginService.CHANNEL_WEB_MANAGER, "delete.word", RequestUtils.getIpAddress(request), CommonUtils.getDate(), JsonUtils.getString(entity)));
    }
    return TEMPLATE_DONE;
}
Also used : LogOperate(com.publiccms.entities.log.LogOperate) CmsWord(com.publiccms.entities.cms.CmsWord) SysSite(com.publiccms.entities.sys.SysSite) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 4 with CmsWord

use of com.publiccms.entities.cms.CmsWord in project PublicCMS-preview by sanluan.

the class CmsWordAdminController method hidden.

/**
 * @param id
 * @param request
 * @param session
 * @param model
 * @return view name
 */
@RequestMapping("hidden")
public String hidden(Long id, HttpServletRequest request, HttpSession session, ModelMap model) {
    SysSite site = getSite(request);
    CmsWord entity = service.getEntity(id);
    if (null != entity) {
        if (ControllerUtils.verifyNotEquals("siteId", site.getId(), entity.getSiteId(), model)) {
            return TEMPLATE_ERROR;
        }
        service.updateStatus(id, true);
        logOperateService.save(new LogOperate(site.getId(), getAdminFromSession(session).getId(), LogLoginService.CHANNEL_WEB_MANAGER, "hidden.word", RequestUtils.getIpAddress(request), CommonUtils.getDate(), JsonUtils.getString(entity)));
    }
    return TEMPLATE_DONE;
}
Also used : LogOperate(com.publiccms.entities.log.LogOperate) CmsWord(com.publiccms.entities.cms.CmsWord) SysSite(com.publiccms.entities.sys.SysSite) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 5 with CmsWord

use of com.publiccms.entities.cms.CmsWord in project PublicCMS-preview by sanluan.

the class CmsWordDirective method execute.

@Override
public void execute(RenderHandler handler) throws IOException, Exception {
    Long id = handler.getLong("id");
    if (CommonUtils.notEmpty(id)) {
        handler.put("object", service.getEntity(id)).render();
    } else {
        Long[] ids = handler.getLongArray("ids");
        if (CommonUtils.notEmpty(ids)) {
            List<CmsWord> entityList = service.getEntitys(ids);
            Map<String, CmsWord> map = new LinkedHashMap<>();
            for (CmsWord entity : entityList) {
                map.put(String.valueOf(entity.getId()), entity);
            }
            handler.put("map", map).render();
        }
    }
}
Also used : CmsWord(com.publiccms.entities.cms.CmsWord) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

CmsWord (com.publiccms.entities.cms.CmsWord)6 LogOperate (com.publiccms.entities.log.LogOperate)4 SysSite (com.publiccms.entities.sys.SysSite)4 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)4 CmsWordStatistics (com.publiccms.views.pojo.entities.CmsWordStatistics)1 LinkedHashMap (java.util.LinkedHashMap)1