Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
L
laravelzh
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
冯超鹏
laravelzh
Commits
da8d947b
Commit
da8d947b
authored
Apr 03, 2020
by
冯超鹏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加新的功能
parent
4613efb9
Pipeline
#20
canceled with stages
Changes
14
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
303 additions
and
100 deletions
+303
-100
CODE_OF_CONDUCT.md
CODE_OF_CONDUCT.md
+1
-0
AuthController.php
app/Http/Controllers/AuthController.php
+24
-2
Controller.php
app/Http/Controllers/Controller.php
+10
-1
DevicesController.php
app/Http/Controllers/DevicesController.php
+40
-5
UserController.php
app/Http/Controllers/UserController.php
+124
-79
WxuserController.php
app/Http/Controllers/WxuserController.php
+1
-1
User.php
app/Laravue/Models/User.php
+1
-0
Users.php
app/Laravue/Models/Users.php
+57
-1
auth.php
config/auth.php
+9
-5
dump.rdb
dump.rdb
+0
-0
zh.js
resources/js/lang/zh.js
+1
-0
index.vue
resources/js/views/login/index.vue
+29
-4
index.vue
resources/js/views/wx_user/index.vue
+2
-2
api.php
routes/api.php
+4
-0
No files found.
CODE_OF_CONDUCT.md
View file @
da8d947b
...
...
@@ -74,3 +74,4 @@ available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.ht
For answers to common questions about this code of conduct, see
https://www.contributor-covenant.org/faq
admin@laravadmin@laravue.devue.devadmin@laravue.dev
\ No newline at end of file
app/Http/Controllers/AuthController.php
View file @
da8d947b
...
...
@@ -13,7 +13,8 @@ use Illuminate\Http\Request;
use
Illuminate\Http\Response
;
use
Illuminate\Support\Facades\Auth
;
use
App\Http\Resources\UserResource
;
use
Illuminate\Support\Facades\DB
;
use
App\Laravue\Models\Users
;
/**
* Class AuthController
*
...
...
@@ -24,8 +25,9 @@ class AuthController extends Controller
/**
* @param Request $request
* @return \Illuminate\Http\JsonResponse
* @ 管理员登入
*/
public
function
login
(
Request
$request
)
public
function
login
(
Request
$request
,
Users
$users
)
{
$credentials
=
$request
->
only
(
'email'
,
'password'
);
if
(
!
Auth
::
attempt
(
$credentials
))
{
...
...
@@ -35,9 +37,11 @@ class AuthController extends Controller
$user
=
$request
->
user
();
$tokenResult
=
$user
->
createToken
(
'Personal Access Token'
);
$token
=
$tokenResult
->
token
;
$token
->
save
();
return
response
()
->
json
(
new
UserResource
(
$user
),
Response
::
HTTP_OK
)
->
header
(
'Authorization'
,
$tokenResult
->
accessToken
);
}
public
function
logout
(
Request
$request
)
...
...
@@ -50,4 +54,22 @@ class AuthController extends Controller
{
return
new
UserResource
(
Auth
::
user
());
}
// 用户登入接口
public
function
userslogin
(
Request
$request
,
Users
$users
){
$credentials
=
$request
->
only
(
'email'
,
'password'
);
$email
=
$credentials
[
'email'
];
$password
=
$credentials
[
'password'
];
// if (!Auth::attempt($credentials)) {
// return response()->json(new JsonResponse([], 'login_error'), Response::HTTP_UNAUTHORIZED);
// }
$BackgroundUser
=
$users
->
where
([[
'username'
,
'='
,
$email
],[
'password'
,
'='
,
sha1
(
$password
)],[
'state'
,
'='
,
'2'
]])
->
first
();
if
(
$BackgroundUser
){
$tokenResult
=
$BackgroundUser
->
createToken
(
'Personal Access Token'
);
$token
=
$tokenResult
->
token
;
$token
->
save
();
return
response
()
->
json
(
new
UserResource
(
$BackgroundUser
),
Response
::
HTTP_OK
)
->
header
(
'Authorization'
,
$tokenResult
->
accessToken
);
}
else
{
return
response
()
->
json
(
new
JsonResponse
([],
'login_error'
),
Response
::
HTTP_UNAUTHORIZED
);
}
}
}
app/Http/Controllers/Controller.php
View file @
da8d947b
...
...
@@ -6,7 +6,8 @@ use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use
Illuminate\Foundation\Bus\DispatchesJobs
;
use
Illuminate\Foundation\Validation\ValidatesRequests
;
use
Illuminate\Routing\Controller
as
BaseController
;
use
Illuminate\Support\Facades\DB
;
use
Illuminate\Support\Facades\Auth
;
class
Controller
extends
BaseController
{
use
AuthorizesRequests
,
DispatchesJobs
,
ValidatesRequests
;
...
...
@@ -58,4 +59,12 @@ class Controller extends BaseController
],
];
}
/*
* 验证当前登入用户
* */
public
function
isadmin
(){
$user
=
Auth
::
user
();
//获取当前用户信息
$isadmin
=
DB
::
table
(
'users'
)
->
where
([[
'name'
,
'='
,
$user
[
'name'
]],
[
'email'
,
'='
,
$user
[
'email'
]]])
->
first
();
return
$isadmin
;
}
}
app/Http/Controllers/DevicesController.php
View file @
da8d947b
...
...
@@ -67,10 +67,41 @@ class DevicesController extends Controller
}
}
//返回逻辑删除的设备
public
function
physicsdelete
(
Request
$request
){
$deviceid
=
$request
->
input
(
'deviceid'
);
$databadevice
=
DB
::
table
(
'device'
);
if
(
$_POST
){
$up
=
$databadevice
->
where
(
'id'
,
'='
,
$deviceid
)
->
update
([
'delete'
=>
2
]);
return
$this
->
jsonSuccessData
(
$up
);
}
else
{
//返回物理删除设备列表
$type
=
(
int
)
$request
->
input
(
'type'
);
//设备类型
$pagenNum
=
$request
->
input
(
'page'
)
-
1
;
//页数
$limit
=
$request
->
input
(
'limit'
);
//条数
if
(
$pagenNum
===
''
||
$limit
==
''
){
return
$this
->
jsonErrorData
(
105
,
'页数或limit不能为空'
);
}
$devicelist
=
$databadevice
->
where
(
'dtype'
,
'='
,
$type
==
''
?
'1'
:
$type
)
->
where
(
'delete'
,
'='
,
'1'
)
//设备逻辑删除状态
->
join
(
'device_type as dy'
,
"device.dtype"
,
'='
,
'dy.tid'
)
->
join
(
'gas as g'
,
"device.status"
,
'='
,
'g.id'
)
->
select
(
'dy.tname'
,
'g.gas'
,
'device.*'
)
->
orderBy
(
'device.id'
,
'desc'
)
->
offset
(
$pagenNum
)
->
limit
(
$limit
)
->
get
()
->
toArray
();
return
$this
->
jsonSuccessData
(
$devicelist
);
}
}
//添加设备
public
function
adddevice
(
Request
$request
){
}
//返回设备类型和单位和介质
...
...
@@ -85,6 +116,7 @@ class DevicesController extends Controller
$databadevice
=
DB
::
table
(
'device'
);
$devicelist
=
$databadevice
->
where
(
'dtype'
,
'='
,
$type
)
->
where
(
'delete'
,
'='
,
'2'
)
//设备不是删除状态
->
join
(
'device_type as dy'
,
"device.dtype"
,
'='
,
'dy.tid'
)
->
join
(
'gas as g'
,
"device.status"
,
'='
,
'g.id'
)
->
select
(
'dy.tname'
,
'g.gas'
,
'device.*'
)
...
...
@@ -104,10 +136,13 @@ class DevicesController extends Controller
private
function
getValidationRulesdevice
(
$isNew
=
true
)
{
return
[
'devicenum'
=>
'required|between:2,25|regex:/^[A-Za-z0-9\-\_]+$/|unique:BackgroundUser,username'
,
'password'
=>
'sometimes|required|string|min:6'
,
'contacts_phone'
=>
'required|regex:/^1[3465789]\d{9}$/|unique:BackgroundUser'
,
'nickname'
=>
'required|between:2,25|regex:/^[A-Za-z0-9\-\_]+$/|unique:BackgroundUser,nickname'
'devicenum'
=>
'required|between:2,25|unique:device,devicenum'
,
//设备编号
'username'
=>
'required|unique:device,username|max:40'
,
//设备名称
'devicephone'
=>
'required|regex:/^1[3465789]\d{9}$/|unique:device,devicephone|max:11'
,
//联系人手机号
'devicelinkman'
=>
'required|max:15'
,
'dtypeid'
=>
'sometimes|required'
,
'statusid'
=>
'sometimes|required'
,
'devicemonadid'
=>
'sometimes|required'
];
}
...
...
app/Http/Controllers/UserController.php
View file @
da8d947b
This diff is collapsed.
Click to expand it.
app/Http/Controllers/WxuserController.php
View file @
da8d947b
...
...
@@ -9,7 +9,7 @@
namespace
App\Http\Controllers
;
use
App\Laravue\Models\wxUser
;
use
App\Laravue\Models\wxUser
;
use
Illuminate\Http\Request
;
use
Illuminate\Support\Facades\DB
;
use
Illuminate\Http\Resources\Json\ResourceCollection
;
...
...
app/Laravue/Models/User.php
View file @
da8d947b
...
...
@@ -75,6 +75,7 @@ class User extends Authenticatable
/**
* @return bool
* 验证是否管理员
*/
public
function
isAdmin
()
:
bool
{
...
...
app/Laravue/Models/Users.php
View file @
da8d947b
...
...
@@ -14,13 +14,14 @@ use Spatie\Permission\Traits\HasRoles;
* @property string $email
* @property string $password
* @property Role[] $roles
*
*
protected
* @method static User create(array $user)
* @package App
*/
class
Users
extends
Authenticatable
{
use
Notifiable
,
HasRoles
,
HasApiTokens
;
protected
$table
=
"BackgroundUser"
;
public
$timestamps
=
false
;
...
...
@@ -29,4 +30,59 @@ class Users extends Authenticatable
$userdata
[
'add_time'
]
=
time
();
return
$this
->
insertGetId
(
$userdata
);
}
protected
$fillable
=
[
'email'
,
'password'
,
];
protected
$hidden
=
[
'password'
,
'remember_token'
,
];
/**
* The attributes that should be cast to native types.
*
* @var array
*/
protected
$casts
=
[
'email_verified_at'
=>
'datetime'
,
];
/**
* Set permissions guard to API by default
* @var string
*/
protected
$guard_name
=
'api'
;
/**
* @inheritdoc
*/
public
function
getJWTIdentifier
()
{
return
$this
->
getKey
();
}
/**
* @inheritdoc
*/
public
function
getJWTCustomClaims
()
{
return
[];
}
/**
* @return bool
* 验证是否管理员
*/
public
function
isAdmin
()
:
bool
{
foreach
(
$this
->
roles
as
$role
)
{
if
(
$role
->
isAdmin
())
{
return
true
;
}
}
return
false
;
}
}
\ No newline at end of file
config/auth.php
View file @
da8d947b
...
...
@@ -46,6 +46,11 @@ return [
'provider'
=>
'users'
,
'hash'
=>
false
,
],
'admin'
=>
[
'driver'
=>
'passport'
,
'provider'
=>
'user'
,
'hash'
=>
false
,
],
],
/*
...
...
@@ -70,11 +75,10 @@ return [
'driver'
=>
'eloquent'
,
'model'
=>
App\Laravue\Models\User
::
class
,
],
// 'users' => [
// 'driver' => 'database',
// 'table' => 'users',
// ],
'user'
=>
[
'driver'
=>
'eloquent'
,
'model'
=>
App\Laravue\Models\Users
::
class
,
],
],
/*
...
...
dump.rdb
0 → 100644
View file @
da8d947b
File added
resources/js/lang/zh.js
View file @
da8d947b
...
...
@@ -77,6 +77,7 @@ export default {
},
login
:
{
title
:
'系统登录'
,
user
:
'用户登录'
,
logIn
:
'登录'
,
username
:
'账号'
,
password
:
'密码'
,
...
...
resources/js/views/login/index.vue
View file @
da8d947b
<
template
>
<div
class=
"login-container"
>
<el-form
ref=
"loginForm"
:model=
"loginForm"
:rules=
"loginRules"
class=
"login-form"
auto-complete=
"on"
label-position=
"left"
>
<h3
class=
"title"
>
{{
$t
(
'login.title'
)
}}
</h3>
<el-tabs
v-model=
"activeName"
@
tab-click=
"handleClick"
>
<el-tab-pane
label=
"系统登录"
name=
"first"
class=
"el-tabs__item"
>
<!--
<h3
class=
"title"
>
{{
$t
(
'login.title'
)
}}
</h3>
-->
</el-tab-pane>
<el-tab-pane
label=
"用户登录"
name=
"second"
>
<!--
<h3
class=
"title"
>
{{
$t
(
'login.user'
)
}}
</h3>
-->
</el-tab-pane>
</el-tabs>
<lang-select
class=
"set-language"
/>
<el-form-item
prop=
"email"
>
<span
class=
"svg-container"
>
...
...
@@ -43,7 +53,6 @@
<
script
>
import
LangSelect
from
'@/components/LangSelect'
;
import
{
validEmail
}
from
'@/utils/validate'
;
export
default
{
name
:
'Login'
,
components
:
{
LangSelect
},
...
...
@@ -74,6 +83,7 @@ export default {
loading
:
false
,
pwdType
:
'password'
,
redirect
:
undefined
,
activeName
:
'second'
,
};
},
watch
:
{
...
...
@@ -85,6 +95,9 @@ export default {
},
},
methods
:
{
handleClick
(
tab
,
event
)
{
console
.
log
(
tab
,
event
);
},
showPwd
()
{
if
(
this
.
pwdType
===
'password'
)
{
this
.
pwdType
=
''
;
...
...
@@ -165,6 +178,18 @@ $light_gray:#eee;
max-width
:
100%
;
padding
:
35px
35px
15px
35px
;
margin
:
120px
auto
;
.el-tabs__item
{
padding
:
0
20px
;
height
:
40px
;
box-sizing
:
border-box
;
line-height
:
40px
;
display
:
inline-block
;
list-style
:
none
;
font-size
:
14px
;
font-weight
:
500
;
color
:
#fff
;
position
:
relative
;
}
}
.tips
{
font-size
:
14px
;
...
...
resources/js/views/wx_user/index.vue
View file @
da8d947b
...
...
@@ -35,7 +35,7 @@
</el-table-column>
<el-table-column
label=
"用户头像"
align=
"center"
width=
"120"
>
<
template
slot-scope=
"scope"
>
<el-image
:src=
"scope.row.headimgurl"
:fit=
"fit"
></el-image>
<el-image
:src=
"scope.row.headimgurl"
:fit=
"fit"
></el-image>
</
template
>
</el-table-column>
<el-table-column
label=
"用户名称"
width=
"130px"
align=
"center"
>
...
...
@@ -199,7 +199,7 @@ export default {
title
:
undefined
,
type
:
undefined
,
sort
:
'+id'
,
fits
:
[
'fill'
,
'contain'
,
'cover'
,
'none'
,
'scale-down'
],
fits
:
[
'fill'
,
'contain'
,
'cover'
,
'none'
,
'scale-down'
],
}
,
calendarTypeOptions
,
sortOptions
:
[{
label
:
'ID Ascending'
,
key
:
'+id'
}
,
{
label
:
'ID Descending'
,
key
:
'-id'
}
],
...
...
routes/api.php
View file @
da8d947b
...
...
@@ -16,6 +16,7 @@ use \App\Laravue\JsonResponse;
*/
Route
::
post
(
'auth/login'
,
'AuthController@login'
);
Route
::
post
(
'auth/userslogin'
,
'AuthController@userslogin'
);
Route
::
group
([
'middleware'
=>
'auth:api'
],
function
()
{
Route
::
get
(
'auth/user'
,
'AuthController@user'
);
Route
::
post
(
'auth/logout'
,
'AuthController@logout'
);
...
...
@@ -32,6 +33,8 @@ Route::group(['middleware' => 'auth:api'], function () {
Route
::
post
(
'user/deleteuser'
,
'UserController@deleteuser'
)
->
middleware
(
'permission:'
.
\App\Laravue\Acl
::
PERMISSION_PERMISSION_MANAGE
);
//删除用户
Route
::
match
([
'get'
,
'post'
],
'user/Upuser'
,
'UserController@Upuser'
)
->
middleware
(
'permission:'
.
\App\Laravue\Acl
::
PERMISSION_PERMISSION_MANAGE
);
//更新用户
Route
::
match
([
'get'
,
'post'
],
'user/areachina'
,
'UserController@areachina'
)
->
middleware
(
'permission:'
.
\App\Laravue\Acl
::
PERMISSION_PERMISSION_MANAGE
);
//获取地址列表
Route
::
post
(
'user/addcontactsuser'
,
'UserController@addcontactsuser'
)
->
middleware
(
'permission:'
.
\App\Laravue\Acl
::
PERMISSION_PERMISSION_MANAGE
);
//添加联系人
Route
::
get
(
'user/contactslist'
,
'UserController@contactslist'
);
});
//设备路由
...
...
@@ -40,6 +43,7 @@ Route::group(['middleware'=>'auth:api'],function (){
Route
::
get
(
'devices/devicetype'
,
'DevicesController@devicetype'
);
//设备类型
Route
::
post
(
'devices/deletedecice'
,
'DevicesController@deletedecice'
)
->
middleware
(
'permission:'
.
\App\Laravue\Acl
::
PERMISSION_PERMISSION_MANAGE
);
//删除设备
Route
::
post
(
'devices/adddevice'
,
'DevicesController@adddevice'
)
->
middleware
(
'permission:'
.
\App\Laravue\Acl
::
PERMISSION_PERMISSION_MANAGE
);
//新增设备
Route
::
match
([
'get'
,
'post'
],
'device/physicsdelete'
,
'DevicesController@physicsdelete'
)
->
middleware
(
'permission:'
.
\App\Laravue\Acl
::
PERMISSION_PERMISSION_MANAGE
);
//返回设备列表和更改设备
});
// Fake APIs
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment