add
This commit is contained in:
67
app/czg/app/controller/LoginController.php
Normal file
67
app/czg/app/controller/LoginController.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace app\czg\app\controller;
|
||||
|
||||
use app\api\model\Msg;
|
||||
use app\api\model\TbUser;
|
||||
use app\common\controller\BaseController;
|
||||
use app\common\model\SysUser;
|
||||
use think\facade\Db;
|
||||
use think\Request;
|
||||
use Throwable;
|
||||
use ba\Captcha;
|
||||
use ba\ClickCaptcha;
|
||||
use think\facade\Config;
|
||||
use app\common\facade\Token;
|
||||
use app\common\controller\Frontend;
|
||||
use app\api\validate\User as UserValidate;
|
||||
|
||||
class LoginController extends BaseController
|
||||
{
|
||||
protected array $noNeedLogin = ['*'];
|
||||
|
||||
|
||||
public function index()
|
||||
{
|
||||
$data = $this->request->post();
|
||||
if(empty($data['phone']) || empty($data['password'])){
|
||||
$this->n_error('参数不完整');
|
||||
}
|
||||
$res = $this->auth->newlogin($data['phone'], $data['password'], 0);
|
||||
if (isset($res) && $res === true) {
|
||||
$data = $this->auth->getUser();
|
||||
$this->n_success([
|
||||
'token' => $this->auth->getUserInfo()['token'],
|
||||
'user' => apiconvertToCamelCase($data)
|
||||
]);
|
||||
} else {
|
||||
$msg = $this->auth->getError();
|
||||
$msg = $msg ?: __('Check in failed, please try again or contact the website administrator~');
|
||||
$this->n_error($msg);
|
||||
}
|
||||
}
|
||||
// 注册
|
||||
public function register()
|
||||
{
|
||||
|
||||
return $this->ApiDataReturn(TbUser::register($this->request->post()));
|
||||
}
|
||||
|
||||
// 发送验证码
|
||||
public function sendMsg()
|
||||
{
|
||||
$get = $this->request->route();
|
||||
return $this->ApiDataReturn(Msg::sendMsg($get['phone'], $get['event']));
|
||||
}
|
||||
|
||||
// 忘记密码
|
||||
public function forgetPwd()
|
||||
{
|
||||
$post = $this->request->post();
|
||||
return $this->ApiDataReturn(TbUser::forgetPwd($post['phone'], $post['pwd'], $post['msg']));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -282,6 +282,7 @@ class Course extends Model
|
||||
// 根据id查询短剧集数列表
|
||||
public static function courseSets($get, $user, $sort = null)
|
||||
{
|
||||
|
||||
try {
|
||||
if(empty($get['courseId'])) {
|
||||
return returnErrorData('参数不完整');
|
||||
|
||||
@@ -18,9 +18,9 @@ class TbUser extends BaseModel
|
||||
public static function GetByusername($username, $field = 'phone')
|
||||
{
|
||||
// 全表扫描username
|
||||
$dbmap = config('database.db_map');
|
||||
$dbmap = config('think-orm.db_map');
|
||||
foreach ($dbmap as $dbname) {
|
||||
if(!in_array($dbname, config('database.unset_db_map'))) {
|
||||
if(!in_array($dbname, config('think-orm.unset_db_map'))) {
|
||||
$connect = Db::connect($dbname);
|
||||
$data = $connect->name('tb_user')->where([$field => $username])->find();
|
||||
if($data) {
|
||||
@@ -35,10 +35,10 @@ class TbUser extends BaseModel
|
||||
public static function GetByuserInvite($inviter_code)
|
||||
{
|
||||
// // 全表扫描username
|
||||
// $dbmap = config('database.db_map');
|
||||
// $dbmap = config('think-orm.db_map');
|
||||
// $count = 0;
|
||||
// foreach ($dbmap as $dbname) {
|
||||
// if(!in_array($dbname, config('database.unset_db_map'))) {
|
||||
// if(!in_array($dbname, config('think-orm.unset_db_map'))) {
|
||||
// $connect = Db::connect($dbname);
|
||||
// $data = $connect->name('tb_user')->where(['inviter_code' => $inviter_code])->count();
|
||||
// $count += $data;
|
||||
@@ -69,11 +69,11 @@ class TbUser extends BaseModel
|
||||
return $data_list;
|
||||
|
||||
|
||||
// $dbmap = config('database.db_map');
|
||||
// $dbmap = config('think-orm.db_map');
|
||||
// $data_list = [];
|
||||
// foreach ($dbmap as $dbname) {
|
||||
//
|
||||
// if(!in_array($dbname, config('database.unset_db_map'))) {
|
||||
// if(!in_array($dbname, config('think-orm.unset_db_map'))) {
|
||||
// $connect = Db::connect($dbname);
|
||||
// $data_arr = $connect->name('tb_user')->where(['inviter_code' => $invitation_code])->field('user_id,avatar,user_name,user_id')->limit(page($page, $limit), $limit)->select()->toArray();
|
||||
// if($data_arr) {
|
||||
@@ -104,9 +104,9 @@ class TbUser extends BaseModel
|
||||
public static function GetByinvitationCode($invitation_code)
|
||||
{
|
||||
// 全表扫描username
|
||||
$dbmap = config('database.db_map');
|
||||
$dbmap = config('think-orm.db_map');
|
||||
foreach ($dbmap as $dbname) {
|
||||
if(!in_array($dbname, config('database.unset_db_map'))) {
|
||||
if(!in_array($dbname, config('think-orm.unset_db_map'))) {
|
||||
$connect = Db::connect($dbname);
|
||||
$data = $connect->name('tb_user')->where(['invitation_code' => $invitation_code])->find();
|
||||
if($data) {
|
||||
@@ -121,9 +121,9 @@ class TbUser extends BaseModel
|
||||
public static function GetByinviterCodeCount($inviter_code)
|
||||
{
|
||||
// 全表扫描username
|
||||
$dbmap = config('database.db_map');
|
||||
$dbmap = config('think-orm.db_map');
|
||||
foreach ($dbmap as $dbname) {
|
||||
if(!in_array($dbname, config('database.unset_db_map'))) {
|
||||
if(!in_array($dbname, config('think-orm.unset_db_map'))) {
|
||||
$connect = Db::connect($dbname);
|
||||
$data = $connect->name('tb_user')->where(['inviter_code' => $inviter_code])->count();
|
||||
if($data) {
|
||||
@@ -281,7 +281,7 @@ class TbUser extends BaseModel
|
||||
|
||||
public static function selectUserByIdNew($user)
|
||||
{
|
||||
$db = Db::connect(config('database.search_library'));
|
||||
$db = Db::connect(config('think-orm.search_library'));
|
||||
$userVip = $db->name('user_vip')->where(['user_id' => $user['user_id']])->find();
|
||||
$db->close();
|
||||
if ($userVip) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\model;
|
||||
namespace app\czg\app\model;
|
||||
|
||||
|
||||
use app\common\library\DatabaseRoute;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\model;
|
||||
namespace app\czg\app\model;
|
||||
|
||||
use app\common\library\DatabaseRoute;
|
||||
use app\common\model\BaseModel;
|
||||
|
||||
Reference in New Issue
Block a user