Activity.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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 Activity extends BaseModel
  16. {
  17. public $page_info;
  18. /**
  19. * 活动列表
  20. * @author csdeshang
  21. * @param type $condition 查询条件
  22. * @param type $pagesize 分页页数
  23. * @param type $order 排序
  24. * @return type
  25. */
  26. public function getActivityList($condition, $pagesize = '', $order = 'activity_sort asc') {
  27. if ($pagesize) {
  28. $res = Db::name('activity')->where($condition)->order($order)->paginate(['list_rows'=>$pagesize,'query' => request()->param()],false);
  29. $this->page_info = $res;
  30. return $res->items();
  31. } else {
  32. return Db::name('activity')->where($condition)->order($order)->select()->toArray();
  33. }
  34. }
  35. /**
  36. * 添加活动
  37. * @author csdeshang
  38. * @param type $data 查询数据
  39. * @return array 一维数组
  40. */
  41. public function addActivity($data)
  42. {
  43. return Db::name('activity')->insertGetId($data);
  44. }
  45. /**
  46. * 更新活动
  47. * @author csdeshang
  48. * @param type $data 活动数据
  49. * @param type $id 活动id
  50. * @return type
  51. */
  52. public function editActivity($data, $id)
  53. {
  54. return Db::name('activity')->where("activity_id='$id' ")->update($data);
  55. }
  56. /**
  57. * 删除活动
  58. * @author csdeshang
  59. * @param type $condition 删除条件
  60. * @return type
  61. */
  62. public function delActivity($condition)
  63. {
  64. return Db::name('activity')->where($condition)->delete();
  65. }
  66. /**
  67. * 根据id查询一条活动
  68. * @author csdeshang
  69. * @param int $id 活动id
  70. * @return array 一维数组
  71. */
  72. public function getOneActivityById($id)
  73. {
  74. return Db::name('activity')->where('activity_id',$id)->find();
  75. }
  76. }