123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224 |
- <?php
- declare (strict_types = 1);
- namespace app\system\controller;
- use app\BaseController;
- use app\model\api\AdverPage;
- use app\model\api\Advert;
- use app\model\api\Upsource;
- use app\Request;
- use library\services\UtilService;
- use library\utils\Qiniu;
- // +----------------------------------------------------------------------
- // | [ WE CAN DO IT MORE SIMPLE ]
- // +----------------------------------------------------------------------
- // | Copyright (c) 2018-2020 rights reserved.
- // +----------------------------------------------------------------------
- // | [ 广告管理 ]
- // +----------------------------------------------------------------------
- // | Date: 2020-09-06 21:53
- // +----------------------------------------------------------------------
- class Adver extends BaseController{
- /**
- * 分类列表数据
- */
- public function page(Request $request){
- [$cate_name,$pid,$is_show] = UtilService::getMore([
- ['cate_name',''],
- ['pid','0'],
- ['is_show','0']
- ],$request,true);
- $menuMenu = new AdverPage();
- $menus = $menuMenu->getArMenu($cate_name,$pid,$is_show);
- return app('json')->success($menus);
- }
- /**
- * 获取树级分类
- */
- public function page_tree() {
- $menuAr = (new AdverPage())->order("sort","desc")->select()->toArray();
- $data = sort_list_tier($menuAr, '顶级', 'pid', 'id');
- return app('json')->success($data);
- }
- /**
- * 获取详情栏目数据
- */
- public function page_info(Request $request){
- [$id] = UtilService::getMore([
- ['id',0,'empty','参数错误']
- ],$request,true);
- $data = (new AdverPage())->find(compact('id'))->toArray();
- return app('json')->success($data);
- }
- /**
- * 保存数据
- */
- public function page_save(Request $request){
- $post = UtilService::getMore([
- ['cate_name','','empty','商品分类'],
- ['pid','0'],
- ['sort','0'],
- ['id','0'],
- ['type','1'],
- ['max_count',0],
- ['json','[]'],
- ['mono','']
- ],$request);
- (new AdverPage())->savePage($post);
- return app('json')->success("数据保存成功");
- }
- /**
- * 栏目删除
- * @param Request $request
- */
- public function page_del(Request $request) {
- [$id] = UtilService::getMore([
- ['id',0,'empty','参数错误']
- ],$request,true);
- $bool = (new AdverPage())->delAdver($id);
- return app('json')->success("栏目删除成功");
- }
- public function list(Request $request) {
- $pageSize = 50;
- [$page,$page_id,$title,$sassid] = UtilService::getMore(
- [
- ['page',1],
- ['page_id','0'],
- ['title',''],
- ['sassid','0']
- ],$request,true
- );
- $where = compact('page_id','title','sassid');
- list($pageCount,$data) = (new Advert)
- ->getList($page,$where,$pageSize,'id desc');
- return app('json')->success([
- 'list' => $data,
- 'pageCount' => $pageCount,
- 'pageSize' => $pageSize,
- 'page' => $page
- ]);
- }
- /**
- * 获取详情栏目数据
- */
- public function info(Request $request){
- [$id] = UtilService::getMore([
- ['id',0,'empty','参数错误']
- ],$request,true);
- $data = (new Advert())->find(compact('id'))->toArray();
- return app('json')->success($data);
- }
- /**
- * 保存数据
- */
- public function save(Request $request){
- $post = UtilService::getMore([
- ['title','','empty','广告'],
- ['page_id','0'],
- ['sort','0'],
- ['sex',0],
- ['id','0'],
- ['text',''],
- ['url',''],
- ['code',''],
- ['img',''],
- ['data',''],
- ['is_show','0']
- ],$request);
- (new Advert())->savePage($post);
- return app('json')->success("数据保存成功");
- }
- /**
- * 栏目删除
- * @param Request $request
- */
- public function del(Request $request) {
- [$id] = UtilService::getMore([
- ['id',0,'empty','参数错误']
- ],$request,true);
- $bool = (new Advert)->where("id",$id)->delete();
- return app('json')->success("栏目删除成功");
- }
-
-
-
-
-
- public function upsourceList(Request $request) {
- $post = UtilService::getMore([
- ['page',1],
- ['pageSize', 50],
- ['title',''],
- ['type',''],
- ['status',''],
- ],$request);
- $data = (new Upsource)->getListData($post);
- return app('json')->success([
- 'list' => $data["list"],
- 'pageCount' => $data["totalCount"],
- 'pageSize' => $data["pageSize"],
- 'page' => $data["page"],
- ]);
- }
-
-
- public function upsourceSave(Request $request){
- $post = UtilService::getMore([
- ['id',''],
- ['url',''],
- ['title',''],
- ['type','img'],
- ],$request);
- $id = $post["id"];
- unset($post["id"]);
- $r=0;
- if(empty($id) || $id=="0"){
- $post["time"] = time();
- $post["status"] = 1;
- $r = (new Upsource)->insert($post);
- }else{
- $r = (new Upsource)->where("id",$id)->update($post);
- }
- if($r){
- return app('json')->success("数据保存成功");
- }else{
- return app('json')->fail("数据保存失败");
- }
- }
- /**
- * 删除资源图片
- * @param Request $request
- */
- public function upsourceDel(Request $request){
- $post = UtilService::getMore([
- ['id','',"empty","参数错误"],
- ],$request);
- $data = (new Upsource)->where("id",$post["id"])->find();
- if(empty($data)){
- return app('json')->fail("数据错误");
- }
- // $qiniu = new Qiniu;
- // $qiniu->
- (new Upsource)->where("id",$post["id"])->update(["is_del"=>1]);
- return app('json')->success("删除成功");
- }
-
-
- }
|