mirror of
http://git.pig4cloud.com/pig/pigx.git
synced 2026-11-11 05:19:00 +08:00
♻️ Refactoring code.wrapper result of controller with R except activiti project
This commit is contained in:
1 parent
fa01371f09
commit
7c614bc5bf
19 files changed
+91
-105
No files matched your search
+3
-3
@@ -22,6 +22,7 @@ import com.baomidou.mybatisplus.plugins.Page;
|
||||
import com.pig4cloud.pigx.codegen.entity.GenConfig;
|
||||
import com.pig4cloud.pigx.codegen.service.SysGeneratorService;
|
||||
import com.pig4cloud.pigx.common.core.util.Query;
|
||||
import com.pig4cloud.pigx.common.core.util.R;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@@ -48,10 +49,9 @@ public class SysGeneratorController {
|
||||
* @return 数据库表
|
||||
*/
|
||||
@GetMapping("/page")
|
||||
public Page list(@RequestParam Map<String, Object> params) {
|
||||
public R<Page> list(@RequestParam Map<String, Object> params) {
|
||||
Query query = new Query(params);
|
||||
query.setRecords(sysGeneratorService.queryPage(query));
|
||||
return query;
|
||||
return new R<>(query.setRecords(sysGeneratorService.queryPage(query)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package ${package}.${moduleName}.controller;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import com.baomidou.mybatisplus.plugins.Page;
|
||||
@@ -19,9 +20,9 @@ import java.util.Map;
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/${pathName}")
|
||||
@AllArgsConstructor
|
||||
public class ${className}Controller {
|
||||
@Autowired
|
||||
private ${className}Service ${classname}Service;
|
||||
private final ${className}Service ${classname}Service;
|
||||
|
||||
|
||||
/**
|
||||
@@ -30,8 +31,8 @@ public class ${className}Controller {
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/page")
|
||||
public Page page(@RequestParam Map<String, Object> params) {
|
||||
return ${classname}Service.selectPage(new Query<>(params), new EntityWrapper<>());
|
||||
public R<Page> page(@RequestParam Map<String, Object> params) {
|
||||
return new R<>(${classname}Service.selectPage(new Query<>(params), new EntityWrapper<>()));
|
||||
}
|
||||
|
||||
|
||||
@@ -41,9 +42,8 @@ public class ${className}Controller {
|
||||
* @return R
|
||||
*/
|
||||
@GetMapping("/{${pk.lowerAttrName}}")
|
||||
public R info(@PathVariable("${pk.lowerAttrName}") ${pk.attrType} ${pk.lowerAttrName}){
|
||||
${className} ${classname} = ${classname}Service.selectById(${pk.lowerAttrName});
|
||||
return new R<>(${classname});
|
||||
public R get${className}ById(@PathVariable("${pk.lowerAttrName}") ${pk.attrType} ${pk.lowerAttrName}){
|
||||
return new R<>(${classname}Service.selectById(${pk.lowerAttrName}));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -52,7 +52,7 @@ public class ${className}Controller {
|
||||
* @return R
|
||||
*/
|
||||
@PostMapping
|
||||
public R save(@RequestBody ${className} ${classname}){
|
||||
public R save${className}(@RequestBody ${className} ${classname}){
|
||||
return new R<>(${classname}Service.insert(${classname}));
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ public class ${className}Controller {
|
||||
* @return R
|
||||
*/
|
||||
@PutMapping
|
||||
public R update(@RequestBody ${className} ${classname}){
|
||||
public R update${className}(@RequestBody ${className} ${classname}){
|
||||
${classname}Service.updateById(${classname});
|
||||
return new R<>(Boolean.TRUE);
|
||||
}
|
||||
@@ -73,7 +73,7 @@ public class ${className}Controller {
|
||||
* @return R
|
||||
*/
|
||||
@DeleteMapping("/{${pk.lowerAttrName}}")
|
||||
public R delete(@PathVariable ${pk.attrType} ${pk.lowerAttrName}){
|
||||
public R delete${className}ById(@PathVariable ${pk.attrType} ${pk.lowerAttrName}){
|
||||
return new R<>(${classname}Service.deleteById(${pk.lowerAttrName}));
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ export function fetchList(query) {
|
||||
|
||||
export function addObj(obj) {
|
||||
return request({
|
||||
url: '/${moduleName}/${pathName}/',
|
||||
url: '/${moduleName}/${pathName}',
|
||||
method: 'post',
|
||||
data: obj
|
||||
})
|
||||
@@ -49,7 +49,7 @@ export function delObj(id) {
|
||||
|
||||
export function putObj(obj) {
|
||||
return request({
|
||||
url: '/${moduleName}/${pathName}/',
|
||||
url: '/${moduleName}/${pathName}',
|
||||
method: 'put',
|
||||
data: obj
|
||||
})
|
||||
|
||||
Reference in new issue
Block a user