Skip to content

Commit

Permalink
修复HashMap参数无法在后端获取的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
lsgwr committed Nov 27, 2019
1 parent 55398f2 commit 1e18f02
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public SysConfig findById(Long id) {

@Override
public PageResult findPage(PageRequest pageRequest) {
Object label = pageRequest.getParam("label");
Object label = pageRequest.getParamValue("label");
if (label != null) {
return MyBatisPageHelper.findPage(pageRequest, sysConfigMapper, "findPageByLabel", label);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public SysDict findById(Long id) {

@Override
public PageResult findPage(PageRequest pageRequest) {
Object label = pageRequest.getParam("label");
Object label = pageRequest.getParamValue("label");
if (label != null) {
return MyBatisPageHelper.findPage(pageRequest, sysDictMapper, "findPageByLabel", label);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public SysLog findById(Long id) {

@Override
public PageResult findPage(PageRequest pageRequest) {
Object label = pageRequest.getParam("userName");
Object label = pageRequest.getParamValue("userName");
if (label != null) {
return MyBatisPageHelper.findPage(pageRequest, sysLogMapper, "findPageByUserName", label);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ public SysLoginLog findById(Long id) {

@Override
public PageResult findPage(PageRequest pageRequest) {
Object userName = pageRequest.getParam("userName");
Object userName = pageRequest.getParamValue("userName");
if (userName != null) {
return MyBatisPageHelper.findPage(pageRequest, sysLoginLogMapper, "findPageByUserName", userName);
}
Object status = pageRequest.getParam("status");
Object status = pageRequest.getParamValue("status");
if (status != null) {
return MyBatisPageHelper.findPage(pageRequest, sysLoginLogMapper, "findPageByStatus", status);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public SysRole findById(Long id) {

@Override
public PageResult findPage(PageRequest pageRequest) {
Object label = pageRequest.getParam("name");
Object label = pageRequest.getParamValue("name");
if (label != null) {
return MyBatisPageHelper.findPage(pageRequest, sysRoleMapper, "findPageByName", label);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ public SysUser findById(Long id) {
@Override
public PageResult findPage(PageRequest pageRequest) {
PageResult pageResult = null;
Object name = pageRequest.getParam("name");
Object email = pageRequest.getParam("email");
Object name = pageRequest.getParamValue("name");
Object email = pageRequest.getParamValue("email");
if (name != null) {
if (email != null) {
pageResult = MyBatisPageHelper.findPage(pageRequest, sysUserMapper, "findPageByNameAndEmail", name, email);
Expand Down
5 changes: 5 additions & 0 deletions code/backend/core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,10 @@
<artifactId>common</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@
***********************************************************/
package com.huawei.l00379880.core.page;

import java.util.HashMap;
import java.util.Map;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;

@Data
public class PageRequest {
/**
* 当前页码
Expand All @@ -23,39 +26,34 @@ public class PageRequest {
/**
* 查询参数
*/
private Map<String, Object> params = new HashMap<>();

public int getPageNum() {
return pageNum;
}

public void setPageNum(int pageNum) {
this.pageNum = pageNum;
}

public int getPageSize() {
return pageSize;
}
private List<Param> params = new ArrayList<>();

public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}

public Map<String, Object> getParams() {
return params;
}

public void setParams(Map<String, Object> params) {
this.params = params;
/**
* 查询参数对象
*
* @param name Param的value
* @return 指定的键值对对象
*/
public Param getParam(String name) {
for (Param param : this.params) {
if (name != null && name.equals(param.getName())) {
return param;
}
}
return null;
}

/**
* 根据键拿到请求参数的指定键值对
* 查询参数值
*
* @param key map的key
* @return 指定键的值
* @param name 参数名称
* @return 参数值
*/
public Object getParam(String key) {
return params.get(key);
public String getParamValue(String name) {
Param param = getParam(name);
if (param != null) {
return param.getValue();
}
return null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/***********************************************************
* @Description : 封装页面参数
* @author : 梁山广(Liang Shan Guang)
* @date : 2019/11/27 22:57
* @email : [email protected]
***********************************************************/
package com.huawei.l00379880.core.page;

import lombok.Data;

@Data
public class Param {
private String name;
private String value;
}

0 comments on commit 1e18f02

Please sign in to comment.