...
|
...
|
@@ -4,6 +4,10 @@ |
|
|
namespace app\api\controller;
|
|
|
|
|
|
use dh2y\qrcode\QRcode;
|
|
|
use think\Db;
|
|
|
use think\Exception;
|
|
|
use think\exception\PDOException;
|
|
|
use think\exception\ValidateException;
|
|
|
|
|
|
/**
|
|
|
* 墨宝档案
|
...
|
...
|
@@ -203,7 +207,17 @@ class Treasured extends BaseApi |
|
|
if ($treasured && $data['page'] == 1){
|
|
|
model('config')->where('name','mobao_num')->setInc('value');
|
|
|
}
|
|
|
//4.返回数据
|
|
|
//4.判断是不是点赞
|
|
|
if ($treasured){
|
|
|
foreach ($treasured as $key => $val){
|
|
|
$treasured[$key]['is_zan'] = 0;
|
|
|
$zan = model('treasured_zan')->where('user_id',$this->auth->id)->where('treasured_id',$val['id'])->find();
|
|
|
if ($zan){
|
|
|
$treasured[$key]['is_zan'] = 1;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//5.返回数据
|
|
|
$this->success('查询数据成功',$treasured);
|
|
|
}
|
|
|
|
...
|
...
|
@@ -255,6 +269,16 @@ class Treasured extends BaseApi |
|
|
}
|
|
|
$treasured = $treasured->page($data['page'],$data['num'])
|
|
|
->select();
|
|
|
//3.判断是不是点赞
|
|
|
if ($treasured){
|
|
|
foreach ($treasured as $key => $val){
|
|
|
$treasured[$key]['is_zan'] = 0;
|
|
|
$zan = model('treasured_zan')->where('user_id',$this->auth->id)->where('treasured_id',$val['id'])->find();
|
|
|
if ($zan){
|
|
|
$treasured[$key]['is_zan'] = 1;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//4.返回数据
|
|
|
$this->success('查询数据成功',$treasured);
|
|
|
}
|
...
|
...
|
@@ -268,14 +292,49 @@ class Treasured extends BaseApi |
|
|
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
|
|
|
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
|
|
|
* @ApiReturnParams (name="data", type="object", description="扩展数据返回")
|
|
|
* @ApiReturn ()
|
|
|
* @ApiReturn ({
|
|
|
"code": 1,
|
|
|
"msg": "查询数据成功",
|
|
|
"time": "1609742416",
|
|
|
"data": {
|
|
|
"id": 1,
|
|
|
"user_id": 2,
|
|
|
"avatar": "头像",
|
|
|
"nickname": "署名",
|
|
|
"title": "墨宝标题",
|
|
|
"number": "墨宝编号",
|
|
|
"author": "作者",
|
|
|
"images": "墨宝图片",
|
|
|
"content": "内容",
|
|
|
"production_typeface": "字体",
|
|
|
"production_typeface_id": "字体ID",
|
|
|
"production_format": "格式",
|
|
|
"production_format_id": "格式ID",
|
|
|
"treasured_size": "尺寸名称",
|
|
|
"treasured_size_id": "尺寸ID",
|
|
|
"status": "状态:0=待出售,1=已出售,2=非卖品",
|
|
|
"zan_num": "点赞数量",
|
|
|
"createtime": "2020-12-30 13:38:38",
|
|
|
"qr_code": "二维码",
|
|
|
"qr_code_d": "海报二维码",
|
|
|
"updatetime": "2020-12-30 13:38:38",
|
|
|
"deletetime": "删除时间",
|
|
|
"message": "删除提示",
|
|
|
"is_zan": "是否点赞 0=未点赞,1=已点赞"
|
|
|
}
|
|
|
})
|
|
|
*/
|
|
|
public function getTreasuredContent(){
|
|
|
//1.获取动态id
|
|
|
$id = $this->get_data('id','墨宝档案ID不能为空');
|
|
|
//2.查询数据
|
|
|
$treasured = model('treasured')->where('id',$id)->find();
|
|
|
//
|
|
|
//3.查询有没有点赞
|
|
|
$treasured['is_zan'] = 0;
|
|
|
$zan = model('treasured_zan')->where('user_id',$this->auth->id)->where('treasured_id',$id)->find();
|
|
|
if ($zan){
|
|
|
$treasured['is_zan'] = 1;
|
|
|
}
|
|
|
//4.返回数据
|
|
|
$this->success('查询数据成功',$treasured);
|
|
|
}
|
...
|
...
|
@@ -310,11 +369,14 @@ class Treasured extends BaseApi |
|
|
->find();
|
|
|
if ($treasured_zan){
|
|
|
$treasured_zan->delete();
|
|
|
model('treasured')->where('id',$treasured_id)->setDec('zan_num');
|
|
|
$this->success('查询成功',['code'=>0,'msg'=>'取消点赞成功']);
|
|
|
}
|
|
|
//3.增加点赞
|
|
|
//4.增加点赞
|
|
|
model('treasured_zan')->create(['user_id'=>$this->auth->id,'treasured_id'=>$treasured_id]);
|
|
|
//4.返回结果
|
|
|
//5.增加点赞数量
|
|
|
model('treasured')->where('id',$treasured_id)->setInc('zan_num');
|
|
|
//6.返回结果
|
|
|
$this->success('查询成功',['code'=>1,'msg'=>'点赞成功']);
|
|
|
}
|
|
|
|
...
|
...
|
|