AssetLists.php 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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\lists\asset;
  15. use app\adminapi\lists\BaseAdminDataLists;
  16. use app\common\lists\ListsSearchInterface;
  17. use app\common\model\article\Article;
  18. use app\common\model\notice\NoticeSetting;
  19. use app\common\model\asset\AssetInfo;
  20. use app\common\service\FileService;
  21. /**
  22. * 资产管理
  23. * Class AssetLists
  24. * @package app\adminapi\lists\asset
  25. */
  26. class AssetLists extends BaseAdminDataLists implements ListsSearchInterface
  27. {
  28. /**
  29. * @notes 搜索条件
  30. * @return \string[][]
  31. * @author
  32. * @date 2025/04/12 2:21 下午
  33. */
  34. public function setSearch(): array
  35. {
  36. return [
  37. '=' => ['name', 'status']
  38. ];
  39. }
  40. /**
  41. * @notes 资产信息列表
  42. * @return array
  43. * @throws \think\db\exception\DataNotFoundException
  44. * @throws \think\db\exception\DbException
  45. * @throws \think\db\exception\ModelNotFoundException
  46. * @author ljj
  47. * @date 2022/2/16 3:18 下午
  48. */
  49. public function lists(): array
  50. {
  51. $lists = (new AssetInfo())->field('id,name,address,images,contacts,mobile,area,content,status,create_time,sort')
  52. ->append(['status_desc'])
  53. ->where($this->searchWhere)
  54. ->limit($this->limitOffset, $this->limitLength)
  55. ->Order('sort desc')
  56. ->select()
  57. ->toArray();
  58. return $lists;
  59. }
  60. /**
  61. * @notes 资产信息数量
  62. * @return int
  63. * @author ljj
  64. * @date 2022/2/16 3:18 下午
  65. */
  66. public function count(): int
  67. {
  68. return (new AssetInfo())->where($this->searchWhere)->count();
  69. }
  70. /**
  71. * @notes 添加资产
  72. * @param array $params
  73. * @author heshihu
  74. * @date 2022/2/22 9:57
  75. */
  76. public static function add(array $params)
  77. {
  78. AssetInfo::create([
  79. 'name' => $params['name'],
  80. 'images' => $params['images'] ?? '',
  81. 'address' => $params['address'] ?? '',
  82. 'contacts' => $params['contacts']?? '', // 联系人
  83. 'mobile' => $params['mobile'] ?? '',
  84. 'area' => $params['area'] ?? '',
  85. 'content' => $params['content'] ?? '',
  86. // 'image' => $params['image'] ? FileService::setFileUrl($params['image']) : '',
  87. 'status' => $params['status'] ?? 1,
  88. 'sort' => $params['sort'] ?? 0, // 排序
  89. ]);
  90. }
  91. }