first commit
This commit is contained in:
96
app/adminapi/lists/user/UserNoticeLists.php
Normal file
96
app/adminapi/lists/user/UserNoticeLists.php
Normal file
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
namespace app\adminapi\lists\user;
|
||||
|
||||
|
||||
use app\adminapi\lists\BaseAdminDataLists;
|
||||
use app\common\model\user\UserNotice;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
|
||||
|
||||
/**
|
||||
* 用户消息列表
|
||||
* Class UserNoticeLists
|
||||
* @package app\adminapi\listsuser
|
||||
*/
|
||||
class UserNoticeLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author BD
|
||||
* @date 2024/05/26 00:36
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['un.title', 'un.read', 'un.notice_type'],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 搜索条件
|
||||
* @author 段誉
|
||||
* @date 2023/2/24 16:08
|
||||
*/
|
||||
public function queryWhere()
|
||||
{
|
||||
$where = [];
|
||||
// 用户
|
||||
if (!empty($this->params['user_info'])) {
|
||||
$where[] = ['u.sn|u.account|u.mobile', '=', $this->params['user_info']];
|
||||
}
|
||||
|
||||
// 创建时间
|
||||
if (!empty($this->params['start_time']) && !empty($this->params['end_time'])) {
|
||||
$time = [strtotime($this->params['start_time']), strtotime($this->params['end_time'])];
|
||||
$where[] = ['un.create_time', 'between', $time];
|
||||
}
|
||||
|
||||
return $where;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取用户消息列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author BD
|
||||
* @date 2024/05/26 00:36
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
$field = 'un.id,un.user_id,un.title,un.content,un.read,un.notice_type,un.create_time';
|
||||
$field .= ',u.account,u.sn as u_sn,u.mobile';
|
||||
return UserNotice::alias('un')
|
||||
->join('user u', 'u.id = un.user_id')
|
||||
->field($field)
|
||||
->where($this->queryWhere())
|
||||
->where($this->searchWhere)
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['un.id' => 'desc'])
|
||||
->select()
|
||||
->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取用户消息数量
|
||||
* @return int
|
||||
* @author BD
|
||||
* @date 2024/05/26 00:36
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return UserNotice::alias('un')
|
||||
->join('user u', 'u.id = un.user_id')
|
||||
->where($this->queryWhere())
|
||||
->where($this->searchWhere)
|
||||
->count();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user