作者 郭宇鹏
1 个管道 的构建 通过 耗费 9 秒

'12-29'

正在显示 36 个修改的文件 包含 1225 行增加21 行删除
<?php
namespace app\admin\controller;
use app\common\controller\Backend;
/**
* 作品朝代
*
* @icon fa fa-circle-o
*/
class ProductionDynasty extends Backend
{
/**
* ProductionDynasty模型对象
* @var \app\admin\model\ProductionDynasty
*/
protected $model = null;
public function _initialize()
{
parent::_initialize();
$this->model = new \app\admin\model\ProductionDynasty;
}
public function import()
{
parent::import();
}
/**
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
*/
}
... ...
<?php
namespace app\admin\controller;
use app\common\controller\Backend;
/**
* 作品格式
*
* @icon fa fa-circle-o
*/
class ProductionFormat extends Backend
{
/**
* ProductionFormat模型对象
* @var \app\admin\model\ProductionFormat
*/
protected $model = null;
public function _initialize()
{
parent::_initialize();
$this->model = new \app\admin\model\ProductionFormat;
}
public function import()
{
parent::import();
}
/**
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
*/
}
... ...
<?php
namespace app\admin\controller;
use app\common\controller\Backend;
/**
* 作品字体
*
* @icon fa fa-circle-o
*/
class ProductionTypeface extends Backend
{
/**
* ProductionTypeface模型对象
* @var \app\admin\model\ProductionTypeface
*/
protected $model = null;
public function _initialize()
{
parent::_initialize();
$this->model = new \app\admin\model\ProductionTypeface;
}
public function import()
{
parent::import();
}
/**
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
*/
}
... ...
<?php
return [
'Id' => '主键',
'Name' => '朝代名称',
'Weigh' => '权重/排序',
'Createtime' => '创建日期',
'Updatetime' => '更新时间'
];
... ...
<?php
return [
'Id' => '主键',
'Name' => '格式名称',
'Weigh' => '权重/排序',
'Createtime' => '创建日期',
'Updatetime' => '更新时间'
];
... ...
<?php
return [
'Id' => '主键',
'Name' => '字体名称',
'Weigh' => '权重/排序',
'Createtime' => '创建日期',
'Updatetime' => '更新时间'
];
... ...
<?php
namespace app\admin\model;
use think\Model;
class ProductionDynasty extends Model
{
// 表名
protected $name = 'production_dynasty';
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'int';
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = 'updatetime';
protected $deleteTime = false;
// 追加属性
protected $append = [
];
protected static function init()
{
self::afterInsert(function ($row) {
if (!$row['weigh']) {
$pk = $row->getPk();
$row->getQuery()->where($pk, $row[$pk])->update(['weigh' => $row[$pk]]);
}
});
}
}
... ...
<?php
namespace app\admin\model;
use think\Model;
class ProductionFormat extends Model
{
// 表名
protected $name = 'production_format';
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'int';
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = 'updatetime';
protected $deleteTime = false;
// 追加属性
protected $append = [
];
protected static function init()
{
self::afterInsert(function ($row) {
if (!$row['weigh']) {
$pk = $row->getPk();
$row->getQuery()->where($pk, $row[$pk])->update(['weigh' => $row[$pk]]);
}
});
}
}
... ...
<?php
namespace app\admin\model;
use think\Model;
class ProductionTypeface extends Model
{
// 表名
protected $name = 'production_typeface';
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'int';
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = 'updatetime';
protected $deleteTime = false;
// 追加属性
protected $append = [
];
protected static function init()
{
self::afterInsert(function ($row) {
if (!$row['weigh']) {
$pk = $row->getPk();
$row->getQuery()->where($pk, $row[$pk])->update(['weigh' => $row[$pk]]);
}
});
}
}
... ...
<?php
namespace app\admin\validate;
use think\Validate;
class ProductionDynasty extends Validate
{
/**
* 验证规则
*/
protected $rule = [
];
/**
* 提示消息
*/
protected $message = [
];
/**
* 验证场景
*/
protected $scene = [
'add' => [],
'edit' => [],
];
}
... ...
<?php
namespace app\admin\validate;
use think\Validate;
class ProductionFormat extends Validate
{
/**
* 验证规则
*/
protected $rule = [
];
/**
* 提示消息
*/
protected $message = [
];
/**
* 验证场景
*/
protected $scene = [
'add' => [],
'edit' => [],
];
}
... ...
<?php
namespace app\admin\validate;
use think\Validate;
class ProductionTypeface extends Validate
{
/**
* 验证规则
*/
protected $rule = [
];
/**
* 提示消息
*/
protected $message = [
];
/**
* 验证场景
*/
protected $scene = [
'add' => [],
'edit' => [],
];
}
... ...
<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Name')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-name" class="form-control" name="row[name]" type="text">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Weigh')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-weigh" class="form-control" name="row[weigh]" type="number">
</div>
</div>
<div class="form-group layer-footer">
<label class="control-label col-xs-12 col-sm-2"></label>
<div class="col-xs-12 col-sm-8">
<button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
<button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
</div>
</div>
</form>
... ...
<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Name')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-name" class="form-control" name="row[name]" type="text" value="{$row.name|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Weigh')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-weigh" class="form-control" name="row[weigh]" type="number" value="{$row.weigh|htmlentities}">
</div>
</div>
<div class="form-group layer-footer">
<label class="control-label col-xs-12 col-sm-2"></label>
<div class="col-xs-12 col-sm-8">
<button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
<button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
</div>
</div>
</form>
... ...
<div class="panel panel-default panel-intro">
{:build_heading()}
<div class="panel-body">
<div id="myTabContent" class="tab-content">
<div class="tab-pane fade active in" id="one">
<div class="widget-body no-padding">
<div id="toolbar" class="toolbar">
<a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
<a href="javascript:;" class="btn btn-success btn-add {:$auth->check('production_dynasty/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>
<!-- <a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('production_dynasty/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>-->
<!-- <a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('production_dynasty/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>-->
<!-- <a href="javascript:;" class="btn btn-danger btn-import {:$auth->check('production_dynasty/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>-->
<!-- <div class="dropdown btn-group {:$auth->check('production_dynasty/multi')?'':'hide'}">-->
<!-- <a class="btn btn-primary btn-more dropdown-toggle btn-disabled disabled" data-toggle="dropdown"><i class="fa fa-cog"></i> {:__('More')}</a>-->
<!-- <ul class="dropdown-menu text-left" role="menu">-->
<!-- <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>-->
<!-- <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>-->
<!-- </ul>-->
<!-- </div>-->
</div>
<table id="table" class="table table-striped table-bordered table-hover table-nowrap"
data-operate-edit="{:$auth->check('production_dynasty/edit')}"
data-operate-del="{:$auth->check('production_dynasty/del')}"
width="100%">
</table>
</div>
</div>
</div>
</div>
</div>
... ...
<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Name')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-name" class="form-control" name="row[name]" type="text">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Weigh')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-weigh" class="form-control" name="row[weigh]" type="number">
</div>
</div>
<div class="form-group layer-footer">
<label class="control-label col-xs-12 col-sm-2"></label>
<div class="col-xs-12 col-sm-8">
<button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
<button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
</div>
</div>
</form>
... ...
<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Name')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-name" class="form-control" name="row[name]" type="text" value="{$row.name|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Weigh')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-weigh" class="form-control" name="row[weigh]" type="number" value="{$row.weigh|htmlentities}">
</div>
</div>
<div class="form-group layer-footer">
<label class="control-label col-xs-12 col-sm-2"></label>
<div class="col-xs-12 col-sm-8">
<button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
<button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
</div>
</div>
</form>
... ...
<div class="panel panel-default panel-intro">
{:build_heading()}
<div class="panel-body">
<div id="myTabContent" class="tab-content">
<div class="tab-pane fade active in" id="one">
<div class="widget-body no-padding">
<div id="toolbar" class="toolbar">
<a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
<a href="javascript:;" class="btn btn-success btn-add {:$auth->check('production_format/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>
<!-- <a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('production_format/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>-->
<!-- <a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('production_format/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>-->
<!-- <a href="javascript:;" class="btn btn-danger btn-import {:$auth->check('production_format/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>-->
<!-- <div class="dropdown btn-group {:$auth->check('production_format/multi')?'':'hide'}">-->
<!-- <a class="btn btn-primary btn-more dropdown-toggle btn-disabled disabled" data-toggle="dropdown"><i class="fa fa-cog"></i> {:__('More')}</a>-->
<!-- <ul class="dropdown-menu text-left" role="menu">-->
<!-- <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>-->
<!-- <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>-->
<!-- </ul>-->
<!-- </div>-->
</div>
<table id="table" class="table table-striped table-bordered table-hover table-nowrap"
data-operate-edit="{:$auth->check('production_format/edit')}"
data-operate-del="{:$auth->check('production_format/del')}"
width="100%">
</table>
</div>
</div>
</div>
</div>
</div>
... ...
<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Name')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-name" class="form-control" name="row[name]" type="text">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Weigh')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-weigh" class="form-control" name="row[weigh]" type="number">
</div>
</div>
<div class="form-group layer-footer">
<label class="control-label col-xs-12 col-sm-2"></label>
<div class="col-xs-12 col-sm-8">
<button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
<button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
</div>
</div>
</form>
... ...
<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Name')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-name" class="form-control" name="row[name]" type="text" value="{$row.name|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Weigh')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-weigh" class="form-control" name="row[weigh]" type="number" value="{$row.weigh|htmlentities}">
</div>
</div>
<div class="form-group layer-footer">
<label class="control-label col-xs-12 col-sm-2"></label>
<div class="col-xs-12 col-sm-8">
<button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
<button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
</div>
</div>
</form>
... ...
<div class="panel panel-default panel-intro">
{:build_heading()}
<div class="panel-body">
<div id="myTabContent" class="tab-content">
<div class="tab-pane fade active in" id="one">
<div class="widget-body no-padding">
<div id="toolbar" class="toolbar">
<a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
<a href="javascript:;" class="btn btn-success btn-add {:$auth->check('production_typeface/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>
<!-- <a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('production_typeface/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>-->
<!-- <a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('production_typeface/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>-->
<!-- <a href="javascript:;" class="btn btn-danger btn-import {:$auth->check('production_typeface/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>-->
<!-- <div class="dropdown btn-group {:$auth->check('production_typeface/multi')?'':'hide'}">-->
<!-- <a class="btn btn-primary btn-more dropdown-toggle btn-disabled disabled" data-toggle="dropdown"><i class="fa fa-cog"></i> {:__('More')}</a>-->
<!-- <ul class="dropdown-menu text-left" role="menu">-->
<!-- <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>-->
<!-- <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>-->
<!-- </ul>-->
<!-- </div>-->
</div>
<table id="table" class="table table-striped table-bordered table-hover table-nowrap"
data-operate-edit="{:$auth->check('production_typeface/edit')}"
data-operate-del="{:$auth->check('production_typeface/del')}"
width="100%">
</table>
</div>
</div>
</div>
</div>
</div>
... ...
... ... @@ -73,7 +73,9 @@ class Article extends BaseApi
'content'=>$data['content'],
'images'=>$images
]);
//6.返回结果
//6.查询数据
$article = model('article')->where('id',$article['id'])->find();
//7.返回结果
$this->success('增加动态成功',$article);
}
/**
... ... @@ -550,7 +552,7 @@ class Article extends BaseApi
*/
public function getArticleGift(){
//1.获取礼物数据
$list = model('article_gift')->order('weigh','desc')->limit(7)->select();
$list = model('gift')->order('weigh','desc')->limit(7)->select();
//2.返回数据
$this->success('获取数据成功',$list);
}
... ... @@ -560,9 +562,9 @@ class Article extends BaseApi
* @ApiMethod (POST)
* @ApiRoute (/api/article/giveGift)
* @ApiParams (name="article_id", type="integer", required=true, description="动态id")
* @ApiParams (name="article_gift_id", type="integer", required=true, description="礼物id")
* @ApiParams (name="gift_id", type="integer", required=true, description="礼物id")
* @ApiParams (name="price", type="integer", required=true, description="价格")
* @ApiParams (name="status", type="integer", required=true, description="是否是自定义价格:0=不是{需要填写article_gift_id},1=是{需要填写金额}")
* @ApiParams (name="status", type="integer", required=true, description="是否是自定义价格:0=不是{需要填写gift_id},1=是{需要填写金额}")
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
* @ApiReturnParams (name="data", type="object", description="扩展数据返回")
... ... @@ -584,12 +586,12 @@ class Article extends BaseApi
//3.判断不是自定义价格
if ($data['status'] == 0){
//3.1 查询礼物
$article_gift = model('article_gift')->where('id',$this->get_data('article_gift_id','礼物id不能为空'))->find();
if (!$article_gift)$this->error('未查询到相关礼物,请您检查article_gift_id');
$article_gift = model('gift')->where('id',$this->get_data('gift_id','礼物id不能为空'))->find();
if (!$article_gift)$this->error('未查询到相关礼物,请您检查gift_id');
//3.2 查询礼物订单
$is_order = model('article_gift_order')
->where('article_id',$article['id'])
->where('article_gift_id',$article_gift['id'])
->where('gift_id',$article_gift['id'])
->where('is_custom',0)
->where('status',0)
->where('price',$article_gift['price'])
... ... @@ -607,7 +609,7 @@ class Article extends BaseApi
'price'=>$article_gift['price'],
'status'=>0,
'is_custom'=>0,
'article_gift_id'=>$article_gift['id'],
'gift_id'=>$article_gift['id'],
'article_gift_name'=>$article_gift['name'],
];
$is_order = model('article_gift_order')->create($a_data);
... ... @@ -648,18 +650,17 @@ class Article extends BaseApi
$app = Factory::payment($config);
//6.查询用户的第三方登录信息
$fa_third = Db::name('third')->where('user_id',$this->auth->id)->find();
dd($fa_third);
if (!$fa_third)$this->error('第三方授权数据不存在');
//3.统一下单接口
$result = $app->order->unify([
'body' => '送出礼物',
'out_trade_no' => $is_order['number'],
//'total_fee' => $order['price'] * 100,
'total_fee' => 1,
'notify_url' =>this_url().'/api/course_order/setWechatNotify', // 支付结果通知网址,如果不设置则会使用配置里的默认地址
'notify_url' =>this_url().'/api/article/setWechatGiftNotify', // 支付结果通知网址,如果不设置则会使用配置里的默认地址
'trade_type' => 'JSAPI', // 请对应换成你的支付方式对应的值类型
'openid' => $fa_third['openid'],
]);
dd($result);
//4.判断返回结果
if ($result['result_code'] == 'SUCCESS' && $result['return_code'] == 'SUCCESS') {
$prepayId = $result['prepay_id'];
... ... @@ -669,16 +670,29 @@ class Article extends BaseApi
} else {
$this->error('失败',$result);
}
$list = model('article_gift')->order('weigh','desc')->limit(7)->select();
//2.返回数据
$this->success('获取数据成功',$list);
}
/**
* 支付礼物回调
* @ApiMethod (POST)
* @ApiRoute (/api/article/setWechatGiftNotify)
* @ApiReturn ()
*/
public function setWechatNotify(){
$config = config('EasyWeChat');
$app = Factory::payment($config);
$response = $app->handlePaidNotify(function ($message, $fail) {
//将礼物进行支付
$order = model('article_gift_order')->where('number',$message['out_trade_no'])->find();
if (!$order)$fail('订单不存在');
if ($order['status'] == 1)$fail('您的订单已经支付');
$order->status = 1;
$order->save();
//给礼物用户一个通知
//
});
$response->send(); // Laravel 里请使用:return $response;
}
}
\ No newline at end of file
... ...
... ... @@ -3,6 +3,8 @@
namespace app\api\controller;
use function Couchbase\defaultDecoder;
/**
* 首页相关
* @package app\api\controller
... ... @@ -93,6 +95,107 @@ class Index extends BaseApi
$this->success('查询数据成功',$art_list);
}
/**
* 获取动态栏目列表
* @ApiTitle (获取动态栏目列表)
* @ApiMethod (POST)
* @ApiRoute (/api/index/articleCategoryList)
* @ApiParams (name="num", type="integer", required=false, description="请求数量 传为所有")
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
* @ApiReturnParams (name="data", type="object", description="扩展数据返回")
* @ApiReturn ()
*/
public function articleCategoryList(){
$num = input('param.num');
if ($num){
$articleCategoryList = model('article_category')->order('weigh','desc')->limit($num)->select();
}else{
$articleCategoryList = model('article_category')->order('weigh','desc')->select();
}
$this->success('查询成功',$articleCategoryList);
}
/**
* 首页分类列表+搜索
* @ApiTitle (首页分类列表+搜索)
* @ApiMethod (POST)
* @ApiRoute (/api/index/CategoryList)
* @ApiParams (name="page", type="integer", required=true, description="分页次数")
* @ApiParams (name="num", type="integer", required=true, description="分页数量")
* @ApiParams (name="article_category_id", type="integer", required=true, description="动态栏目id")
* @ApiParams (name="search", type="string", required=false, description="搜索内容")
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
* @ApiReturnParams (name="data", type="object", description="扩展数据返回")
* @ApiReturn ({
"code": 1,
"msg": "查询数据成功",
"time": "1608857680",
"data": [
{
"id": 9,
"user_id": 1,
"article_category_id": 7,
"content": "内",
"images": [
"http://qldk2g57y.hn-bkt.clouddn.com/uploads/20201221/667431fe2f31e5d0e76344ba7545ea20.jpg"
],
"createtime": "2020-12-24 15:13:48",
"updatetime": "2020-12-24 15:13:48",
"deletetime": null,
"message": null,
"is_friend": "是否是好友 1=是 0=不是",
"str_time": "首页显示时间"
}
]
})
*/
public function CategoryList(){
//1.获取数据
$data = $this->get_data_array([
['page','分页次数不能为空'],
['num','分页数量不能为空'],
['article_category_id','动态栏目id必须填写'],
]);
//2.获取列表数据
$art_list = model('article')
->where('deletetime',null)
->where('article_category_id',$data['article_category_id'])
->with(['user'])
->order('createtime','desc')
->page($data['page'],$data['num'])
->select();
//3.判断是不是搜索
$search = input('param.search');
if (isset($search) && !empty($search)){
$art_list = model('article')
->where('deletetime',null)
->where('article_category_id',$data['article_category_id'])
->where('content','like','%'.$search.'%')
->with(['user'])
->order('createtime','desc')
->page($data['page'],$data['num'])
->select();
}
//3.判断是不是好友
$user_id = $this->auth->id;
if (!empty($art_list)){
foreach ($art_list as $key => $val){
//1.查询关注和被关注
$attention = model('user_attention')->where(function ($query) use ($val,$user_id){
$query->where('user_id',$user_id)->where('in_user_id',$val['user_id']);
})->whereOr(function ($query) use ($val,$user_id){
$query->where('user_id',$val['user_id'])->where('in_user_id',$user_id);
})->count();
if ($attention == 2){
$art_list[$key]['is_friend'] = 1;
}else{
$art_list[$key]['is_friend'] = 1;
}
}
}
$this->success('查询数据成功',$art_list);
}
/**
* 搜索动态
* @ApiTitle (搜索动态)
* @ApiMethod (POST)
... ...
<?php
namespace app\api\controller;
/**
* 作品相关
* @package app\api\controller
*/
class Production extends BaseApi
{
protected $noNeedLogin = '';
protected $noNeedRight = '*';
/**
* 获取作品朝代
*/
public function getDynasty(){
$dynasty = model('production_dynasty')->order('weigh','desc')->field('id,name,createtime')->select();
$this->success('查询成功',$dynasty);
}
/**
* 获取作品格式
*/
public function getFormat(){
$forma = model('production_tforma')->order('weigh','desc')->field('id,name,createtime')->select();
$this->success('查询成功',$forma);
}
/**
* 获取作品字体
*/
public function getTypeface(){
$typeface = model('production_typeface')->order('weigh','desc')->field('id,name,createtime')->select();
$this->success('查询成功',$typeface);
}
/**
* 增加作品
* @ApiTitle (增加作品)
* @ApiMethod (POST)
* @ApiRoute (/api/production/addProduction)
* @ApiParams (name="title", type="string", required=true, description="作品标题")
* @ApiParams (name="content", type="string", required=true, description="内容")
* @ApiParams (name="images", type="string", required=true, description="图片数组(不带域名)")
* @ApiParams (name="typeface_id", type="integer", required=true, description="字体ID")
* @ApiParams (name="dynasty_id", type="integer", required=true, description="朝代ID")
* @ApiParams (name="format_id", type="integer", required=true, description="格式ID")
* @ApiParams (name="width", type="integer", required=true, description="宽度")
* @ApiParams (name="height", type="integer", required=true, description="高度")
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
* @ApiReturnParams (name="data", type="object", description="扩展数据返回")
* @ApiReturn ({
"code": 1,
"msg": "增加作品成功",
"time": "1609213602",
"data": {
"title": "作品标题",
"content": "作品内容",
"images": "作品图片",
"typeface_id": "字体ID",
"dynasty_id": "朝代ID",
"format_id": "格式ID",
"width": "宽度",
"height": "高度",
"typeface": "字体",
"dynasty": "朝代",
"format": "格式",
"user_id": "用户ID",
"avatar": "头像",
"nickname": "署名",
"fenxiang_num": "分享数量",
"zan_num": "点赞数量",
"ping_num": "点赞数量",
"price_num": "打赏总数",
"shoucang_num": "收藏数量",
"createtime": "2020-12-29 11:46:43",
"updatetime": "2020-12-29 11:46:43",
"id": "2"
}
})
*/
public function addProduction(){
//1.验证用户权限
if ($this->auth->authlist == '' || $this->auth->authlist == ','){
$this->error('请您先实名认证');
}
//2.获取数据
$data = $this->get_data_array([
['title','作品标题不能为空'],
['content','内容不存在'],
['images','图片必须上传'],
['typeface_id','字体ID必须传入'],
['dynasty_id','朝代ID必须传入'],
['format_id','格式ID必须传入'],
['width','宽度'],
['height','高度'],
]);
//3.获取图片数据
$files = str_replace('&quot;','"',$data['images']);
$images = implode(',',json_decode($files,true));
//4.查询数据
$typeface = model('production_typeface')->where('id',$data['typeface_id'])->find();
$dynasty = model('production_dynasty')->where('id',$data['dynasty_id'])->find();
$format = model('production_format')->where('id',$data['format_id'])->find();
if (!$typeface || !$dynasty || !$format){
$this->error('数据不存在');
}
$data['typeface'] = $typeface['name'];
$data['dynasty'] = $dynasty['name'];
$data['format'] = $format['name'];
$data['user_id'] = $this->auth->id;
$data['avatar'] = $this->auth->avatar;
$data['nickname'] = $this->auth->nickname;
$data['images'] = $images;
//5.增加作品
$production = model('production')->create($data);
//6.查询数据
$production = model('production')->where('id',$production['id'])->find();
//7.返回结果
$this->success('增加作品成功',$production);
}
/**
* 增加作品列表
* @ApiTitle (获取首页动态)
* @ApiMethod (POST)
* @ApiRoute (/api/production/articleList)
* @ApiParams (name="page", type="integer", required=true, description="分页次数")
* @ApiParams (name="num", type="integer", required=true, description="分页数量")
* @ApiParams (name="status", type="integer", required=true, description="1=最热,2=最新作品,3=书体筛选")
* @ApiParams (name="production_typeface_id", type="integer", required=true, description="1=最热,2=最新作品,3=书体筛选")
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
* @ApiReturnParams (name="data", type="object", description="扩展数据返回")
* @ApiReturn ({
"code": 1,
"msg": "增加作品成功",
"time": "1609213602",
"data": {
"title": "作品标题",
"content": "作品内容",
"images": "作品图片",
"typeface_id": "字体ID",
"dynasty_id": "朝代ID",
"format_id": "格式ID",
"width": "宽度",
"height": "高度",
"typeface": "字体",
"dynasty": "朝代",
"format": "格式",
"user_id": "用户ID",
"avatar": "头像",
"nickname": "署名",
"fenxiang_num": "分享数量",
"zan_num": "点赞数量",
"ping_num": "点赞数量",
"price_num": "打赏总数",
"shoucang_num": "收藏数量",
"createtime": "2020-12-29 11:46:43",
"updatetime": "2020-12-29 11:46:43",
"id": "2"
}
})
*/
public function ProductionList(){
//1.获取数据
$data = $this->get_data_array([
['page','分页次数不能为空'],
['num','分页数量不能为空'],
['status','状态必须填写'],
]);
//2.获取列表数据
if ($data['status'] == 1){
//最热
$Pro_list = model('production')
->where('deletetime',null)
->with(['user'])
->order('zan_num','desc')
->page($data['page'],$data['num'])
->select();
}else if ($data['status'] == 2){
//最新作品
$Pro_list = model('production')
->where('deletetime',null)
->with(['user'])
->order('createtime','desc')
->page($data['page'],$data['num'])
->select();
}else if ($data['status'] == 2){
$typeface_id = $this->get_data('typeface_id','字体ID不能为空');
//最新作品
$Pro_list = model('production')
->where('deletetime',null)
->with(['user'])
->where('typeface_id',$typeface_id)
->page($data['page'],$data['num'])
->select();
}
//3.判断是不是好友
$user_id = $this->auth->id;
if (!empty($Pro_list)){
foreach ($Pro_list as $key => $val){
//1.查询关注和被关注
$attention = model('production_zan')->where('','')->where('','')->count();
if ($attention == 2){
$art_list[$key]['is_friend'] = 1;
}else{
$art_list[$key]['is_friend'] = 1;
}
}
}
$this->success('查询数据成功',$art_list);
}
}
\ No newline at end of file
... ...
... ... @@ -469,3 +469,27 @@ if (!function_exists('this_url')){
}
}
/**
* 打印数据
* @param string $name 数据
* @return mixed
*/
if (!function_exists('dd')) {
function dd($name,$stu = true){
if (is_string($name)){
echo gettype($name);
echo '</br>';
echo $name;
exit();
}
if ($stu){
echo json_encode($name);
}else{
echo "<pre>";
var_dump($name);
echo "</pre>";
}
exit();
}
}
... ...
... ... @@ -4,7 +4,7 @@
namespace app\common\model;
class ArticleGift extends BaseModel
class Gift extends BaseModel
{
/**
... ...
<?php
namespace app\common\model;
class Production extends BaseModel
{
}
\ No newline at end of file
... ...
<?php
namespace app\common\model;
class ProductionDynasty extends BaseModel
{
}
\ No newline at end of file
... ...
<?php
namespace app\common\model;
class ProductionFormat extends BaseModel
{
}
\ No newline at end of file
... ...
<?php
namespace app\common\model;
class ProductionTypeface extends BaseModel
{
}
\ No newline at end of file
... ...
<?php
namespace app\common\model;
class ProductionZan extends BaseModel
{
}
\ No newline at end of file
... ...
... ... @@ -290,7 +290,7 @@ return [
//插件纯净模式,插件启用后是否删除插件目录的application、public和assets文件夹
'addon_pure_mode' => true,
//允许跨域的域名,多个以,分隔
'cors_request_domain' => 'localhost,127.0.0.1',
'cors_request_domain' => 'localhost,127.0.0.1,sjbk.h.brofirst.cn',
//版本号
'version' => '1.2.0.20201008_beta',
//API接口地址
... ...
此 diff 太大无法显示。
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
var Controller = {
index: function () {
// 初始化表格参数配置
Table.api.init({
extend: {
index_url: 'production_dynasty/index' + location.search,
add_url: 'production_dynasty/add',
edit_url: 'production_dynasty/edit',
del_url: 'production_dynasty/del',
multi_url: 'production_dynasty/multi',
import_url: 'production_dynasty/import',
table: 'production_dynasty',
}
});
var table = $("#table");
// 初始化表格
table.bootstrapTable({
url: $.fn.bootstrapTable.defaults.extend.index_url,
pk: 'id',
sortName: 'weigh',
search:false,
visible: false,
showToggle: false,
showColumns: false,
howExport: false,
commonSearch: false,
operate: false,
columns: [
[
{checkbox: true},
{field: 'id', title: __('Id')},
{field: 'name', title: __('Name'), operate: 'LIKE'},
{field: 'weigh', title: __('Weigh'), operate: false},
{field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
{field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
]
]
});
// 为表格绑定事件
Table.api.bindevent(table);
},
add: function () {
Controller.api.bindevent();
},
edit: function () {
Controller.api.bindevent();
},
api: {
bindevent: function () {
Form.api.bindevent($("form[role=form]"));
}
}
};
return Controller;
});
\ No newline at end of file
... ...
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
var Controller = {
index: function () {
// 初始化表格参数配置
Table.api.init({
extend: {
index_url: 'production_format/index' + location.search,
add_url: 'production_format/add',
edit_url: 'production_format/edit',
del_url: 'production_format/del',
multi_url: 'production_format/multi',
import_url: 'production_format/import',
table: 'production_format',
}
});
var table = $("#table");
// 初始化表格
table.bootstrapTable({
url: $.fn.bootstrapTable.defaults.extend.index_url,
pk: 'id',
sortName: 'weigh',
search:false,
visible: false,
showToggle: false,
showColumns: false,
howExport: false,
commonSearch: false,
operate: false,
columns: [
[
{checkbox: true},
{field: 'id', title: __('Id')},
{field: 'name', title: __('Name'), operate: 'LIKE'},
{field: 'weigh', title: __('Weigh'), operate: false},
{field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
{field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
]
]
});
// 为表格绑定事件
Table.api.bindevent(table);
},
add: function () {
Controller.api.bindevent();
},
edit: function () {
Controller.api.bindevent();
},
api: {
bindevent: function () {
Form.api.bindevent($("form[role=form]"));
}
}
};
return Controller;
});
\ No newline at end of file
... ...
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
var Controller = {
index: function () {
// 初始化表格参数配置
Table.api.init({
extend: {
index_url: 'production_typeface/index' + location.search,
add_url: 'production_typeface/add',
edit_url: 'production_typeface/edit',
del_url: 'production_typeface/del',
multi_url: 'production_typeface/multi',
import_url: 'production_typeface/import',
table: 'production_typeface',
}
});
var table = $("#table");
// 初始化表格
table.bootstrapTable({
url: $.fn.bootstrapTable.defaults.extend.index_url,
pk: 'id',
sortName: 'weigh',
search:false,
visible: false,
showToggle: false,
showColumns: false,
howExport: false,
commonSearch: false,
operate: false,
columns: [
[
{checkbox: true},
{field: 'id', title: __('Id')},
{field: 'name', title: __('Name'), operate: 'LIKE'},
{field: 'weigh', title: __('Weigh'), operate: false},
{field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
{field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
]
]
});
// 为表格绑定事件
Table.api.bindevent(table);
},
add: function () {
Controller.api.bindevent();
},
edit: function () {
Controller.api.bindevent();
},
api: {
bindevent: function () {
Form.api.bindevent($("form[role=form]"));
}
}
};
return Controller;
});
\ No newline at end of file
... ...