Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
yangxiujun
/
paidan_demo
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 5ae97a31
authored
Jul 11, 2023
by
chamberone
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 添加用户登录和获取用户接口
1 parent
baf13f7e
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
106 additions
and
48 deletions
project-interface/src/main/java/com/dituhui/pea/pojo/UserLoginDTO.java
project-interface/src/main/java/com/dituhui/pea/user/IUser.java
project-user/src/main/java/com/dituhui/pea/user/controller/RoleController.java
project-user/src/main/java/com/dituhui/pea/user/controller/UserController.java
project-user/src/main/java/com/dituhui/pea/user/dao/UserDao.java
project-user/src/main/java/com/dituhui/pea/user/service/UserService.java
project-interface/src/main/java/com/dituhui/pea/pojo/UserLoginDTO.java
0 → 100644
View file @
5ae97a3
package
com
.
dituhui
.
pea
.
pojo
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
lombok.Data
;
@Data
public
class
UserLoginDTO
{
private
String
account
;
@JsonIgnore
private
String
password
;
private
String
nickname
;
private
String
email
;
private
String
phone
;
private
String
birthday
;
private
String
region
;
private
Integer
sex
;
private
String
avatar
;
private
String
wechat
;
private
String
token
;
}
project-interface/src/main/java/com/dituhui/pea/user/IUser.java
View file @
5ae97a3
package
com
.
dituhui
.
pea
.
user
;
import
com.dituhui.pea.common.Result
;
import
com.dituhui.pea.enums.ThirdPartyEnum
;
import
com.dituhui.pea.pojo.ThirdUserInfo
;
import
com.dituhui.pea.pojo.UserInfo
;
import
com.dituhui.pea.pojo.UserLoginDTO
;
import
com.dituhui.pea.pojo.WebResult
;
import
org.springframework.cloud.openfeign.FeignClient
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestHeader
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestParam
;
...
...
@@ -16,6 +19,12 @@ import org.springframework.web.bind.annotation.RequestParam;
*/
@FeignClient
(
value
=
"user"
)
public
interface
IUser
{
@RequestMapping
(
value
=
"/user/login"
,
method
=
RequestMethod
.
POST
)
public
Result
<?>
userLogin
(
@RequestBody
UserLoginDTO
user
);
@RequestMapping
(
value
=
"/user/userInfo"
,
method
=
RequestMethod
.
GET
)
public
Result
<?>
getUserInfo
(
@RequestHeader
(
name
=
"Authorization"
,
required
=
true
)
String
authorization
);
/**
* 获取当前登陆用户信息
...
...
project-user/src/main/java/com/dituhui/pea/user/controller/RoleController.java
View file @
5ae97a3
...
...
@@ -14,7 +14,6 @@ import org.springframework.web.bind.annotation.RestController;
/**
* 角色控制层
* @author zl
*/
@RestController
@RefreshScope
...
...
project-user/src/main/java/com/dituhui/pea/user/controller/UserController.java
View file @
5ae97a3
...
...
@@ -2,6 +2,8 @@ package com.dituhui.pea.user.controller;
import
cn.hutool.core.util.ObjectUtil
;
import
com.dituhui.pea.common.Result
;
import
com.dituhui.pea.enums.RedisKeyGroup
;
import
com.dituhui.pea.enums.StatusCodeEnum
;
import
com.dituhui.pea.enums.ThirdPartyEnum
;
...
...
@@ -13,13 +15,15 @@ import org.apache.commons.lang.StringUtils;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestHeader
;
import
org.springframework.web.bind.annotation.RestController
;
/**
* 用户控制层
*
* @author zl
* @since 2020-12-09 15:42:00
*/
@RestController
public
class
UserController
implements
IUser
{
...
...
@@ -29,6 +33,14 @@ public class UserController implements IUser {
@Autowired
private
RedisService
redisService
;
public
Result
<?>
userLogin
(
UserLoginDTO
user
)
{
return
userService
.
userLogin
(
user
.
getAccount
(),
user
.
getAccount
());
}
public
Result
<?>
getUserInfo
(
String
token
)
{
return
userService
.
getUserInfo
(
token
);
}
@Override
public
WebResult
<
UserInfo
>
getCurrentUserInfo
(
String
userToken
,
Boolean
needTeamInfo
)
{
...
...
project-user/src/main/java/com/dituhui/pea/user/dao/UserDao.java
View file @
5ae97a3
package
com
.
dituhui
.
pea
.
user
.
dao
;
import
java.util.List
;
import
org.springframework.data.jpa.repository.JpaRepository
;
...
...
@@ -15,56 +14,72 @@ import com.dituhui.pea.user.entity.UserEntity;
* @author zl
* @since 2020-12-09 15:34:42
*/
public
interface
UserDao
extends
JpaRepository
<
UserEntity
,
String
>,
JpaSpecificationExecutor
<
UserEntity
>,
CrudRepository
<
UserEntity
,
String
>
{
public
interface
UserDao
extends
JpaRepository
<
UserEntity
,
String
>,
JpaSpecificationExecutor
<
UserEntity
>,
CrudRepository
<
UserEntity
,
String
>
{
/**
* 根据手机号查询
*
* @param phoneNumber 手机号码
* @return
*/
UserEntity
findByPhone
(
String
phone
);
/**
* 根据手机号查询
* @param phoneNumber 手机号码
* @return
*/
UserEntity
findByPhone
(
String
phone
);
/**
* 根据邮箱查询
*
* @param email 邮箱
* @return
*/
UserEntity
findByEmail
(
String
email
);
/**
* 根据邮箱查询
* @param email 邮箱
* @return
*/
UserEntity
findByEmail
(
String
email
);
/**
* 根据微信查询
*
* @param wechat 微信
* @return
*/
List
<
UserEntity
>
findByWechat
(
String
wechat
);
/**
* 根据微信查询
* @param wechat 微信
* @return
*/
List
<
UserEntity
>
findByWechat
(
String
wechat
);
/**
* 根据微信小程序查询
*
* @param wechatMiniProgram 微信小程序openId
* @return
*/
List
<
UserEntity
>
findByWechatMiniProgram
(
String
wechatMiniProgram
);
/**
* 根据微信小程序查询
* @param wechatMiniProgram 微信小程序openId
* @return
*/
List
<
UserEntity
>
findByWechatMiniProgram
(
String
wechatMiniProgram
);
/**
* 根据账号查询
*
* @param account 账号
* @return
*/
UserEntity
findByAccount
(
String
account
);
/**
* 根据账号查询
* @param account 账号
* @return
*/
UserEntity
findByAccount
(
String
account
);
/**
* 根据账号查询
*
* @param account 账号
* @param password 加密密码
* @return
*/
UserEntity
findByAccountAndPassword
(
String
account
,
String
password
);
/**
* 根据账号查询
* @param account 账号
* @return
*/
List
<
UserEntity
>
findAllByAccount
(
String
account
);
/**
* 根据账号查询
*
* @param account 账号
* @return
*/
List
<
UserEntity
>
findAllByAccount
(
String
account
);
/**
* 根据用户ID批量查询
* @param userIds 用户ID集合
* @return
*/
List
<
UserEntity
>
findByIdIn
(
List
<
String
>
userIds
);
/**
* 根据用户ID批量查询
*
* @param userIds 用户ID集合
* @return
*/
List
<
UserEntity
>
findByIdIn
(
List
<
String
>
userIds
);
}
project-user/src/main/java/com/dituhui/pea/user/service/UserService.java
View file @
5ae97a3
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
Attach a file
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 post a comment