|
|
@@ -7,8 +7,11 @@ import com.yami.shop.common.util.R;
|
|
|
import com.yami.shop.delivery.comment.service.Transport2Service;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
@RestController
|
|
|
@RequestMapping("/platform/transport2")
|
|
|
public class Transport2Controller {
|
|
|
@@ -32,19 +35,17 @@ public class Transport2Controller {
|
|
|
|
|
|
@PostMapping("/addOrEdit")
|
|
|
@ApiOperation(value = "新增或更新运费模板")
|
|
|
- public R<Void> addOrEdit(Transport2 transport) {
|
|
|
- if (transport.getChannelId() != null) {
|
|
|
- Transport2 transport2 = transportService.queryTransport2ByChannelId(transport.getChannelId());
|
|
|
- if (transport2 != null) {
|
|
|
- transport.setTransportId(transport2.getTransportId());
|
|
|
- transportService.updateById(transport);
|
|
|
- } else {
|
|
|
- transportService.save(transport);
|
|
|
- }
|
|
|
- }else {
|
|
|
- transportService.save(transport);
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public R<Void> addOrEdit(@RequestBody List<Transport2> transport2List) {
|
|
|
+ if (transport2List != null && !transport2List.isEmpty()) {
|
|
|
+ transport2List.forEach(transport -> {
|
|
|
+ if (transport.getTransportId() != null) {
|
|
|
+ transportService.updateById(transport);
|
|
|
+ } else {
|
|
|
+ transportService.save(transport);
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
return R.SUCCESS();
|
|
|
}
|
|
|
-
|
|
|
}
|