【类 型】:
【原 因】: 【过 程】: 【影 响】:
This commit is contained in:
parent
17db93bd7d
commit
94f6534713
@ -287,6 +287,8 @@ class AdminController extends PublicController
|
||||
$dataList = array();
|
||||
foreach ($idArr as $admin_id) {
|
||||
$dataList[] = array(
|
||||
'shop_id' => $this->tokenShop_id,
|
||||
'by_admin_id' => $this->admin_id,
|
||||
'admin_id' => intval($admin_id),
|
||||
'message' => $message,
|
||||
'tit' => $tit,
|
||||
@ -305,10 +307,15 @@ class AdminController extends PublicController
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @description 获取公告列表(当前管理员 + 未过期)
|
||||
* @description 获取公告列表(未过期),连表获取 发送者管理员信息
|
||||
*/
|
||||
public function getMessageList()
|
||||
{
|
||||
// 权限判断
|
||||
if ($this->tokenShop_id != C('powerId')) {
|
||||
$where['m.shop_id'] = $this->tokenShop_id; // 非总管理员 只返回自己的账户信息
|
||||
}
|
||||
|
||||
$adminId = $this->admin_id; //当前管理员
|
||||
$now = time();
|
||||
|
||||
@ -318,12 +325,28 @@ class AdminController extends PublicController
|
||||
'end_time' => array('gt', $now) // 未过期
|
||||
);
|
||||
|
||||
// 查询字段
|
||||
$fields = array('id', 'tit', 'message', 'end_time', 'add_time');
|
||||
// 查询字段,注意字段前加表别名
|
||||
$fields = array(
|
||||
'm.id',
|
||||
'm.admin_id',
|
||||
'm.by_admin_id',
|
||||
'm.tit',
|
||||
'm.message',
|
||||
'm.end_time',
|
||||
'm.add_time',
|
||||
'a.name' => 'admin_name',
|
||||
'a.uname' => 'admin_uname'
|
||||
);
|
||||
|
||||
// 数据库查询
|
||||
$messageDb = D('message');
|
||||
$messageList = $messageDb->where($where)->field($fields)->order('add_time DESC')->select();
|
||||
$messageDb = M('message');
|
||||
$messageList = $messageDb
|
||||
->alias('m')
|
||||
->join('__ADMINUSER__ a ON m.by_admin_id = a.id', 'LEFT')
|
||||
->where($where)
|
||||
->field($fields)
|
||||
->order('m.add_time DESC')
|
||||
->select();
|
||||
|
||||
if ($messageList !== false) {
|
||||
echo json_encode(array(
|
||||
@ -338,6 +361,54 @@ class AdminController extends PublicController
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 获取全部公告 不只 和自己admin_id相关的 且不考虑过期
|
||||
*/
|
||||
public function getAllMessageList()
|
||||
{
|
||||
// 权限判断
|
||||
if ($this->tokenShop_id != C('powerId')) {
|
||||
$where['m.shop_id'] = $this->tokenShop_id; // 非总管理员 只返回自己的账户信息
|
||||
}
|
||||
|
||||
// 查询字段,注意字段前加表别名
|
||||
$fields = array(
|
||||
'm.id',
|
||||
'm.admin_id',
|
||||
'm.by_admin_id',
|
||||
'm.tit',
|
||||
'm.message',
|
||||
'm.end_time',
|
||||
'm.add_time',
|
||||
'a.name' => 'admin_name',
|
||||
'a.uname' => 'admin_uname'
|
||||
);
|
||||
|
||||
// 数据库查询
|
||||
$messageDb = M('message');
|
||||
$messageList = $messageDb
|
||||
->alias('m')
|
||||
->join('__ADMINUSER__ a ON m.by_admin_id = a.id', 'LEFT')
|
||||
->where($where)
|
||||
->field($fields)
|
||||
->order('m.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