Search in sources :

Example 1 with Log

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);
}
Also used : List(java.util.List) Map(java.util.Map) SysApi(vip.mate.system.entity.SysApi) LambdaQueryWrapper(com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper) PreAuth(vip.mate.core.auth.annotation.PreAuth) Log(vip.mate.core.log.annotation.Log) ApiOperation(io.swagger.annotations.ApiOperation)

Example 2 with Log

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("操作失败");
}
Also used : SysBlacklist(vip.mate.system.entity.SysBlacklist) BlackList(vip.mate.core.rule.entity.BlackList) PreAuth(vip.mate.core.auth.annotation.PreAuth) Log(vip.mate.core.log.annotation.Log) ApiOperation(io.swagger.annotations.ApiOperation)

Example 3 with Log

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("删除成功");
}
Also used : Collection(java.util.Collection) PreAuth(vip.mate.core.auth.annotation.PreAuth) ApiImplicitParams(io.swagger.annotations.ApiImplicitParams) Log(vip.mate.core.log.annotation.Log) ApiOperation(io.swagger.annotations.ApiOperation)

Example 4 with Log

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("操作成功");
}
Also used : SysRolePermission(vip.mate.system.entity.SysRolePermission) Collection(java.util.Collection) LambdaQueryWrapper(com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper) PreAuth(vip.mate.core.auth.annotation.PreAuth) ApiImplicitParams(io.swagger.annotations.ApiImplicitParams) Log(vip.mate.core.log.annotation.Log) ApiOperation(io.swagger.annotations.ApiOperation)

Example 5 with Log

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);
}
Also used : SysRole(vip.mate.system.entity.SysRole) PreAuth(vip.mate.core.auth.annotation.PreAuth) Log(vip.mate.core.log.annotation.Log) ApiOperation(io.swagger.annotations.ApiOperation)

Aggregations

Log (vip.mate.core.log.annotation.Log)13 ApiOperation (io.swagger.annotations.ApiOperation)11 PreAuth (vip.mate.core.auth.annotation.PreAuth)8 ApiImplicitParams (io.swagger.annotations.ApiImplicitParams)4 Collection (java.util.Collection)3 LambdaQueryWrapper (com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)2 Method (java.lang.reflect.Method)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 PostMapping (org.springframework.web.bind.annotation.PostMapping)2 SysDataSource (vip.mate.code.entity.SysDataSource)2 CommonLog (vip.mate.core.common.dto.CommonLog)2 LogEvent (vip.mate.core.log.event.LogEvent)2 BlackList (vip.mate.core.rule.entity.BlackList)2 SysBlacklist (vip.mate.system.entity.SysBlacklist)2 JSONObject (com.alibaba.fastjson.JSONObject)1 ConfigBuilder (com.baomidou.mybatisplus.generator.config.builder.ConfigBuilder)1 TableInfo (com.baomidou.mybatisplus.generator.config.po.TableInfo)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1