Snsalbum.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <?php
  2. namespace app\common\model;
  3. use think\facade\Db;
  4. /**
  5. * ============================================================================
  6. * DSMall多用户商城
  7. * ============================================================================
  8. * 版权所有 2014-2028 长沙德尚网络科技有限公司,并保留所有权利。
  9. * 网站地址: http://www.csdeshang.com
  10. * ----------------------------------------------------------------------------
  11. * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用 .
  12. * 不允许对程序代码以任何形式任何目的的再发布。
  13. * ============================================================================
  14. * 数据层模型
  15. */
  16. class Snsalbum extends BaseModel
  17. {
  18. public $page_info;
  19. /**
  20. * 获取默认相册分类
  21. * @access public
  22. * @author csdeshang
  23. * @param type $member_id 会员id
  24. * @return bool
  25. */
  26. public function getSnsAlbumClassDefault($member_id) {
  27. if(empty($member_id)) {
  28. return '0';
  29. }
  30. $info = Db::name('snsalbumclass')->where('member_id',$member_id)->where('ac_isdefault',1)->find();
  31. if(!empty($info)) {
  32. return $info['ac_id'];
  33. } else {
  34. return '0';
  35. }
  36. }
  37. /**
  38. * 获取会员相册分类列表
  39. * @param type $condition
  40. * @param type $pagesize
  41. * @param type $field
  42. * @return type
  43. */
  44. public function getSnsalbumclassList($condition,$pagesize,$field){
  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. return Db::name('snsalbumpic')->field($field)->where($condition)->group($group)->select()->toArray();
  62. }
  63. /**
  64. * 获取图片列表
  65. * @param type $condition
  66. * @return type
  67. */
  68. public function getSnsalbumpicList($condition,$pagesize=''){
  69. if($pagesize){
  70. $pic_list = Db::name('snsalbumpic')->where($condition)->paginate(['list_rows'=>$pagesize,'query' => request()->param()],false);
  71. $this->page_info=$pic_list;
  72. return $pic_list->items();
  73. } else {
  74. $pic_list = Db::name('snsalbumpic')->where($condition)->select()->toArray();
  75. return $pic_list;
  76. }
  77. }
  78. /**
  79. * 删除图片
  80. * @param type $condition
  81. * @return type
  82. */
  83. public function delSnsalbumpic($condition){
  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. return Db::name('snsalbumpic')->find($id);
  93. }
  94. /**
  95. * 根据ID删除图片
  96. * @param type $id
  97. * @return type
  98. */
  99. public function delPic($id){
  100. return Db::name('snsalbumpic')->delete($id);
  101. }
  102. }