Search in sources :

Example 6 with SysApp

use of com.publiccms.entities.sys.SysApp in project PublicCMS-preview by sanluan.

the class SysAppDirective method execute.

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

Example 7 with SysApp

use of com.publiccms.entities.sys.SysApp in project PublicCMS-preview by sanluan.

the class SysAppAdminController method save.

/**
 * @param entity
 * @param apis
 * @param request
 * @param session
 * @param model
 * @return view name
 */
@RequestMapping("save")
public String save(SysApp entity, String[] apis, HttpServletRequest request, HttpSession session, ModelMap model) {
    SysSite site = getSite(request);
    entity.setAuthorizedApis(arrayToCommaDelimitedString(apis));
    if (null != entity.getId()) {
        SysApp 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) {
            entity.setAppSecret(null);
            logOperateService.save(new LogOperate(site.getId(), getAdminFromSession(session).getId(), LogLoginService.CHANNEL_WEB_MANAGER, "update.app", RequestUtils.getIpAddress(request), CommonUtils.getDate(), JsonUtils.getString(entity)));
        }
    } else {
        entity.setSiteId(site.getId());
        service.save(entity);
        entity.setAppSecret(null);
        logOperateService.save(new LogOperate(site.getId(), getAdminFromSession(session).getId(), LogLoginService.CHANNEL_WEB_MANAGER, "save.app", RequestUtils.getIpAddress(request), CommonUtils.getDate(), JsonUtils.getString(entity)));
    }
    return TEMPLATE_DONE;
}
Also used : LogOperate(com.publiccms.entities.log.LogOperate) SysApp(com.publiccms.entities.sys.SysApp) SysSite(com.publiccms.entities.sys.SysSite) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 8 with SysApp

use of com.publiccms.entities.sys.SysApp in project PublicCMS-preview by sanluan.

the class AbstractAppDirective method execute.

@Override
public void execute(RenderHandler handler) throws IOException, Exception {
    SysApp app = null;
    SysUser user = null;
    if (needAppToken() && (null == (app = getApp(handler)) || CommonUtils.empty(app.getAuthorizedApis()) || !ArrayUtils.contains(StringUtils.split(app.getAuthorizedApis(), COMMA_DELIMITED), getName()))) {
        if (null == app) {
            handler.put("error", ApiController.NEED_APP_TOKEN).render();
        } else {
            handler.put("error", ApiController.UN_AUTHORIZED).render();
        }
    } else if (needUserToken() && null == (user = getUser(handler))) {
        handler.put("error", ApiController.NEED_LOGIN).render();
    } else {
        execute(handler, app, user);
        handler.render();
    }
}
Also used : SysApp(com.publiccms.entities.sys.SysApp) SysUser(com.publiccms.entities.sys.SysUser)

Example 9 with SysApp

use of com.publiccms.entities.sys.SysApp in project PublicCMS-preview by sanluan.

the class AbstractTaskDirective method execute.

@Override
public void execute(HttpMessageConverter<Object> httpMessageConverter, MediaType mediaType, HttpServletRequest request, String callback, HttpServletResponse response) throws IOException, Exception {
    HttpParameterHandler handler = new HttpParameterHandler(httpMessageConverter, mediaType, request, callback, response);
    SysApp app = null;
    if (null == (app = getApp(handler))) {
        handler.put("error", ApiController.NEED_APP_TOKEN).render();
    } else if (CommonUtils.empty(app.getAuthorizedApis()) || !ArrayUtils.contains(StringUtils.split(app.getAuthorizedApis(), COMMA_DELIMITED), getName())) {
        handler.put("error", ApiController.UN_AUTHORIZED).render();
    } else {
        execute(handler);
        handler.render();
    }
}
Also used : SysApp(com.publiccms.entities.sys.SysApp) HttpParameterHandler(com.publiccms.common.handler.HttpParameterHandler)

Aggregations

SysApp (com.publiccms.entities.sys.SysApp)9 SysSite (com.publiccms.entities.sys.SysSite)4 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)4 LogOperate (com.publiccms.entities.log.LogOperate)3 SysAppToken (com.publiccms.entities.sys.SysAppToken)3 HttpParameterHandler (com.publiccms.common.handler.HttpParameterHandler)2 BaseMethod (com.publiccms.common.base.BaseMethod)1 SysUser (com.publiccms.entities.sys.SysUser)1 TemplateModel (freemarker.template.TemplateModel)1 TemplateModelException (freemarker.template.TemplateModelException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1