Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
map-parent
Overview
Overview
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
常超
map-parent
Commits
684daecf
Commit
684daecf
authored
Aug 05, 2021
by
YANGYANG
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
登录
parent
09a7ba34
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
67 additions
and
0 deletions
+67
-0
service/asj/src/main/java/com/founder/asj/controller/LoginController.java
+38
-0
service/asj/src/main/java/com/founder/asj/mapper/SysUsersMapper.java
+2
-0
service/asj/src/main/java/com/founder/asj/service/SysUsersService.java
+3
-0
service/asj/src/main/java/com/founder/asj/service/impl/SysUsersServiceImpl.java
+24
-0
No files found.
service/asj/src/main/java/com/founder/asj/controller/LoginController.java
0 → 100644
View file @
684daecf
package
com
.
founder
.
asj
.
controller
;
import
com.founder.asj.service.SysUsersService
;
import
com.founder.commonutils.publicEntity.MapRestResult
;
import
com.founder.commonutils.publicEntity.SysUser
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
@RestController
@RequestMapping
(
"/"
)
@Api
(
tags
=
"登陆管理"
)
public
class
LoginController
{
@Autowired
private
SysUsersService
userService
;
@ApiOperation
(
value
=
"登陆"
)
@PostMapping
(
"/login"
)
@ResponseBody
public
MapRestResult
login
(
@RequestParam
String
username
,
@RequestParam
String
password
){
SysUser
user
=
new
SysUser
();
user
.
setUsername
(
username
);
user
.
setPassword
(
password
);
if
(
user
!=
null
)
{
SysUser
loginUser
=
userService
.
login
(
user
);
if
(
loginUser
==
null
)
{
return
MapRestResult
.
build
(
201
,
"用户名或密码错误"
,
"1"
);
}
else
{
return
MapRestResult
.
build
(
200
,
"登陆成功"
,
"1"
,
loginUser
);
}
}
return
MapRestResult
.
error
();
}
}
service/asj/src/main/java/com/founder/asj/mapper/SysUsersMapper.java
View file @
684daecf
...
@@ -4,6 +4,7 @@ package com.founder.asj.mapper;
...
@@ -4,6 +4,7 @@ package com.founder.asj.mapper;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.founder.commonutils.publicEntity.SysUser
;
import
com.founder.commonutils.publicEntity.SysUser
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.springframework.stereotype.Component
;
/**
/**
* <p>
* <p>
...
@@ -14,6 +15,7 @@ import org.apache.ibatis.annotations.Mapper;
...
@@ -14,6 +15,7 @@ import org.apache.ibatis.annotations.Mapper;
* @since 2021-03-11
* @since 2021-03-11
*/
*/
@Mapper
@Mapper
@Component
public
interface
SysUsersMapper
extends
BaseMapper
<
SysUser
>
{
public
interface
SysUsersMapper
extends
BaseMapper
<
SysUser
>
{
}
}
service/asj/src/main/java/com/founder/asj/service/SysUsersService.java
View file @
684daecf
...
@@ -4,6 +4,9 @@ package com.founder.asj.service;
...
@@ -4,6 +4,9 @@ package com.founder.asj.service;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.founder.commonutils.publicEntity.SysUser
;
import
com.founder.commonutils.publicEntity.SysUser
;
import
javax.servlet.http.HttpServletRequest
;
public
interface
SysUsersService
extends
IService
<
SysUser
>
{
public
interface
SysUsersService
extends
IService
<
SysUser
>
{
SysUser
login
(
SysUser
user
);
}
}
service/asj/src/main/java/com/founder/asj/service/impl/SysUsersServiceImpl.java
View file @
684daecf
package
com
.
founder
.
asj
.
service
.
impl
;
package
com
.
founder
.
asj
.
service
.
impl
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.founder.asj.mapper.SysUsersMapper
;
import
com.founder.asj.mapper.SysUsersMapper
;
import
com.founder.asj.service.SysUsersService
;
import
com.founder.asj.service.SysUsersService
;
import
com.founder.commonutils.publicEntity.SysUser
;
import
com.founder.commonutils.publicEntity.SysUser
;
import
io.swagger.annotations.ApiModel
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
java.util.Base64
;
@Service
@Service
public
class
SysUsersServiceImpl
extends
ServiceImpl
<
SysUsersMapper
,
SysUser
>
implements
SysUsersService
{
public
class
SysUsersServiceImpl
extends
ServiceImpl
<
SysUsersMapper
,
SysUser
>
implements
SysUsersService
{
@Autowired
private
SysUsersMapper
sysUsersMapper
;
@Override
public
SysUser
login
(
SysUser
user
)
{
//对password进行加密
String
password
=
Base64
.
getEncoder
().
encodeToString
(
user
.
getPassword
().
getBytes
());
QueryWrapper
<
SysUser
>
wrapper
=
new
QueryWrapper
<
SysUser
>();
// 数据库字段名 对应值
wrapper
.
eq
(
"USERNAME"
,
user
.
getUsername
());
wrapper
.
eq
(
"PASSWORD"
,
password
);
wrapper
.
eq
(
"OPEN_FLAG"
,
"1"
);
wrapper
.
eq
(
"SCBZ"
,
"0"
);
//设置需要查询的字段
wrapper
.
select
(
"IDENTITYCARD"
,
"USERNAME"
,
"UNITCODE"
,
"TRUE_NAME"
,
"TELEPHONE"
,
"UNITNAME"
,
"GRADE"
,
"POLICEMANID"
);
user
=
sysUsersMapper
.
selectOne
(
wrapper
);
return
user
;
}
}
}
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