Fleafavorites.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. namespace app\common\model;
  3. use think\facade\Db;
  4. /**
  5. * ============================================================================
  6. *
  7. * ============================================================================
  8. * 版权所有 2014-2028 浙江惠利玛产业互联网有限公司,并保留所有权利。
  9. * 网站地址: https://www.valimart.net/
  10. * ----------------------------------------------------------------------------
  11. *
  12. * ============================================================================
  13. * 数据层模型
  14. */
  15. class Fleafavorites extends BaseModel {
  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. if (intval($fav_id) > 0) {
  28. $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();
  29. return $result;
  30. } else {
  31. return false;
  32. }
  33. }
  34. /**
  35. * 新增收藏
  36. * @access public
  37. * @author csdeshang
  38. * @param array $data 参数内容
  39. * @return bool 布尔类型的返回结果
  40. */
  41. public function addFleafavorites($data) {
  42. $result = Db::name('fleafavorites')->insert($data);
  43. return $result;
  44. }
  45. /**
  46. * 验证是否为当前用户收藏
  47. * @access public
  48. * @author csdeshang
  49. * @param type $fav_id 收藏ID
  50. * @param type $fav_type 收藏类型
  51. * @param type $member_id 会员ID
  52. * @return boolean
  53. */
  54. public function checkFleafavorites($fav_id, $fav_type, $member_id) {
  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. $result = Db::name('fleafavorites')->where($condition)->delete();
  74. return $result;
  75. }
  76. }