Java Code Examples for com.github.knightliao.apollo.utils.time.DateUtils#format()

The following examples show how to use com.github.knightliao.apollo.utils.time.DateUtils#format() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AppMgrImpl.java    From disconf with Apache License 2.0 6 votes vote down vote up
@Override
@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public App create(AppNewForm appNew) {

    // new app
    App app = new App();
    app.setName(appNew.getApp());
    app.setDesc(appNew.getDesc());
    app.setEmails(appNew.getEmails());

    String curTime = DateUtils.format(new Date(), DataFormatConstants.COMMON_TIME_FORMAT);
    app.setCreateTime(curTime);
    app.setUpdateTime(curTime);

    //
    return appDao.create(app);
}
 
Example 2
Source File: ConfigHistoryMgrImpl.java    From disconf with Apache License 2.0 6 votes vote down vote up
@Override
public void createOne(Long configId, String oldValue, String newValue) {

    ConfigHistory configHistory = new ConfigHistory();

    configHistory.setConfigId(configId);
    configHistory.setOldValue(oldValue);
    configHistory.setNewValue(newValue);

    Visitor visitor = ThreadContext.getSessionVisitor();
    if (visitor != null) {
        configHistory.setUpdateBy(visitor.getLoginUserId());
    }

    String curTime = DateUtils.format(new Date(), DataFormatConstants.COMMON_TIME_FORMAT);
    configHistory.setCreateTime(curTime);

    configHistoryDao.create(configHistory);
}
 
Example 3
Source File: AppMgrImpl.java    From disconf with Apache License 2.0 6 votes vote down vote up
@Override
@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public App create(AppNewForm appNew) {

    // new app
    App app = new App();
    app.setName(appNew.getApp());
    app.setDesc(appNew.getDesc());
    app.setEmails(appNew.getEmails());

    String curTime = DateUtils.format(new Date(), DataFormatConstants.COMMON_TIME_FORMAT);
    app.setCreateTime(curTime);
    app.setUpdateTime(curTime);

    //
    return appDao.create(app);
}
 
Example 4
Source File: ConfigHistoryMgrImpl.java    From disconf with Apache License 2.0 6 votes vote down vote up
@Override
public void createOne(Long configId, String oldValue, String newValue) {

    ConfigHistory configHistory = new ConfigHistory();

    configHistory.setConfigId(configId);
    configHistory.setOldValue(oldValue);
    configHistory.setNewValue(newValue);

    Visitor visitor = ThreadContext.getSessionVisitor();
    if (visitor != null) {
        configHistory.setUpdateBy(visitor.getLoginUserId());
    }

    String curTime = DateUtils.format(new Date(), DataFormatConstants.COMMON_TIME_FORMAT);
    configHistory.setCreateTime(curTime);

    configHistoryDao.create(configHistory);
}
 
Example 5
Source File: ConfigDaoImpl.java    From disconf with Apache License 2.0 5 votes vote down vote up
/**
 * @param configId
 */
@Override
public void deleteItem(Long configId) {
    String curTime = DateUtils.format(new Date(), DataFormatConstants.COMMON_TIME_FORMAT);
    List<Modify> modifyList = new ArrayList<Modify>();
    modifyList.add(modify(Columns.STATUS, Constants.STATUS_DELETE));
    modifyList.add(modify(Columns.UPDATE_TIME, curTime));

    update(modifyList, match(Columns.CONFIG_ID, configId));
}
 
Example 6
Source File: ConfigDaoImpl.java    From disconf with Apache License 2.0 5 votes vote down vote up
/**
 *
 */
@Override
public void updateValue(Long configId, String value) {

    // 时间
    String curTime = DateUtils.format(new Date(), DataFormatConstants.COMMON_TIME_FORMAT);

    List<Modify> modifyList = new ArrayList<Modify>();
    modifyList.add(modify(Columns.VALUE, value));
    modifyList.add(modify(Columns.UPDATE_TIME, curTime));

    update(modifyList, match(Columns.CONFIG_ID, configId));
}
 
Example 7
Source File: ConfigMgrImpl.java    From disconf with Apache License 2.0 5 votes vote down vote up
/**
 * 配置文件的整合
 *
 * @param confListForm
 *
 * @return
 */
public List<File> getDisconfFileList(ConfListForm confListForm) {

    List<Config> configList =
            configDao.getConfigList(confListForm.getAppId(), confListForm.getEnvId(), confListForm.getVersion(),
                    true);

    // 时间作为当前文件夹
    String curTime = DateUtils.format(new Date(), DataFormatConstants.COMMON_TIME_FORMAT);
    curTime = "tmp" + File.separator + curTime;
    OsUtil.makeDirs(curTime);

    List<File> files = new ArrayList<File>();
    for (Config config : configList) {

        if (config.getType().equals(DisConfigTypeEnum.FILE.getType())) {

            File file = new File(curTime, config.getName());
            try {
                FileUtils.writeByteArrayToFile(file, config.getValue().getBytes());
            } catch (IOException e) {
                LOG.warn(e.toString());
            }

            files.add(file);
        }
    }

    return files;
}
 
