JobLogic.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <?php
  2. /**
  3. * Created by Administrator.
  4. * User: 向往那片天空
  5. * Date: 2022\5\21 0021
  6. * Time: 11:33
  7. * 格言: 抓住中心,宁精勿杂,宁专勿多
  8. * QQ/微信: 250023777
  9. * 描述: 无
  10. */
  11. namespace app\admin\logic\enterprise;
  12. use app\admin\controller\AuthController;
  13. use app\admin\model\enterprise\EnterPriseType as Type;
  14. use app\admin\model\system\SystemAdmin;
  15. use app\admin\logic\BaseLogic;
  16. use crmeb\exceptions\AuthException;
  17. use crmeb\services\JsonService;
  18. use crmeb\traits\ModelTrait;
  19. use think\facade\Db;
  20. use think\facade\Route as Url;
  21. class JobLogic extends \app\admin\logic\BaseLogic
  22. {
  23. use ModelTrait;
  24. protected $pk = 'id';
  25. protected $name = 'job';
  26. public function toggleIsShow($id)
  27. {
  28. $find = self::find($id);
  29. if (empty($find)) {
  30. return JsonService::fail('找不到记录');
  31. }
  32. $res = self::update([
  33. 'id' => $id,
  34. 'is_show' => $find['is_show'] == 1 ? 0 : 1,
  35. 'update_time' => time(),
  36. 'update_admin_id' => $this->adminInfo['id']
  37. ]);
  38. if (empty($res)) {
  39. return JsonService::fail('操作失败');
  40. }
  41. return JsonService::successful('操作成功');
  42. }
  43. public function getPageList($where)
  44. {
  45. $query = [];
  46. $query['is_delete'] = '0';
  47. if ($where['is_show'] != -1) {
  48. $query['is_show'] = $where['is_show'];
  49. }
  50. $list = self::where($query)->page($where['page'], $where['limit'])->order('rank desc,add_time desc')->select()->toArray();
  51. $count = count($list);
  52. // 通过行业Id获取行业名
  53. foreach ($list as &$v) {
  54. $v['add_time'] = date('Y-m-d H:i:s', $v['add_time']);
  55. }
  56. return JsonService::successlayui(['count' => $count, 'data' => $list]);
  57. }
  58. public function add($data)
  59. {
  60. $data['add_admin_id'] = $this->adminInfo['id'];
  61. $data['add_time'] = time();
  62. $res = self::insert($data);
  63. if (empty($res)) {
  64. return JsonService::fail('添加失败');
  65. }
  66. return JsonService::successful('添加成功');
  67. }
  68. public function edit($data)
  69. {
  70. $data['update_admin_id'] = $this->adminInfo['id'];
  71. $data['edit_time'] = time();
  72. $res = self::update($data);
  73. if (empty($res)) {
  74. return JsonService::fail('修改失败');
  75. }
  76. return JsonService::successful('修改成功');
  77. }
  78. public function getList($where)
  79. {
  80. return self::where($where)->order('rank desc,add_time desc')->select()->toArray();
  81. }
  82. }