调整代码格式及使用常量去替换常用值

This commit is contained in:
柳清爽
2025-05-08 10:39:53 +08:00
parent b5939b36b3
commit 0426485177
31 changed files with 230 additions and 191 deletions

View File

@@ -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(),
]
);