【类 型】:feat
【原 因】:获取管理员公告列表 接口 【过 程】: 【影 响】: # 类型 包含: # feat:新功能(feature) # fix:修补bug # docs:文档(documentation) # style: 格式(不影响代码运行的变动) # refactor:重构(即不是新增功能,也不是修改bug的代码变动) # test:增加测试 # chore:构建过程或辅助工具的变动
This commit is contained in:
parent
b2c303daf7
commit
70748438bc
@ -304,6 +304,40 @@ class AdminController extends PublicController
|
||||
echo json_encode(array('status' => 0, 'msg' => '公告发布失败'));
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @description 获取公告列表(当前管理员 + 未过期)
|
||||
*/
|
||||
public function getMessageList()
|
||||
{
|
||||
$adminId = $this->admin_id;
|
||||
$now = time();
|
||||
|
||||
// 构造查询条件
|
||||
$where = array(
|
||||
'admin_id' => $adminId,
|
||||
'end_time' => array('gt', $now) // 未过期
|
||||
);
|
||||
|
||||
// 查询字段
|
||||
$fields = array('id', 'tit', 'message', 'end_time', 'add_time');
|
||||
|
||||
// 数据库查询
|
||||
$messageDb = D('message');
|
||||
$messageList = $messageDb->where($where)->field($fields)->order('add_time DESC')->select();
|
||||
|
||||
if ($messageList !== false) {
|
||||
echo json_encode(array(
|
||||
'status' => 1,
|
||||
'msg' => '获取成功',
|
||||
'messageList' => $messageList
|
||||
));
|
||||
} else {
|
||||
echo json_encode(array(
|
||||
'status' => 0,
|
||||
'msg' => '获取失败'
|
||||
));
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @description: 分类列表
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user