UP
This commit is contained in:
@@ -6,6 +6,8 @@ namespace app\controller;
|
||||
use app\BaseController;
|
||||
use app\middleware\Auth;
|
||||
use app\service\CrawlerService;
|
||||
use app\service\UserConfigService;
|
||||
use think\facade\Session;
|
||||
use think\facade\View;
|
||||
|
||||
/**
|
||||
@@ -19,8 +21,77 @@ class Crawler extends BaseController
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
// 获取当前用户的配置
|
||||
$username = Session::get('username', '');
|
||||
$config = [];
|
||||
|
||||
if ($username) {
|
||||
$configService = new UserConfigService();
|
||||
$config = $configService->getUserConfig($username);
|
||||
}
|
||||
|
||||
// 将配置传递给视图
|
||||
View::assign('userConfig', $config);
|
||||
|
||||
return View::fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户配置
|
||||
*/
|
||||
public function getUserConfig()
|
||||
{
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
|
||||
$username = Session::get('username', '');
|
||||
|
||||
if (empty($username)) {
|
||||
return json([
|
||||
'code' => 0,
|
||||
'msg' => '未登录',
|
||||
]);
|
||||
}
|
||||
|
||||
$configService = new UserConfigService();
|
||||
$config = $configService->getUserConfig($username);
|
||||
|
||||
return json([
|
||||
'code' => 1,
|
||||
'data' => $config,
|
||||
'msg' => '获取成功',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存用户配置
|
||||
*/
|
||||
public function saveUserConfig()
|
||||
{
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
|
||||
$username = Session::get('username', '');
|
||||
|
||||
if (empty($username)) {
|
||||
return json([
|
||||
'code' => 0,
|
||||
'msg' => '未登录',
|
||||
]);
|
||||
}
|
||||
|
||||
$config = [
|
||||
'jsessionid1' => $this->request->param('jsessionid1', ''),
|
||||
'jsessionid2' => $this->request->param('jsessionid2', ''),
|
||||
'serverid' => $this->request->param('serverid', ''),
|
||||
'examid' => $this->request->param('examid', ''),
|
||||
'bmid' => $this->request->param('bmid', ''),
|
||||
'userid' => $this->request->param('userid', ''),
|
||||
];
|
||||
|
||||
$configService = new UserConfigService();
|
||||
$result = $configService->saveUserConfig($username, $config);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取地区选项(从网页HTML中提取)
|
||||
|
||||
Reference in New Issue
Block a user