Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query排序无效 #42

Closed
lltx opened this issue Sep 13, 2021 · 1 comment
Closed

Query排序无效 #42

lltx opened this issue Sep 13, 2021 · 1 comment

Comments

@lltx
Copy link
Collaborator

lltx commented Sep 13, 2021

com.github.pig.common.util.Query;

public class Query extends Page {
private static final String PAGE = "page";
private static final String LIMIT = "limit";
private static final String ORDER_BY_FIELD = "orderByField";
private static final String IS_ASC = "isAsc";

public Query(Map<String, Object> params) {
    super(Integer.parseInt(params.getOrDefault(PAGE, 1).toString())
            , Integer.parseInt(params.getOrDefault(LIMIT, 10).toString()));
    params.remove(PAGE);
    params.remove(LIMIT);
    params.remove(ORDER_BY_FIELD);  //orderByField  是否应先 赋值 再 remove
    params.remove(IS_ASC);          //isAsc  是否应先 赋值 再 remove
    this.setCondition(params);

    String orderByField = params.getOrDefault(ORDER_BY_FIELD, "").toString();  
    if (StringUtils.isNotEmpty(orderByField)) {
        this.setOrderByField(orderByField);
    }

    Boolean isAsc = Boolean.parseBoolean(params.getOrDefault(IS_ASC, Boolean.TRUE).toString()); 
    this.setAsc(isAsc);
}

}

@lltx
Copy link
Collaborator Author

lltx commented Sep 13, 2021

感谢反馈,已经修复

@lltx lltx closed this as completed Sep 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant