use of com.orion.ops.annotation.RequireRole in project orion-ops by lijiahangmax.
the class SystemController method cleanSystemFile.
/**
* 清理系统文件
*/
@RequestMapping("/clean-system-file")
@EventLog(EventType.CLEAN_SYSTEM_FILE)
@RequireRole(RoleType.ADMINISTRATOR)
public HttpWrapper<?> cleanSystemFile(@RequestBody SystemFileCleanRequest request) {
SystemCleanType cleanType = Valid.notNull(SystemCleanType.of(request.getCleanType()));
systemService.cleanSystemFile(cleanType);
return HttpWrapper.ok();
}
use of com.orion.ops.annotation.RequireRole in project orion-ops by lijiahangmax.
the class RoleInterceptor method preHandle.
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
if (!(handler instanceof HandlerMethod)) {
return true;
}
RequireRole role = ((HandlerMethod) handler).getMethodAnnotation(RequireRole.class);
if (role == null) {
return true;
}
UserDTO user = UserHolder.get();
if (user == null) {
response.setContentType(StandardContentType.APPLICATION_JSON);
Servlets.transfer(response, HttpWrapper.of(ResultCode.UNAUTHORIZED).toJsonString().getBytes());
return false;
}
RoleType[] hasRoles = role.value();
if (Arrays1.isEmpty(hasRoles)) {
return true;
}
for (RoleType roleType : hasRoles) {
if (roleType.getType().equals(user.getRoleType())) {
return true;
}
}
response.setContentType(StandardContentType.APPLICATION_JSON);
Servlets.transfer(response, HttpWrapper.of(ResultCode.NO_PERMISSION).toJsonString().getBytes());
return false;
}
use of com.orion.ops.annotation.RequireRole in project orion-ops by lijiahangmax.
the class SystemController method updateSystemOption.
/**
* 修改系统配置项
*/
@RequestMapping("/update-system-option")
@EventLog(EventType.UPDATE_SYSTEM_OPTION)
@RequireRole(RoleType.ADMINISTRATOR)
public HttpWrapper<?> updateSystemOption(@RequestBody SystemOptionRequest request) {
SystemConfigKey key = Valid.notNull(SystemConfigKey.of(request.getOption()));
String value = key.getValue(Valid.notBlank(request.getValue()));
systemService.updateSystemOption(key.getEnv(), value);
return HttpWrapper.ok();
}
use of com.orion.ops.annotation.RequireRole in project orion-ops by lijiahangmax.
the class ApplicationReleaseController method auditAppRelease.
/**
* 发布审核
*/
@RequestMapping("/audit")
@RequireRole(RoleType.ADMINISTRATOR)
@EventLog(EventType.AUDIT_RELEASE)
public Integer auditAppRelease(@RequestBody ApplicationReleaseAuditRequest request) {
Valid.notNull(request.getId());
AuditStatus status = Valid.notNull(AuditStatus.of(request.getStatus()));
if (AuditStatus.REJECT.equals(status)) {
Valid.notBlank(request.getReason());
}
return applicationReleaseService.auditAppRelease(request);
}
Aggregations