Commit 7274db94 authored by clone's avatar clone

savebug

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