Fleafavorites.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. namespace app\common\model;
  3. use think\facade\Db;
  4. /**
  5. *
  6. *
  7. * ----------------------------------------------------------------------------
  8. *
  9. * 数据层模型
  10. */
  11. class Fleafavorites extends BaseModel
  12. {
  13. public $page_info;
  14. /**
  15. * 取单个收藏的内容
  16. * @access public
  17. * @author csdeshang
  18. * @param type $fav_id 收藏ID
  19. * @param type $type 收藏类型
  20. * @param type $member_id 会员ID
  21. * @return boolean
  22. */
  23. public function getOneFleafavorites($fav_id, $type, $member_id)
  24. {
  25. if (intval($fav_id) > 0) {
  26. $result = Db::name('fleafavorites')->where('fleafav_id', intval($fav_id))->where('fleafav_type', $type)->where('member_id', $member_id)->field('fleafav_id,member_id,fleafav_type')->find();
  27. return $result;
  28. } else {
  29. return false;
  30. }
  31. }
  32. /**
  33. * 新增收藏
  34. * @access public
  35. * @author csdeshang
  36. * @param array $data 参数内容
  37. * @return bool 布尔类型的返回结果
  38. */
  39. public function addFleafavorites($data)
  40. {
  41. $result = Db::name('fleafavorites')->insert($data);
  42. return $result;
  43. }
  44. /**
  45. * 验证是否为当前用户收藏
  46. * @access public
  47. * @author csdeshang
  48. * @param type $fav_id 收藏ID
  49. * @param type $fav_type 收藏类型
  50. * @param type $member_id 会员ID
  51. * @return boolean
  52. */
  53. public function checkFleafavorites($fav_id, $fav_type, $member_id)
  54. {
  55. if (intval($fav_id) == 0 || empty($fav_type) || intval($member_id) == 0) {
  56. return true;
  57. }
  58. $result = self::getOneFleafavorites($fav_id, $fav_type, $member_id);
  59. if ($result['member_id'] == $member_id) {
  60. return true;
  61. } else {
  62. return false;
  63. }
  64. }
  65. /**
  66. * 删除
  67. * @access public
  68. * @author csdeshang
  69. * @param type $condition
  70. * @return boolean
  71. */
  72. public function delFleafavorites($condition)
  73. {
  74. $result = Db::name('fleafavorites')->where($condition)->delete();
  75. return $result;
  76. }
  77. }