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
c22685a4
Commit
c22685a4
authored
Jul 17, 2019
by
guojuxing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新建商户和超级管理员
parent
299e3bc7
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
191 additions
and
32 deletions
+191
-32
UserConstants.java
...pi/src/main/java/com/gic/auth/constant/UserConstants.java
+16
-0
UserDTO.java
...form-auth-api/src/main/java/com/gic/auth/dto/UserDTO.java
+35
-5
UserApiService.java
...pi/src/main/java/com/gic/auth/service/UserApiService.java
+9
-0
CreatePasswordAutoUtil.java
.../main/java/com/gic/auth/utils/CreatePasswordAutoUtil.java
+34
-0
TabUserMapper.java
...ain/java/com/gic/enterprise/dao/mapper/TabUserMapper.java
+10
-0
UserService.java
...src/main/java/com/gic/enterprise/service/UserService.java
+18
-0
UserServiceImpl.java
...java/com/gic/enterprise/service/impl/UserServiceImpl.java
+20
-0
UserApiServiceImpl.java
.../com/gic/enterprise/service/outer/UserApiServiceImpl.java
+35
-0
dubbo-gic-platform-auth-service.xml
...ce/src/main/resources/dubbo-gic-platform-auth-service.xml
+1
-24
TabUserMapper.xml
...-auth-service/src/main/resources/mapper/TabUserMapper.xml
+10
-0
GlobalExceptionHandler.java
...va/com/gic/auth/web/exception/GlobalExceptionHandler.java
+3
-3
No files found.
gic-platform-auth-api/src/main/java/com/gic/auth/constant/UserConstants.java
0 → 100644
View file @
c22685a4
package
com
.
gic
.
auth
.
constant
;
/**
* @author guojx
* @date 2019/7/17 10:55 AM
*/
public
class
UserConstants
{
/**
* 密码自动生成类型
*/
public
static
final
int
CREATE_AUTO
=
1
;
/**
* 自定义生成密码类型
*/
public
static
final
int
CREATE_MYSELF
=
2
;
}
gic-platform-auth-api/src/main/java/com/gic/auth/dto/UserDTO.java
View file @
c22685a4
...
...
@@ -15,31 +15,45 @@ public class UserDTO implements Serializable{
public
interface
SaveUserValid
{
}
public
interface
EditUserValid
{
}
/**
* 用户id
*/
@NotNull
(
message
=
"用户ID不能为空"
,
groups
=
{
EditUserValid
.
class
})
private
Integer
userId
;
/**
* 用户名
*/
@NotBlank
(
message
=
"用户名不能为空"
,
groups
=
{
SaveUserValid
.
class
})
@NotBlank
(
message
=
"用户名不能为空"
,
groups
=
{
SaveUserValid
.
class
,
EditUserValid
.
class
})
private
String
userName
;
/**
* 手机号码
*/
@NotBlank
(
message
=
"手机号不能为空"
,
groups
=
{
SaveUserValid
.
class
})
@NotBlank
(
message
=
"手机号不能为空"
,
groups
=
{
SaveUserValid
.
class
,
EditUserValid
.
class
})
private
String
phoneNumber
;
/**
* 密码
*/
@NotBlank
(
message
=
"密码不能为空"
,
groups
=
{
SaveUserValid
.
class
})
private
String
password
;
/**
* 1:自动生成 2:自定义密码
*/
private
Integer
passwordType
;
/**
* 确认密码
*/
private
String
confirmPassword
;
/**
* 是否是超级管理员
*/
@NotNull
(
message
=
"用户类型不能为空"
,
groups
=
{
SaveUserValid
.
class
})
...
...
@@ -63,13 +77,13 @@ public class UserDTO implements Serializable{
/**
*
*/
@NotNull
(
message
=
"企业ID不能为空"
,
groups
=
{
Save
UserValid
.
class
})
@NotNull
(
message
=
"企业ID不能为空"
,
groups
=
{
Edit
UserValid
.
class
})
private
Integer
enterpriseId
;
/**
* 国际区号,如中国 86
*/
@NotBlank
(
message
=
"手机国际区号不能为空"
,
groups
=
{
SaveUserValid
.
class
})
@NotBlank
(
message
=
"手机国际区号不能为空"
,
groups
=
{
SaveUserValid
.
class
,
EditUserValid
.
class
})
private
String
phoneAreaCode
;
public
Integer
getUserId
()
{
...
...
@@ -151,4 +165,20 @@ public class UserDTO implements Serializable{
public
void
setPhoneAreaCode
(
String
phoneAreaCode
)
{
this
.
phoneAreaCode
=
phoneAreaCode
;
}
public
Integer
getPasswordType
()
{
return
passwordType
;
}
public
void
setPasswordType
(
Integer
passwordType
)
{
this
.
passwordType
=
passwordType
;
}
public
String
getConfirmPassword
()
{
return
confirmPassword
;
}
public
void
setConfirmPassword
(
String
confirmPassword
)
{
this
.
confirmPassword
=
confirmPassword
;
}
}
gic-platform-auth-api/src/main/java/com/gic/auth/service/UserApiService.java
View file @
c22685a4
...
...
@@ -15,4 +15,13 @@ public interface UserApiService {
* @return
*/
ServiceResponse
<
Integer
>
saveUser
(
UserDTO
userDTO
);
/**
* 编辑
* @param userDTO
* @return
*/
ServiceResponse
editUser
(
UserDTO
userDTO
);
ServiceResponse
<
UserDTO
>
getUserById
(
Integer
userId
);
}
gic-platform-auth-api/src/main/java/com/gic/auth/utils/CreatePasswordAutoUtil.java
0 → 100644
View file @
c22685a4
package
com
.
gic
.
auth
.
utils
;
import
java.util.Random
;
/**
* @author guojx
* @date 2019/7/17 9:25 AM
*/
public
class
CreatePasswordAutoUtil
{
/**
* 随机生成字母、数字参合的密码
* @param length 生成多少位数的密码
* @return
*/
public
static
String
getStringRandom
(
int
length
)
{
String
val
=
""
;
Random
random
=
new
Random
();
//length为几位密码
for
(
int
i
=
0
;
i
<
length
;
i
++)
{
String
charOrNum
=
random
.
nextInt
(
2
)
%
2
==
0
?
"char"
:
"num"
;
//输出字母还是数字
if
(
"char"
.
equalsIgnoreCase
(
charOrNum
))
{
//输出是大写字母还是小写字母
int
temp
=
random
.
nextInt
(
2
)
%
2
==
0
?
65
:
97
;
val
+=
(
char
)
(
random
.
nextInt
(
26
)
+
temp
);
}
else
if
(
"num"
.
equalsIgnoreCase
(
charOrNum
))
{
val
+=
String
.
valueOf
(
random
.
nextInt
(
10
));
}
}
return
val
;
}
}
gic-platform-auth-service/src/main/java/com/gic/enterprise/dao/mapper/TabUserMapper.java
View file @
c22685a4
package
com
.
gic
.
enterprise
.
dao
.
mapper
;
import
com.gic.enterprise.entity.TabUser
;
import
org.apache.ibatis.annotations.Param
;
public
interface
TabUserMapper
{
/**
...
...
@@ -50,4 +51,12 @@ public interface TabUserMapper {
* @return 更新条目数
*/
int
updateByPrimaryKey
(
TabUser
record
);
/**
* 手机号码查询个数
* @param phone
* @param userId
* @return
*/
int
countByPhone
(
@Param
(
"phone"
)
String
phone
,
@Param
(
"userId"
)
Integer
userId
);
}
\ No newline at end of file
gic-platform-auth-service/src/main/java/com/gic/enterprise/service/UserService.java
View file @
c22685a4
package
com
.
gic
.
enterprise
.
service
;
import
com.gic.auth.dto.UserDTO
;
import
com.gic.enterprise.entity.TabUser
;
/**
* @author guojx
...
...
@@ -14,4 +15,21 @@ public interface UserService {
* @return
*/
int
saveUser
(
UserDTO
userDTO
);
void
editUser
(
UserDTO
userDTO
);
/**
* 根据主键获取数据
* @param userId
* @return
*/
TabUser
getUserById
(
Integer
userId
);
/**
* 手机号码是否重复
* @param userId
* @param phone
* @return
*/
boolean
isPhoneRepeat
(
Integer
userId
,
String
phone
);
}
gic-platform-auth-service/src/main/java/com/gic/enterprise/service/impl/UserServiceImpl.java
View file @
c22685a4
...
...
@@ -22,4 +22,24 @@ public class UserServiceImpl implements UserService{
tabUserMapper
.
insert
(
tabUser
);
return
tabUser
.
getUserId
();
}
@Override
public
void
editUser
(
UserDTO
userDTO
)
{
TabUser
tabUser
=
EntityUtil
.
changeEntityNew
(
TabUser
.
class
,
userDTO
);
tabUserMapper
.
updateByPrimaryKeySelective
(
tabUser
);
}
@Override
public
TabUser
getUserById
(
Integer
userId
)
{
return
tabUserMapper
.
selectByPrimaryKey
(
userId
);
}
@Override
public
boolean
isPhoneRepeat
(
Integer
userId
,
String
phone
)
{
int
count
=
tabUserMapper
.
countByPhone
(
phone
,
userId
);
if
(
count
>
0
)
{
return
true
;
}
return
false
;
}
}
gic-platform-auth-service/src/main/java/com/gic/enterprise/service/outer/UserApiServiceImpl.java
View file @
c22685a4
...
...
@@ -3,6 +3,9 @@ package com.gic.enterprise.service.outer;
import
com.gic.api.base.commons.ServiceResponse
;
import
com.gic.auth.dto.UserDTO
;
import
com.gic.auth.service.UserApiService
;
import
com.gic.commons.util.EntityUtil
;
import
com.gic.enterprise.entity.TabUser
;
import
com.gic.enterprise.error.ErrorCode
;
import
com.gic.enterprise.service.UserService
;
import
com.gic.store.utils.valid.ValidUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -25,9 +28,41 @@ public class UserApiServiceImpl implements UserApiService{
if
(!
paramResult
.
isSuccess
())
{
return
paramResult
;
}
if
(
userService
.
isPhoneRepeat
(
null
,
userDTO
.
getPhoneNumber
()))
{
return
ServiceResponse
.
failure
(
ErrorCode
.
PARAMETER_ERROR
.
getCode
(),
"手机号码不能重复"
);
}
userDTO
.
setCreateTime
(
new
Date
());
userDTO
.
setUpdateTime
(
new
Date
());
userDTO
.
setStatus
(
1
);
return
ServiceResponse
.
success
(
userService
.
saveUser
(
userDTO
));
}
@Override
public
ServiceResponse
editUser
(
UserDTO
userDTO
)
{
//valid param
ServiceResponse
paramResult
=
ValidUtil
.
allCheckValidate
(
userDTO
,
UserDTO
.
EditUserValid
.
class
);
if
(!
paramResult
.
isSuccess
())
{
return
paramResult
;
}
TabUser
tabUser
=
userService
.
getUserById
(
userDTO
.
getUserId
());
if
(
tabUser
==
null
)
{
return
ServiceResponse
.
failure
(
ErrorCode
.
PARAMETER_ERROR
.
getCode
(),
"用户ID输入有误"
);
}
if
(
userService
.
isPhoneRepeat
(
userDTO
.
getUserId
(),
userDTO
.
getPhoneNumber
()))
{
return
ServiceResponse
.
failure
(
ErrorCode
.
PARAMETER_ERROR
.
getCode
(),
"手机号码不能重复"
);
}
userDTO
.
setUpdateTime
(
new
Date
());
userService
.
editUser
(
userDTO
);
return
ServiceResponse
.
success
();
}
@Override
public
ServiceResponse
<
UserDTO
>
getUserById
(
Integer
userId
)
{
TabUser
tabUser
=
userService
.
getUserById
(
userId
);
if
(
tabUser
==
null
)
{
return
ServiceResponse
.
failure
(
ErrorCode
.
PARAMETER_ERROR
.
getCode
(),
"用户ID输入有误"
);
}
return
ServiceResponse
.
success
(
EntityUtil
.
changeEntityNew
(
UserDTO
.
class
,
tabUser
));
}
}
gic-platform-auth-service/src/main/resources/dubbo-gic-platform-auth-service.xml
View file @
c22685a4
...
...
@@ -15,30 +15,7 @@
<dubbo:protocol
name=
"dubbo"
port=
"20320"
/>
<!--门店域-->
<dubbo:service
interface=
"com.gic.store.service.StoreRegionApiService"
ref=
"storeRegionApiService"
timeout=
"60000"
/>
<!--门店品牌-->
<dubbo:service
interface=
"com.gic.store.service.StoreBrandApiService"
ref=
"storeBrandApiService"
timeout=
"60000"
/>
<dubbo:service
interface=
"com.gic.store.service.StoreDictApiService"
ref=
"storeDictApiService"
timeout=
"6000"
/>
<dubbo:service
interface=
"com.gic.auth.service.UserApiService"
ref=
"userApiService"
timeout=
"60000"
/>
<dubbo:reference
interface=
"com.gic.bizdict.api.service.BizdictService"
id=
"bizdictService "
timeout=
"6000"
retries=
"0"
/>
<!--分组-->
<dubbo:service
interface=
"com.gic.store.service.StoreGroupApiService"
ref=
"storeGroupApiService"
timeout=
"60000"
/>
<!--自定义域字段-->
<dubbo:service
interface=
"com.gic.store.service.StoreFieldApiService"
ref=
"storeFieldApiService"
timeout=
"60000"
/>
<dubbo:service
interface=
"com.gic.store.service.StoreFieldSelectApiService"
ref=
"storeFieldSelectApiService"
timeout=
"60000"
/>
<!--门店-->
<dubbo:service
interface=
"com.gic.store.service.StoreApiService"
ref=
"storeApiService"
timeout=
"60000"
/>
<dubbo:service
interface=
"com.gic.store.service.ProvincesApiService"
ref=
"provincesApiService"
timeout=
"60000"
/>
<!--分组策略-->
<dubbo:service
interface=
"com.gic.store.service.StoreStrategyApiService"
ref=
"storeStrategyApiService"
timeout=
"60000"
/>
<!--门店导入-->
<dubbo:service
interface=
"com.gic.store.service.StoreImportApiService"
ref=
"storeImportApiService"
timeout=
"60000"
/>
<dubbo:service
interface=
"com.gic.store.service.StoreTaskApiService"
ref=
"storeTaskApiService"
timeout=
"60000"
/>
<dubbo:service
interface=
"com.gic.store.service.StoreStatusSettingApiService"
ref=
"storeStatusSettingApiService"
timeout=
"60000"
/>
<dubbo:reference
interface=
"com.gic.log.api.service.LogApiService"
id=
"logApiService"
timeout=
"60000"
/>
</beans>
gic-platform-auth-service/src/main/resources/mapper/TabUserMapper.xml
View file @
c22685a4
...
...
@@ -150,4 +150,13 @@
phone_area_code = #{phoneAreaCode,jdbcType=VARCHAR}
where user_id = #{userId,jdbcType=INTEGER}
</update>
<select
id=
"countByPhone"
resultType=
"int"
>
select count(1) from tab_user
where status = 1
<if
test=
"userId != null"
>
user_id
<![CDATA[ <> ]]>
#{userId}
</if>
and phone_number = #{phone}
</select>
</mapper>
\ No newline at end of file
gic-platform-auth-web/src/main/java/com/gic/auth/web/exception/GlobalExceptionHandler.java
View file @
c22685a4
package
com
.
gic
.
auth
.
web
.
exception
;
import
com.gic.commons.webapi.reponse.RestResponse
;
import
com.gic.enterprise.error.ErrorCode
;
import
com.gic.store.constant.StoreGroupErrorEnum
;
import
com.gic.store.exception.StoreException
;
import
com.gic.store.exception.StoreGroupException
;
import
com.gic.store.utils.ErrorCode
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.validation.BindException
;
...
...
@@ -34,7 +34,7 @@ public class GlobalExceptionHandler {
@ExceptionHandler
(
Exception
.
class
)
public
RestResponse
controllerException
(
HttpServletResponse
response
,
Exception
ex
)
{
logger
.
error
(
"err"
,
ex
);
RestResponse
failureResponse
=
getRestResponse
(
ErrorCode
.
ERR_3
.
getCode
(),
ErrorCode
.
ERR_3
.
getMsg
());
RestResponse
failureResponse
=
getRestResponse
(
ErrorCode
.
SYSTEM_ERROR
.
getCode
(),
ErrorCode
.
SYSTEM_ERROR
.
getMsg
());
StringBuilder
sb
=
new
StringBuilder
();
ByteArrayOutputStream
baos
=
new
ByteArrayOutputStream
();
try
(
PrintWriter
printWriter
=
new
PrintWriter
(
baos
))
{
...
...
@@ -76,7 +76,7 @@ public class GlobalExceptionHandler {
Set
<
ConstraintViolation
<?>>
constraintViolations
=
e
.
getConstraintViolations
();
String
paramName
=
constraintViolations
.
iterator
().
next
().
getPropertyPath
().
toString
();
String
paramError
=
constraintViolations
.
iterator
().
next
().
getMessage
();
return
getRestResponse
(
com
.
gic
.
enterprise
.
error
.
ErrorCode
.
ERR_5
.
getCode
(),
getFailFastMsg
(
paramName
,
paramError
));
return
getRestResponse
(
ErrorCode
.
PARAMETER_ERROR
.
getCode
(),
getFailFastMsg
(
paramName
,
paramError
));
}
/**
...
...
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