更新若干bug
This commit is contained in:
parent
5dffe62adc
commit
f134b0e759
@ -117,6 +117,18 @@ class TenantDomainController extends BaseController
|
||||
]);
|
||||
}
|
||||
|
||||
// 检查该租户是否已有域名数据
|
||||
$hasDomain = TenantDomain::where('tid', $tid)
|
||||
->where('delete_time', null)
|
||||
->find();
|
||||
|
||||
if ($hasDomain) {
|
||||
return json([
|
||||
'code' => 400,
|
||||
'msg' => '该租户已有域名,请删除后再次申请'
|
||||
]);
|
||||
}
|
||||
|
||||
if (empty($subDomain)) {
|
||||
return json([
|
||||
'code' => 400,
|
||||
|
||||
@ -8,7 +8,9 @@ use app\admin\BaseController;
|
||||
use think\exception\ValidateException;
|
||||
use think\facade\Db;
|
||||
use think\response\Json;
|
||||
use app\model\System\SystemSiteSetting;
|
||||
use app\model\System\SystemSiteSettings;
|
||||
use app\model\Tenant\Tenant;
|
||||
|
||||
class SiteSettingsController extends BaseController
|
||||
{
|
||||
@ -18,28 +20,43 @@ class SiteSettingsController extends BaseController
|
||||
*/
|
||||
public function getNormalInfos()
|
||||
{
|
||||
// 定义你需要的 label 列表
|
||||
$targetLabels = [
|
||||
'sitename',
|
||||
'logo',
|
||||
'logow',
|
||||
'description',
|
||||
'copyright',
|
||||
'companyname',
|
||||
'icp'
|
||||
];
|
||||
// 获取当前租户ID
|
||||
$tid = $this->request->param('tid', 0, 'int');
|
||||
|
||||
$siteSettings = SystemSiteSettings::where('delete_time', null)
|
||||
->whereIn('label', $targetLabels) // 仅筛选指定的 label
|
||||
->field('label, value')
|
||||
->select();
|
||||
// 查询站点设置
|
||||
$siteSetting = SystemSiteSetting::where('delete_time', null)
|
||||
->where('tid', $tid)
|
||||
->find();
|
||||
|
||||
// 如果没有数据,返回空值结构
|
||||
if (!$siteSetting) {
|
||||
$data = [
|
||||
'sitename' => '',
|
||||
'logo' => '',
|
||||
'logow' => '',
|
||||
'description' => '',
|
||||
'copyright' => '',
|
||||
'companyname' => '',
|
||||
'icp' => ''
|
||||
];
|
||||
} else {
|
||||
$data = [
|
||||
'sitename' => $siteSetting->sitename ?? '',
|
||||
'logo' => $siteSetting->logo ?? '',
|
||||
'logow' => $siteSetting->{'logo-w'} ?? '',
|
||||
'description' => $siteSetting->description ?? '',
|
||||
'copyright' => $siteSetting->copyright ?? '',
|
||||
'companyname' => $siteSetting->companyname ?? '',
|
||||
'icp' => $siteSetting->icp ?? ''
|
||||
];
|
||||
}
|
||||
|
||||
$this->logSuccess('站点设置管理', '查看基本信息配置', [], $this->getAdminUserInfo());
|
||||
|
||||
return json([
|
||||
'code' => 200,
|
||||
'msg' => '获取成功',
|
||||
'data' => $siteSettings->toArray()
|
||||
'data' => $data
|
||||
]);
|
||||
}
|
||||
|
||||
@ -51,18 +68,46 @@ class SiteSettingsController extends BaseController
|
||||
{
|
||||
$params = $this->request->param();
|
||||
$rawData = isset($params['data']) ? json_decode($params['data'], true) : $params;
|
||||
$allowedLabels = ['sitename', 'logo', 'logow', 'description', 'copyright', 'companyname', 'icp'];
|
||||
$tid = $params['tid'] ?? 0;
|
||||
|
||||
foreach ($allowedLabels as $label) {
|
||||
if (isset($rawData[$label])) {
|
||||
SystemSiteSettings::update(
|
||||
['value' => (string)$rawData[$label]],
|
||||
['label' => $label]
|
||||
);
|
||||
}
|
||||
// 查找或创建记录
|
||||
$siteSetting = SystemSiteSetting::where('delete_time', null)
|
||||
->where('tid', $tid)
|
||||
->find();
|
||||
|
||||
if (!$siteSetting) {
|
||||
$siteSetting = new SystemSiteSetting();
|
||||
$siteSetting->tid = $tid;
|
||||
$siteSetting->create_time = date('Y-m-d H:i:s');
|
||||
}
|
||||
|
||||
$this->logSuccess('站点设置管理', '保存基本信息', ['labels' => $allowedLabels], $this->getAdminUserInfo());
|
||||
// 更新字段
|
||||
if (isset($rawData['sitename'])) {
|
||||
$siteSetting->sitename = (string)$rawData['sitename'];
|
||||
}
|
||||
if (isset($rawData['logo'])) {
|
||||
$siteSetting->logo = (string)$rawData['logo'];
|
||||
}
|
||||
if (isset($rawData['logow'])) {
|
||||
$siteSetting->{'logo-w'} = (string)$rawData['logow'];
|
||||
}
|
||||
if (isset($rawData['description'])) {
|
||||
$siteSetting->description = (string)$rawData['description'];
|
||||
}
|
||||
if (isset($rawData['copyright'])) {
|
||||
$siteSetting->copyright = (string)$rawData['copyright'];
|
||||
}
|
||||
if (isset($rawData['companyname'])) {
|
||||
$siteSetting->companyname = (string)$rawData['companyname'];
|
||||
}
|
||||
if (isset($rawData['icp'])) {
|
||||
$siteSetting->icp = (string)$rawData['icp'];
|
||||
}
|
||||
|
||||
$siteSetting->update_time = date('Y-m-d H:i:s');
|
||||
$siteSetting->save();
|
||||
|
||||
$this->logSuccess('站点设置管理', '保存基本信息', ['tid' => $tid], $this->getAdminUserInfo());
|
||||
|
||||
return json(['code' => 200, 'msg' => '基本信息保存成功']);
|
||||
}
|
||||
@ -173,4 +218,86 @@ class SiteSettingsController extends BaseController
|
||||
|
||||
return json(['code' => 200, 'msg' => '法律声明和隐私条款保存成功']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取企业信息
|
||||
* @return Json
|
||||
*/
|
||||
public function getCompanyInfos()
|
||||
{
|
||||
// 获取当前租户ID
|
||||
$tid = $this->request->param('tid', 0, 'int');
|
||||
|
||||
// 查询租户信息
|
||||
$tenant = Tenant::where('delete_time', null)
|
||||
->where('id', $tid)
|
||||
->find();
|
||||
|
||||
// 如果没有数据,返回空值结构
|
||||
if (!$tenant) {
|
||||
$data = [
|
||||
'contact_phone' => '',
|
||||
'contact_email' => '',
|
||||
'address' => '',
|
||||
'worktime' => ''
|
||||
];
|
||||
} else {
|
||||
$data = [
|
||||
'contact_phone' => $tenant->contact_phone ?? '',
|
||||
'contact_email' => $tenant->contact_email ?? '',
|
||||
'address' => $tenant->address ?? '',
|
||||
'worktime' => $tenant->worktime ?? ''
|
||||
];
|
||||
}
|
||||
|
||||
$this->logSuccess('站点设置管理', '查看企业信息', [], $this->getAdminUserInfo());
|
||||
|
||||
return json([
|
||||
'code' => 200,
|
||||
'msg' => '获取成功',
|
||||
'data' => $data
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存企业信息
|
||||
* @return Json
|
||||
*/
|
||||
public function saveCompanyInfos()
|
||||
{
|
||||
$params = $this->request->param();
|
||||
$tid = $params['tid'] ?? 0;
|
||||
|
||||
// 查找租户记录
|
||||
$tenant = Tenant::where('delete_time', null)
|
||||
->where('id', $tid)
|
||||
->find();
|
||||
|
||||
if (!$tenant) {
|
||||
return json([
|
||||
'code' => 404,
|
||||
'msg' => '租户不存在'
|
||||
]);
|
||||
}
|
||||
|
||||
// 更新字段
|
||||
if (isset($params['contact_phone'])) {
|
||||
$tenant->contact_phone = (string)$params['contact_phone'];
|
||||
}
|
||||
if (isset($params['contact_email'])) {
|
||||
$tenant->contact_email = (string)$params['contact_email'];
|
||||
}
|
||||
if (isset($params['address'])) {
|
||||
$tenant->address = (string)$params['address'];
|
||||
}
|
||||
if (isset($params['worktime'])) {
|
||||
$tenant->worktime = (string)$params['worktime'];
|
||||
}
|
||||
|
||||
$tenant->save();
|
||||
|
||||
$this->logSuccess('站点设置管理', '保存企业信息', ['tid' => $tid], $this->getAdminUserInfo());
|
||||
|
||||
return json(['code' => 200, 'msg' => '企业信息保存成功']);
|
||||
}
|
||||
}
|
||||
|
||||
@ -8,3 +8,5 @@ Route::get('loginVerifyInfos', 'app\\admin\\controller\\SiteSettingsController@g
|
||||
Route::post('saveloginVerifyInfos', 'app\\admin\\controller\\SiteSettingsController@saveVerifyInfos');
|
||||
Route::get('legalInfos', 'app\\admin\\controller\\SiteSettingsController@getLegalInfos');
|
||||
Route::post('saveLegalInfos', 'app\\admin\\controller\\SiteSettingsController@saveLegalInfos');
|
||||
Route::get('companyInfos', 'app\\admin\\controller\\SiteSettingsController@getCompanyInfos');
|
||||
Route::post('saveCompanyInfos', 'app\\admin\\controller\\SiteSettingsController@saveCompanyInfos');
|
||||
|
||||
41
app/model/System/SystemSiteSetting.php
Normal file
41
app/model/System/SystemSiteSetting.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2006-2018 http://thinkphp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: Liu21st <liu21st@gmail.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\model\System;
|
||||
|
||||
use think\Model;
|
||||
use think\model\concern\SoftDelete;
|
||||
|
||||
/**
|
||||
* 站点设置模型
|
||||
*/
|
||||
class SystemSiteSetting extends Model
|
||||
{
|
||||
// 启用软删除
|
||||
use SoftDelete;
|
||||
|
||||
// 数据库表名
|
||||
protected $name = 'mete_system_site_setting';
|
||||
|
||||
// 字段类型转换
|
||||
protected $type = [
|
||||
'id' => 'integer',
|
||||
'tid' => 'integer',
|
||||
'sitename' => 'string',
|
||||
'logo' => 'string',
|
||||
'logo-w' => 'string',
|
||||
'description' => 'string',
|
||||
'copyright' => 'string',
|
||||
'companyname' => 'string',
|
||||
'icp' => 'string',
|
||||
'create_time' => 'datetime',
|
||||
];
|
||||
}
|
||||
@ -30,7 +30,7 @@ class Tenant extends Model
|
||||
'contact_phone' => 'string',
|
||||
'contact_email' => 'string',
|
||||
'address' => 'string',
|
||||
'domain' => 'string',
|
||||
'worktime' => 'string',
|
||||
'status' => 'integer',
|
||||
'create_time' => 'datetime',
|
||||
'update_time' => 'datetime',
|
||||
|
||||
@ -1,3 +1,6 @@
|
||||
<?php
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html class="no-js" lang="">
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user