$params['type'], 'name' => $params['name'], 'value' => $params['value'] ]); Db::commit(); return true; } catch (\Throwable $e) { Db::rollback(); throw new BusinessException($e->getMessage()); } } /** * @notes 编辑配置表 * @param array $params * @return bool * @author admin * @date 2024/06/24 17:52 */ public static function edit(array $params): bool { Db::startTrans(); try { Config::where('id', $params['id'])->update([ 'type' => $params['type'], 'name' => $params['name'], 'value' => $params['value'] ]); Db::commit(); return true; } catch (\Throwable $e) { Db::rollback(); throw new BusinessException($e->getMessage()); } } /** * @notes 删除配置表 * @param array $params * @return bool * @author admin * @date 2024/06/24 17:52 */ public static function delete(array $params): bool { return Config::destroy($params['id']); } /** * @notes 获取配置表详情 * @param $params * @return array * @author admin * @date 2024/06/24 17:52 */ public static function detail($params): array { return Config::findOrEmpty($params['id'])->toArray(); } /** * @notes 获取配置 * @return array * @author 乔峰 * @date 2021/12/31 11:03 */ public static function getConfig(): array { $config = [ // 文件域名 'oss_domain' => FileService::getFileUrl(), // 网站名称 'web_name' => ConfigService::get('website', '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', []), ]; return $config; } /** * @notes 根据类型获取字典类型 * @param $type * @return array * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException * @author 乔峰 * @date 2022/9/27 19:09 */ public static function getDictByType($type) { if (!is_string($type)) { return []; } $type = explode(',', $type); $lists = DictData::whereIn('type_value', $type)->select()->toArray(); if (empty($lists)) { return []; } $result = []; foreach ($type as $item) { foreach ($lists as $dict) { if ($dict['type_value'] == $item) { $result[$item][] = $dict; } } } return $result; } }