118 lines
2.8 KiB
PHP
118 lines
2.8 KiB
PHP
<?php
|
|
/**
|
|
* Dataorder 数据申请相关
|
|
*/
|
|
class Dataorder
|
|
{
|
|
public $db; //PDO
|
|
|
|
public $tbl_Metadata = "metadata"; //元数据数据表
|
|
public $tbl_Metadata_temp = "metadata_temp"; //新元数据缓存表
|
|
public $tbl_Dataorder = "dataorder"; //dataorder表
|
|
public $tbl_Offlineapp = "offlineapp"; //offlineapp
|
|
public $tbl_fav = "favorite"; //收藏表
|
|
|
|
function __construct($db)
|
|
{
|
|
$this->db = $db;
|
|
}
|
|
|
|
public function fetchAllOfflineApp($statu=0,$q=""){
|
|
|
|
$wheresql = array();
|
|
|
|
if ($statu==4)
|
|
$wheresql[] = " (o.ts_approved is null and o.pdflink is not null and d.status=4) ";
|
|
elseif ($statu==-1)
|
|
$wheresql[] = " (o.pdflink is not null and o.status=-1)";
|
|
elseif ($statu == 3)
|
|
$wheresql[] = " (o.applicationform is not null and d.status=3 ) ";
|
|
elseif ($statu == 5)
|
|
$wheresql[] = " (o.status=5) ";
|
|
else
|
|
$wheresql[] = " (o.ts_approved is null and o.pdflink is not null and d.status in (3,4))";
|
|
|
|
if(!empty($q))
|
|
{
|
|
$wheresql[] = " (o.username LIKE '%$q%' OR o.unit LIKE '%$q%' OR o.project LIKE '%$q%' OR o.address LIKE '%$q%') ";
|
|
}
|
|
|
|
if(count($wheresql)>0)
|
|
{
|
|
$wheresql = " WHERE ".join(" AND ",$wheresql);
|
|
}else{
|
|
$wheresql = "";
|
|
}
|
|
|
|
$sql = "select distinct(o.*),d.status as datastatus from ".$this->tbl_Offlineapp." o
|
|
left join ".$this->tbl_Dataorder." d on o.id = d.offlineappid
|
|
$wheresql
|
|
order by o.ts_created desc";
|
|
|
|
$rs = $this->db->query($sql);
|
|
$rows = $rs->fetchAll();
|
|
|
|
return $rows;
|
|
}
|
|
|
|
//收藏元数据
|
|
public function fav($uid,$uuid)
|
|
{
|
|
if(!is_numeric($uid))
|
|
{
|
|
return false;
|
|
}
|
|
|
|
if(!preg_match("/^[0-9A-Za-z]{8}-[0-9A-Za-z]{4}-[0-9A-Za-z]{4}-[0-9A-Za-z]{4}-[0-9A-Za-z]{12}$/",$uuid))
|
|
{
|
|
return false;
|
|
}
|
|
|
|
$sql = "SELECT * FROM ".$this->tbl_fav." WHERE uid=$uid AND uuid='$uuid'";
|
|
$rs = $this->db->query($sql);
|
|
$rows = $rs->fetchAll();
|
|
if(count($rows)>0)
|
|
{
|
|
return "您已经收藏过此元数据";
|
|
}
|
|
|
|
$sql = "INSERT INTO ".$this->tbl_fav." (uid,uuid) VALUES ($uid,'$uuid')";
|
|
if($this->db->exec($sql))
|
|
{
|
|
return true;
|
|
}else{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
//移除收藏
|
|
public function favRemove($uid,$uuid){
|
|
if(!is_numeric($uid))
|
|
{
|
|
return false;
|
|
}
|
|
|
|
if(!preg_match("/^[0-9A-Za-z]{8}-[0-9A-Za-z]{4}-[0-9A-Za-z]{4}-[0-9A-Za-z]{4}-[0-9A-Za-z]{12}$/",$uuid))
|
|
{
|
|
return false;
|
|
}
|
|
|
|
$sql = "SELECT * FROM ".$this->tbl_fav." WHERE uid=$uid AND uuid='$uuid'";
|
|
$rs = $this->db->query($sql);
|
|
$rows = $rs->fetchAll();
|
|
if(count($rows)<1)
|
|
{
|
|
return "参数错误";
|
|
}
|
|
|
|
$sql = "DELETE FROM ".$this->tbl_fav." WHERE uid=$uid AND uuid='$uuid'";
|
|
if($this->db->exec($sql))
|
|
{
|
|
return true;
|
|
}else{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
}
|