| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151 |
- <?php
- // +----------------------------------------------------------------------
- // | likeadmin快速开发前后端分离管理后台(PHP版)
- // +----------------------------------------------------------------------
- // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
- // | 开源版本可自由商用,可去除界面版权logo
- // | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
- // | github下载:https://github.com/likeshop-github/likeadmin
- // | 访问官网:https://www.likeadmin.cn
- // | likeadmin团队 版权所有 拥有最终解释权
- // +----------------------------------------------------------------------
- // | author: likeadminTeam
- // +----------------------------------------------------------------------
- namespace app\adminapi\lists\asset;
- use app\adminapi\lists\BaseAdminDataLists;
- use app\common\lists\ListsSearchInterface;
- use app\common\model\article\Article;
- use app\common\model\notice\NoticeSetting;
- use app\common\model\asset\AssetInfo;
- use app\common\service\FileService;
- /**
- * 资产管理
- * Class AssetLists
- * @package app\adminapi\lists\asset
- */
- class AssetLists extends BaseAdminDataLists implements ListsSearchInterface
- {
- /**
- * @notes 搜索条件
- * @return \string[][]
- * @author
- * @date 2025/04/12 2:21 下午
- */
- public function setSearch(): array
- {
- return [
- '=' => ['name', 'status']
- ];
- }
- /**
- * @notes 资产信息列表
- * @return array
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- * @author ljj
- * @date 2022/2/16 3:18 下午
- */
- public function lists(): array
- {
- $lists = (new AssetInfo())->field('id,name,address,images,contacts,mobile,area,content,status,lease_status,create_time,sort')
- ->append(['status_desc','lease_status_desc'])
- ->where($this->searchWhere)
- ->limit($this->limitOffset, $this->limitLength)
- ->Order('sort desc')
- ->select()
- ->toArray();
- return $lists;
- }
- /**
- * @notes 资产信息数量
- * @return int
- * @author ljj
- * @date 2022/2/16 3:18 下午
- */
- public function count(): int
- {
- return (new AssetInfo())->where($this->searchWhere)->count();
- }
- /**
- * @notes 添加资产
- * @param array $params
- * @author heshihu
- * @date 2022/2/22 9:57
- */
- public static function add(array $params)
- {
- AssetInfo::create([
- 'name' => $params['name'],
- 'images' => $params['images'] ?? '',
- 'address' => $params['address'] ?? '',
- 'contacts' => $params['contacts']?? '', // 联系人
- 'mobile' => $params['mobile'] ?? '',
- 'area' => $params['area'] ?? '',
- 'content' => $params['content'] ?? '',
- // 'image' => $params['image'] ? FileService::setFileUrl($params['image']) : '',
- 'status' => $params['status'] ?? 1,
- 'sort' => $params['sort'] ?? 0, // 排序
- ]);
- }
- /**
- * @notes 编辑资产
- * @param array $params
- * @return bool
- * @author heshihu
- * @date 2022/2/22 10:12
- */
- public static function edit(array $params) : bool
- {
- try {
- AssetInfo::update([
- 'id' => $params['id'],
- 'name' => $params['name'],
- 'images' => $params['images'],
- 'address' => $params['address'],
- 'contacts' => $params['contacts'],
- 'mobile' => $params['mobile'],
- 'area' => $params['area'] ?? '',
- 'content' => $params['content'] ?? '',
- 'status' => $params['status'] ?? 1,
- 'sort' => $params['sort'] ?? 0,
- 'content' => $params['content'] ?? '',
- ]);
- return true;
- } catch (\Exception $e) {
- self::setError($e->getMessage());
- return false;
- }
- }
- /**
- * @notes 删除资产
- * @param array $params
- * @author heshihu
- * @date 2022/2/22 10:17
- */
- public static function delete(array $params)
- {
- AssetInfo::destroy($params['id']);
- }
- /**
- * @notes 查看资产详情
- * @param $params
- * @return array
- * @author heshihu
- * @date 2022/2/22 10:15
- */
- public static function detail($params) : array
- {
- return AssetInfo::findOrEmpty($params['id'])->append(['status_desc','lease_status_desc'])->toArray();
- }
- }
|