ボタンは、バックエンドへの引数、複数の条件を選択するためにスクリーニングする必要があり、その結果をスクリーニングます。
データ処理のためのバックエンドインターフェイス
@PostMapping(value = "/getResult")
public HttpResult getResult(HttpServletRequest request){
//数据类型
HttpResult result = new HttpResult();
Map<String,String[]> paramMap = request.getParameterMap();
//当传入的参数为空时确保也能够执行
if(paramMap.size()>=0){
Map<String,String> condtionMap = new HashMap();
for(String key: paramMap.keySet()){
condtionMap.put(key,paramMap.get(key)[0]);
}
try{
List<JobDO> sjob =service.selectJob(condtionMap);
return HttpResult.build(sjob);
}catch (Exception e){
result = HttpResult.build(false,"获取结果失败");
return result;
}
}else{
result = HttpResult.build(false,"查询结果失败");
return result;
}
}
DAO層データのフィルタリング、動的SQL
クエリ結果夜12時例外、マッパー層のSQL文のパラメータの種類IntergerときIntergerタイプとして条件の照会状況、ステータスは0、すべてのケースのためのクエリ結果、ステータスがIntergerタイプですので、それは0、デフォルトであるときそれはnullです。
ソリューション:もっと支払う裁判官
"<テスト= \あれば" 状態== 0?'0':ステータス\ ">とステータス=#{ステータス} </ IF>"
@Results(id = "job",value = {
@Result(column = "id", property = "id"),
@Result(column = "name", property = "name"),
@Result(column = "state", property = "state")
})
@ResultMap(value = "job")
@Select("<script>" +
"select * from table" +
"<where>" +
"<if test=\"conditionMap.id !=null and conditionMap.id!=''\"> id=#{conditionMap.id}</if>" +
//字段的类型为封装类型 值为0时,会转为空
"<if test=\"conditionMap.state == 0\">and state=0 </if> "+
"<if test=\"conditionMap.state !=null and conditionMap.state!=''\">and state=#{conditionMap.state}</if>" +
"</where>" +
"</script>"
)
List<JobDO> selectJob(@Param("conditionMap") Map<String,String> conditionMap);
フロントエンド要求コールインタフェースを反応させます
//筛选按钮
doFilter = ()=>{
//配置路径,微服务名称 ,接口参数
request.post(`/api/jobservice/job/getResult`)
.set('Content-Type', 'application/x-www-form-urlencoded')
.send({
//参数是否传入
id:this.state.Id ? this.state.Id :undefined,
//状态为开启,关闭,全部,全部情况下为undefined
states : (this.state.choseState && this.state.choseState != 2 ? this.state.choseState : undefined)
})
.end((err,res)=>{
if(!err){
let response=JSON.parse(res.xhr.response);
if(response.code='200'){
//对取得的值倒序
this.setState({list:response.data.reverse()})
}else{
message.error(response.msg);
}
}else{
message.error("服务暂不可用");
}
this.setState({ afterFiltered: true });
});
}