Bladeren bron

设备控制-001

hanqingsong 1 jaar geleden
bovenliggende
commit
3bd97bbcc5

+ 21 - 4
src/main/java/com/chinaitop/depot/intelligent/devControl/controller/TDevControlController.java

@@ -8,11 +8,10 @@ import com.unissoft.model.ResponseEntity;
8 8
 import io.swagger.annotations.Api;
9 9
 import io.swagger.annotations.ApiOperation;
10 10
 import org.springframework.validation.annotation.Validated;
11
-import org.springframework.web.bind.annotation.GetMapping;
12
-import org.springframework.web.bind.annotation.RequestMapping;
13
-import org.springframework.web.bind.annotation.RestController;
11
+import org.springframework.web.bind.annotation.*;
14 12
 
15 13
 import javax.annotation.Resource;
14
+import javax.ws.rs.GET;
16 15
 
17 16
 
18 17
 /**
@@ -31,9 +30,27 @@ public class TDevControlController {
31 30
     private TDevControlService devControlService;
32 31
 
33 32
     @GetMapping("/getPageList")
34
-    @ApiOperation(value="设备配置分页列表", notes = "支持分页")
33
+    @ApiOperation(value = "设备配置分页列表", notes = "支持分页")
35 34
     public ResponseEntity<Page<TDevControl>> getPageList(@Validated TDevControlPageParam devControl) {
36 35
         return ResponseEntity.ok(devControlService.selectPageList(devControl));
37 36
     }
38 37
 
38
+    @PostMapping("/save")
39
+    @ApiOperation(value = "设备配置新增", notes = "新增")
40
+    public ResponseEntity save(@RequestBody TDevControl devControl) {
41
+        return ResponseEntity.ok(devControlService.saveData(devControl));
42
+    }
43
+
44
+    @PutMapping("/update")
45
+    @ApiOperation(value = "设备配置修改", notes = "修改")
46
+    public ResponseEntity update(@RequestBody TDevControl devControl) {
47
+        return ResponseEntity.ok(devControlService.updateData(devControl));
48
+    }
49
+
50
+    @DeleteMapping("/delete/{id}")
51
+    @ApiOperation(value = "设备配置删除", notes = "id删除")
52
+    public ResponseEntity delete(@PathVariable("id") String id) {
53
+        return ResponseEntity.ok(devControlService.deleteData(id));
54
+    }
55
+
39 56
 }

+ 6 - 0
src/main/java/com/chinaitop/depot/intelligent/devControl/service/TDevControlService.java

@@ -16,4 +16,10 @@ import com.chinaitop.depot.intelligent.devControl.model.TDevControlPageParam;
16 16
 public interface TDevControlService extends IService<TDevControl> {
17 17
 
18 18
     Page<TDevControl> selectPageList(TDevControlPageParam devControl);
19
+
20
+    int saveData(TDevControl devControl);
21
+
22
+    int updateData(TDevControl devControl);
23
+
24
+    int deleteData(String id);
19 25
 }

+ 22 - 0
src/main/java/com/chinaitop/depot/intelligent/devControl/service/impl/TDevControlServiceImpl.java

@@ -7,8 +7,10 @@ import com.chinaitop.depot.intelligent.devControl.mapper.TDevControlMapper;
7 7
 import com.chinaitop.depot.intelligent.devControl.model.TDevControl;
8 8
 import com.chinaitop.depot.intelligent.devControl.model.TDevControlPageParam;
9 9
 import com.chinaitop.depot.intelligent.devControl.service.TDevControlService;
10
+import com.chinaitop.depot.intelligent.utils.UuidUtils;
10 11
 import org.apache.commons.lang3.StringUtils;
11 12
 import org.springframework.stereotype.Service;
13
+import org.springframework.transaction.annotation.Transactional;
12 14
 
13 15
 import javax.annotation.Resource;
14 16
 
@@ -35,4 +37,24 @@ public class TDevControlServiceImpl extends ServiceImpl<TDevControlMapper, TDevC
35 37
             wrapper.like("dev_name", devControl.getDevName());
36 38
         return devControlMapper.selectPage(new Page<>(devControl.getCurrent(), devControl.getSize()), wrapper);
37 39
     }
40
+
41
+    @Override
42
+    @Transactional(rollbackFor = Exception.class)
43
+    public int saveData(TDevControl devControl) {
44
+        // 生成32id
45
+        devControl.setId(UuidUtils.getCode());
46
+        return devControlMapper.insert(devControl);
47
+    }
48
+
49
+    @Override
50
+    @Transactional(rollbackFor = Exception.class)
51
+    public int updateData(TDevControl devControl) {
52
+        return devControlMapper.updateById(devControl);
53
+    }
54
+
55
+    @Override
56
+    @Transactional(rollbackFor = Exception.class)
57
+    public int deleteData(String id) {
58
+        return devControlMapper.deleteById(id);
59
+    }
38 60
 }