multi-store/app/store/controller/ConfigController.php

164 lines
5.8 KiB
PHP
Raw Normal View History

2024-06-04 09:18:17 +08:00
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\store\controller;
use app\admin\logic\ConfigLogic;
2024-06-06 17:14:49 +08:00
use app\admin\logic\system_store\SystemStoreLogic;
use app\common\controller\Definitions;
2024-06-12 10:29:29 +08:00
use app\common\service\ConfigService;
use app\common\service\FileService;
2024-06-06 17:14:49 +08:00
use think\facade\Db;
2024-06-04 09:18:17 +08:00
/**
* 配置控制器
* Class ConfigController
* @package app\admin\controller
*/
class ConfigController extends BaseAdminController
{
public $notNeedLogin = ['getConfig', 'dict'];
2024-06-14 15:53:47 +08:00
// #[
// ApiDoc\Title('站点配置'),
// ApiDoc\url('/store/config/getConfig'),
// ApiDoc\Method('GET'),
// ApiDoc\NotHeaders(),
// ApiDoc\Author('中国队长'),
// ApiDoc\ResponseSuccess("data", type: "array", children: [
// ['name' => 'oss_domain', 'desc' => 'oss域名', 'type' => 'string'],
// ['name' => 'web_name', 'desc' => '站点名称', 'type' => 'string'],
// ['name' => 'web_favicon', 'desc' => '站点图标', 'type' => 'string'],
// ['name' => 'web_logo', 'desc' => '站点logo', 'type' => 'string'],
// ['name' => 'login_image', 'desc' => '登录页背景图', 'type' => 'string'],
// ['name' => 'copyright_config', 'desc' => '版权信息', 'type' => 'array'],
// ]),
// ]
2024-06-04 09:18:17 +08:00
public function getConfig()
{
2024-06-12 10:29:29 +08:00
// $data = ConfigLogic::getConfig();
$data = [
// 文件域名
'oss_domain' => FileService::getFileUrl(),
// 网站名称
'web_name' => '泸优采门店后台',
// 网站图标
'web_favicon' => FileService::getFileUrl(ConfigService::get('website', 'web_favicon')),
// 网站logo
'web_logo' => FileService::getFileUrl(ConfigService::get('website', 'web_logo')),
// 登录页
'login_image' => FileService::getFileUrl(ConfigService::get('website', 'login_image')),
// 版权信息
'copyright_config' => ConfigService::get('copyright', 'config', []),
];
2024-06-04 09:18:17 +08:00
return $this->data($data);
}
2024-06-14 15:53:47 +08:00
// #[
// ApiDoc\Title('门店配置'),
// ApiDoc\url('/store/config/store'),
// ApiDoc\Method('GET'),
// ApiDoc\NotHeaders(),
// ApiDoc\Author('中国队长'),
// ApiDoc\Header(ref: [Definitions::class, "token"]),
// ApiDoc\ResponseSuccess("data", type: "array"),
// ]
2024-06-06 17:14:49 +08:00
public function store()
2024-06-04 09:18:17 +08:00
{
2024-06-06 17:14:49 +08:00
$params['id'] = $this->request->adminInfo['store_id'];
$result = SystemStoreLogic::detail($params);
return $this->data($result);
2024-06-04 09:18:17 +08:00
}
2024-06-14 15:53:47 +08:00
// #[
// ApiDoc\Title('保存门店配置'),
// ApiDoc\url('/store/config/saveStore'),
// ApiDoc\Method('POST'),
// ApiDoc\NotHeaders(),
// ApiDoc\Author('中国队长'),
// ApiDoc\Header(ref: [Definitions::class, "token"]),
// ApiDoc\ResponseSuccess("data", type: "array"),
// ]
2024-06-06 17:32:18 +08:00
public function saveStore()
{
$params = $this->request->post();
$params['id'] = $this->request->adminInfo['store_id'];
SystemStoreLogic::edit($params);
return $this->success('操作成功', [], 1, 1);
}
2024-06-14 15:53:47 +08:00
// #[
// ApiDoc\Title('省列表'),
// ApiDoc\url('/store/config/province'),
// ApiDoc\Method('GET'),
// ApiDoc\NotHeaders(),
// ApiDoc\Author('中国队长'),
// ApiDoc\Header(ref: [Definitions::class, "token"]),
// ApiDoc\ResponseSuccess("data", type: "array"),
// ]
2024-06-04 09:18:17 +08:00
public function province()
{
$list = Db::name('geo_province')->select()->toArray();
return $this->success('ok', $list);
}
2024-06-14 15:53:47 +08:00
// #[
// ApiDoc\Title('市列表'),
// ApiDoc\url('/store/config/city'),
// ApiDoc\Method('GET'),
// ApiDoc\NotHeaders(),
// ApiDoc\Author('中国队长'),
// ApiDoc\Query(name: 'code', type: 'int', require: true, desc: '省份代码'),
// ApiDoc\Header(ref: [Definitions::class, "token"]),
// ApiDoc\ResponseSuccess("data", type: "array"),
// ]
2024-06-04 09:18:17 +08:00
public function city()
{
$province_code = $this->request->get('code');
$list = Db::name('geo_city')->where('province_code', $province_code)->select()?->toArray();
return $this->success('ok', $list);
}
2024-06-14 15:53:47 +08:00
// #[
// ApiDoc\Title('区列表'),
// ApiDoc\url('/store/config/area'),
// ApiDoc\Method('GET'),
// ApiDoc\NotHeaders(),
// ApiDoc\Author('中国队长'),
// ApiDoc\Query(name: 'code', type: 'int', require: true, desc: '城市代码'),
// ApiDoc\Header(ref: [Definitions::class, "token"]),
// ApiDoc\ResponseSuccess("data", type: "array"),
// ]
2024-06-04 09:18:17 +08:00
public function area()
{
$city_code = $this->request->get('code');
$list = Db::name('geo_area')->where('city_code', $city_code)->select()?->toArray();
return $this->success('ok', $list);
}
2025-01-23 15:26:14 +08:00
/**
* @notes 根据类型获取字典数据
*/
public function dict()
{
$type = $this->request->get('type', '');
$data = ConfigLogic::getDictByType($type);
return $this->data($data);
}
2024-06-04 09:18:17 +08:00
}