All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.zcj.web.mybatis.action.BasicAction Maven / Gradle / Ivy

package com.zcj.web.mybatis.action;

import com.zcj.util.UtilDate;
import com.zcj.util.UtilString;
import com.zcj.web.mybatis.service.BasicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;

import java.beans.PropertyEditorSupport;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@Deprecated
public class BasicAction {

    @Autowired
    protected S basicService;

    @InitBinder
    public void initBinder(WebDataBinder binder) {
        binder.setAutoGrowCollectionLimit(10000);
        binder.registerCustomEditor(Date.class, new DateEditor());
    }

    private class DateEditor extends PropertyEditorSupport {
        @Override
        public void setAsText(String text) {
            Date date = UtilDate.format(text);
            setValue(date);
        }
    }

    protected Map initQbuilder(String key, Object value) {
        Map query = new HashMap<>(16);
        if (UtilString.isNotBlank(key) && value != null) {
            query.put(key, value);
        }
        return query;
    }

    protected Map initQbuilder(String[] keys, Object[] values) {
        Map query = new HashMap<>(16);
        if (keys != null && keys.length > 0 && values != null && values.length > 0 && keys.length == values.length) {
            for (int i = 0; i < keys.length; i++) {
                if (UtilString.isNotBlank(keys[i]) && values[i] != null) {
                    query.put(keys[i], values[i]);
                }
            }
        }
        return query;
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy