Search in sources :

Example 56 with LambdaQueryWrapper

use of com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper in project orion-ops by lijiahangmax.

the class ApplicationEnvServiceImpl method syncAppEnv.

@Override
@Transactional(rollbackFor = Exception.class)
public void syncAppEnv(Long id, Long appId, Long profileId, List<Long> targetProfileIdList) {
    ApplicationEnvService self = SpringHolder.getBean(ApplicationEnvService.class);
    List<ApplicationEnvDO> envList;
    // 查询数据
    if (Const.N_N_L_1.equals(id)) {
        // 全量同步
        LambdaQueryWrapper<ApplicationEnvDO> wrapper = new LambdaQueryWrapper<ApplicationEnvDO>().eq(ApplicationEnvDO::getAppId, appId).eq(ApplicationEnvDO::getProfileId, profileId).eq(ApplicationEnvDO::getSystemEnv, Const.NOT_SYSTEM).orderByAsc(ApplicationEnvDO::getUpdateTime);
        envList = applicationEnvDAO.selectList(wrapper);
    } else {
        // 查询数据
        ApplicationEnvDO env = applicationEnvDAO.selectById(id);
        Valid.notNull(env, MessageConst.UNKNOWN_DATA);
        envList = Lists.singleton(env);
    }
    // 同步数据
    for (Long targetProfileId : targetProfileIdList) {
        // 同步环境变量
        for (ApplicationEnvDO syncEnv : envList) {
            ApplicationEnvRequest request = new ApplicationEnvRequest();
            request.setAppId(syncEnv.getAppId());
            request.setProfileId(targetProfileId);
            request.setKey(syncEnv.getAttrKey());
            request.setValue(syncEnv.getAttrValue());
            request.setDescription(syncEnv.getDescription());
            self.addAppEnv(request);
        }
        // 初始化系统变量
        self.checkInitSystemEnv(appId, targetProfileId);
    }
    // 设置日志参数
    EventParamsHolder.addParam(EventKeys.ID, id);
    EventParamsHolder.addParam(EventKeys.APP_ID, appId);
    EventParamsHolder.addParam(EventKeys.PROFILE_ID, profileId);
    EventParamsHolder.addParam(EventKeys.ID_LIST, targetProfileIdList);
    EventParamsHolder.addParam(EventKeys.ENV_COUNT, envList.size());
    EventParamsHolder.addParam(EventKeys.PROFILE_COUNT, targetProfileIdList.size());
}
Also used : ApplicationEnvRequest(com.orion.ops.entity.request.ApplicationEnvRequest) ApplicationEnvDO(com.orion.ops.entity.domain.ApplicationEnvDO) ApplicationEnvService(com.orion.ops.service.api.ApplicationEnvService) LambdaQueryWrapper(com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper) Transactional(org.springframework.transaction.annotation.Transactional)

Example 57 with LambdaQueryWrapper

use of com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper 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 58 with LambdaQueryWrapper

use of com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper 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 59 with LambdaQueryWrapper

use of com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper in project matecloud by matevip.

the class SysClientServiceImpl method export.

