Industry.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\customer\model;
  14. use think\model;
  15. use think\facade\Db;
  16. class Industry extends Model
  17. {
  18. /**
  19. * 获取分页列表
  20. * @param $where
  21. * @param $param
  22. */
  23. public function datalist($where, $param)
  24. {
  25. $rows = empty($param['limit']) ? get_config('app.page_size') : $param['limit'];
  26. $order = empty($param['order']) ? 'id desc' : $param['order'];
  27. try {
  28. $list = self::where($where)->order($order)->paginate(['list_rows'=> $rows]);
  29. return $list;
  30. } catch(\Exception $e) {
  31. return ['code' => 1, 'data' => [], 'msg' => $e->getMessage()];
  32. }
  33. }
  34. /**
  35. * 添加数据
  36. * @param $param
  37. */
  38. public function add($param)
  39. {
  40. $insertId = 0;
  41. try {
  42. $param['create_time'] = time();
  43. $insertId = self::strict(false)->field(true)->insertGetId($param);
  44. add_log('add', $insertId, $param);
  45. } catch(\Exception $e) {
  46. return to_assign(1, '操作失败,原因:'.$e->getMessage());
  47. }
  48. return to_assign(0,'操作成功',['return_id'=>$insertId]);
  49. }
  50. /**
  51. * 编辑信息
  52. * @param $param
  53. */
  54. public function edit($param)
  55. {
  56. try {
  57. $param['update_time'] = time();
  58. self::where('id', $param['id'])->strict(false)->field(true)->update($param);
  59. add_log('edit', $param['id'], $param);
  60. } catch(\Exception $e) {
  61. return to_assign(1, '操作失败,原因:'.$e->getMessage());
  62. }
  63. return to_assign(0,'操作成功',['return_id'=>$param['id']]);
  64. }
  65. /**
  66. * 根据id获取信息
  67. * @param $id
  68. */
  69. public function getById($id)
  70. {
  71. $info = self::find($id);
  72. return $info;
  73. }
  74. }