You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
147 lines
4.0 KiB
147 lines
4.0 KiB
<?php
|
|
// +----------------------------------------------------------------------
|
|
// | Niucloud-admin 企业快速开发的多应用管理平台
|
|
// +----------------------------------------------------------------------
|
|
// | 官方网址:https://www.niucloud.com
|
|
// +----------------------------------------------------------------------
|
|
// | niucloud团队 版权所有 开源版本可自由商用
|
|
// +----------------------------------------------------------------------
|
|
// | Author: Niucloud Team
|
|
// +----------------------------------------------------------------------
|
|
|
|
namespace addon\hygl\app\adminapi\controller\user;
|
|
|
|
use core\base\BaseAdminController;
|
|
use addon\hygl\app\service\admin\user\UserService;
|
|
|
|
|
|
/**
|
|
* 会员管理控制器
|
|
* Class User
|
|
* @package addon\hygl\app\adminapi\controller\user
|
|
*/
|
|
class User extends BaseAdminController
|
|
{
|
|
/**
|
|
* 获取会员管理列表
|
|
* @return \think\Response
|
|
*/
|
|
public function lists(){
|
|
$data = $this->request->params([
|
|
["tel",""],
|
|
["name",""],
|
|
["password",""],
|
|
["sex",""],
|
|
["birthday",["",""]],
|
|
["is_show",""]
|
|
]);
|
|
return success((new UserService())->getPage($data));
|
|
}
|
|
|
|
/**
|
|
* 会员管理详情
|
|
* @param int $id
|
|
* @return \think\Response
|
|
*/
|
|
public function info(int $id){
|
|
return success((new UserService())->getInfo($id));
|
|
}
|
|
|
|
/**
|
|
* 添加会员管理
|
|
* @return \think\Response
|
|
*/
|
|
public function add(){
|
|
$data = $this->request->params([
|
|
["tel",""],
|
|
["name",""],
|
|
["pic",""],
|
|
["password",""],
|
|
["pid",0],
|
|
["level",0],
|
|
["wx_openid",""],
|
|
["wx_unionid",""],
|
|
["sex",""],
|
|
["birthday","2024-02-20 11:15:10"],
|
|
["is_show",""],
|
|
|
|
]);
|
|
|
|
//验证手机号唯一
|
|
$isTelExist = (new UserService())->isTelExist($data['tel']);
|
|
if ($isTelExist) {
|
|
return fail('手机号已存在');
|
|
}
|
|
|
|
$data['password'] = create_password($data['password']);
|
|
|
|
//根据pid计算对应的用户层级
|
|
$data['level'] = (new UserService())->createLevel($data['pid']);
|
|
$this->validate($data, 'addon\hygl\app\validate\user\User.add');
|
|
$id = (new UserService())->add($data);
|
|
return success('ADD_SUCCESS', ['id' => $id]);
|
|
}
|
|
|
|
/**
|
|
* 会员管理编辑
|
|
* @param $id 会员管理id
|
|
* @return \think\Response
|
|
*/
|
|
public function edit(int $id){
|
|
$data = $this->request->params([
|
|
["tel",""],
|
|
["name",""],
|
|
["pic",""],
|
|
["password",""],
|
|
["pid",0],
|
|
["level",0],
|
|
["wx_openid",""],
|
|
["wx_unionid",""],
|
|
["sex",""],
|
|
["birthday","2024-02-20 11:15:10"],
|
|
["is_show",""],
|
|
|
|
]);
|
|
|
|
//验证手机号唯一
|
|
$isTelExist = (new UserService())->isTelExist($data['tel'],$id);
|
|
if ($isTelExist) {
|
|
return fail('手机号已存在');
|
|
}
|
|
|
|
if ($data['password']) {
|
|
$data['password'] = create_password($data['password']);
|
|
} else {
|
|
unset($data['password']);
|
|
}
|
|
|
|
//根据pid计算对应的用户层级
|
|
$data['level'] = (new UserService())->createLevel($data['pid']);
|
|
$this->validate($data, 'addon\hygl\app\validate\user\User.edit');
|
|
(new UserService())->edit($id, $data);
|
|
return success('EDIT_SUCCESS');
|
|
}
|
|
|
|
/**
|
|
* 会员管理删除
|
|
* @param $id 会员管理id
|
|
* @return \think\Response
|
|
*/
|
|
public function del(int $id){
|
|
(new UserService())->del($id);
|
|
return success('DELETE_SUCCESS');
|
|
}
|
|
|
|
//获取全部用户
|
|
public function getUserAll(){
|
|
return success(( new UserService())->getUserAll());
|
|
}
|
|
|
|
//获取全部站点
|
|
public function getSiteAll(){
|
|
return success(( new UserService())->getSiteAll());
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|