作者 郭盛
1 个管道 的构建 通过 耗费 3 秒

首页轮播图接口以及咨询分类接口

正在显示 43 个修改的文件 包含 2980 行增加122 行删除
  1 +<?php
  2 +
  3 +namespace addons\command;
  4 +
  5 +use app\common\library\Menu;
  6 +use think\Addons;
  7 +
  8 +/**
  9 + * 在线命令插件
  10 + */
  11 +class Command extends Addons
  12 +{
  13 +
  14 + /**
  15 + * 插件安装方法
  16 + * @return bool
  17 + */
  18 + public function install()
  19 + {
  20 + $menu = [
  21 + [
  22 + 'name' => 'command',
  23 + 'title' => '在线命令管理',
  24 + 'icon' => 'fa fa-terminal',
  25 + 'sublist' => [
  26 + ['name' => 'command/index', 'title' => '查看'],
  27 + ['name' => 'command/add', 'title' => '添加'],
  28 + ['name' => 'command/detail', 'title' => '详情'],
  29 + ['name' => 'command/execute', 'title' => '运行'],
  30 + ['name' => 'command/del', 'title' => '删除'],
  31 + ['name' => 'command/multi', 'title' => '批量更新'],
  32 + ]
  33 + ]
  34 + ];
  35 + Menu::create($menu);
  36 + return true;
  37 + }
  38 +
  39 + /**
  40 + * 插件卸载方法
  41 + * @return bool
  42 + */
  43 + public function uninstall()
  44 + {
  45 + Menu::delete('command');
  46 + return true;
  47 + }
  48 +
  49 + /**
  50 + * 插件启用方法
  51 + * @return bool
  52 + */
  53 + public function enable()
  54 + {
  55 + Menu::enable('command');
  56 + return true;
  57 + }
  58 +
  59 + /**
  60 + * 插件禁用方法
  61 + * @return bool
  62 + */
  63 + public function disable()
  64 + {
  65 + Menu::disable('command');
  66 + return true;
  67 + }
  68 +
  69 +}
  1 +<?php
  2 +
  3 +namespace app\admin\controller;
  4 +
  5 +use app\common\controller\Backend;
  6 +use think\Config;
  7 +use think\console\Input;
  8 +use think\Db;
  9 +use think\Exception;
  10 +
  11 +/**
  12 + * 在线命令管理
  13 + *
  14 + * @icon fa fa-circle-o
  15 + */
  16 +class Command extends Backend
  17 +{
  18 +
  19 + /**
  20 + * Command模型对象
  21 + */
  22 + protected $model = null;
  23 + protected $noNeedRight = ['get_controller_list', 'get_field_list'];
  24 +
  25 + public function _initialize()
  26 + {
  27 + parent::_initialize();
  28 + $this->model = model('Command');
  29 + $this->view->assign("statusList", $this->model->getStatusList());
  30 + }
  31 +
  32 + /**
  33 + * 添加
  34 + */
  35 + public function add()
  36 + {
  37 +
  38 + $tableList = [];
  39 + $list = \think\Db::query("SHOW TABLES");
  40 + foreach ($list as $key => $row) {
  41 + $tableList[reset($row)] = reset($row);
  42 + }
  43 +
  44 + $this->view->assign("tableList", $tableList);
  45 + return $this->view->fetch();
  46 + }
  47 +
  48 + /**
  49 + * 获取字段列表
  50 + * @internal
  51 + */
  52 + public function get_field_list()
  53 + {
  54 + $dbname = Config::get('database.database');
  55 + $prefix = Config::get('database.prefix');
  56 + $table = $this->request->request('table');
  57 + //从数据库中获取表字段信息
  58 + $sql = "SELECT * FROM `information_schema`.`columns` "
  59 + . "WHERE TABLE_SCHEMA = ? AND table_name = ? "
  60 + . "ORDER BY ORDINAL_POSITION";
  61 + //加载主表的列
  62 + $columnList = Db::query($sql, [$dbname, $table]);
  63 + $fieldlist = [];
  64 + foreach ($columnList as $index => $item) {
  65 + $fieldlist[] = $item['COLUMN_NAME'];
  66 + }
  67 + $this->success("", null, ['fieldlist' => $fieldlist]);
  68 + }
  69 +
  70 + /**
  71 + * 获取控制器列表
  72 + * @internal
  73 + */
  74 + public function get_controller_list()
  75 + {
  76 + $adminPath = dirname(__DIR__) . DS;
  77 + $controllerDir = $adminPath . 'controller' . DS;
  78 + $files = new \RecursiveIteratorIterator(
  79 + new \RecursiveDirectoryIterator($controllerDir), \RecursiveIteratorIterator::LEAVES_ONLY
  80 + );
  81 + $list = [];
  82 + foreach ($files as $name => $file) {
  83 + if (!$file->isDir()) {
  84 + $filePath = $file->getRealPath();
  85 + $name = str_replace($controllerDir, '', $filePath);
  86 + $name = str_replace(DS, "/", $name);
  87 + $list[] = ['id' => $name, 'name' => $name];
  88 + }
  89 + }
  90 + $pageNumber = $this->request->request("pageNumber");
  91 + $pageSize = $this->request->request("pageSize");
  92 + return json(['list' => array_slice($list, ($pageNumber - 1) * $pageSize, $pageSize), 'total' => count($list)]);
  93 + }
  94 +
  95 + /**
  96 + * 详情
  97 + */
  98 + public function detail($ids)
  99 + {
  100 + $row = $this->model->get($ids);
  101 + if (!$row)
  102 + $this->error(__('No Results were found'));
  103 + $this->view->assign("row", $row);
  104 + return $this->view->fetch();
  105 + }
  106 +
  107 + /**
  108 + * 执行
  109 + */
  110 + public function execute($ids)
  111 + {
  112 + $row = $this->model->get($ids);
  113 + if (!$row)
  114 + $this->error(__('No Results were found'));
  115 + $result = $this->doexecute($row['type'], json_decode($row['params'], true));
  116 + $this->success("", null, ['result' => $result]);
  117 + }
  118 +
  119 + /**
  120 + * 执行命令
  121 + */
  122 + public function command($action = '')
  123 + {
  124 + $commandtype = $this->request->request("commandtype");
  125 + $params = $this->request->request();
  126 + $allowfields = [
  127 + 'crud' => 'table,controller,model,fields,force,local,delete,menu',
  128 + 'menu' => 'controller,delete',
  129 + 'min' => 'module,resource,optimize',
  130 + 'api' => 'url,module,output,template,force,title,author,class,language',
  131 + ];
  132 + $argv = [];
  133 + $allowfields = isset($allowfields[$commandtype]) ? explode(',', $allowfields[$commandtype]) : [];
  134 + $allowfields = array_filter(array_intersect_key($params, array_flip($allowfields)));
  135 + if (isset($params['local']) && !$params['local']) {
  136 + $allowfields['local'] = $params['local'];
  137 + } else {
  138 + unset($allowfields['local']);
  139 + }
  140 + foreach ($allowfields as $key => $param) {
  141 + $argv[] = "--{$key}=" . (is_array($param) ? implode(',', $param) : $param);
  142 + }
  143 + if ($commandtype == 'crud') {
  144 + $extend = 'setcheckboxsuffix,enumradiosuffix,imagefield,filefield,intdatesuffix,switchsuffix,citysuffix,selectpagesuffix,selectpagessuffix,ignorefields,sortfield,editorsuffix,headingfilterfield';
  145 + $extendArr = explode(',', $extend);
  146 + foreach ($params as $index => $item) {
  147 + if (in_array($index, $extendArr)) {
  148 + foreach (explode(',', $item) as $key => $value) {
  149 + if ($value) {
  150 + $argv[] = "--{$index}={$value}";
  151 + }
  152 + }
  153 + }
  154 + }
  155 + $isrelation = (int)$this->request->request('isrelation');
  156 + if ($isrelation && isset($params['relation'])) {
  157 + foreach ($params['relation'] as $index => $relation) {
  158 + foreach ($relation as $key => $value) {
  159 + $argv[] = "--{$key}=" . (is_array($value) ? implode(',', $value) : $value);
  160 + }
  161 + }
  162 + }
  163 + } else if ($commandtype == 'menu') {
  164 + if (isset($params['allcontroller']) && $params['allcontroller']) {
  165 + $argv[] = "--controller=all-controller";
  166 + } else {
  167 + foreach (explode(',', $params['controllerfile']) as $index => $param) {
  168 + if ($param) {
  169 + $argv[] = "--controller=" . substr($param, 0, -4);
  170 + }
  171 + }
  172 + }
  173 + } else if ($commandtype == 'min') {
  174 +
  175 + } else if ($commandtype == 'api') {
  176 +
  177 + } else {
  178 +
  179 + }
  180 + if ($action == 'execute') {
  181 + $result = $this->doexecute($commandtype, $argv);
  182 + $this->success("", null, ['result' => $result]);
  183 + } else {
  184 + $this->success("", null, ['command' => "php think {$commandtype} " . implode(' ', $argv)]);
  185 + }
  186 +
  187 + return;
  188 + }
  189 +
  190 + protected function doexecute($commandtype, $argv)
  191 + {
  192 + $commandName = "\\app\\admin\\command\\" . ucfirst($commandtype);
  193 + $input = new Input($argv);
  194 + $output = new \addons\command\library\Output();
  195 + $command = new $commandName($commandtype);
  196 + $data = [
  197 + 'type' => $commandtype,
  198 + 'params' => json_encode($argv),
  199 + 'command' => "php think {$commandtype} " . implode(' ', $argv),
  200 + 'executetime' => time(),
  201 + ];
  202 + $this->model->save($data);
  203 + try {
  204 + $command->run($input, $output);
  205 + $result = implode("\n", $output->getMessage());
  206 + $this->model->status = 'successed';
  207 + } catch (Exception $e) {
  208 + $result = implode("\n", $output->getMessage()) . "\n";
  209 + $result .= $e->getMessage();
  210 + $this->model->status = 'failured';
  211 + }
  212 + $result = trim($result);
  213 + $this->model->content = $result;
  214 + $this->model->save();
  215 + return $result;
  216 + }
  217 +
  218 +
  219 +}
  1 +<?php
  2 +
  3 +return [
  4 + 'Id' => 'ID',
  5 + 'Type' => '类型',
  6 + 'Params' => '参数',
  7 + 'Command' => '命令',
  8 + 'Content' => '返回结果',
  9 + 'Executetime' => '执行时间',
  10 + 'Createtime' => '创建时间',
  11 + 'Updatetime' => '更新时间',
  12 + 'Execute again' => '再次执行',
  13 + 'Successed' => '成功',
  14 + 'Failured' => '失败',
  15 + 'Status' => '状态'
  16 +];
  1 +<?php
  2 +
  3 +namespace app\admin\model;
  4 +
  5 +use think\Model;
  6 +
  7 +class Command extends Model
  8 +{
  9 + // 表名
  10 + protected $name = 'command';
  11 +
  12 + // 自动写入时间戳字段
  13 + protected $autoWriteTimestamp = 'int';
  14 +
  15 + // 定义时间戳字段名
  16 + protected $createTime = 'createtime';
  17 + protected $updateTime = 'updatetime';
  18 +
  19 + // 追加属性
  20 + protected $append = [
  21 + 'executetime_text',
  22 + 'type_text',
  23 + 'status_text'
  24 + ];
  25 +
  26 +
  27 + public function getStatusList()
  28 + {
  29 + return ['successed' => __('Successed'), 'failured' => __('Failured')];
  30 + }
  31 +
  32 +
  33 + public function getExecutetimeTextAttr($value, $data)
  34 + {
  35 + $value = $value ? $value : $data['executetime'];
  36 + return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
  37 + }
  38 +
  39 + public function getTypeTextAttr($value, $data)
  40 + {
  41 + $value = $value ? $value : $data['type'];
  42 + $list = ['crud' => '一键生成CRUD', 'menu' => '一键生成菜单', 'min' => '一键压缩打包', 'api' => '一键生成文档'];
  43 + return isset($list[$value]) ? $list[$value] : '';
  44 + }
  45 +
  46 + public function getStatusTextAttr($value, $data)
  47 + {
  48 + $value = $value ? $value : $data['status'];
  49 + $list = $this->getStatusList();
  50 + return isset($list[$value]) ? $list[$value] : '';
  51 + }
  52 +
  53 + protected function setExecutetimeAttr($value)
  54 + {
  55 + return $value && !is_numeric($value) ? strtotime($value) : $value;
  56 + }
  57 +
  58 +
  59 +}
  1 +<?php
  2 +
  3 +namespace app\admin\validate;
  4 +
  5 +use think\Validate;
  6 +
  7 +class Command extends Validate
  8 +{
  9 + /**
  10 + * 验证规则
  11 + */
  12 + protected $rule = [
  13 + ];
  14 + /**
  15 + * 提示消息
  16 + */
  17 + protected $message = [
  18 + ];
  19 + /**
  20 + * 验证场景
  21 + */
  22 + protected $scene = [
  23 + 'add' => [],
  24 + 'edit' => [],
  25 + ];
  26 +
  27 +}
  1 +<style>
  2 + .relation-item {margin-top:10px;}
  3 + legend {padding-bottom:5px;font-size:14px;font-weight:600;}
  4 + label {font-weight:normal;}
  5 + .form-control{padding:6px 8px;}
  6 + #extend-zone .col-xs-2 {margin-top:10px;padding-right:0;}
  7 + #extend-zone .col-xs-2:nth-child(6n+0) {padding-right:15px;}
  8 +</style>
  9 +<div class="panel panel-default panel-intro">
  10 + <div class="panel-heading">
  11 + <ul class="nav nav-tabs">
  12 + <li class="active"><a href="#crud" data-toggle="tab">{:__('一键生成CRUD')}</a></li>
  13 + <li><a href="#menu" data-toggle="tab">{:__('一键生成菜单')}</a></li>
  14 + <li><a href="#min" data-toggle="tab">{:__('一键压缩打包')}</a></li>
  15 + <li><a href="#api" data-toggle="tab">{:__('一键生成API文档')}</a></li>
  16 + </ul>
  17 + </div>
  18 + <div class="panel-body">
  19 + <div id="myTabContent" class="tab-content">
  20 + <div class="tab-pane fade active in" id="crud">
  21 + <div class="row">
  22 + <div class="col-xs-12">
  23 + <form role="form">
  24 + <input type="hidden" name="commandtype" value="crud" />
  25 + <div class="form-group">
  26 + <div class="row">
  27 + <div class="col-xs-3">
  28 + <input checked="" name="isrelation" type="hidden" value="0">
  29 + <label class="control-label" data-toggle="tooltip" title="当前只支持生成1对1关联模型,选中后请配置关联表和字段">
  30 + <input name="isrelation" type="checkbox" value="1">
  31 + 关联模型
  32 + </label>
  33 + </div>
  34 + <div class="col-xs-3">
  35 + <input checked="" name="local" type="hidden" value="1">
  36 + <label class="control-label" data-toggle="tooltip" title="默认模型生成在application/admin/model目录下,选中后将生成在application/common/model目录下">
  37 + <input name="local" type="checkbox" value="0"> 全局模型类
  38 + </label>
  39 + </div>
  40 + <div class="col-xs-3">
  41 + <input checked="" name="delete" type="hidden" value="0">
  42 + <label class="control-label" data-toggle="tooltip" title="删除CRUD生成的相关文件">
  43 + <input name="delete" type="checkbox" value="1"> 删除模式
  44 + </label>
  45 + </div>
  46 + <div class="col-xs-3">
  47 + <input checked="" name="force" type="hidden" value="0">
  48 + <label class="control-label" data-toggle="tooltip" title="选中后,如果已经存在同名文件将被覆盖。如果是删除将不再提醒">
  49 + <input name="force" type="checkbox" value="1">
  50 + 强制覆盖模式
  51 + </label>
  52 + </div>
  53 + <!--
  54 + <div class="col-xs-3">
  55 + <input checked="" name="menu" type="hidden" value="0">
  56 + <label class="control-label" data-toggle="tooltip" title="选中后,将同时生成后台菜单规则">
  57 + <input name="menu" type="checkbox" value="1">
  58 + 生成菜单
  59 + </label>
  60 + </div>
  61 + -->
  62 + </div>
  63 + </div>
  64 + <div class="form-group">
  65 + <legend>主表设置</legend>
  66 + <div class="row">
  67 + <div class="col-xs-3">
  68 + <label>请选择主表</label>
  69 + {:build_select('table',$tableList,null,['class'=>'form-control selectpicker']);}
  70 + </div>
  71 + <div class="col-xs-3">
  72 + <label>自定义控制器名</label>
  73 + <input type="text" class="form-control" name="controller" data-toggle="tooltip" title="默认根据表名自动生成,如果需要放在二级目录请手动填写" placeholder="支持目录层级,以/分隔">
  74 + </div>
  75 + <div class="col-xs-3">
  76 + <label>自定义模型名</label>
  77 + <input type="text" class="form-control" name="model" data-toggle="tooltip" title="默认根据表名自动生成" placeholder="不支持目录层级">
  78 + </div>
  79 + <div class="col-xs-3">
  80 + <label>请选择显示字段(默认全部)</label>
  81 + <select name="fields[]" id="fields" multiple style="height:30px;" class="form-control selectpicker"></select>
  82 + </div>
  83 +
  84 + </div>
  85 +
  86 + </div>
  87 +
  88 + <div class="form-group hide" id="relation-zone">
  89 + <legend>关联表设置</legend>
  90 +
  91 + <div class="row" style="margin-top:15px;">
  92 + <div class="col-xs-12">
  93 + <a href="javascript:;" class="btn btn-primary btn-sm btn-newrelation" data-index="1">追加关联模型</a>
  94 + </div>
  95 + </div>
  96 + </div>
  97 +
  98 + <hr>
  99 + <div class="form-group" id="extend-zone">
  100 + <legend>字段识别设置 <span style="font-size:12px;font-weight: normal;">(与之匹配的字段都将生成相应组件)</span></legend>
  101 + <div class="row">
  102 + <div class="col-xs-2">
  103 + <label>复选框后缀</label>
  104 + <input type="text" class="form-control" name="setcheckboxsuffix" placeholder="默认为set类型" />
  105 + </div>
  106 + <div class="col-xs-2">
  107 + <label>单选框后缀</label>
  108 + <input type="text" class="form-control" name="enumradiosuffix" placeholder="默认为enum类型" />
  109 + </div>
  110 + <div class="col-xs-2">
  111 + <label>图片类型后缀</label>
  112 + <input type="text" class="form-control" name="imagefield" placeholder="默认为image,images,avatar,avatars" />
  113 + </div>
  114 + <div class="col-xs-2">
  115 + <label>文件类型后缀</label>
  116 + <input type="text" class="form-control" name="filefield" placeholder="默认为file,files" />
  117 + </div>
  118 + <div class="col-xs-2">
  119 + <label>日期时间后缀</label>
  120 + <input type="text" class="form-control" name="intdatesuffix" placeholder="默认为time" />
  121 + </div>
  122 + <div class="col-xs-2">
  123 + <label>开关后缀</label>
  124 + <input type="text" class="form-control" name="switchsuffix" placeholder="默认为switch" />
  125 + </div>
  126 + <div class="col-xs-2">
  127 + <label>城市选择后缀</label>
  128 + <input type="text" class="form-control" name="citysuffix" placeholder="默认为city" />
  129 + </div>
  130 + <div class="col-xs-2">
  131 + <label>动态下拉后缀(单)</label>
  132 + <input type="text" class="form-control" name="selectpagesuffix" placeholder="默认为_id" />
  133 + </div>
  134 + <div class="col-xs-2">
  135 + <label>动态下拉后缀(多)</label>
  136 + <input type="text" class="form-control" name="selectpagessuffix" placeholder="默认为_ids" />
  137 + </div>
  138 + <div class="col-xs-2">
  139 + <label>忽略的字段</label>
  140 + <input type="text" class="form-control" name="ignorefields" placeholder="默认无" />
  141 + </div>
  142 + <div class="col-xs-2">
  143 + <label>排序字段</label>
  144 + <input type="text" class="form-control" name="sortfield" placeholder="默认为weigh" />
  145 + </div>
  146 + <div class="col-xs-2">
  147 + <label>富文本编辑器</label>
  148 + <input type="text" class="form-control" name="editorsuffix" placeholder="默认为content" />
  149 + </div>
  150 + <div class="col-xs-2">
  151 + <label>选项卡过滤字段</label>
  152 + <input type="text" class="form-control" name="headingfilterfield" placeholder="默认为status" />
  153 + </div>
  154 +
  155 + </div>
  156 +
  157 + </div>
  158 +
  159 + <div class="form-group">
  160 + <legend>生成命令行</legend>
  161 + <textarea class="form-control" data-toggle="tooltip" title="如果在线执行命令失败,可以将命令复制到命令行进行执行" rel="command" rows="1" placeholder="请点击生成命令行"></textarea>
  162 + </div>
  163 +
  164 + <div class="form-group">
  165 + <legend>返回结果</legend>
  166 + <textarea class="form-control" rel="result" rows="5" placeholder="请点击立即执行"></textarea>
  167 + </div>
  168 +
  169 + <div class="form-group">
  170 + <button type="button" class="btn btn-info btn-embossed btn-command">{:__('生成命令行')}</button>
  171 + <button type="button" class="btn btn-success btn-embossed btn-execute">{:__('立即执行')}</button>
  172 + </div>
  173 +
  174 + </form>
  175 + </div>
  176 + </div>
  177 + </div>
  178 + <div class="tab-pane fade" id="menu">
  179 + <div class="row">
  180 + <div class="col-xs-12">
  181 + <form role="form">
  182 + <input type="hidden" name="commandtype" value="menu" />
  183 + <div class="form-group">
  184 + <div class="row">
  185 + <div class="col-xs-3">
  186 + <input checked="" name="allcontroller" type="hidden" value="0">
  187 + <label class="control-label">
  188 + <input name="allcontroller" data-toggle="collapse" data-target="#controller" type="checkbox" value="1"> 一键生成全部控制器
  189 + </label>
  190 + </div>
  191 + <div class="col-xs-3">
  192 + <input checked="" name="delete" type="hidden" value="0">
  193 + <label class="control-label">
  194 + <input name="delete" type="checkbox" value="1"> 删除模式
  195 + </label>
  196 + </div>
  197 + <div class="col-xs-3">
  198 + <input checked="" name="force" type="hidden" value="0">
  199 + <label class="control-label">
  200 + <input name="force" type="checkbox" value="1"> 强制覆盖模式
  201 + </label>
  202 + </div>
  203 + </div>
  204 + </div>
  205 +
  206 + <div class="form-group in" id="controller">
  207 + <legend>控制器设置</legend>
  208 +
  209 + <div class="row" style="margin-top:15px;">
  210 + <div class="col-xs-12">
  211 + <input type="text" name="controllerfile" class="form-control selectpage" style="width:720px;" data-source="command/get_controller_list" data-multiple="true" name="controller" placeholder="请选择控制器" />
  212 + </div>
  213 + </div>
  214 + </div>
  215 +
  216 + <div class="form-group">
  217 + <legend>生成命令行</legend>
  218 + <textarea class="form-control" rel="command" rows="1" placeholder="请点击生成命令行"></textarea>
  219 + </div>
  220 +
  221 + <div class="form-group">
  222 + <legend>返回结果</legend>
  223 + <textarea class="form-control" rel="result" rows="5" placeholder="请点击立即执行"></textarea>
  224 + </div>
  225 +
  226 + <div class="form-group">
  227 + <button type="button" class="btn btn-info btn-embossed btn-command">{:__('生成命令行')}</button>
  228 + <button type="button" class="btn btn-success btn-embossed btn-execute">{:__('立即执行')}</button>
  229 + </div>
  230 +
  231 + </form>
  232 + </div>
  233 + </div>
  234 + </div>
  235 + <div class="tab-pane fade" id="min">
  236 + <div class="row">
  237 + <div class="col-xs-12">
  238 + <form role="form">
  239 + <input type="hidden" name="commandtype" value="min" />
  240 + <div class="form-group">
  241 + <legend>基础设置</legend>
  242 + <div class="row">
  243 + <div class="col-xs-3">
  244 + <label>请选择压缩模块</label>
  245 + <select name="module" class="form-control selectpicker">
  246 + <option value="all" selected>全部</option>
  247 + <option value="backend">后台Backend</option>
  248 + <option value="frontend">前台Frontend</option>
  249 + </select>
  250 + </div>
  251 + <div class="col-xs-3">
  252 + <label>请选择压缩资源</label>
  253 + <select name="resource" class="form-control selectpicker">
  254 + <option value="all" selected>全部</option>
  255 + <option value="js">JS</option>
  256 + <option value="css">CSS</option>
  257 + </select>
  258 + </div>
  259 + <div class="col-xs-3">
  260 + <label>请选择压缩模式</label>
  261 + <select name="optimize" class="form-control selectpicker">
  262 + <option value=""></option>
  263 + <option value="uglify">uglify</option>
  264 + <option value="closure">closure</option>
  265 + </select>
  266 + </div>
  267 + </div>
  268 + </div>
  269 +
  270 + <div class="form-group in">
  271 + <legend>控制器设置</legend>
  272 +
  273 + <div class="row" style="margin-top:15px;">
  274 + <div class="col-xs-12">
  275 +
  276 + </div>
  277 + </div>
  278 + </div>
  279 +
  280 + <div class="form-group">
  281 + <legend>生成命令行</legend>
  282 + <textarea class="form-control" rel="command" rows="1" placeholder="请点击生成命令行"></textarea>
  283 + </div>
  284 +
  285 + <div class="form-group">
  286 + <legend>返回结果</legend>
  287 + <textarea class="form-control" rel="result" rows="5" placeholder="请点击立即执行"></textarea>
  288 + </div>
  289 +
  290 + <div class="form-group">
  291 + <button type="button" class="btn btn-info btn-embossed btn-command">{:__('生成命令行')}</button>
  292 + <button type="button" class="btn btn-success btn-embossed btn-execute">{:__('立即执行')}</button>
  293 + </div>
  294 +
  295 + </form>
  296 + </div>
  297 + </div>
  298 + </div>
  299 + <div class="tab-pane fade" id="api">
  300 + <div class="row">
  301 + <div class="col-xs-12">
  302 + <form role="form">
  303 + <input type="hidden" name="commandtype" value="api" />
  304 + <div class="form-group">
  305 + <div class="row">
  306 + <div class="col-xs-3">
  307 + <input checked="" name="force" type="hidden" value="0">
  308 + <label class="control-label">
  309 + <input name="force" type="checkbox" value="1">
  310 + 覆盖模式
  311 + </label>
  312 + </div>
  313 + </div>
  314 + </div>
  315 + <div class="form-group">
  316 + <legend>文档设置</legend>
  317 + <div class="row">
  318 + <div class="col-xs-3">
  319 + <label>请输入接口URL</label>
  320 + <input type="text" name="url" class="form-control" placeholder="API URL,可留空" />
  321 + </div>
  322 + <div class="col-xs-3">
  323 + <label>接口生成文件</label>
  324 + <input type="text" name="output" class="form-control" placeholder="留空则使用api.html" />
  325 + </div>
  326 + <div class="col-xs-3">
  327 + <label>模板文件</label>
  328 + <input type="text" name="template" class="form-control" placeholder="如果不清楚请留空" />
  329 + </div>
  330 + </div>
  331 + <div class="row" style="margin-top:10px;">
  332 + <div class="col-xs-3">
  333 + <label>文档标题</label>
  334 + <input type="text" name="title" class="form-control" placeholder="默认为FastAdmin" />
  335 + </div>
  336 + <div class="col-xs-3">
  337 + <label>文档作者</label>
  338 + <input type="text" name="author" class="form-control" placeholder="默认为FastAdmin" />
  339 + </div>
  340 + <div class="col-xs-3">
  341 + <label>文档语言</label>
  342 + <select name="language" class="form-control">
  343 + <option value="" selected>请选择语言</option>
  344 + <option value="zh-cn">中文</option>
  345 + <option value="en">英文</option>
  346 + </select>
  347 + </div>
  348 + </div>
  349 + </div>
  350 +
  351 + <div class="form-group">
  352 + <legend>生成命令行</legend>
  353 + <textarea class="form-control" rel="command" rows="1" placeholder="请点击生成命令行"></textarea>
  354 + </div>
  355 +
  356 + <div class="form-group">
  357 + <legend>返回结果</legend>
  358 + <textarea class="form-control" rel="result" rows="5" placeholder="请点击立即执行"></textarea>
  359 + </div>
  360 +
  361 + <div class="form-group">
  362 + <button type="button" class="btn btn-info btn-embossed btn-command">{:__('生成命令行')}</button>
  363 + <button type="button" class="btn btn-success btn-embossed btn-execute">{:__('立即执行')}</button>
  364 + </div>
  365 +
  366 + </form>
  367 + </div>
  368 + </div>
  369 + </div>
  370 + </div>
  371 + </div>
  372 +</div>
  373 +<script id="relationtpl" type="text/html">
  374 + <div class="row relation-item">
  375 + <div class="col-xs-2">
  376 + <label>请选择关联表</label>
  377 + <select name="relation[<%=index%>][relation]" class="form-control relationtable"></select>
  378 + </div>
  379 + <div class="col-xs-2">
  380 + <label>请选择关联类型</label>
  381 + <select name="relation[<%=index%>][relationmode]" class="form-control relationmode"></select>
  382 + </div>
  383 + <div class="col-xs-2">
  384 + <label>关联外键</label>
  385 + <select name="relation[<%=index%>][relationforeignkey]" class="form-control relationforeignkey"></select>
  386 + </div>
  387 + <div class="col-xs-2">
  388 + <label>关联主键</label>
  389 + <select name="relation[<%=index%>][relationprimarykey]" class="form-control relationprimarykey"></select>
  390 + </div>
  391 + <div class="col-xs-2">
  392 + <label>请选择显示字段</label>
  393 + <select name="relation[<%=index%>][relationfields][]" multiple class="form-control relationfields"></select>
  394 + </div>
  395 + <div class="col-xs-2">
  396 + <label>&nbsp;</label>
  397 + <a href="javascript:;" class="btn btn-danger btn-block btn-removerelation">移除</a>
  398 + </div>
  399 + </div>
  400 +</script>
  1 +<table class="table table-striped">
  2 + <thead>
  3 + <tr>
  4 + <th>{:__('Title')}</th>
  5 + <th>{:__('Content')}</th>
  6 + </tr>
  7 + </thead>
  8 + <tbody>
  9 + <tr>
  10 + <td>{:__('Type')}</td>
  11 + <td>{$row.type}({$row.type_text})</td>
  12 + </tr>
  13 + <tr>
  14 + <td>{:__('Params')}</td>
  15 + <td>{$row.params}</td>
  16 + </tr>
  17 + <tr>
  18 + <td>{:__('Command')}</td>
  19 + <td>{$row.command}</td>
  20 + </tr>
  21 + <tr>
  22 + <td>{:__('Content')}</td>
  23 + <td>
  24 + <textarea class="form-control" name="" id="" cols="60" rows="10">{$row.content}</textarea>
  25 + </td>
  26 + </tr>
  27 + <tr>
  28 + <td>{:__('Executetime')}</td>
  29 + <td>{$row.executetime|datetime}</td>
  30 + </tr>
  31 + <tr>
  32 + <td>{:__('Status')}</td>
  33 + <td>{$row.status_text}</td>
  34 + </tr>
  35 + </tbody>
  36 +</table>
  37 +<div class="hide layer-footer">
  38 + <label class="control-label col-xs-12 col-sm-2"></label>
  39 + <div class="col-xs-12 col-sm-8">
  40 + <button type="reset" class="btn btn-primary btn-embossed btn-close" onclick="Layer.closeAll();">{:__('Close')}</button>
  41 + </div>
  42 +</div>
  1 +<div class="panel panel-default panel-intro">
  2 + {:build_heading()}
  3 +
  4 + <div class="panel-body">
  5 + <div id="myTabContent" class="tab-content">
  6 + <div class="tab-pane fade active in" id="one">
  7 + <div class="widget-body no-padding">
  8 + <div id="toolbar" class="toolbar">
  9 + <a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
  10 + <a href="javascript:;" class="btn btn-success btn-add {:$auth->check('command/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>
  11 + <a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('command/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
  12 +
  13 + </div>
  14 + <table id="table" class="table table-striped table-bordered table-hover"
  15 + data-operate-detail="{:$auth->check('command/detail')}"
  16 + data-operate-execute="{:$auth->check('command/execute')}"
  17 + data-operate-del="{:$auth->check('command/del')}"
  18 + width="100%">
  19 + </table>
  20 + </div>
  21 + </div>
  22 +
  23 + </div>
  24 + </div>
  25 +</div>
  1 +<?php
  2 +
  3 +return [
  4 +];
  1 +<?php
  2 +
  3 +namespace addons\command\controller;
  4 +
  5 +use think\addons\Controller;
  6 +
  7 +class Index extends Controller
  8 +{
  9 +
  10 + public function index()
  11 + {
  12 + $this->error("当前插件暂无前台页面");
  13 + }
  14 +
  15 +}
  1 +name = command
  2 +title = 在线命令
  3 +intro = 可在线执行FastAdmin的命令行相关命令
  4 +author = Karson
  5 +website = http://www.fastadmin.net
  6 +version = 1.0.5
  7 +state = 1
  8 +url = /addons/command.html
  1 +CREATE TABLE IF NOT EXISTS `__PREFIX__command` (
  2 + `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'ID',
  3 + `type` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '类型',
  4 + `params` varchar(1500) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '参数',
  5 + `command` varchar(1500) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '命令',
  6 + `content` text COMMENT '返回结果',
  7 + `executetime` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '执行时间',
  8 + `createtime` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '创建时间',
  9 + `updatetime` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '更新时间',
  10 + `status` enum('successed','failured') CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'failured' COMMENT '状态',
  11 + PRIMARY KEY (`id`) USING BTREE
  12 +) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '在线命令表' ROW_FORMAT = Compact;
  1 +<?php
  2 +
  3 +namespace addons\command\library;
  4 +
  5 +/**
  6 + * Class Output
  7 + */
  8 +class Output extends \think\console\Output
  9 +{
  10 +
  11 + protected $message = [];
  12 +
  13 + public function __construct($driver = 'console')
  14 + {
  15 + parent::__construct($driver);
  16 + }
  17 +
  18 + protected function block($style, $message)
  19 + {
  20 + $this->message[] = $message;
  21 + }
  22 +
  23 + public function getMessage()
  24 + {
  25 + return $this->message;
  26 + }
  27 +
  28 +}
  1 +define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template'], function ($, undefined, Backend, Table, Form, Template) {
  2 +
  3 + var Controller = {
  4 + index: function () {
  5 + // 初始化表格参数配置
  6 + Table.api.init({
  7 + extend: {
  8 + index_url: 'command/index',
  9 + add_url: 'command/add',
  10 + edit_url: '',
  11 + del_url: 'command/del',
  12 + multi_url: 'command/multi',
  13 + table: 'command',
  14 + }
  15 + });
  16 +
  17 + var table = $("#table");
  18 +
  19 + // 初始化表格
  20 + table.bootstrapTable({
  21 + url: $.fn.bootstrapTable.defaults.extend.index_url,
  22 + pk: 'id',
  23 + sortName: 'id',
  24 + columns: [
  25 + [
  26 + {checkbox: true},
  27 + {field: 'id', title: __('Id')},
  28 + {field: 'type', title: __('Type'), formatter: Table.api.formatter.search},
  29 + {field: 'type_text', title: __('Type')},
  30 + {
  31 + field: 'command', title: __('Command'), formatter: function (value, row, index) {
  32 + return '<input type="text" class="form-control" value="' + value + '">';
  33 + }
  34 + },
  35 + {
  36 + field: 'executetime',
  37 + title: __('Executetime'),
  38 + operate: 'RANGE',
  39 + addclass: 'datetimerange',
  40 + formatter: Table.api.formatter.datetime
  41 + },
  42 + {
  43 + field: 'createtime',
  44 + title: __('Createtime'),
  45 + operate: 'RANGE',
  46 + addclass: 'datetimerange',
  47 + formatter: Table.api.formatter.datetime
  48 + },
  49 + {
  50 + field: 'updatetime',
  51 + title: __('Updatetime'),
  52 + operate: 'RANGE',
  53 + addclass: 'datetimerange',
  54 + formatter: Table.api.formatter.datetime
  55 + },
  56 + {
  57 + field: 'status',
  58 + title: __('Status'),
  59 + table: table,
  60 + custom: {"successed": 'success', "failured": 'danger'},
  61 + searchList: {"successed": __('Successed'), "failured": __('Failured')},
  62 + formatter: Table.api.formatter.status
  63 + },
  64 + {
  65 + field: 'operate',
  66 + title: __('Operate'),
  67 + buttons: [
  68 + {
  69 + name: 'execute',
  70 + title: __('Execute again'),
  71 + text: __('Execute again'),
  72 + url: 'command/execute',
  73 + icon: 'fa fa-repeat',
  74 + classname: 'btn btn-success btn-xs btn-execute btn-ajax',
  75 + success: function (data) {
  76 + Layer.alert("<textarea class='form-control' cols='60' rows='5'>" + data.result + "</textarea>", {
  77 + title: __("执行结果"),
  78 + shadeClose: true
  79 + });
  80 + table.bootstrapTable('refresh');
  81 + return false;
  82 + }
  83 + },
  84 + {
  85 + name: 'execute',
  86 + title: __('Detail'),
  87 + text: __('Detail'),
  88 + url: 'command/detail',
  89 + icon: 'fa fa-list',
  90 + classname: 'btn btn-info btn-xs btn-execute btn-dialog'
  91 + }
  92 + ],
  93 + table: table,
  94 + events: Table.api.events.operate,
  95 + formatter: Table.api.formatter.operate
  96 + }
  97 + ]
  98 + ]
  99 + });
  100 +
  101 + // 为表格绑定事件
  102 + Table.api.bindevent(table);
  103 + },
  104 + add: function () {
  105 + require(['bootstrap-select', 'bootstrap-select-lang']);
  106 + var mainfields = [];
  107 + var relationfields = {};
  108 + var maintable = [];
  109 + var relationtable = [];
  110 + var relationmode = ["belongsto", "hasone"];
  111 +
  112 + var renderselect = function (select, data) {
  113 + var html = [];
  114 + for (var i = 0; i < data.length; i++) {
  115 + html.push("<option value='" + data[i] + "'>" + data[i] + "</option>");
  116 + }
  117 + $(select).html(html.join(""));
  118 + select.trigger("change");
  119 + if (select.data("selectpicker")) {
  120 + select.selectpicker('refresh');
  121 + }
  122 + return select;
  123 + };
  124 +
  125 + $("select[name=table] option").each(function () {
  126 + maintable.push($(this).val());
  127 + });
  128 + $(document).on('change', "input[name='isrelation']", function () {
  129 + $("#relation-zone").toggleClass("hide", !$(this).prop("checked"));
  130 + });
  131 + $(document).on('change', "select[name='table']", function () {
  132 + var that = this;
  133 + Fast.api.ajax({
  134 + url: "command/get_field_list",
  135 + data: {table: $(that).val()},
  136 + }, function (data, ret) {
  137 + mainfields = data.fieldlist;
  138 + $("#relation-zone .relation-item").remove();
  139 + renderselect($("#fields"), mainfields);
  140 + return false;
  141 + });
  142 + return false;
  143 + });
  144 + $(document).on('click', "a.btn-newrelation", function () {
  145 + var that = this;
  146 + var index = parseInt($(that).data("index")) + 1;
  147 + var content = Template("relationtpl", {index: index});
  148 + content = $(content.replace(/\[index\]/, index));
  149 + $(this).data("index", index);
  150 + $(content).insertBefore($(that).closest(".row"));
  151 + $('select', content).selectpicker();
  152 + var exists = [$("select[name='table']").val()];
  153 + $("select.relationtable").each(function () {
  154 + exists.push($(this).val());
  155 + });
  156 + relationtable = [];
  157 + $.each(maintable, function (i, j) {
  158 + if ($.inArray(j, exists) < 0) {
  159 + relationtable.push(j);
  160 + }
  161 + });
  162 + renderselect($("select.relationtable", content), relationtable);
  163 + $("select.relationtable", content).trigger("change");
  164 + });
  165 + $(document).on('click', "a.btn-removerelation", function () {
  166 + $(this).closest(".row").remove();
  167 + });
  168 + $(document).on('change', "#relation-zone select.relationmode", function () {
  169 + var table = $("select.relationtable", $(this).closest(".row")).val();
  170 + var that = this;
  171 + Fast.api.ajax({
  172 + url: "command/get_field_list",
  173 + data: {table: table},
  174 + }, function (data, ret) {
  175 + renderselect($(that).closest(".row").find("select.relationprimarykey"), $(that).val() == 'belongsto' ? data.fieldlist : mainfields);
  176 + renderselect($(that).closest(".row").find("select.relationforeignkey"), $(that).val() == 'hasone' ? data.fieldlist : mainfields);
  177 + return false;
  178 + });
  179 + });
  180 + $(document).on('change', "#relation-zone select.relationtable", function () {
  181 + var that = this;
  182 + Fast.api.ajax({
  183 + url: "command/get_field_list",
  184 + data: {table: $(that).val()},
  185 + }, function (data, ret) {
  186 + renderselect($(that).closest(".row").find("select.relationmode"), relationmode);
  187 + renderselect($(that).closest(".row").find("select.relationfields"), mainfields)
  188 + renderselect($(that).closest(".row").find("select.relationforeignkey"), data.fieldlist)
  189 + renderselect($(that).closest(".row").find("select.relationfields"), data.fieldlist)
  190 + return false;
  191 + });
  192 + });
  193 + $(document).on('click', ".btn-command", function () {
  194 + var form = $(this).closest("form");
  195 + var textarea = $("textarea[rel=command]", form);
  196 + textarea.val('');
  197 + Fast.api.ajax({
  198 + url: "command/command/action/command",
  199 + data: form.serialize(),
  200 + }, function (data, ret) {
  201 + textarea.val(data.command);
  202 + return false;
  203 + });
  204 + });
  205 + $(document).on('click', ".btn-execute", function () {
  206 + var form = $(this).closest("form");
  207 + var textarea = $("textarea[rel=result]", form);
  208 + textarea.val('');
  209 + Fast.api.ajax({
  210 + url: "command/command/action/execute",
  211 + data: form.serialize(),
  212 + }, function (data, ret) {
  213 + textarea.val(data.result);
  214 + window.parent.$(".toolbar .btn-refresh").trigger('click');
  215 + top.window.Fast.api.refreshmenu();
  216 + return false;
  217 + }, function () {
  218 + window.parent.$(".toolbar .btn-refresh").trigger('click');
  219 + });
  220 + });
  221 + $("select[name='table']").trigger("change");
  222 + Controller.api.bindevent();
  223 + },
  224 + edit: function () {
  225 + Controller.api.bindevent();
  226 + },
  227 + api: {
  228 + bindevent: function () {
  229 + Form.api.bindevent($("form[role=form]"));
  230 + }
  231 + }
  232 + };
  233 + return Controller;
  234 +});
  1 +<?php
  2 +
  3 +namespace app\admin\controller;
  4 +
  5 +use app\common\controller\Backend;
  6 +use think\Config;
  7 +use think\console\Input;
  8 +use think\Db;
  9 +use think\Exception;
  10 +
  11 +/**
  12 + * 在线命令管理
  13 + *
  14 + * @icon fa fa-circle-o
  15 + */
  16 +class Command extends Backend
  17 +{
  18 +
  19 + /**
  20 + * Command模型对象
  21 + */
  22 + protected $model = null;
  23 + protected $noNeedRight = ['get_controller_list', 'get_field_list'];
  24 +
  25 + public function _initialize()
  26 + {
  27 + parent::_initialize();
  28 + $this->model = model('Command');
  29 + $this->view->assign("statusList", $this->model->getStatusList());
  30 + }
  31 +
  32 + /**
  33 + * 添加
  34 + */
  35 + public function add()
  36 + {
  37 +
  38 + $tableList = [];
  39 + $list = \think\Db::query("SHOW TABLES");
  40 + foreach ($list as $key => $row) {
  41 + $tableList[reset($row)] = reset($row);
  42 + }
  43 +
  44 + $this->view->assign("tableList", $tableList);
  45 + return $this->view->fetch();
  46 + }
  47 +
  48 + /**
  49 + * 获取字段列表
  50 + * @internal
  51 + */
  52 + public function get_field_list()
  53 + {
  54 + $dbname = Config::get('database.database');
  55 + $prefix = Config::get('database.prefix');
  56 + $table = $this->request->request('table');
  57 + //从数据库中获取表字段信息
  58 + $sql = "SELECT * FROM `information_schema`.`columns` "
  59 + . "WHERE TABLE_SCHEMA = ? AND table_name = ? "
  60 + . "ORDER BY ORDINAL_POSITION";
  61 + //加载主表的列
  62 + $columnList = Db::query($sql, [$dbname, $table]);
  63 + $fieldlist = [];
  64 + foreach ($columnList as $index => $item) {
  65 + $fieldlist[] = $item['COLUMN_NAME'];
  66 + }
  67 + $this->success("", null, ['fieldlist' => $fieldlist]);
  68 + }
  69 +
  70 + /**
  71 + * 获取控制器列表
  72 + * @internal
  73 + */
  74 + public function get_controller_list()
  75 + {
  76 + $adminPath = dirname(__DIR__) . DS;
  77 + $controllerDir = $adminPath . 'controller' . DS;
  78 + $files = new \RecursiveIteratorIterator(
  79 + new \RecursiveDirectoryIterator($controllerDir), \RecursiveIteratorIterator::LEAVES_ONLY
  80 + );
  81 + $list = [];
  82 + foreach ($files as $name => $file) {
  83 + if (!$file->isDir()) {
  84 + $filePath = $file->getRealPath();
  85 + $name = str_replace($controllerDir, '', $filePath);
  86 + $name = str_replace(DS, "/", $name);
  87 + $list[] = ['id' => $name, 'name' => $name];
  88 + }
  89 + }
  90 + $pageNumber = $this->request->request("pageNumber");
  91 + $pageSize = $this->request->request("pageSize");
  92 + return json(['list' => array_slice($list, ($pageNumber - 1) * $pageSize, $pageSize), 'total' => count($list)]);
  93 + }
  94 +
  95 + /**
  96 + * 详情
  97 + */
  98 + public function detail($ids)
  99 + {
  100 + $row = $this->model->get($ids);
  101 + if (!$row)
  102 + $this->error(__('No Results were found'));
  103 + $this->view->assign("row", $row);
  104 + return $this->view->fetch();
  105 + }
  106 +
  107 + /**
  108 + * 执行
  109 + */
  110 + public function execute($ids)
  111 + {
  112 + $row = $this->model->get($ids);
  113 + if (!$row)
  114 + $this->error(__('No Results were found'));
  115 + $result = $this->doexecute($row['type'], json_decode($row['params'], true));
  116 + $this->success("", null, ['result' => $result]);
  117 + }
  118 +
  119 + /**
  120 + * 执行命令
  121 + */
  122 + public function command($action = '')
  123 + {
  124 + $commandtype = $this->request->request("commandtype");
  125 + $params = $this->request->request();
  126 + $allowfields = [
  127 + 'crud' => 'table,controller,model,fields,force,local,delete,menu',
  128 + 'menu' => 'controller,delete',
  129 + 'min' => 'module,resource,optimize',
  130 + 'api' => 'url,module,output,template,force,title,author,class,language',
  131 + ];
  132 + $argv = [];
  133 + $allowfields = isset($allowfields[$commandtype]) ? explode(',', $allowfields[$commandtype]) : [];
  134 + $allowfields = array_filter(array_intersect_key($params, array_flip($allowfields)));
  135 + if (isset($params['local']) && !$params['local']) {
  136 + $allowfields['local'] = $params['local'];
  137 + } else {
  138 + unset($allowfields['local']);
  139 + }
  140 + foreach ($allowfields as $key => $param) {
  141 + $argv[] = "--{$key}=" . (is_array($param) ? implode(',', $param) : $param);
  142 + }
  143 + if ($commandtype == 'crud') {
  144 + $extend = 'setcheckboxsuffix,enumradiosuffix,imagefield,filefield,intdatesuffix,switchsuffix,citysuffix,selectpagesuffix,selectpagessuffix,ignorefields,sortfield,editorsuffix,headingfilterfield';
  145 + $extendArr = explode(',', $extend);
  146 + foreach ($params as $index => $item) {
  147 + if (in_array($index, $extendArr)) {
  148 + foreach (explode(',', $item) as $key => $value) {
  149 + if ($value) {
  150 + $argv[] = "--{$index}={$value}";
  151 + }
  152 + }
  153 + }
  154 + }
  155 + $isrelation = (int)$this->request->request('isrelation');
  156 + if ($isrelation && isset($params['relation'])) {
  157 + foreach ($params['relation'] as $index => $relation) {
  158 + foreach ($relation as $key => $value) {
  159 + $argv[] = "--{$key}=" . (is_array($value) ? implode(',', $value) : $value);
  160 + }
  161 + }
  162 + }
  163 + } else if ($commandtype == 'menu') {
  164 + if (isset($params['allcontroller']) && $params['allcontroller']) {
  165 + $argv[] = "--controller=all-controller";
  166 + } else {
  167 + foreach (explode(',', $params['controllerfile']) as $index => $param) {
  168 + if ($param) {
  169 + $argv[] = "--controller=" . substr($param, 0, -4);
  170 + }
  171 + }
  172 + }
  173 + } else if ($commandtype == 'min') {
  174 +
  175 + } else if ($commandtype == 'api') {
  176 +
  177 + } else {
  178 +
  179 + }
  180 + if ($action == 'execute') {
  181 + $result = $this->doexecute($commandtype, $argv);
  182 + $this->success("", null, ['result' => $result]);
  183 + } else {
  184 + $this->success("", null, ['command' => "php think {$commandtype} " . implode(' ', $argv)]);
  185 + }
  186 +
  187 + return;
  188 + }
  189 +
  190 + protected function doexecute($commandtype, $argv)
  191 + {
  192 + $commandName = "\\app\\admin\\command\\" . ucfirst($commandtype);
  193 + $input = new Input($argv);
  194 + $output = new \addons\command\library\Output();
  195 + $command = new $commandName($commandtype);
  196 + $data = [
  197 + 'type' => $commandtype,
  198 + 'params' => json_encode($argv),
  199 + 'command' => "php think {$commandtype} " . implode(' ', $argv),
  200 + 'executetime' => time(),
  201 + ];
  202 + $this->model->save($data);
  203 + try {
  204 + $command->run($input, $output);
  205 + $result = implode("\n", $output->getMessage());
  206 + $this->model->status = 'successed';
  207 + } catch (Exception $e) {
  208 + $result = implode("\n", $output->getMessage()) . "\n";
  209 + $result .= $e->getMessage();
  210 + $this->model->status = 'failured';
  211 + }
  212 + $result = trim($result);
  213 + $this->model->content = $result;
  214 + $this->model->save();
  215 + return $result;
  216 + }
  217 +
  218 +
  219 +}
  1 +<?php
  2 +
  3 +namespace app\admin\controller;
  4 +
  5 +use app\common\controller\Backend;
  6 +
  7 +/**
  8 + * 资讯分类管理
  9 + *
  10 + * @icon fa fa-circle-o
  11 + */
  12 +class Contype extends Backend
  13 +{
  14 +
  15 + /**
  16 + * Contype模型对象
  17 + * @var \app\admin\model\Contype
  18 + */
  19 + protected $model = null;
  20 + protected $searchFields = 'title';
  21 + public function _initialize()
  22 + {
  23 + parent::_initialize();
  24 + $this->model = new \app\admin\model\Contype;
  25 +
  26 + }
  27 +
  28 + /**
  29 + * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
  30 + * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
  31 + * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
  32 + */
  33 +
  34 +
  35 +}
  1 +<?php
  2 +
  3 +namespace app\admin\controller;
  4 +
  5 +use app\common\controller\Backend;
  6 +
  7 +/**
  8 + * 首页轮播图
  9 + *
  10 + * @icon fa fa-circle-o
  11 + */
  12 +class Pic extends Backend
  13 +{
  14 +
  15 + /**
  16 + * Pic模型对象
  17 + * @var \app\admin\model\Pic
  18 + */
  19 + protected $model = null;
  20 +
  21 +
  22 + public function _initialize()
  23 + {
  24 + parent::_initialize();
  25 + $this->model = new \app\admin\model\Pic;
  26 +
  27 + }
  28 +
  29 + /**
  30 + * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
  31 + * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
  32 + * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
  33 + */
  34 +
  35 +
  36 +}
  1 +<?php
  2 +
  3 +return [
  4 + 'Id' => 'ID',
  5 + 'Type' => '类型',
  6 + 'Params' => '参数',
  7 + 'Command' => '命令',
  8 + 'Content' => '返回结果',
  9 + 'Executetime' => '执行时间',
  10 + 'Createtime' => '创建时间',
  11 + 'Updatetime' => '更新时间',
  12 + 'Execute again' => '再次执行',
  13 + 'Successed' => '成功',
  14 + 'Failured' => '失败',
  15 + 'Status' => '状态'
  16 +];
  1 +<?php
  2 +
  3 +return [
  4 + 'Id' => '资讯分类ID',
  5 + 'Title' => '标题',
  6 + 'Type' => '类型',
  7 + 'Createtime' => '创建时间',
  8 + 'Updatetime' => '修改时间'
  9 +];
  1 +<?php
  2 +
  3 +return [
  4 + 'Id' => '轮播图ID',
  5 + 'Thumbnail' => '图片',
  6 + 'Createtime' => '创建时间',
  7 + 'Updatetime' => '修改时间'
  8 +];
  1 +<?php
  2 +
  3 +namespace app\admin\model;
  4 +
  5 +use think\Model;
  6 +
  7 +class Command extends Model
  8 +{
  9 + // 表名
  10 + protected $name = 'command';
  11 +
  12 + // 自动写入时间戳字段
  13 + protected $autoWriteTimestamp = 'int';
  14 +
  15 + // 定义时间戳字段名
  16 + protected $createTime = 'createtime';
  17 + protected $updateTime = 'updatetime';
  18 +
  19 + // 追加属性
  20 + protected $append = [
  21 + 'executetime_text',
  22 + 'type_text',
  23 + 'status_text'
  24 + ];
  25 +
  26 +
  27 + public function getStatusList()
  28 + {
  29 + return ['successed' => __('Successed'), 'failured' => __('Failured')];
  30 + }
  31 +
  32 +
  33 + public function getExecutetimeTextAttr($value, $data)
  34 + {
  35 + $value = $value ? $value : $data['executetime'];
  36 + return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
  37 + }
  38 +
  39 + public function getTypeTextAttr($value, $data)
  40 + {
  41 + $value = $value ? $value : $data['type'];
  42 + $list = ['crud' => '一键生成CRUD', 'menu' => '一键生成菜单', 'min' => '一键压缩打包', 'api' => '一键生成文档'];
  43 + return isset($list[$value]) ? $list[$value] : '';
  44 + }
  45 +
  46 + public function getStatusTextAttr($value, $data)
  47 + {
  48 + $value = $value ? $value : $data['status'];
  49 + $list = $this->getStatusList();
  50 + return isset($list[$value]) ? $list[$value] : '';
  51 + }
  52 +
  53 + protected function setExecutetimeAttr($value)
  54 + {
  55 + return $value && !is_numeric($value) ? strtotime($value) : $value;
  56 + }
  57 +
  58 +
  59 +}
  1 +<?php
  2 +
  3 +namespace app\admin\model;
  4 +
  5 +use think\Model;
  6 +
  7 +
  8 +class Contype extends Model
  9 +{
  10 +
  11 +
  12 +
  13 +
  14 +
  15 + // 表名
  16 + protected $name = 'contype';
  17 +
  18 + // 自动写入时间戳字段
  19 + protected $autoWriteTimestamp = 'int';
  20 +
  21 + // 定义时间戳字段名
  22 + protected $createTime = 'createtime';
  23 + protected $updateTime = 'updatetime';
  24 + protected $deleteTime = false;
  25 +
  26 + // 追加属性
  27 + protected $append = [
  28 +
  29 + ];
  30 +
  31 +
  32 +
  33 +
  34 +
  35 +
  36 +
  37 +
  38 +
  39 +
  40 +}
  1 +<?php
  2 +
  3 +namespace app\admin\model;
  4 +
  5 +use think\Model;
  6 +
  7 +
  8 +class Pic extends Model
  9 +{
  10 +
  11 +
  12 +
  13 +
  14 +
  15 + // 表名
  16 + protected $name = 'pic';
  17 +
  18 + // 自动写入时间戳字段
  19 + protected $autoWriteTimestamp = 'int';
  20 +
  21 + // 定义时间戳字段名
  22 + protected $createTime = 'createtime';
  23 + protected $updateTime = 'updatetime';
  24 + protected $deleteTime = false;
  25 +
  26 + // 追加属性
  27 + protected $append = [
  28 +
  29 + ];
  30 +
  31 +
  32 +
  33 +
  34 +
  35 +
  36 +
  37 +
  38 +
  39 +
  40 +}
  1 +<?php
  2 +
  3 +namespace app\admin\validate;
  4 +
  5 +use think\Validate;
  6 +
  7 +class Command extends Validate
  8 +{
  9 + /**
  10 + * 验证规则
  11 + */
  12 + protected $rule = [
  13 + ];
  14 + /**
  15 + * 提示消息
  16 + */
  17 + protected $message = [
  18 + ];
  19 + /**
  20 + * 验证场景
  21 + */
  22 + protected $scene = [
  23 + 'add' => [],
  24 + 'edit' => [],
  25 + ];
  26 +
  27 +}
  1 +<?php
  2 +
  3 +namespace app\admin\validate;
  4 +
  5 +use think\Validate;
  6 +
  7 +class Contype extends Validate
  8 +{
  9 + /**
  10 + * 验证规则
  11 + */
  12 + protected $rule = [
  13 + ];
  14 + /**
  15 + * 提示消息
  16 + */
  17 + protected $message = [
  18 + ];
  19 + /**
  20 + * 验证场景
  21 + */
  22 + protected $scene = [
  23 + 'add' => [],
  24 + 'edit' => [],
  25 + ];
  26 +
  27 +}
  1 +<?php
  2 +
  3 +namespace app\admin\validate;
  4 +
  5 +use think\Validate;
  6 +
  7 +class Pic extends Validate
  8 +{
  9 + /**
  10 + * 验证规则
  11 + */
  12 + protected $rule = [
  13 + ];
  14 + /**
  15 + * 提示消息
  16 + */
  17 + protected $message = [
  18 + ];
  19 + /**
  20 + * 验证场景
  21 + */
  22 + protected $scene = [
  23 + 'add' => [],
  24 + 'edit' => [],
  25 + ];
  26 +
  27 +}
  1 +<style>
  2 + .relation-item {margin-top:10px;}
  3 + legend {padding-bottom:5px;font-size:14px;font-weight:600;}
  4 + label {font-weight:normal;}
  5 + .form-control{padding:6px 8px;}
  6 + #extend-zone .col-xs-2 {margin-top:10px;padding-right:0;}
  7 + #extend-zone .col-xs-2:nth-child(6n+0) {padding-right:15px;}
  8 +</style>
  9 +<div class="panel panel-default panel-intro">
  10 + <div class="panel-heading">
  11 + <ul class="nav nav-tabs">
  12 + <li class="active"><a href="#crud" data-toggle="tab">{:__('一键生成CRUD')}</a></li>
  13 + <li><a href="#menu" data-toggle="tab">{:__('一键生成菜单')}</a></li>
  14 + <li><a href="#min" data-toggle="tab">{:__('一键压缩打包')}</a></li>
  15 + <li><a href="#api" data-toggle="tab">{:__('一键生成API文档')}</a></li>
  16 + </ul>
  17 + </div>
  18 + <div class="panel-body">
  19 + <div id="myTabContent" class="tab-content">
  20 + <div class="tab-pane fade active in" id="crud">
  21 + <div class="row">
  22 + <div class="col-xs-12">
  23 + <form role="form">
  24 + <input type="hidden" name="commandtype" value="crud" />
  25 + <div class="form-group">
  26 + <div class="row">
  27 + <div class="col-xs-3">
  28 + <input checked="" name="isrelation" type="hidden" value="0">
  29 + <label class="control-label" data-toggle="tooltip" title="当前只支持生成1对1关联模型,选中后请配置关联表和字段">
  30 + <input name="isrelation" type="checkbox" value="1">
  31 + 关联模型
  32 + </label>
  33 + </div>
  34 + <div class="col-xs-3">
  35 + <input checked="" name="local" type="hidden" value="1">
  36 + <label class="control-label" data-toggle="tooltip" title="默认模型生成在application/admin/model目录下,选中后将生成在application/common/model目录下">
  37 + <input name="local" type="checkbox" value="0"> 全局模型类
  38 + </label>
  39 + </div>
  40 + <div class="col-xs-3">
  41 + <input checked="" name="delete" type="hidden" value="0">
  42 + <label class="control-label" data-toggle="tooltip" title="删除CRUD生成的相关文件">
  43 + <input name="delete" type="checkbox" value="1"> 删除模式
  44 + </label>
  45 + </div>
  46 + <div class="col-xs-3">
  47 + <input checked="" name="force" type="hidden" value="0">
  48 + <label class="control-label" data-toggle="tooltip" title="选中后,如果已经存在同名文件将被覆盖。如果是删除将不再提醒">
  49 + <input name="force" type="checkbox" value="1">
  50 + 强制覆盖模式
  51 + </label>
  52 + </div>
  53 + <!--
  54 + <div class="col-xs-3">
  55 + <input checked="" name="menu" type="hidden" value="0">
  56 + <label class="control-label" data-toggle="tooltip" title="选中后,将同时生成后台菜单规则">
  57 + <input name="menu" type="checkbox" value="1">
  58 + 生成菜单
  59 + </label>
  60 + </div>
  61 + -->
  62 + </div>
  63 + </div>
  64 + <div class="form-group">
  65 + <legend>主表设置</legend>
  66 + <div class="row">
  67 + <div class="col-xs-3">
  68 + <label>请选择主表</label>
  69 + {:build_select('table',$tableList,null,['class'=>'form-control selectpicker']);}
  70 + </div>
  71 + <div class="col-xs-3">
  72 + <label>自定义控制器名</label>
  73 + <input type="text" class="form-control" name="controller" data-toggle="tooltip" title="默认根据表名自动生成,如果需要放在二级目录请手动填写" placeholder="支持目录层级,以/分隔">
  74 + </div>
  75 + <div class="col-xs-3">
  76 + <label>自定义模型名</label>
  77 + <input type="text" class="form-control" name="model" data-toggle="tooltip" title="默认根据表名自动生成" placeholder="不支持目录层级">
  78 + </div>
  79 + <div class="col-xs-3">
  80 + <label>请选择显示字段(默认全部)</label>
  81 + <select name="fields[]" id="fields" multiple style="height:30px;" class="form-control selectpicker"></select>
  82 + </div>
  83 +
  84 + </div>
  85 +
  86 + </div>
  87 +
  88 + <div class="form-group hide" id="relation-zone">
  89 + <legend>关联表设置</legend>
  90 +
  91 + <div class="row" style="margin-top:15px;">
  92 + <div class="col-xs-12">
  93 + <a href="javascript:;" class="btn btn-primary btn-sm btn-newrelation" data-index="1">追加关联模型</a>
  94 + </div>
  95 + </div>
  96 + </div>
  97 +
  98 + <hr>
  99 + <div class="form-group" id="extend-zone">
  100 + <legend>字段识别设置 <span style="font-size:12px;font-weight: normal;">(与之匹配的字段都将生成相应组件)</span></legend>
  101 + <div class="row">
  102 + <div class="col-xs-2">
  103 + <label>复选框后缀</label>
  104 + <input type="text" class="form-control" name="setcheckboxsuffix" placeholder="默认为set类型" />
  105 + </div>
  106 + <div class="col-xs-2">
  107 + <label>单选框后缀</label>
  108 + <input type="text" class="form-control" name="enumradiosuffix" placeholder="默认为enum类型" />
  109 + </div>
  110 + <div class="col-xs-2">
  111 + <label>图片类型后缀</label>
  112 + <input type="text" class="form-control" name="imagefield" placeholder="默认为image,images,avatar,avatars" />
  113 + </div>
  114 + <div class="col-xs-2">
  115 + <label>文件类型后缀</label>
  116 + <input type="text" class="form-control" name="filefield" placeholder="默认为file,files" />
  117 + </div>
  118 + <div class="col-xs-2">
  119 + <label>日期时间后缀</label>
  120 + <input type="text" class="form-control" name="intdatesuffix" placeholder="默认为time" />
  121 + </div>
  122 + <div class="col-xs-2">
  123 + <label>开关后缀</label>
  124 + <input type="text" class="form-control" name="switchsuffix" placeholder="默认为switch" />
  125 + </div>
  126 + <div class="col-xs-2">
  127 + <label>城市选择后缀</label>
  128 + <input type="text" class="form-control" name="citysuffix" placeholder="默认为city" />
  129 + </div>
  130 + <div class="col-xs-2">
  131 + <label>动态下拉后缀(单)</label>
  132 + <input type="text" class="form-control" name="selectpagesuffix" placeholder="默认为_id" />
  133 + </div>
  134 + <div class="col-xs-2">
  135 + <label>动态下拉后缀(多)</label>
  136 + <input type="text" class="form-control" name="selectpagessuffix" placeholder="默认为_ids" />
  137 + </div>
  138 + <div class="col-xs-2">
  139 + <label>忽略的字段</label>
  140 + <input type="text" class="form-control" name="ignorefields" placeholder="默认无" />
  141 + </div>
  142 + <div class="col-xs-2">
  143 + <label>排序字段</label>
  144 + <input type="text" class="form-control" name="sortfield" placeholder="默认为weigh" />
  145 + </div>
  146 + <div class="col-xs-2">
  147 + <label>富文本编辑器</label>
  148 + <input type="text" class="form-control" name="editorsuffix" placeholder="默认为content" />
  149 + </div>
  150 + <div class="col-xs-2">
  151 + <label>选项卡过滤字段</label>
  152 + <input type="text" class="form-control" name="headingfilterfield" placeholder="默认为status" />
  153 + </div>
  154 +
  155 + </div>
  156 +
  157 + </div>
  158 +
  159 + <div class="form-group">
  160 + <legend>生成命令行</legend>
  161 + <textarea class="form-control" data-toggle="tooltip" title="如果在线执行命令失败,可以将命令复制到命令行进行执行" rel="command" rows="1" placeholder="请点击生成命令行"></textarea>
  162 + </div>
  163 +
  164 + <div class="form-group">
  165 + <legend>返回结果</legend>
  166 + <textarea class="form-control" rel="result" rows="5" placeholder="请点击立即执行"></textarea>
  167 + </div>
  168 +
  169 + <div class="form-group">
  170 + <button type="button" class="btn btn-info btn-embossed btn-command">{:__('生成命令行')}</button>
  171 + <button type="button" class="btn btn-success btn-embossed btn-execute">{:__('立即执行')}</button>
  172 + </div>
  173 +
  174 + </form>
  175 + </div>
  176 + </div>
  177 + </div>
  178 + <div class="tab-pane fade" id="menu">
  179 + <div class="row">
  180 + <div class="col-xs-12">
  181 + <form role="form">
  182 + <input type="hidden" name="commandtype" value="menu" />
  183 + <div class="form-group">
  184 + <div class="row">
  185 + <div class="col-xs-3">
  186 + <input checked="" name="allcontroller" type="hidden" value="0">
  187 + <label class="control-label">
  188 + <input name="allcontroller" data-toggle="collapse" data-target="#controller" type="checkbox" value="1"> 一键生成全部控制器
  189 + </label>
  190 + </div>
  191 + <div class="col-xs-3">
  192 + <input checked="" name="delete" type="hidden" value="0">
  193 + <label class="control-label">
  194 + <input name="delete" type="checkbox" value="1"> 删除模式
  195 + </label>
  196 + </div>
  197 + <div class="col-xs-3">
  198 + <input checked="" name="force" type="hidden" value="0">
  199 + <label class="control-label">
  200 + <input name="force" type="checkbox" value="1"> 强制覆盖模式
  201 + </label>
  202 + </div>
  203 + </div>
  204 + </div>
  205 +
  206 + <div class="form-group in" id="controller">
  207 + <legend>控制器设置</legend>
  208 +
  209 + <div class="row" style="margin-top:15px;">
  210 + <div class="col-xs-12">
  211 + <input type="text" name="controllerfile" class="form-control selectpage" style="width:720px;" data-source="command/get_controller_list" data-multiple="true" name="controller" placeholder="请选择控制器" />
  212 + </div>
  213 + </div>
  214 + </div>
  215 +
  216 + <div class="form-group">
  217 + <legend>生成命令行</legend>
  218 + <textarea class="form-control" rel="command" rows="1" placeholder="请点击生成命令行"></textarea>
  219 + </div>
  220 +
  221 + <div class="form-group">
  222 + <legend>返回结果</legend>
  223 + <textarea class="form-control" rel="result" rows="5" placeholder="请点击立即执行"></textarea>
  224 + </div>
  225 +
  226 + <div class="form-group">
  227 + <button type="button" class="btn btn-info btn-embossed btn-command">{:__('生成命令行')}</button>
  228 + <button type="button" class="btn btn-success btn-embossed btn-execute">{:__('立即执行')}</button>
  229 + </div>
  230 +
  231 + </form>
  232 + </div>
  233 + </div>
  234 + </div>
  235 + <div class="tab-pane fade" id="min">
  236 + <div class="row">
  237 + <div class="col-xs-12">
  238 + <form role="form">
  239 + <input type="hidden" name="commandtype" value="min" />
  240 + <div class="form-group">
  241 + <legend>基础设置</legend>
  242 + <div class="row">
  243 + <div class="col-xs-3">
  244 + <label>请选择压缩模块</label>
  245 + <select name="module" class="form-control selectpicker">
  246 + <option value="all" selected>全部</option>
  247 + <option value="backend">后台Backend</option>
  248 + <option value="frontend">前台Frontend</option>
  249 + </select>
  250 + </div>
  251 + <div class="col-xs-3">
  252 + <label>请选择压缩资源</label>
  253 + <select name="resource" class="form-control selectpicker">
  254 + <option value="all" selected>全部</option>
  255 + <option value="js">JS</option>
  256 + <option value="css">CSS</option>
  257 + </select>
  258 + </div>
  259 + <div class="col-xs-3">
  260 + <label>请选择压缩模式</label>
  261 + <select name="optimize" class="form-control selectpicker">
  262 + <option value=""></option>
  263 + <option value="uglify">uglify</option>
  264 + <option value="closure">closure</option>
  265 + </select>
  266 + </div>
  267 + </div>
  268 + </div>
  269 +
  270 + <div class="form-group in">
  271 + <legend>控制器设置</legend>
  272 +
  273 + <div class="row" style="margin-top:15px;">
  274 + <div class="col-xs-12">
  275 +
  276 + </div>
  277 + </div>
  278 + </div>
  279 +
  280 + <div class="form-group">
  281 + <legend>生成命令行</legend>
  282 + <textarea class="form-control" rel="command" rows="1" placeholder="请点击生成命令行"></textarea>
  283 + </div>
  284 +
  285 + <div class="form-group">
  286 + <legend>返回结果</legend>
  287 + <textarea class="form-control" rel="result" rows="5" placeholder="请点击立即执行"></textarea>
  288 + </div>
  289 +
  290 + <div class="form-group">
  291 + <button type="button" class="btn btn-info btn-embossed btn-command">{:__('生成命令行')}</button>
  292 + <button type="button" class="btn btn-success btn-embossed btn-execute">{:__('立即执行')}</button>
  293 + </div>
  294 +
  295 + </form>
  296 + </div>
  297 + </div>
  298 + </div>
  299 + <div class="tab-pane fade" id="api">
  300 + <div class="row">
  301 + <div class="col-xs-12">
  302 + <form role="form">
  303 + <input type="hidden" name="commandtype" value="api" />
  304 + <div class="form-group">
  305 + <div class="row">
  306 + <div class="col-xs-3">
  307 + <input checked="" name="force" type="hidden" value="0">
  308 + <label class="control-label">
  309 + <input name="force" type="checkbox" value="1">
  310 + 覆盖模式
  311 + </label>
  312 + </div>
  313 + </div>
  314 + </div>
  315 + <div class="form-group">
  316 + <legend>文档设置</legend>
  317 + <div class="row">
  318 + <div class="col-xs-3">
  319 + <label>请输入接口URL</label>
  320 + <input type="text" name="url" class="form-control" placeholder="API URL,可留空" />
  321 + </div>
  322 + <div class="col-xs-3">
  323 + <label>接口生成文件</label>
  324 + <input type="text" name="output" class="form-control" placeholder="留空则使用api.html" />
  325 + </div>
  326 + <div class="col-xs-3">
  327 + <label>模板文件</label>
  328 + <input type="text" name="template" class="form-control" placeholder="如果不清楚请留空" />
  329 + </div>
  330 + </div>
  331 + <div class="row" style="margin-top:10px;">
  332 + <div class="col-xs-3">
  333 + <label>文档标题</label>
  334 + <input type="text" name="title" class="form-control" placeholder="默认为FastAdmin" />
  335 + </div>
  336 + <div class="col-xs-3">
  337 + <label>文档作者</label>
  338 + <input type="text" name="author" class="form-control" placeholder="默认为FastAdmin" />
  339 + </div>
  340 + <div class="col-xs-3">
  341 + <label>文档语言</label>
  342 + <select name="language" class="form-control">
  343 + <option value="" selected>请选择语言</option>
  344 + <option value="zh-cn">中文</option>
  345 + <option value="en">英文</option>
  346 + </select>
  347 + </div>
  348 + </div>
  349 + </div>
  350 +
  351 + <div class="form-group">
  352 + <legend>生成命令行</legend>
  353 + <textarea class="form-control" rel="command" rows="1" placeholder="请点击生成命令行"></textarea>
  354 + </div>
  355 +
  356 + <div class="form-group">
  357 + <legend>返回结果</legend>
  358 + <textarea class="form-control" rel="result" rows="5" placeholder="请点击立即执行"></textarea>
  359 + </div>
  360 +
  361 + <div class="form-group">
  362 + <button type="button" class="btn btn-info btn-embossed btn-command">{:__('生成命令行')}</button>
  363 + <button type="button" class="btn btn-success btn-embossed btn-execute">{:__('立即执行')}</button>
  364 + </div>
  365 +
  366 + </form>
  367 + </div>
  368 + </div>
  369 + </div>
  370 + </div>
  371 + </div>
  372 +</div>
  373 +<script id="relationtpl" type="text/html">
  374 + <div class="row relation-item">
  375 + <div class="col-xs-2">
  376 + <label>请选择关联表</label>
  377 + <select name="relation[<%=index%>][relation]" class="form-control relationtable"></select>
  378 + </div>
  379 + <div class="col-xs-2">
  380 + <label>请选择关联类型</label>
  381 + <select name="relation[<%=index%>][relationmode]" class="form-control relationmode"></select>
  382 + </div>
  383 + <div class="col-xs-2">
  384 + <label>关联外键</label>
  385 + <select name="relation[<%=index%>][relationforeignkey]" class="form-control relationforeignkey"></select>
  386 + </div>
  387 + <div class="col-xs-2">
  388 + <label>关联主键</label>
  389 + <select name="relation[<%=index%>][relationprimarykey]" class="form-control relationprimarykey"></select>
  390 + </div>
  391 + <div class="col-xs-2">
  392 + <label>请选择显示字段</label>
  393 + <select name="relation[<%=index%>][relationfields][]" multiple class="form-control relationfields"></select>
  394 + </div>
  395 + <div class="col-xs-2">
  396 + <label>&nbsp;</label>
  397 + <a href="javascript:;" class="btn btn-danger btn-block btn-removerelation">移除</a>
  398 + </div>
  399 + </div>
  400 +</script>
  1 +<table class="table table-striped">
  2 + <thead>
  3 + <tr>
  4 + <th>{:__('Title')}</th>
  5 + <th>{:__('Content')}</th>
  6 + </tr>
  7 + </thead>
  8 + <tbody>
  9 + <tr>
  10 + <td>{:__('Type')}</td>
  11 + <td>{$row.type}({$row.type_text})</td>
  12 + </tr>
  13 + <tr>
  14 + <td>{:__('Params')}</td>
  15 + <td>{$row.params}</td>
  16 + </tr>
  17 + <tr>
  18 + <td>{:__('Command')}</td>
  19 + <td>{$row.command}</td>
  20 + </tr>
  21 + <tr>
  22 + <td>{:__('Content')}</td>
  23 + <td>
  24 + <textarea class="form-control" name="" id="" cols="60" rows="10">{$row.content}</textarea>
  25 + </td>
  26 + </tr>
  27 + <tr>
  28 + <td>{:__('Executetime')}</td>
  29 + <td>{$row.executetime|datetime}</td>
  30 + </tr>
  31 + <tr>
  32 + <td>{:__('Status')}</td>
  33 + <td>{$row.status_text}</td>
  34 + </tr>
  35 + </tbody>
  36 +</table>
  37 +<div class="hide layer-footer">
  38 + <label class="control-label col-xs-12 col-sm-2"></label>
  39 + <div class="col-xs-12 col-sm-8">
  40 + <button type="reset" class="btn btn-primary btn-embossed btn-close" onclick="Layer.closeAll();">{:__('Close')}</button>
  41 + </div>
  42 +</div>
  1 +<div class="panel panel-default panel-intro">
  2 + {:build_heading()}
  3 +
  4 + <div class="panel-body">
  5 + <div id="myTabContent" class="tab-content">
  6 + <div class="tab-pane fade active in" id="one">
  7 + <div class="widget-body no-padding">
  8 + <div id="toolbar" class="toolbar">
  9 + <a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
  10 + <a href="javascript:;" class="btn btn-success btn-add {:$auth->check('command/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>
  11 + <a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('command/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
  12 +
  13 + </div>
  14 + <table id="table" class="table table-striped table-bordered table-hover"
  15 + data-operate-detail="{:$auth->check('command/detail')}"
  16 + data-operate-execute="{:$auth->check('command/execute')}"
  17 + data-operate-del="{:$auth->check('command/del')}"
  18 + width="100%">
  19 + </table>
  20 + </div>
  21 + </div>
  22 +
  23 + </div>
  24 + </div>
  25 +</div>
  1 +<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
  2 +
  3 + <div class="form-group">
  4 + <label class="control-label col-xs-12 col-sm-2">{:__('Title')}:</label>
  5 + <div class="col-xs-12 col-sm-8">
  6 + <input id="c-title" data-rule="required" class="form-control" name="row[title]" type="text" placeholder="请输入标签名称">
  7 + </div>
  8 + </div>
  9 + <div class="form-group">
  10 + <label class="control-label col-xs-12 col-sm-2">{:__('Type')}:</label>
  11 + <div class="col-xs-12 col-sm-8">
  12 + {:build_radios('row[type]', ['1'=>__('经营管理'), '2'=>__('职业发展')])}
  13 + </div>
  14 + </div>
  15 + <div class="form-group layer-footer">
  16 + <label class="control-label col-xs-12 col-sm-2"></label>
  17 + <div class="col-xs-12 col-sm-8">
  18 + <button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
  19 + <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
  20 + </div>
  21 + </div>
  22 +</form>
  1 +<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
  2 +
  3 + <div class="form-group">
  4 + <label class="control-label col-xs-12 col-sm-2">{:__('Title')}:</label>
  5 + <div class="col-xs-12 col-sm-8">
  6 + <input id="c-title" data-rule="required" class="form-control" name="row[title]" type="text" value="{$row.title|htmlentities}" placeholder="请输入标签名称">
  7 + </div>
  8 + </div>
  9 + <div class="form-group">
  10 + <label class="control-label col-xs-12 col-sm-2">{:__('Type')}:</label>
  11 + <div class="col-xs-12 col-sm-8">
  12 + {:build_radios('row[type]', ['1'=>__('经营管理'), '2'=>__('职业发展')], $row['type'])}
  13 + </div>
  14 + </div>
  15 + <div class="form-group layer-footer">
  16 + <label class="control-label col-xs-12 col-sm-2"></label>
  17 + <div class="col-xs-12 col-sm-8">
  18 + <button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
  19 + <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
  20 + </div>
  21 + </div>
  22 +</form>
  1 +<div class="panel panel-default panel-intro">
  2 + {:build_heading()}
  3 +
  4 + <div class="panel-body">
  5 + <div id="myTabContent" class="tab-content">
  6 + <div class="tab-pane fade active in" id="one">
  7 + <div class="widget-body no-padding">
  8 + <div id="toolbar" class="toolbar">
  9 + <a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
  10 + <a href="javascript:;" class="btn btn-success btn-add {:$auth->check('contype/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>
  11 + <a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('contype/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>
  12 + <a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('contype/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
  13 + <a href="javascript:;" class="btn btn-danger btn-import {:$auth->check('contype/import')?'':'hide'}" title="{:__('Import')}" id="btn-import-file" data-url="ajax/upload" data-mimetype="csv,xls,xlsx" data-multiple="false"><i class="fa fa-upload"></i> {:__('Import')}</a>
  14 +
  15 + <div class="dropdown btn-group {:$auth->check('contype/multi')?'':'hide'}">
  16 + <a class="btn btn-primary btn-more dropdown-toggle btn-disabled disabled" data-toggle="dropdown"><i class="fa fa-cog"></i> {:__('More')}</a>
  17 + <ul class="dropdown-menu text-left" role="menu">
  18 + <li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=normal"><i class="fa fa-eye"></i> {:__('Set to normal')}</a></li>
  19 + <li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=hidden"><i class="fa fa-eye-slash"></i> {:__('Set to hidden')}</a></li>
  20 + </ul>
  21 + </div>
  22 +
  23 +
  24 + </div>
  25 + <table id="table" class="table table-striped table-bordered table-hover table-nowrap"
  26 + data-operate-edit="{:$auth->check('contype/edit')}"
  27 + data-operate-del="{:$auth->check('contype/del')}"
  28 + width="100%">
  29 + </table>
  30 + </div>
  31 + </div>
  32 +
  33 + </div>
  34 + </div>
  35 +</div>
  1 +<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
  2 +
  3 + <div class="form-group">
  4 + <label class="control-label col-xs-12 col-sm-2">{:__('Thumbnail')}:</label>
  5 + <div class="col-xs-12 col-sm-8">
  6 + <div class="input-group">
  7 + <input id="c-thumbnail" data-rule="required" class="form-control" size="35" name="row[thumbnail]" type="text" placeholder="请选择图片">
  8 + <div class="input-group-addon no-border no-padding">
  9 + <span><button type="button" id="plupload-thumbnail" class="btn btn-danger plupload" data-input-id="c-thumbnail" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp" data-multiple="false" data-preview-id="p-thumbnail"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
  10 + <span><button type="button" id="fachoose-thumbnail" class="btn btn-primary fachoose" data-input-id="c-thumbnail" data-mimetype="image/*" data-multiple="false"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
  11 + </div>
  12 + <span class="msg-box n-right"></span>
  13 + </div>
  14 + <ul class="row list-inline plupload-preview" id="p-thumbnail"></ul>
  15 + </div>
  16 + </div>
  17 + <div class="form-group layer-footer">
  18 + <label class="control-label col-xs-12 col-sm-2"></label>
  19 + <div class="col-xs-12 col-sm-8">
  20 + <button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
  21 + <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
  22 + </div>
  23 + </div>
  24 +</form>
  1 +<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
  2 +
  3 + <div class="form-group">
  4 + <label class="control-label col-xs-12 col-sm-2">{:__('Thumbnail')}:</label>
  5 + <div class="col-xs-12 col-sm-8">
  6 + <div class="input-group">
  7 + <input id="c-thumbnail" data-rule="required" class="form-control" size="35" name="row[thumbnail]" type="text" value="{$row.thumbnail}" placeholder="请选择图片">
  8 + <div class="input-group-addon no-border no-padding">
  9 + <span><button type="button" id="plupload-thumbnail" class="btn btn-danger plupload" data-input-id="c-thumbnail" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp" data-multiple="false" data-preview-id="p-thumbnail"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
  10 + <span><button type="button" id="fachoose-thumbnail" class="btn btn-primary fachoose" data-input-id="c-thumbnail" data-mimetype="image/*" data-multiple="false"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
  11 + </div>
  12 + <span class="msg-box n-right"></span>
  13 + </div>
  14 + <ul class="row list-inline plupload-preview" id="p-thumbnail"></ul>
  15 + </div>
  16 + </div>
  17 + <div class="form-group layer-footer">
  18 + <label class="control-label col-xs-12 col-sm-2"></label>
  19 + <div class="col-xs-12 col-sm-8">
  20 + <button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
  21 + <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
  22 + </div>
  23 + </div>
  24 +</form>
  1 +<div class="panel panel-default panel-intro">
  2 + {:build_heading()}
  3 +
  4 + <div class="panel-body">
  5 + <div id="myTabContent" class="tab-content">
  6 + <div class="tab-pane fade active in" id="one">
  7 + <div class="widget-body no-padding">
  8 + <div id="toolbar" class="toolbar">
  9 + <a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
  10 + <a href="javascript:;" class="btn btn-success btn-add {:$auth->check('pic/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>
  11 + <a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('pic/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>
  12 + <a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('pic/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
  13 + <a href="javascript:;" class="btn btn-danger btn-import {:$auth->check('pic/import')?'':'hide'}" title="{:__('Import')}" id="btn-import-file" data-url="ajax/upload" data-mimetype="csv,xls,xlsx" data-multiple="false"><i class="fa fa-upload"></i> {:__('Import')}</a>
  14 +
  15 + <div class="dropdown btn-group {:$auth->check('pic/multi')?'':'hide'}">
  16 + <a class="btn btn-primary btn-more dropdown-toggle btn-disabled disabled" data-toggle="dropdown"><i class="fa fa-cog"></i> {:__('More')}</a>
  17 + <ul class="dropdown-menu text-left" role="menu">
  18 + <li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=normal"><i class="fa fa-eye"></i> {:__('Set to normal')}</a></li>
  19 + <li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=hidden"><i class="fa fa-eye-slash"></i> {:__('Set to hidden')}</a></li>
  20 + </ul>
  21 + </div>
  22 +
  23 +
  24 + </div>
  25 + <table id="table" class="table table-striped table-bordered table-hover table-nowrap"
  26 + data-operate-edit="{:$auth->check('pic/edit')}"
  27 + data-operate-del="{:$auth->check('pic/del')}"
  28 + width="100%">
  29 + </table>
  30 + </div>
  31 + </div>
  32 +
  33 + </div>
  34 + </div>
  35 +</div>
@@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
3 namespace app\api\controller; 3 namespace app\api\controller;
4 4
5 use app\common\controller\Api; 5 use app\common\controller\Api;
  6 +use think\Db;
6 7
7 /** 8 /**
8 * 首页接口 9 * 首页接口
@@ -13,12 +14,73 @@ class Index extends Api @@ -13,12 +14,73 @@ class Index extends Api
13 protected $noNeedRight = ['*']; 14 protected $noNeedRight = ['*'];
14 15
15 /** 16 /**
16 - * 首页 17 + * @ApiTitle (首页轮播图列表)
  18 + * @ApiSummary (首页轮播图列表)
  19 + * @ApiMethod (POST)
  20 + * @ApiRoute (/api/index/pic)
17 * 21 *
  22 + * @ApiReturn({
  23 + "code": 1,
  24 + "msg": "成功",
  25 + "time": "1571492001",
  26 + "data": {
  27 + "id": //图片id,
  28 + "thumbnail": //图片,
  29 + "createtime" ://创建时间
  30 + }
  31 + })
18 */ 32 */
19 - public function index() 33 + public function pic()
20 { 34 {
21 - $user_id = $this->getUserId();  
22 - $this->success('请求成功'); 35 + $domain_name = $this->request->domain();//域名
  36 + $data = Db::name('pic')
  37 + ->field('id,thumbnail,createtime')
  38 + ->order('id desc')
  39 + ->limit(5)
  40 + ->select();
  41 + foreach ($data as &$v){
  42 + $v['createtime'] = date('Y-m-d H:i:s',$v['createtime']);
  43 + $v['thumbnail'] = $domain_name.$v['thumbnail'];
  44 + }
  45 + $this->success('请求成功',$data);
  46 + }
  47 +
  48 + /**
  49 + * @ApiTitle (首页咨询分类列表)
  50 + * @ApiSummary (首页咨询分类列表)
  51 + * @ApiMethod (POST)
  52 + * @ApiRoute (/api/index/typeList)
  53 + *
  54 + * @ApiParams (name="type", type="int", required=false, description="类型(如果为空或者为1是经营管理 2是职业发展)")
  55 + *
  56 + * @ApiReturn({
  57 + "code": 1,
  58 + "msg": "成功",
  59 + "time": "1571492001",
  60 + "data": {
  61 + "id": //id,
  62 + "title"://标题,
  63 + }
  64 + })
  65 + */
  66 + public function typeList(){
  67 + $type = $this->request->param('type');
  68 + if(empty($type) || $type == 1){
  69 + $data = Db::name('contype')
  70 + ->field('updatetime,createtime,type',true)
  71 + ->where('type',1)
  72 + ->order('id desc')
  73 + ->select();
  74 + $this->success('success',$data);
  75 + }elseif($type == 2){
  76 + $data = Db::name('contype')
  77 + ->field('updatetime,createtime,type',true)
  78 + ->where('type',2)
  79 + ->order('id desc')
  80 + ->select();
  81 + $this->success('success',$data);
  82 + }else{
  83 + $this->error('类型错误');
  84 + }
23 } 85 }
24 } 86 }
@@ -152,20 +152,21 @@ @@ -152,20 +152,21 @@
152 </div> 152 </div>
153 <a href="#首页接口" class="list-group-item" data-toggle="collapse" data-parent="#sidebar">首页接口 <i class="fa fa-caret-down"></i></a> 153 <a href="#首页接口" class="list-group-item" data-toggle="collapse" data-parent="#sidebar">首页接口 <i class="fa fa-caret-down"></i></a>
154 <div class="child collapse" id="首页接口"> 154 <div class="child collapse" id="首页接口">
155 - <a href="javascript:;" data-id="5" class="list-group-item">首页</a> 155 + <a href="javascript:;" data-id="5" class="list-group-item">首页轮播图列表</a>
  156 + <a href="javascript:;" data-id="6" class="list-group-item">首页咨询分类列表</a>
156 </div> 157 </div>
157 <a href="#手机短信接口" class="list-group-item" data-toggle="collapse" data-parent="#sidebar">手机短信接口 <i class="fa fa-caret-down"></i></a> 158 <a href="#手机短信接口" class="list-group-item" data-toggle="collapse" data-parent="#sidebar">手机短信接口 <i class="fa fa-caret-down"></i></a>
158 <div class="child collapse" id="手机短信接口"> 159 <div class="child collapse" id="手机短信接口">
159 - <a href="javascript:;" data-id="6" class="list-group-item">发送验证码</a>  
160 - <a href="javascript:;" data-id="7" class="list-group-item">检测验证码</a> 160 + <a href="javascript:;" data-id="7" class="list-group-item">发送验证码</a>
  161 + <a href="javascript:;" data-id="8" class="list-group-item">检测验证码</a>
161 </div> 162 </div>
162 <a href="#登录接口" class="list-group-item" data-toggle="collapse" data-parent="#sidebar">登录接口 <i class="fa fa-caret-down"></i></a> 163 <a href="#登录接口" class="list-group-item" data-toggle="collapse" data-parent="#sidebar">登录接口 <i class="fa fa-caret-down"></i></a>
163 <div class="child collapse" id="登录接口"> 164 <div class="child collapse" id="登录接口">
164 - <a href="javascript:;" data-id="8" class="list-group-item">获取sessionKey和openid</a>  
165 - <a href="javascript:;" data-id="9" class="list-group-item"></a>  
166 - <a href="javascript:;" data-id="10" class="list-group-item">小程序登录注册</a>  
167 - <a href="javascript:;" data-id="11" class="list-group-item">通过code获取token</a>  
168 - <a href="javascript:;" data-id="12" class="list-group-item"></a> 165 + <a href="javascript:;" data-id="9" class="list-group-item">获取sessionKey和openid</a>
  166 + <a href="javascript:;" data-id="10" class="list-group-item"></a>
  167 + <a href="javascript:;" data-id="11" class="list-group-item">小程序登录注册</a>
  168 + <a href="javascript:;" data-id="12" class="list-group-item">通过code获取token</a>
  169 + <a href="javascript:;" data-id="13" class="list-group-item"></a>
169 </div> 170 </div>
170 </div> 171 </div>
171 </div> 172 </div>
@@ -796,8 +797,8 @@ @@ -796,8 +797,8 @@
796 <div class="panel panel-default"> 797 <div class="panel panel-default">
797 <div class="panel-heading" id="heading-5"> 798 <div class="panel-heading" id="heading-5">
798 <h4 class="panel-title"> 799 <h4 class="panel-title">
799 - <span class="label label-success">GET</span>  
800 - <a data-toggle="collapse" data-parent="#accordion5" href="#collapseOne5"> 首页 <span class="text-muted">/api/index/index</span></a> 800 + <span class="label label-primary">POST</span>
  801 + <a data-toggle="collapse" data-parent="#accordion5" href="#collapseOne5"> 首页轮播图列表 <span class="text-muted">/api/index/pic</span></a>
801 </h4> 802 </h4>
802 </div> 803 </div>
803 <div id="collapseOne5" class="panel-collapse collapse"> 804 <div id="collapseOne5" class="panel-collapse collapse">
@@ -815,7 +816,7 @@ @@ -815,7 +816,7 @@
815 816
816 <div class="tab-pane active" id="info5"> 817 <div class="tab-pane active" id="info5">
817 <div class="well"> 818 <div class="well">
818 - 首页 </div> 819 + 首页轮播图列表 </div>
819 <div class="panel panel-default"> 820 <div class="panel panel-default">
820 <div class="panel-heading"><strong>Headers</strong></div> 821 <div class="panel-heading"><strong>Headers</strong></div>
821 <div class="panel-body"> 822 <div class="panel-body">
@@ -841,7 +842,7 @@ @@ -841,7 +842,7 @@
841 <div class="panel panel-default"> 842 <div class="panel panel-default">
842 <div class="panel-heading"><strong>参数</strong></div> 843 <div class="panel-heading"><strong>参数</strong></div>
843 <div class="panel-body"> 844 <div class="panel-body">
844 - <form enctype="application/x-www-form-urlencoded" role="form" action="/api/index/index" method="get" name="form5" id="form5"> 845 + <form enctype="application/x-www-form-urlencoded" role="form" action="/api/index/pic" method="POST" name="form5" id="form5">
845 <div class="form-group"> 846 <div class="form-group">
846 847
847 </div> 848 </div>
@@ -876,7 +877,16 @@ @@ -876,7 +877,16 @@
876 <div class="tab-pane" id="sample5"> 877 <div class="tab-pane" id="sample5">
877 <div class="row"> 878 <div class="row">
878 <div class="col-md-12"> 879 <div class="col-md-12">
879 - <pre id="sample_response5"></pre> 880 + <pre id="sample_response5">{
  881 + "code": 1,
  882 + "msg": "成功",
  883 + "time": "1571492001",
  884 + "data": {
  885 + "id": //图片id,
  886 + "thumbnail": //图片,
  887 + "createtime" ://创建时间
  888 + }
  889 + }</pre>
880 </div> 890 </div>
881 </div> 891 </div>
882 </div><!-- #sample --> 892 </div><!-- #sample -->
@@ -885,13 +895,11 @@ @@ -885,13 +895,11 @@
885 </div> 895 </div>
886 </div> 896 </div>
887 </div> 897 </div>
888 - <h2>手机短信接口</h2>  
889 - <hr>  
890 <div class="panel panel-default"> 898 <div class="panel panel-default">
891 <div class="panel-heading" id="heading-6"> 899 <div class="panel-heading" id="heading-6">
892 <h4 class="panel-title"> 900 <h4 class="panel-title">
893 - <span class="label label-success">GET</span>  
894 - <a data-toggle="collapse" data-parent="#accordion6" href="#collapseOne6"> 发送验证码 <span class="text-muted">/api/sms/send</span></a> 901 + <span class="label label-primary">POST</span>
  902 + <a data-toggle="collapse" data-parent="#accordion6" href="#collapseOne6"> 首页咨询分类列表 <span class="text-muted">/api/index/typeList</span></a>
895 </h4> 903 </h4>
896 </div> 904 </div>
897 <div id="collapseOne6" class="panel-collapse collapse"> 905 <div id="collapseOne6" class="panel-collapse collapse">
@@ -909,7 +917,7 @@ @@ -909,7 +917,7 @@
909 917
910 <div class="tab-pane active" id="info6"> 918 <div class="tab-pane active" id="info6">
911 <div class="well"> 919 <div class="well">
912 - 发送验证码 </div> 920 + 首页咨询分类列表 </div>
913 <div class="panel panel-default"> 921 <div class="panel panel-default">
914 <div class="panel-heading"><strong>Headers</strong></div> 922 <div class="panel-heading"><strong>Headers</strong></div>
915 <div class="panel-body"> 923 <div class="panel-body">
@@ -930,16 +938,10 @@ @@ -930,16 +938,10 @@
930 </thead> 938 </thead>
931 <tbody> 939 <tbody>
932 <tr> 940 <tr>
933 - <td>mobile</td>  
934 - <td>string</td>  
935 - <td></td>  
936 - <td>手机号</td>  
937 - </tr>  
938 - <tr>  
939 - <td>event</td>  
940 - <td>string</td>  
941 - <td></td>  
942 - <td>事件名称</td> 941 + <td>type</td>
  942 + <td>int</td>
  943 + <td></td>
  944 + <td>类型(如果为空或者为1是经营管理 2是职业发展</td>
943 </tr> 945 </tr>
944 </tbody> 946 </tbody>
945 </table> 947 </table>
@@ -958,14 +960,10 @@ @@ -958,14 +960,10 @@
958 <div class="panel panel-default"> 960 <div class="panel panel-default">
959 <div class="panel-heading"><strong>参数</strong></div> 961 <div class="panel-heading"><strong>参数</strong></div>
960 <div class="panel-body"> 962 <div class="panel-body">
961 - <form enctype="application/x-www-form-urlencoded" role="form" action="/api/sms/send" method="get" name="form6" id="form6"> 963 + <form enctype="application/x-www-form-urlencoded" role="form" action="/api/index/typeList" method="POST" name="form6" id="form6">
962 <div class="form-group"> 964 <div class="form-group">
963 - <label class="control-label" for="mobile">mobile</label>  
964 - <input type="string" class="form-control input-sm" id="mobile" required placeholder="手机号" name="mobile">  
965 - </div>  
966 - <div class="form-group">  
967 - <label class="control-label" for="event">event</label>  
968 - <input type="string" class="form-control input-sm" id="event" required placeholder="事件名称" name="event"> 965 + <label class="control-label" for="type">type</label>
  966 + <input type="int" class="form-control input-sm" id="type" placeholder="类型(如果为空或者为1是经营管理 2是职业发展" name="type">
969 </div> 967 </div>
970 <div class="form-group"> 968 <div class="form-group">
971 <button type="submit" class="btn btn-success send" rel="6">提交</button> 969 <button type="submit" class="btn btn-success send" rel="6">提交</button>
@@ -998,7 +996,14 @@ @@ -998,7 +996,14 @@
998 <div class="tab-pane" id="sample6"> 996 <div class="tab-pane" id="sample6">
999 <div class="row"> 997 <div class="row">
1000 <div class="col-md-12"> 998 <div class="col-md-12">
1001 - <pre id="sample_response6"></pre> 999 + <pre id="sample_response6">{
  1000 + "code": 1,
  1001 + "msg": "成功",
  1002 + "time": "1571492001",
  1003 + "data": {
  1004 + "id": //id,
  1005 + "title"://标题,
  1006 + "type" ://类型(1经营管理2职业发展</pre>
1002 </div> 1007 </div>
1003 </div> 1008 </div>
1004 </div><!-- #sample --> 1009 </div><!-- #sample -->
@@ -1007,11 +1012,13 @@ @@ -1007,11 +1012,13 @@
1007 </div> 1012 </div>
1008 </div> 1013 </div>
1009 </div> 1014 </div>
  1015 + <h2>手机短信接口</h2>
  1016 + <hr>
1010 <div class="panel panel-default"> 1017 <div class="panel panel-default">
1011 <div class="panel-heading" id="heading-7"> 1018 <div class="panel-heading" id="heading-7">
1012 <h4 class="panel-title"> 1019 <h4 class="panel-title">
1013 <span class="label label-success">GET</span> 1020 <span class="label label-success">GET</span>
1014 - <a data-toggle="collapse" data-parent="#accordion7" href="#collapseOne7"> 检测验证码 <span class="text-muted">/api/sms/check</span></a> 1021 + <a data-toggle="collapse" data-parent="#accordion7" href="#collapseOne7"> 发送验证码 <span class="text-muted">/api/sms/send</span></a>
1015 </h4> 1022 </h4>
1016 </div> 1023 </div>
1017 <div id="collapseOne7" class="panel-collapse collapse"> 1024 <div id="collapseOne7" class="panel-collapse collapse">
@@ -1029,7 +1036,7 @@ @@ -1029,7 +1036,7 @@
1029 1036
1030 <div class="tab-pane active" id="info7"> 1037 <div class="tab-pane active" id="info7">
1031 <div class="well"> 1038 <div class="well">
1032 - 检测验证码 </div> 1039 + 发送验证码 </div>
1033 <div class="panel panel-default"> 1040 <div class="panel panel-default">
1034 <div class="panel-heading"><strong>Headers</strong></div> 1041 <div class="panel-heading"><strong>Headers</strong></div>
1035 <div class="panel-body"> 1042 <div class="panel-body">
@@ -1061,12 +1068,6 @@ @@ -1061,12 +1068,6 @@
1061 <td></td> 1068 <td></td>
1062 <td>事件名称</td> 1069 <td>事件名称</td>
1063 </tr> 1070 </tr>
1064 - <tr>  
1065 - <td>captcha</td>  
1066 - <td>string</td>  
1067 - <td></td>  
1068 - <td>验证码</td>  
1069 - </tr>  
1070 </tbody> 1071 </tbody>
1071 </table> 1072 </table>
1072 </div> 1073 </div>
@@ -1084,7 +1085,7 @@ @@ -1084,7 +1085,7 @@
1084 <div class="panel panel-default"> 1085 <div class="panel panel-default">
1085 <div class="panel-heading"><strong>参数</strong></div> 1086 <div class="panel-heading"><strong>参数</strong></div>
1086 <div class="panel-body"> 1087 <div class="panel-body">
1087 - <form enctype="application/x-www-form-urlencoded" role="form" action="/api/sms/check" method="get" name="form7" id="form7"> 1088 + <form enctype="application/x-www-form-urlencoded" role="form" action="/api/sms/send" method="get" name="form7" id="form7">
1088 <div class="form-group"> 1089 <div class="form-group">
1089 <label class="control-label" for="mobile">mobile</label> 1090 <label class="control-label" for="mobile">mobile</label>
1090 <input type="string" class="form-control input-sm" id="mobile" required placeholder="手机号" name="mobile"> 1091 <input type="string" class="form-control input-sm" id="mobile" required placeholder="手机号" name="mobile">
@@ -1094,10 +1095,6 @@ @@ -1094,10 +1095,6 @@
1094 <input type="string" class="form-control input-sm" id="event" required placeholder="事件名称" name="event"> 1095 <input type="string" class="form-control input-sm" id="event" required placeholder="事件名称" name="event">
1095 </div> 1096 </div>
1096 <div class="form-group"> 1097 <div class="form-group">
1097 - <label class="control-label" for="captcha">captcha</label>  
1098 - <input type="string" class="form-control input-sm" id="captcha" required placeholder="验证码" name="captcha">  
1099 - </div>  
1100 - <div class="form-group">  
1101 <button type="submit" class="btn btn-success send" rel="7">提交</button> 1098 <button type="submit" class="btn btn-success send" rel="7">提交</button>
1102 <button type="reset" class="btn btn-info" rel="7">重置</button> 1099 <button type="reset" class="btn btn-info" rel="7">重置</button>
1103 </div> 1100 </div>
@@ -1137,13 +1134,11 @@ @@ -1137,13 +1134,11 @@
1137 </div> 1134 </div>
1138 </div> 1135 </div>
1139 </div> 1136 </div>
1140 - <h2>登录接口</h2>  
1141 - <hr>  
1142 <div class="panel panel-default"> 1137 <div class="panel panel-default">
1143 <div class="panel-heading" id="heading-8"> 1138 <div class="panel-heading" id="heading-8">
1144 <h4 class="panel-title"> 1139 <h4 class="panel-title">
1145 - <span class="label label-primary">POST</span>  
1146 - <a data-toggle="collapse" data-parent="#accordion8" href="#collapseOne8"> 获取sessionKey和openid <span class="text-muted">/api/user/getSessionKey</span></a> 1140 + <span class="label label-success">GET</span>
  1141 + <a data-toggle="collapse" data-parent="#accordion8" href="#collapseOne8"> 检测验证码 <span class="text-muted">/api/sms/check</span></a>
1147 </h4> 1142 </h4>
1148 </div> 1143 </div>
1149 <div id="collapseOne8" class="panel-collapse collapse"> 1144 <div id="collapseOne8" class="panel-collapse collapse">
@@ -1161,7 +1156,7 @@ @@ -1161,7 +1156,7 @@
1161 1156
1162 <div class="tab-pane active" id="info8"> 1157 <div class="tab-pane active" id="info8">
1163 <div class="well"> 1158 <div class="well">
1164 - 获取sessionKey和openid </div> 1159 + 检测验证码 </div>
1165 <div class="panel panel-default"> 1160 <div class="panel panel-default">
1166 <div class="panel-heading"><strong>Headers</strong></div> 1161 <div class="panel-heading"><strong>Headers</strong></div>
1167 <div class="panel-body"> 1162 <div class="panel-body">
@@ -1182,10 +1177,22 @@ @@ -1182,10 +1177,22 @@
1182 </thead> 1177 </thead>
1183 <tbody> 1178 <tbody>
1184 <tr> 1179 <tr>
1185 - <td>code</td> 1180 + <td>mobile</td>
1186 <td>string</td> 1181 <td>string</td>
1187 <td></td> 1182 <td></td>
1188 - <td>小程序code</td> 1183 + <td>手机号</td>
  1184 + </tr>
  1185 + <tr>
  1186 + <td>event</td>
  1187 + <td>string</td>
  1188 + <td></td>
  1189 + <td>事件名称</td>
  1190 + </tr>
  1191 + <tr>
  1192 + <td>captcha</td>
  1193 + <td>string</td>
  1194 + <td></td>
  1195 + <td>验证码</td>
1189 </tr> 1196 </tr>
1190 </tbody> 1197 </tbody>
1191 </table> 1198 </table>
@@ -1204,10 +1211,18 @@ @@ -1204,10 +1211,18 @@
1204 <div class="panel panel-default"> 1211 <div class="panel panel-default">
1205 <div class="panel-heading"><strong>参数</strong></div> 1212 <div class="panel-heading"><strong>参数</strong></div>
1206 <div class="panel-body"> 1213 <div class="panel-body">
1207 - <form enctype="application/x-www-form-urlencoded" role="form" action="/api/user/getSessionKey" method="POST" name="form8" id="form8"> 1214 + <form enctype="application/x-www-form-urlencoded" role="form" action="/api/sms/check" method="get" name="form8" id="form8">
1208 <div class="form-group"> 1215 <div class="form-group">
1209 - <label class="control-label" for="code">code</label>  
1210 - <input type="string" class="form-control input-sm" id="code" required placeholder="小程序code" name="code"> 1216 + <label class="control-label" for="mobile">mobile</label>
  1217 + <input type="string" class="form-control input-sm" id="mobile" required placeholder="手机号" name="mobile">
  1218 + </div>
  1219 + <div class="form-group">
  1220 + <label class="control-label" for="event">event</label>
  1221 + <input type="string" class="form-control input-sm" id="event" required placeholder="事件名称" name="event">
  1222 + </div>
  1223 + <div class="form-group">
  1224 + <label class="control-label" for="captcha">captcha</label>
  1225 + <input type="string" class="form-control input-sm" id="captcha" required placeholder="验证码" name="captcha">
1211 </div> 1226 </div>
1212 <div class="form-group"> 1227 <div class="form-group">
1213 <button type="submit" class="btn btn-success send" rel="8">提交</button> 1228 <button type="submit" class="btn btn-success send" rel="8">提交</button>
@@ -1240,15 +1255,7 @@ @@ -1240,15 +1255,7 @@
1240 <div class="tab-pane" id="sample8"> 1255 <div class="tab-pane" id="sample8">
1241 <div class="row"> 1256 <div class="row">
1242 <div class="col-md-12"> 1257 <div class="col-md-12">
1243 - <pre id="sample_response8">{  
1244 - "code": 1,  
1245 - "msg": "获取成功",  
1246 - "time": "1553839125",  
1247 - "data": {  
1248 - "session_key": "session_key",//token  
1249 - "openid": "openid",//openid  
1250 - },  
1251 - }</pre> 1258 + <pre id="sample_response8"></pre>
1252 </div> 1259 </div>
1253 </div> 1260 </div>
1254 </div><!-- #sample --> 1261 </div><!-- #sample -->
@@ -1257,11 +1264,13 @@ @@ -1257,11 +1264,13 @@
1257 </div> 1264 </div>
1258 </div> 1265 </div>
1259 </div> 1266 </div>
  1267 + <h2>登录接口</h2>
  1268 + <hr>
1260 <div class="panel panel-default"> 1269 <div class="panel panel-default">
1261 <div class="panel-heading" id="heading-9"> 1270 <div class="panel-heading" id="heading-9">
1262 <h4 class="panel-title"> 1271 <h4 class="panel-title">
1263 - <span class="label label-success">GET</span>  
1264 - <a data-toggle="collapse" data-parent="#accordion9" href="#collapseOne9"> <span class="text-muted">/api/user/http_get</span></a> 1272 + <span class="label label-primary">POST</span>
  1273 + <a data-toggle="collapse" data-parent="#accordion9" href="#collapseOne9"> 获取sessionKey和openid <span class="text-muted">/api/user/getSessionKey</span></a>
1265 </h4> 1274 </h4>
1266 </div> 1275 </div>
1267 <div id="collapseOne9" class="panel-collapse collapse"> 1276 <div id="collapseOne9" class="panel-collapse collapse">
@@ -1279,7 +1288,7 @@ @@ -1279,7 +1288,7 @@
1279 1288
1280 <div class="tab-pane active" id="info9"> 1289 <div class="tab-pane active" id="info9">
1281 <div class="well"> 1290 <div class="well">
1282 - </div> 1291 + 获取sessionKey和openid </div>
1283 <div class="panel panel-default"> 1292 <div class="panel panel-default">
1284 <div class="panel-heading"><strong>Headers</strong></div> 1293 <div class="panel-heading"><strong>Headers</strong></div>
1285 <div class="panel-body"> 1294 <div class="panel-body">
@@ -1289,7 +1298,24 @@ @@ -1289,7 +1298,24 @@
1289 <div class="panel panel-default"> 1298 <div class="panel panel-default">
1290 <div class="panel-heading"><strong>参数</strong></div> 1299 <div class="panel-heading"><strong>参数</strong></div>
1291 <div class="panel-body"> 1300 <div class="panel-body">
1292 - 1301 + <table class="table table-hover">
  1302 + <thead>
  1303 + <tr>
  1304 + <th>名称</th>
  1305 + <th>类型</th>
  1306 + <th>必选</th>
  1307 + <th>描述</th>
  1308 + </tr>
  1309 + </thead>
  1310 + <tbody>
  1311 + <tr>
  1312 + <td>code</td>
  1313 + <td>string</td>
  1314 + <td></td>
  1315 + <td>小程序code</td>
  1316 + </tr>
  1317 + </tbody>
  1318 + </table>
1293 </div> 1319 </div>
1294 </div> 1320 </div>
1295 <div class="panel panel-default"> 1321 <div class="panel panel-default">
@@ -1305,9 +1331,10 @@ @@ -1305,9 +1331,10 @@
1305 <div class="panel panel-default"> 1331 <div class="panel panel-default">
1306 <div class="panel-heading"><strong>参数</strong></div> 1332 <div class="panel-heading"><strong>参数</strong></div>
1307 <div class="panel-body"> 1333 <div class="panel-body">
1308 - <form enctype="application/x-www-form-urlencoded" role="form" action="/api/user/http_get" method="get" name="form9" id="form9"> 1334 + <form enctype="application/x-www-form-urlencoded" role="form" action="/api/user/getSessionKey" method="POST" name="form9" id="form9">
1309 <div class="form-group"> 1335 <div class="form-group">
1310 - 1336 + <label class="control-label" for="code">code</label>
  1337 + <input type="string" class="form-control input-sm" id="code" required placeholder="小程序code" name="code">
1311 </div> 1338 </div>
1312 <div class="form-group"> 1339 <div class="form-group">
1313 <button type="submit" class="btn btn-success send" rel="9">提交</button> 1340 <button type="submit" class="btn btn-success send" rel="9">提交</button>
@@ -1340,7 +1367,15 @@ @@ -1340,7 +1367,15 @@
1340 <div class="tab-pane" id="sample9"> 1367 <div class="tab-pane" id="sample9">
1341 <div class="row"> 1368 <div class="row">
1342 <div class="col-md-12"> 1369 <div class="col-md-12">
1343 - <pre id="sample_response9"></pre> 1370 + <pre id="sample_response9">{
  1371 + "code": 1,
  1372 + "msg": "获取成功",
  1373 + "time": "1553839125",
  1374 + "data": {
  1375 + "session_key": "session_key",//token
  1376 + "openid": "openid",//openid
  1377 + },
  1378 + }</pre>
1344 </div> 1379 </div>
1345 </div> 1380 </div>
1346 </div><!-- #sample --> 1381 </div><!-- #sample -->
@@ -1352,8 +1387,8 @@ @@ -1352,8 +1387,8 @@
1352 <div class="panel panel-default"> 1387 <div class="panel panel-default">
1353 <div class="panel-heading" id="heading-10"> 1388 <div class="panel-heading" id="heading-10">
1354 <h4 class="panel-title"> 1389 <h4 class="panel-title">
1355 - <span class="label label-primary">POST</span>  
1356 - <a data-toggle="collapse" data-parent="#accordion10" href="#collapseOne10"> 小程序登录注册 <span class="text-muted">/api/user/login</span></a> 1390 + <span class="label label-success">GET</span>
  1391 + <a data-toggle="collapse" data-parent="#accordion10" href="#collapseOne10"> <span class="text-muted">/api/user/http_get</span></a>
1357 </h4> 1392 </h4>
1358 </div> 1393 </div>
1359 <div id="collapseOne10" class="panel-collapse collapse"> 1394 <div id="collapseOne10" class="panel-collapse collapse">
@@ -1371,6 +1406,98 @@ @@ -1371,6 +1406,98 @@
1371 1406
1372 <div class="tab-pane active" id="info10"> 1407 <div class="tab-pane active" id="info10">
1373 <div class="well"> 1408 <div class="well">
  1409 + </div>
  1410 + <div class="panel panel-default">
  1411 + <div class="panel-heading"><strong>Headers</strong></div>
  1412 + <div class="panel-body">
  1413 +
  1414 + </div>
  1415 + </div>
  1416 + <div class="panel panel-default">
  1417 + <div class="panel-heading"><strong>参数</strong></div>
  1418 + <div class="panel-body">
  1419 +
  1420 + </div>
  1421 + </div>
  1422 + <div class="panel panel-default">
  1423 + <div class="panel-heading"><strong>正文</strong></div>
  1424 + <div class="panel-body">
  1425 +</div>
  1426 + </div>
  1427 + </div><!-- #info -->
  1428 +
  1429 + <div class="tab-pane" id="sandbox10">
  1430 + <div class="row">
  1431 + <div class="col-md-12">
  1432 + <div class="panel panel-default">
  1433 + <div class="panel-heading"><strong>参数</strong></div>
  1434 + <div class="panel-body">
  1435 + <form enctype="application/x-www-form-urlencoded" role="form" action="/api/user/http_get" method="get" name="form10" id="form10">
  1436 + <div class="form-group">
  1437 +
  1438 + </div>
  1439 + <div class="form-group">
  1440 + <button type="submit" class="btn btn-success send" rel="10">提交</button>
  1441 + <button type="reset" class="btn btn-info" rel="10">重置</button>
  1442 + </div>
  1443 + </form>
  1444 + </div>
  1445 + </div>
  1446 + <div class="panel panel-default">
  1447 + <div class="panel-heading"><strong>响应输出</strong></div>
  1448 + <div class="panel-body">
  1449 + <div class="row">
  1450 + <div class="col-md-12" style="overflow-x:auto">
  1451 + <pre id="response_headers10"></pre>
  1452 + <pre id="response10"></pre>
  1453 + </div>
  1454 + </div>
  1455 + </div>
  1456 + </div>
  1457 + <div class="panel panel-default">
  1458 + <div class="panel-heading"><strong>返回参数</strong></div>
  1459 + <div class="panel-body">
  1460 +
  1461 + </div>
  1462 + </div>
  1463 + </div>
  1464 + </div>
  1465 + </div><!-- #sandbox -->
  1466 +
  1467 + <div class="tab-pane" id="sample10">
  1468 + <div class="row">
  1469 + <div class="col-md-12">
  1470 + <pre id="sample_response10"></pre>
  1471 + </div>
  1472 + </div>
  1473 + </div><!-- #sample -->
  1474 +
  1475 + </div><!-- .tab-content -->
  1476 + </div>
  1477 + </div>
  1478 + </div>
  1479 + <div class="panel panel-default">
  1480 + <div class="panel-heading" id="heading-11">
  1481 + <h4 class="panel-title">
  1482 + <span class="label label-primary">POST</span>
  1483 + <a data-toggle="collapse" data-parent="#accordion11" href="#collapseOne11"> 小程序登录注册 <span class="text-muted">/api/user/login</span></a>
  1484 + </h4>
  1485 + </div>
  1486 + <div id="collapseOne11" class="panel-collapse collapse">
  1487 + <div class="panel-body">
  1488 +
  1489 + <!-- Nav tabs -->
  1490 + <ul class="nav nav-tabs" id="doctab11">
  1491 + <li class="active"><a href="#info11" data-toggle="tab">基础信息</a></li>
  1492 + <li><a href="#sandbox11" data-toggle="tab">在线测试</a></li>
  1493 + <li><a href="#sample11" data-toggle="tab">返回示例</a></li>
  1494 + </ul>
  1495 +
  1496 + <!-- Tab panes -->
  1497 + <div class="tab-content">
  1498 +
  1499 + <div class="tab-pane active" id="info11">
  1500 + <div class="well">
1374 小程序登录注册 </div> 1501 小程序登录注册 </div>
1375 <div class="panel panel-default"> 1502 <div class="panel panel-default">
1376 <div class="panel-heading"><strong>Headers</strong></div> 1503 <div class="panel-heading"><strong>Headers</strong></div>
@@ -1426,13 +1553,13 @@ @@ -1426,13 +1553,13 @@
1426 </div> 1553 </div>
1427 </div><!-- #info --> 1554 </div><!-- #info -->
1428 1555
1429 - <div class="tab-pane" id="sandbox10"> 1556 + <div class="tab-pane" id="sandbox11">
1430 <div class="row"> 1557 <div class="row">
1431 <div class="col-md-12"> 1558 <div class="col-md-12">
1432 <div class="panel panel-default"> 1559 <div class="panel panel-default">
1433 <div class="panel-heading"><strong>参数</strong></div> 1560 <div class="panel-heading"><strong>参数</strong></div>
1434 <div class="panel-body"> 1561 <div class="panel-body">
1435 - <form enctype="application/x-www-form-urlencoded" role="form" action="/api/user/login" method="POST" name="form10" id="form10"> 1562 + <form enctype="application/x-www-form-urlencoded" role="form" action="/api/user/login" method="POST" name="form11" id="form11">
1436 <div class="form-group"> 1563 <div class="form-group">
1437 <label class="control-label" for="openid">openid</label> 1564 <label class="control-label" for="openid">openid</label>
1438 <input type="string" class="form-control input-sm" id="openid" required placeholder="openid" name="openid"> 1565 <input type="string" class="form-control input-sm" id="openid" required placeholder="openid" name="openid">
@@ -1450,8 +1577,8 @@ @@ -1450,8 +1577,8 @@
1450 <input type="string" class="form-control input-sm" id="iv" required placeholder="iv" name="iv"> 1577 <input type="string" class="form-control input-sm" id="iv" required placeholder="iv" name="iv">
1451 </div> 1578 </div>
1452 <div class="form-group"> 1579 <div class="form-group">
1453 - <button type="submit" class="btn btn-success send" rel="10">提交</button>  
1454 - <button type="reset" class="btn btn-info" rel="10">重置</button> 1580 + <button type="submit" class="btn btn-success send" rel="11">提交</button>
  1581 + <button type="reset" class="btn btn-info" rel="11">重置</button>
1455 </div> 1582 </div>
1456 </form> 1583 </form>
1457 </div> 1584 </div>
@@ -1461,8 +1588,8 @@ @@ -1461,8 +1588,8 @@
1461 <div class="panel-body"> 1588 <div class="panel-body">
1462 <div class="row"> 1589 <div class="row">
1463 <div class="col-md-12" style="overflow-x:auto"> 1590 <div class="col-md-12" style="overflow-x:auto">
1464 - <pre id="response_headers10"></pre>  
1465 - <pre id="response10"></pre> 1591 + <pre id="response_headers11"></pre>
  1592 + <pre id="response11"></pre>
1466 </div> 1593 </div>
1467 </div> 1594 </div>
1468 </div> 1595 </div>
@@ -1477,10 +1604,10 @@ @@ -1477,10 +1604,10 @@
1477 </div> 1604 </div>
1478 </div><!-- #sandbox --> 1605 </div><!-- #sandbox -->
1479 1606
1480 - <div class="tab-pane" id="sample10"> 1607 + <div class="tab-pane" id="sample11">
1481 <div class="row"> 1608 <div class="row">
1482 <div class="col-md-12"> 1609 <div class="col-md-12">
1483 - <pre id="sample_response10">{ 1610 + <pre id="sample_response11">{
1484 "code": 1, 1611 "code": 1,
1485 "msg": "登陆成功", 1612 "msg": "登陆成功",
1486 "time": "1553839125", 1613 "time": "1553839125",
@@ -1497,26 +1624,26 @@ @@ -1497,26 +1624,26 @@
1497 </div> 1624 </div>
1498 </div> 1625 </div>
1499 <div class="panel panel-default"> 1626 <div class="panel panel-default">
1500 - <div class="panel-heading" id="heading-11"> 1627 + <div class="panel-heading" id="heading-12">
1501 <h4 class="panel-title"> 1628 <h4 class="panel-title">
1502 <span class="label label-primary">POST</span> 1629 <span class="label label-primary">POST</span>
1503 - <a data-toggle="collapse" data-parent="#accordion11" href="#collapseOne11"> 通过code获取token <span class="text-muted">/api/user/getToken</span></a> 1630 + <a data-toggle="collapse" data-parent="#accordion12" href="#collapseOne12"> 通过code获取token <span class="text-muted">/api/user/getToken</span></a>
1504 </h4> 1631 </h4>
1505 </div> 1632 </div>
1506 - <div id="collapseOne11" class="panel-collapse collapse"> 1633 + <div id="collapseOne12" class="panel-collapse collapse">
1507 <div class="panel-body"> 1634 <div class="panel-body">
1508 1635
1509 <!-- Nav tabs --> 1636 <!-- Nav tabs -->
1510 - <ul class="nav nav-tabs" id="doctab11">  
1511 - <li class="active"><a href="#info11" data-toggle="tab">基础信息</a></li>  
1512 - <li><a href="#sandbox11" data-toggle="tab">在线测试</a></li>  
1513 - <li><a href="#sample11" data-toggle="tab">返回示例</a></li> 1637 + <ul class="nav nav-tabs" id="doctab12">
  1638 + <li class="active"><a href="#info12" data-toggle="tab">基础信息</a></li>
  1639 + <li><a href="#sandbox12" data-toggle="tab">在线测试</a></li>
  1640 + <li><a href="#sample12" data-toggle="tab">返回示例</a></li>
1514 </ul> 1641 </ul>
1515 1642
1516 <!-- Tab panes --> 1643 <!-- Tab panes -->
1517 <div class="tab-content"> 1644 <div class="tab-content">
1518 1645
1519 - <div class="tab-pane active" id="info11"> 1646 + <div class="tab-pane active" id="info12">
1520 <div class="well"> 1647 <div class="well">
1521 通过code获取token </div> 1648 通过code获取token </div>
1522 <div class="panel panel-default"> 1649 <div class="panel panel-default">
@@ -1555,20 +1682,20 @@ @@ -1555,20 +1682,20 @@
1555 </div> 1682 </div>
1556 </div><!-- #info --> 1683 </div><!-- #info -->
1557 1684
1558 - <div class="tab-pane" id="sandbox11"> 1685 + <div class="tab-pane" id="sandbox12">
1559 <div class="row"> 1686 <div class="row">
1560 <div class="col-md-12"> 1687 <div class="col-md-12">
1561 <div class="panel panel-default"> 1688 <div class="panel panel-default">
1562 <div class="panel-heading"><strong>参数</strong></div> 1689 <div class="panel-heading"><strong>参数</strong></div>
1563 <div class="panel-body"> 1690 <div class="panel-body">
1564 - <form enctype="application/x-www-form-urlencoded" role="form" action="/api/user/getToken" method="POST" name="form11" id="form11"> 1691 + <form enctype="application/x-www-form-urlencoded" role="form" action="/api/user/getToken" method="POST" name="form12" id="form12">
1565 <div class="form-group"> 1692 <div class="form-group">
1566 <label class="control-label" for="code">code</label> 1693 <label class="control-label" for="code">code</label>
1567 <input type="string" class="form-control input-sm" id="code" required placeholder="code" name="code"> 1694 <input type="string" class="form-control input-sm" id="code" required placeholder="code" name="code">
1568 </div> 1695 </div>
1569 <div class="form-group"> 1696 <div class="form-group">
1570 - <button type="submit" class="btn btn-success send" rel="11">提交</button>  
1571 - <button type="reset" class="btn btn-info" rel="11">重置</button> 1697 + <button type="submit" class="btn btn-success send" rel="12">提交</button>
  1698 + <button type="reset" class="btn btn-info" rel="12">重置</button>
1572 </div> 1699 </div>
1573 </form> 1700 </form>
1574 </div> 1701 </div>
@@ -1578,8 +1705,8 @@ @@ -1578,8 +1705,8 @@
1578 <div class="panel-body"> 1705 <div class="panel-body">
1579 <div class="row"> 1706 <div class="row">
1580 <div class="col-md-12" style="overflow-x:auto"> 1707 <div class="col-md-12" style="overflow-x:auto">
1581 - <pre id="response_headers11"></pre>  
1582 - <pre id="response11"></pre> 1708 + <pre id="response_headers12"></pre>
  1709 + <pre id="response12"></pre>
1583 </div> 1710 </div>
1584 </div> 1711 </div>
1585 </div> 1712 </div>
@@ -1594,10 +1721,10 @@ @@ -1594,10 +1721,10 @@
1594 </div> 1721 </div>
1595 </div><!-- #sandbox --> 1722 </div><!-- #sandbox -->
1596 1723
1597 - <div class="tab-pane" id="sample11"> 1724 + <div class="tab-pane" id="sample12">
1598 <div class="row"> 1725 <div class="row">
1599 <div class="col-md-12"> 1726 <div class="col-md-12">
1600 - <pre id="sample_response11">{ 1727 + <pre id="sample_response12">{
1601 "code": 1, 1728 "code": 1,
1602 "msg": "SUCCESS", 1729 "msg": "SUCCESS",
1603 "time": "1553839125", 1730 "time": "1553839125",
@@ -1614,26 +1741,26 @@ @@ -1614,26 +1741,26 @@
1614 </div> 1741 </div>
1615 </div> 1742 </div>
1616 <div class="panel panel-default"> 1743 <div class="panel panel-default">
1617 - <div class="panel-heading" id="heading-12"> 1744 + <div class="panel-heading" id="heading-13">
1618 <h4 class="panel-title"> 1745 <h4 class="panel-title">
1619 <span class="label label-success">GET</span> 1746 <span class="label label-success">GET</span>
1620 - <a data-toggle="collapse" data-parent="#accordion12" href="#collapseOne12"> <span class="text-muted">/api/user/member</span></a> 1747 + <a data-toggle="collapse" data-parent="#accordion13" href="#collapseOne13"> <span class="text-muted">/api/user/member</span></a>
1621 </h4> 1748 </h4>
1622 </div> 1749 </div>
1623 - <div id="collapseOne12" class="panel-collapse collapse"> 1750 + <div id="collapseOne13" class="panel-collapse collapse">
1624 <div class="panel-body"> 1751 <div class="panel-body">
1625 1752
1626 <!-- Nav tabs --> 1753 <!-- Nav tabs -->
1627 - <ul class="nav nav-tabs" id="doctab12">  
1628 - <li class="active"><a href="#info12" data-toggle="tab">基础信息</a></li>  
1629 - <li><a href="#sandbox12" data-toggle="tab">在线测试</a></li>  
1630 - <li><a href="#sample12" data-toggle="tab">返回示例</a></li> 1754 + <ul class="nav nav-tabs" id="doctab13">
  1755 + <li class="active"><a href="#info13" data-toggle="tab">基础信息</a></li>
  1756 + <li><a href="#sandbox13" data-toggle="tab">在线测试</a></li>
  1757 + <li><a href="#sample13" data-toggle="tab">返回示例</a></li>
1631 </ul> 1758 </ul>
1632 1759
1633 <!-- Tab panes --> 1760 <!-- Tab panes -->
1634 <div class="tab-content"> 1761 <div class="tab-content">
1635 1762
1636 - <div class="tab-pane active" id="info12"> 1763 + <div class="tab-pane active" id="info13">
1637 <div class="well"> 1764 <div class="well">
1638 </div> 1765 </div>
1639 <div class="panel panel-default"> 1766 <div class="panel panel-default">
@@ -1655,19 +1782,19 @@ @@ -1655,19 +1782,19 @@
1655 </div> 1782 </div>
1656 </div><!-- #info --> 1783 </div><!-- #info -->
1657 1784
1658 - <div class="tab-pane" id="sandbox12"> 1785 + <div class="tab-pane" id="sandbox13">
1659 <div class="row"> 1786 <div class="row">
1660 <div class="col-md-12"> 1787 <div class="col-md-12">
1661 <div class="panel panel-default"> 1788 <div class="panel panel-default">
1662 <div class="panel-heading"><strong>参数</strong></div> 1789 <div class="panel-heading"><strong>参数</strong></div>
1663 <div class="panel-body"> 1790 <div class="panel-body">
1664 - <form enctype="application/x-www-form-urlencoded" role="form" action="/api/user/member" method="get" name="form12" id="form12"> 1791 + <form enctype="application/x-www-form-urlencoded" role="form" action="/api/user/member" method="get" name="form13" id="form13">
1665 <div class="form-group"> 1792 <div class="form-group">
1666 1793
1667 </div> 1794 </div>
1668 <div class="form-group"> 1795 <div class="form-group">
1669 - <button type="submit" class="btn btn-success send" rel="12">提交</button>  
1670 - <button type="reset" class="btn btn-info" rel="12">重置</button> 1796 + <button type="submit" class="btn btn-success send" rel="13">提交</button>
  1797 + <button type="reset" class="btn btn-info" rel="13">重置</button>
1671 </div> 1798 </div>
1672 </form> 1799 </form>
1673 </div> 1800 </div>
@@ -1677,8 +1804,8 @@ @@ -1677,8 +1804,8 @@
1677 <div class="panel-body"> 1804 <div class="panel-body">
1678 <div class="row"> 1805 <div class="row">
1679 <div class="col-md-12" style="overflow-x:auto"> 1806 <div class="col-md-12" style="overflow-x:auto">
1680 - <pre id="response_headers12"></pre>  
1681 - <pre id="response12"></pre> 1807 + <pre id="response_headers13"></pre>
  1808 + <pre id="response13"></pre>
1682 </div> 1809 </div>
1683 </div> 1810 </div>
1684 </div> 1811 </div>
@@ -1693,10 +1820,10 @@ @@ -1693,10 +1820,10 @@
1693 </div> 1820 </div>
1694 </div><!-- #sandbox --> 1821 </div><!-- #sandbox -->
1695 1822
1696 - <div class="tab-pane" id="sample12"> 1823 + <div class="tab-pane" id="sample13">
1697 <div class="row"> 1824 <div class="row">
1698 <div class="col-md-12"> 1825 <div class="col-md-12">
1699 - <pre id="sample_response12"></pre> 1826 + <pre id="sample_response13"></pre>
1700 </div> 1827 </div>
1701 </div> 1828 </div>
1702 </div><!-- #sample --> 1829 </div><!-- #sample -->
@@ -1711,7 +1838,7 @@ @@ -1711,7 +1838,7 @@
1711 1838
1712 <div class="row mt0 footer"> 1839 <div class="row mt0 footer">
1713 <div class="col-md-6" align="left"> 1840 <div class="col-md-6" align="left">
1714 - Generated on 2020-01-09 14:41:36 </div> 1841 + Generated on 2020-01-09 15:52:43 </div>
1715 <div class="col-md-6" align="right"> 1842 <div class="col-md-6" align="right">
1716 <a href="https://www.fastadmin.net" target="_blank">FastAdmin</a> 1843 <a href="https://www.fastadmin.net" target="_blank">FastAdmin</a>
1717 </div> 1844 </div>
  1 +define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template'], function ($, undefined, Backend, Table, Form, Template) {
  2 +
  3 + var Controller = {
  4 + index: function () {
  5 + // 初始化表格参数配置
  6 + Table.api.init({
  7 + extend: {
  8 + index_url: 'command/index',
  9 + add_url: 'command/add',
  10 + edit_url: '',
  11 + del_url: 'command/del',
  12 + multi_url: 'command/multi',
  13 + table: 'command',
  14 + }
  15 + });
  16 +
  17 + var table = $("#table");
  18 +
  19 + // 初始化表格
  20 + table.bootstrapTable({
  21 + url: $.fn.bootstrapTable.defaults.extend.index_url,
  22 + pk: 'id',
  23 + sortName: 'id',
  24 + columns: [
  25 + [
  26 + {checkbox: true},
  27 + {field: 'id', title: __('Id')},
  28 + {field: 'type', title: __('Type'), formatter: Table.api.formatter.search},
  29 + {field: 'type_text', title: __('Type')},
  30 + {
  31 + field: 'command', title: __('Command'), formatter: function (value, row, index) {
  32 + return '<input type="text" class="form-control" value="' + value + '">';
  33 + }
  34 + },
  35 + {
  36 + field: 'executetime',
  37 + title: __('Executetime'),
  38 + operate: 'RANGE',
  39 + addclass: 'datetimerange',
  40 + formatter: Table.api.formatter.datetime
  41 + },
  42 + {
  43 + field: 'createtime',
  44 + title: __('Createtime'),
  45 + operate: 'RANGE',
  46 + addclass: 'datetimerange',
  47 + formatter: Table.api.formatter.datetime
  48 + },
  49 + {
  50 + field: 'updatetime',
  51 + title: __('Updatetime'),
  52 + operate: 'RANGE',
  53 + addclass: 'datetimerange',
  54 + formatter: Table.api.formatter.datetime
  55 + },
  56 + {
  57 + field: 'status',
  58 + title: __('Status'),
  59 + table: table,
  60 + custom: {"successed": 'success', "failured": 'danger'},
  61 + searchList: {"successed": __('Successed'), "failured": __('Failured')},
  62 + formatter: Table.api.formatter.status
  63 + },
  64 + {
  65 + field: 'operate',
  66 + title: __('Operate'),
  67 + buttons: [
  68 + {
  69 + name: 'execute',
  70 + title: __('Execute again'),
  71 + text: __('Execute again'),
  72 + url: 'command/execute',
  73 + icon: 'fa fa-repeat',
  74 + classname: 'btn btn-success btn-xs btn-execute btn-ajax',
  75 + success: function (data) {
  76 + Layer.alert("<textarea class='form-control' cols='60' rows='5'>" + data.result + "</textarea>", {
  77 + title: __("执行结果"),
  78 + shadeClose: true
  79 + });
  80 + table.bootstrapTable('refresh');
  81 + return false;
  82 + }
  83 + },
  84 + {
  85 + name: 'execute',
  86 + title: __('Detail'),
  87 + text: __('Detail'),
  88 + url: 'command/detail',
  89 + icon: 'fa fa-list',
  90 + classname: 'btn btn-info btn-xs btn-execute btn-dialog'
  91 + }
  92 + ],
  93 + table: table,
  94 + events: Table.api.events.operate,
  95 + formatter: Table.api.formatter.operate
  96 + }
  97 + ]
  98 + ]
  99 + });
  100 +
  101 + // 为表格绑定事件
  102 + Table.api.bindevent(table);
  103 + },
  104 + add: function () {
  105 + require(['bootstrap-select', 'bootstrap-select-lang']);
  106 + var mainfields = [];
  107 + var relationfields = {};
  108 + var maintable = [];
  109 + var relationtable = [];
  110 + var relationmode = ["belongsto", "hasone"];
  111 +
  112 + var renderselect = function (select, data) {
  113 + var html = [];
  114 + for (var i = 0; i < data.length; i++) {
  115 + html.push("<option value='" + data[i] + "'>" + data[i] + "</option>");
  116 + }
  117 + $(select).html(html.join(""));
  118 + select.trigger("change");
  119 + if (select.data("selectpicker")) {
  120 + select.selectpicker('refresh');
  121 + }
  122 + return select;
  123 + };
  124 +
  125 + $("select[name=table] option").each(function () {
  126 + maintable.push($(this).val());
  127 + });
  128 + $(document).on('change', "input[name='isrelation']", function () {
  129 + $("#relation-zone").toggleClass("hide", !$(this).prop("checked"));
  130 + });
  131 + $(document).on('change', "select[name='table']", function () {
  132 + var that = this;
  133 + Fast.api.ajax({
  134 + url: "command/get_field_list",
  135 + data: {table: $(that).val()},
  136 + }, function (data, ret) {
  137 + mainfields = data.fieldlist;
  138 + $("#relation-zone .relation-item").remove();
  139 + renderselect($("#fields"), mainfields);
  140 + return false;
  141 + });
  142 + return false;
  143 + });
  144 + $(document).on('click', "a.btn-newrelation", function () {
  145 + var that = this;
  146 + var index = parseInt($(that).data("index")) + 1;
  147 + var content = Template("relationtpl", {index: index});
  148 + content = $(content.replace(/\[index\]/, index));
  149 + $(this).data("index", index);
  150 + $(content).insertBefore($(that).closest(".row"));
  151 + $('select', content).selectpicker();
  152 + var exists = [$("select[name='table']").val()];
  153 + $("select.relationtable").each(function () {
  154 + exists.push($(this).val());
  155 + });
  156 + relationtable = [];
  157 + $.each(maintable, function (i, j) {
  158 + if ($.inArray(j, exists) < 0) {
  159 + relationtable.push(j);
  160 + }
  161 + });
  162 + renderselect($("select.relationtable", content), relationtable);
  163 + $("select.relationtable", content).trigger("change");
  164 + });
  165 + $(document).on('click', "a.btn-removerelation", function () {
  166 + $(this).closest(".row").remove();
  167 + });
  168 + $(document).on('change', "#relation-zone select.relationmode", function () {
  169 + var table = $("select.relationtable", $(this).closest(".row")).val();
  170 + var that = this;
  171 + Fast.api.ajax({
  172 + url: "command/get_field_list",
  173 + data: {table: table},
  174 + }, function (data, ret) {
  175 + renderselect($(that).closest(".row").find("select.relationprimarykey"), $(that).val() == 'belongsto' ? data.fieldlist : mainfields);
  176 + renderselect($(that).closest(".row").find("select.relationforeignkey"), $(that).val() == 'hasone' ? data.fieldlist : mainfields);
  177 + return false;
  178 + });
  179 + });
  180 + $(document).on('change', "#relation-zone select.relationtable", function () {
  181 + var that = this;
  182 + Fast.api.ajax({
  183 + url: "command/get_field_list",
  184 + data: {table: $(that).val()},
  185 + }, function (data, ret) {
  186 + renderselect($(that).closest(".row").find("select.relationmode"), relationmode);
  187 + renderselect($(that).closest(".row").find("select.relationfields"), mainfields)
  188 + renderselect($(that).closest(".row").find("select.relationforeignkey"), data.fieldlist)
  189 + renderselect($(that).closest(".row").find("select.relationfields"), data.fieldlist)
  190 + return false;
  191 + });
  192 + });
  193 + $(document).on('click', ".btn-command", function () {
  194 + var form = $(this).closest("form");
  195 + var textarea = $("textarea[rel=command]", form);
  196 + textarea.val('');
  197 + Fast.api.ajax({
  198 + url: "command/command/action/command",
  199 + data: form.serialize(),
  200 + }, function (data, ret) {
  201 + textarea.val(data.command);
  202 + return false;
  203 + });
  204 + });
  205 + $(document).on('click', ".btn-execute", function () {
  206 + var form = $(this).closest("form");
  207 + var textarea = $("textarea[rel=result]", form);
  208 + textarea.val('');
  209 + Fast.api.ajax({
  210 + url: "command/command/action/execute",
  211 + data: form.serialize(),
  212 + }, function (data, ret) {
  213 + textarea.val(data.result);
  214 + window.parent.$(".toolbar .btn-refresh").trigger('click');
  215 + top.window.Fast.api.refreshmenu();
  216 + return false;
  217 + }, function () {
  218 + window.parent.$(".toolbar .btn-refresh").trigger('click');
  219 + });
  220 + });
  221 + $("select[name='table']").trigger("change");
  222 + Controller.api.bindevent();
  223 + },
  224 + edit: function () {
  225 + Controller.api.bindevent();
  226 + },
  227 + api: {
  228 + bindevent: function () {
  229 + Form.api.bindevent($("form[role=form]"));
  230 + }
  231 + }
  232 + };
  233 + return Controller;
  234 +});
  1 +define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2 +
  3 + var Controller = {
  4 + index: function () {
  5 + // 初始化表格参数配置
  6 + Table.api.init({
  7 + extend: {
  8 + index_url: 'contype/index' + location.search,
  9 + add_url: 'contype/add',
  10 + edit_url: 'contype/edit',
  11 + del_url: 'contype/del',
  12 + multi_url: 'contype/multi',
  13 + table: 'contype',
  14 + }
  15 + });
  16 +
  17 + var table = $("#table");
  18 +
  19 + // 初始化表格
  20 + table.bootstrapTable({
  21 + url: $.fn.bootstrapTable.defaults.extend.index_url,
  22 + pk: 'id',
  23 + sortName: 'id',
  24 + columns: [
  25 + [
  26 + {checkbox: true},
  27 + {field: 'id', title: __('Id'), operate:false},
  28 + {field: 'title', title: __('Title'), operate:false},
  29 + {field: 'type', title: __('Type'),formatter: Table.api.formatter.label,searchList:{'1': '经营管理','2':'职业发展'}},
  30 + {field: 'createtime', title: __('Createtime'), operate:false, addclass:'datetimerange', formatter: Table.api.formatter.datetime},
  31 + {field: 'updatetime', title: __('Updatetime'), operate:false, addclass:'datetimerange', formatter: Table.api.formatter.datetime},
  32 + {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  33 + ]
  34 + ]
  35 + });
  36 +
  37 + // 为表格绑定事件
  38 + Table.api.bindevent(table);
  39 + },
  40 + add: function () {
  41 + Controller.api.bindevent();
  42 + },
  43 + edit: function () {
  44 + Controller.api.bindevent();
  45 + },
  46 + api: {
  47 + bindevent: function () {
  48 + Form.api.bindevent($("form[role=form]"));
  49 + }
  50 + }
  51 + };
  52 + return Controller;
  53 +});
  1 +define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2 +
  3 + var Controller = {
  4 + index: function () {
  5 + // 初始化表格参数配置
  6 + Table.api.init({
  7 + extend: {
  8 + index_url: 'pic/index' + location.search,
  9 + add_url: 'pic/add',
  10 + edit_url: 'pic/edit',
  11 + del_url: 'pic/del',
  12 + multi_url: 'pic/multi',
  13 + table: 'pic',
  14 + }
  15 + });
  16 +
  17 + var table = $("#table");
  18 +
  19 + // 初始化表格
  20 + table.bootstrapTable({
  21 + url: $.fn.bootstrapTable.defaults.extend.index_url,
  22 + pk: 'id',
  23 + sortName: 'id',
  24 + columns: [
  25 + [
  26 + {checkbox: true},
  27 + {field: 'id', title: __('Id'),operate:false},
  28 + {field: 'thumbnail', title: __('Thumbnail'), operate:false, events: Table.api.events.image, formatter: Table.api.formatter.image},
  29 + {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
  30 + {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
  31 + {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  32 + ]
  33 + ]
  34 + });
  35 +
  36 + // 为表格绑定事件
  37 + Table.api.bindevent(table);
  38 + },
  39 + add: function () {
  40 + Controller.api.bindevent();
  41 + },
  42 + edit: function () {
  43 + Controller.api.bindevent();
  44 + },
  45 + api: {
  46 + bindevent: function () {
  47 + Form.api.bindevent($("form[role=form]"));
  48 + }
  49 + }
  50 + };
  51 + return Controller;
  52 +});