rabin 4 years ago
commit
623cc1755b
7 changed files with 499 additions and 0 deletions
  1. 178 0
      database/data.php
  2. 147 0
      database/info.php
  3. 117 0
      database/page.php
  4. 8 0
      index.php
  5. 24 0
      lib/Data.php
  6. 10 0
      lib/Manage.php
  7. 15 0
      src/Api.php

+ 178 - 0
database/data.php

@@ -0,0 +1,178 @@
+<?php
+
+$info = function()
+{
+    $array = array();
+    $info = Dever::db('ad/info')->state();
+    if($info)
+    {
+        $array += $info;
+    }
+    return $array;
+};
+$info_id = Dever::input('search_option_info_id');
+$config = array();
+$pic = 'image';
+$video = 'upload';
+$code = 'textarea';
+if ($info_id) {
+    $config = Dever::load('ad/info-one', $info_id);
+    if ($config['type'] == 1) {
+        $video = 'hidden';
+        $code = 'hidden';
+    }
+    if ($config['type'] == 2) {
+        $pic = 'hidden';
+        $code = 'hidden';
+    }
+    if ($config['type'] == 3) {
+        $video = 'hidden';
+        $pic = 'hidden';
+    }
+}
+return array
+(
+    # 表名
+    'name' => 'data',
+    # 显示给用户看的名称
+    'lang' => '广告投放',
+    'order' => 200,
+    'menu' => false,
+    # 数据结构
+    'struct' => array
+    (
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '广告位ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            //'search'  => 'order',
+            'order'     => 'desc',
+            'list'        => true,
+        ),
+        
+        'name'      => array
+        (
+            'type'      => 'varchar-60',
+            'name'      => '标题',
+            'default'   => '',
+            'desc'      => '请输入标题',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'list'      => true,
+            'edit'      => true,
+        ),
+
+        'info_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '选择所属广告位',
+            'default'   => Dever::input('search_option_info_id', '1'),
+            'desc'      => '选择所属广告位',
+            'match'     => 'is_numeric',
+            'option'    => $info,
+            //'update'    => 'select',
+            'search'    => 'select',
+            'list'        => true,
+            'value'     => Dever::input('search_option_info_id', '1'),
+        ),
+
+        'pic'     => array
+        (
+            'type'      => 'varchar-150',
+            'name'      => '广告图',
+            'default'   => '',
+            'desc'      => '广告图',
+            'match'     => 'is_string',
+            'update'    => $pic,
+            'key'       => '1',
+            'place'     => '150',
+        ),
+
+        'video'     => array
+        (
+            'type'      => 'varchar-800',
+            'name'      => '广告视频-视频格式mp4,mov,上传大小不能超过4G',
+            'default'   => '',
+            'desc'      => '广告视频',
+            'match'     => 'is_string',
+            'update'    => $video,
+            'key'       => '3',
+            'place'     => '150',
+            'upload'    => 'qiniu',
+            'large'     => true,
+            //不覆盖原文件,生成新文件
+            'cover'     => 2,
+        ),
+
+        'code'      => array
+        (
+            'type'      => 'text-255',
+            'name'      => '广告代码',
+            'default'   => '',
+            'desc'      => '广告代码',
+            'match'     => 'option',
+            'update'    => $code,
+        ),
+        
+        'reorder'       => array
+        (
+            'type'      => 'int-11',
+            'name'      => '排序(数值越大越靠前)',
+            'default'   => '1',
+            'desc'      => '请输入排序',
+            'match'     => 'option',
+            'update'    => 'text',
+            'search'    => 'order',
+            'list_name' => '排序',
+            'list'      => true,
+            'order'     => 'desc',
+            //'edit'        => true,
+        ),
+
+        'state'     => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '状态',
+            'default'   => '1',
+            'desc'      => '请选择状态',
+            'match'     => 'is_numeric',
+        ),
+        
+        'cdate'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '录入时间',
+            'match'     => array('is_numeric', time()),
+            'desc'      => '',
+            # 只有insert时才生效
+            'insert'    => true,
+            'list'      => 'date("Y-m-d H:i:s", {cdate})',
+        ),
+    ),
+
+    'manage' => array
+    (
+
+    ),
+
+    # request 请求接口定义
+    'request' => array
+    (
+        'getAll' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'info_id' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('id' => 'desc'),
+            'col' => '*',
+        ),
+    ),
+);

+ 147 - 0
database/info.php

