作者 李美松

Merge branch 'develop' into lms

... ... @@ -4,6 +4,7 @@
/storage
/vendor
/uploads
composer.json
.env
.env.backup
.phpunit.result.cache
... ...
... ... @@ -142,13 +142,13 @@ class Country
'con_flag' => '',
],
'zh-CN' => [
'cn' => [
'text' => '中文(简体)',
'lang_text' => '简体中文',
'con_flag' => 'con_flag/zh.jfif',
'shop_lang' => 'zh-cn',
],
'zh-TW' => [
'tw' => [
'text' => '中文(繁体)',
'lang_text' => '繁体中文',
'con_flag' => 'con_flag/zh.jfif',
... ... @@ -680,7 +680,7 @@ class Country
public function set_country(){
$data = [];
foreach ($this->tls_list as $k=>$v){
$data[] = ['name'=>$v['text'],'alias'=>$k];
$data[] = ['name'=>$v['text'],'alias'=>$k,'image'=>$k.'.png','con_flag'=>$v['con_flag'],'lang_text'=>$v['lang_text']];
}
$webCountry = new WebSettingCountry();
$webCountry->insert($data);
... ...
... ... @@ -168,6 +168,9 @@ class BaseController extends Controller
$data['images_link'][$k1] = url('/b/image/' . $v1);
}
break;
case 'country_img'://国家图标
$data['image_link'] = url('upload/country/' . $v);
break;
case 'file':
$data['file_link'] = url('/b/file_hash/' . $v);
break;
... ...
... ... @@ -3,22 +3,15 @@
namespace App\Http\Controllers\Bside;
use App\Enums\Common\Code;
use App\Helper\AyrShare as AyrShareHelper;
use App\Helper\Common;
use App\Helper\FormGlobalsoApi;
use App\Models\AyrShare\AyrRelease as AyrReleaseModel;
use App\Models\AyrShare\AyrShare as AyrShareModel;
use App\Models\Project\DeployBuild;
use App\Http\Logic\Bside\User\UserLogic;
use App\Models\Project\Project;
use App\Models\Project\Project as ProjectModel;
use App\Models\SmsLog;
use App\Models\User\ProjectMenu as ProjectMenuModel;
use App\Models\User\ProjectRole as ProjectRoleModel;
use App\Models\User\User as UserModel;
use Carbon\Carbon;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
use Mrgoon\AliSms\AliSms;
/***
... ... @@ -40,11 +33,8 @@ class ComController extends BaseController
'password.required'=>'内容必须填写',
'mobile.regex' => '请输入正确的手机号码',
]);
$userModel = new UserModel();
$res = $userModel->login($this->param);
if($res === false){
$this->response('当前用户不存在或者被禁用,登录失败',Code::USER_ERROR,[]);
}
$userLogic = new UserLogic();
$res = $userLogic->login();
$this->response('请求成功',Code::SUCCESS,$res);
}
... ... @@ -98,12 +88,9 @@ class ComController extends BaseController
'password.required'=>'密码必须填写',
'name.required'=>'名称必须填写',
]);
$userModel = new UserModel();
$userLogic = new UserLogic();
$this->param['id'] = $this->uid;
$rs = $userModel->edits($this->param);
if($rs === false){
$this->response('参数错误或其他服务器原因,编辑失败',Code::USER_ERROR);
}
$userLogic->edits($this->param);
$this->response('编辑成功');
}
... ... @@ -155,21 +142,7 @@ class ComController extends BaseController
}
public function ceshi(){
$data = [];
for ($i = 30;$i >= 1 ;$i--){
$start_time = Carbon::now()->modify('-'.$i.' days')->toDateString();
$data[] = [
'project_id'=>1,
'pv_num'=>$i*(rand(10,1000)),
'ip_num'=>$i*(rand(10,1000)),
'inquiry_num'=>$i*(rand(10,1000)),
'date'=>$start_time,
'compliance_day'=>2351,
'service_day'=>1233,
'created_at'=>$start_time.' 00:00:00',
'updated_at'=>$start_time.' 00:00:00',
];
}
DB::table('gl_count')->insert($data);
$country = new \App\Helper\Country();
return $country->set_country();
}
}
... ...
... ... @@ -35,7 +35,9 @@ class BaseLogic extends Logic
$this->request = request();
$this->requestAll = request()->all();
$this->user = Cache::get(request()->header('token'));
$this->project = (new ProjectLogic())->getInfo($this->user['project_id']);
if(!empty($this->user)){
$this->project = (new ProjectLogic())->getInfo($this->user['project_id']);
}
}
... ...
... ... @@ -24,14 +24,13 @@ class WebSettingCountryLogic extends BaseLogic
* @time :2023/4/28 16:18
*/
public function country_list(){
$lists = $this->model->list($this->param,'id',['id','name','image']);
$lists = $this->model->list($this->param,'id',['id','name','country_img']);
if (empty($lists)){
$this->fail('当前数据不存在');
}
return $this->success($lists);
}
public function edit_country(){
return $this->success();
... ...
... ... @@ -3,8 +3,12 @@
namespace App\Http\Logic\Bside\User;
use App\Enums\Common\Code;
use App\Helper\Common;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\SmsLog;
use App\Models\User\ProjectRole as ProjectRoleModel;
use App\Models\User\User;
use Illuminate\Support\Facades\Cache;
class UserLogic extends BaseLogic
{
... ... @@ -103,4 +107,74 @@ class UserLogic extends BaseLogic
return $this->success();
}
/***
* @name :登录
* @return void
* @author :liyuhang
* @method
*/
public function login(){
//验证账号密码
$password = base64_encode(md5($this->param['password']));
$info = $this->model->read(['mobile'=>$this->param['mobile'],'password'=>$password,'status'=>0], ['id','mobile','role_id','token','name','project_id']);
if($info === false){
//账号密码没通过时,验证验证码
$info = $this->model->read(['mobile'=>$this->param['mobile'],'status'=>0], ['id','mobile','role_id','token','name','project_id']);
if($info === false){
$this->fail('账号密码错误',Code::USER_REGISTER_ERROE);
}
//验证验证码是否准备
$last_sms = SmsLog::getLastLog($this->param['mobile'], SmsLog::TYPE_LOGIN);
if($this->param['password'] != $last_sms->code){
$this->fail('账号密码错误',Code::USER_REGISTER_ERROE);
}
}
//当前用户角色是否被禁用
$projectRoleModel = new ProjectRoleModel();
$role_info = $projectRoleModel->read(['id'=>$info['role_id'],'status'=>0]);
if($role_info === false){
$this->fail('当前用户角色被禁用',Code::USER_REGISTER_ERROE);
}
if(isset($info['token']) && !empty($info['token'])){
//清除上一次用户缓存
Cache::pull($info['token']);
}
//生成新token
$token = md5(uniqid().$info['id']);
//存储缓存
$info['token'] = $token;
Cache::add($token,$info);
$rs = $this->model->edit(['token'=>$token],['id'=>$info['id']]);
if($rs === false){
$this->fail('系统错误,请联系管理员');
}
//写入日志
Common::set_user_login(['user_id'=>$info['id'],'ip'=>request()->ip()]);
return $this->success($info);
}
/**
* @param $param
* @name :编辑管理员
* @return bool
* @author :liyuhang
* @method
*/
public function edits($param){
//查看密码是否修改
$info = $this->model->read(['id'=>$param['id']]);
$param['password'] = base64_encode(md5($param['password']));
if($param['password'] == $info['password']){
unset($param['password']);
}
//密码加密
$rs = $this->model->edit($param,['id'=>$param['id']]);
if($rs === false){
$this->fail('系统错误,请联系管理员');
}
//清空当前用户登录缓存
Cache::pull($info['token']);
return $this->success();
}
}
... ...
... ... @@ -53,74 +53,4 @@ class User extends Base
'updated_at' => 'datetime:Y-m-d H:i:s',
];
/***
* @name :登录
* @return void
* @author :liyuhang
* @method
*/
public function login($param){
//验证账号密码
$password = base64_encode(md5($param['password']));
$info = $this->read(['mobile'=>$param['mobile'],'password'=>$password,'status'=>0], ['id','mobile','role_id','token','name','project_id']);
if($info === false){
//账号密码没通过时,验证验证码
$info = $this->read(['mobile'=>$param['mobile'],'status'=>0], ['id','mobile','role_id','token','name','project_id']);
if($info === false){
return false;
}
//验证验证码是否准备
$last_sms = SmsLog::getLastLog($param['mobile'], SmsLog::TYPE_LOGIN);
if($param['password'] != $last_sms->code){
return false;
}
}
//当前用户角色是否被禁用
$projectRoleModel = new ProjectRoleModel();
$role_info = $projectRoleModel->read(['id'=>$info['role_id'],'status'=>0]);
if($role_info === false){
return false;
}
if(isset($info['token']) && !empty($info['token'])){
//清除上一次用户缓存
Cache::pull($info['token']);
}
//生成新token
$token = md5(uniqid().$info['id']);
//存储缓存
$info['token'] = $token;
Cache::add($token,$info);
$rs = $this->edit(['token'=>$token],['id'=>$info['id']]);
if($rs === false){
return false;
}
//写入日志
Common::set_user_login(['user_id'=>$info['id'],'ip'=>request()->ip()]);
return $info;
}
/**
* @param $param
* @name :编辑管理员
* @return bool
* @author :liyuhang
* @method
*/
public function edits($param){
//查看密码是否修改
$info = $this->read(['id'=>$param['id']]);
$param['password'] = base64_encode(md5($param['password']));
if($param['password'] == $info['password']){
unset($param['password']);
}
//密码加密
$rs = $this->edit($param,['id'=>$param['id']]);
if($rs === false){
return false;
}
//清空当前用户登录缓存
Cache::pull($info['token']);
return true;
}
}
... ...