get请求
前端请求
页面
getproblemTypeList() {
const filter = Object.assign({
keyWord: this.keyWord,
pageNum: this.queryParams.pageNum,
pageSize: this.queryParams.pageSize,
});
getproblemTypeList(filter).then((res) => {
if (res) {
this.problemTypeList = res.data.list;
this.totalCount = res.data.tol;
} else {
this.$message.error(res.msg);
}
});
},
js页面
/*获取列表*/
export function getList(data) {
return request({
url: '/award/problemType/list',
method: 'get',
params:data
})
}
后端接收
@GetMapping("/list")
public AjaxResult getList(@RequestParam(value="pageNum",required = false,defaultValue = "1") Integer pageNum,
@RequestParam(value="pageSize",required = false,defaultValue = "8") Integer pageSize,
@RequestParam(value="keyWord") String keyWord){
try {
AjaxResult ajaxResult= awardProblemTypeService.getList(pageNum,pageSize,keyWord);
return ajaxResult;
} catch (Exception e) {
e.printStackTrace();
return AjaxResult.error("查询异常");
}
}
post请求
方式一:
页面代码
deleteById(id) {
this.$confirm("此操作将永久删除,是否继续?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
})
.then(() => {
this.loadingbutDel = true;
this.loadingbuttextDel = "删除中...";
let filter = Object.assign({}, { id: id });
console.log(filter);
deleteById(filter).then((response) => {
if (response) {
this.$message({
message: "删除成功",
type: "success",
});
this.loadingbutDel = false;
this.loadingbuttextDel = "删除";
} else {
this.$message.error(response.msg);
this.loadingbutDel = false;
this.loadingbuttextDel = "删除";
}
this.findFeedBack();
});
})
.catch(() => {});
},
js页面
方式一:
export function deleteById(data) {
return request({
url: '/award/problemType/deleteById',
method: 'post',
params: data
})
}
方式二:
export function deleteById(id) {
return request({
url: '/award/problemType/deleteById',
method: 'post',
params: { 'id':id}
})
}
后端收
@Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
@PostMapping("/delete")
public AjaxResult delete(Long id) {
try {
AjaxResult ajaxResult = workflowStepService.delete(id);
return ajaxResult;
} catch (Exception e) {
e.printStackTrace();
return AjaxResult.error("删除异常");
}
}