Snsalbum.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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 Snsalbum extends BaseModel
  16. {
  17. public $page_info;
  18. /**
  19. * 获取默认相册分类
  20. * @access public
  21. * @author csdeshang
  22. * @param type $member_id 会员id
  23. * @return bool
  24. */
  25. public function getSnsAlbumClassDefault($member_id) {
  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. if($pagesize){
  45. $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);
  46. $this->page_info = $result;
  47. return $result->items();
  48. } else {
  49. 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();
  50. }
  51. }
  52. /**
  53. * 获取会员相册数量列表
  54. * @param type $condition
  55. * @param type $field
  56. * @param type $group
  57. * @return type
  58. */
  59. public function getSnsalbumpicCountList($condition,$field,$group){
  60. return Db::name('snsalbumpic')->field($field)->where($condition)->group($group)->select()->toArray();
  61. }
  62. /**
  63. * 获取图片列表
  64. * @param type $condition
  65. * @return type
  66. */
  67. public function getSnsalbumpicList($condition,$pagesize=''){
  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. return Db::name('snsalbumpic')->where($condition)->delete();
  84. }
  85. /**
  86. * 获取单个图片
  87. * @param type $id
  88. * @return type
  89. */
  90. public function getOneSnsalbumpic($id){
  91. return Db::name('snsalbumpic')->find($id);
  92. }
  93. /**
  94. * 根据ID删除图片
  95. * @param type $id
  96. * @return type
  97. */
  98. public function delPic($id){
  99. return Db::name('snsalbumpic')->delete($id);
  100. }
  101. }