$data['name'], 'insert_time' => time(), ]; $Department_id = $this->insertGetId($insert_data); return $Department_id; } /** * 写入数据 * @author 唐远望 * @version 1.0 * @date 2025-12-04 * @param $data * @return bool */ public function addDepartment($data) { DB::beginTransaction(); try { $this->addDepartment_content($data); DB::commit(); return true; // 成功处理... } catch (\Exception $e) { DB::rollBack(); // 错误处理... return false; } } /** * 编辑内容 * @author 唐远望 * @version 1.0 * @date 2025-12-04 * @param $data * @return bool */ public function editDepartment_content($where, $data) { $Department = $this->where($where)->first(); if (!$Department) { return false; } $Department->name = $data['name']; $Department->update_time = time(); $Department->save(); return true; } /** * 更新数据 * @author 唐远望 * @version 1.0 * @date 2025-12-04 * @param $data * @return bool */ public function updateDepartment($where, $data) { DB::beginTransaction(); try { $this->editDepartment_content($where, $data); DB::commit(); return true; // 成功处理... } catch (\Exception $e) { DB::rollBack(); // 错误处理... return false; } } /** * 修改状态 * @author 唐远望 * @version 1.0 * @date 2025-12-04 * @param $id * @param $status * @return bool */ public function changeStatus($where, $status) { $Department = $this->where($where)->first(); if (!$Department) { return false; } $Department->status = $status; $Department->update_time = time(); $Department->save(); return true; } /** * 删除数据 * @author 唐远望 * @version 1.0 * @date 2025-12-04 * @param $id * @return bool */ public function deleteDepartment($where) { $Department = $this->where($where)->first(); if (!$Department) { return false; } $Department->delete(); return true; } }