You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
114 lines
4.2 KiB
114 lines
4.2 KiB
<?php
|
|
/**
|
|
* Created by ETEDU.
|
|
* User: Leo Chu
|
|
* Date: 2017/3/28 0028
|
|
* Time: 15:45
|
|
*/
|
|
|
|
namespace app\cult4\model;
|
|
|
|
use think\Model;
|
|
|
|
|
|
/**
|
|
* 文化四板上传文件列表
|
|
* @package app\admin\model
|
|
*/
|
|
class Cult4upfiles extends Model
|
|
{
|
|
/**
|
|
* 根据文件id获取文件信息,返回值为数组
|
|
* @param int $fid 文件id
|
|
* @return array 文件信息数组
|
|
*/
|
|
public static function getFileInfo($fid)
|
|
{
|
|
$fileInfo = Db()->name('cult4upfiles')->where("file_id='$fid'")->find();
|
|
$fileInfo[$fid]=$fileInfo?:array();
|
|
return $fileInfo[$fid];
|
|
}
|
|
/**
|
|
* 根据模板文件id获取文件信息,返回值为数组
|
|
* @param int $ftype_id 模板文件id
|
|
* @param int $apply_id 申请id
|
|
* @return array 文件信息数组
|
|
*/
|
|
public static function getFileInfoFromTempFile($ftype_id,$apply_id)
|
|
{
|
|
$where['ftype_id']=array('eq', $ftype_id);
|
|
$where['new_flag']=array('eq', 1);
|
|
$where['apply_id']=array('eq', $apply_id);
|
|
$fileInfo = Db()->name('cult4upfiles')->where($where)->order('addorder desc')->find();
|
|
$fileInfo[$ftype_id]=$fileInfo?:array();
|
|
return $fileInfo[$ftype_id];
|
|
}
|
|
/**
|
|
* 根据文件id获取文件信息,返回值为数组
|
|
* @param int $fid 文件id
|
|
* @return array 文件信息数组
|
|
*/
|
|
public static function getFileInfoFromFileID($fid)
|
|
{
|
|
$where['file_id']=array('eq', $fid);
|
|
$where['new_flag']=array('eq', 1);
|
|
$fileInfo = Db()->name('cult4upfiles')->where($where)->order('addorder desc')->find();
|
|
$fileInfo[$fid]=$fileInfo?:array();
|
|
return $fileInfo[$fid];
|
|
}
|
|
/**
|
|
* 根据apply_id获取该申请在$status下的全部未审核文件数量,返回值为数量
|
|
* @param int $apply_id 申请id
|
|
* @param int $status 状态数组
|
|
* @return int 文件数量
|
|
*/
|
|
public static function getNotPassFilesCntFromApplyIDCurrStatus($apply_id,$status)
|
|
{
|
|
$where['apply_id']=array('eq', $apply_id);
|
|
$where['new_flag']=array('eq', 1);
|
|
$where['status'] = is_array($status)?array('in',$status):array('eq',$status);
|
|
$where['flag']=array('eq', 0);
|
|
$fileCnt = Db()->name('cult4upfiles')->where($where)->count();
|
|
return $fileCnt;
|
|
}
|
|
/**
|
|
* 根据apply_id获取该申请在<=$status下的全部未审核文件数量,返回值为数量
|
|
* @param int $apply_id 申请id
|
|
* @param int $status 状态
|
|
* @return int 文件数量
|
|
*/
|
|
public static function getNotPassFilesCntFromApplyID($apply_id,$status)
|
|
{
|
|
$where['apply_id']=array('eq', $apply_id);
|
|
$where['new_flag']=array('eq', 1);
|
|
$where['status']=array('elt', $status);
|
|
$where['flag']=array('eq', 0);
|
|
$fileCnt = Db()->name('cult4upfiles')->where($where)->count();
|
|
return $fileCnt;
|
|
}
|
|
/**
|
|
* 上传文件列表
|
|
* @param array
|
|
* @param int $apply_id 查询条件(申请ID)
|
|
* @param int $ftype 查询条件(-1:包括临时和固定 0:固定 1:临时 2:模板)
|
|
* @param int $status 查询条件(文件类型显示在哪个状态)
|
|
* @param int $ftype_id 查询条件(文件类型ID)
|
|
* @param int $new_flag 查询条件(-1:包括历史记录,0取所有历史记录,1取最新记录)
|
|
* @param string $order 结果排序
|
|
* @return mixed
|
|
*/
|
|
public static function getList($apply_id,$ftype=-1,$status=-1,$ftype_id=-1,$new_flag=-1,$order='file_id,status,ftype,apply_id')
|
|
{
|
|
$where=array();
|
|
|
|
//根据状态值取出对应状态的数据
|
|
$where['apply_id'] = array('eq', $apply_id);
|
|
if($ftype != -1)$where['ftype'] = array('eq', $ftype);
|
|
if($status != -1&&$status)$where['status'] = is_array($status)?array('in',$status):$status;
|
|
if($ftype_id != -1&&$ftype_id)$where['ftype_id'] = array('eq',$ftype_id);
|
|
if($new_flag != -1)$where['new_flag'] = array('eq',$new_flag);
|
|
|
|
$find=self::where($where)->order($order)->select();
|
|
return $find;
|
|
}
|
|
}
|