更新用户数据

This commit is contained in:
yaooo 2023-11-25 15:48:26 +08:00
parent 1a7119f42a
commit ae0bc19500
11 changed files with 130 additions and 26 deletions

View File

@ -2,8 +2,8 @@ const config = {
terminal: 1, //终端
title: '后台管理系统', //网站默认标题
version: '1.6.0', //版本号
baseUrl: `${import.meta.env.VITE_APP_BASE_URL || ''}/`, //请求接口域名
// baseUrl: 'http://127.0.0.1:30005/',
// baseUrl: `${import.meta.env.VITE_APP_BASE_URL || ''}/`, //请求接口域名
baseUrl: 'http://127.0.0.1:30005/',
urlPrefix: 'adminapi', //请求默认前缀
timeout: 10 * 1000 //请求超时时长
}

View File

@ -34,7 +34,6 @@ class BaseAdminController extends BaseLikeAdminController
if (isset($this->request->adminInfo) && $this->request->adminInfo) {
$this->adminInfo = $this->request->adminInfo;
$this->adminId = $this->request->adminInfo['admin_id'];
$this->userId = $this->request->adminInfo['user_id'];
}
}

View File

@ -44,6 +44,19 @@ class AirMonitorLists extends BaseAdminDataLists implements ListsSearchInterface
return array_intersect(array_keys($this->params), $allowSearch);
}
public function userSearch(): array
{
$userWhere['user_id'] = 0;
// 超级管理员数据
if ($this->adminInfo['root'] && !$this->adminInfo['user_id']) {
unset($userWhere['user_id']);
}
// 普通用户数据
if (!$this->adminInfo['root'] && $this->adminInfo['user_id']) {
$userWhere['user_id'] = $this->adminInfo['user_id'];
}
return $userWhere;
}
/**
* @notes 获取列表
@ -56,7 +69,7 @@ class AirMonitorLists extends BaseAdminDataLists implements ListsSearchInterface
*/
public function lists(): array
{
return AirMonitor::withSearch($this->setSearch(), $this->params)->with('device')
return AirMonitor::withSearch($this->setSearch(), $this->params)->where($this->userSearch())->with('device')
->field(['id', 'device_id', 'wind_direction', 'wind_speed', 'temperature', 'moisture', 'co2_content', 'pressure', 'rainfall', 'light_intensity', 'create_time'])
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
@ -73,7 +86,7 @@ class AirMonitorLists extends BaseAdminDataLists implements ListsSearchInterface
*/
public function count(): int
{
return AirMonitor::withSearch($this->setSearch(), $this->params)->count();
return AirMonitor::withSearch($this->setSearch(), $this->params)->where($this->userSearch())->count();
}
}

View File

@ -45,6 +45,19 @@ class DeviceLists extends BaseAdminDataLists implements ListsSearchInterface
];
}
public function userSearch(): array
{
$userWhere['d.user_id'] = 0;
// 超级管理员数据
if ($this->adminInfo['root'] && !$this->adminInfo['user_id']) {
unset($userWhere['user_id']);
}
// 普通用户数据
if (!$this->adminInfo['root'] && $this->adminInfo['user_id']) {
$userWhere['d.user_id'] = $this->adminInfo['user_id'];
}
return $userWhere;
}
/**
* @notes 获取列表
@ -57,11 +70,11 @@ class DeviceLists extends BaseAdminDataLists implements ListsSearchInterface
*/
public function lists(): array
{
return Db::name('device')->where($this->searchWhere)
->alias('d')
->leftJoin('land_device ld','ld.device_id = d.id')
->leftJoin('land l','l.id = ld.land_id')
->field('d.*, ld.land_id, l.title')
return Db::name('device')->alias('d')
->where($this->searchWhere)->where($this->userSearch())
// ->leftJoin('land_device ld','ld.device_id = d.id')
// ->leftJoin('land l','l.id = ld.land_id')
// ->field('d.*, ld.land_id, l.title')
->limit($this->limitOffset, $this->limitLength)
->order(['d.id' => 'desc'])
->select()
@ -77,7 +90,7 @@ class DeviceLists extends BaseAdminDataLists implements ListsSearchInterface
*/
public function count(): int
{
return Db::name('device')->where($this->searchWhere)->alias('d')->count();
return Db::name('device')->alias('d')->where($this->searchWhere)->where($this->userSearch())->count();
}
}

