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