Example 8
Source File: ConfigMgrImpl.java    From disconf with Apache License 2.0 5 votes vote down vote up
/**
 * 新建配置
 */
@Override
public void newConfig(ConfNewItemForm confNewForm, DisConfigTypeEnum disConfigTypeEnum) {

    Config config = new Config();

    config.setAppId(confNewForm.getAppId());
    config.setEnvId(confNewForm.getEnvId());
    config.setName(confNewForm.getKey());
    config.setType(disConfigTypeEnum.getType());
    config.setVersion(confNewForm.getVersion());
    config.setValue(CodeUtils.utf8ToUnicode(confNewForm.getValue()));
    config.setStatus(Constants.STATUS_NORMAL);

    // 时间
    String curTime = DateUtils.format(new Date(), DataFormatConstants.COMMON_TIME_FORMAT);
    config.setCreateTime(curTime);
    config.setUpdateTime(curTime);

    configDao.create(config);
    configHistoryMgr.createOne(config.getId(), "", config.getValue());

    // 发送邮件通知
    //
    String toEmails = appMgr.getEmails(config.getAppId());
    if (applicationPropertyConfig.isEmailMonitorOn() == true) {
        logMailBean.sendHtmlEmail(toEmails, " config new", getNewValue(confNewForm.getValue(), config.toString(),
                getConfigUrlHtml(config)));
    }
}
 
Example 9
Source File: ConfigDaoImpl.java    From disconf with Apache License 2.0 5 votes vote down vote up
/**
 * @param configId
 */
@Override
public void deleteItem(Long configId) {
    String curTime = DateUtils.format(new Date(), DataFormatConstants.COMMON_TIME_FORMAT);
    List<Modify> modifyList = new ArrayList<Modify>();
    modifyList.add(modify(Columns.STATUS, Constants.STATUS_DELETE));
    modifyList.add(modify(Columns.UPDATE_TIME, curTime));

    update(modifyList, match(Columns.CONFIG_ID, configId));
}
 
Example 10
Source File: ConfigDaoImpl.java    From disconf with Apache License 2.0 5 votes vote down vote up
/**
 *
 */
@Override
public void updateValue(Long configId, String value) {

    // 时间
    String curTime = DateUtils.format(new Date(), DataFormatConstants.COMMON_TIME_FORMAT);

    List<Modify> modifyList = new ArrayList<Modify>();
    modifyList.add(modify(Columns.VALUE, value));
    modifyList.add(modify(Columns.UPDATE_TIME, curTime));

    update(modifyList, match(Columns.CONFIG_ID, configId));
}
 
Example 11
Source File: ConfigMgrImpl.java    From disconf with Apache License 2.0 5 votes vote down vote up
/**
 * 配置文件的整合
 *
 * @param confListForm
 *
 * @return
 */
public List<File> getDisconfFileList(ConfListForm confListForm) {

    List<Config> configList =
            configDao.getConfigList(confListForm.getAppId(), confListForm.getEnvId(), confListForm.getVersion(),true);

    // 时间作为当前文件夹
    String curTime = DateUtils.format(new Date(), DataFormatConstants.COMMON_TIME_FORMAT);
    curTime = "tmp" + File.separator + curTime;
    OsUtil.makeDirs(curTime);

    List<File> files = new ArrayList<File>();
    for (Config config : configList) {

        if (config.getType().equals(DisConfigTypeEnum.FILE.getType())) {

            File file = new File(curTime, config.getName());
            try {
                FileUtils.writeByteArrayToFile(file, config.getValue().getBytes());
            } catch (IOException e) {
                LOG.warn(e.toString());
            }

            files.add(file);
        }
    }

    return files;
}
 
Example 12
Source File: ConfigMgrImpl.java    From disconf with Apache License 2.0 5 votes vote down vote up
/**
 * 新建配置
 */
@Override
public void newConfig(ConfNewItemForm confNewForm, DisConfigTypeEnum disConfigTypeEnum) {

    Config config = new Config();

    config.setAppId(confNewForm.getAppId());
    config.setEnvId(confNewForm.getEnvId());
    config.setName(confNewForm.getKey());
    config.setType(disConfigTypeEnum.getType());
    config.setVersion(confNewForm.getVersion());
    config.setValue(CodeUtils.utf8ToUnicode(confNewForm.getValue()));
    config.setStatus(Constants.STATUS_NORMAL);

    // 时间
    String curTime = DateUtils.format(new Date(), DataFormatConstants.COMMON_TIME_FORMAT);
    config.setCreateTime(curTime);
    config.setUpdateTime(curTime);

    configDao.create(config);
    configHistoryMgr.createOne(config.getId(), "", config.getValue());

    // 发送邮件通知
    //
    String toEmails = appMgr.getEmails(config.getAppId());
    if (applicationPropertyConfig.isEmailMonitorOn() == true) {
        logMailBean.sendHtmlEmail(toEmails, " config new", getNewValue(confNewForm.getValue(), config.toString(),
                getConfigUrlHtml(config)));
    }
}