Commit d8f711ff by lincyawer

重构基本完成,还剩一些小问题

parent 0a5bb6a1
Showing with 1035 additions and 116 deletions
<?php
namespace App\Http\Caches;
use Illuminate\Support\Facades\Redis;
class MenuCache
{
const _KEY_MENU_PREFIX = 'system_menu';
private $enable_cache_system_names = [
'新crm客户管理系统',
'交易系统-采购系统',
'交易系统-销售系统',
'询报价后台管理系统',
];
private $redis;
public function __construct($default_instance = 'data')
{
if ($default_instance) {
$this->redis = Redis::connection($default_instance);
} else {
$this->redis = Redis::connection();
}
}
// 清除所有系统缓存
public function deleteAllSystemMenuCache()
{
$perm_cache_key = self::_KEY_MENU_PREFIX . ':*';
$system_menu_cache = $this->redis->keys($perm_cache_key);
if( $system_menu_cache ){
return $this->redis->del($system_menu_cache);
}
return ;
}
}
<?php
namespace App\Http\Caches;
use Illuminate\Support\Facades\Redis;
class PermCache
{
const _KEY_PERM_PREFIX = 'system_perm';
private $enable_cache_system_names = [
'新crm客户管理系统',
'交易系统-采购系统',
'交易系统-销售系统',
'询报价后台管理系统',
];
private $redis;
public function __construct($default_instance = 'data')
{
if ($default_instance) {
$this->redis = Redis::connection($default_instance);
} else {
$this->redis = Redis::connection();
}
}
// 清除所有系统缓存
public function deleteAllSystemPermCache()
{
$perm_cache_key = self::_KEY_PERM_PREFIX . ':*';
$system_menu_cache = $this->redis->keys($perm_cache_key);
if( $system_menu_cache ){
return $this->redis->del($system_menu_cache);
}
return ;
}
// 去掉该系统的权限缓存
public function deleteSystemPermCache($system_name)
{
if( !in_array($system_name, $this->enable_cache_system_names) ){
return false;
}
$perm_cache_key = self::_KEY_PERM_PREFIX . ':' . md5($system_name) . ':*';
$system_menu_cache = $this->redis->keys($perm_cache_key);
if( $system_menu_cache ){
return $this->redis->del($system_menu_cache);
}
return false;
}
}
<?php
namespace App\Http\Controllers;
class ConfigController extends Controller
{
// 帮助文档
public function help()
{
return redirect('/doc/user_helper.html');
}
}
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
use App\Http\Service\UserService; use App\Http\Service\UserService;
use App\Http\Service\UserTokenService; use App\Http\Service\UserTokenService;
use App\Models\user\LoginModel; use App\Models\user\LoginModel;
use App\Models\user\UserInfoModel;
use App\Models\user\UserLoginModel;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\Config; use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
...@@ -77,35 +79,34 @@ public function checkLogin(Request $request): array ...@@ -77,35 +79,34 @@ public function checkLogin(Request $request): array
Log::error("passwd or name not match"); // 记录到日志文件 Log::error("passwd or name not match"); // 记录到日志文件
return Output::makeResult($request, Error::E_NOT_MATCH, "passwd or name not match"); return Output::makeResult($request, Error::E_NOT_MATCH, "passwd or name not match");
} }
$info = $info[0];
if ($info->status != LoginController::STATUS_NEED_CHANGE_PASSWD && $info->status != 0) { if ($info['status'] != LoginController::STATUS_NEED_CHANGE_PASSWD && $info['status'] != 0) {
Log::error("forbidden login"); // 记录到日志文件 Log::error("forbidden login"); // 记录到日志文件
return Output::makeResult($request, Error::E_FORBIDDEN, "forbidden login"); return Output::makeResult($request, Error::E_FORBIDDEN, "forbidden login");
} }
if ($info->status == LoginController::STATUS_NEED_CHANGE_PASSWD) { if ($info['status'] == LoginController::STATUS_NEED_CHANGE_PASSWD) {
$token = UserTokenService::createToken($info->status); $token = UserTokenService::createToken($info['status']);
return Output::makeResult($request, Error::E_RESET_PASSWD, "", $token); return Output::makeResult($request, Error::E_RESET_PASSWD, "", $token);
} }
$passwd = UserService::createPasswd($passwd, $info->slat); $passwd = UserService::createPasswd($passwd, $info['slat']);
if ($passwd != $info->passwd) { if ($passwd != $info['passwd']) {
$this->checkLoginFailedLimit($info); $this->checkLoginFailedLimit($info);
Log::error($info->email . ":passwd or name not match"); // 记录到日志文件 Log::error($info['email'] . ":passwd or name not match"); // 记录到日志文件
return Output::makeResult($request, Error::E_NOT_MATCH, "passwd or name not match"); return Output::makeResult($request, Error::E_NOT_MATCH, "passwd or name not match");
} }
$session = self::generateSession($info->userId, $request->ip(), $info->email, $info->name, $info->engName); $session = self::generateSession($info['userId'], $request->ip(), $info['email'], $info['name'], $info['engName']);
if (!$session) { if (!$session) {
Log::error("unknown server error"); // 记录到日志文件 Log::error("unknown server error"); // 记录到日志文件
return Output::makeResult($request, Error::E_SERVER, "unknow server error, try again"); return Output::makeResult($request, Error::E_SERVER, "unknow server error, try again");
} }
$this->setLoginCookie($session['userId'], $session['skey'], $info->header, $this->setLoginCookie($session['userId'], $session['skey'], $info['header'],
$remember ? strtotime($session['expireTime']) : 0); $remember ? strtotime($session['expireTime']) : 0);
$this->delLoginFailed($info->userId); // 登录成功后删除错误次数 $this->delLoginFailed($info['userId']); // 登录成功后删除错误次数
return Output::makeResult($request, 0, 'OK', ['userId' => $info->userId, 'skey' => $session['skey']]); return Output::makeResult($request, 0, 'OK', ['userId' => $info['userId'], 'skey' => $session['skey']]);
} catch (\Exception $e) { } catch (\Exception $e) {
Log::error("unknown server error: " . $e->getMessage()); // 记录到日志文件 Log::error("unknown server error: " . $e->getMessage()); // 记录到日志文件
return Output::makeResult($request, Error::E_SERVER, return Output::makeResult($request, Error::E_SERVER,
...@@ -227,4 +228,61 @@ private function checkLoginFailedLimit($info) ...@@ -227,4 +228,61 @@ private function checkLoginFailedLimit($info)
}); });
} }
} }
// 用户登录日志列表接口
public function getLoginLogList(Request $request)
{
$page = $request->input('page', 1);
$limit = $request->input('limit', 10);
$params = [
'email' => $request->input('email', ''),
'begin_time' => $request->input('begin_time', '') ? $request->input('begin_time') : '',
'end_time' => $request->input('end_time', '') ? $request->input('end_time') : '',
];
// 查询条件
$where = [];
if ($params['email']) {
$user_info = UserInfoModel::querySingle([['email',$params['email']]]);
if ($user_info) {
$where[] = ['userId', '=', $user_info['userId']];
} else {
return $this->setSuccess(['list' => [], 'total' => 0]);
}
}
if ($params['begin_time']) {
$where[] = ['loginTime', '>=', $params['begin_time']];
}
if ($params['end_time']) {
$where[] = ['loginTime', '<=', date("Y-m-d", strtotime($params['end_time']) + 86400)];
}
$search_field = ['userId', 'loginTime', 'loginIp'];
$login_log_data = UserLoginModel::getListByWhere($where, $page, $limit, $search_field);
$login_log_list = [];
if ($login_log_data['data']) {
$user_ids = array_column($login_log_data['data'], 'userId');//返回数组中单个列(userId)的值
$user_list_map = UserService::getUserListMapByIds($user_ids);
foreach ($login_log_data['data'] as $login_log_info) {
$user_info = $user_list_map[$login_log_info['userId']] ?? [];
$login_log_list[] = [
"email" => $user_info ? $user_info['email'] : '',
'name' => $user_info ? $user_info['name'] : '',
"engName" => $user_info ? $user_info['engName'] : '',
"loginIp" => $login_log_info['loginIp'],
"loginTime" => $login_log_info['loginTime'],
"userId" => $login_log_info['userId']
];
}
}
$data = [
'list' => $login_log_list,
'total' => $login_log_data['total']
];
return $this->setSuccess($data);
}
} }
<?php
namespace App\Http\Controllers;
use App\Http\Service\PermService;
use App\Http\Service\UserService;
use App\Models\user\DepartmentModel;
use App\Models\user\PositionModel;
use App\Models\user\UserInfoModel;
use Illuminate\Http\Request;
class PositionController extends Controller
{
// 职位列表
public function positionList(Request $request)
{
$map['parent_id'] = 0;
$data = [
'id' => 'positionList',
'title' => '职位列表',
'paths' => [['href' => '#', 'title' => '组织管理'], ['href' => '#', 'title' => '职位列表']],
'department' => DepartmentModel::getDepartmentNameWithIdList($map),
];
return view('position.positionList', $data);
}
// 职位列表
public function getPositionList(Request $request)
{
$page = $request->input('page', 1);
$limit = $request->input('limit', 10);
$position_map = [];
$position_map['position_name'] = $request->input('position_name', ''); // 职位名称
$position_map['department_id'] = $request->input('search_department_id', ''); // 部门
$position_map['begin_time'] = $request->input('begin_time', '') ? strtotime($request->input('begin_time')) : '';
$position_map['end_time'] = $request->input('end_time', '') ? strtotime($request->input('end_time')) + 86399 : '';
$where = [];
if ($position_map['position_name']) {
$where[] = ['position_name', 'like', $position_map['position_name'] . '%'];
}
if (isset($position_map['department_id']) && $position_map['department_id']) {
$where[] = ['department_id', '=', $position_map['department_id']];
}
if ($position_map['begin_time']) {
$where[] = ['ctime', '>=', $position_map['begin_time']];
}
if ($position_map['end_time']) {
$where[] = ['ctime', '<=', $position_map['end_time']];
}
$position_field = ['position_id', 'position_name', 'department_id', 'department_name', 'author', 'last_author', 'ctime', 'mtime'];
$position_list = PositionModel::getPositionFieldList($where, $position_field, $limit, $page);
$data = [
"total" => isset($position_list['total']) ? $position_list['total'] : 0,
"list" => $position_list['data']
];
return $this->setSuccess($data);
}
// 新增职位
public function addPosition(Request $request)
{
$input_data = [];
$input_data['position_name'] = $request->input('position_name');
$input_data['department_id'] = $request->input('department_id');
$input_data['department_name'] = $request->input('department_name');
$input_data['author'] = $request->user->email;
$input_data['last_author'] = $request->user->email;
$res_get = PositionModel::querySingle([['position_name', $input_data['position_name']]]);
if ($res_get) {
return $this->setError('新增失败,职位已存在');
}
$res_creat = PositionModel::createItem($input_data);
if ($res_creat === false) {
return $this->setError('新增失败');
}
return $this->setSuccess('新增成功');
}
// 编辑职位
public function editPosition(Request $request)
{
$position_id = $request->input('position_id');
$input_data = [];
$input_data['position_name'] = $request->input('position_name');
$input_data['department_id'] = $request->input('department_id');
$input_data['department_name'] = $request->input('department_name');
$input_data['last_author'] = $request->user->email;
$res_get = PositionModel::querySingle([['position_name', $input_data['position_name']]]);
if (!$res_get) {
return $this->setError('编辑失败,职位不存在');
}
$res_update = PositionModel::updateWhere([['position_id', $position_id]], $input_data);
if ($res_update === false) {
return $this->setError('更新失败');
}
UserInfoModel::updateWhere([['position_id', $position_id]], ['position_name' => $input_data['position_name']]);
UserInfoModel::updateByDepartmentId($input_data['department_id'], ['department_name' => $input_data['department_name']]);
return $this->setSuccess('更新成功');
}
// 删除职位
public function delPosition(Request $request)
{
$position_id = $request->input('position_id');
$res_delete = PositionModel::deleteWhere([['position_id', $position_id]]);
if ($res_delete === false) {
return $this->setError('删除失败');
}
$delete_position_id_name = [
'position_id' => 0,
'position_name' => ''
];
UserInfoModel::updateWhere([['position_id', $position_id]], $delete_position_id_name);
return $this->setSuccess('删除成功');
}
}
<?php
namespace App\Http\Controllers;
use App\Http\Caches\MenuCache;
use App\Http\Caches\PermCache;
use App\Http\Service\PermService;
use App\Models\user\PositionModel;
use App\Models\user\PositionPermModel;
use App\Models\user\TBusinessConfigModel;
use App\Models\user\TUserPermModel;
use App\Models\user\UserInfoModel;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class PositionPermController extends Controller
{
// 职位权限列表
public function positionPermList(Request $request)
{
$info = [
'id' => 'positionPerm',
'title' => '职位权限列表',
'paths' => [['href' => '#', 'title' => '组织管理'], ['href' => '#', 'title' => '职位权限列表']],
'position' => PositionModel::getPositionNameMap(),// 职位
'businessName' => TBusinessConfigModel::getBusinessNameList(),// 业务系统名称
];
return view('positionPerm.positionPermList', $info);
}
// 职位角色权限列表
public function getPositionPermList(Request $request)
{
$page = $request->input('page', 1);
$limit = $request->input('limit', 10);
$position_perm_map = [];
$position_perm_map['position_id'] = $request->input('position_id', ''); // 职位名称
$position_perm_map['bid'] = $request->input('bid', ''); // 业务系统ID
$position_perm_map['role_id'] = $request->input('business_role_id', ''); // 角色ID
$position_perm_map['begin_time'] = $request->input('begin_time', '') ? strtotime($request->input('begin_time')) : '';
$position_perm_map['end_time'] = $request->input('end_time', '') ? strtotime($request->input('end_time')) + 86399 : '';
$where = [];
if ($position_perm_map['position_id']) {
$where[] = ['position_id', '=', $position_perm_map['position_id']];
}
if ($position_perm_map['bid']) {
$where[] = ['bid', '=', $position_perm_map['bid']];
}
if ($position_perm_map['role_id']) {
$where[] = ['role_id', '=', $position_perm_map['role_id']];
}
if ($position_perm_map['begin_time']) {
$where[] = ['ctime', '>=', $position_perm_map['begin_time']];
}
if ($position_perm_map['end_time']) {
$where[] = ['ctime', '<=', $position_perm_map['end_time']];
}
$position_field = ['position_perm_id', 'position_id', 'position_name', 'bid', 'business_name', 'role_id', 'role_name', 'author', 'last_author', 'ctime', 'mtime'];
$position_perm_list = PositionPermModel::getPositionPermList($where, $position_field, $limit, $page);
$data = [
"total" => $position_perm_list['total'] ?? 0,
"list" => $position_perm_list['data']
];
return $this->setSuccess($data);
}
// 职位绑定/编辑角色
public function setPositionPerm(Request $request)
{
$map['position_perm_id'] = $request->input('position_perm_id', '');
$input_data = [];
$input_data['position_id'] = $request->input('position_id');
$input_data['position_name'] = $request->input('position_name');
$input_data['bid'] = $request->input('bid');
$input_data['business_name'] = $request->input('business_name');
$input_data['role_id'] = $request->input('business_role_id');
$input_data['role_name'] = $request->input('role_name');
$input_data['author'] = $request->user->email;
$input_data['last_author'] = $request->user->email;
$msg_txt = !$map['position_perm_id'] ? '绑定' : '更新';
$check_data = [];
$check_data['position_id'] = $input_data['position_id'];
$check_data['bid'] = $input_data['bid'];
$res_get = PositionPermModel::querySingle($check_data);
if ($res_get) {
return $this->setError('该职位已绑定');
}
DB::beginTransaction();
try {
$res_update = PositionPermModel::updateOrCreateData($map, $input_data);
if ($res_update === false) {
DB::rollBack();
return $this->setError('操作失败');
}
/*** 绑定用户权限 ***/
// 查询该职位下所有用户
$user_id_email = UserInfoModel::queryWhere([['position_id', $input_data['position_id']]]);
if (!$user_id_email) {
DB::commit();
return $this->setSuccess('绑定成功');
}
$user_ids = array_column($user_id_email, 'userId');
$res_get = PermService::delUserPerms($user_ids); // 删除该职位下用户的所有权限
if ($res_get === false) {
return $this->setError('删除用户权限失败');
}
// 查询该职位绑定的系统、角色,并重新设置用户权限
$position_roles = PositionPermModel::queryWhere([['position_id', $input_data['position_id']]]);
$user_perm = [];
foreach ($position_roles as $roles) {
foreach ($user_id_email as $v) {
$temp = [];
$temp['bid'] = $roles['bid'];
$temp['roles'] = json_encode(array("{$roles['role_id']}"));
$temp['userId'] = $v['userId'];
$temp['perms'] = json_encode(array());
$temp['username'] = $v['email'];
$temp['begDate'] = date('Y-m-d');
$temp['endDate'] = date('Y-m-d', time() + 15552000); // 半年
$temp['ctime'] = date('Y-m-d H:i:s');
$temp['mtime'] = date('Y-m-d H:i:s');
$user_perm[] = $temp;
}
}
$res_get = TUserPermModel::createItem($user_perm);
if ($res_get === false) {
DB::rollBack();
return $this->setError('添加用户失败');
}
DB::commit();
} catch (\Exception $e) {
DB::rollBack();
return $this->setError('操作失败', 0, $e->getMessage());
}
// 绑定职位权限,删除系统的权限和菜单缓存
$perm_cache = new PermCache();
$perm_cache->deleteAllSystemPermCache();
$menu_cache = new MenuCache();
$menu_cache->deleteAllSystemMenuCache();
return $this->setSuccess('操作成功');
}
// 删除职位权限
public function delPositionPerm(Request $request)
{
$position_perm_id = $request->input('position_perm_id');
$delete_position_perm_id = PositionPermModel::deleteWhere([['position_perm_id', $position_perm_id]]);
if ($delete_position_perm_id === false) {
return $this->setError('删除失败');
}
// 如果职位变更,删除系统的权限和菜单缓存
$perm_cache = new PermCache();
$perm_cache->deleteAllSystemPermCache();
$menu_cache = new MenuCache();
$menu_cache->deleteAllSystemMenuCache();
return $this->setSuccess('删除成功');
}
}
<?php
namespace App\Http\Controllers;
use App\Http\Service\PermService;
use App\Models\user\TRolePermModel;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
class RoleController extends Controller
{
// 获取业务系统角色
public function getBusinessRoles(Request $request)
{
$bid = $request->input('bid');
$role_id_name_map = TRolePermModel::getRoles($bid);
if (!$role_id_name_map) {
return $this->setError('业务系统角色为空');
}
return $this->setSuccess($role_id_name_map);
}
}
...@@ -13,5 +13,7 @@ class EncryptCookies extends Middleware ...@@ -13,5 +13,7 @@ class EncryptCookies extends Middleware
*/ */
protected $except = [ protected $except = [
// //
'oa_skey',
'oa_user_id'
]; ];
} }
...@@ -5,11 +5,15 @@ ...@@ -5,11 +5,15 @@
use App\Http\Error; use App\Http\Error;
use App\Http\Output; use App\Http\Output;
use App\Models\user\UserLoginModel;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\Config; use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Cookie;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Redis;
class LoginService{ class LoginService
{
public static function checkEmailDomain($email) public static function checkEmailDomain($email)
{ {
return substr($email, 1 + strpos($email, '@')) == Config::get('website.emailDomain'); return substr($email, 1 + strpos($email, '@')) == Config::get('website.emailDomain');
...@@ -34,14 +38,13 @@ public static function checkLoginStatus(Request $request): array ...@@ -34,14 +38,13 @@ public static function checkLoginStatus(Request $request): array
} }
} }
public static function checkSession($userId, $skey) public static function checkSession($userId, $skey)
{ {
$sKey = null; $sKey = null;
try { try {
$key = self::sessionKey($userId, $skey); $key = self::sessionKey($userId, $skey);
$sKey = Cache::getRedis()->get($key); $sKey = Cache::getRedis()->get($key);
}catch (\Exception $e){ } catch (\Exception $e) {
Log::error($e); Log::error($e);
} }
if ($sKey === null) { if ($sKey === null) {
...@@ -59,10 +62,12 @@ public static function checkSession($userId, $skey) ...@@ -59,10 +62,12 @@ public static function checkSession($userId, $skey)
} }
return $jsonResult; return $jsonResult;
} }
public static function sessionKey($userId, $skey): string public static function sessionKey($userId, $skey): string
{ {
return $userId . ':' . substr($skey, 0, 8); // 8个字节足够了; 一个用户的空间范围内冲突概率很低 return $userId . ':' . substr($skey, 0, 8); // 8个字节足够了; 一个用户的空间范围内冲突概率很低
} }
public static function isCookieDomain($url): bool public static function isCookieDomain($url): bool
{ {
$domain_info = parse_url($url); $domain_info = parse_url($url);
...@@ -75,4 +80,29 @@ public static function isCookieDomain($url): bool ...@@ -75,4 +80,29 @@ public static function isCookieDomain($url): bool
} }
return false; return false;
} }
public static function expireLogin($userId, $skey = null)
{
$expire = date('Y-m-d H:i:s', time() - 2 * 24 * 3600);
if ($skey === null) {
$login_list =UserLoginModel::queryWhere([['userId', $userId], ['expireTime', '>', $expire]]);
} else {
$login_list = [['skey' => $skey]];
}
if ($login_list) {
Redis::pipeline(function ($pipe) use ($login_list, $userId) {
foreach ($login_list as $login_info) {
$keys[] = self::sessionKey($userId, $login_info['skey']);
}
call_user_func_array([$pipe, 'del'], $keys);
});
}
return true;
}
public static function expireTime()
{
$expire = Config::get('website.skeyExpire');
return $expire ? $expire : 3600 * 12;
}
} }
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
use App\Http\Error; use App\Http\Error;
use App\Http\Output; use App\Http\Output;
use App\Models\queue\QueuedModel;
use App\Models\user\UserInfoModel; use App\Models\user\UserInfoModel;
use App\Models\user\UserModel; use App\Models\user\UserModel;
use http\Client\Curl\User; use http\Client\Curl\User;
...@@ -13,23 +14,23 @@ ...@@ -13,23 +14,23 @@
class UserService class UserService
{ {
const SLAT_LENGTH = 32; // 用户密码加盐的随机数 const SLAT_LENGTH = 32; // 用户密码加盐的随机数
const TABLE_NAME = 'user'; // 表名
public static function createPasswd($passwd, $slat) public static function createPasswd($passwd, $slat)
{ {
return hash('sha256', md5($passwd) . $slat); return hash('sha256', md5($passwd) . $slat);
} }
public static function createSlat() public static function createSlat()
{ {
return base64_encode(openssl_random_pseudo_bytes(self::SLAT_LENGTH)); return base64_encode(openssl_random_pseudo_bytes(self::SLAT_LENGTH));
} }
public static function getUserInfo($userId, $isLimit) public static function getUserInfo($userId, $isLimit)
{ {
$info = UserInfoModel::getInfoById($userId); $info = UserInfoModel::getInfoById($userId);
$boss = UserInfoModel::getInfoById($info['superior']); $boss = UserInfoModel::getInfoById($info['superior']);
$user_info = $info; $user_info = $info;
var_dump($boss); if ($boss) {
if($boss){
$user_info['sup_engName'] = $boss['engName']; $user_info['sup_engName'] = $boss['engName'];
$user_info['sup_name'] = $boss['name']; $user_info['sup_name'] = $boss['name'];
} }
...@@ -44,7 +45,7 @@ public static function getUserInfo($userId, $isLimit) ...@@ -44,7 +45,7 @@ public static function getUserInfo($userId, $isLimit)
} }
$supTitle = ''; $supTitle = '';
if(!empty($user_info['sup_engName'])){ if (!empty($user_info['sup_engName'])) {
$supTitle = $user_info['sup_engName']; $supTitle = $user_info['sup_engName'];
} }
if (!empty($user_info['sup_name'])) { if (!empty($user_info['sup_name'])) {
...@@ -60,7 +61,7 @@ public static function getUserInfo($userId, $isLimit) ...@@ -60,7 +61,7 @@ public static function getUserInfo($userId, $isLimit)
public static function getUserInfoByName($type, $name) public static function getUserInfoByName($type, $name)
{ {
$userInfo = UserInfoModel::QueryWhere([ $userInfo = UserInfoModel::querySingle([
[ [
($type == 1) ? 'email' : 'engName', ($type == 1) ? 'email' : 'engName',
'=', '=',
...@@ -75,19 +76,19 @@ public static function getUserInfoByName($type, $name) ...@@ -75,19 +76,19 @@ public static function getUserInfoByName($type, $name)
if (!$userInfo) { if (!$userInfo) {
return []; return [];
} }
$metaUser = UserModel::QueryWhere([ $metaUser = UserModel::querySingle([
[ [
'userId', 'userId',
'=', '=',
$userInfo[0]->userId, $userInfo['userId'],
] ]
]); ]);
if (!$metaUser) { if (!$metaUser) {
return []; return [];
} }
$userInfo[0]->passwd = $metaUser[0]->passwd; $userInfo['passwd'] = $metaUser['passwd'];
$userInfo[0]->slat = $metaUser[0]->slat; $userInfo['slat'] = $metaUser['slat'];
$userInfo[0]->status = $metaUser[0]->status; $userInfo['status'] = $metaUser['status'];
return $userInfo; return $userInfo;
} }
...@@ -130,7 +131,7 @@ public static function getList(Request $request): array ...@@ -130,7 +131,7 @@ public static function getList(Request $request): array
} }
// $q->where($key, 'LIKE', $value . "%"); // $q->where($key, 'LIKE', $value . "%");
$result = UserInfoModel::queryLimitOffset($whereList,$count,($page - 1) * $count); $result = UserInfoModel::queryLimitOffset($whereList, $count, ($page - 1) * $count);
$total = $result['total']; $total = $result['total'];
$users = $result['data']; $users = $result['data'];
$list = []; $list = [];
...@@ -220,6 +221,7 @@ public static function extractUserInfoFromReq(Request $request, $isRegistered) ...@@ -220,6 +221,7 @@ public static function extractUserInfoFromReq(Request $request, $isRegistered)
return $data; return $data;
} }
public static function checkUserInfo($info) public static function checkUserInfo($info)
{ {
if (!empty($info['userId']) && $info['userId'] <= 0) { if (!empty($info['userId']) && $info['userId'] <= 0) {
...@@ -304,6 +306,7 @@ public static function generateTree($list, $pk = 'department_id', $pid = 'parent ...@@ -304,6 +306,7 @@ public static function generateTree($list, $pk = 'department_id', $pid = 'parent
return $department_tree; return $department_tree;
} }
// 部门添加html // 部门添加html
public static function getDepartmentHtml($tree) public static function getDepartmentHtml($tree)
{ {
...@@ -325,4 +328,40 @@ public static function getDepartmentHtml($tree) ...@@ -325,4 +328,40 @@ public static function getDepartmentHtml($tree)
return $html; return $html;
} }
public static function getUserListMapByIds($user_ids)
{
$user_list = UserInfoModel::getInfoByIds($user_ids);
$user_list_map = [];
if ($user_list) {
$user_list_map = array_column($user_list, null, 'userId');
}
return $user_list_map;
}
public static function checkoutPassword($info, $oldpasswd)
{
if (!$info) {
return false;
}
$passwd = UserService::createPasswd($oldpasswd, $info['slat']);
return $passwd == $info['passwd'];
}
// 线上销售离职,推送到CRM队列
public static function sysToCrm($info)
{
$department_ids = [];
DepartmentService::getSubDepartmentId(33, $department_ids); // 获取线上销售所有部门
if (!in_array($info['department_id'], $department_ids)) {
return false;
}
$queue = new QueuedModel();
$queue_name = 'crm_online_sales_leave';
$data['sale_id'] = intval($info['userId']);
$queue->pushQueue($queue_name, json_encode($data));
}
} }
...@@ -2,14 +2,15 @@ ...@@ -2,14 +2,15 @@
namespace App\Http\Service; namespace App\Http\Service;
use App\Models\user\UserTokenModel;
use Illuminate\Support\Facades\Config; use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\DB;
class UserTokenService{ class UserTokenService
{
const TOKEN_RESET_PASSWD_FORCE = 1; const TOKEN_RESET_PASSWD_FORCE = 1;
const TOKEN_RESET_PASSWD_EMAIL = 2; const TOKEN_RESET_PASSWD_EMAIL = 2;
const TABLE_NAME = 'user_token'; protected const tableName = 'user_token';
const TOKEN_LENGTH = 64; // token的随机数字节数; base64之后是 TOKEN_LENGTH * 2 const TOKEN_LENGTH = 64; // token的随机数字节数; base64之后是 TOKEN_LENGTH * 2
public static function __createToken() public static function __createToken()
...@@ -39,7 +40,7 @@ public static function createToken($userId, $expire = null) ...@@ -39,7 +40,7 @@ public static function createToken($userId, $expire = null)
'mtime' => $now 'mtime' => $now
]; ];
$ret = DB::table(self::TABLE_NAME)->insert($data); $ret = UserTokenModel::createItem($data);
if (!$ret) { if (!$ret) {
return false; return false;
} }
......
...@@ -6,7 +6,30 @@ ...@@ -6,7 +6,30 @@
class CommonModel extends Model class CommonModel extends Model
{ {
public static function queryWhere($whereList){ public static function queryWhere($whereList)
{
return self::where($whereList)->get()->toArray(); return self::where($whereList)->get()->toArray();
} }
public static function querySingle($whereList)
{
$res = self::where($whereList)->first();
return $res ? $res->toArray() : [];
}
public static function updateWhere($whereList, $data)
{
return self::where($whereList)->update($data);
}
public static function deleteWhere($whereList)
{
return self::where($whereList)->delete();
}
public static function pluckWhere($whereList,$pluckList)
{
return self::where($whereList)->pluck(...$pluckList);
}
public static function createItem($data)
{
return self::insert($data);
}
} }
<?php
namespace App\Models\department;
use Illuminate\Database\Eloquent\Model;
class DepartmentModel extends Model
{
protected $table = 'department';
protected $primaryKey = 'departmentId';
public static function getDepartmentIdTitlePatent($key, $number)
{
return self::where('title', 'LIKE', $key)->take($number)
->select('departmentId', 'title', 'parent')->get();
}
public static function getDepartmentIdParentIsvirtulTitle()
{
return self::select('departmentId', 'parent', 'isVirtual', 'title')->get();
}
public static function getDepartmentId($departmentId)
{
return self::where('departmentId', $departmentId)->first();
}
public static function getTitleParent($data)
{
$res = self::where('departmentId', $data)
->select('title', 'parent')
->first();
return ($res) ? $res->toArray() : [];
}
}
...@@ -2,11 +2,12 @@ ...@@ -2,11 +2,12 @@
namespace App\Models\queue; namespace App\Models\queue;
use App\Models\CommonModel;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use PhpAmqpLib\Connection\AMQPStreamConnection; use PhpAmqpLib\Connection\AMQPStreamConnection;
use PhpAmqpLib\Message\AMQPMessage; use PhpAmqpLib\Message\AMQPMessage;
class QueuedModel extends Model class QueuedModel extends CommonModel
{ {
public function pushAmq($content = '') public function pushAmq($content = '')
{ {
......
<?php
namespace App\Models\spu;
use App\Models\CommonModel;
class SupplierModel extends CommonModel
{
protected $connection = 'spu';
protected $table = 'supplier';
protected $primaryKey = 'supplier_id';
const CREATED_AT = 'create_time';
const UPDATED_AT = 'update_time';
public static function getSupplierIdName($data)
{
$res = self::where('code', $data)
->select('supplier_name', 'supplier_id')
->first();
return ($res) ? $res->toArray() : [];
}
public static function getSupplierListByCodeIds($code_ids)
{
$res = self::whereIn('code', $code_ids)->get();
return ($res) ? $res->toArray() : [];
}
public static function wherePluck($whereList, $pluckList)
{
return self::where($whereList)->pluck(...$pluckList);
}
}
...@@ -70,4 +70,9 @@ public static function updateDataByDepartmentId($departmentId, $data) ...@@ -70,4 +70,9 @@ public static function updateDataByDepartmentId($departmentId, $data)
{ {
return self::where('department_id', $departmentId)->update($data); return self::where('department_id', $departmentId)->update($data);
} }
public static function getDepartmentNameWithIdList($whereList)
{
$res = self::where($whereList)->pluck('department_name', 'department_id')->toArray();
return $res ?:[];
}
} }
<?php
namespace App\Models\user;
use App\Models\CommonModel;
class IntraCodeModel extends CommonModel
{
protected $table = 'lie_intracode';
const CREATED_AT = 'create_time';
const UPDATED_AT = 'update_time';
public static function wherePaginate($pagesize, $whereList = [])
{
return self::where($whereList)->paginate($pagesize);
}
public static function insertAndGetId($data){
return self::insertGetId($data);
}
}
<?php
namespace App\Models\user;
use App\Models\CommonModel;
use Illuminate\Database\Eloquent\Model;
class OrganizationModel extends CommonModel
{
protected $table = 'organization';
protected $primaryKey = 'departmentId';
public static function getDepartmentInfoMap($departmentId)
{
return self::leftJoin('user_info', 'organization.userId', '=', 'user_info.userId')
->where('organization.departmentId', $departmentId)
->select('user_info.userId', 'user_info.email', 'user_info.engName',
'user_info.name', 'organization.isPartTime', 'organization.ctime',
'user_info.header', 'user_info.position', 'user_info.jobLevel', 'user_info.mobile')
->get();
}
public static function getUserIdDepartment()
{
return self::select('userId', 'departmentId')->get();
}
public static function getDepartmentIdByUserId($data)
{
$res = self::where('userId', $data)
->select('departmentId')
->first();
return ($res) ? $res->toArray() : [];
}
public static function countDepartmentId($departmentId)
{
return self::where('departmentId', $departmentId)->count();
}
public static function deleteDepartmentId($departmentId, $userId)
{
self::where('departmentId', $departmentId)->where('userId', $userId)->delete();
}
public static function getUserIdByIspartAndCtime($userId)
{
return self::where('userId', $userId)->orderBy('isPart ASC, ctime DESC')->get();
}
}
...@@ -35,4 +35,15 @@ public static function getPositionNameMap() ...@@ -35,4 +35,15 @@ public static function getPositionNameMap()
public static function getPositionNameWithIdArray(){ public static function getPositionNameWithIdArray(){
return self::select('position_name', 'position_id')->get(); return self::select('position_name', 'position_id')->get();
} }
public static function getPositionFieldList($where, $field, $limit, $page)
{
$query = self::select($field);
if ($where) {
$query->where($where);
}
return $query->orderBy('ctime', 'desc')
->orderBy('position_id', 'desc')
->paginate($limit, ['*'], 'page', $page)->toArray();
}
} }
...@@ -2,9 +2,10 @@ ...@@ -2,9 +2,10 @@
namespace App\Models\user; namespace App\Models\user;
use App\Models\CommonModel;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
class PositionPermModel extends Model class PositionPermModel extends CommonModel
{ {
protected $table = 'user_position_perm'; protected $table = 'user_position_perm';
protected $primaryKey = 'position_perm_id'; protected $primaryKey = 'position_perm_id';
...@@ -12,6 +13,10 @@ class PositionPermModel extends Model ...@@ -12,6 +13,10 @@ class PositionPermModel extends Model
// protected $fillable = ['user_role_id', 'user_role_name', 'bid', 'business_name', 'role_id', 'role_name', 'author', 'last_author']; // protected $fillable = ['user_role_id', 'user_role_name', 'bid', 'business_name', 'role_id', 'role_name', 'author', 'last_author'];
const CREATED_AT = 'ctime'; const CREATED_AT = 'ctime';
const UPDATED_AT = 'mtime'; const UPDATED_AT = 'mtime';
public function fromDateTime($value)
{
return strtotime(parent::fromDateTime($value));
}
// 获取用户角色权限 // 获取用户角色权限
public static function getUserRolePermList($position_id) public static function getUserRolePermList($position_id)
...@@ -19,5 +24,22 @@ public static function getUserRolePermList($position_id) ...@@ -19,5 +24,22 @@ public static function getUserRolePermList($position_id)
if (!$position_id) return false; if (!$position_id) return false;
return self::where('position_id', $position_id)->select('position_perm_id', 'position_id', 'bid', 'role_id')->get()->toArray(); return self::where('position_id', $position_id)->select('position_perm_id', 'position_id', 'bid', 'role_id')->get()->toArray();
} }
// 职位角色权限列表
public static function getPositionPermList($where, $field, $limit, $page)
{
$query = self::select($field);
if($where){
$query->where($where);
}
return $query->orderBy('ctime', 'desc')
->orderBy('position_perm_id', 'desc')
->paginate($limit, ['*'], 'page', $page)->toArray();
}
public static function updateOrCreateData($map, $data)
{
return self::updateOrCreate($map, $data);
}
} }
...@@ -16,4 +16,9 @@ public static function getBusinessInfoByTitle($title) ...@@ -16,4 +16,9 @@ public static function getBusinessInfoByTitle($title)
$res = self::where('title', $title)->first(); $res = self::where('title', $title)->first();
return $res ? $res->toArray() : []; return $res ? $res->toArray() : [];
} }
// 获取所有业务系统名称
public static function getBusinessNameList()
{
return self::pluck('title', 'bid')->toArray();
}
} }
...@@ -23,5 +23,11 @@ public static function getBidUsername($bid, $roleName) ...@@ -23,5 +23,11 @@ public static function getBidUsername($bid, $roleName)
$res = self::where(['bid' => $bid, 'name' => $roleName])->first(); $res = self::where(['bid' => $bid, 'name' => $roleName])->first();
return $res ? $res->toArray() : []; return $res ? $res->toArray() : [];
} }
// 获取所有业务系统角色
public static function getRoles($bid)
{
return self::where('bid', $bid)->pluck('name', 'roleId')->toArray();
}
} }
...@@ -2,9 +2,10 @@ ...@@ -2,9 +2,10 @@
namespace App\Models\user; namespace App\Models\user;
use App\Models\CommonModel;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
class TUserPermModel extends Model class TUserPermModel extends CommonModel
{ {
protected $table = 't_user_perm'; protected $table = 't_user_perm';
protected $primaryKey = 'userId'; protected $primaryKey = 'userId';
......
...@@ -14,14 +14,6 @@ class UserInfoModel extends commonModel ...@@ -14,14 +14,6 @@ class UserInfoModel extends commonModel
const STATUS_WORKING = 0; const STATUS_WORKING = 0;
const STATUS_NOT_WORKING = 4; const STATUS_NOT_WORKING = 4;
public static function getNameWithEngNameMap($userId)
{
return self::leftJoin('user_info as t', 'user_info.superior', '=', 't.userId')
->where('user_info.userId', $userId)
->select('user_info.*', 't.engName as sup_engName', 't.name as sup_name')
->first();
}
public static function getInfoById($id) public static function getInfoById($id)
{ {
$res = self::where('userId', $id)->first(); $res = self::where('userId', $id)->first();
...@@ -34,7 +26,9 @@ public static function getInfoByIds($user_ids) ...@@ -34,7 +26,9 @@ public static function getInfoByIds($user_ids)
return ($res) ? $res->toArray() : []; return ($res) ? $res->toArray() : [];
} }
public static function getByWhere($whereList){
return self::where($whereList)->get();
}
public static function deleteInfoById($id) public static function deleteInfoById($id)
{ {
...@@ -45,7 +39,6 @@ public static function InsertUser($info) ...@@ -45,7 +39,6 @@ public static function InsertUser($info)
return self::insert($info); return self::insert($info);
} }
public static function queryLimitOffset($whereList, $limit, $offset) public static function queryLimitOffset($whereList, $limit, $offset)
{ {
$query = self::where($whereList); $query = self::where($whereList);
......
<?php
namespace App\Models\user;
use App\Models\CommonModel;
use Illuminate\Database\Eloquent\Model;
class UserLoginModel extends CommonModel
{
protected $table = 'user_login';
public $timestamps = false;
public static function insertData($data)
{
return self::insert($data);
}
public static function getLoginListByUserIdAndTime($userId, $expire)
{
$res = self::where('userId', $userId)
->where('expireTime', '>', $expire)->get();
return ($res) ? $res->toArray() : [];
}
// 根据条件获取列表
public static function getListByWhere($where, $page, $limit, $field = "*")
{
$query = self::select($field);
if ($where) {
$query->where($where);
}
return $query->orderBy('loginTime', 'desc')->paginate($limit, ['*'], 'page', $page)->toArray();
}
}
...@@ -4,6 +4,9 @@ ...@@ -4,6 +4,9 @@
class UserModel extends CommonModel { class UserModel extends CommonModel {
protected $table = "user"; protected $table = "user";
const CREATED_AT = 'ctime';
const UPDATED_AT = 'mtime';
public static function InsertUser($user){ public static function InsertUser($user){
return self::insertGetId($user); return self::insertGetId($user);
} }
......
<?php
namespace App\Models\user;
use App\Models\CommonModel;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\DB;
class UserTokenModel extends CommonModel
{
const TOKEN_RESET_PASSWD_FORCE = 1;
const TOKEN_RESET_PASSWD_EMAIL = 2;
protected $table = 'user_token';
const TOKEN_LENGTH = 64; // token的随机数字节数; base64之后是 TOKEN_LENGTH * 2
public static function checkToken($userId, $token)
{
$count = self::where('userId', $userId)
->where('status', 0)->where('token', $token)
->where('expireTime', '>=', date('Y-m-d H:i:s'))->count();
return $count == 1;
}
}
<?php
namespace App\Models\web;
use App\Models\CommonModel;
use Illuminate\Database\Eloquent\Model;
class UserMainModel extends CommonModel
{
protected $connection = 'web';
protected $table = 'user_main';
protected $primaryKey = 'id';
// 根据用户ids,获取用户列表
public static function getUsersByIds($user_ids)
{
$res = self::whereIn('user_id', $user_ids)->get();
return ($res) ? $res->toArray() : [];
}
public static function getUserMobileByUserId($id)
{
return self::whereIn('user_id', $id)->get();
}
public static function getIdByMobile($val)
{
return self::where('mobile', $val)->select('user_id')->first();
}
public static function countUid($data)
{
return self::where('invite_uid', $data)
->count();
}
public static function getNameMobileEmail($data)
{
$res = self::where('user_id', $data)
->select('mobile', 'email', 'user_name')
->first();
return ($res) ? $res->toArray() : [];
}
}
...@@ -63,6 +63,32 @@ ...@@ -63,6 +63,32 @@
]) : [], ]) : [],
], ],
'web' => [
'driver' => 'mysql',
'host' => get_resource_config_section('db', 'db_liexin')['host'],
'database' => get_resource_config_section('db', 'db_liexin')['db'],
'username' => get_resource_config_section('db', 'db_liexin')['user'],
'password' => get_resource_config_section('db', 'db_liexin')['passwd'],
'port' => 3306,
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => 'lie_',
'strict' => false,
],
'spu' => [
'driver' => 'mysql',
'host' => get_resource_config_section('db', 'db_spu')['host'],
'database' => get_resource_config_section('db', 'db_spu')['db'],
'username' => get_resource_config_section('db', 'db_spu')['user'],
'password' => get_resource_config_section('db', 'db_spu')['passwd'],
'port' => 3306,
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => 'lie_',
'strict' => false,
],
'pgsql' => [ 'pgsql' => [
'driver' => 'pgsql', 'driver' => 'pgsql',
'url' => env('DATABASE_URL'), 'url' => env('DATABASE_URL'),
...@@ -133,7 +159,12 @@ ...@@ -133,7 +159,12 @@
'port' => get_resource_config_section('redis', 'user')['port'], 'port' => get_resource_config_section('redis', 'user')['port'],
'database' => env('REDIS_DB', '0'), 'database' => env('REDIS_DB', '0'),
], ],
'data' => [
'host' => get_resource_config_section('redis', 'data')['host'],
'password' => get_resource_config_section('redis', 'data')['passwd'],
'port' => get_resource_config_section('redis', 'data')['port'],
'database' => 0,
],
'cache' => [ 'cache' => [
'url' => env('REDIS_URL'), 'url' => env('REDIS_URL'),
'host' => env('REDIS_HOST', '127.0.0.1'), 'host' => env('REDIS_HOST', '127.0.0.1'),
......
...@@ -52,55 +52,6 @@ layui.config({ ...@@ -52,55 +52,6 @@ layui.config({
}; };
renderTable(); renderTable();
// layui.use(['form', 'table', 'laydate'], function () {
// var form = layui.form;
// var table = layui.table;
// var laydate = layui.laydate;
//
// laydate.render({
// elem: '#begin_time' //指定元素
// });
//
// laydate.render({
// elem: '#end_time' //指定元素
// });
// var renderTable = function () {
// table.render({
// id: 'list'
// , elem: '#department'
// , url: '/ajax/departmentList' //数据接口
// , method: 'post'
// , cellMinWidth: 80 //全局定义常规单元格的最小宽度
// , page: true //开启分页
// , cols: [[ //表头
// {title: '序号', type: 'numbers', fixed: 'left', width: 60}
// , {field: 'department_id', title: '部门ID', width: 100}
// , {field: 'department_name', title: '部门名称', width: 313}
// , {field: 'author', title: '创建人', width: 260}
// , {field: 'last_author', title: '修改人', width: 260}
// , {field: 'ctime', title: '创建时间', width: 220}
// , {field: 'mtime', title: '修改时间', width: 220}
// , {title: '操作', fixed: 'right', toolbar: '#department_action', width: 120}
// ]]
// , limit: 10
// , limits: [10, 20, 50,]
// });
// };
//
// renderTable(); // 加载表格
// form.on('submit(load)', function(data) {
// //执行重载
// table.reload('list', {
// page: {
// curr: 1
// }
// ,where: data.field
// });
//
// return false;
// });
// tool操作 // tool操作
table.on('tool(department)', function (obj) { //注:tool是工具条事件名,department是table原始容器的属性lay-filter="对应的值" table.on('tool(department)', function (obj) { //注:tool是工具条事件名,department是table原始容器的属性lay-filter="对应的值"
...@@ -156,16 +107,16 @@ layui.config({ ...@@ -156,16 +107,16 @@ layui.config({
return false; return false;
} }
if (type == 1) { if (type === 1) {
var url = '/api/department/addDepartment'; var url = '/api/department/addDepartment';
var msg = '新增部门中...'; var msg = '新增部门中...';
} else if (type == 2) { } else if (type === 2) {
var url = '/api/department/editDepartment'; var url = '/api/department/editDepartment';
var msg = '编辑部门中...'; var msg = '编辑部门中...';
} else if (type == 3) { } else if (type === 3) {
var url = '/api/department/delDepartment'; var url = '/api/department/delDepartment';
var msg = '删除部门中...'; var msg = '删除部门中...';
} else if (type == 4) { } else if (type === 4) {
var url = '/api/department/addChildDepartment'; var url = '/api/department/addChildDepartment';
var msg = '新增子级中...'; var msg = '新增子级中...';
} }
...@@ -181,7 +132,7 @@ layui.config({ ...@@ -181,7 +132,7 @@ layui.config({
type: 'post', type: 'post',
data: datas, data: datas,
success: function (resp) { success: function (resp) {
if (resp.code == 0) { if (resp.code === 0) {
layer.msg(resp.msg); layer.msg(resp.msg);
renderTable(); // 重新加载table renderTable(); // 重新加载table
......
...@@ -6,7 +6,7 @@ layui.use(['form','layer'], function(){ ...@@ -6,7 +6,7 @@ layui.use(['form','layer'], function(){
form.on('submit(formDemo)', function(data){ form.on('submit(formDemo)', function(data){
$.ajax({ $.ajax({
type: 'post', type: 'post',
url: '/intracode/binding', url: '/api/intracode/binding',
timeout : 10000, //超时时间设置,单位毫秒 timeout : 10000, //超时时间设置,单位毫秒
data: { data: {
code_id:data.field.code_id, code_id:data.field.code_id,
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>账号管理系统 | {{$title or ''}}</title> <title>账号管理系统 | {{$title ?? ''}}</title>
@include('web.css') @include('web.css')
<style> <style>
......
...@@ -10,9 +10,11 @@ ...@@ -10,9 +10,11 @@
<label class="layui-form-label">前台账号</label> <label class="layui-form-label">前台账号</label>
<div class="layui-input-block"> <div class="layui-input-block">
@if(!empty($info['mobile'])) @if(!empty($info['mobile']))
<input type="text" autocomplete="off" autocomplete="off" class="layui-input" value="{{$info['mobile'] or ''}}" disabled> <input type="text" autocomplete="off" autocomplete="off" class="layui-input"
value="{{$info['mobile'] ?? ''}}" disabled>
@else @else
<input type="text" name="mobile" autocomplete="off" placeholder="请输入手机号" autocomplete="off" class="layui-input"> <input type="text" name="mobile" autocomplete="off" placeholder="请输入手机号" autocomplete="off"
class="layui-input">
@endif @endif
</div> </div>
</div> </div>
...@@ -24,7 +26,7 @@ ...@@ -24,7 +26,7 @@
<select name="admin_id" lay-search> <select name="admin_id" lay-search>
<option value="">未绑定</option> <option value="">未绑定</option>
@foreach($all_admin as $k=>$v) @foreach($all_admin as $k=>$v)
<option value="{{$v->userId}}">{{$v->name or $v->email}}</option> <option value="{{$v->userId}}">{{$v->name?$v->name:$v->email}}</option>
@endforeach @endforeach
</select> </select>
@else @else
...@@ -47,7 +49,7 @@ ...@@ -47,7 +49,7 @@
</select> </select>
@else @else
<select name="city" disabled> <select name="city" disabled>
<option value="">{{$info['supplier_name'] or ''}}</option> <option value="">{{$info['supplier_name'] ?? ''}}</option>
</select> </select>
@endif @endif
</div> </div>
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>帐号系统 | {{$title}}</title> {{-- <title>帐号系统 | {{$title}}</title>--}}
@include('userlist.css') @include('userlist.css')
</head> </head>
...@@ -63,7 +63,7 @@ ...@@ -63,7 +63,7 @@
<tr role="row"> <tr role="row">
<td style="width:100px;" class="text-center">{{$v['code_id']}}</td> <td style="width:100px;" class="text-center">{{$v['code_id']}}</td>
<td style="width:120px;" class="text-center"> <td style="width:120px;" class="text-center">
{{$v['name'] or '未绑定'}} {{$v['name'] ? $v['name']: '未绑定'}}
<span class="label label-primary"> <span class="label label-primary">
{{ $v['title'] ? $v['title'] : '猎芯科技' }} {{ $v['title'] ? $v['title'] : '猎芯科技' }}
</span> </span>
...@@ -83,8 +83,8 @@ ...@@ -83,8 +83,8 @@
<a class="btn btn-xs btn-outline btn-warning Unbundling" data-type="supplier" data-id="{{$v['code_id']}}">解绑</a> <a class="btn btn-xs btn-outline btn-warning Unbundling" data-type="supplier" data-id="{{$v['code_id']}}">解绑</a>
@endif @endif
</td> </td>
<td style="width:100px;" class="text-center">{{$v['user_count'] or 0}}</td> <td style="width:100px;" class="text-center">{{$v['user_count'] ? $v['user_count']: 0}}</td>
<td style="width:133px;" class="text-center">{{date('Y-m-d H:i',$v['update_time'])}}</td> <td style="width:133px;" class="text-center">{{date('Y-m-d H:i',strtotime($v['update_time']))}}</td>
<td style="width: 64px;" class="text-center"> <td style="width: 64px;" class="text-center">
@if(!empty($v['status'])) @if(!empty($v['status']))
<span class="label label-primary"> <span class="label label-primary">
...@@ -128,7 +128,7 @@ ...@@ -128,7 +128,7 @@
</tbody> </tbody>
<tfoot></tfoot> <tfoot></tfoot>
</table> </table>
{!! $list ? $list->links() : '' !!} {!! $links !!}
</div> </div>
</div> </div>
<div class="row" id="my_list_paginate"></div> <div class="row" id="my_list_paginate"></div>
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>账号管理系统 | {{$title or ''}}</title> <title>账号管理系统 | {{$title ?? ''}}</title>
@include('web.css') @include('web.css')
<style> <style>
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>账号管理系统 | {{$title or ''}}</title> <title>账号管理系统 | {{$title ?? ''}}</title>
@include('web.css') @include('web.css')
<style> <style>
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>账号管理系统 | {{$title or ''}}</title> <title>账号管理系统 | {{$title ?? ''}}</title>
@include('web.css') @include('web.css')
<style> <style>
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>账号管理系统 | {{$title or ''}}</title> <title>账号管理系统 | {{$title ?? ''}}</title>
@include('role.css') @include('role.css')
<style> <style>
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>账号管理系统 | {{$title or ''}}</title> <title>账号管理系统 | {{$title ?? ''}}</title>
@include('role.css') @include('role.css')
<style> <style>
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>账号管理系统 | {{$title or ''}}</title> <title>账号管理系统 | {{$title ?? ''}}</title>
@include('web.css') @include('web.css')
<style> <style>
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>账号管理系统 | {{$title or ''}}</title> <title>账号管理系统 | {{$title ?? ''}}</title>
@include('web.css') @include('web.css')
<style> <style>
......
<?php <?php
use App\Http\Controllers\CodeController;
use App\Http\Controllers\DepartmentController; use App\Http\Controllers\DepartmentController;
use App\Http\Controllers\LoginController;
use App\Http\Controllers\PositionController;
use App\Http\Controllers\PositionPermController;
use App\Http\Controllers\RoleController;
use App\Http\Controllers\UserController; use App\Http\Controllers\UserController;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route; use Illuminate\Support\Facades\Route;
...@@ -32,3 +37,22 @@ ...@@ -32,3 +37,22 @@
Route::match(['get', 'post'], '/department/delDepartment', [DepartmentController::class, 'delDepartment']); Route::match(['get', 'post'], '/department/delDepartment', [DepartmentController::class, 'delDepartment']);
Route::match(['get', 'post'], '/department/addDepartment', [DepartmentController::class, 'addDepartment']); Route::match(['get', 'post'], '/department/addDepartment', [DepartmentController::class, 'addDepartment']);
Route::match(['get', 'post'], '/department/editDepartment', [DepartmentController::class, 'editDepartment']); Route::match(['get', 'post'], '/department/editDepartment', [DepartmentController::class, 'editDepartment']);
Route::match(['get', 'post'], '/position/getPositionList', [PositionController::class, 'getPositionList']);
Route::match(['get', 'post'], '/position/addPosition', [PositionController::class, 'addPosition']);
Route::match(['get', 'post'], '/position/editPosition', [PositionController::class, 'editPosition']);
Route::match(['get', 'post'], '/position/delPosition', [PositionController::class, 'delPosition']);
Route::match(['get', 'post'], '/positionPerm/getPositionPermList', [PositionPermController::class, 'getPositionPermList']);
Route::match(['get', 'post'], '/positionPerm/setPositionPerm', [PositionPermController::class, 'setPositionPerm']);
Route::match(['get', 'post'], '/positionPerm/delPositionPerm', [PositionPermController::class, 'delPositionPerm']);
Route::match(['get', 'post'], '/businessRoles/getBusinessRoles', [RoleController::class, 'getBusinessRoles']);
Route::match(['get', 'post'], '/intracode/Unbundling', [CodeController::class, 'Unbundling']);
Route::match(['get', 'post'], '/intracode/refreshDingDing', [CodeController::class, 'refreshDingDing']);
Route::match(['get', 'post'], '/intracode/binding', [CodeController::class, 'binding']);
Route::match(['get', 'post'], '/log/getLoginLogList', [LoginController::class, 'getLoginLogList']);
Route::post('/resetpasswd', [UserController::class, 'resetpasswd']);//用户修改密码接口
<?php <?php
use App\Http\Controllers\CodeController;
use App\Http\Controllers\ConfigController;
use App\Http\Controllers\DepartmentController; use App\Http\Controllers\DepartmentController;
use App\Http\Controllers\PositionController;
use App\Http\Controllers\PositionPermController;
use Illuminate\Support\Facades\Route; use Illuminate\Support\Facades\Route;
use App\Http\Controllers\UserController; use App\Http\Controllers\UserController;
...@@ -25,3 +29,11 @@ ...@@ -25,3 +29,11 @@
Route::get('/user/{id?}', [UserController::class, 'info']); Route::get('/user/{id?}', [UserController::class, 'info']);
Route::match(['get', 'post'], '/web/departmentList', [DepartmentController::class, 'departmentList']); Route::match(['get', 'post'], '/web/departmentList', [DepartmentController::class, 'departmentList']);
Route::match(['get', 'post'], '/web/positionList', [PositionController::class, 'positionList']);
Route::match(['get', 'post'], '/web/positionPermList', [PositionPermController::class, 'positionPermList']);
Route::match(['get', 'post'], '/intracode/codelist', [CodeController::class, 'codelist']);
Route::match(['get', 'post'], '/intracode/Handle_code', [CodeController::class, 'Handle_code']);
Route::get('/resetpasswd', [UserController::class, 'resetPassWord']);//用户修改密码
Route::match(['get', 'post'], '/web/loginLog', [UserController::class, 'loginLog']);
Route::get('/help', [ConfigController::class, 'help']);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment