| 157 | } |
| 158 | |
| 159 | pub async fn update(mg: MulticastGroup) -> Result<MulticastGroup, Error> { |
| 160 | mg.validate()?; |
| 161 | |
| 162 | let mg: MulticastGroup = diesel::update(multicast_group::dsl::multicast_group.find(&mg.id)) |
| 163 | .set(( |
| 164 | multicast_group::updated_at.eq(Utc::now()), |
| 165 | multicast_group::name.eq(&mg.name), |
| 166 | multicast_group::region.eq(&mg.region), |
| 167 | multicast_group::mc_addr.eq(&mg.mc_addr), |
| 168 | multicast_group::mc_nwk_s_key.eq(&mg.mc_nwk_s_key), |
| 169 | multicast_group::mc_app_s_key.eq(&mg.mc_app_s_key), |
| 170 | multicast_group::f_cnt.eq(&mg.f_cnt), |
| 171 | multicast_group::group_type.eq(&mg.group_type), |
| 172 | multicast_group::dr.eq(&mg.dr), |
| 173 | multicast_group::frequency.eq(&mg.frequency), |
| 174 | multicast_group::class_b_ping_slot_periodicity.eq(&mg.class_b_ping_slot_periodicity), |
| 175 | multicast_group::class_c_scheduling_type.eq(&mg.class_c_scheduling_type), |
| 176 | )) |
| 177 | .get_result(&mut get_async_db_conn().await?) |
| 178 | .await |
| 179 | .map_err(|e| Error::from_diesel(e, mg.id.to_string()))?; |
| 180 | info!(id = %mg.id, "Multicast-group updated"); |
| 181 | Ok(mg) |
| 182 | } |
| 183 | |
| 184 | pub async fn delete(id: &Uuid) -> Result<(), Error> { |
| 185 | let ra = diesel::delete(multicast_group::dsl::multicast_group.find(&fields::Uuid::from(id))) |