www_fpvone_cn/application/admin/service/ScreenService.php

60 lines
1.5 KiB
PHP
Raw Normal View History

2024-12-20 12:29:51 +08:00
<?php
/**
* 数据大屏
* @Author:Soar
* @Time:2023/11/17 10:55
*/
namespace app\admin\service;
use app\admin\model\MatchScreen;
use think\Exception;
class ScreenService
{
public function __construct()
{
$this->matchScreenModel = new MatchScreen();
}
public function addScreen($param)
{
$param['look_pwd'] = md5($param['look_pwd']);
$screen_info = $this->matchScreenModel->where("match_id", "eq", $param['match_id'])
->where("type", $param['type'])
->find();
if (!empty($screen_info)) {
$param['id'] = $screen_info->id;
if ($param['nopass'] == "false") {
$param['look_pwd'] = null;
}
unset($param['nopass']);
try {
return $this->matchScreenModel->update($param);
} catch (\Exception $exception) {
$this->error($exception->getMessage());
}
} else {
unset($param['nopass']);
try {
return $this->matchScreenModel->insert($param);
} catch (\Exception $exception) {
$this->error($exception->getMessage());
}
}
}
public function getScreen($param)
{
try {
return $this->matchScreenModel->where($param)->field("title, id, backound_img, font_rgb")->find();
} catch (\Exception $exception) {
$this->error($exception->getMessage());
}
}
}