1
0
mirror of https://gitee.com/zoujingli/ThinkAdmin.git synced 2025-04-06 03:58:04 +08:00

修改代码

This commit is contained in:
邹景立 2021-04-07 15:48:18 +08:00
parent 44af0fa6a3
commit a5f11218f8
4 changed files with 15 additions and 12 deletions
app/data/controller/api
vendor

@ -43,11 +43,16 @@ abstract class Auth extends Controller
*/ */
protected function initialize() protected function initialize()
{ {
// 接口数据类型 // 接收接口类型
$this->type = $this->request->header('api-name') ?: input('api'); $this->type = $this->request->request('api');
$this->type = $this->type ?: $this->request->header('api-name');
$this->type = $this->type ?: $this->request->header('api-type'); $this->type = $this->type ?: $this->request->header('api-type');
if (empty($this->type) || empty(UserAdminService::TYPES[$this->type])) { // 检查接口类型
$this->error("接口支付未定义!"); if (empty($this->type)) {
$this->error("未获取到接口类型字段!");
}
if (isset(UserAdminService::TYPES[$this->type])) {
$this->error("接口类型[{$this->type}]未定义!");
} }
// 获取用户数据 // 获取用户数据
$this->user = $this->getUser(); $this->user = $this->getUser();
@ -84,7 +89,7 @@ abstract class Auth extends Controller
protected function checkUserStatus() protected function checkUserStatus()
{ {
if (empty($this->user['status'])) { if (empty($this->user['status'])) {
$this->error('抱歉,账户已被冻结!'); $this->error('账户已被冻结!');
} }
} }

@ -45,7 +45,7 @@ class Address extends Auth
unset($data['code']); unset($data['code']);
$count = $this->app->db->name($this->table)->where($data)->count(); $count = $this->app->db->name($this->table)->where($data)->count();
if ($count > 0) $this->error('抱歉,该地址已经存在!'); if ($count > 0) $this->error('抱歉,该地址已经存在!');
$data['code'] = CodeExtend::uniqidDate(12, 'A'); $data['code'] = CodeExtend::uniqidDate(20, 'A');
if ($this->app->db->name($this->table)->insert($data) === false) { if ($this->app->db->name($this->table)->insert($data) === false) {
$this->error('添加地址失败!'); $this->error('添加地址失败!');
} }
@ -78,7 +78,7 @@ class Address extends Auth
} }
/** /**
* 修改收货地址状态 * 修改地址状态
* @throws \think\db\exception\DbException * @throws \think\db\exception\DbException
*/ */
public function state() public function state()
@ -124,7 +124,7 @@ class Address extends Auth
} }
/** /**
* 获取指定的收货地址 * 获取指定的地址
* @param string $code * @param string $code
* @return null|array * @return null|array
* @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DataNotFoundException

@ -37,9 +37,7 @@ class Center extends Auth
'base_weight.default' => '', 'base_weight.default' => '',
'base_birthday.default' => '', 'base_birthday.default' => '',
]); ]);
foreach ($data as $key => $vo) { foreach ($data as $key => $vo) if ($vo === '') unset($data[$key]);
if ($vo === '') unset($data[$key]);
}
if (empty($data)) $this->error('没有修改的数据!'); if (empty($data)) $this->error('没有修改的数据!');
if ($this->app->db->name($this->table)->where(['id' => $this->uuid])->update($data) !== false) { if ($this->app->db->name($this->table)->where(['id' => $this->uuid])->update($data) !== false) {
$this->success('更新资料成功!', $this->getUser()); $this->success('更新资料成功!', $this->getUser());

2
vendor/services.php vendored

@ -1,5 +1,5 @@
<?php <?php
// This file is automatically generated at:2021-04-07 11:34:27 // This file is automatically generated at:2021-04-07 15:26:53
declare (strict_types = 1); declare (strict_types = 1);
return array ( return array (
0 => 'think\\admin\\Library', 0 => 'think\\admin\\Library',