Material.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <?php
  2. /**
  3. * Niushop商城系统 - 团队十年电商经验汇集巨献!
  4. * =========================================================
  5. * Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
  6. * ----------------------------------------------
  7. * 官方网址: https://www.niushop.com
  8. * =========================================================
  9. */
  10. namespace addon\wechat\model;
  11. use think\facade\Cache;
  12. use app\model\BaseModel;
  13. /**
  14. * 微信素材管理
  15. */
  16. class Material extends BaseModel
  17. {
  18. /**
  19. * 添加微信素材
  20. * @param array $data
  21. */
  22. public function addMaterial($data)
  23. {
  24. $res = model('wechat_media')->add($data);
  25. return $this->success($res);
  26. }
  27. /**
  28. * 修改微信素材
  29. * @param array $data
  30. * @param array $condition
  31. * @return multitype:string mixed
  32. */
  33. public function editMaterial($data, $condition)
  34. {
  35. $res = model('wechat_media')->update($data, $condition);
  36. return $this->success($res);
  37. }
  38. /**
  39. * 删除微信素材
  40. * @param array $condition
  41. * @return multitype:string mixed
  42. */
  43. public function deleteMaterial($condition)
  44. {
  45. $res = model('wechat_media')->delete($condition);
  46. return $this->success($res);
  47. }
  48. /**
  49. * 获取微信素材信息
  50. * @param array $condition
  51. * @param string $field
  52. * @return multitype:string mixed
  53. */
  54. public function getMaterialInfo($condition, $field = '*')
  55. {
  56. $res = model('wechat_media')->getInfo($condition, $field);
  57. return $this->success($res);
  58. }
  59. /**
  60. * 获取微信素材列表
  61. * @param array $condition
  62. * @param string $field
  63. * @param string $order
  64. * @param string $limit
  65. */
  66. public function getMaterialList($condition = [], $field = '*', $order = '', $limit = null)
  67. {
  68. $res = model('wechat_media')->getList($condition, $field, $order, '', '', '', $limit);
  69. return $this->success($res);
  70. }
  71. /**
  72. * 获取微信素材分页列表
  73. * @param array $condition
  74. * @param number $page
  75. * @param string $page_size
  76. * @param string $order
  77. * @param string $field
  78. * @return multitype:string mixed
  79. */
  80. public function getMaterialPageList($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $order = 'update_time desc', $field = '*')
  81. {
  82. $list = model('wechat_media')->pageList($condition, $field, $order, $page, $page_size);
  83. return $this->success($list);
  84. }
  85. }