SystemConfigDao.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\dao\system\config;
  12. use app\dao\BaseDao;
  13. use app\model\system\config\SystemConfig;
  14. /**
  15. * 系统配置
  16. * Class SystemConfigDao
  17. * @package app\dao\system\config
  18. */
  19. class SystemConfigDao extends BaseDao
  20. {
  21. /**
  22. * 设置模型
  23. * @return string
  24. */
  25. protected function setModel(): string
  26. {
  27. return SystemConfig::class;
  28. }
  29. /**
  30. * 获取某个系统配置
  31. * @param string $configNmae
  32. * @return mixed
  33. * @throws \ReflectionException
  34. */
  35. public function getConfigValue(string $configNmae)
  36. {
  37. return $this->search(['menu_name' => $configNmae])->value('value');
  38. }
  39. /**
  40. * 获取所有配置
  41. * @param array $configName
  42. * @return array
  43. * @throws \ReflectionException
  44. */
  45. public function getConfigAll(array $configName = [])
  46. {
  47. if ($configName) {
  48. return $this->search(['menu_name' => $configName])->column('value', 'menu_name');
  49. } else {
  50. return $this->getModel()->column('value', 'menu_name');
  51. }
  52. }
  53. /**
  54. * 获取配置列表分页
  55. * @param array $where
  56. * @param int $page
  57. * @param int $limit
  58. * @return array
  59. * @throws \think\db\exception\DataNotFoundException
  60. * @throws \think\db\exception\DbException
  61. * @throws \think\db\exception\ModelNotFoundException
  62. */
  63. public function getConfigList(array $where, int $page, int $limit)
  64. {
  65. return $this->search($where)->page($page, $limit)->order('sort desc,id asc')->select()->toArray();
  66. }
  67. /**
  68. * 获取某些分类配置下的配置列表
  69. * @param int $tabId
  70. * @param int $status
  71. * @return array
  72. * @throws \think\db\exception\DataNotFoundException
  73. * @throws \think\db\exception\DbException
  74. * @throws \think\db\exception\ModelNotFoundException
  75. */
  76. public function getConfigTabAllList(int $tabId, int $status = 1)
  77. {
  78. $where['tab_id'] = $tabId;
  79. if ($status == 1) $where['status'] = $status;
  80. return $this->search($where)->order('sort desc,id ASC')->select()->toArray();
  81. }
  82. /**
  83. * 获取上传配置中的上传类型
  84. * @param string $configName
  85. * @return array
  86. * @throws \ReflectionException
  87. */
  88. public function getUploadTypeList(string $configName)
  89. {
  90. return $this->search(['menu_name' => $configName])->column('upload_type', 'type');
  91. }
  92. }