Commit 80d2b6ba by lincyawer

重构完成

parent d8f711ff
......@@ -122,6 +122,7 @@ public function code_info($code_id = 0, $map = array())
}
foreach ($return as $key => $intracode_item) {
// var_dump($intracode_item);
$intracode_info = $intracode_item->toArray();
$adm_user_info = $adm_user_map[$intracode_info['admin_id']] ?? [];
$name = '';
......@@ -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']] : [];
$supplier_info = isset($code_id_supplier_map[$intracode_info['code_id']]) ? $code_id_supplier_map[$intracode_info['code_id']] : [];
$web_user_info = $web_user_map[$intracode_info['user_id']] ?? [];
$supplier_info = $code_id_supplier_map[$intracode_info['code_id']] ?? [];
$extra_info = [
'name' => $name,
'status' => ($adm_user_info) ? $adm_user_info['status'] : "",
......@@ -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) {
$info = IntraCodeModel::querySingle([['code_id', $code_id]]);
......@@ -256,7 +257,7 @@ public function Unbundling(Request $request)
$this->Export(10002, '解绑失败');
}
}
$redis = Redis::connection();
$redis = Cache::getRedis();
$redis->hdel('intracode', $code_id);
$this->Export(0, '解绑成功');
......
......@@ -2,6 +2,9 @@
namespace App\Http\Controllers;
use App\Models\web\DashboardConfigModel;
use Illuminate\Http\Request;
class ConfigController extends Controller
{
// 帮助文档
......@@ -9,4 +12,36 @@ public function help()
{
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
'userId' => $userId,
'skey' => self::createSkey(),
'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,
];
......@@ -152,12 +152,6 @@ private static function createSkey(): string
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)
{
$key = LoginService::sessionKey($info['userId'], $info['skey']); // 32个字节足够了
......
......@@ -2,6 +2,8 @@
namespace App\Http\Controllers;
use App\Http\Caches\MenuCache;
use App\Http\Caches\PermCache;
use App\Http\Error;
use App\Http\Output;
use App\Http\Service\DepartmentService;
......@@ -283,7 +285,14 @@ public function update(Request $request)
$queue = new QueuedModel();
$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);
} catch (\Exception $e) {
$err_msg = "msg:{$e->getMessage()},file:{$e->getFile()},line:{$e->getLine()}";
......@@ -734,8 +743,6 @@ public static function loginLog(Request $request)
return view('user.loginLogList', $info);
}
}
......
......@@ -197,9 +197,9 @@ public static function getMenuPerm($menus, $user_id)
public static function getParentDepartment($id)
{
$parentId = DepartmentModel::getParentId($id);
$parentDep = DepartmentModel::getInfoById($parentId);
if (isset($parentDep[0])) {
return $parentDep[0]['department_name'];
$parentDep = DepartmentModel::getInfoById($parentId['parent_id']);
if (!empty($parentDep)) {
return $parentDep['department_name'];
}
return '';
}
......
......@@ -135,6 +135,8 @@ public static function getList(Request $request): array
$total = $result['total'];
$users = $result['data'];
$list = [];
$i = 0;
foreach ($users as $u) {
$list[] = [
'userId' => $u->userId,
......@@ -152,17 +154,11 @@ public static function getList(Request $request): array
'jobLevel' => $u->jobLevel,
'status' => $u->status,
'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];
return Output::makeResult($request, 0, null, $data);
......@@ -328,6 +324,7 @@ public static function getDepartmentHtml($tree)
return $html;
}
public static function getUserListMapByIds($user_ids)
{
$user_list = UserInfoModel::getInfoByIds($user_ids);
......@@ -337,6 +334,7 @@ public static function getUserListMapByIds($user_ids)
}
return $user_list_map;
}
public static function checkoutPassword($info, $oldpasswd)
{
if (!$info) {
......@@ -345,6 +343,7 @@ public static function checkoutPassword($info, $oldpasswd)
$passwd = UserService::createPasswd($oldpasswd, $info['slat']);
return $passwd == $info['passwd'];
}
// 线上销售离职,推送到CRM队列
public static function sysToCrm($info)
{
......
......@@ -46,4 +46,8 @@ public static function createToken($userId, $expire = null)
}
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
namespace App\Models\config;
use Illuminate\Database\Eloquent\Model;
class ConfigModel extends Model
use App\Models\CommonModel;
class ConfigModel extends CommonModel
{
protected $table = 'config';
protected $primaryKey = 'config_id';
......
<?php
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 $table = 'employee_card';
......
......@@ -2,29 +2,13 @@
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 $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)
......
......@@ -3,7 +3,6 @@
namespace App\Models\queue;
use App\Models\CommonModel;
use Illuminate\Database\Eloquent\Model;
use PhpAmqpLib\Connection\AMQPStreamConnection;
use PhpAmqpLib\Message\AMQPMessage;
......@@ -26,24 +25,6 @@ public function pushAmq($content = '')
$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)
{
......
......@@ -25,10 +25,4 @@ 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);
}
}
......@@ -34,7 +34,7 @@ public static function deleteDepartmentId($departmentId)
public static function getDepartmentNameWithIdArray()
{
$res = self::select('department_name', 'department_id')->get();
$res = self::pluck('department_name', 'department_id');
return $res;
}
......
......@@ -3,28 +3,12 @@
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)
......@@ -32,19 +16,4 @@ public static function getDepartmentIdByUserId($data)
->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();
}
}
......@@ -33,7 +33,7 @@ public static function getPositionNameMap()
return $data;
}
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)
......
......@@ -3,7 +3,6 @@
namespace App\Models\user;
use App\Models\CommonModel;
use Illuminate\Database\Eloquent\Model;
class PositionPermModel extends CommonModel
{
......
......@@ -2,9 +2,9 @@
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 $primaryKey = 'roleId';
......@@ -28,6 +28,4 @@ public static function getRoles($bid)
{
return self::where('bid', $bid)->pluck('name', 'roleId')->toArray();
}
}
......@@ -3,7 +3,6 @@
namespace App\Models\user;
use App\Models\CommonModel;
use Illuminate\Database\Eloquent\Model;
class TUserPermModel extends CommonModel
{
......
......@@ -4,9 +4,8 @@
use App\Models\CommonModel;
class UserInfoModel extends commonModel
class UserInfoModel extends CommonModel
{
const tableName = 'user_info';
protected $table = 'user_info';
protected $primaryKey = 'userId';
public $timestamps = false;
......
......@@ -3,26 +3,12 @@
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 = "*")
{
......
......@@ -3,8 +3,6 @@
namespace App\Models\user;
use App\Models\CommonModel;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\DB;
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 @@
namespace App\Models\web;
use App\Models\CommonModel;
use Illuminate\Database\Eloquent\Model;
class UserMainModel extends CommonModel
{
......@@ -18,11 +17,6 @@ public static function getUsersByIds($user_ids)
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();
......
......@@ -2,6 +2,7 @@
namespace App\Providers;
use Illuminate\Pagination\Paginator;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
......@@ -23,6 +24,6 @@ public function register()
*/
public function boot()
{
//
Paginator::useBootstrap();
}
}
......@@ -11,6 +11,7 @@ var myTable = {};
var _isAdmin = null;
function buildTable($tbody, data, isAdmin)
{
console.log(data);
var i = 1;
$tbody.html('');
for (var i = 0; i < data.length; i++) {
......@@ -249,4 +250,4 @@ var myTable = {};
myTable.getData(1);
}
})();
\ No newline at end of file
})();
......@@ -128,7 +128,7 @@
</tbody>
<tfoot></tfoot>
</table>
{!! $links !!}
{{ $list->links() }}
</div>
</div>
<div class="row" id="my_list_paginate"></div>
......
......@@ -19,9 +19,6 @@
|
*/
//Route::get('/', function () {
// return view('welcome');
//});
Route::get('/', [UserController::class, 'my']);
Route::get('/my', [UserController::class, 'my']);//目前路由为 /my
Route::get('/userlist', [UserController::class, 'userlist']);
......@@ -36,4 +33,7 @@
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']);
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