Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gic-platform-auth
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
base_platform_enterprise
gic-platform-auth
Commits
f62be843
Commit
f62be843
authored
Aug 29, 2019
by
陶光胜
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
登陆接口
parent
18eb1d44
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
179 additions
and
1 deletions
+179
-1
UserDTO.java
...form-auth-api/src/main/java/com/gic/auth/dto/UserDTO.java
+3
-1
UserApiService.java
...pi/src/main/java/com/gic/auth/service/UserApiService.java
+6
-0
pom.xml
gic-platform-auth-service/pom.xml
+5
-0
TabUserMapper.java
.../src/main/java/com/gic/auth/dao/mapper/TabUserMapper.java
+10
-0
UserService.java
...rvice/src/main/java/com/gic/auth/service/UserService.java
+6
-0
UserServiceImpl.java
.../main/java/com/gic/auth/service/impl/UserServiceImpl.java
+12
-0
UserApiServiceImpl.java
...a/com/gic/auth/service/outer/impl/UserApiServiceImpl.java
+17
-0
TabUserMapper.xml
...-auth-service/src/main/resources/mapper/TabUserMapper.xml
+19
-0
pom.xml
gic-platform-auth-web/pom.xml
+5
-0
LoginController.java
...ain/java/com/gic/auth/web/controller/LoginController.java
+93
-0
dubbo-gic-platform-auth-web.xml
...th-web/src/main/resources/dubbo-gic-platform-auth-web.xml
+3
-0
No files found.
gic-platform-auth-api/src/main/java/com/gic/auth/dto/UserDTO.java
View file @
f62be843
package
com
.
gic
.
auth
.
dto
;
import
com.gic.enterprise.base.UserInfo
;
import
javax.validation.constraints.NotBlank
;
import
javax.validation.constraints.NotNull
;
import
javax.validation.constraints.Pattern
;
...
...
@@ -10,7 +12,7 @@ import java.util.Date;
* @author guojx
* @date 2019/7/16 6:49 PM
*/
public
class
UserDTO
implements
Serializable
{
public
class
UserDTO
implements
UserInfo
,
Serializable
{
private
static
final
long
serialVersionUID
=
7296135586565827660L
;
public
interface
SaveUserValid
{
...
...
gic-platform-auth-api/src/main/java/com/gic/auth/service/UserApiService.java
View file @
f62be843
...
...
@@ -3,6 +3,8 @@ package com.gic.auth.service;
import
com.gic.api.base.commons.ServiceResponse
;
import
com.gic.auth.dto.UserDTO
;
import
java.util.List
;
/**
* @author guojx
* @date 2019/7/16 6:48 PM
...
...
@@ -31,4 +33,8 @@ public interface UserApiService {
* @return
*/
ServiceResponse
<
UserDTO
>
getUserByEnterpriseId
(
Integer
enterpriseId
);
ServiceResponse
<
List
<
UserDTO
>>
listUserByPhoneNumber
(
String
phoneNumber
);
ServiceResponse
<
UserDTO
>
login
(
String
phoneNumber
,
Integer
enterpriseId
,
String
password
);
}
gic-platform-auth-service/pom.xml
View file @
f62be843
...
...
@@ -113,6 +113,11 @@
<artifactId>
gic-platform-auth-api
</artifactId>
<version>
${gic-platform-auth-api}
</version>
</dependency>
<dependency>
<groupId>
com.gic
</groupId>
<artifactId>
gic-platform-enterprise-api
</artifactId>
<version>
${gic-platform-enterprise-api}
</version>
</dependency>
</dependencies>
<build>
...
...
gic-platform-auth-service/src/main/java/com/gic/auth/dao/mapper/TabUserMapper.java
View file @
f62be843
package
com
.
gic
.
auth
.
dao
.
mapper
;
import
com.gic.auth.dto.UserDTO
;
import
com.gic.auth.entity.TabUser
;
import
org.apache.ibatis.annotations.Param
;
import
java.util.List
;
public
interface
TabUserMapper
{
/**
* 根据主键删除
...
...
@@ -61,4 +64,10 @@ public interface TabUserMapper {
int
countByPhone
(
@Param
(
"phone"
)
String
phone
,
@Param
(
"userId"
)
Integer
userId
);
TabUser
selectByEnterpriseId
(
@Param
(
"enterpriseId"
)
Integer
enterpriseId
);
List
<
TabUser
>
listAllUserByPhoneNumber
(
@Param
(
"phoneNumber"
)
String
phoneNumber
);
TabUser
login
(
@Param
(
"phoneNumber"
)
String
phoneNumber
,
@Param
(
"password"
)
String
password
,
@Param
(
"enterpriseId"
)
Integer
enterpriseId
);
}
\ No newline at end of file
gic-platform-auth-service/src/main/java/com/gic/auth/service/UserService.java
View file @
f62be843
...
...
@@ -3,6 +3,8 @@ package com.gic.auth.service;
import
com.gic.auth.dto.UserDTO
;
import
com.gic.auth.entity.TabUser
;
import
java.util.List
;
/**
* @author guojx
* @date 2019/7/16 6:50 PM
...
...
@@ -34,4 +36,8 @@ public interface UserService {
boolean
isPhoneRepeat
(
Integer
userId
,
String
phone
);
TabUser
getUserByEnterpriseId
(
Integer
enterpriseId
);
List
<
TabUser
>
listAllUserByPhoneNumber
(
String
phoneNumber
);
TabUser
login
(
String
phoneNumber
,
Integer
enterpriseId
,
String
password
);
}
gic-platform-auth-service/src/main/java/com/gic/auth/service/impl/UserServiceImpl.java
View file @
f62be843
...
...
@@ -8,6 +8,8 @@ import com.gic.auth.dao.mapper.TabUserMapper;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
/**
* @author guojx
* @date 2019/7/16 6:52 PM
...
...
@@ -47,4 +49,14 @@ public class UserServiceImpl implements UserService {
public
TabUser
getUserByEnterpriseId
(
Integer
enterpriseId
)
{
return
null
;
}
@Override
public
List
<
TabUser
>
listAllUserByPhoneNumber
(
String
phoneNumber
)
{
return
this
.
tabUserMapper
.
listAllUserByPhoneNumber
(
phoneNumber
);
}
@Override
public
TabUser
login
(
String
phoneNumber
,
Integer
enterpriseId
,
String
password
)
{
return
this
.
tabUserMapper
.
login
(
phoneNumber
,
password
,
enterpriseId
);
}
}
gic-platform-auth-service/src/main/java/com/gic/auth/service/outer/impl/UserApiServiceImpl.java
View file @
f62be843
...
...
@@ -8,10 +8,12 @@ import com.gic.auth.entity.TabUser;
import
com.gic.enterprise.error.ErrorCode
;
import
com.gic.auth.service.UserService
;
import
com.gic.store.utils.valid.ValidUtil
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.Date
;
import
java.util.List
;
/**
* @author guojx
...
...
@@ -74,4 +76,19 @@ public class UserApiServiceImpl implements UserApiService{
}
return
ServiceResponse
.
success
(
EntityUtil
.
changeEntityNew
(
UserDTO
.
class
,
tabUser
));
}
@Override
public
ServiceResponse
<
List
<
UserDTO
>>
listUserByPhoneNumber
(
String
phoneNumber
)
{
List
<
TabUser
>
list
=
this
.
userService
.
listAllUserByPhoneNumber
(
phoneNumber
);
if
(
CollectionUtils
.
isNotEmpty
(
list
)){
return
ServiceResponse
.
success
(
EntityUtil
.
changeEntityListByJSON
(
UserDTO
.
class
,
list
));
}
return
ServiceResponse
.
success
();
}
@Override
public
ServiceResponse
<
UserDTO
>
login
(
String
phoneNumber
,
Integer
enterpriseId
,
String
password
)
{
TabUser
user
=
this
.
userService
.
login
(
phoneNumber
,
enterpriseId
,
password
);
return
ServiceResponse
.
success
(
EntityUtil
.
changeEntityByJSON
(
UserDTO
.
class
,
user
));
}
}
gic-platform-auth-service/src/main/resources/mapper/TabUserMapper.xml
View file @
f62be843
...
...
@@ -169,4 +169,22 @@
and status = 1
and super_admin = 1
</select>
<select
id=
"listAllUserByPhoneNumber"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from tab_sys_user
where phone_number = #{phoneNumber}
and status = 1
</select>
<select
id=
"login"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from tab_sys_user
where phone_number = #{phoneNumber}
and status = 1
and enterprise_id = #{enterpriseId}
and password = #{password}
</select>
</mapper>
\ No newline at end of file
gic-platform-auth-web/pom.xml
View file @
f62be843
...
...
@@ -127,6 +127,11 @@
<artifactId>
gic-platform-auth-api
</artifactId>
<version>
${gic-platform-auth-api}
</version>
</dependency>
<dependency>
<groupId>
com.gic
</groupId>
<artifactId>
gic-platform-enterprise-api
</artifactId>
<version>
${gic-platform-enterprise-api}
</version>
</dependency>
</dependencies>
<build>
...
...
gic-platform-auth-web/src/main/java/com/gic/auth/web/controller/LoginController.java
0 → 100644
View file @
f62be843
package
com
.
gic
.
auth
.
web
.
controller
;
import
com.gic.api.base.commons.ServiceResponse
;
import
com.gic.auth.dto.UserDTO
;
import
com.gic.auth.service.UserApiService
;
import
com.gic.commons.util.Md5Util
;
import
com.gic.commons.webapi.reponse.RestResponse
;
import
com.gic.enterprise.dto.EnterpriseDTO
;
import
com.gic.enterprise.error.ErrorCode
;
import
com.gic.enterprise.response.EnterpriseRestResponse
;
import
com.gic.enterprise.service.EnterpriseApiService
;
import
com.gic.enterprise.utils.UserDetail
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.log4j.LogManager
;
import
org.apache.log4j.Logger
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.ArrayList
;
import
java.util.List
;
@RestController
public
class
LoginController
{
private
final
Logger
logger
=
LogManager
.
getLogger
(
LoginController
.
class
);
@Autowired
private
EnterpriseApiService
enterpriseApiService
;
@Autowired
private
UserApiService
userApiService
;
@RequestMapping
(
"list-enterprise-by-phone"
)
public
RestResponse
listUserEnterprise
(
String
phoneNumber
){
if
(
StringUtils
.
isBlank
(
phoneNumber
)){
return
EnterpriseRestResponse
.
failure
(
ErrorCode
.
PARAMETER_ERROR
);
}
ServiceResponse
<
List
<
UserDTO
>>
listServiceResponse
=
this
.
userApiService
.
listUserByPhoneNumber
(
phoneNumber
);
if
(
listServiceResponse
.
isSuccess
()){
List
<
UserDTO
>
result
=
listServiceResponse
.
getResult
();
if
(
CollectionUtils
.
isEmpty
(
result
)){
return
RestResponse
.
failure
(
ErrorCode
.
SYSTEM_ERROR
.
getCode
(),
"用户不存在"
);
}
else
{
List
<
Integer
>
idList
=
new
ArrayList
<>();
for
(
UserDTO
userDTO
:
result
){
idList
.
add
(
userDTO
.
getEnterpriseId
());
}
ServiceResponse
<
List
<
EnterpriseDTO
>>
serviceResponse
=
this
.
enterpriseApiService
.
listEnterpriseByIds
(
idList
);
if
(
serviceResponse
.
isSuccess
()){
List
<
EnterpriseDTO
>
list
=
serviceResponse
.
getResult
();
if
(
CollectionUtils
.
isEmpty
(
list
)){
return
RestResponse
.
failure
(
ErrorCode
.
SYSTEM_ERROR
.
getCode
(),
"用户不存在"
);
}
else
{
return
RestResponse
.
success
(
list
);
}
}
}
}
return
RestResponse
.
success
();
}
@RequestMapping
(
"login"
)
public
RestResponse
login
(
String
phoneNumber
,
Integer
enterpriseId
,
String
password
){
if
(
StringUtils
.
isBlank
(
password
)
||
StringUtils
.
isBlank
(
phoneNumber
)
||
enterpriseId
==
null
){
return
EnterpriseRestResponse
.
failure
(
ErrorCode
.
PARAMETER_ERROR
);
}
Md5Util
md5
=
new
Md5Util
();
// password 自身作为盐值
if
(
password
.
length
()
!=
32
)
{
password
=
md5
.
encrypt
(
password
+
password
);
}
ServiceResponse
<
UserDTO
>
login
=
this
.
userApiService
.
login
(
phoneNumber
,
enterpriseId
,
password
);
if
(
login
.
isSuccess
()){
UserDTO
userDTO
=
login
.
getResult
();
if
(
userDTO
==
null
){
return
EnterpriseRestResponse
.
failure
(
ErrorCode
.
LOGIN_ERROR
);
}
UserDetail
userDetail
=
new
UserDetail
();
userDetail
.
setUserId
(
userDTO
.
getUserId
());
userDetail
.
setUserInfo
(
userDTO
);
ServiceResponse
<
EnterpriseDTO
>
enterprise
=
this
.
enterpriseApiService
.
getEnterpriseById
(
enterpriseId
);
if
(
enterprise
.
isSuccess
()){
EnterpriseDTO
enterpriseDTO
=
enterprise
.
getResult
();
if
(
enterpriseDTO
!=
null
){
userDetail
.
setEnterpriseId
(
enterpriseDTO
.
getEnterpriseId
());
userDetail
.
setEnterpriseInfo
(
enterpriseDTO
);
return
RestResponse
.
success
(
userDetail
);
}
}
}
return
RestResponse
.
success
();
}
}
gic-platform-auth-web/src/main/resources/dubbo-gic-platform-auth-web.xml
View file @
f62be843
...
...
@@ -36,4 +36,6 @@
<dubbo:reference
interface=
"com.gic.store.service.StoreStatusSettingApiService"
id=
"storeStatusSettingApiService"
timeout=
"60000"
/>
<dubbo:reference
interface=
"com.gic.log.api.service.LogApiService"
id=
"logApiService"
timeout=
"60000"
/>
<dubbo:reference
interface=
"com.gic.auth.service.MenuApiService"
id=
"menuApiService"
timeout=
"6000"
/>
<dubbo:reference
interface=
"com.gic.enterprise.service.EnterpriseApiService"
id=
"enterpriseApiService"
timeout=
"6000"
/>
<dubbo:reference
interface=
"com.gic.auth.service.UserApiService"
id=
"userApiService"
timeout=
"6000"
/>
</beans>
\ 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