ConfigLogic.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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\tenantapi\logic;
  15. use app\common\logic\TableDataLogic;
  16. use app\tenantapi\logic\article\ArticleCateLogic;
  17. use app\tenantapi\logic\auth\MenuLogic;
  18. use app\tenantapi\logic\auth\RoleLogic;
  19. use app\tenantapi\logic\dept\DeptLogic;
  20. use app\tenantapi\logic\dept\JobsLogic;
  21. use app\tenantapi\logic\setting\dict\DictTypeLogic;
  22. use app\common\enum\YesNoEnum;
  23. use app\common\model\article\ArticleCate;
  24. use app\common\model\auth\SystemMenu;
  25. use app\common\model\auth\SystemRole;
  26. use app\common\model\dept\Dept;
  27. use app\common\model\dept\Jobs;
  28. use app\common\model\dict\DictData;
  29. use app\common\model\dict\DictType;
  30. use app\common\service\ConfigService;
  31. use app\common\service\{FileService};
  32. use think\facade\Log;
  33. /**
  34. * 配置类逻辑层
  35. * Class ConfigLogic
  36. * @package app\tenantapi\logic
  37. */
  38. class ConfigLogic
  39. {
  40. /**
  41. * @notes 获取配置
  42. * @return array
  43. * @author 段誉
  44. * @date 2021/12/31 11:03
  45. */
  46. public static function getConfig(): array
  47. {
  48. $config = [
  49. // 文件域名
  50. 'oss_domain' => FileService::getFileUrl(),
  51. // 网站名称
  52. 'web_name' => ConfigService::get('tenant', 'name'),
  53. // 网站图标
  54. 'web_favicon' => FileService::getFileUrl(ConfigService::get('tenant', 'web_favicon')),
  55. // 网站logo
  56. 'web_logo' => FileService::getFileUrl(ConfigService::get('tenant', 'web_logo')),
  57. // 登录页
  58. 'login_image' => FileService::getFileUrl(ConfigService::get('tenant', 'login_image')),
  59. // 版权信息
  60. 'copyright_config' => ConfigService::get('copyright', 'config', []),
  61. ];
  62. return $config;
  63. }
  64. /**
  65. * @notes 根据类型获取字典类型
  66. * @param $type
  67. * @return array
  68. * @throws \think\db\exception\DataNotFoundException
  69. * @throws \think\db\exception\DbException
  70. * @throws \think\db\exception\ModelNotFoundException
  71. * @author 段誉
  72. * @date 2022/9/27 19:09
  73. */
  74. public static function getDictByType($type)
  75. {
  76. if (!is_string($type)) {
  77. return [];
  78. }
  79. $type = explode(',', $type);
  80. $lists = DictData::whereIn('type_value', $type)->select()->toArray();
  81. if (empty($lists)) {
  82. return [];
  83. }
  84. $result = [];
  85. foreach ($type as $item) {
  86. if (str_contains($item, 'data_table_')) {
  87. $table = str_replace('data_table_', '', $item);
  88. $result[$item] = getOptionDataByTable($table);
  89. }else{
  90. foreach ($lists as $dict) {
  91. if ($dict['type_value'] == $item) {
  92. $result[$item][] = $dict;
  93. }
  94. }
  95. }
  96. }
  97. return $result;
  98. }
  99. }