Snsalbum.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <?php
  2. namespace app\common\model;
  3. use think\facade\Db;
  4. /**
  5. * ============================================================================
  6. *
  7. * ============================================================================
  8. *
  9. * ----------------------------------------------------------------------------
  10. *
  11. * ============================================================================
  12. * 数据层模型
  13. */
  14. class Snsalbum extends BaseModel
  15. {
  16. public $page_info;
  17. /**
  18. * 获取默认相册分类
  19. * @access public
  20. * @author csdeshang
  21. * @param type $member_id 会员id
  22. * @return bool
  23. */
  24. public function getSnsAlbumClassDefault($member_id)
  25. {
  26. if (empty($member_id)) {
  27. return '0';
  28. }
  29. $info = Db::name('snsalbumclass')->where('member_id', $member_id)->where('ac_isdefault', 1)->find();
  30. if (!empty($info)) {
  31. return $info['ac_id'];
  32. } else {
  33. return '0';
  34. }
  35. }
  36. /**
  37. * 获取会员相册分类列表
  38. * @param type $condition
  39. * @param type $pagesize
  40. * @param type $field
  41. * @return type
  42. */
  43. public function getSnsalbumclassList($condition, $pagesize, $field)
  44. {
  45. if ($pagesize) {
  46. $result = Db::name('snsalbumclass')->alias('a')->field('a.*,m.member_name')->join('member m', 'a.member_id=m.member_id', 'LEFT')->where($condition)->paginate(['list_rows' => $pagesize, 'query' => request()->param()], false);
  47. $this->page_info = $result;
  48. return $result->items();
  49. } else {
  50. return Db::name('snsalbumclass')->alias('a')->field('a.*,m.member_name')->join('member m', 'a.member_id=m.member_id', 'LEFT')->where($condition)->select()->toArray();
  51. }
  52. }
  53. /**
  54. * 获取会员相册数量列表
  55. * @param type $condition
  56. * @param type $field
  57. * @param type $group
  58. * @return type
  59. */
  60. public function getSnsalbumpicCountList($condition, $field, $group)
  61. {
  62. return Db::name('snsalbumpic')->field($field)->where($condition)->group($group)->select()->toArray();
  63. }
  64. /**
  65. * 获取图片列表
  66. * @param type $condition
  67. * @return type
  68. */
  69. public function getSnsalbumpicList($condition, $pagesize = '')
  70. {
  71. if ($pagesize) {
  72. $pic_list = Db::name('snsalbumpic')->where($condition)->paginate(['list_rows' => $pagesize, 'query' => request()->param()], false);
  73. $this->page_info = $pic_list;
  74. return $pic_list->items();
  75. } else {
  76. $pic_list = Db::name('snsalbumpic')->where($condition)->select()->toArray();
  77. return $pic_list;
  78. }
  79. }
  80. /**
  81. * 删除图片
  82. * @param type $condition
  83. * @return type
  84. */
  85. public function delSnsalbumpic($condition)
  86. {
  87. return Db::name('snsalbumpic')->where($condition)->delete();
  88. }
  89. /**
  90. * 获取单个图片
  91. * @param type $id
  92. * @return type
  93. */
  94. public function getOneSnsalbumpic($id)
  95. {
  96. return Db::name('snsalbumpic')->find($id);
  97. }
  98. /**
  99. * 根据ID删除图片
  100. * @param type $id
  101. * @return type
  102. */
  103. public function delPic($id)
  104. {
  105. return Db::name('snsalbumpic')->delete($id);
  106. }
  107. }