@@ -4,9 +4,12 @@ import io.swagger.annotations.Api;
4
4
import io.swagger.annotations.ApiImplicitParam;
5
5
import io.swagger.annotations.ApiImplicitParams;
6
6
import io.swagger.annotations.ApiOperation;
7
+ import lazy.fast.code.core.exception.NoContentNotException;
8
+ import lazy.fast.code.core.exception.NotFoundException;
7
9
import lazy.fast.code.core.orm.BaseController;
8
10
import lazy.fast.code.core.orm.BaseService;
9
11
import org.springframework.http.ResponseEntity;
12
+ import org.springframework.util.CollectionUtils;
10
13
import org.springframework.web.bind.annotation.DeleteMapping;
11
14
import org.springframework.web.bind.annotation.GetMapping;
12
15
import org.springframework.web.bind.annotation.PathVariable;
@@ -37,14 +40,22 @@ public class ${className?cap_first}Controller extends BaseController<${className
37
40
@ApiOperation(value = "获取${classDescription} 列表")
38
41
@GetMapping
39
42
public List<${className?cap_first } > list(${className?cap_first } ${className?uncap_first } ) {
40
- return this.getBaseService().list(${className?uncap_first } );
43
+ List<${className?cap_first } > list = this.getBaseService().list(${className?uncap_first } );
44
+ if (CollectionUtils.isEmpty(list)) {
45
+ throw new NoContentNotException();
46
+ }
47
+ return list;
41
48
}
42
49
43
50
@ApiOperation(value = "根据数据主键获取${classDescription} ")
44
51
@ApiImplicitParams({@ApiImplicitParam(name = "id", value = "数据主键", required = true, paramType = "path")})
45
52
@GetMapping("/{id}")
46
53
public ${className?cap_first } get(@PathVariable String id) {
47
- return this.getBaseService().get(id);
54
+ ${className?cap_first } ${className?uncap_first } = this.getBaseService().get(id);
55
+ if (${className?uncap_first } == null) {
56
+ throw new NotFoundException();
57
+ }
58
+ return ${className?uncap_first } ;
48
59
}
49
60
50
61
@ApiOperation(value = "保存${classDescription} ")
0 commit comments