Search in sources :

Example 1 with HomeFile

use of com.publiccms.entities.home.HomeFile in project PublicCMS-preview by sanluan.

the class HomeFileAdminController method enable.

/**
 * @param id
 * @param request
 * @param session
 * @param model
 * @return view name
 */
@RequestMapping(value = "enable", method = RequestMethod.POST)
public String enable(Long id, HttpServletRequest request, HttpSession session, ModelMap model) {
    if (ControllerUtils.verifyEquals("admin.operate", getAdminFromSession(session).getId(), id, model)) {
        return TEMPLATE_ERROR;
    }
    HomeFile entity = service.getEntity(id);
    if (null != entity) {
        SysSite site = getSite(request);
        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, "enable.home.file", RequestUtils.getIpAddress(request), CommonUtils.getDate(), JsonUtils.getString(entity)));
    }
    return TEMPLATE_DONE;
}
Also used : HomeFile(com.publiccms.entities.home.HomeFile) LogOperate(com.publiccms.entities.log.LogOperate) SysSite(com.publiccms.entities.sys.SysSite) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with HomeFile

use of com.publiccms.entities.home.HomeFile in project PublicCMS-preview by sanluan.

the class HomeFileAdminController method disable.

/**
 * @param id
 * @param request
 * @param session
 * @param model
 * @return view name
 */
@RequestMapping(value = "disable", method = RequestMethod.POST)
public String disable(Long id, HttpServletRequest request, HttpSession session, ModelMap model) {
    if (ControllerUtils.verifyEquals("admin.operate", getAdminFromSession(session).getId(), id, model)) {
        return TEMPLATE_ERROR;
    }
    HomeFile entity = service.getEntity(id);
    if (null != entity) {
        SysSite site = getSite(request);
        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, "disable.home.file", RequestUtils.getIpAddress(request), CommonUtils.getDate(), JsonUtils.getString(entity)));
    }
    return TEMPLATE_DONE;
}
Also used : HomeFile(com.publiccms.entities.home.HomeFile) LogOperate(com.publiccms.entities.log.LogOperate) SysSite(com.publiccms.entities.sys.SysSite) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with HomeFile

use of com.publiccms.entities.home.HomeFile in project PublicCMS-preview by sanluan.

the class HomeFileDirective method execute.

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

Aggregations

HomeFile (com.publiccms.entities.home.HomeFile)3 LogOperate (com.publiccms.entities.log.LogOperate)2 SysSite (com.publiccms.entities.sys.SysSite)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 LinkedHashMap (java.util.LinkedHashMap)1