调整代码格式及使用常量去替换常用值
This commit is contained in:
@@ -4,6 +4,7 @@ namespace app\cunkebao\controller\device;
|
||||
|
||||
use app\common\model\Device as DeviceModel;
|
||||
use app\common\model\DeviceUser as DeviceUserModel;
|
||||
use app\common\model\User as UserModel;
|
||||
use app\common\model\WechatFriend;
|
||||
use app\cunkebao\controller\BaseController;
|
||||
use library\ResponseHelper;
|
||||
@@ -34,7 +35,6 @@ class GetDeviceListV1Controller extends BaseController
|
||||
}
|
||||
|
||||
$where['d.companyId'] = $this->getUserInfo('companyId');
|
||||
$where['d.deleteTime'] = 0;
|
||||
|
||||
return array_merge($params, $where);
|
||||
}
|
||||
@@ -72,7 +72,11 @@ class GetDeviceListV1Controller extends BaseController
|
||||
protected function getDeviceList(array $where, int $page = 1, int $limit = 10): \think\Paginator
|
||||
{
|
||||
$query = DeviceModel::alias('d')
|
||||
->field(['d.id', 'd.imei', 'd.memo', 'l.wechatId', 'd.alive', 'wa.nickname', 'wa.alias', '0 totalFriend'])
|
||||
->field([
|
||||
'd.id', 'd.imei', 'd.memo', 'd.alive',
|
||||
'l.wechatId',
|
||||
'wa.nickname', 'wa.alias', '0 totalFriend'
|
||||
])
|
||||
->leftJoin('device_wechat_login l', 'd.id = l.deviceId')
|
||||
->leftJoin('wechat_account wa', 'l.wechatId = wa.wechatId')
|
||||
->order('d.id desc');
|
||||
@@ -119,7 +123,7 @@ class GetDeviceListV1Controller extends BaseController
|
||||
public function index()
|
||||
{
|
||||
try {
|
||||
if ($this->getUserInfo('isAdmin') == 1) {
|
||||
if ($this->getUserInfo('isAdmin') == UserModel::ADMIN_STP) {
|
||||
$where = $this->makeWhere();
|
||||
$result = $this->getDeviceList($where);
|
||||
} else {
|
||||
@@ -129,7 +133,7 @@ class GetDeviceListV1Controller extends BaseController
|
||||
|
||||
return ResponseHelper::success(
|
||||
[
|
||||
'list' => $this->countFriend($result),
|
||||
'list' => $this->countFriend($result),
|
||||
'total' => $result->total(),
|
||||
]
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user