Search in sources :

Example 1 with EvidenceSaveServiceCopy

use of com.itrus.portal.db.EvidenceSaveServiceCopy in project portal by ixinportal.

the class SaveServiceImpl method selectByEvidenceSaveServiceCopy.

/**
 * 得到对应存证服务的第二条数据
 * @param id
 * @return
 */
public EvidenceSaveServiceCopy selectByEvidenceSaveServiceCopy(Long id) {
    EvidenceSaveServiceCopyExample ece = new EvidenceSaveServiceCopyExample();
    EvidenceSaveServiceCopyExample.Criteria ecec = ece.createCriteria();
    ecec.andAppServiceEqualTo(id);
    List<EvidenceSaveServiceCopy> ecList = sqlSession.selectList("com.itrus.portal.db.EvidenceSaveServiceCopyMapper.selectByExample", ece);
    if (ecList == null || ecList.isEmpty()) {
        return null;
    }
    return ecList.get(0);
}
Also used : EvidenceSaveServiceCopy(com.itrus.portal.db.EvidenceSaveServiceCopy) EvidenceSaveServiceCopyExample(com.itrus.portal.db.EvidenceSaveServiceCopyExample)

Example 2 with EvidenceSaveServiceCopy

use of com.itrus.portal.db.EvidenceSaveServiceCopy in project portal by ixinportal.

the class SaveServiceImpl method saveEvidenceSaveService.

/**
 * 保存新存证服务
 * @param saveService
 * @param appService
 * @param adminId
 */
public void saveEvidenceSaveService(EvidenceSaveService saveService, AppService appService, Long adminId) {
    DefaultTransactionDefinition def = new DefaultTransactionDefinition();
    def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
    TransactionStatus status = transactionManager.getTransaction(def);
    try {
        // 存储应用服务配置
        appService.setIsDelete(false);
        appService.setServiceConfigName("EvidenceSaveService");
        appService.setCreator(adminId);
        appService.setType(2L);
        appService.setCreateTime(new Date());
        sqlSession.insert("com.itrus.portal.db.AppServiceMapper.insert", appService);
        sqlSession.flushStatements();
        // 存储存证服务配置
        saveService.setAppService(appService.getId());
        sqlSession.insert("com.itrus.portal.db.EvidenceSaveServiceMapper.insert", saveService);
        sqlSession.flushStatements();
        // 复制一份存证服务
        EvidenceSaveServiceCopy saveServiceCopy = new EvidenceSaveServiceCopy();
        saveServiceCopy.setEncryptionWay(saveService.getEncryptionWay());
        saveServiceCopy.setFixationWay(saveService.getFixationWay());
        saveServiceCopy.setSaveTime(saveService.getSaveTime());
        saveServiceCopy.setBaseSpace(saveService.getBaseSpace());
        saveServiceCopy.setFactorBusinessInfo(saveService.getFactorBusinessInfo());
        saveServiceCopy.setFactorIdVerify(saveService.getFactorIdVerify());
        saveServiceCopy.setFactorEventVerify(saveService.getFactorEventVerify());
        saveServiceCopy.setFactorCertSave(saveService.getFactorCertSave());
        saveServiceCopy.setFactorContent(saveService.getFactorContent());
        saveServiceCopy.setAppService(saveService.getAppService());
        sqlSession.insert("com.itrus.portal.db.EvidenceSaveServiceCopyMapper.insert", saveServiceCopy);
        sqlSession.flushStatements();
        // 应用服务设置对应的存证服务
        appService.setServiceConfigId(saveService.getId());
        appServiceImpl.updateByAppService(appService);
        transactionManager.commit(status);
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        if (!status.isCompleted())
            transactionManager.rollback(status);
    }
}
Also used : DefaultTransactionDefinition(org.springframework.transaction.support.DefaultTransactionDefinition) EvidenceSaveServiceCopy(com.itrus.portal.db.EvidenceSaveServiceCopy) TransactionStatus(org.springframework.transaction.TransactionStatus) Date(java.util.Date)

Example 3 with EvidenceSaveServiceCopy

use of com.itrus.portal.db.EvidenceSaveServiceCopy in project portal by ixinportal.

the class SaveServiceImpl method updateEvidenceSaveService.

/**
 * 修改存证服务
 * @param evidenceSaveService
 * @param appService
 * @param id
 */
