travel/service/app/admin/controller/SettingController.php

41 lines
1.2 KiB
PHP
Raw Normal View History

2024-10-21 17:14:32 +08:00
<?php
namespace app\admin\controller;
use app\model\Settings;
use support\Redis;
use support\Request;
class SettingController extends base {
2024-10-22 15:00:11 +08:00
// 境内
2024-10-21 17:14:32 +08:00
const SETTING_DOMESTIC = 'setting:domestic';
2024-10-22 15:00:11 +08:00
// 境外
2024-10-21 17:14:32 +08:00
const SETTING_ABROAD = 'setting:abroad';
/**
* 配置合同获取
* @param Request $request
* @return \support\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function getContractSetting(Request $request) {
$domestic = Redis::get(self::SETTING_DOMESTIC) ?? '';
$abroad = Redis::get(self::SETTING_ABROAD) ?? '';
return $this->success(compact('domestic', 'abroad'));
}
/**
* 合同配置保存
*/
public function saveContractSetting(Request $request) {
2024-10-22 09:09:13 +08:00
if (!empty($request->post('domestic'))) {
2024-10-22 10:51:24 +08:00
Redis::set(self::SETTING_DOMESTIC, $request->post('domestic'));
2024-10-21 17:14:32 +08:00
}
2024-10-22 09:09:13 +08:00
if (!empty($request->post('abroad'))) {
2024-10-22 10:51:24 +08:00
Redis::set(self::SETTING_ABROAD, $request->post('abroad'));
2024-10-21 17:14:32 +08:00
}
2024-10-22 09:09:13 +08:00
2024-10-22 10:51:24 +08:00
return $this->success($request->post());
2024-10-21 17:14:32 +08:00
}
}