|
|
@@ -0,0 +1,135 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+namespace App\Models\manager\Process;
|
|
|
+
|
|
|
+use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
|
+use Illuminate\Database\Eloquent\Model;
|
|
|
+use Illuminate\Support\Facades\DB;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 通知消息模型
|
|
|
+ * @author: 唐远望
|
|
|
+ * @version: 1.0
|
|
|
+ * @date: 2025-12-29
|
|
|
+ */
|
|
|
+class Notices extends Model
|
|
|
+{
|
|
|
+ use HasFactory;
|
|
|
+ // 与模型关联的表名
|
|
|
+ protected $table = 'process_notices';
|
|
|
+ // 是否主动维护时间戳
|
|
|
+ public $timestamps = false;
|
|
|
+ // 定义时间戳字段名
|
|
|
+ // const CREATED_AT = 'insert_time';
|
|
|
+ // const UPDATED_AT = 'update_time';
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 添加
|
|
|
+ * @author 唐远望
|
|
|
+ * @version 1.0
|
|
|
+ * @date 2025-12-29
|
|
|
+ */
|
|
|
+ public function addNotices_content($data)
|
|
|
+ {
|
|
|
+ $insert_data = [
|
|
|
+ 'title' => $data['title'],
|
|
|
+ 'content' => $data['content'],
|
|
|
+ 'msg_type' => $data['msg_type'],
|
|
|
+ 'custom_uid' => $data['custom_uid'],
|
|
|
+ ];
|
|
|
+ $Notices_id = $this->insertGetId($insert_data);
|
|
|
+ return $Notices_id;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 写入数据
|
|
|
+ * @author 唐远望
|
|
|
+ * @version 1.0
|
|
|
+ * @date 2025-12-29
|
|
|
+ * @param $data
|
|
|
+ * @return bool
|
|
|
+ */
|
|
|
+ public function addNotices($data)
|
|
|
+ {
|
|
|
+ DB::beginTransaction();
|
|
|
+ try {
|
|
|
+ $this->addNotices_content($data);
|
|
|
+ DB::commit();
|
|
|
+ return true;
|
|
|
+ // 成功处理...
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ DB::rollBack();
|
|
|
+ // 错误处理...
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 编辑内容
|
|
|
+ * @author 唐远望
|
|
|
+ * @version 1.0
|
|
|
+ * @date 2025-12-29
|
|
|
+ * @param $data
|
|
|
+ * @return bool
|
|
|
+ */
|
|
|
+ public function editNotices_content($where, $data)
|
|
|
+ {
|
|
|
+ $Notices = $this->where($where)->first();
|
|
|
+ if (!$Notices) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ $Notices->title = $data['title'];
|
|
|
+ $Notices->content = $data['content'];
|
|
|
+ $Notices->msg_type = $data['msg_type'];
|
|
|
+ $Notices->custom_uid = $data['custom_uid'];
|
|
|
+ $Notices->save();
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 更新数据
|
|
|
+ * @author 唐远望
|
|
|
+ * @version 1.0
|
|
|
+ * @date 2025-12-29
|
|
|
+ * @param $data
|
|
|
+ * @return bool
|
|
|
+ */
|
|
|
+ public function updateNotices($where, $data)
|
|
|
+ {
|
|
|
+ DB::beginTransaction();
|
|
|
+ try {
|
|
|
+ $this->editNotices_content($where, $data);
|
|
|
+ DB::commit();
|
|
|
+ return true;
|
|
|
+ // 成功处理...
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ DB::rollBack();
|
|
|
+ // 错误处理...
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除数据
|
|
|
+ * @author 唐远望
|
|
|
+ * @version 1.0
|
|
|
+ * @date 2025-12-29
|
|
|
+ * @param $id
|
|
|
+ * @return bool
|
|
|
+ */
|
|
|
+ public function deleteNotices($where)
|
|
|
+ {
|
|
|
+ $Notices = $this->where($where)->first();
|
|
|
+ if (!$Notices) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ $Notices->delete();
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+}
|