FeedbackDao.php 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\common\dao\user;
  12. use app\common\dao\BaseDao;
  13. use app\common\model\BaseModel;
  14. use app\common\model\user\Feedback;
  15. use think\db\BaseQuery;
  16. /**
  17. * Class FeedbackDao
  18. * @package app\common\dao\user
  19. * @author xaboy
  20. * @day 2020/5/28
  21. */
  22. class FeedbackDao extends BaseDao
  23. {
  24. /**
  25. * @return string
  26. * @author xaboy
  27. * @day 2020/5/28
  28. */
  29. protected function getModel(): string
  30. {
  31. return Feedback::class;
  32. }
  33. /**
  34. * @param array $where
  35. * @return BaseQuery
  36. * @author xaboy
  37. * @day 2020/5/28
  38. */
  39. public function search(array $where)
  40. {
  41. return Feedback::getDB()->when(isset($where['uid']) && $where['uid'] !== '', function ($query) use ($where) {
  42. $query->where('uid', $where['uid']);
  43. })->when(isset($where['keyword']) && $where['keyword'] !== '', function ($query) use ($where) {
  44. $query->where('content','like', '%'.$where['keyword'].'%')->whereOr('reply','like', '%'.$where['keyword'].'%')->whereOr('remake','like', '%'.$where['keyword'].'%');
  45. })->when(isset($where['type']) && $where['type'] !== '', function ($query) use ($where) {
  46. $query->where('type',$where['type']);
  47. })->when(isset($where['status']) && $where['status'] !== '', function ($query) use ($where) {
  48. $query->where('status', $where['status']);
  49. })->when(isset($where['realname']) && $where['realname'] !== '', function ($query) use ($where) {
  50. $query->where('realname','like', '%'.$where['realname'].'%');
  51. })->when(isset($where['is_del']) && $where['is_del'] !== '', function ($query) use ($where) {
  52. $query->where('is_del',$where['is_del']);
  53. })->order('create_time DESC');
  54. }
  55. /**
  56. * @param $id
  57. * @param $uid
  58. * @return bool
  59. * @author xaboy
  60. * @day 2020/5/28
  61. */
  62. public function uidExists($id, $uid): bool
  63. {
  64. return Feedback::getDB()->where($this->getPk(), $id)->where('uid', $uid)->where('is_del', 0)->count($this->getPk()) > 0;
  65. }
  66. public function merExists(int $id)
  67. {
  68. return $this->getModel()::getDB()->where($this->getPk(), $id)->where('is_del', 0)->count() > 0;
  69. }
  70. }