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

com.zyy.common.util.BaseModel Maven / Gradle / Ivy

package com.zyy.common.util;

import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.persistence.Transient;
import javax.servlet.http.HttpServletRequest;
import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Description:
 * Author:jia.song
 * Date:2020/5/27 14:40
 */
@Slf4j
@Data
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public class BaseModel implements Serializable {

    @Transient
    protected List ownerList;
    //当前页
    @Transient
    protected Integer currentPage;
    //页码
    @Transient
    protected Integer pageSize;
    //选择排序的字段
    @Transient
    protected String sortColumn;
    //升序/降序 - asc/desc
    @Transient
    protected String sortOrder;
    @Transient
    protected Integer start;

    public void toSearchMap() {
        ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
        if (servletRequestAttributes != null) {
            HttpServletRequest request = servletRequestAttributes.getRequest();
            this.ownerList = RedisUtil.getOwnerList(request);
        }
        if (currentPage != null && pageSize != null) {
            this.start = (currentPage - 1) * pageSize;
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy