update
This commit is contained in:
parent
bf8ea2a150
commit
0822795b7a
@ -57,8 +57,11 @@ class UserController extends BaseAdminController
|
|||||||
*/
|
*/
|
||||||
public function edit()
|
public function edit()
|
||||||
{
|
{
|
||||||
$params = (new UserValidate())->post()->goCheck('setInfo');
|
$params = (new UserValidate())->post()->goCheck('edit');
|
||||||
UserLogic::setUserInfo($params);
|
$result = UserLogic::edit($params);
|
||||||
return $this->success('操作成功', [], 1, 1);
|
if (true === $result) {
|
||||||
|
return $this->success('编辑成功', [], 1, 1);
|
||||||
|
}
|
||||||
|
return $this->fail(UserLogic::getError());
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -35,13 +35,26 @@ class UserLists extends BaseAdminDataLists implements ListsExcelInterface
|
|||||||
*/
|
*/
|
||||||
public function lists(): array
|
public function lists(): array
|
||||||
{
|
{
|
||||||
|
$params = $this->params;
|
||||||
|
$where = [];
|
||||||
|
if(isset($params['nickname']) && $params['nickname'] != ''){
|
||||||
|
$where[] = ['nickname','like','%'.$params['nickname'].'%'];
|
||||||
|
}
|
||||||
|
if(isset($params['account']) && $params['account'] != ''){
|
||||||
|
$where[] = ['account','like','%'.$params['account'].'%'];
|
||||||
|
}
|
||||||
|
if(isset($params['mobile']) && $params['mobile'] != ''){
|
||||||
|
$where[] = ['mobile','like','%'.$params['mobile'].'%'];
|
||||||
|
}
|
||||||
|
if(isset($params['is_disable']) && $params['is_disable'] != ''){
|
||||||
|
$where[] = ['is_disable','=', $params['is_disable']];
|
||||||
|
}
|
||||||
$field = "id,nickname,real_name,sex,avatar,account,mobile,channel,create_time";
|
$field = "id,nickname,real_name,sex,avatar,account,mobile,channel,create_time";
|
||||||
$lists = User::withSearch($this->setSearch(), $this->params)
|
$lists = User::withSearch($this->setSearch(), $this->params)->where($where)
|
||||||
->limit($this->limitOffset, $this->limitLength)
|
->limit($this->limitOffset, $this->limitLength)
|
||||||
->field($field)
|
->field($field)
|
||||||
->order('id desc')
|
->order('id desc')
|
||||||
->select()->toArray();
|
->select()->toArray();
|
||||||
|
|
||||||
foreach ($lists as &$item) {
|
foreach ($lists as &$item) {
|
||||||
$item['channel'] = UserTerminalEnum::getTermInalDesc($item['channel']);
|
$item['channel'] = UserTerminalEnum::getTermInalDesc($item['channel']);
|
||||||
}
|
}
|
||||||
@ -58,7 +71,21 @@ class UserLists extends BaseAdminDataLists implements ListsExcelInterface
|
|||||||
*/
|
*/
|
||||||
public function count(): int
|
public function count(): int
|
||||||
{
|
{
|
||||||
return User::withSearch($this->setSearch(), $this->params)->count();
|
$params = $this->params;
|
||||||
|
$where = [];
|
||||||
|
if(isset($params['nickname']) && $params['nickname'] != ''){
|
||||||
|
$where[] = ['nickname','like','%'.$params['nickname'].'%'];
|
||||||
|
}
|
||||||
|
if(isset($params['account']) && $params['account'] != ''){
|
||||||
|
$where[] = ['account','like','%'.$params['account'].'%'];
|
||||||
|
}
|
||||||
|
if(isset($params['mobile']) && $params['mobile'] != ''){
|
||||||
|
$where[] = ['mobile','like','%'.$params['mobile'].'%'];
|
||||||
|
}
|
||||||
|
if(isset($params['is_disable']) && $params['is_disable'] != ''){
|
||||||
|
$where[] = ['is_disable','=', $params['is_disable']];
|
||||||
|
}
|
||||||
|
return User::withSearch($this->setSearch(), $this->params)->where($where)->count();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -75,15 +75,15 @@ class UserLogic extends BaseLogic
|
|||||||
Db::startTrans();
|
Db::startTrans();
|
||||||
try {
|
try {
|
||||||
User::where('id', $params['id'])->update([
|
User::where('id', $params['id'])->update([
|
||||||
'avatar' => $params['avatar'],
|
'avatar' => $params['avatar'] ?? '',
|
||||||
'real_name' => $params['real_name'],
|
'real_name' => $params['real_name'],
|
||||||
'nickname' => $params['nickname'],
|
'nickname' => $params['nickname'],
|
||||||
'account' => $params['account'],
|
'account' => $params['account'],
|
||||||
'password' => $params['password'],
|
'password' => $params['password'] ?? '',
|
||||||
'mobile' => $params['mobile'],
|
'mobile' => $params['mobile'] ?? '',
|
||||||
'sex' => $params['sex'],
|
'sex' => $params['sex'] ?? 0,
|
||||||
'is_disable' => $params['is_disable'],
|
'is_disable' => $params['is_disable'] ?? 0,
|
||||||
'user_money' => $params['user_money']
|
'user_money' => $params['user_money'] ?? 0
|
||||||
]);
|
]);
|
||||||
|
|
||||||
Db::commit();
|
Db::commit();
|
||||||
|
@ -24,7 +24,10 @@ class UserValidate extends BaseValidate
|
|||||||
'nickname' => 'require',
|
'nickname' => 'require',
|
||||||
'account' => 'require',
|
'account' => 'require',
|
||||||
'password' => 'require',
|
'password' => 'require',
|
||||||
'mobile' => 'require',
|
'mobile' => 'require|mobile',
|
||||||
|
'is_disable' => 'in:0,1',
|
||||||
|
'sex' => 'in:i,2',
|
||||||
|
'user_money' => 'float'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
@ -39,6 +42,9 @@ class UserValidate extends BaseValidate
|
|||||||
'account' => '用户账号',
|
'account' => '用户账号',
|
||||||
'password' => '用户密码',
|
'password' => '用户密码',
|
||||||
'mobile' => '用户电话',
|
'mobile' => '用户电话',
|
||||||
|
'is_disable' => '是否禁用',
|
||||||
|
'sex' => '用户性别',
|
||||||
|
'user_money' => '用户余额',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
@ -62,7 +68,7 @@ class UserValidate extends BaseValidate
|
|||||||
*/
|
*/
|
||||||
public function sceneEdit()
|
public function sceneEdit()
|
||||||
{
|
{
|
||||||
return $this->only(['id','real_name','nickname','account','password','mobile']);
|
return $this->only(['id','real_name','nickname','account','password','mobile'])->remove('password','require');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user