RewardsCate.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. /**
  3. +-----------------------------------------------------------------------------------------------
  4. * GouGuOPEN [ 左手研发,右手开源,未来可期!]
  5. +-----------------------------------------------------------------------------------------------
  6. * @Copyright (c) 2021~2024 http://www.gouguoa.com All rights reserved.
  7. +-----------------------------------------------------------------------------------------------
  8. * @Licensed 勾股OA,开源且可免费使用,但并不是自由软件,未经授权许可不能去除勾股OA的相关版权信息
  9. +-----------------------------------------------------------------------------------------------
  10. * @Author 勾股工作室 <hdm58@qq.com>
  11. +-----------------------------------------------------------------------------------------------
  12. */
  13. namespace app\user\model;
  14. use think\model;
  15. class RewardsCate extends Model
  16. {
  17. /**
  18. * 获取分页列表
  19. * @param $where
  20. * @param $param
  21. */
  22. public function getList($where, $param)
  23. {
  24. $rows = empty($param['limit']) ? get_config('app.page_size') : $param['limit'];
  25. $order = empty($param['order']) ? 'id desc' : $param['order'];
  26. try {
  27. $list = $this->where($where)->order($order)->paginate(['list_rows'=> $rows]);
  28. return $list;
  29. } catch(\Exception $e) {
  30. return ['code' => 1, 'data' => [], 'msg' => $e->getMessage()];
  31. }
  32. }
  33. /**
  34. * 添加数据
  35. * @param $param
  36. */
  37. public function add($param)
  38. {
  39. $insertId = 0;
  40. try {
  41. $param['create_time'] = time();
  42. $insertId = $this->strict(false)->field(true)->insertGetId($param);
  43. add_log('add', $insertId, $param);
  44. } catch(\Exception $e) {
  45. return to_assign(1, '操作失败,原因:'.$e->getMessage());
  46. }
  47. return to_assign(0,'操作成功',['aid'=>$insertId]);
  48. }
  49. /**
  50. * 编辑信息
  51. * @param $param
  52. */
  53. public function edit($param)
  54. {
  55. try {
  56. $param['update_time'] = time();
  57. $this->where('id', $param['id'])->strict(false)->field(true)->update($param);
  58. add_log('edit', $param['id'], $param);
  59. } catch(\Exception $e) {
  60. return to_assign(1, '操作失败,原因:'.$e->getMessage());
  61. }
  62. return to_assign();
  63. }
  64. /**
  65. * 根据id获取信息
  66. * @param $id
  67. */
  68. public function getById($id)
  69. {
  70. $info = $this->where('id', $id)->find();
  71. return $info;
  72. }
  73. }