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