Commit 80d2b6ba by lincyawer

重构完成

parent d8f711ff
...@@ -122,6 +122,7 @@ public function code_info($code_id = 0, $map = array()) ...@@ -122,6 +122,7 @@ public function code_info($code_id = 0, $map = array())
} }
foreach ($return as $key => $intracode_item) { foreach ($return as $key => $intracode_item) {
// var_dump($intracode_item);
$intracode_info = $intracode_item->toArray(); $intracode_info = $intracode_item->toArray();
$adm_user_info = $adm_user_map[$intracode_info['admin_id']] ?? []; $adm_user_info = $adm_user_map[$intracode_info['admin_id']] ?? [];
$name = ''; $name = '';
...@@ -132,8 +133,8 @@ public function code_info($code_id = 0, $map = array()) ...@@ -132,8 +133,8 @@ public function code_info($code_id = 0, $map = array())
} }
} }
$web_user_info = isset($web_user_map[$intracode_info['user_id']]) ? $web_user_map[$intracode_info['user_id']] : []; $web_user_info = $web_user_map[$intracode_info['user_id']] ?? [];
$supplier_info = isset($code_id_supplier_map[$intracode_info['code_id']]) ? $code_id_supplier_map[$intracode_info['code_id']] : []; $supplier_info = $code_id_supplier_map[$intracode_info['code_id']] ?? [];
$extra_info = [ $extra_info = [
'name' => $name, 'name' => $name,
'status' => ($adm_user_info) ? $adm_user_info['status'] : "", 'status' => ($adm_user_info) ? $adm_user_info['status'] : "",
...@@ -203,7 +204,7 @@ public function Handle_code(Request $request) ...@@ -203,7 +204,7 @@ public function Handle_code(Request $request)
//提取未绑定得供应商 //提取未绑定得供应商
$all_supplier = SupplierModel::wherePluck([['code', ''], ['status', 1]], ['supplier_name', 'supplier_id']); $all_supplier = SupplierModel::pluckWhere([['code', ''], ['status', 1]], ['supplier_name', 'supplier_id']);
if (!empty($code_id) && $code_id != 0) { if (!empty($code_id) && $code_id != 0) {
$info = IntraCodeModel::querySingle([['code_id', $code_id]]); $info = IntraCodeModel::querySingle([['code_id', $code_id]]);
...@@ -256,7 +257,7 @@ public function Unbundling(Request $request) ...@@ -256,7 +257,7 @@ public function Unbundling(Request $request)
$this->Export(10002, '解绑失败'); $this->Export(10002, '解绑失败');
} }
} }
$redis = Redis::connection(); $redis = Cache::getRedis();
$redis->hdel('intracode', $code_id); $redis->hdel('intracode', $code_id);
$this->Export(0, '解绑成功'); $this->Export(0, '解绑成功');
......
...@@ -2,6 +2,9 @@ ...@@ -2,6 +2,9 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\Models\web\DashboardConfigModel;
use Illuminate\Http\Request;
class ConfigController extends Controller class ConfigController extends Controller
{ {
// 帮助文档 // 帮助文档
...@@ -9,4 +12,36 @@ public function help() ...@@ -9,4 +12,36 @@ public function help()
{ {
return redirect('/doc/user_helper.html'); return redirect('/doc/user_helper.html');
} }
public function dashboard(Request $request)
{
$ft = [];
try {
$ft = DashboardConfigModel::getConfigId();
if ($ft) {
$ft->config = json_decode($ft->config, true);
}
if (!$ft || !is_array($ft->config)) {
abort(400);
}
} catch (\Exception $e) {
abort(500);
}
$username = $request->user->email;
// 尽调账号隐藏指定后台系统
foreach ($ft->config as $k => $v) {
foreach ($v['urls'] as $key => $val) {
if (in_array($val['url'], Config('website.hide_site')) && $username == 'vpadmin@ichunt.com') {
unset($ft->config[$k]['urls'][$key]);
// array_splice($ft->config[$k]['urls'], $key, 1); // 删除指定链接
}
}
}
$vpadmin_filter = ['订单系统', '财务系统', '数据对接'];
return view('config.dashboard',
['urlgroup' => $ft->config, 'vpadmin_filter' => $vpadmin_filter, 'curr_user' => $request->user->email]);
}
} }
...@@ -120,7 +120,7 @@ private static function generateSession($userId, $userIp, $email, $name, $engNam ...@@ -120,7 +120,7 @@ private static function generateSession($userId, $userIp, $email, $name, $engNam
'userId' => $userId, 'userId' => $userId,
'skey' => self::createSkey(), 'skey' => self::createSkey(),
'loginTime' => date('Y-m-d H:i:s'), 'loginTime' => date('Y-m-d H:i:s'),
'expireTime' => date('Y-m-d H:i:s', time() + self::expireTime()), 'expireTime' => date('Y-m-d H:i:s', time() + LoginService::expireTime()),
'loginIp' => $userIp, 'loginIp' => $userIp,
]; ];
...@@ -152,12 +152,6 @@ private static function createSkey(): string ...@@ -152,12 +152,6 @@ private static function createSkey(): string
return bin2hex(openssl_random_pseudo_bytes(self::SKEY_LENGTH)); return bin2hex(openssl_random_pseudo_bytes(self::SKEY_LENGTH));
} }
private static function expireTime(): int
{
$expire = Config::get('website.skeyExpire');
return $expire ? $expire : 3600 * 12;
}
private static function saveToRedis($info, $expire = 0) private static function saveToRedis($info, $expire = 0)
{ {
$key = LoginService::sessionKey($info['userId'], $info['skey']); // 32个字节足够了 $key = LoginService::sessionKey($info['userId'], $info['skey']); // 32个字节足够了
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\Http\Caches\MenuCache;
use App\Http\Caches\PermCache;
use App\Http\Error; use App\Http\Error;
use App\Http\Output; use App\Http\Output;
use App\Http\Service\DepartmentService; use App\Http\Service\DepartmentService;
...@@ -283,7 +285,14 @@ public function update(Request $request) ...@@ -283,7 +285,14 @@ public function update(Request $request)
$queue = new QueuedModel(); $queue = new QueuedModel();
$queue->pushAmq(json_encode($saveData)); $queue->pushAmq(json_encode($saveData));
} }
// 如果职位变更,删除系统的权限和菜单缓存
if ($info['position_id'] != $user->position_id){
$perm_cache = new PermCache();
$perm_cache->deleteAllSystemPermCache();
$menu_cache = new MenuCache();
$menu_cache->deleteAllSystemMenuCache();
}
return Output::makeResult($request, 0); return Output::makeResult($request, 0);
} catch (\Exception $e) { } catch (\Exception $e) {
$err_msg = "msg:{$e->getMessage()},file:{$e->getFile()},line:{$e->getLine()}"; $err_msg = "msg:{$e->getMessage()},file:{$e->getFile()},line:{$e->getLine()}";
...@@ -734,8 +743,6 @@ public static function loginLog(Request $request) ...@@ -734,8 +743,6 @@ public static function loginLog(Request $request)
return view('user.loginLogList', $info); return view('user.loginLogList', $info);
} }
} }
......
...@@ -197,9 +197,9 @@ public static function getMenuPerm($menus, $user_id) ...@@ -197,9 +197,9 @@ public static function getMenuPerm($menus, $user_id)
public static function getParentDepartment($id) public static function getParentDepartment($id)
{ {
$parentId = DepartmentModel::getParentId($id); $parentId = DepartmentModel::getParentId($id);
$parentDep = DepartmentModel::getInfoById($parentId); $parentDep = DepartmentModel::getInfoById($parentId['parent_id']);
if (isset($parentDep[0])) { if (!empty($parentDep)) {
return $parentDep[0]['department_name']; return $parentDep['department_name'];
} }
return ''; return '';
} }
......
...@@ -135,6 +135,8 @@ public static function getList(Request $request): array ...@@ -135,6 +135,8 @@ public static function getList(Request $request): array
$total = $result['total']; $total = $result['total'];
$users = $result['data']; $users = $result['data'];
$list = []; $list = [];
$i = 0;
foreach ($users as $u) { foreach ($users as $u) {
$list[] = [ $list[] = [
'userId' => $u->userId, 'userId' => $u->userId,
...@@ -152,17 +154,11 @@ public static function getList(Request $request): array ...@@ -152,17 +154,11 @@ public static function getList(Request $request): array
'jobLevel' => $u->jobLevel, 'jobLevel' => $u->jobLevel,
'status' => $u->status, 'status' => $u->status,
'qq' => $u->qq, 'qq' => $u->qq,
'parent_department_name' => PermService::getParentDepartment($u['department_id']),
'index' => ++$i,
]; ];
} }
$i = 0;
foreach ($list as $key => $value) {
//获取上级部门名称
$list[$key]['parent_department_name'] = PermService::getParentDepartment($value['department_id']);
$list[$key]['index'] = ++$i;
}
$data = ['page' => $page, 'count' => $count, 'total' => $total, 'list' => $list]; $data = ['page' => $page, 'count' => $count, 'total' => $total, 'list' => $list];
return Output::makeResult($request, 0, null, $data); return Output::makeResult($request, 0, null, $data);
...@@ -328,6 +324,7 @@ public static function getDepartmentHtml($tree) ...@@ -328,6 +324,7 @@ public static function getDepartmentHtml($tree)
return $html; return $html;
} }
public static function getUserListMapByIds($user_ids) public static function getUserListMapByIds($user_ids)
{ {
$user_list = UserInfoModel::getInfoByIds($user_ids); $user_list = UserInfoModel::getInfoByIds($user_ids);
...@@ -337,6 +334,7 @@ public static function getUserListMapByIds($user_ids) ...@@ -337,6 +334,7 @@ public static function getUserListMapByIds($user_ids)
} }
return $user_list_map; return $user_list_map;
} }
public static function checkoutPassword($info, $oldpasswd) public static function checkoutPassword($info, $oldpasswd)
{ {
if (!$info) { if (!$info) {
...@@ -345,6 +343,7 @@ public static function checkoutPassword($info, $oldpasswd) ...@@ -345,6 +343,7 @@ public static function checkoutPassword($info, $oldpasswd)
$passwd = UserService::createPasswd($oldpasswd, $info['slat']); $passwd = UserService::createPasswd($oldpasswd, $info['slat']);
return $passwd == $info['passwd']; return $passwd == $info['passwd'];
} }
// 线上销售离职,推送到CRM队列 // 线上销售离职,推送到CRM队列
public static function sysToCrm($info) public static function sysToCrm($info)
{ {
......
...@@ -46,4 +46,8 @@ public static function createToken($userId, $expire = null) ...@@ -46,4 +46,8 @@ public static function createToken($userId, $expire = null)
} }
return $data; return $data;
} }
public static function setTokenStatus($userId, $token, $status)
{
return UserTokenModel::updateWhere([['userId', $userId],['token', $token]], ['status' => $status, 'mtime' => date('Y-m-d H:i:s')]);
}
} }
<?php <?php
namespace App\Models\config; namespace App\Models\config;
use Illuminate\Database\Eloquent\Model; use App\Models\CommonModel;
class ConfigModel extends CommonModel
class ConfigModel extends Model
{ {
protected $table = 'config'; protected $table = 'config';
protected $primaryKey = 'config_id'; protected $primaryKey = 'config_id';
......
<?php <?php
namespace App\Models\crm; namespace App\Models\crm;
use Illuminate\Database\Eloquent\Model; use App\Models\CommonModel;
class EmployeeCardModel extends Model class EmployeeCardModel extends CommonModel
{ {
protected $connection = 'crm'; protected $connection = 'crm';
protected $table = 'employee_card'; protected $table = 'employee_card';
......
...@@ -2,29 +2,13 @@ ...@@ -2,29 +2,13 @@
namespace App\Models\department; namespace App\Models\department;
use Illuminate\Database\Eloquent\Model; use App\Models\CommonModel;
class DepartmentModel extends Model class DepartmentModel extends CommonModel
{ {
protected $table = 'department'; protected $table = 'department';
protected $primaryKey = 'departmentId'; 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) public static function getTitleParent($data)
{ {
$res = self::where('departmentId', $data) $res = self::where('departmentId', $data)
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
namespace App\Models\queue; namespace App\Models\queue;
use App\Models\CommonModel; use App\Models\CommonModel;
use Illuminate\Database\Eloquent\Model;
use PhpAmqpLib\Connection\AMQPStreamConnection; use PhpAmqpLib\Connection\AMQPStreamConnection;
use PhpAmqpLib\Message\AMQPMessage; use PhpAmqpLib\Message\AMQPMessage;
...@@ -26,24 +25,6 @@ public function pushAmq($content = '') ...@@ -26,24 +25,6 @@ public function pushAmq($content = '')
$connection->close(); $connection->close();
} }
public function pullAmq($queue_name = '')
{
// $queue_name = 'test';
$config = Config('database.connections.rabbitmq');
$connection = new AMQPStreamConnection($config['host'], $config['port'], $config['login'], $config['password'],
$config['vhost']); // 创建连接
$channel = $connection->channel();
$message = $channel->basic_get($queue_name); // 取出消息
echo '<pre>';
print_r($message);
$channel->basic_ack($message->delivery_info['delivery_tag']); // 确认取出消息后会发送一个ack来确认取出来了,然后会从rabbitmq中将这个消息移除,如果删掉这段代码,会发现rabbitmq中的消息还是没有减少
$channel->close();
$connection->close();
}
// 自定义队列推送 // 自定义队列推送
public function pushQueue($queue_name, $content) public function pushQueue($queue_name, $content)
{ {
......
...@@ -25,10 +25,4 @@ public static function getSupplierListByCodeIds($code_ids) ...@@ -25,10 +25,4 @@ public static function getSupplierListByCodeIds($code_ids)
$res = self::whereIn('code', $code_ids)->get(); $res = self::whereIn('code', $code_ids)->get();
return ($res) ? $res->toArray() : []; return ($res) ? $res->toArray() : [];
} }
public static function wherePluck($whereList, $pluckList)
{
return self::where($whereList)->pluck(...$pluckList);
}
} }
...@@ -34,7 +34,7 @@ public static function deleteDepartmentId($departmentId) ...@@ -34,7 +34,7 @@ public static function deleteDepartmentId($departmentId)
public static function getDepartmentNameWithIdArray() public static function getDepartmentNameWithIdArray()
{ {
$res = self::select('department_name', 'department_id')->get(); $res = self::pluck('department_name', 'department_id');
return $res; return $res;
} }
......
...@@ -3,28 +3,12 @@ ...@@ -3,28 +3,12 @@
namespace App\Models\user; namespace App\Models\user;
use App\Models\CommonModel; use App\Models\CommonModel;
use Illuminate\Database\Eloquent\Model;
class OrganizationModel extends CommonModel class OrganizationModel extends CommonModel
{ {
protected $table = 'organization'; protected $table = 'organization';
protected $primaryKey = 'departmentId'; 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) public static function getDepartmentIdByUserId($data)
{ {
$res = self::where('userId', $data) $res = self::where('userId', $data)
...@@ -32,19 +16,4 @@ public static function getDepartmentIdByUserId($data) ...@@ -32,19 +16,4 @@ public static function getDepartmentIdByUserId($data)
->first(); ->first();
return ($res) ? $res->toArray() : []; 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();
}
} }
...@@ -33,7 +33,7 @@ public static function getPositionNameMap() ...@@ -33,7 +33,7 @@ public static function getPositionNameMap()
return $data; return $data;
} }
public static function getPositionNameWithIdArray(){ public static function getPositionNameWithIdArray(){
return self::select('position_name', 'position_id')->get(); return self::pluck('position_name', 'position_id');
} }
public static function getPositionFieldList($where, $field, $limit, $page) public static function getPositionFieldList($where, $field, $limit, $page)
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
namespace App\Models\user; namespace App\Models\user;
use App\Models\CommonModel; use App\Models\CommonModel;
use Illuminate\Database\Eloquent\Model;
class PositionPermModel extends CommonModel class PositionPermModel extends CommonModel
{ {
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
namespace App\Models\user; namespace App\Models\user;
use Illuminate\Database\Eloquent\Model; use App\Models\CommonModel;
class TRolePermModel extends Model class TRolePermModel extends CommonModel
{ {
protected $table = 't_role_perm'; protected $table = 't_role_perm';
protected $primaryKey = 'roleId'; protected $primaryKey = 'roleId';
...@@ -28,6 +28,4 @@ public static function getRoles($bid) ...@@ -28,6 +28,4 @@ public static function getRoles($bid)
{ {
return self::where('bid', $bid)->pluck('name', 'roleId')->toArray(); return self::where('bid', $bid)->pluck('name', 'roleId')->toArray();
} }
} }
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
namespace App\Models\user; namespace App\Models\user;
use App\Models\CommonModel; use App\Models\CommonModel;
use Illuminate\Database\Eloquent\Model;
class TUserPermModel extends CommonModel class TUserPermModel extends CommonModel
{ {
......
...@@ -4,9 +4,8 @@ ...@@ -4,9 +4,8 @@
use App\Models\CommonModel; use App\Models\CommonModel;
class UserInfoModel extends commonModel class UserInfoModel extends CommonModel
{ {
const tableName = 'user_info';
protected $table = 'user_info'; protected $table = 'user_info';
protected $primaryKey = 'userId'; protected $primaryKey = 'userId';
public $timestamps = false; public $timestamps = false;
......
...@@ -3,26 +3,12 @@ ...@@ -3,26 +3,12 @@
namespace App\Models\user; namespace App\Models\user;
use App\Models\CommonModel; use App\Models\CommonModel;
use Illuminate\Database\Eloquent\Model;
class UserLoginModel extends CommonModel class UserLoginModel extends CommonModel
{ {
protected $table = 'user_login'; protected $table = 'user_login';
public $timestamps = false; 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 = "*") public static function getListByWhere($where, $page, $limit, $field = "*")
{ {
......
...@@ -3,8 +3,6 @@ ...@@ -3,8 +3,6 @@
namespace App\Models\user; namespace App\Models\user;
use App\Models\CommonModel; use App\Models\CommonModel;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\DB;
class UserTokenModel extends CommonModel class UserTokenModel extends CommonModel
{ {
......
<?php
namespace App\Models\web;
use App\Models\CommonModel;
class DashboardConfigModel extends CommonModel {
protected $table = 'dashboard_config';
protected $primaryKey = 'configId';
const CREATED_AT = 'ctime';
const UPDATED_AT = 'mtime';
public static function getConfigId(){
return self::where('configId', 0)->first();
}
}
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
namespace App\Models\web; namespace App\Models\web;
use App\Models\CommonModel; use App\Models\CommonModel;
use Illuminate\Database\Eloquent\Model;
class UserMainModel extends CommonModel class UserMainModel extends CommonModel
{ {
...@@ -18,11 +17,6 @@ public static function getUsersByIds($user_ids) ...@@ -18,11 +17,6 @@ public static function getUsersByIds($user_ids)
return ($res) ? $res->toArray() : []; return ($res) ? $res->toArray() : [];
} }
public static function getUserMobileByUserId($id)
{
return self::whereIn('user_id', $id)->get();
}
public static function getIdByMobile($val) public static function getIdByMobile($val)
{ {
return self::where('mobile', $val)->select('user_id')->first(); return self::where('mobile', $val)->select('user_id')->first();
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
namespace App\Providers; namespace App\Providers;
use Illuminate\Pagination\Paginator;
use Illuminate\Support\ServiceProvider; use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider class AppServiceProvider extends ServiceProvider
...@@ -23,6 +24,6 @@ public function register() ...@@ -23,6 +24,6 @@ public function register()
*/ */
public function boot() public function boot()
{ {
// Paginator::useBootstrap();
} }
} }
...@@ -11,6 +11,7 @@ var myTable = {}; ...@@ -11,6 +11,7 @@ var myTable = {};
var _isAdmin = null; var _isAdmin = null;
function buildTable($tbody, data, isAdmin) function buildTable($tbody, data, isAdmin)
{ {
console.log(data);
var i = 1; var i = 1;
$tbody.html(''); $tbody.html('');
for (var i = 0; i < data.length; i++) { for (var i = 0; i < data.length; i++) {
......
...@@ -128,7 +128,7 @@ ...@@ -128,7 +128,7 @@
</tbody> </tbody>
<tfoot></tfoot> <tfoot></tfoot>
</table> </table>
{!! $links !!} {{ $list->links() }}
</div> </div>
</div> </div>
<div class="row" id="my_list_paginate"></div> <div class="row" id="my_list_paginate"></div>
......
...@@ -19,9 +19,6 @@ ...@@ -19,9 +19,6 @@
| |
*/ */
//Route::get('/', function () {
// return view('welcome');
//});
Route::get('/', [UserController::class, 'my']); Route::get('/', [UserController::class, 'my']);
Route::get('/my', [UserController::class, 'my']);//目前路由为 /my Route::get('/my', [UserController::class, 'my']);//目前路由为 /my
Route::get('/userlist', [UserController::class, 'userlist']); Route::get('/userlist', [UserController::class, 'userlist']);
...@@ -36,4 +33,7 @@ ...@@ -36,4 +33,7 @@
Route::match(['get', 'post'], '/intracode/Handle_code', [CodeController::class, 'Handle_code']); Route::match(['get', 'post'], '/intracode/Handle_code', [CodeController::class, 'Handle_code']);
Route::get('/resetpasswd', [UserController::class, 'resetPassWord']);//用户修改密码 Route::get('/resetpasswd', [UserController::class, 'resetPassWord']);//用户修改密码
Route::match(['get', 'post'], '/web/loginLog', [UserController::class, 'loginLog']); Route::match(['get', 'post'], '/web/loginLog', [UserController::class, 'loginLog']);
Route::get('/help', [ConfigController::class, 'help']); Route::get('/help', [ConfigController::class, 'help']);
Route::get('/dashboard', [ConfigController::class, 'dashboard']);
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