View File

@ -47,6 +47,19 @@ class MonitorAlarmLists extends BaseAdminDataLists implements ListsSearchInterfa
return array_intersect(array_keys($this->params), $allowSearch);
}
public function userSearch(): array
{
$userWhere['user_id'] = 0;
// 超级管理员数据
if ($this->adminInfo['root'] && !$this->adminInfo['user_id']) {
unset($userWhere['user_id']);
}
// 普通用户数据
if (!$this->adminInfo['root'] && $this->adminInfo['user_id']) {
$userWhere['user_id'] = $this->adminInfo['user_id'];
}
return $userWhere;
}
/**
* @notes 获取列表
@ -59,7 +72,7 @@ class MonitorAlarmLists extends BaseAdminDataLists implements ListsSearchInterfa
*/
public function lists(): array
{
return MonitorAlarm::withSearch($this->setSearch(), $this->params)->with('device')
return MonitorAlarm::withSearch($this->setSearch(), $this->params)->where($this->userSearch())->with('device')
->field(['id', 'device_id', 'type', 'content', 'value', 'solution', 'create_time'])
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
@ -76,7 +89,7 @@ class MonitorAlarmLists extends BaseAdminDataLists implements ListsSearchInterfa
*/
public function count(): int
{
return MonitorAlarm::withSearch($this->setSearch(), $this->params)->count();
return MonitorAlarm::withSearch($this->setSearch(), $this->params)->where($this->userSearch())->count();
}
}

View File

@ -44,6 +44,19 @@ class SoilMonitorLists extends BaseAdminDataLists implements ListsSearchInterfac
return array_intersect(array_keys($this->params), $allowSearch);
}
public function userSearch(): array
{
$userWhere['user_id'] = 0;
// 超级管理员数据
if ($this->adminInfo['root'] && !$this->adminInfo['user_id']) {
unset($userWhere['user_id']);
}
// 普通用户数据
if (!$this->adminInfo['root'] && $this->adminInfo['user_id']) {
$userWhere['user_id'] = $this->adminInfo['user_id'];
}
return $userWhere;
}
/**
* @notes 获取列表
@ -56,7 +69,7 @@ class SoilMonitorLists extends BaseAdminDataLists implements ListsSearchInterfac
*/
public function lists(): array
{
return SoilMonitor::withSearch($this->setSearch(), $this->params)->with('device')
return SoilMonitor::withSearch($this->setSearch(), $this->params)->where($this->userSearch())->with('device')
->field(['id', 'device_id', 'temperature', 'moisture', 'conductivity', 'ph', 'n_content', 'p_content', 'k_content', 'create_time'])
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
@ -73,7 +86,7 @@ class SoilMonitorLists extends BaseAdminDataLists implements ListsSearchInterfac
*/
public function count(): int
{
return SoilMonitor::withSearch($this->setSearch(), $this->params)->count();
return SoilMonitor::withSearch($this->setSearch(), $this->params)->where($this->userSearch())->count();
}
}

View File

@ -43,6 +43,19 @@ class LandLists extends BaseAdminDataLists implements ListsSearchInterface
];
}
public function userSearch(): array
{
$userWhere['user_id'] = 0;
// 超级管理员数据
if ($this->adminInfo['root'] && !$this->adminInfo['user_id']) {
unset($userWhere['user_id']);
}
// 普通用户数据
if (!$this->adminInfo['root'] && $this->adminInfo['user_id']) {
$userWhere['user_id'] = $this->adminInfo['user_id'];
}
return $userWhere;
}
/**
* @notes 获取列表
@ -55,7 +68,7 @@ class LandLists extends BaseAdminDataLists implements ListsSearchInterface
*/
public function lists(): array
{
return Land::where($this->searchWhere)->with('user')
return Land::where($this->searchWhere)->where($this->userSearch())->with('user')
->field(['id', 'user_id', 'title', 'total_area', 'residual_area', 'province_code', 'province_name', 'city_code', 'city_name', 'county_code', 'county_name', 'town_code', 'town_name', 'village_code', 'village_name', 'group_code', 'group_name', 'longitude', 'latitude', 'master_name', 'master_phone'])
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
@ -72,7 +85,7 @@ class LandLists extends BaseAdminDataLists implements ListsSearchInterface
*/
public function count(): int
{
return Land::where($this->searchWhere)->count();
return Land::where($this->searchWhere)->where($this->userSearch())->count();
}
}

