控制台应用,yzncms本身基于tp5.1框架,里面的队列用不了,bug,坑
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Page.php 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | Yzncms [ 御宅男工作室 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2018 http://yzncms.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
  8. // +----------------------------------------------------------------------
  9. // | Author: 御宅男 <530765310@qq.com>
  10. // +----------------------------------------------------------------------
  11. // +----------------------------------------------------------------------
  12. // | 单页模型
  13. // +----------------------------------------------------------------------
  14. namespace app\admin\model\cms;
  15. use think\Model;
  16. class Page extends Model
  17. {
  18. protected $pk = 'catid';
  19. protected $autoWriteTimestamp = true;
  20. /**
  21. * 根据栏目ID获取内容
  22. *
  23. * @param type $catid 栏目ID
  24. *
  25. * @return boolean
  26. */
  27. public function getPage($catid, $cache = false)
  28. {
  29. if (empty($catid)) {
  30. return false;
  31. }
  32. if (is_numeric($cache)) {
  33. $cache = (int) $cache;
  34. }
  35. return self::get($catid, $cache);
  36. }
  37. /**
  38. * 更新单页内容
  39. *
  40. * @param $data
  41. *
  42. * @return boolean
  43. */
  44. public function savePage($data)
  45. {
  46. if (empty($data)) {
  47. $this->error = '内容不能为空!';
  48. return false;
  49. }
  50. $data['create_time'] = strtotime($data['create_time']);
  51. $row = self::get($data['catid']);
  52. if ($row) {
  53. //更新
  54. self::update($data, [], true);
  55. } else {
  56. //新增
  57. self::create($data, true);
  58. }
  59. return true;
  60. }
  61. }