1
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
namespace plugin\admin\app\controller;
|
||||
|
||||
use think\facade\Db;
|
||||
/**
|
||||
* @ControllerAnnotation('{$description}')
|
||||
* Class {$controllerClass}
|
||||
* @package plugin\admin\app\controller
|
||||
*/
|
||||
class {$controllerClass} extends Crud
|
||||
{
|
||||
protected array \$noNeedLogin = [];
|
||||
protected array \$noNeedRight = [];
|
||||
|
||||
function __construct()
|
||||
{
|
||||
$this->model = new \app\model\{:(str_replace('','',$controllerClass)};
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
<?php
|
||||
namespace app\api\controller;
|
||||
use think\facade\Db;
|
||||
use support\Request;
|
||||
use taoser\facade\Validate;
|
||||
use support\Jwt;
|
||||
use hg\apidoc\annotation as Apidoc;
|
||||
/**
|
||||
* @ControllerAnnotation('{$description}')
|
||||
* Class {$controllerClass}
|
||||
* @package app\api\controller
|
||||
*/
|
||||
class {$controllerClass} extends BaseController
|
||||
{
|
||||
/**
|
||||
* 不需要鉴权的方法
|
||||
* @var array
|
||||
*/
|
||||
protected array \$noNeedRight = [];
|
||||
/**
|
||||
* 无需登录及鉴权的方法
|
||||
* @var array
|
||||
*/
|
||||
protected array \$noNeedLogin = [];
|
||||
|
||||
function __construct()
|
||||
{
|
||||
$this->model = new \app\model\{:(str_replace('','',$controllerClass)};
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表
|
||||
* @Apidoc\Method("POST")
|
||||
* @Apidoc\Query("network", type="string", require=true, desc="网络")
|
||||
* @Apidoc\Query("page", type="int", require=true, desc="页码",default=1)
|
||||
* @Apidoc\Query("limit", type="int", require=true, desc="分页大小",default=10)
|
||||
*/
|
||||
public function list()
|
||||
{
|
||||
$limit = (int)input('limit',10);
|
||||
$page = (int)input('page',1);
|
||||
$status = (int)input('status',-1);
|
||||
$network = input('network');
|
||||
$type = input('type');
|
||||
$model = $this->model->where('user_id',\support\Jwt\JwtToken::getCurrentId());
|
||||
//->where('network','BEP-20');
|
||||
if($type){
|
||||
$model = $model->where('status',1);
|
||||
}
|
||||
if($network){
|
||||
$model = $model->where('network',$network);
|
||||
}
|
||||
$list = $model->paginate($limit);
|
||||
return $this->success(__('successful'),$list->toArray());
|
||||
|
||||
}
|
||||
/**
|
||||
* 创建
|
||||
* @Apidoc\Method("POST")
|
||||
* @Apidoc\Param("network", type="string", require=true, desc="网络,BEP-20,TRC-20",default="BEP-20")
|
||||
* @Apidoc\Param("address", type="string", require=true, desc="地址")
|
||||
* @Apidoc\Param("title", type="string", require=true, desc="名称")
|
||||
* @Apidoc\Param("status", type="string", require=true, desc="状态,可选,1,0,默认1")
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//captcha_verfiy('image','create_address');
|
||||
//* @Apidoc\Param("code", type="string", require=true, desc="图形验证码 event=create_address")
|
||||
//$trade_password = input('trade_password');
|
||||
//\support\Jwt::verify_trade_password($trade_password);
|
||||
//* @Apidoc\Param("trade_password", type="string", require=true, desc="交易密码")
|
||||
$data = [
|
||||
'title' => input('title',''),
|
||||
'network' => input('network','BEP-20'),
|
||||
'address' => input('address'),
|
||||
'status' => input('status',0),
|
||||
'user_id' => \support\Jwt\JwtToken::getCurrentId()
|
||||
];
|
||||
if(!$data['title']){
|
||||
return $this->error(__('Invalid title'));
|
||||
}
|
||||
// || substr($data['address'],0,2)!='0x'
|
||||
if(!$data['address']){
|
||||
return $this->error(__('Invalid address'));
|
||||
}
|
||||
$this->model->create($data);
|
||||
return $this->success(__('successful'));
|
||||
}
|
||||
/**
|
||||
* 编辑
|
||||
* @Apidoc\Method("POST")
|
||||
* @Apidoc\Param("id", type="string", require=true, desc="id")
|
||||
* @Apidoc\Param("title", type="string", require=true, desc="名称")
|
||||
* @Apidoc\Param("status", type="string", require=true, desc="状态,可选,1,0,默认1")
|
||||
*/
|
||||
public function update()
|
||||
{
|
||||
//captcha_verfiy('image','update_address');
|
||||
//$trade_password = input('trade_password');
|
||||
//\support\Jwt::verify_trade_password($trade_password);
|
||||
$data = [
|
||||
'id' => input('id',''),
|
||||
'title' => input('title',''),
|
||||
'status' => input('status',1)
|
||||
];
|
||||
if(!$data['id']){
|
||||
return $this->error(__('Invalid parameters'));
|
||||
}
|
||||
if(!$data['title']){
|
||||
return $this->error(__('Invalid title'));
|
||||
}
|
||||
$this->model->where('id',$data['id'])->save($data);
|
||||
return $this->success(__('successful'));
|
||||
}
|
||||
/**
|
||||
* 详情
|
||||
* @Apidoc\Query("id", type="int", require=true, desc="id")
|
||||
*/
|
||||
public function detail(){
|
||||
$id = input('id');
|
||||
$vo = $this->model->where('id',$id)->find();
|
||||
if($vo) {
|
||||
return $this->success(__('successful'),$vo->toArray());
|
||||
}else{
|
||||
return $this->error(__("Record is not exist"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
namespace app\controller;
|
||||
|
||||
use think\facade\Db;
|
||||
/**
|
||||
* @ControllerAnnotation('{$description}')
|
||||
* Class {$controllerClass}
|
||||
* @package app\controller
|
||||
*/
|
||||
class {$controllerClass} extends Base
|
||||
{
|
||||
protected array \$noNeedLogin = [];
|
||||
protected array \$noNeedRight = [];
|
||||
|
||||
function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @NodeAnnotation(title='列表')
|
||||
* @return mixed
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return view();
|
||||
}
|
||||
|
||||
/**
|
||||
* @NodeAnnotation(title='添加')
|
||||
* @return mixed
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @NodeAnnotation(title='编辑')
|
||||
* @return \\support\\response
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
define(['table', 'upload','form'], function (Table,Upload,Form) {
|
||||
var {$controllerClass} = {
|
||||
index: function () {
|
||||
|
||||
Table.api.init({
|
||||
extend: {
|
||||
index_url: '/app/admin/{$controllerLower}/select',
|
||||
add_url: '/app/admin/{$controllerLower}/insert',
|
||||
edit_url: '/app/admin/{$controllerLower}/update',
|
||||
del_url: '/app/admin/{$controllerLower}/delete',
|
||||
multi_url: '/app/admin/{$controllerLower}/multi',
|
||||
dragsort_url: '/app/admin/{$controllerLower}/weigh',
|
||||
table: 'admin',
|
||||
}
|
||||
});
|
||||
|
||||
var table = $("#table");
|
||||
var tableOptions = {
|
||||
url: $.fn.bootstrapTable.defaults.extend.index_url,
|
||||
pk: 'id',
|
||||
sortName: 'id',
|
||||
pagination: false,
|
||||
commonSearch: false,
|
||||
search: false,
|
||||
columns: [
|
||||
[
|
||||
{checkbox: true},
|
||||
{
|
||||
field: 'id',
|
||||
title: 'ID',
|
||||
filter: "number",
|
||||
sortable: true // 是否排序
|
||||
},
|
||||
{
|
||||
field: 'username',
|
||||
title: '用户名',
|
||||
filter: "string",
|
||||
},
|
||||
{
|
||||
field: 'role_name',
|
||||
title: '角色',
|
||||
filter: "string",
|
||||
},
|
||||
{
|
||||
field: 'mobile',
|
||||
title: '手机',
|
||||
filter: "string",
|
||||
},
|
||||
{
|
||||
field: 'email',
|
||||
title: '邮箱',
|
||||
filter: "string"
|
||||
},
|
||||
{
|
||||
field: 'login_at',
|
||||
title: '最后登录',
|
||||
filter: "date",
|
||||
visible:false
|
||||
},
|
||||
{
|
||||
field: 'created_at',
|
||||
title: '注册时间',
|
||||
filter: "date",
|
||||
visible:false
|
||||
},
|
||||
{
|
||||
field: 'status',
|
||||
title: '状态',
|
||||
formatter:Table.api.formatter.switch
|
||||
},
|
||||
{field: 'operate', title: '操作', table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
|
||||
]
|
||||
]
|
||||
};
|
||||
// 初始化表格
|
||||
table.bootstrapTable(tableOptions);
|
||||
// 为表格绑定事件
|
||||
Table.api.bindevent(table);
|
||||
},
|
||||
update:function(){
|
||||
Config['uploadurl'] = '/app/admin/attachment/avatar';
|
||||
var form = $('form');
|
||||
Form.api.bindevent(form)
|
||||
this.getRole();
|
||||
},
|
||||
insert:function(){
|
||||
Config['uploadurl'] = '/app/admin/attachment/avatar';
|
||||
var form = $('form');
|
||||
Form.api.bindevent(form)
|
||||
this.getRole();
|
||||
},
|
||||
getRole:function(){
|
||||
Fast.api.ajax({
|
||||
url: "/app/admin/adminrole/select?format=select",
|
||||
dataType: "json",
|
||||
success: function (res) {
|
||||
var html = "";
|
||||
var selected=$('#roles').data('value');
|
||||
for (let index = 0; index < res.data.length; index++) {
|
||||
const element = res.data[index];
|
||||
if(selected == element.value){
|
||||
html+='<option value="'+element.value+'" selected>'+element.name+'</option>';
|
||||
}else{
|
||||
html+='<option value="'+element.value+'">'+element.name+'</option>';
|
||||
}
|
||||
}
|
||||
$('#roles').append(html);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
return {$controllerClass}
|
||||
});
|
||||
@@ -0,0 +1,21 @@
|
||||
{layout name="layout"}
|
||||
<div class="toolbar" class="toolbar-btn-action">
|
||||
<a id="btn_add" class="btn btn-primary m-r-5 btn-add" data-url="{:url('insert')}" data-title="新增">
|
||||
<span class="mdi mdi-plus" aria-hidden="true"></span>新增
|
||||
</a>
|
||||
<a id="btn_edit" class="btn btn-success m-r-5 btn-disabled disabled btn-multi" data-params="status=1">
|
||||
<span class="mdi mdi-check" aria-hidden="true"></span>启用
|
||||
</a>
|
||||
<a id="btn_edit" class="btn btn-warning m-r-5 btn-disabled disabled btn-multi" data-params="status=0">
|
||||
<span class="mdi mdi-block-helper" aria-hidden="true"></span>禁用
|
||||
</a>
|
||||
<a id="btn_delete" class="btn btn-danger btn-del btn-disabled disabled">
|
||||
<span class="mdi mdi-window-close" aria-hidden="true"></span>删除
|
||||
</a>
|
||||
</div>
|
||||
<!-- 数据表格 -->
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<table id="table"></table>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,99 @@
|
||||
{layout name="layout"}
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<form class="form-horizontal" action="__SELF__" method="post">
|
||||
<input type="hidden" name="id" value="{$row.id|null}" />
|
||||
{volist name="fields" id="vo"}
|
||||
<?php
|
||||
$fieldName = $field['name'];
|
||||
$fieldComment = $field['comment'] ?? $fieldName;
|
||||
$fieldType = $field['type'] ?? 'varchar';
|
||||
?>
|
||||
{switch $fieldType}
|
||||
{case value='select'}
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{$fieldComment}</label>
|
||||
<div class="col-xs-12 col-sm-8 col-md-6">
|
||||
<select name="{$fieldName}" class="form-control selectpicker">
|
||||
{\\volist name="$vo.selectOptions" id="cvo"}
|
||||
<option value="{\\$cvo.id}" {\\if $row['{$fieldName}']== $cvo.id}selected{\\/if}>{\\$cvo.title}</option>
|
||||
{\\/volist}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
{/case}
|
||||
{case value='radio'}
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{$fieldComment}</label>
|
||||
<div class="col-xs-12 col-sm-8 col-md-6">
|
||||
{\\volist name="$vo.selectOptions" id="cvo"}
|
||||
<label class="lyear-radio radio-primary radio-inline">
|
||||
<input type="radio" name="{$fieldName}" {\\if $row.{$fieldName} == $key} checked{\\/if} value="{\\$key}">
|
||||
<span>{\\$rvo}</span>
|
||||
</label>
|
||||
{\\/volist}
|
||||
</div>
|
||||
</div>
|
||||
{/case}
|
||||
{case value='time'}
|
||||
<div class="form-group">
|
||||
<label for="type" class="control-label col-xs-12 col-sm-2">{$fieldComment}</label>
|
||||
<div class="col-xs-12 col-sm-8 col-md-6">
|
||||
<input type="password" name="{$fieldName}" placeholder="请输入{$fieldComment}" value="{\$row.{$fieldName}|null}" class="form-control" />
|
||||
</div>
|
||||
</div>
|
||||
{/case}
|
||||
{case value='image'}
|
||||
<div class="form-group">
|
||||
<label for="type" class="control-label col-xs-12 col-sm-2">{$fieldComment}</label>
|
||||
<div class="col-xs-12 col-sm-8 col-md-6">
|
||||
<input id="c-{$fieldName}" class="form-control" size="50" name="{$fieldName}" type="hidden" value="{\$row.{$fieldName}|default=''}" data-tip="image">
|
||||
<ul class="list-inline clearfix lyear-uploads-pic" data-template="preview" id="p-{$fieldName}">
|
||||
<li nodelete class="col-xs-4 col-sm-3 col-md-2">
|
||||
<a class="pic-add faupload" style="height: auto;border: 0;" permission="app.admin.upload.image" id="add-pic-btn" href="#!" title="点击上传" data-input-id="c-{$fieldName}" data-mimetype="image/*" data-multiple="false" data-preview-id="p-{$fieldName}"></a>
|
||||
<a class="pic-add fachoose" style="height: auto;border: 0;" permission="app.admin.upload.attachment" id="choose-pic-btn" href="#!" title="选择文件" data-input-id="c-{$fieldName}" data-mimetype="image/*" data-multiple="false" data-preview-id="p-{$fieldName}"></a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
{/case}
|
||||
{case value='file'}
|
||||
<div class="form-group">
|
||||
<label for="type" class="control-label col-xs-12 col-sm-2">{$fieldComment}</label>
|
||||
<div class="col-xs-12 col-sm-8 col-md-6">
|
||||
<input id="c-{$fieldName}" class="form-control" size="50" name="{$fieldName}" type="hidden" value="{\$row.{$fieldName}|default=''}" data-tip="image">
|
||||
<ul class="list-inline clearfix lyear-uploads-pic" data-template="preview" id="p-{$fieldName}">
|
||||
<li nodelete class="col-xs-4 col-sm-3 col-md-2">
|
||||
<a class="pic-add faupload" style="height: auto;border: 0;" permission="app.admin.upload.image" id="add-pic-btn" href="#!" title="点击上传" data-input-id="c-{$fieldName}" data-multiple="false" data-preview-id="p-{$fieldName}"></a>
|
||||
<a class="pic-add fachoose" style="height: auto;border: 0;" permission="app.admin.upload.attachment" id="choose-pic-btn" href="#!" title="选择文件" data-input-id="c-{$fieldName}" data-multiple="false" data-preview-id="p-{$fieldName}"></a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
{/case}
|
||||
{case value='password'}
|
||||
<div class="form-group">
|
||||
<label for="type" class="control-label col-xs-12 col-sm-2">{$fieldComment}</label>
|
||||
<div class="col-xs-12 col-sm-8 col-md-6">
|
||||
<input type="password" name="{$fieldName}" placeholder="请输入{$fieldComment}" value="{\$row.{$fieldName}|null}" class="form-control" />
|
||||
</div>
|
||||
</div>
|
||||
{/case}
|
||||
{default /}
|
||||
<div class="form-group">
|
||||
<label for="type" class="control-label col-xs-12 col-sm-2">{$fieldComment}</label>
|
||||
<div class="col-xs-12 col-sm-8 col-md-6">
|
||||
<input type="text" name="{$fieldName}" placeholder="请输入{$fieldComment}" value="{\$row.{$fieldName}|null}" class="form-control" />
|
||||
</div>
|
||||
</div>
|
||||
{/switch}
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2"></label>
|
||||
<div class="col-xs-12 col-sm-8 col-md-6 layer-footer">
|
||||
<button type="submit" class="btn btn-primary m-r-5">提交</button>
|
||||
<button type="reset" class="btn btn-warning m-r-5">重置</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
Reference in New Issue
Block a user