View File

@ -42,6 +42,19 @@ class LandPlantActionLists extends BaseAdminDataLists implements ListsSearchInte
];
}
public function userSearch(): array
{
$userWhere['user_id'] = 0;
// 超级管理员数据
if ($this->adminInfo['root'] && !$this->adminInfo['user_id']) {
unset($userWhere['user_id']);
}
// 普通用户数据
if (!$this->adminInfo['root'] && $this->adminInfo['user_id']) {
$userWhere['user_id'] = $this->adminInfo['user_id'];
}
return $userWhere;
}
/**
* @notes 获取列表
@ -54,7 +67,7 @@ class LandPlantActionLists extends BaseAdminDataLists implements ListsSearchInte
*/
public function lists(): array
{
return LandPlantAction::where($this->searchWhere)->with('landPlant')
return LandPlantAction::where($this->searchWhere)->where($this->userSearch())->with('landPlant')
->field(['id', 'plant_id', 'type', 'type_text', 'detail'])
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
@ -71,7 +84,7 @@ class LandPlantActionLists extends BaseAdminDataLists implements ListsSearchInte
*/
public function count(): int
{
return LandPlantAction::where($this->searchWhere)->count();
return LandPlantAction::where($this->searchWhere)->where($this->userSearch())->count();
}
}

View File

@ -57,6 +57,19 @@ class LandPlantLists extends BaseAdminDataLists implements ListsSearchInterface
return $where;
}
public function userSearch(): array
{
$userWhere['user_id'] = 0;
// 超级管理员数据
if ($this->adminInfo['root'] && !$this->adminInfo['user_id']) {
unset($userWhere['user_id']);
}
// 普通用户数据
if (!$this->adminInfo['root'] && $this->adminInfo['user_id']) {
$userWhere['user_id'] = $this->adminInfo['user_id'];
}
return $userWhere;
}
/**
* @notes 获取列表
@ -69,7 +82,7 @@ class LandPlantLists extends BaseAdminDataLists implements ListsSearchInterface
*/
public function lists(): array
{
return LandPlant::where($this->queryWhere())->where($this->searchWhere)->with('land')
return LandPlant::where($this->queryWhere())->where($this->searchWhere)->where($this->userSearch())->with('land')
->field(['id', 'land_id', 'kind', 'breed', 'area', 'user', 'status', 'pic', 'qr_code', 'plant_date', 'remark'])
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
@ -86,7 +99,7 @@ class LandPlantLists extends BaseAdminDataLists implements ListsSearchInterface
*/
public function count(): int
{
return LandPlant::where($this->queryWhere())->where($this->searchWhere)->count();
return LandPlant::where($this->queryWhere())->where($this->searchWhere)->where($this->userSearch())->count();
}
}

View File

@ -39,6 +39,20 @@ class UserLists extends BaseAdminDataLists implements ListsExcelInterface
return array_intersect(array_keys($this->params), $allowSearch);
}
public function userSearch(): array
{
$userWhere['id'] = 0;
// 超级管理员数据
if ($this->adminInfo['root'] && !$this->adminInfo['user_id']) {
unset($userWhere['id']);
}
// 普通用户数据
if (!$this->adminInfo['root'] && $this->adminInfo['user_id']) {
$userWhere['id'] = $this->adminInfo['user_id'];
}
return $userWhere;
}
/**
* @notes 获取用户列表
* @return array
@ -51,7 +65,7 @@ class UserLists extends BaseAdminDataLists implements ListsExcelInterface
public function lists(): array
{
$field = "id,sn,nickname,sex,avatar,account,mobile,channel,is_disable,create_time";
$lists = User::withSearch($this->setSearch(), $this->params)
$lists = User::withSearch($this->setSearch(), $this->params)->where($this->userSearch())
->limit($this->limitOffset, $this->limitLength)
->field($field)
->order('id desc')
@ -73,7 +87,7 @@ class UserLists extends BaseAdminDataLists implements ListsExcelInterface
*/
public function count(): int
{
return User::withSearch($this->setSearch(), $this->params)->count();
return User::withSearch($this->setSearch(), $this->params)->where($this->userSearch())->count();
}