@@ -0,0 +1,147 @@
+<?php
+
+$page = function()
+{
+    $array = array();
+    $info = Dever::db('ad/page')->state();
+    if($info)
+    {
+        $array += $info;
+    }
+    return $array;
+};
+
+$type = array
+(
+    1 => '图片广告',
+    2 => '视频广告',
+    3 => '代码广告',
+);
+
+return array
+(
+    # 表名
+    'name' => 'info',
+    # 显示给用户看的名称
+    'lang' => '广告位管理',
+    'order' => 100,
+    # 数据结构
+    'struct' => array
+    (
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '广告位ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            //'search'  => 'order',
+            'order'     => 'desc',
+            'list'        => true,
+        ),
+
+        'page_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '所属页面',
+            'default'   => '1',
+            'desc'      => '选择所属页面',
+            'match'     => 'is_numeric',
+            'option'    => $page,
+            'update'    => 'select',
+            'search'    => 'select',
+            'list'        => true,
+        ),
+        
+        'name'      => array
+        (
+            'type'      => 'varchar-60',
+            'name'      => '广告位标题',
+            'default'   => '',
+            'desc'      => '请输入广告位标题',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'list'      => true,
+            'edit'      => true,
+        ),
+
+        'type'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '广告类型',
+            'default'   => '1',
+            'desc'      => '请选择广告类型',
+            'match'     => 'is_numeric',
+            'option'    => $type,
+            'update'    => 'radio',
+            'search'    => 'select',
+            'list'        => true,
+        ),
+        
+        'reorder'       => array
+        (
+            'type'      => 'int-11',
+            'name'      => '排序(数值越大越靠前)',
+            'default'   => '1',
+            'desc'      => '请输入排序',
+            'match'     => 'option',
+            'update'    => 'text',
+            'search'    => 'order',
+            'list_name' => '排序',
+            'list'      => true,
+            'order'     => 'desc',
+            //'edit'        => true,
+        ),
+
+        'state'     => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '状态',
+            'default'   => '1',
+            'desc'      => '请选择状态',
+            'match'     => 'is_numeric',
+        ),
+        
+        'cdate'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '录入时间',
+            'match'     => array('is_numeric', time()),
+            'desc'      => '',
+            # 只有insert时才生效
+            'insert'    => true,
+            'list'      => 'date("Y-m-d H:i:s", {cdate})',
+        ),
+    ),
+
+    'manage' => array
+    (
+        'delete' => false,
+        //'edit' => false,
+        //'insert' => $curPage ? true : false,
+        'list_button' => array
+        (
+            'add' => array('广告投放', '"data&search_option_info_id={id}&oper_parent=info"'),
+
+            'list' => array('投放列表', '"data&search_option_info_id={id}&oper_parent=info"'),
+        ),
+    ),
+
+    # request 请求接口定义
+    'request' => array
+    (
+        'getAll' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'page_id' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('id' => 'desc'),
+            'col' => '*',
+        ),
+    ),
+);

+ 117 - 0
database/page.php

@@ -0,0 +1,117 @@
+<?php
+
+$type = array
+(
+    1 => 'H5',
+    2 => '安卓APP',
+    3 => '苹果APP',
+    4 => '微信小程序',
+);
+return array
+(
+    # 表名
+    'name' => 'page',
+    # 显示给用户看的名称
+    'lang' => '页面管理',
+    'order' => 10,
+    # 数据结构
+    'struct' => array
+    (
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            //'search'  => 'order',
+            'order'     => 'desc',
+            //'list'        => true,
+        ),
+        
+        'name'      => array
+        (
+            'type'      => 'varchar-60',
+            'name'      => '页面标题',
+            'default'   => '',
+            'desc'      => '请输入页面标题',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'list'      => true,
+            'edit'      => true,
+        ),
+
+        'key'      => array
+        (
+            'type'      => 'varchar-800',
+            'name'      => '页面标识-可以根据路由获取页面里的广告信息,也可以约定一个标识值,直接通过获取广告的接口来获取信息',
+            'default'   => '',
+            'desc'      => '页面标识',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'list'      => true,
+            'edit'      => true,
+        ),
+
+        'type'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '页面类型',
+            'default'   => '1',
+            'desc'      => '请选择页面类型',
+            'match'     => 'is_numeric',
+            'option'    => $type,
+            'update'    => 'radio',
+            'search'    => 'select',
+            'list'        => true,
+        ),
+        
+        'reorder'       => array
+        (
+            'type'      => 'int-11',
+            'name'      => '排序(数值越大越靠前)',
+            'default'   => '1',
+            'desc'      => '请输入排序',
+            'match'     => 'option',
+            'update'    => 'text',
+            'search'    => 'order',
+            'list_name' => '排序',
+            'list'      => true,
+            'order'     => 'desc',
+            //'edit'        => true,
+        ),
+
+        'state'     => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '状态',
+            'default'   => '1',
+            'desc'      => '请选择状态',
+            'match'     => 'is_numeric',
+        ),
+        
+        'cdate'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '录入时间',
+            'match'     => array('is_numeric', time()),
+            'desc'      => '',
+            # 只有insert时才生效
+            'insert'    => true,
+            'list'      => 'date("Y-m-d H:i:s", {cdate})',
+        ),
+    ),
+
+    'manage' => array
+    (
+
+    ),
+
+    # request 请求接口定义
+    'request' => array
+    (
+        
+    ),
+);

+ 8 - 0
index.php

@@ -0,0 +1,8 @@
+<?php
+
+define('DEVER_APP_NAME', 'ad');
+define('DEVER_APP_LANG', '广告管理');
+define('DEVER_APP_PATH', dirname(__FILE__) . DIRECTORY_SEPARATOR);
+define('DEVER_MANAGE_ORDER', 200);
+define('DEVER_MANAGE_ICON', 'glyphicon glyphicon-tower layui-icon-read');
+include(DEVER_APP_PATH . '../boot.php');

+ 24 - 0
lib/Data.php

@@ -0,0 +1,24 @@
+<?php
+
+namespace Ad\Lib;
+
+use Dever;
+
+class Data
+{
+    public function get($key, $data = array())
+    {
+        $page = Dever::db('ad/page')->one(array('key' => $key));
+        if ($page) {
+            $info = Dever::db('ad/info')->getAll(array('page_id' => $page['id']));
+            if ($info) {
+                foreach ($info as $k => $v) {
+                    $info[$k]['data'] = Dever::db('ad/data')->getAll(array('info_id' => $v['id']));
+                }
+                return $info;
+            }
+        }
+
+        return false;
+    }
+}

+ 10 - 0
lib/Manage.php

@@ -0,0 +1,10 @@
+<?php
+
+namespace Ad\Lib;
+
+use Dever;
+
+class Manage
+{
+    
+}

+ 15 - 0
src/Api.php

@@ -0,0 +1,15 @@
+<?php
+
+namespace Ad\Src;
+
+use Dever;
+
+class Api
+{
+    public function get()
+    {
+        $key = Dever::input('key');
+
+        return Dever::load('ad/lib/data')->get($key);
+    }
+}