add
This commit is contained in:
78
app/admin/controller/ExtSys.php
Normal file
78
app/admin/controller/ExtSys.php
Normal file
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\api\model\CommonInfo;
|
||||
use app\common\controller\Backend;
|
||||
use app\common\library\DatabaseRoute;
|
||||
use think\facade\Db;
|
||||
|
||||
class ExtSys extends Backend
|
||||
{
|
||||
protected array $noNeedLogin = ['*'];
|
||||
public function friendConfig()
|
||||
{
|
||||
$code = 999;
|
||||
$commonInfo = cache('common_info:'.$code);
|
||||
if (!$commonInfo) {
|
||||
$commonInfo = CommonInfo::where([
|
||||
'type' => $code
|
||||
])->find();
|
||||
if($commonInfo) {
|
||||
$commonInfo = $commonInfo->toArray();
|
||||
}
|
||||
cache('common_info:'.$code, $commonInfo, 60 * 60 * 24);
|
||||
}
|
||||
if (!$commonInfo) {
|
||||
$this->success();
|
||||
}
|
||||
|
||||
$this->successWithData([
|
||||
'imageUrl' => $commonInfo['value'],
|
||||
'tips' => $commonInfo['max']
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
public function friendConfigSave()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
if (empty($params['imageUrl'])) {
|
||||
$this->error('顶部图片地址不能为空');
|
||||
}
|
||||
|
||||
if (empty($params['tips'])) {
|
||||
$this->error('邀请文案不能为空');
|
||||
}
|
||||
|
||||
if (strlen($params['tips']) > 20) {
|
||||
$this->error('邀请文案不能大于20个字符');
|
||||
}
|
||||
|
||||
$commonInfo = (new CommonInfo())->getByCode(999);
|
||||
if ($commonInfo) {
|
||||
Db::name('common_info')->where([
|
||||
'id' => $commonInfo['id']
|
||||
])->update([
|
||||
'max' => $params['tips'],
|
||||
'value' => $params['imageUrl']
|
||||
]);
|
||||
}else{
|
||||
Db::name('common_info')->insert([
|
||||
'code' => 999,
|
||||
'max' => $params['tips'],
|
||||
'value' => $params['imageUrl'],
|
||||
'min' => '邀请好友配置',
|
||||
'is_app_use' => 1,
|
||||
'create_at' => getNormalDate()
|
||||
]);
|
||||
}
|
||||
cache('common_info:999', Db::name('common_info')->where([
|
||||
'type' => 999
|
||||
])->find());
|
||||
$this->success();
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user