You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
79 lines
2.6 KiB
Java
79 lines
2.6 KiB
Java
package com.xydl.cac.controller;
|
|
|
|
import com.xydl.cac.entity.Modev;
|
|
import com.xydl.cac.entity.ModevType;
|
|
import com.xydl.cac.exception.BusinessException;
|
|
import com.xydl.cac.model.Response;
|
|
import com.xydl.cac.service.ModevService;
|
|
import com.xydl.cac.service.ModevTypeService;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.data.repository.query.Param;
|
|
import org.springframework.validation.annotation.Validated;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.validation.constraints.NotNull;
|
|
import java.util.List;
|
|
|
|
@RestController
|
|
@Api(tags = {"旧监测设备相关接口"})
|
|
@RequestMapping("modev")
|
|
@Slf4j
|
|
public class ModevController extends BasicController {
|
|
|
|
@Resource
|
|
ModevService service;
|
|
|
|
@GetMapping("listAll")
|
|
@ApiOperation("查询列表")
|
|
public Response<List<Modev>> listAll(@NotNull(message = "主设备编号不能缺少") @Param("zsbid") Integer zsbid) {
|
|
List<Modev> result = service.listAll(zsbid);
|
|
return Response.success(result);
|
|
}
|
|
|
|
@PostMapping("add")
|
|
@ApiOperation("新增")
|
|
public Response<Modev> add(@Validated @RequestBody Modev item) throws Exception {
|
|
Modev result = service.add(item);
|
|
return Response.success(result);
|
|
}
|
|
|
|
@PostMapping("update")
|
|
@ApiOperation("更新")
|
|
public Response<String> update(@Validated @RequestBody Modev item) throws Exception {
|
|
if (item.getId() == null) {
|
|
throw new BusinessException("ID不能为空!");
|
|
}
|
|
service.update(item);
|
|
return Response.success("OK");
|
|
}
|
|
|
|
@PostMapping("delete")
|
|
@ApiOperation("删除")
|
|
public Response<String> delete(@Validated @NotNull(message = "ID不能为空!") @Param("id") Integer id) {
|
|
service.delete(id);
|
|
return Response.success("OK");
|
|
}
|
|
|
|
@PostMapping("detail")
|
|
@ApiOperation("详情")
|
|
public Response<Modev> detail(@Validated @NotNull(message = "ID不能为空!") Integer id) throws Exception {
|
|
Modev detail = service.detail(id);
|
|
return Response.success(detail);
|
|
}
|
|
|
|
@PostMapping("bindicd")
|
|
@ApiOperation("详情")
|
|
public Response<String> bindicd(@Validated @NotNull(message = "ID不能为空!") @Param("id") Integer id,@Validated @NotNull(message = "icdid不能为空!") @Param("icdid") Integer icdid) {
|
|
try {
|
|
service.bindicd(id,icdid);
|
|
return Response.success("OK");
|
|
} catch (Exception ex) {
|
|
return Response.fail(ex.getMessage());
|
|
}
|
|
}
|
|
|
|
}
|