| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- <?php
- namespace app\admin\controller\system;
- use app\admin\logic\SystemAdminLogic;
- use app\admin\logic\SystemArticleLogic;
- use app\admin\model\dao\SystemArticle;
- use app\admin\model\dao\SystemArticleType;
- use app\common\controller\AdminController;
- use app\common\model\ArticleTypeModel;
- use app\common\model\CouponPlanModel;
- use app\common\model\SystemArticleModel;
- use app\common\model\SystemBannerModel;
- use app\common\model\UserModel;
- use think\App;
- use think\facade\Db;
- use think\Request;
- /**
- * @ControllerAnnotation(title="系统公告/文章配置")
- */
- class Article extends AdminController
- {
- use \app\admin\traits\Curd;
- public function __construct(App $app)
- {
- parent::__construct($app);
- $this->model = new SystemArticleModel();
- }
- public function index()
- {
- if ($this->request->isAjax()) {
- if (input('selectFields')) {
- return $this->selectList();
- }
- list($page, $limit, $where) = $this->buildTableParames();
- list($count, $list) = SystemArticleLogic::getList($page, $limit, $where, $this->sort);
- $data = [
- 'code' => 0,
- 'msg' => '',
- 'count' => $count,
- 'data' => $list,
- ];
- return json($data);
- }
- return $this->fetch();
- }
- /**
- * @NodeAnotation(title="修改")
- */
- public function edit($id)
- {
- $row = $this->model->find($id);
- empty($row) && $this->error('数据不存在');
- if ($this->request->isAjax()) {
- $post = $this->request->post();
- $rule = [];
- $this->validate($post, $rule);
- try {
- $post['banner_desc'] = htmlspecialchars_decode($post['banner_desc']);
- // $post['img_pic'] = __HTTPSAVEIMGADMIN($post['img_pic']);
- $save = $row->save($post);
- } catch (\Exception $e) {
- $this->error('保存失败');
- }
- $save ? $this->success('保存成功') : $this->error('保存失败');
- }
- $row['img_pic'] = __HTTPGETIMGADMIN($row['img_pic']);
- $this->assign('row', $row);
- return $this->fetch();
- }
- /**
- * @NodeAnotation(title="添加")
- */
- public function add()
- {
- if ($this->request->isAjax()) {
- $row = request()->post();
- list($save, $msg) = SystemArticleLogic::add($row);
- $save ? $this->success($msg) : $this->error($msg);
- }
- return $this->fetch();
- }
- public function articleType()
- {
- $list = SystemArticle::getIdNameMapByStatus(1);
- $this->success('成功', $list);
- }
- }
|