控制台应用,yzncms本身基于tp5.1框架,里面的队列用不了,bug,坑
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

Publish.php 4.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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\controller\cms;
  15. use app\admin\model\cms\Cms as Cms_Model;
  16. use app\cms\model\CmsContent as CmsContentModel;
  17. use app\common\controller\Adminbase;
  18. use think\Db;
  19. class Publish extends Adminbase
  20. {
  21. protected function initialize()
  22. {
  23. parent::initialize();
  24. $this->Cms_Model = new Cms_Model;
  25. }
  26. public function index()
  27. {
  28. if ($this->request->isAjax()) {
  29. $limit = $this->request->param('limit/d', 10);
  30. $page = $this->request->param('page/d', 10);
  31. $total = CmsContentModel::count();
  32. $_list = CmsContentModel::page($page, $limit)->order(["id" => "DESC"])->select();
  33. foreach ($_list as $k => $v) {
  34. $modelid = getCategory($v['catid'], 'modelid');
  35. $tablename = ucwords(getModel($modelid, 'tablename'));
  36. $info = Db::name($tablename)->where(["id" => $v['content_id'], "sysadd" => 0])->find();
  37. if ($info) {
  38. $_list[$k]['url'] = buildContentUrl($v['catid'], $v['content_id'], $info['url']);
  39. $_list[$k]['title'] = $info['title'];
  40. $_list[$k]['catname'] = getCategory($v['catid'], 'catname');
  41. }
  42. }
  43. $result = ["code" => 0, "count" => $total, "data" => $_list];
  44. return json($result);
  45. }
  46. return $this->fetch();
  47. }
  48. //删除
  49. public function del()
  50. {
  51. $ids = $this->request->param('id/a', null);
  52. if (empty($ids)) {
  53. $this->error('请指定需要删除的信息!');
  54. }
  55. if (!is_array($ids)) {
  56. $ids = [0 => $ids];
  57. }
  58. foreach ($ids as $id) {
  59. //信息
  60. $info = CmsContentModel::where('id', $id)->find();
  61. //取得栏目信息
  62. $category = getCategory($info['catid']);
  63. if (!$category) {
  64. $this->success('栏目不存在!');
  65. }
  66. try {
  67. $this->Cms_Model->deleteModelData($category['modelid'], $info['content_id']);
  68. } catch (\Exception $ex) {
  69. $this->error($ex->getMessage());
  70. }
  71. }
  72. $this->success('删除成功!');
  73. }
  74. //通过审核
  75. public function pass()
  76. {
  77. $ids = $this->request->param('id/a', null);
  78. if (empty($ids)) {
  79. $this->error('请指定需要操作的信息!');
  80. }
  81. if (!is_array($ids)) {
  82. $ids = [0 => $ids];
  83. }
  84. foreach ($ids as $id) {
  85. $info = CmsContentModel::get($id);
  86. $info->status = 1;
  87. $info->save();
  88. $modelid = getCategory($info['catid'], 'modelid');
  89. $model_cache = cache("Model");
  90. $tablename = ucwords($model_cache[$modelid]['tablename']);
  91. Db::name($tablename)->where('id', $info['content_id'])->setField('status', 1);
  92. }
  93. $this->success('操作成功!');
  94. }
  95. //退稿
  96. public function reject()
  97. {
  98. $ids = $this->request->param('id/a', null);
  99. if (empty($ids)) {
  100. $this->error('请指定需要操作的信息!');
  101. }
  102. if (!is_array($ids)) {
  103. $ids = [0 => $ids];
  104. }
  105. foreach ($ids as $id) {
  106. $info = CmsContentModel::get($id);
  107. $info->status = -1;
  108. $info->save();
  109. $modelid = getCategory($info['catid'], 'modelid');
  110. $model_cache = cache("Model");
  111. $tablename = ucwords($model_cache[$modelid]['tablename']);
  112. Db::name($tablename)->where('id', $info['content_id'])->setField('status', 0);
  113. }
  114. $this->success('操作成功!');
  115. }
  116. }