Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
D
data-server
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
licc
data-server
Commits
8e97a67a
Commit
8e97a67a
authored
Feb 23, 2021
by
m1991
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
简单登录功能
parent
c9af998c
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
127 additions
and
0 deletions
+127
-0
UsersMapper.java
...mapper/src/main/java/cn/wisenergy/mapper/UsersMapper.java
+5
-0
UsersMapper.xml
wisenergy-mapper/src/main/resources/mapper/UsersMapper.xml
+21
-0
UserService.java
.../main/java/cn/wisenergy/service/app/impl/UserService.java
+63
-0
UserController.java
...src/main/java/cn/wisenergy/controller/UserController.java
+38
-0
No files found.
wisenergy-mapper/src/main/java/cn/wisenergy/mapper/UsersMapper.java
View file @
8e97a67a
...
...
@@ -43,4 +43,9 @@ public interface UsersMapper extends BaseMapper<User> {
List
<
User
>
getList
(
Map
<
String
,
Object
>
map
);
List
<
User
>
findAll
();
User
findByName
(
String
name
);
String
findPswByName
(
String
UserName
);
void
save
(
User
user
);
}
wisenergy-mapper/src/main/resources/mapper/UsersMapper.xml
View file @
8e97a67a
...
...
@@ -144,4 +144,25 @@
limit #{pageNo},#{pageSize}
</where>
</select>
<!--查询全部-->
<select
id=
"findAll"
resultType=
"User"
>
select * from User
</select>
<!--查询用户-->
<select
id=
"findByName"
resultType=
"User"
>
select * from User where user_id = #{userId}
</select>
<!--查询密码-->
<select
id=
"findPswByName"
resultType=
"String"
>
select password from user where user_id = #{userId}
</select>
<!--用户添加-->
<insert
id=
"save"
>
insert into user(user_id,password) value (#{userId},#{password})
</insert>
</mapper>
wisenergy-service/src/main/java/cn/wisenergy/service/app/impl/UserService.java
0 → 100644
View file @
8e97a67a
package
cn
.
wisenergy
.
service
.
app
.
impl
;
import
cn.wisenergy.common.utils.R
;
import
cn.wisenergy.mapper.UsersMapper
;
import
cn.wisenergy.model.app.User
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
/**
* @ Description: 用户接口实现
* @ Author : 86187
* @ Date : 2021/1/6 16:11
* @author 86187
*/
@Service
@Slf4j
public
class
UserService
extends
ServiceImpl
<
UsersMapper
,
User
>
{
@Autowired
private
UsersMapper
userMapper
;
public
String
login
(
User
user
){
//TODO:登陆逻辑函数
try
{
User
userExistN
=
userMapper
.
findByName
(
String
.
valueOf
(
user
.
getUserId
()));
if
(
userExistN
!=
null
){
String
userExistP
=
userMapper
.
findPswByName
(
String
.
valueOf
(
user
.
getUserId
()));
if
(
userExistP
.
equals
(
user
.
getPassword
())){
return
user
.
getUserId
()+
" 用户登录成功,欢迎您!"
;
}
else
{
return
"登陆失败,密码错误!"
;
}
}
else
{
return
"登陆失败,账户不存在"
;
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
e
.
getMessage
();
}
}
public
String
regist
(
User
user
){
//TODO:注册判断逻辑函数
try
{
User
userExist
=
userMapper
.
findByName
(
String
.
valueOf
(
user
.
getUserId
()));
if
(
user
.
getUserId
().
equals
(
""
)){
return
"账户名不能为空"
;
}
else
if
(
user
.
getPassword
().
equals
(
""
)){
return
"密码不能为空"
;
}
else
if
(
userExist
!=
null
){
return
"账户已经存在"
;
}
else
{
userMapper
.
save
(
user
);
return
"注册成功"
;
}
}
catch
(
Exception
e
){
e
.
printStackTrace
();
return
e
.
getMessage
();
}
}
}
wisenergy-web-admin/src/main/java/cn/wisenergy/controller/UserController.java
0 → 100644
View file @
8e97a67a
package
cn
.
wisenergy
.
controller
;
import
cn.wisenergy.model.app.User
;
import
cn.wisenergy.service.app.impl.UserService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
springfox.documentation.swagger2.annotations.EnableSwagger2
;
/**
* Created by m1991 on 2021/2/23 15:45
*/
@EnableSwagger2
@RestController
@RequestMapping
(
"/sys"
)
public
class
UserController
{
@Autowired
UserService
userService
;
/**
* 登录
*/
@PostMapping
(
"/login"
)
public
String
login
(
User
user
){
return
userService
.
login
(
user
);
}
/**
* 注册
* @param user
* @return
*/
@PostMapping
(
"/regist"
)
public
String
regist
(
User
user
){
return
userService
.
regist
(
user
);
}
}
\ No newline at end of file
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