use of io.jpom.permission.MethodFeature in project Jpom by dromara.
the class OperateLogController method createCacheInfo.
private CacheInfo createCacheInfo(Method method) {
Feature feature = method.getAnnotation(Feature.class);
if (feature == null) {
return null;
}
Class<?> declaringClass = method.getDeclaringClass();
MethodFeature methodFeature = feature.method();
if (methodFeature == MethodFeature.NULL) {
DefaultSystemLog.getLog().error("权限分发配置错误:{} {}", declaringClass, method.getName());
return null;
}
ClassFeature classFeature = feature.cls();
if (classFeature == ClassFeature.NULL) {
Feature feature1 = declaringClass.getAnnotation(Feature.class);
if (feature1 == null || feature1.cls() == ClassFeature.NULL) {
DefaultSystemLog.getLog().error("权限分发配置错误:{} {} class not find", declaringClass, method.getName());
return null;
}
classFeature = feature1.cls();
}
CacheInfo cacheInfo = new CacheInfo();
cacheInfo.setClassFeature(classFeature);
cacheInfo.setMethodFeature(methodFeature);
cacheInfo.setOptTime(SystemClock.now());
cacheInfo.setResultCode(feature.resultCode());
cacheInfo.setLogResponse(feature.logResponse());
//
if (dbUserOperateLogService == null) {
dbUserOperateLogService = SpringUtil.getBean(DbUserOperateLogService.class);
}
return cacheInfo;
}
use of io.jpom.permission.MethodFeature in project Jpom by dromara.
the class MonitorUserOptListController method getOperateTypeList.
/**
* 操作监控类型列表
*
* @return json
*/
@RequestMapping(value = "type_data", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
@Feature(method = MethodFeature.LIST)
public String getOperateTypeList() {
JSONObject jsonObject = new JSONObject();
//
List<JSONObject> classFeatureList = Arrays.stream(ClassFeature.values()).filter(classFeature -> classFeature != ClassFeature.NULL).map(classFeature -> {
JSONObject jsonObject1 = new JSONObject();
jsonObject1.put("title", classFeature.getName());
jsonObject1.put("value", classFeature.name());
return jsonObject1;
}).collect(Collectors.toList());
jsonObject.put("classFeature", classFeatureList);
//
List<JSONObject> methodFeatureList = Arrays.stream(MethodFeature.values()).filter(methodFeature -> methodFeature != MethodFeature.NULL && methodFeature != MethodFeature.LIST).map(classFeature -> {
JSONObject jsonObject1 = new JSONObject();
jsonObject1.put("title", classFeature.getName());
jsonObject1.put("value", classFeature.name());
return jsonObject1;
}).collect(Collectors.toList());
jsonObject.put("methodFeature", methodFeatureList);
return JsonMessage.getString(200, "success", jsonObject);
}
use of io.jpom.permission.MethodFeature in project Jpom by dromara.
the class MonitorUserOptListController method updateMonitor.
/**
* 增加或修改监控
*
* @param id id
* @param name name
* @param notifyUser user
* @return json
*/
@RequestMapping(value = "update", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
@Feature(method = MethodFeature.EDIT)
public String updateMonitor(String id, @ValidatorItem(value = ValidatorRule.NOT_BLANK, msg = "监控名称不能为空") String name, String notifyUser, String monitorUser, String monitorOpt, String monitorFeature) {
String status = getParameter("status");
JSONArray jsonArray = JSONArray.parseArray(notifyUser);
List<String> notifyUsers = jsonArray.toJavaList(String.class).stream().filter(Objects::nonNull).collect(Collectors.toList());
Assert.notEmpty(notifyUsers, "请选择报警联系人");
JSONArray monitorUserArray = JSONArray.parseArray(monitorUser);
List<String> monitorUserArrays = monitorUserArray.toJavaList(String.class).stream().filter(Objects::nonNull).collect(Collectors.toList());
Assert.notEmpty(monitorUserArrays, "请选择监控人员");
JSONArray monitorOptArray = JSONArray.parseArray(monitorOpt);
List<MethodFeature> monitorOptArrays = monitorOptArray.stream().map(o -> EnumUtil.fromString(MethodFeature.class, StrUtil.toString(o), null)).filter(Objects::nonNull).collect(Collectors.toList());
Assert.notEmpty(monitorOptArrays, "请选择监控的操作");
JSONArray monitorFeatureArray = JSONArray.parseArray(monitorFeature);
List<ClassFeature> monitorFeatureArrays = monitorFeatureArray.stream().map(o -> EnumUtil.fromString(ClassFeature.class, StrUtil.toString(o), null)).filter(Objects::nonNull).collect(Collectors.toList());
Assert.notEmpty(monitorFeatureArrays, "请选择监控的功能");
boolean start = "on".equalsIgnoreCase(status);
MonitorUserOptModel monitorModel = monitorUserOptService.getByKey(id);
if (monitorModel == null) {
monitorModel = new MonitorUserOptModel();
}
monitorModel.monitorUser(monitorUserArrays);
monitorModel.setStatus(start);
monitorModel.monitorOpt(monitorOptArrays);
monitorModel.monitorFeature(monitorFeatureArrays);
monitorModel.notifyUser(notifyUsers);
monitorModel.setName(name);
if (StrUtil.isEmpty(id)) {
// 添加监控
monitorUserOptService.insert(monitorModel);
return JsonMessage.getString(200, "添加成功");
}
monitorUserOptService.update(monitorModel);
return JsonMessage.getString(200, "修改成功");
}
Aggregations