| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155 |
- <?php
- namespace App\Models\Api\Process;
- use Illuminate\Database\Eloquent\Factories\HasFactory;
- use Illuminate\Database\Eloquent\Model;
- use Illuminate\Support\Facades\DB;
- /**
- * 违规处理-执行日志模型
- * @author: 唐远望
- * @version: 1.0
- * @date: 2025-12-09
- */
- class ExecuteLog extends Model
- {
- use HasFactory;
- // 与模型关联的表名
- protected $table = 'process_execute_log';
- // 是否主动维护时间戳
- public $timestamps = false;
- // 定义时间戳字段名
- // const CREATED_AT = 'insert_time';
- // const UPDATED_AT = 'update_time';
- /**
- * 添加
- * @author 唐远望
- * @version 1.0
- * @date 2025-12-09
- */
- public function addExecuteLog_content($data)
- {
- $insert_data = [
- 'name' => $data['name'],
- 'code' => $data['code'],
- 'admin_id' => $data['admin_id'],
- 'insert_time' => time(),
- ];
- $ExecuteLog_id = $this->insertGetId($insert_data);
- return $ExecuteLog_id;
- }
- /**
- * 写入数据
- * @author 唐远望
- * @version 1.0
- * @date 2025-12-09
- * @param $data
- * @return bool
- */
- public function addExecuteLog($data)
- {
- DB::beginTransaction();
- try {
- $this->addExecuteLog_content($data);
- DB::commit();
- return true;
- // 成功处理...
- } catch (\Exception $e) {
- DB::rollBack();
- // 错误处理...
- return false;
- }
- }
- /**
- * 编辑内容
- * @author 唐远望
- * @version 1.0
- * @date 2025-12-09
- * @param $data
- * @return bool
- */
- public function editExecuteLog_content($where, $data)
- {
- $ExecuteLog = $this->where($where)->first();
- if (!$ExecuteLog) {
- return false;
- }
- $ExecuteLog->name = $data['name'];
- $ExecuteLog->code = $data['responsible_person'];
- $ExecuteLog->admin_id = $data['product_name'];
- $ExecuteLog->update_time = time();
- $ExecuteLog->save();
- return true;
- }
- /**
- * 更新数据
- * @author 唐远望
- * @version 1.0
- * @date 2025-12-09
- * @param $data
- * @return bool
- */
- public function updateExecuteLog($where, $data)
- {
- DB::beginTransaction();
- try {
- $this->editExecuteLog_content($where, $data);
- DB::commit();
- return true;
- // 成功处理...
- } catch (\Exception $e) {
- DB::rollBack();
- // 错误处理...
- return false;
- }
- }
- /**
- * 修改状态
- * @author 唐远望
- * @version 1.0
- * @date 2025-12-09
- * @param $id
- * @param $status
- * @return bool
- */
- public function changeStatus($where, $status)
- {
- $ExecuteLog = $this->where($where)->first();
- if (!$ExecuteLog) {
- return false;
- }
- $ExecuteLog->status = $status;
- $ExecuteLog->update_time = time();
- $ExecuteLog->save();
- return true;
- }
- /**
- * 删除数据
- * @author 唐远望
- * @version 1.0
- * @date 2025-12-09
- * @param $id
- * @return bool
- */
- public function deleteExecuteLog($where)
- {
- $ExecuteLog = $this->where($where)->first();
- if (!$ExecuteLog) {
- return false;
- }
- $ExecuteLog->delete();
- return true;
- }
- }
|