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

'1-4'

... ... @@ -16,7 +16,7 @@ use think\Request;
*/
class Article extends BaseApi
{
protected $noNeedLogin = '';
protected $noNeedLogin = ['setWechatNotify'];
protected $noNeedRight = '*';
/**
... ... @@ -699,7 +699,7 @@ class Article extends BaseApi
/**
* 支付礼物回调
* @ApiMethod (POST)
* @ApiRoute (/api/article/setWechatGiftNotify)
* @ApiRoute (/api/article/setWechatNotify)
* @ApiReturn ()
*/
public function setWechatNotify(){
... ...
... ... @@ -208,8 +208,8 @@ class Treasured extends BaseApi
}
/**
* 墨宝档案列表
* @ApiTitle (墨宝档案列表)
* 墨宝档案筛选
* @ApiTitle (墨宝档案筛选)
* @ApiMethod (POST)
* @ApiRoute (/api/treasured/getTreasuredShai)
* @ApiParams (name="page", type="integer", required=true, description="分页次数")
... ... @@ -217,8 +217,10 @@ class Treasured extends BaseApi
* @ApiParams (name="author", type="string", required=false, description="作者名称")
* @ApiParams (name="start_time", type="integer", required=false, description="开始时间")
* @ApiParams (name="end_time", type="integer", required=false, description="结束时间")
* @ApiParams (name="author", type="string", required=true, description="作者名称")
* @ApiParams (name="author", type="string", required=true, description="作者名称")
* @ApiParams (name="production_format_id", type="integer", required=false, description="格式ID")
* @ApiParams (name="production_typeface_id", type="integer", required=false, description="字体ID")
* @ApiParams (name="treasured_size_id", type="integer", required=false, description="尺寸ID")
* @ApiParams (name="status", type="integer", required=false, description="状态:0=待出售,1=已出售,2=非卖品")
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
* @ApiReturnParams (name="data", type="object", description="扩展数据返回")
... ... @@ -230,21 +232,90 @@ class Treasured extends BaseApi
['page','分页次数不能为空'],
['num','分页数量不能为空']
]);
$res = input('param.');
//2.查询数据
$treasured = model('treasured')
->where('deletetime',null)
->order('createtime','desc')
->page($data['page'],$data['num'])
->select();
//3.记录浏览记录
if ($treasured && $data['page'] == 1){
model('config')->where('name','mobao_num')->setInc('value');
$treasured = model('treasured');
if (isset($res['author']) && !empty($res['author'])){
$treasured = $treasured->where('author',$res['author']);
}
if (isset($res['start_time']) && !empty($res['start_time']) && isset($res['end_time']) && !empty($res['end_time'])){
$treasured = $treasured->where('createtime','>',$res['start_time'])->where('createtime','<',$res['end_time']);
}
if (isset($res['production_format_id']) && !empty($res['production_format_id'])){
$treasured = $treasured->where('production_format_id',$res['production_format_id']);
}
if (isset($res['production_typeface_id']) && !empty($res['production_typeface_id'])){
$treasured = $treasured->where('production_typeface_id',$res['production_typeface_id']);
}
if (isset($res['treasured_size_id']) && !empty($res['treasured_size_id'])){
$treasured = $treasured->where('treasured_size_id',$res['treasured_size_id']);
}
if (isset($res['status']) && $res['status'] != ''){
$treasured = $treasured->where('status',$res['status']);
}
$treasured = $treasured->page($data['page'],$data['num'])
->select();
//4.返回数据
$this->success('查询数据成功',$treasured);
}
/**
* 墨宝档案详情
* @ApiTitle (墨宝档案详情)
* @ApiMethod (POST)
* @ApiRoute (/api/treasured/getTreasuredContent)
* @ApiParams (name="id", type="integer", required=true, description="墨宝ID")
* @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 getTreasuredContent(){
//1.获取动态id
$id = $this->get_data('id','墨宝档案ID不能为空');
//2.查询数据
$treasured = model('treasured')->where('id',$id)->find();
//
//4.返回数据
$this->success('查询数据成功',$treasured);
}
/**
* 动态点赞或取消点赞{注意}
* @ApiTitle (动态点赞或取消点赞{注意})
* @ApiMethod (POST)
* @ApiRoute (/api/treasured/setTreasuredZan)
* @ApiParams (name="treasured_id", 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": "1608886856",
"data": {
"code": "0取消点赞 1=点赞成功",
"msg": "提示"
}
})
*/
public function setTreasuredZan(){
//1.获取数据
$treasured_id = $this->get_data('treasured_id','动态id不能为空');
//2.查询点赞
$treasured_zan = model('treasured_zan')
->where('user_id',$this->auth->id)
->where('treasured_id',$treasured_id)
->find();
if ($treasured_zan){
$treasured_zan->delete();
$this->success('查询成功',['code'=>0,'msg'=>'取消点赞成功']);
}
//3.增加点赞
model('treasured_zan')->create(['user_id'=>$this->auth->id,'treasured_id'=>$treasured_id]);
//4.返回结果
$this->success('查询成功',['code'=>1,'msg'=>'点赞成功']);
}
}
\ No newline at end of file
... ...
<?php
namespace app\common\model;
class TreasuredZan extends BaseModel
{
}
\ No newline at end of file
... ...
此 diff 太大无法显示。