心理咨询网
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

MemberCommentModel.php 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <?php
  2. /**
  3. * @copyright (C)2016-2099 Hnaoyun Inc.
  4. * @author XingMeng
  5. * @email hnxsh@foxmail.com
  6. * @date 2020年06月27日
  7. * 文章评论模型类
  8. */
  9. namespace app\admin\model\member;
  10. use core\basic\Model;
  11. class MemberCommentModel extends Model
  12. {
  13. // 获取列表
  14. public function getList()
  15. {
  16. $field = array(
  17. 'a.*',
  18. 'b.title',
  19. 'c.username',
  20. 'c.nickname',
  21. 'c.headpic'
  22. );
  23. $join = array(
  24. array(
  25. 'ay_content b',
  26. 'a.contentid=b.id',
  27. 'LEFT'
  28. ),
  29. array(
  30. 'ay_member c',
  31. 'a.uid=c.id',
  32. 'LEFT'
  33. )
  34. );
  35. return parent::table('ay_member_comment a')->field($field)
  36. ->join($join)
  37. ->order('a.id desc')
  38. ->page()
  39. ->select();
  40. }
  41. // 查找
  42. public function findComment($field, $keyword)
  43. {
  44. $fields = array(
  45. 'a.*',
  46. 'b.title',
  47. 'c.username',
  48. 'c.nickname',
  49. 'c.headpic'
  50. );
  51. $join = array(
  52. array(
  53. 'ay_content b',
  54. 'a.contentid=b.id',
  55. 'LEFT'
  56. ),
  57. array(
  58. 'ay_member c',
  59. 'a.uid=c.id',
  60. 'LEFT'
  61. )
  62. );
  63. return parent::table('ay_member_comment a')->field($fields)
  64. ->join($join)
  65. ->like($field, $keyword)
  66. ->order('a.id desc')
  67. ->page()
  68. ->select();
  69. }
  70. // 获取详情
  71. public function getComment($id)
  72. {
  73. $field = array(
  74. 'a.*',
  75. 'b.title',
  76. 'c.username',
  77. 'c.nickname',
  78. 'c.headpic',
  79. 'd.username as pusername',
  80. 'd.nickname as pnickname'
  81. );
  82. $join = array(
  83. array(
  84. 'ay_content b',
  85. 'a.contentid=b.id',
  86. 'LEFT'
  87. ),
  88. array(
  89. 'ay_member c',
  90. 'a.uid=c.id',
  91. 'LEFT'
  92. ),
  93. array(
  94. 'ay_member d',
  95. 'a.puid=d.id',
  96. 'LEFT'
  97. )
  98. );
  99. return parent::table('ay_member_comment a')->field($field)
  100. ->join($join)
  101. ->where("a.id=$id")
  102. ->find();
  103. }
  104. // 删除
  105. public function delComment($id)
  106. {
  107. return parent::table('ay_member_comment')->where("id=$id")->delete();
  108. }
  109. // 删除多个
  110. public function delCommentList($ids)
  111. {
  112. return parent::table('ay_member_comment')->delete($ids);
  113. }
  114. // 修改
  115. public function modComment($id, $data)
  116. {
  117. return parent::table('ay_member_comment')->where("id=$id")
  118. ->autoTime()
  119. ->update($data);
  120. }
  121. // 修改多个
  122. public function modCommentList($ids, $data)
  123. {
  124. return parent::table('ay_member_comment')->in('id', $ids)->update($data);
  125. }
  126. }