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();
}
}
}
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;
}
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();
}
}
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();
}
}
Aggregations