Implementation
Future<List<Cow>?> moveOrCopyCowsToCowGroup(
/// 그룹에 추가할 소 개체의 리스트입니다.
List<Cow> _,
/// 기존에 속한 소의 그룹입니다.
CowGroup? fromCowGroup,
/// 새로 이동 또는 복사할 타겟 그룹입니다.
CowGroup? toCowGroup,
/// 이동이면 "move", 복사면 "copy" 입니다.
String action,
) async {
LogManager().addLog("updateCow", screen: runtimeType.toString());
try {
await reqPUT(
path: '/api/cow_groups/cows',
queryParameters: {
"cow_ids": "[${_.map((e) => "\"${e.id}\"").toList().join(",")}]",
"from_cow_group_id": fromCowGroup != null ? fromCowGroup.id.toString() : "0",
"to_cow_group_id": toCowGroup != null ? toCowGroup.id.toString() : "0",
"action": action
},
body: Uint8List.fromList([]),
);
await fetchCows();
return _;
} catch (e) {
LogManager().addLog('updateCow call failed: $e', screen: runtimeType.toString());
return null;
}
}