Snsalbum.php 3.1 KB

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