www_fpvone_cn/application/admin/controller/Screen.php

88 lines
2.2 KiB
PHP
Raw Normal View History

2024-12-20 12:29:51 +08:00
<?php
/**
* @Created by PhpStorm.
* @Author:Soar
* @Time:2023/11/17 10:56
*/
namespace app\admin\controller;
use app\admin\service\ScreenService;
use app\common\controller\Backend;
use think\Db;
use think\Validate;
class Screen extends Backend
{
protected $noNeedLogin = ["*"];
protected $noNeedRight = ["*"];
protected $layout = '';
public function _initialize()
{
parent::_initialize();
$this->screenService = new ScreenService();
}
public function addScreen()
{
$param['title'] = $this->request->param("title");
$param['look_pwd'] = $this->request->param("password");
$param['match_id'] = $this->request->param("match_id");
$param['backound_img'] = $this->request->param("backound_img", "");
$param['nopass'] = $this->request->param("nopass");
$param['font_rgb'] = $this->request->param("font_rgb");
$param['type'] = $this->request->param("type");
$rule = [
'title' => 'require',
'match_id' => 'require',
];
$msg = [
'title.require' => '标题不可为空',
'match_id.require' => '赛程数据不可为空',
];
$validate = new Validate($rule, $msg);
$result = $validate->check($param);
if (!$result) {
$this->error(__($validate->getError()), null, ['token' => $this->request->token()]);
}
$res = $this->screenService->addScreen($param);
if (!empty($res)) {
$row['code'] = 1;
$row['data'] = [];
$row['msg'] = "保存成功";
} else {
$row['code'] = 0;
$row['data'] = [];
$row['msg'] = "保存失败";
}
return json($row);
}
public function getScreen()
{
$param['match_id'] = $this->request->param("match_id");
$param['type'] = $this->request->param("type");
$res = $this->screenService->getScreen($param);
if (!empty($res)) {
$row['code'] = 1;
$row['data'] = $res;
$row['msg'] = "获取成功";
} else {
$row['code'] = 0;
$row['data'] = [];
$row['msg'] = "获取失败";
}
return json($row);
}
}