Search in sources :

Example 51 with LambdaQueryWrapper

use of com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper in project usercenteradmin by caijiya.

the class RoleServiceImpl method grantMenus.

@Override
@Transactional(rollbackFor = Exception.class)
public void grantMenus(GrantMenuDTO grantMenuDTO) {
    roleMenuRelService.remove(new LambdaQueryWrapper<RoleMenuRel>().eq(RoleMenuRel::getRoleId, grantMenuDTO.getRoleId()));
    roleMenuRelService.saveBatch(grantMenuDTO.getMenuIds().stream().map(menuId -> {
        RoleMenuRel roleMenuRel = new RoleMenuRel();
        roleMenuRel.setRoleId(roleMenuRel.getRoleId());
        roleMenuRel.setMenuId(menuId);
        return roleMenuRel;
    }).collect(Collectors.toList()));
}
Also used : RoleMenuRel(com.zy.usercenteradmin.entity.RoleMenuRel) LambdaQueryWrapper(com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper) Transactional(org.springframework.transaction.annotation.Transactional)

Example 52 with LambdaQueryWrapper

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

the class WebSideMessageServiceImpl method setAllRead.

@Override
public Integer setAllRead() {
    WebSideMessageDO update = new WebSideMessageDO();
    update.setReadStatus(ReadStatus.READ.getStatus());
    LambdaQueryWrapper<WebSideMessageDO> wrapper = new LambdaQueryWrapper<WebSideMessageDO>().eq(WebSideMessageDO::getToUserId, Currents.getUserId()).eq(WebSideMessageDO::getReadStatus, ReadStatus.UNREAD.getStatus());
    return webSideMessageDAO.update(update, wrapper);
}
Also used : WebSideMessageDO(com.orion.ops.entity.domain.WebSideMessageDO) LambdaQueryWrapper(com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)

Example 53 with LambdaQueryWrapper

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

the class MachineEnvServiceImpl method syncMachineEnv.

@Override
@Transactional(rollbackFor = Exception.class)
public void syncMachineEnv(MachineEnvRequest request) {
    Long id = request.getId();
    Long machineId = request.getMachineId();
    List<Long> targetMachineIdList = request.getTargetMachineIdList();
    // 获取self
    MachineEnvService self = SpringHolder.getBean(MachineEnvService.class);
    List<MachineEnvDO> envList;
    if (Const.N_N_L_1.equals(id)) {
        // 全量同步
        LambdaQueryWrapper<MachineEnvDO> wrapper = new LambdaQueryWrapper<MachineEnvDO>().eq(MachineEnvDO::getMachineId, machineId).orderByAsc(MachineEnvDO::getUpdateTime);
        envList = machineEnvDAO.selectList(wrapper);
    } else {
        // 查询数据
        MachineEnvDO env = machineEnvDAO.selectById(id);
        Valid.notNull(env, MessageConst.UNKNOWN_DATA);
        envList = Lists.singleton(env);
    }
    // 同步
    for (Long targetMachineId : targetMachineIdList) {
        for (MachineEnvDO syncEnv : envList) {
            MachineEnvRequest addRequest = new MachineEnvRequest();
            addRequest.setMachineId(targetMachineId);
            addRequest.setKey(syncEnv.getAttrKey());
            addRequest.setValue(syncEnv.getAttrValue());
            addRequest.setDescription(syncEnv.getDescription());
            self.addEnv(addRequest);
        }
    }
    // 设置日志参数
    EventParamsHolder.addParams(request);
    EventParamsHolder.addParam(EventKeys.ENV_COUNT, envList.size());
    EventParamsHolder.addParam(EventKeys.MACHINE_COUNT, targetMachineIdList.size());
}
Also used : MachineEnvService(com.orion.ops.service.api.MachineEnvService) MachineEnvRequest(com.orion.ops.entity.request.MachineEnvRequest) MachineEnvDO(com.orion.ops.entity.domain.MachineEnvDO) LambdaQueryWrapper(com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper) Transactional(org.springframework.transaction.annotation.Transactional)

Example 54 with LambdaQueryWrapper

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

the class CleanTransferStatusRunner method run.

@Override
public void run(String... args) {
    log.info("重置传输状态-开始");
    // 更新可打包传输状态
    LambdaQueryWrapper<FileTransferLogDO> packageWrapper = new LambdaQueryWrapper<FileTransferLogDO>().eq(FileTransferLogDO::getTransferType, SftpTransferType.PACKAGE.getType()).in(FileTransferLogDO::getTransferStatus, SftpTransferStatus.WAIT.getStatus(), SftpTransferStatus.RUNNABLE.getStatus());
    FileTransferLogDO updatePackage = new FileTransferLogDO();
    updatePackage.setTransferStatus(SftpTransferStatus.CANCEL.getStatus());
    updatePackage.setUpdateTime(new Date());
    fileTransferLogDAO.update(updatePackage, packageWrapper);
    // 更新可恢复传输状态
    LambdaQueryWrapper<FileTransferLogDO> resumeWrapper = new LambdaQueryWrapper<FileTransferLogDO>().ne(FileTransferLogDO::getTransferType, SftpTransferType.PACKAGE.getType()).in(FileTransferLogDO::getTransferStatus, SftpTransferStatus.WAIT.getStatus(), SftpTransferStatus.RUNNABLE.getStatus());
    FileTransferLogDO updateResume = new FileTransferLogDO();
    updateResume.setTransferStatus(SftpTransferStatus.PAUSE.getStatus());
    updateResume.setUpdateTime(new Date());
    fileTransferLogDAO.update(updateResume, resumeWrapper);
    log.info("重置传输状态-结束");
}
Also used : FileTransferLogDO(com.orion.ops.entity.domain.FileTransferLogDO) Date(java.util.Date) LambdaQueryWrapper(com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)

Example 55 with LambdaQueryWrapper

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

the class MachineInfoServiceImpl method copyMachine.

@Override
public Long copyMachine(Long id) {
    MachineInfoDO machine = machineInfoDAO.selectById(id);
    Valid.notNull(machine, MessageConst.INVALID_MACHINE);
    String sourceMachineName = machine.getMachineName();
    String targetMachineName = sourceMachineName + Utils.getCopySuffix();
    machine.setId(null);
    machine.setCreateTime(null);
    machine.setUpdateTime(null);
    machine.setMachineName(targetMachineName);
    machineInfoDAO.insert(machine);
    Long insertId = machine.getId();
    // 复制环境变量
    LambdaQueryWrapper<MachineEnvDO> wrapper = new LambdaQueryWrapper<MachineEnvDO>().eq(MachineEnvDO::getMachineId, id).orderByAsc(MachineEnvDO::getUpdateTime);
    machineEnvDAO.selectList(wrapper).forEach(e -> {
        // 插入环境变量
        e.setMachineId(insertId);
        e.setCreateTime(null);
        e.setUpdateTime(null);
        machineEnvDAO.insert(e);
        // 插入历史值
        historyValueService.addHistory(e.getId(), HistoryValueType.MACHINE_ENV, HistoryOperator.ADD, null, e.getAttrValue());
    });
    // 设置日志参数
    EventParamsHolder.addParam(EventKeys.ID, id);
    EventParamsHolder.addParam(EventKeys.SOURCE, sourceMachineName);
    EventParamsHolder.addParam(EventKeys.TARGET, targetMachineName);
    return insertId;
}
Also used : MachineInfoDO(com.orion.ops.entity.domain.MachineInfoDO) MachineEnvDO(com.orion.ops.entity.domain.MachineEnvDO) 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