BaseLogic.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. /**
  3. * Created by Administrator.
  4. * User: 向往那片天空
  5. * Date: 2022\5\21 0021
  6. * Time: 12:57
  7. * 格言: 抓住中心,宁精勿杂,宁专勿多
  8. * QQ/微信: 250023777
  9. * 描述: 无
  10. */
  11. namespace app\admin\logic;
  12. use app\admin\model\system\SystemAdmin;
  13. use crmeb\basic\BaseModel;
  14. use crmeb\traits\ModelTrait;
  15. use crmeb\services\JsonService;
  16. use think\facade\Route as Url;
  17. class BaseLogic extends BaseModel
  18. {
  19. protected $adminInfo;
  20. public function __construct(array $data = [])
  21. {
  22. parent::__construct($data);
  23. if (!SystemAdmin::hasActiveAdmin()) return $this->redirect(Url::buildUrl('login/index')->suffix(false)->build());
  24. try {
  25. $adminInfo = SystemAdmin::activeAdminInfoOrFail();
  26. } catch (\Exception $e) {
  27. return $this->failed(SystemAdmin::getErrorInfo($e->getMessage()), Url::buildUrl('login/index')->suffix(false)->build());
  28. }
  29. $this->adminInfo = $adminInfo;
  30. }
  31. public function delById($id)
  32. {
  33. $res = self::update([
  34. 'id' => $id,
  35. 'is_delete' => '1',
  36. ]);
  37. if (empty($res)) {
  38. return JsonService::fail('删除失败');
  39. }
  40. return JsonService::successful('删除成功');
  41. }
  42. }