public void updateEvidenceSaveService(EvidenceSaveService evidenceSaveService, AppService appService, Long id) {
    DefaultTransactionDefinition def = new DefaultTransactionDefinition();
    def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
    TransactionStatus status = transactionManager.getTransaction(def);
    try {
        // 修改存证服务配置表
        EvidenceSaveService evidenceSaveService0 = selectById(evidenceSaveService.getId());
        evidenceSaveService.setAppService(evidenceSaveService0.getAppService());
        sqlSession.update("com.itrus.portal.db.EvidenceSaveServiceMapper.updateByPrimaryKey", evidenceSaveService);
        // 根据服务id获取第二次存证服务
        EvidenceSaveServiceCopy evidenceSaveServiceCopy = selectByEvidenceSaveServiceCopy(appService.getId());
        evidenceSaveServiceCopy.setEncryptionWay(evidenceSaveService.getEncryptionWay());
        evidenceSaveServiceCopy.setFixationWay(evidenceSaveService.getFixationWay());
        evidenceSaveServiceCopy.setSaveTime(evidenceSaveService.getSaveTime());
        evidenceSaveServiceCopy.setBaseSpace(evidenceSaveService.getBaseSpace());
        evidenceSaveServiceCopy.setFactorBusinessInfo(evidenceSaveService.getFactorBusinessInfo());
        evidenceSaveServiceCopy.setFactorIdVerify(evidenceSaveService.getFactorIdVerify());
        evidenceSaveServiceCopy.setFactorEventVerify(evidenceSaveService.getFactorEventVerify());
        evidenceSaveServiceCopy.setFactorCertSave(evidenceSaveService.getFactorCertSave());
        evidenceSaveServiceCopy.setFactorContent(evidenceSaveService.getFactorContent());
        evidenceSaveServiceCopy.setAppService(evidenceSaveService.getAppService());
        sqlSession.update("com.itrus.portal.db.EvidenceSaveServiceCopyMapper.updateByPrimaryKey", evidenceSaveServiceCopy);
        // 修改应用服务表
        AppService appService0 = appServiceImpl.selectById(appService.getId());
        appService.setCreator(appService0.getCreator());
        appService.setCreateTime(appService0.getCreateTime());
        appService.setType(appService0.getType());
        appService.setServiceConfigName(appService0.getServiceConfigName());
        appService.setServiceConfigId(appService0.getServiceConfigId());
        appService.setModifyTime(new Date());
        appService.setModifier(id);
        appService.setIsDelete(appService0.getIsDelete());
        sqlSession.update("com.itrus.portal.db.AppServiceMapper.updateByPrimaryKey", appService);
        sqlSession.flushStatements();
        transactionManager.commit(status);
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        if (!status.isCompleted())
            transactionManager.rollback(status);
    }
}
Also used : AppService(com.itrus.portal.db.AppService) DefaultTransactionDefinition(org.springframework.transaction.support.DefaultTransactionDefinition) EvidenceSaveServiceCopy(com.itrus.portal.db.EvidenceSaveServiceCopy) TransactionStatus(org.springframework.transaction.TransactionStatus) EvidenceSaveService(com.itrus.portal.db.EvidenceSaveService) Date(java.util.Date)

Example 4 with EvidenceSaveServiceCopy

use of com.itrus.portal.db.EvidenceSaveServiceCopy in project portal by ixinportal.

the class SaveServiceImpl method deleteAppServiceAuthentication.

/**
 * 删除存证服务
 * @param serviceId
 * @param saveServiceId
 */
public void deleteAppServiceAuthentication(Long serviceId, Long saveServiceId) {
    DefaultTransactionDefinition def = new DefaultTransactionDefinition();
    def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
    TransactionStatus status = transactionManager.getTransaction(def);
    try {
        EvidenceSaveServiceCopy saveServiceCopy = selectByEvidenceSaveServiceCopy(serviceId);
        deleteEvidenceSaveServiceCopyById(saveServiceCopy.getId());
        deleteEvidenceSaveServiceById(saveServiceId);
        appServiceImpl.deleteAppServiceById(serviceId);
        transactionManager.commit(status);
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        if (!status.isCompleted())
            transactionManager.rollback(status);
    }
}
Also used : DefaultTransactionDefinition(org.springframework.transaction.support.DefaultTransactionDefinition) EvidenceSaveServiceCopy(com.itrus.portal.db.EvidenceSaveServiceCopy) TransactionStatus(org.springframework.transaction.TransactionStatus)

Aggregations

EvidenceSaveServiceCopy (com.itrus.portal.db.EvidenceSaveServiceCopy)4 TransactionStatus (org.springframework.transaction.TransactionStatus)3 DefaultTransactionDefinition (org.springframework.transaction.support.DefaultTransactionDefinition)3 Date (java.util.Date)2 AppService (com.itrus.portal.db.AppService)1 EvidenceSaveService (com.itrus.portal.db.EvidenceSaveService)1 EvidenceSaveServiceCopyExample (com.itrus.portal.db.EvidenceSaveServiceCopyExample)1