Search in sources :

Example 1 with Modify

use of com.baidu.unbiz.common.genericdao.operator.Modify in project disconf by knightliao.

the class ConfigDaoImpl method updateValue.

/**
     *
     */
@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));
}
Also used : ArrayList(java.util.ArrayList) Modify(com.baidu.unbiz.common.genericdao.operator.Modify) Date(java.util.Date)

Example 2 with Modify

use of com.baidu.unbiz.common.genericdao.operator.Modify in project disconf by knightliao.

the class QueryGenerator method appendModifytoSQL.

/**
     * @param modifies
     * @param sb
     * @param params
     */
private void appendModifytoSQL(List<Modify> modifies, StringBuilder sb, List<Object> params) {
    for (Modify modify : modifies) {
        sb.append(modify.getColumn());
        Object value = modify.getValue();
        if (value instanceof IncrParam) {
            sb.append("=(").append(modify.getColumn()).append("+?),");
            params.add(((IncrParam) value).getValue());
        } else if (value instanceof ExpressionParam) {
            sb.append(',');
        } else {
            sb.append("=?,");
            params.add(value);
        }
    }
}
Also used : IncrParam(com.baidu.unbiz.common.genericdao.param.IncrParam) Modify(com.baidu.unbiz.common.genericdao.operator.Modify) BaseObject(com.github.knightliao.apollo.db.bo.BaseObject) ExpressionParam(com.baidu.unbiz.common.genericdao.param.ExpressionParam)

Example 3 with Modify

use of com.baidu.unbiz.common.genericdao.operator.Modify in project disconf by knightliao.

the class QueryGenerator method getUpdateQuery.

public List<Query> getUpdateQuery(List<ENTITY> entities) {
    List<Query> queries = new ArrayList<Query>(entities.size());
    Set<String> modifiableColumns = orMapping.getModifiableColumns();
    for (ENTITY entity : entities) {
        List<Match> matches = getKeyMatches(entity.getId());
        List<Modify> modifies = new ArrayList<Modify>(modifiableColumns.size());
        for (String column : modifiableColumns) {
            Object value = getColumnValue(column, entity);
            modifies.add(new Modify(column, value));
        }
        queries.add(getUpdateQuery(modifies, matches));
    }
    return queries;
}
Also used : Query(com.baidu.unbiz.common.genericdao.operator.Query) ArrayList(java.util.ArrayList) Modify(com.baidu.unbiz.common.genericdao.operator.Modify) BaseObject(com.github.knightliao.apollo.db.bo.BaseObject) Match(com.baidu.unbiz.common.genericdao.operator.Match)

Example 4 with Modify

use of com.baidu.unbiz.common.genericdao.operator.Modify in project disconf by knightliao.

the class ConfigDaoImpl method deleteItem.

/**
     * @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));
}
Also used : ArrayList(java.util.ArrayList) Modify(com.baidu.unbiz.common.genericdao.operator.Modify) Date(java.util.Date)

Aggregations

Modify (com.baidu.unbiz.common.genericdao.operator.Modify)4 ArrayList (java.util.ArrayList)3 BaseObject (com.github.knightliao.apollo.db.bo.BaseObject)2 Date (java.util.Date)2 Match (com.baidu.unbiz.common.genericdao.operator.Match)1 Query (com.baidu.unbiz.common.genericdao.operator.Query)1 ExpressionParam (com.baidu.unbiz.common.genericdao.param.ExpressionParam)1 IncrParam (com.baidu.unbiz.common.genericdao.param.IncrParam)1