Fleafavorites.php 2.4 KB

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