Browse Source

# 添加设备巡检内容批量更新的feign接口

zhongwei
haungxing 1 year ago
parent
commit
c178f4c648
  1. 16
      hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/obj/feign/IContentClient.java
  2. 10
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/obj/feign/ContentClient.java

16
hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/obj/feign/IContentClient.java

@ -1,16 +1,22 @@
package com.hnac.hzinfo.inspect.obj.feign;
import com.hnac.hzinfo.inspect.Constants;
import com.hnac.hzinfo.inspect.obj.dto.ContentDTO;
import com.hnac.hzinfo.inspect.obj.vo.ContentVO;
import org.springblade.core.tool.api.R;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import java.util.List;
@FeignClient(value = Constants.APP_NAME)
public interface IContentClient {
String API_PREFIX = "/feign/content";
String DETAIL = API_PREFIX + "/detail";
String SAVE_BATCH = API_PREFIX + "/saveBatch";
String UPDATE_BATCH = API_PREFIX + "/detail";
String SAVE_BATCH = API_PREFIX + "/updateBatch";
String LIST = API_PREFIX + "/list";
String SAVE_OR_UPDATE_BATCH = API_PREFIX + "/saveOrUpdateBatch";
@ -22,4 +28,12 @@ public interface IContentClient {
@GetMapping(DETAIL)
R<ContentVO> detail(Long id);
/**
* 批量更新巡检内容
* @param request 巡检内容列表
* @return
*/
@PutMapping(UPDATE_BATCH)
R<Boolean> updateBatch(@RequestBody List<ContentDTO> request);
}

10
hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/obj/feign/ContentClient.java

@ -1,5 +1,8 @@
package com.hnac.hzinfo.inspect.obj.feign;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.hnac.hzinfo.inspect.obj.dto.ContentDTO;
import com.hnac.hzinfo.inspect.obj.entity.ContentEntity;
import com.hnac.hzinfo.inspect.obj.services.ContentService;
import com.hnac.hzinfo.inspect.obj.vo.ContentVO;
@ -10,6 +13,7 @@ import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.tool.api.R;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Optional;
/**
@ -32,5 +36,11 @@ public class ContentClient extends BladeController implements IContentClient {
return R.data(Optional.ofNullable(entity).map(content -> ContentWrapper.build().entityVO(content)).orElse(null));
}
@Override
public R<Boolean> updateBatch(List<ContentDTO> request) {
List<ContentEntity> contentList = JSONArray.parseArray(JSON.toJSONString(request), ContentEntity.class);
return R.data(contentService.updateBatchById(contentList));
}
}

Loading…
Cancel
Save