提交 | 用户 | 时间
|
c06f48
|
1 |
package com.iailab.module.model.mcs.pre.controller.admin; |
7fd198
|
2 |
|
潘 |
3 |
import com.iailab.framework.common.exception.ErrorCode; |
|
4 |
import com.iailab.framework.common.pojo.CommonResult; |
|
5 |
import com.iailab.framework.common.pojo.PageResult; |
|
6 |
import com.iailab.framework.common.util.object.BeanUtils; |
|
7 |
import com.iailab.module.model.mcs.pre.entity.DmModuleEntity; |
|
8 |
import com.iailab.module.model.mcs.pre.service.DmModuleService; |
|
9 |
import com.iailab.module.model.mcs.pre.vo.DmModulePageReqVO; |
|
10 |
import com.iailab.module.model.mcs.pre.vo.DmModuleRespVO; |
|
11 |
import org.springframework.beans.factory.annotation.Autowired; |
abba54
|
12 |
import org.springframework.security.access.prepost.PreAuthorize; |
7fd198
|
13 |
import org.springframework.validation.annotation.Validated; |
潘 |
14 |
import org.springframework.web.bind.annotation.*; |
|
15 |
|
|
16 |
import java.util.List; |
|
17 |
import java.util.Map; |
|
18 |
|
|
19 |
import static com.iailab.framework.common.pojo.CommonResult.error; |
|
20 |
import static com.iailab.framework.common.pojo.CommonResult.success; |
|
21 |
|
|
22 |
/** |
|
23 |
* @author PanZhibao |
|
24 |
* @date 2021年04月23日 9:05 |
|
25 |
*/ |
|
26 |
@RestController |
abba54
|
27 |
@RequestMapping("/model/pre/module") |
7fd198
|
28 |
public class DmModuleController { |
潘 |
29 |
|
|
30 |
@Autowired |
|
31 |
private DmModuleService dmModuleService; |
|
32 |
|
|
33 |
/** |
|
34 |
* 管网列表 |
|
35 |
*/ |
|
36 |
@GetMapping("/page") |
abba54
|
37 |
@PreAuthorize("@ss.hasPermission('model:pre-module:query')") |
7fd198
|
38 |
public CommonResult<PageResult<DmModuleRespVO>> page(@Validated DmModulePageReqVO reqVO) { |
潘 |
39 |
PageResult<DmModuleEntity> page = dmModuleService.queryPage(reqVO); |
|
40 |
|
|
41 |
return success(BeanUtils.toBean(page, DmModuleRespVO.class)); |
|
42 |
} |
|
43 |
|
|
44 |
/** |
|
45 |
* 管网列表 |
|
46 |
*/ |
|
47 |
@GetMapping("/list") |
abba54
|
48 |
@PreAuthorize("@ss.hasPermission('model:pre-module:query')") |
7fd198
|
49 |
public CommonResult<List<DmModuleEntity>> list(@RequestParam Map<String, Object> params) { |
潘 |
50 |
List<DmModuleEntity> list = dmModuleService.list(params); |
|
51 |
|
|
52 |
return success(list); |
|
53 |
} |
|
54 |
|
|
55 |
/** |
|
56 |
* 管网信息 |
|
57 |
*/ |
d395d2
|
58 |
@GetMapping("/get/{id}") |
abba54
|
59 |
@PreAuthorize("@ss.hasPermission('model:pre-module:query')") |
d395d2
|
60 |
public CommonResult<DmModuleEntity> info(@PathVariable("id") String id){ |
L |
61 |
DmModuleEntity info = dmModuleService.selectById(id); |
7fd198
|
62 |
|
d395d2
|
63 |
return success(info); |
7fd198
|
64 |
} |
潘 |
65 |
|
|
66 |
/** |
|
67 |
* 保存管网 |
|
68 |
*/ |
|
69 |
@PostMapping("/create") |
abba54
|
70 |
@PreAuthorize("@ss.hasPermission('model:pre-module:create')") |
7fd198
|
71 |
public CommonResult<Boolean> save(@RequestBody DmModuleEntity module){ |
潘 |
72 |
int count = dmModuleService.check(module); |
|
73 |
if (count > 0) { |
|
74 |
ErrorCode errorCode = new ErrorCode(999, "名称重复"); |
|
75 |
return error(errorCode); |
|
76 |
} |
|
77 |
dmModuleService.saveModule(module); |
|
78 |
return success(true); |
|
79 |
} |
|
80 |
|
|
81 |
/** |
|
82 |
* 修改管网 |
|
83 |
*/ |
|
84 |
@PutMapping("/update") |
abba54
|
85 |
@PreAuthorize("@ss.hasPermission('model:pre-module:update')") |
7fd198
|
86 |
public CommonResult<Boolean> update(@RequestBody DmModuleEntity module){ |
潘 |
87 |
dmModuleService.update(module); |
|
88 |
return success(true); |
|
89 |
} |
|
90 |
|
|
91 |
/** |
|
92 |
* 删除管网 |
|
93 |
*/ |
|
94 |
@DeleteMapping("/delete") |
abba54
|
95 |
@PreAuthorize("@ss.hasPermission('model:pre-module:delete')") |
7fd198
|
96 |
public CommonResult<Boolean> delete(@RequestParam("id") String id){ |
潘 |
97 |
dmModuleService.deleteBatch(new String[]{id}); |
|
98 |
return success(true); |
|
99 |
} |
|
100 |
} |