Search in sources :

Example 1 with ApplicationEnvDO

use of com.orion.ops.entity.domain.ApplicationEnvDO in project orion-ops by lijiahangmax.

the class ApplicationEnvServiceImpl method updateAppEnv.

@Override
@Transactional(rollbackFor = Exception.class)
public Integer updateAppEnv(ApplicationEnvRequest request) {
    // 查询
    ApplicationEnvDO before = applicationEnvDAO.selectById(request.getId());
    Valid.notNull(before, MessageConst.ENV_ABSENT);
    return SpringHolder.getBean(ApplicationEnvService.class).updateAppEnv(before, request);
}
Also used : ApplicationEnvDO(com.orion.ops.entity.domain.ApplicationEnvDO) ApplicationEnvService(com.orion.ops.service.api.ApplicationEnvService) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with ApplicationEnvDO

use of com.orion.ops.entity.domain.ApplicationEnvDO in project orion-ops by lijiahangmax.

the class ApplicationEnvServiceImpl method getAppEnvDetail.

@Override
public ApplicationEnvVO getAppEnvDetail(Long id) {
    ApplicationEnvDO env = applicationEnvDAO.selectById(id);
    Valid.notNull(env, MessageConst.UNKNOWN_DATA);
    return Converts.to(env, ApplicationEnvVO.class);
}
Also used : ApplicationEnvDO(com.orion.ops.entity.domain.ApplicationEnvDO)

Example 3 with ApplicationEnvDO

use of com.orion.ops.entity.domain.ApplicationEnvDO 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 4 with ApplicationEnvDO

use of com.orion.ops.entity.domain.ApplicationEnvDO in project orion-ops by lijiahangmax.

the class ApplicationEnvServiceImpl method deleteAppEnv.

@Override
@Transactional(rollbackFor = Exception.class)
public Integer deleteAppEnv(List<Long> idList) {
    int effect = 0;
    for (Long id : idList) {
        // 获取元数据
        ApplicationEnvDO env = applicationEnvDAO.selectById(id);
        Valid.notNull(env, MessageConst.ENV_ABSENT);
        String key = env.getAttrKey();
        Valid.isTrue(ApplicationEnvAttr.of(key) == null, "{} " + MessageConst.FORBID_DELETE, key);
        // 删除
        effect += applicationEnvDAO.deleteById(id);
        // 插入历史值
        historyValueService.addHistory(id, HistoryValueType.APP_ENV, HistoryOperator.DELETE, env.getAttrValue(), null);
    }
    // 设置日志参数
    EventParamsHolder.addParam(EventKeys.ID_LIST, idList);
    EventParamsHolder.addParam(EventKeys.COUNT, effect);
    return effect;
}
Also used : ApplicationEnvDO(com.orion.ops.entity.domain.ApplicationEnvDO) Transactional(org.springframework.transaction.annotation.Transactional)

Example 5 with ApplicationEnvDO

use of com.orion.ops.entity.domain.ApplicationEnvDO in project orion-ops by lijiahangmax.

the class ApplicationEnvServiceImpl method checkInitSystemEnv.

@Override
@Transactional(rollbackFor = Exception.class)
public void checkInitSystemEnv(Long appId, Long profileId) {
    List<ApplicationEnvDO> list = Lists.newList();
    String buildSeqValue = this.getAppEnvValue(appId, profileId, ApplicationEnvAttr.BUILD_SEQ.getKey());
    if (buildSeqValue == null) {
        // 构建序列
        ApplicationEnvDO buildSeq = ApplicationEnvAttr.BUILD_SEQ.getInitEnv();
        buildSeq.setAppId(appId);
        buildSeq.setProfileId(profileId);
        list.add(buildSeq);
    }
    // 插入
    list.forEach(applicationEnvDAO::insert);
}
Also used : ApplicationEnvDO(com.orion.ops.entity.domain.ApplicationEnvDO) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

ApplicationEnvDO (com.orion.ops.entity.domain.ApplicationEnvDO)8 Transactional (org.springframework.transaction.annotation.Transactional)7 ApplicationEnvService (com.orion.ops.service.api.ApplicationEnvService)4 LambdaQueryWrapper (com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)1 ApplicationEnvRequest (com.orion.ops.entity.request.ApplicationEnvRequest)1 Date (java.util.Date)1