@Override
public List<SysClientPOI> export() {
    LambdaQueryWrapper<SysClient> queryWrapper = new LambdaQueryWrapper<>();
    queryWrapper.eq(SysClient::getIsDeleted, 0);
    List<SysClient> sysClients = this.baseMapper.selectList(queryWrapper);
    return sysClients.stream().map(sysClient -> {
        SysClientPOI sysClientPOI = new SysClientPOI();
        BeanUtils.copyProperties(sysClient, sysClientPOI);
        return sysClientPOI;
    }).collect(Collectors.toList());
}
Also used : ServiceImpl(com.baomidou.mybatisplus.extension.service.impl.ServiceImpl) Wrappers(com.baomidou.mybatisplus.core.toolkit.Wrappers) Search(vip.mate.core.database.entity.Search) SysClientMapper(vip.mate.system.mapper.SysClientMapper) Collection(java.util.Collection) LambdaQueryWrapper(com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper) PageUtil(vip.mate.core.database.util.PageUtil) Collectors(java.util.stream.Collectors) Serializable(java.io.Serializable) StrUtil(cn.hutool.core.util.StrUtil) SysClient(vip.mate.system.entity.SysClient) List(java.util.List) Service(org.springframework.stereotype.Service) IPage(com.baomidou.mybatisplus.core.metadata.IPage) ISysClientService(vip.mate.system.service.ISysClientService) BeanUtils(org.springframework.beans.BeanUtils) CollectionUtil(vip.mate.core.web.util.CollectionUtil) SysClientPOI(vip.mate.system.poi.SysClientPOI) SysClientPOI(vip.mate.system.poi.SysClientPOI) SysClient(vip.mate.system.entity.SysClient) LambdaQueryWrapper(com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)

Example 60 with LambdaQueryWrapper

use of com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper in project matecloud by matevip.

the class SysDepartServiceImpl method export.

@Override
public List<SysDepartPOI> export() {
    LambdaQueryWrapper<SysDepart> queryWrapper = new LambdaQueryWrapper<>();
    queryWrapper.eq(SysDepart::getIsDeleted, 0);
    List<SysDepart> sysDeparts = this.baseMapper.selectList(queryWrapper);
    return sysDeparts.stream().map(sysDepart -> {
        SysDepartPOI sysDepartPOI = new SysDepartPOI();
        BeanUtils.copyProperties(sysDepart, sysDepartPOI);
        return sysDepartPOI;
    }).collect(Collectors.toList());
}
Also used : ServiceImpl(com.baomidou.mybatisplus.extension.service.impl.ServiceImpl) Wrappers(com.baomidou.mybatisplus.core.toolkit.Wrappers) SysDepart(vip.mate.system.entity.SysDepart) SysDepartMapper(vip.mate.system.mapper.SysDepartMapper) SysDepartVO(vip.mate.system.vo.SysDepartVO) LambdaQueryWrapper(com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) StrUtil(cn.hutool.core.util.StrUtil) ISysDepartService(vip.mate.system.service.ISysDepartService) List(java.util.List) Service(org.springframework.stereotype.Service) Map(java.util.Map) DepartDTO(vip.mate.system.dto.DepartDTO) ForestNodeMerger(vip.mate.core.web.tree.ForestNodeMerger) SysDepartPOI(vip.mate.system.poi.SysDepartPOI) BeanUtils(org.springframework.beans.BeanUtils) SysDepartPOI(vip.mate.system.poi.SysDepartPOI) SysDepart(vip.mate.system.entity.SysDepart) LambdaQueryWrapper(com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)

Aggregations

LambdaQueryWrapper (com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)381 Transactional (org.springframework.transaction.annotation.Transactional)60 JSONObject (com.alibaba.fastjson.JSONObject)52 Result (org.jeecg.common.api.vo.Result)50 ArrayList (java.util.ArrayList)42 List (java.util.List)30 Map (java.util.Map)29 Collectors (java.util.stream.Collectors)26 Service (org.springframework.stereotype.Service)24 LoginUser (org.jeecg.common.system.vo.LoginUser)22 SysPermission (org.jeecg.modules.system.entity.SysPermission)22 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)22 QueryWrapper (com.baomidou.mybatisplus.core.conditions.query.QueryWrapper)21 IPage (com.baomidou.mybatisplus.core.metadata.IPage)20 HashMap (java.util.HashMap)20 SysUser (org.jeecg.modules.system.entity.SysUser)20 ApiOperation (io.swagger.annotations.ApiOperation)19 ServiceException (cn.lili.common.exception.ServiceException)18 ServiceImpl (com.baomidou.mybatisplus.extension.service.impl.ServiceImpl)18 Autowired (org.springframework.beans.factory.annotation.Autowired)18