|
@@ -0,0 +1,91 @@
|
|
|
+package com.example.opc_da.controller;
|
|
|
+
|
|
|
+import com.example.opc_common.entity.AlarmLevel;
|
|
|
+import com.example.opc_common.enums.ModelEnum;
|
|
|
+import com.example.opc_common.enums.OperationEnum;
|
|
|
+import com.example.opc_common.enums.ResultEnum;
|
|
|
+import com.example.opc_common.enums.ServerEnum;
|
|
|
+import com.example.opc_common.util.Blank;
|
|
|
+import com.example.opc_common.util.Result;
|
|
|
+import com.example.opc_da.annotation.WebLog;
|
|
|
+import com.example.opc_da.service.AlarmLevelService;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import javax.validation.Valid;
|
|
|
+import javax.validation.constraints.Min;
|
|
|
+
|
|
|
+@RestController
|
|
|
+@RequestMapping("alarmLevel")
|
|
|
+@Slf4j
|
|
|
+public class AlarmLevelController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private AlarmLevelService alarmLevelService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增报警级别
|
|
|
+ *
|
|
|
+ * @param alarmLevel
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @PostMapping("/addAlarmLevel")
|
|
|
+ @WebLog(ServerEnum = ServerEnum.CLIENT, ModelEnum = ModelEnum.ALARMLEVEL, OperationEnum = OperationEnum.ADD)
|
|
|
+ public Result addAlarmLevel(@RequestBody @Valid AlarmLevel alarmLevel) {
|
|
|
+ return alarmLevelService.addAlarmLevel(alarmLevel);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改报警级别
|
|
|
+ *
|
|
|
+ * @param alarmLevel
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @PostMapping("/updateAlarmLevel")
|
|
|
+ @WebLog(ServerEnum = ServerEnum.CLIENT, ModelEnum = ModelEnum.ALARMLEVEL, OperationEnum = OperationEnum.UPDATE)
|
|
|
+ public Result updateAlarmLevel(@RequestBody @Valid AlarmLevel alarmLevel) {
|
|
|
+ if (Blank.isEmpty(alarmLevel.getId())) {
|
|
|
+ return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "修改时主键不能为空");
|
|
|
+ }
|
|
|
+ return alarmLevelService.updateAlarmLevel(alarmLevel);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 分页查询报警级别
|
|
|
+ *
|
|
|
+ * @param page
|
|
|
+ * @param limit
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @GetMapping("/getAlarmLevelPage")
|
|
|
+ @WebLog(ServerEnum = ServerEnum.CLIENT, ModelEnum = ModelEnum.ALARMLEVEL, OperationEnum = OperationEnum.SELECT)
|
|
|
+ public Result getAlarmLevelPage(@Min(value = 1, message = "必须大于0") Integer page,
|
|
|
+ @Min(value = 1, message = "必须大于0") Integer limit) {
|
|
|
+ return alarmLevelService.getAlarmLevelPage(page, limit);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 通过id获取报警级别
|
|
|
+ *
|
|
|
+ * @param id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @GetMapping("/getAlarmLevelById")
|
|
|
+ @WebLog(ServerEnum = ServerEnum.CLIENT, ModelEnum = ModelEnum.ALARMLEVEL, OperationEnum = OperationEnum.SELECT)
|
|
|
+ public Result getAlarmLevelById(@RequestParam Integer id) {
|
|
|
+ return alarmLevelService.getAlarmLevelById(id);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 通过id删除报警级别
|
|
|
+ *
|
|
|
+ * @param id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @PostMapping("/delAlarmLevelById")
|
|
|
+ @WebLog(ServerEnum = ServerEnum.CLIENT, ModelEnum = ModelEnum.ALARMLEVEL, OperationEnum = OperationEnum.DELETE)
|
|
|
+ public Result delAlarmLevelById(@RequestParam Integer id) {
|
|
|
+ return alarmLevelService.delAlarmLevelById(id);
|
|
|
+ }
|
|
|
+}
|