ConfigLogic.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | likeadmin快速开发前后端分离管理后台(PHP版)
  4. // +----------------------------------------------------------------------
  5. // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
  6. // | 开源版本可自由商用,可去除界面版权logo
  7. // | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
  8. // | github下载:https://github.com/likeshop-github/likeadmin
  9. // | 访问官网:https://www.likeadmin.cn
  10. // | likeadmin团队 版权所有 拥有最终解释权
  11. // +----------------------------------------------------------------------
  12. // | author: likeadminTeam
  13. // +----------------------------------------------------------------------
  14. namespace app\adminapi\logic;
  15. use app\adminapi\logic\article\ArticleCateLogic;
  16. use app\adminapi\logic\auth\MenuLogic;
  17. use app\adminapi\logic\auth\RoleLogic;
  18. use app\adminapi\logic\dept\DeptLogic;
  19. use app\adminapi\logic\dept\JobsLogic;
  20. use app\adminapi\logic\setting\dict\DictTypeLogic;
  21. use app\common\enum\YesNoEnum;
  22. use app\common\model\article\ArticleCate;
  23. use app\common\model\auth\SystemMenu;
  24. use app\common\model\auth\SystemRole;
  25. use app\common\model\dept\Dept;
  26. use app\common\model\dept\Jobs;
  27. use app\common\model\dict\DictData;
  28. use app\common\model\dict\DictType;
  29. use app\common\service\{FileService, ConfigService};
  30. /**
  31. * 配置类逻辑层
  32. * Class ConfigLogic
  33. * @package app\adminapi\logic
  34. */
  35. class ConfigLogic
  36. {
  37. /**
  38. * @notes 获取配置
  39. * @return array
  40. * @author 段誉
  41. * @date 2021/12/31 11:03
  42. */
  43. public static function getConfig(): array
  44. {
  45. $config = [
  46. // 文件域名
  47. 'oss_domain' => FileService::getFileUrl(),
  48. // 网站名称
  49. 'web_name' => ConfigService::get('website', 'name'),
  50. // 网站图标
  51. 'web_favicon' => FileService::getFileUrl(ConfigService::get('website', 'web_favicon')),
  52. // 网站logo
  53. 'web_logo' => FileService::getFileUrl(ConfigService::get('website', 'web_logo')),
  54. // 登录页
  55. 'login_image' => FileService::getFileUrl(ConfigService::get('website', 'login_image')),
  56. // 版权信息
  57. 'copyright_config' => ConfigService::get('copyright', 'config', []),
  58. // 版本号
  59. 'version' => config('project.version')
  60. ];
  61. return $config;
  62. }
  63. /**
  64. * @notes 根据类型获取字典类型
  65. * @param $type
  66. * @return array
  67. * @throws \think\db\exception\DataNotFoundException
  68. * @throws \think\db\exception\DbException
  69. * @throws \think\db\exception\ModelNotFoundException
  70. * @author 段誉
  71. * @date 2022/9/27 19:09
  72. */
  73. public static function getDictByType($type)
  74. {
  75. if (!is_string($type)) {
  76. return [];
  77. }
  78. $type = explode(',', $type);
  79. $lists = DictData::whereIn('type_value', $type)->select()->toArray();
  80. if (empty($lists)) {
  81. return [];
  82. }
  83. $result = [];
  84. foreach ($type as $item) {
  85. foreach ($lists as $dict) {
  86. if ($dict['type_value'] == $item) {
  87. $result[$item][] = $dict;
  88. }
  89. }
  90. }
  91. return $result;
  92. }
  93. }