♻️ 重构代码 . R.ok R.failed
This commit is contained in:
1 parent
8affb5519e
commit
0ca10e1adc
43 files changed
+231
-249
No files matched your search
@@ -53,7 +53,7 @@ public class ${className}Controller {
|
||||
*/
|
||||
@GetMapping("/page" )
|
||||
public R get${className}Page(Page page, ${className} ${classname}) {
|
||||
return new R<>(${classname}Service.page(page, Wrappers.query(${classname})));
|
||||
return R.ok(${classname}Service.page(page, Wrappers.query(${classname})));
|
||||
}
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ public class ${className}Controller {
|
||||
*/
|
||||
@GetMapping("/{${pk.lowerAttrName}}" )
|
||||
public R getById(@PathVariable("${pk.lowerAttrName}" ) ${pk.attrType} ${pk.lowerAttrName}) {
|
||||
return new R<>(${classname}Service.getById(${pk.lowerAttrName}));
|
||||
return R.ok(${classname}Service.getById(${pk.lowerAttrName}));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -76,7 +76,7 @@ public class ${className}Controller {
|
||||
@PostMapping
|
||||
@PreAuthorize("@pms.hasPermission('${moduleName}_${pathName}_add')" )
|
||||
public R save(@RequestBody ${className} ${classname}) {
|
||||
return new R<>(${classname}Service.save(${classname}));
|
||||
return R.ok(${classname}Service.save(${classname}));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -88,7 +88,7 @@ public class ${className}Controller {
|
||||
@PutMapping
|
||||
@PreAuthorize("@pms.hasPermission('${moduleName}_${pathName}_edit')" )
|
||||
public R updateById(@RequestBody ${className} ${classname}) {
|
||||
return new R<>(${classname}Service.updateById(${classname}));
|
||||
return R.ok(${classname}Service.updateById(${classname}));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -100,7 +100,7 @@ public class ${className}Controller {
|
||||
@DeleteMapping("/{${pk.lowerAttrName}}" )
|
||||
@PreAuthorize("@pms.hasPermission('${moduleName}_${pathName}_del')" )
|
||||
public R removeById(@PathVariable ${pk.attrType} ${pk.lowerAttrName}) {
|
||||
return new R<>(${classname}Service.removeById(${pk.lowerAttrName}));
|
||||
return R.ok(${classname}Service.removeById(${pk.lowerAttrName}));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -83,6 +83,8 @@
|
||||
this.tableData = response.data.data.records
|
||||
this.page.total = response.data.data.total
|
||||
this.tableLoading = false
|
||||
}).catch(() => {
|
||||
this.listLoading=false
|
||||
})
|
||||
},
|
||||
rowDel: function (row, index) {
|
||||
@@ -101,7 +103,6 @@
|
||||
type: 'success'
|
||||
})
|
||||
this.getList(this.page)
|
||||
}).catch(function (err) {
|
||||
})
|
||||
},
|
||||
/**
|
||||
@@ -111,7 +112,7 @@
|
||||
* @param done 为表单关闭函数
|
||||
*
|
||||
**/
|
||||
handleUpdate: function (row, index, done) {
|
||||
handleUpdate: function (row, index, done,loading) {
|
||||
putObj(row).then(data => {
|
||||
this.tableData.splice(index, 1, Object.assign({}, row))
|
||||
this.$message({
|
||||
@@ -121,7 +122,9 @@
|
||||
})
|
||||
done()
|
||||
this.getList(this.page)
|
||||
})
|
||||
}).catch(() => {
|
||||
loading();
|
||||
});
|
||||
},
|
||||
/**
|
||||
* @title 数据添加
|
||||
@@ -129,7 +132,7 @@
|
||||
* @param done 为表单关闭函数
|
||||
*
|
||||
**/
|
||||
handleSave: function (row, done) {
|
||||
handleSave: function (row, done,loading) {
|
||||
addObj(row).then(data => {
|
||||
this.tableData.push(Object.assign({}, row))
|
||||
this.$message({
|
||||
@@ -139,7 +142,9 @@
|
||||
})
|
||||
done()
|
||||
this.getList(this.page)
|
||||
})
|
||||
}).catch(() => {
|
||||
loading();
|
||||
});
|
||||
},
|
||||
/**
|
||||
* 搜索回调
|
||||
|
||||
Reference in new issue
Block a user