use of vip.mate.core.log.annotation.Log in project matecloud by matevip.
the class SysApiController method sync.
/**
* 从redis同步api至数据库
*
* @return Boolean
*/
@PreAuth
@PostMapping("/sync")
@ApiOperation(value = "API同步")
@Log(value = "API同步")
public Result<?> sync() {
Set<Object> serviceIds = redisService.sGet(MateConstant.MATE_SERVICE_RESOURCE);
for (Object service : serviceIds) {
if (redisService.hHasKey(MateConstant.MATE_API_RESOURCE, service.toString())) {
Map<String, Object> apiMap = (Map<String, Object>) redisService.hget(MateConstant.MATE_API_RESOURCE, service.toString());
List<Map<String, String>> list = (List<Map<String, String>>) apiMap.get("list");
list.forEach(item -> {
SysApi sysApi = new SysApi();
sysApi.setAuth(item.get("auth"));
sysApi.setClassName(item.get("className"));
sysApi.setCode(item.get("code"));
sysApi.setContentType(item.get("contentType"));
sysApi.setMethod(item.get("method"));
sysApi.setMethodName(item.get("methodName"));
sysApi.setName(item.get("name"));
sysApi.setNotes(item.get("notes"));
sysApi.setPath(item.get("path"));
sysApi.setServiceId(item.get("serviceId"));
SysApi exist = sysApiService.getByCode(sysApi.getCode());
if (ObjectUtils.isEmpty(exist)) {
sysApiService.save(sysApi);
} else {
LambdaQueryWrapper<SysApi> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(SysApi::getCode, sysApi.getCode());
sysApiService.update(sysApi, queryWrapper);
}
});
}
redisService.hdel(MateConstant.MATE_API_RESOURCE, service.toString());
}
redisService.del(MateConstant.MATE_SERVICE_RESOURCE);
return Result.condition(true);
}
use of vip.mate.core.log.annotation.Log in project matecloud by matevip.
the class SysBlacklistController method set.
/**
* 黑名单设置
* @param sysBlacklist SysBlacklist对象
* @return Result
*/
@PreAuth
@Log(value = "黑名单设置", exception = "黑名单设置请求异常")
@PostMapping("/set")
@ApiOperation(value = "黑名单设置", notes = "黑名单设置,支持新增或修改")
public Result<?> set(@Valid @RequestBody SysBlacklist sysBlacklist) {
BlackList blackList = new BlackList();
// 删除缓存
if (sysBlacklist.getId() != null) {
SysBlacklist b = sysBlacklistService.getById(sysBlacklist.getId());
BeanUtils.copyProperties(b, blackList);
ruleCacheService.deleteBlackList(blackList);
}
// 删除缓存
if (sysBlacklistService.saveOrUpdate(sysBlacklist)) {
// 缓存操作-----start
SysBlacklist blacklistCurr = sysBlacklistService.getById(sysBlacklist.getId());
BeanUtils.copyProperties(blacklistCurr, blackList);
ruleCacheService.setBlackList(blackList);
// 缓存操作----end
return Result.success("操作成功");
}
return Result.fail("操作失败");
}
use of vip.mate.core.log.annotation.Log in project matecloud by matevip.
the class SysAttachmentController method del.
/**
* 删除文件
* @param ids id多个采用逗号分隔
* @return
*/
@PreAuth
@Log(value = "删除文件")
@ApiOperation(value = "删除文件")
@ApiImplicitParams({ @ApiImplicitParam(name = "ids", required = true, value = "多个用,号隔开", paramType = "form") })
@PostMapping("/del")
public Result<?> del(@RequestParam String ids) {
Collection collection = CollectionUtil.stringToCollection(ids);
for (Iterator<Long> it = collection.iterator(); it.hasNext(); ) {
long id = it.next();
sysAttachmentService.delete(id);
}
return Result.success("删除成功");
}
use of vip.mate.core.log.annotation.Log in project matecloud by matevip.
the class SysRoleController method savePermission.
/**
* 角色权限设置
*
* @param roleId 角色Id
* @param ids 多个id使用逗号分隔
* @return Result
*/
@PreAuth
@Log(value = "角色权限设置", exception = "角色权限设置")
@PostMapping("/set-permission")
@ApiOperation(value = "角色权限设置", notes = "角色权限设置")
@ApiImplicitParams({ @ApiImplicitParam(name = "roleId", required = true, value = "角色ID", paramType = "form"), @ApiImplicitParam(name = "ids", required = true, value = "多个用,号隔开", paramType = "form") })
public Result<?> savePermission(@RequestParam String roleId, @RequestParam String ids) {
Collection longs = CollectionUtil.stringToCollection(ids);
long roleIdc = CollectionUtil.strToLong(roleId, 0L);
LambdaQueryWrapper<SysRolePermission> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(SysRolePermission::getRoleId, roleIdc);
sysRolePermissionService.remove(lambdaQueryWrapper);
for (Iterator<Long> it = longs.iterator(); it.hasNext(); ) {
SysRolePermission sysRolePermission = new SysRolePermission();
long menuId = it.next();
sysRolePermission.setMenuId(menuId);
sysRolePermission.setRoleId(roleIdc);
sysRolePermissionService.saveOrUpdate(sysRolePermission);
}
redisService.del("getPermission-" + roleId);
return Result.success("操作成功");
}
use of vip.mate.core.log.annotation.Log in project matecloud by matevip.
the class SysRoleController method allList.
/**
* 所有角色列表
*
* @return List
*/
@PreAuth
@Log(value = "所有角色列表")
@GetMapping("/all-list")
@ApiOperation(value = "所有角色列表")
public Result<?> allList() {
// 设置一个未授权的角色信息,提供给前端使用
SysRole sysRole = new SysRole();
sysRole.setId(NumberUtil.parseLong(SystemConstant.ROLE_DEFAULT_ID));
sysRole.setRoleName(SystemConstant.ROLE_DEFAULT_VALUE);
// 查询所有角色列表
List<SysRole> list = sysRoleService.list();
// 增加未授权角色信息
list.add(sysRole);
// 业务返回
return Result.data(list);
}
Aggregations