WorkbenchLogic.php 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  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\common\logic\BaseLogic;
  16. use app\common\service\ConfigService;
  17. use app\common\service\FileService;
  18. /**
  19. * 工作台
  20. * Class WorkbenchLogic
  21. * @package app\adminapi\logic
  22. */
  23. class WorkbenchLogic extends BaseLogic
  24. {
  25. /**
  26. * @notes 工作套
  27. * @param $adminInfo
  28. * @return array
  29. * @author 段誉
  30. * @date 2021/12/29 15:58
  31. */
  32. public static function index()
  33. {
  34. return [
  35. // 版本信息
  36. 'version' => self::versionInfo(),
  37. // 今日数据
  38. 'today' => self::today(),
  39. // 常用功能
  40. 'menu' => self::menu(),
  41. // 近15日访客数
  42. 'visitor' => self::visitor(),
  43. // 服务支持
  44. 'support' => self::support()
  45. ];
  46. }
  47. /**
  48. * @notes 常用功能
  49. * @return array[]
  50. * @author 段誉
  51. * @date 2021/12/29 16:40
  52. */
  53. public static function menu(): array
  54. {
  55. return [
  56. [
  57. 'name' => '管理员',
  58. 'image' => FileService::getFileUrl(config('project.default_image.menu_admin')),
  59. 'url' => '/permission/admin'
  60. ],
  61. [
  62. 'name' => '角色管理',
  63. 'image' => FileService::getFileUrl(config('project.default_image.menu_role')),
  64. 'url' => '/permission/role'
  65. ],
  66. [
  67. 'name' => '部门管理',
  68. 'image' => FileService::getFileUrl(config('project.default_image.menu_dept')),
  69. 'url' => '/organization/department'
  70. ],
  71. [
  72. 'name' => '字典管理',
  73. 'image' => FileService::getFileUrl(config('project.default_image.menu_dict')),
  74. 'url' => '/dev_tools/dict'
  75. ],
  76. [
  77. 'name' => '代码生成器',
  78. 'image' => FileService::getFileUrl(config('project.default_image.menu_generator')),
  79. 'url' => '/dev_tools/code'
  80. ],
  81. [
  82. 'name' => '素材中心',
  83. 'image' => FileService::getFileUrl(config('project.default_image.menu_file')),
  84. 'url' => '/material/index'
  85. ],
  86. [
  87. 'name' => '菜单权限',
  88. 'image' => FileService::getFileUrl(config('project.default_image.menu_auth')),
  89. 'url' => '/permission/menu'
  90. ],
  91. [
  92. 'name' => '网站信息',
  93. 'image' => FileService::getFileUrl(config('project.default_image.menu_web')),
  94. 'url' => '/setting/website/information'
  95. ],
  96. ];
  97. }
  98. /**
  99. * @notes 版本信息
  100. * @return array
  101. * @author 段誉
  102. * @date 2021/12/29 16:08
  103. */
  104. public static function versionInfo(): array
  105. {
  106. return [
  107. 'version' => config('project.version'),
  108. 'website' => config('project.website.url'),
  109. 'name' => ConfigService::get('website', 'name'),
  110. 'based' => 'vue3.x、ElementUI、MySQL',
  111. 'channel' => [
  112. 'website' => 'https://www.likeadmin.cn',
  113. 'gitee' => 'https://gitee.com/likeadmin/likeadmin_php',
  114. ]
  115. ];
  116. }
  117. /**
  118. * @notes 今日数据
  119. * @return int[]
  120. * @author 段誉
  121. * @date 2021/12/29 16:15
  122. */
  123. public static function today(): array
  124. {
  125. return [
  126. 'time' => date('Y-m-d H:i:s'),
  127. // 今日销售额
  128. 'today_sales' => 100,
  129. // 总销售额
  130. 'total_sales' => 1000,
  131. // 今日访问量
  132. 'today_visitor' => 10,
  133. // 总访问量
  134. 'total_visitor' => 100,
  135. // 今日新增用户量
  136. 'today_new_user' => 30,
  137. // 总用户量
  138. 'total_new_user' => 3000,
  139. // 订单量 (笔)
  140. 'order_num' => 12,
  141. // 总订单量
  142. 'order_sum' => 255
  143. ];
  144. }
  145. /**
  146. * @notes 访问数
  147. * @return array
  148. * @author 段誉
  149. * @date 2021/12/29 16:57
  150. */
  151. public static function visitor(): array
  152. {
  153. $num = [];
  154. $date = [];
  155. for ($i = 0; $i < 15; $i++) {
  156. $where_start = strtotime("- " . $i . "day");
  157. $date[] = date('Y/m/d', $where_start);
  158. $num[$i] = rand(0, 100);
  159. }
  160. return [
  161. 'date' => $date,
  162. 'list' => [
  163. ['name' => '访客数', 'data' => $num]
  164. ]
  165. ];
  166. }
  167. /**
  168. * @notes 服务支持
  169. * @return array[]
  170. * @author 段誉
  171. * @date 2022/7/18 11:18
  172. */
  173. public static function support()
  174. {
  175. return [
  176. [
  177. 'image' => FileService::getFileUrl(config('project.default_image.qq_group')),
  178. 'title' => '官方公众号',
  179. 'desc' => '关注官方公众号',
  180. ],
  181. [
  182. 'image' => FileService::getFileUrl(config('project.default_image.customer_service')),
  183. 'title' => '添加企业客服微信',
  184. 'desc' => '想了解更多请添加客服',
  185. ]
  186. ];
  187. }
  188. }