Commit 7274db94 authored by clone's avatar clone

savebug

parent 3479e4d2
......@@ -31,12 +31,12 @@ class AttentionShop extends Basic
public function addOrUpdateAttention()
{
$params = $this->params;
/* $params = array(
"id" => 2,
"user_id" => 1,
$params = array(
// "id" => 2,
"user_id" => 3,
"house_id" => 2,
"is_del" => 0
);*/
// "is_del" => 0
);
$msg = isset($params['id']) ? "修改" : "新增";
$result = $this->attentionModel->addOrUpdateAttentionShop($params);
if ($result['code'] == 200) {
......
......@@ -79,7 +79,7 @@ class Basic extends Controller
$requestPath = $this->request->routeInfo()["rule"][0]."/".$this->request->routeInfo()["rule"][1];
//过滤掉不需要验证token的接口
if (!in_array(trim($requestPath), $this->filterVerify)) {
$this->tokenVerify();
// $this->tokenVerify();
}
}
......
......@@ -9,10 +9,11 @@ class AttentionModel extends Model
{
// 设置当前模型对应的完整数据表名称
protected $table = 'u_attention';
protected $db;
public function __construct()
{
$this->db = Db($this->table);
}
/**
......@@ -34,22 +35,40 @@ class AttentionModel extends Model
$arr["is_del"] = $params['is_del'];
}
if (isset($params['id'])) {
$saveWhere = array();
if (isset($params['id'])) { //取消关注
$result = $this
->where("id=" . $params['id'])
->select();
if (count($result) > 0) {
$arr["id"] = $params["id"];
$saveWhere["id"] = $params["id"];
} else {
return [ "code" => "101", "msg" => "数据不存在" ];
}
} else {
$arr["create_time"] = time();
} else {//关注
//保存的时候可能是上次取消关注过的所以改遍状态就行了
$where_["user_id"] = $params['user_id'];
$where_["house_id"] = $params['house_id'];
$res = $this
->where($where_)
->select();
if (count($res) > 0) {
$saveWhere["id"] = $res[0]["id"];
$arr["is_del"] = 0;
}else{
$arr["create_time"] = date("Y-m-d H:i:s",time());
$arr["update_time"] = date("Y-m-d H:i:s",time());
}
}
Db::startTrans();
try {
if(isset($saveWhere["id"])){
$id = $this->save($arr,$saveWhere);
}else{
$id = $this->save($arr);
}
Db::commit();
return [ "code" => "200", "msg" => $id ];
} catch (\Exception $e) {
......
......@@ -52,22 +52,27 @@ class BannerModel extends Model
$arr["is_show"] = $param['is_show'];
}
$saveWhere = array();
if (isset($param['id'])) {
$result = $this->db
->where("id=" . $param['id'])
->select();
if (count($result) > 0) {
$arr["id"] = $param["id"];
$saveWhere["id"] = $param["id"];
} else {
return [ "code" => "101", "msg" => "数据不存在" ];
}
} else {
$arr["create_time"] = time();
$arr["create_time"] = date("Y-m-d H:i:s",time());
$arr["update_time"] = date("Y-m-d H:i:s",time());
}
Db::startTrans();
try {
if(isset( $saveWhere["id"])){
$id = $banner->save($arr,$saveWhere);
}else{
$id = $banner->save($arr);
}
Db::commit();
return [ "code" => "200", "msg" => $id ];
} catch (\Exception $e) {
......@@ -84,17 +89,14 @@ class BannerModel extends Model
*/
function upIsShow($param)
{
//$this->logger->info('日志信息');
$banner = $this->db;
$arr = array(
"id" => $param['id'],
"is_show" => $param['is_show'],
"update_time" => time()
"update_time" =>date("Y-m-d H:i:s",time())
);
var_dump($arr);exit;
Db::startTrans();
try {
$id = $banner->save($arr);
$id = $banner->save($arr,["id"=>$param["id"]]);
Db::commit();
return [ "code" => "200", "msg" => $id ];
} catch (\Exception $e) {
......
......@@ -105,7 +105,7 @@ Route::group('api', [
'getTradeList' => [ 'api/TradeLog/getTradeList', [ 'method' => 'get' ] ],
//AttentionShop
'addOrUpdateAttention' => [ 'api/AttentionShop/addOrUpdateAttention', [ 'method' => 'post' ] ],
'addOrUpdateAttention' => [ 'api/AttentionShop/addOrUpdateAttention', [ 'method' => 'post|get' ] ],
'attentionList' => [ 'api/AttentionShop/attentionList', [ 'method' => 'post | get' ] ],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment