Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
X
xyqb-user2
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
head_group
xyqb-user2
Commits
3d92b780
Commit
3d92b780
authored
Feb 08, 2018
by
技术部-任文超
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into 20180130-geetest
parents
d8c18754
fba3c8c4
Changes
16
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
64 additions
and
52 deletions
+64
-52
pom.xml
pom.xml
+1
-1
Bootstrap.java
src/main/java/cn/quantgroup/xyqb/Bootstrap.java
+1
-1
InnerController.java
...tgroup/xyqb/controller/external/user/InnerController.java
+2
-2
UserAuthorizedController.java
...qb/controller/internal/user/UserAuthorizedController.java
+1
-1
RequestFilter.java
src/main/java/cn/quantgroup/xyqb/filter/RequestFilter.java
+1
-1
AuthPattern.java
src/main/java/cn/quantgroup/xyqb/model/AuthPattern.java
+3
-1
UserAuthorizedParam.java
...in/java/cn/quantgroup/xyqb/model/UserAuthorizedParam.java
+0
-1
IUserAuthorizedService.java
.../quantgroup/xyqb/service/auth/IUserAuthorizedService.java
+1
-1
UserAuthorizedServiceImpl.java
...oup/xyqb/service/auth/impl/UserAuthorizedServiceImpl.java
+11
-9
IPUtil.java
src/main/java/cn/quantgroup/xyqb/util/IPUtil.java
+3
-2
BaseParametersTests.java
src/test/java/demo/BaseParametersTests.java
+2
-1
RepsitoryTests.java
src/test/java/demo/RepsitoryTests.java
+2
-1
ServiceTests.java
src/test/java/demo/ServiceTests.java
+2
-1
UserAuthorizedRepsitoryTests.java
src/test/java/repsitory/UserAuthorizedRepsitoryTests.java
+12
-12
UserAuthorizedServiceTests.java
src/test/java/service/UserAuthorizedServiceTests.java
+17
-12
UserAuthorizedControllerTests.java
src/test/java/web/UserAuthorizedControllerTests.java
+5
-5
No files found.
pom.xml
View file @
3d92b780
...
@@ -253,7 +253,7 @@
...
@@ -253,7 +253,7 @@
<dependency>
<dependency>
<groupId>
cn.quantgroup
</groupId>
<groupId>
cn.quantgroup
</groupId>
<artifactId>
commons
</artifactId>
<artifactId>
commons
</artifactId>
<version>
0.0.
5
</version>
<version>
0.0.
7
</version>
<scope>
compile
</scope>
<scope>
compile
</scope>
</dependency>
</dependency>
...
...
src/main/java/cn/quantgroup/xyqb/Bootstrap.java
View file @
3d92b780
...
@@ -17,7 +17,7 @@ import org.springframework.core.env.Environment;
...
@@ -17,7 +17,7 @@ import org.springframework.core.env.Environment;
import
org.springframework.scheduling.annotation.EnableAsync
;
import
org.springframework.scheduling.annotation.EnableAsync
;
import
sun.misc.Signal
;
import
sun.misc.Signal
;
@ComponentScan
(
basePackages
=
{
"cn.quantgroup.sms"
,
"cn.quantgroup.xyqb"
})
@ComponentScan
(
basePackages
=
{
"cn.quantgroup.sms"
,
"cn.quantgroup.xyqb"
,
"cn.quantgroup.tech"
})
@SpringBootApplication
@SpringBootApplication
@EnableCaching
@EnableCaching
@EnableAspectJAutoProxy
@EnableAspectJAutoProxy
...
...
src/main/java/cn/quantgroup/xyqb/controller/external/user/InnerController.java
View file @
3d92b780
...
@@ -117,7 +117,7 @@ public class InnerController implements IBaseController {
...
@@ -117,7 +117,7 @@ public class InnerController implements IBaseController {
@LogHttpCaller
@LogHttpCaller
@RequestMapping
(
"/user/search/uuid"
)
@RequestMapping
(
"/user/search/uuid"
)
public
JsonResult
findByUuid
(
String
uuid
)
{
public
JsonResult
findByUuid
(
String
uuid
)
{
User
user
=
userService
.
findByUuid
InDb
(
uuid
);
User
user
=
userService
.
findByUuid
WithCache
(
uuid
);
if
(
user
==
null
)
{
if
(
user
==
null
)
{
return
JsonResult
.
buildErrorStateResult
(
""
,
null
);
return
JsonResult
.
buildErrorStateResult
(
""
,
null
);
}
}
...
@@ -133,7 +133,7 @@ public class InnerController implements IBaseController {
...
@@ -133,7 +133,7 @@ public class InnerController implements IBaseController {
if
(
StringUtils
.
isBlank
(
uuid
))
{
if
(
StringUtils
.
isBlank
(
uuid
))
{
return
JsonResult
.
buildSuccessResult
(
null
,
null
);
return
JsonResult
.
buildSuccessResult
(
null
,
null
);
}
}
User
user
=
userService
.
findByUuid
InDb
(
uuid
);
User
user
=
userService
.
findByUuid
WithCache
(
uuid
);
if
(
null
!=
user
)
{
if
(
null
!=
user
)
{
if
(!
user
.
getEnable
())
{
if
(!
user
.
getEnable
())
{
return
JsonResult
.
buildSuccessResult
(
""
,
null
);
return
JsonResult
.
buildSuccessResult
(
""
,
null
);
...
...
src/main/java/cn/quantgroup/xyqb/controller/internal/user/UserAuthorizedController.java
View file @
3d92b780
...
@@ -49,7 +49,7 @@ public class UserAuthorizedController {
...
@@ -49,7 +49,7 @@ public class UserAuthorizedController {
}
}
UserAuthorized
userAuthorized
=
userAuthorizedService
.
createUserAuthorized
(
userAuthorizedParam
);
UserAuthorized
userAuthorized
=
userAuthorizedService
.
createUserAuthorized
(
userAuthorizedParam
);
if
(
null
==
userAuthorized
)
{
if
(
null
==
userAuthorized
)
{
return
JsonResult
.
buildErrorStateResult
(
"重复创建异常"
,
null
);
return
JsonResult
.
buildErrorStateResult
(
"重复创建异常
或userUuid有误
"
,
null
);
}
else
{
}
else
{
return
JsonResult
.
buildSuccessResult
(
"创建成功"
,
userAuthorized
.
getId
());
return
JsonResult
.
buildSuccessResult
(
"创建成功"
,
userAuthorized
.
getId
());
}
}
...
...
src/main/java/cn/quantgroup/xyqb/filter/RequestFilter.java
View file @
3d92b780
...
@@ -26,7 +26,7 @@ public class RequestFilter implements Filter {
...
@@ -26,7 +26,7 @@ public class RequestFilter implements Filter {
private
static
final
String
[]
ALLOWED_PATTERNS
=
{
private
static
final
String
[]
ALLOWED_PATTERNS
=
{
"/wechat/**"
,
"/config/**"
,
"/api/**"
,
"/query/**"
,
"/user_detail/**"
,
"/hello/**"
,
"/innerapi/**"
,
"/app/**"
,
"/motan/**"
,
"/user/**"
,
"/lock/**"
,
"/wechat/**"
,
"/config/**"
,
"/api/**"
,
"/query/**"
,
"/user_detail/**"
,
"/hello/**"
,
"/innerapi/**"
,
"/app/**"
,
"/motan/**"
,
"/user/**"
,
"/lock/**"
,
"/auth/info/login"
,
"/platform/api/page/return_url"
,
"/MP_verify_AWiagUn4kZiwmTt0.txt"
"/auth/info/login"
,
"/platform/api/page/return_url"
,
"/MP_verify_AWiagUn4kZiwmTt0.txt"
,
"/tech/health/check"
};
};
private
static
final
String
UNAUTH_RESULT
=
JSONObject
.
toJSONString
(
JsonResult
.
buildErrorStateResult
(
"登录失败"
,
null
));
private
static
final
String
UNAUTH_RESULT
=
JSONObject
.
toJSONString
(
JsonResult
.
buildErrorStateResult
(
"登录失败"
,
null
));
@Autowired
@Autowired
...
...
src/main/java/cn/quantgroup/xyqb/model/AuthPattern.java
View file @
3d92b780
...
@@ -5,7 +5,9 @@ package cn.quantgroup.xyqb.model;
...
@@ -5,7 +5,9 @@ package cn.quantgroup.xyqb.model;
*/
*/
public
enum
AuthPattern
{
public
enum
AuthPattern
{
ZMXY
(
"芝麻分授权"
),
ZMXY
(
"芝麻分授权"
),
FOUR_ELEMENTS_OF_BANK_CARD
(
"银行卡四要素"
);
FOUR_ELEMENTS_OF_BANK_CARD
(
"银行卡四要素"
),
KA_ZMXY
(
"ka芝麻分授权"
),
KA_FOUR_ELEMENTS_OF_BANK_CARD
(
"ka银行卡四要素"
);
private
String
desc
;
private
String
desc
;
AuthPattern
(
String
desc
)
{
AuthPattern
(
String
desc
)
{
...
...
src/main/java/cn/quantgroup/xyqb/model/UserAuthorizedParam.java
View file @
3d92b780
...
@@ -11,7 +11,6 @@ import lombok.Getter;
...
@@ -11,7 +11,6 @@ import lombok.Getter;
public
class
UserAuthorizedParam
{
public
class
UserAuthorizedParam
{
private
String
name
;
private
String
name
;
private
String
idNo
;
private
String
idNo
;
private
Long
userId
;
private
String
authPattern
;
private
String
authPattern
;
private
String
userUuid
;
private
String
userUuid
;
}
}
src/main/java/cn/quantgroup/xyqb/service/auth/IUserAuthorizedService.java
View file @
3d92b780
...
@@ -24,7 +24,7 @@ public interface IUserAuthorizedService {
...
@@ -24,7 +24,7 @@ public interface IUserAuthorizedService {
UserAuthorized
createUserAuthorized
(
UserAuthorizedParam
userAuthorizedParam
);
UserAuthorized
createUserAuthorized
(
UserAuthorizedParam
userAuthorizedParam
);
/**
/**
* 通过user
I
d获取实名账户表的id
* 通过user
Uui
d获取实名账户表的id
*
*
* @param userUuid userUuid
* @param userUuid userUuid
* @return
* @return
...
...
src/main/java/cn/quantgroup/xyqb/service/auth/impl/UserAuthorizedServiceImpl.java
View file @
3d92b780
...
@@ -4,6 +4,7 @@ import cn.quantgroup.xyqb.entity.UserAuthorized;
...
@@ -4,6 +4,7 @@ import cn.quantgroup.xyqb.entity.UserAuthorized;
import
cn.quantgroup.xyqb.model.AuthPattern
;
import
cn.quantgroup.xyqb.model.AuthPattern
;
import
cn.quantgroup.xyqb.model.UserAuthorizedParam
;
import
cn.quantgroup.xyqb.model.UserAuthorizedParam
;
import
cn.quantgroup.xyqb.repository.IUserAuthorizedRepository
;
import
cn.quantgroup.xyqb.repository.IUserAuthorizedRepository
;
import
cn.quantgroup.xyqb.repository.IUserRepository
;
import
cn.quantgroup.xyqb.service.auth.IIdCardService
;
import
cn.quantgroup.xyqb.service.auth.IIdCardService
;
import
cn.quantgroup.xyqb.service.auth.IUserAuthorizedService
;
import
cn.quantgroup.xyqb.service.auth.IUserAuthorizedService
;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.commons.lang.StringUtils
;
...
@@ -29,7 +30,10 @@ public class UserAuthorizedServiceImpl implements IUserAuthorizedService {
...
@@ -29,7 +30,10 @@ public class UserAuthorizedServiceImpl implements IUserAuthorizedService {
@Resource
@Resource
private
IUserAuthorizedRepository
userAuthorizedRepository
;
private
IUserAuthorizedRepository
userAuthorizedRepository
;
@Cacheable
(
value
=
"user_authorized_idno_cache"
,
key
=
"#idNo"
,
unless
=
"#result == null"
,
cacheManager
=
"cacheManager"
)
@Resource
private
IUserRepository
userRepository
;
@Cacheable
(
value
=
"user_authorized_idno_cache"
,
key
=
"#idNo"
,
unless
=
"#result == false"
,
cacheManager
=
"cacheManager"
)
@Override
@Override
public
Boolean
hasUserAuthorized
(
String
idNo
)
{
public
Boolean
hasUserAuthorized
(
String
idNo
)
{
try
{
try
{
...
@@ -51,12 +55,9 @@ public class UserAuthorizedServiceImpl implements IUserAuthorizedService {
...
@@ -51,12 +55,9 @@ public class UserAuthorizedServiceImpl implements IUserAuthorizedService {
if
(
null
==
userAuthorizedParam
)
{
if
(
null
==
userAuthorizedParam
)
{
return
Boolean
.
TRUE
;
return
Boolean
.
TRUE
;
}
}
Long
userId
=
userAuthorizedParam
.
getUserId
();
String
userUuid
=
userAuthorizedParam
.
getUserUuid
();
String
userUuid
=
userAuthorizedParam
.
getUserUuid
();
if
(
userId
==
null
||
userId
==
0L
)
{
if
(
StringUtils
.
isBlank
(
userUuid
))
{
if
(
StringUtils
.
isBlank
(
userUuid
))
{
return
Boolean
.
TRUE
;
return
Boolean
.
TRUE
;
}
}
}
String
name
=
userAuthorizedParam
.
getName
();
String
name
=
userAuthorizedParam
.
getName
();
String
authPattern
=
userAuthorizedParam
.
getAuthPattern
();
String
authPattern
=
userAuthorizedParam
.
getAuthPattern
();
...
@@ -66,8 +67,9 @@ public class UserAuthorizedServiceImpl implements IUserAuthorizedService {
...
@@ -66,8 +67,9 @@ public class UserAuthorizedServiceImpl implements IUserAuthorizedService {
@Override
@Override
public
UserAuthorized
createUserAuthorized
(
UserAuthorizedParam
userAuthorizedParam
)
{
public
UserAuthorized
createUserAuthorized
(
UserAuthorizedParam
userAuthorizedParam
)
{
// 数据检查
// 数据检查,以及检查userUuid是否存在
if
(
Objects
.
isNull
(
userAuthorizedParam
)
||
this
.
hasUserAuthorized
(
userAuthorizedParam
.
getIdNo
())){
if
(
Objects
.
isNull
(
userAuthorizedParam
)
||
this
.
hasUserAuthorized
(
userAuthorizedParam
.
getIdNo
())
||
Objects
.
isNull
(
userRepository
.
findByUuid
(
userAuthorizedParam
.
getUserUuid
())))
{
return
null
;
return
null
;
}
}
AuthPattern
authPatternEnum
=
AuthPattern
.
valueOf
(
userAuthorizedParam
.
getAuthPattern
());
AuthPattern
authPatternEnum
=
AuthPattern
.
valueOf
(
userAuthorizedParam
.
getAuthPattern
());
...
@@ -100,7 +102,7 @@ public class UserAuthorizedServiceImpl implements IUserAuthorizedService {
...
@@ -100,7 +102,7 @@ public class UserAuthorizedServiceImpl implements IUserAuthorizedService {
}
}
UserAuthorized
userAuthorized
=
userAuthorizedRepository
.
findByUserUuid
(
userUuid
);
UserAuthorized
userAuthorized
=
userAuthorizedRepository
.
findByUserUuid
(
userUuid
);
LOGGER
.
info
(
"[getUserAuthorizedId]获取实名账户的id,userUuid:{},userAuthorized:{}"
,
userUuid
,
userAuthorized
);
LOGGER
.
info
(
"[getUserAuthorizedId]获取实名账户的id,userUuid:{},userAuthorized:{}"
,
userUuid
,
userAuthorized
);
if
(
null
==
userAuthorized
)
{
if
(
null
==
userAuthorized
)
{
return
null
;
return
null
;
}
}
...
...
src/main/java/cn/quantgroup/xyqb/util/IPUtil.java
View file @
3d92b780
package
cn
.
quantgroup
.
xyqb
.
util
;
package
cn
.
quantgroup
.
xyqb
.
util
;
import
cn.quantgroup.tech.security.TechSecurityUtil
;
import
cn.quantgroup.tech.util.TechEnvironment
;
import
com.google.common.collect.Sets
;
import
com.google.common.collect.Sets
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
...
@@ -29,8 +31,7 @@ public class IPUtil {
...
@@ -29,8 +31,7 @@ public class IPUtil {
String
[]
ips
=
{
"172.16."
,
"172.20."
,
"172.30."
,
"192.168.3."
,
"192.168.4."
};
String
[]
ips
=
{
"172.16."
,
"172.20."
,
"172.30."
,
"192.168.3."
,
"192.168.4."
};
WHITE_ADDRESS
.
addAll
(
Arrays
.
asList
(
ips
));
WHITE_ADDRESS
.
addAll
(
Arrays
.
asList
(
ips
));
//系统环境
//系统环境
String
jvmTest
=
System
.
getProperty
(
"test"
);
if
(!
TechEnvironment
.
isPro
()){
if
(
Boolean
.
valueOf
(
jvmTest
)){
WHITE_ADDRESS
.
add
(
"192.168."
);
WHITE_ADDRESS
.
add
(
"192.168."
);
WHITE_ADDRESS
.
add
(
"10."
);
WHITE_ADDRESS
.
add
(
"10."
);
WHITE_ADDRESS
.
add
(
LOCAL_ADDRESS
);
WHITE_ADDRESS
.
add
(
LOCAL_ADDRESS
);
...
...
src/test/java/demo/BaseParametersTests.java
View file @
3d92b780
...
@@ -2,12 +2,13 @@ package demo;
...
@@ -2,12 +2,13 @@ package demo;
import
org.junit.Before
;
import
org.junit.Before
;
import
org.springframework.test.context.TestContextManager
;
import
org.springframework.test.context.TestContextManager
;
import
org.springframework.test.context.junit4.AbstractTransactionalJUnit4SpringContextTests
;
/**
/**
* @author renwc
* @author renwc
* @date 2018-01-05
* @date 2018-01-05
*/
*/
public
abstract
class
BaseParametersTests
{
public
abstract
class
BaseParametersTests
extends
AbstractTransactionalJUnit4SpringContextTests
{
private
TestContextManager
testContextManager
;
private
TestContextManager
testContextManager
;
@Before
@Before
public
void
setUpContext
()
throws
Exception
{
public
void
setUpContext
()
throws
Exception
{
...
...
src/test/java/demo/RepsitoryTests.java
View file @
3d92b780
...
@@ -10,6 +10,7 @@ import org.junit.runner.RunWith;
...
@@ -10,6 +10,7 @@ import org.junit.runner.RunWith;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.test.annotation.Rollback
;
import
org.springframework.test.annotation.Rollback
;
import
org.springframework.test.context.ContextConfiguration
;
import
org.springframework.test.context.ContextConfiguration
;
import
org.springframework.test.context.junit4.AbstractTransactionalJUnit4SpringContextTests
;
import
org.springframework.test.context.junit4.SpringRunner
;
import
org.springframework.test.context.junit4.SpringRunner
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
...
@@ -28,7 +29,7 @@ import java.time.Instant;
...
@@ -28,7 +29,7 @@ import java.time.Instant;
@RunWith
(
SpringRunner
.
class
)
@RunWith
(
SpringRunner
.
class
)
@SpringBootTest
(
classes
=
Bootstrap
.
class
)
@SpringBootTest
(
classes
=
Bootstrap
.
class
)
@ContextConfiguration
(
initializers
=
ApolloPropertySourceInitializer
.
class
)
@ContextConfiguration
(
initializers
=
ApolloPropertySourceInitializer
.
class
)
public
class
RepsitoryTests
{
public
class
RepsitoryTests
extends
AbstractTransactionalJUnit4SpringContextTests
{
@Resource
@Resource
private
IUserRepository
userRepository
;
private
IUserRepository
userRepository
;
...
...
src/test/java/demo/ServiceTests.java
View file @
3d92b780
...
@@ -10,6 +10,7 @@ import org.junit.runner.RunWith;
...
@@ -10,6 +10,7 @@ import org.junit.runner.RunWith;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.test.annotation.Rollback
;
import
org.springframework.test.annotation.Rollback
;
import
org.springframework.test.context.ContextConfiguration
;
import
org.springframework.test.context.ContextConfiguration
;
import
org.springframework.test.context.junit4.AbstractTransactionalJUnit4SpringContextTests
;
import
org.springframework.test.context.junit4.SpringRunner
;
import
org.springframework.test.context.junit4.SpringRunner
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
...
@@ -27,7 +28,7 @@ import java.time.Instant;
...
@@ -27,7 +28,7 @@ import java.time.Instant;
@RunWith
(
SpringRunner
.
class
)
@RunWith
(
SpringRunner
.
class
)
@SpringBootTest
(
classes
=
Bootstrap
.
class
)
@SpringBootTest
(
classes
=
Bootstrap
.
class
)
@ContextConfiguration
(
initializers
=
ApolloPropertySourceInitializer
.
class
)
@ContextConfiguration
(
initializers
=
ApolloPropertySourceInitializer
.
class
)
public
class
ServiceTests
{
public
class
ServiceTests
extends
AbstractTransactionalJUnit4SpringContextTests
{
@Resource
@Resource
private
IUserService
userService
;
private
IUserService
userService
;
...
...
src/test/java/repsitory/UserAuthorizedRepsitoryTests.java
View file @
3d92b780
...
@@ -49,10 +49,10 @@ public class UserAuthorizedRepsitoryTests extends BaseParametersTests {
...
@@ -49,10 +49,10 @@ public class UserAuthorizedRepsitoryTests extends BaseParametersTests {
@Parameterized
.
Parameters
@Parameterized
.
Parameters
public
static
Collection
<
Object
[]>
data
()
{
public
static
Collection
<
Object
[]>
data
()
{
Object
[][]
data
=
new
Object
[][]{
Object
[][]
data
=
new
Object
[][]{
{
1L
,
"350504198805144101"
,
"史书一"
,
AuthPattern
.
ZMXY
,
true
},
{
"711892ae-191b-445a-a4eb-3c0b7bab7840"
,
"350504198805144101"
,
"史书一"
,
AuthPattern
.
ZMXY
,
true
},
{
10L
,
"350504198805144102"
,
"史书二"
,
AuthPattern
.
ZMXY
,
true
},
{
"711892ae-191b-445a-a4eb-3c0b7bab7841"
,
"350504198805144102"
,
"史书二"
,
AuthPattern
.
ZMXY
,
true
},
{
20L
,
"350504198805144103"
,
"史书三"
,
AuthPattern
.
FOUR_ELEMENTS_OF_BANK_CARD
,
true
},
{
"711892ae-191b-445a-a4eb-3c0b7bab7842"
,
"350504198805144103"
,
"史书三"
,
AuthPattern
.
FOUR_ELEMENTS_OF_BANK_CARD
,
true
},
{
1L
,
"IDNO-1"
,
"王-1"
,
AuthPattern
.
ZMXY
,
true
}
{
"711892ae-191b-445a-a4eb-3c0b7bab7843"
,
"IDNO-1"
,
"王-1"
,
AuthPattern
.
ZMXY
,
true
}
};
};
return
Arrays
.
asList
(
data
);
return
Arrays
.
asList
(
data
);
}
}
...
@@ -60,24 +60,24 @@ public class UserAuthorizedRepsitoryTests extends BaseParametersTests {
...
@@ -60,24 +60,24 @@ public class UserAuthorizedRepsitoryTests extends BaseParametersTests {
@Test
@Test
public
void
testExist
()
throws
Exception
{
public
void
testExist
()
throws
Exception
{
log
.
info
(
"testExist: name:{}, idNo:{}, userId:{}, authPattern:{}"
,
obj
.
getName
(),
obj
.
getIdNo
(),
obj
.
getUserUuid
(),
obj
.
getAuthPattern
());
log
.
info
(
"testExist: name:{}, idNo:{}, userId:{}, authPattern:{}"
,
obj
.
getName
(),
obj
.
getIdNo
(),
obj
.
getUserUuid
(),
obj
.
getAuthPattern
());
UserAuthorized
obj
=
new
UserAuthorized
();
boolean
exist
=
userAuthorizedRepository
.
exists
(
Example
.
of
(
obj
));
boolean
exist
=
userAuthorizedRepository
.
exists
(
Example
.
of
(
obj
));
Assert
.
assert
NotNull
(
obj
);
Assert
.
assert
False
(
exist
);
}
}
@Test
@Test
public
void
testSave
()
throws
Exception
{
public
void
testSave
()
throws
Exception
{
log
.
info
(
"testSave: name:{}, idNo:{}, userId:{}, authPattern:{}"
,
obj
.
getName
(),
obj
.
getIdNo
(),
obj
.
getUserUuid
(),
obj
.
getAuthPattern
());
log
.
info
(
"testSave: name:{}, idNo:{}, userId:{}, authPattern:{}"
,
obj
.
getName
(),
obj
.
getIdNo
(),
obj
.
getUserUuid
(),
obj
.
getAuthPattern
());
UserAuthorized
obj
=
new
UserAuthorized
(
);
Object
o
=
userAuthorizedRepository
.
save
(
obj
);
obj
=
userAuthorizedRepository
.
save
(
obj
);
Assert
.
assertNotNull
(
o
);
Assert
.
assert
NotNull
(
obj
);
Assert
.
assert
Equals
(
obj
,
o
);
}
}
@Test
@Test
public
void
testQuery
(){
public
void
test
Then
Query
(){
log
.
info
(
"testQuery: name:{}, idNo:{}, userId:{}, authPattern:{}"
,
obj
.
getName
(),
obj
.
getIdNo
(),
obj
.
getUserUuid
(),
obj
.
getAuthPattern
());
log
.
info
(
"testQuery: name:{}, idNo:{}, userId:{}, authPattern:{}"
,
obj
.
getName
(),
obj
.
getIdNo
(),
obj
.
getUserUuid
(),
obj
.
getAuthPattern
());
UserAuthorized
obj
=
userAuthorizedRepository
.
findByIdNo
(
this
.
obj
.
getIdNo
());
UserAuthorized
o
=
userAuthorizedRepository
.
findByIdNo
(
this
.
obj
.
getIdNo
());
Assert
.
assertNotNull
(
obj
);
Assert
.
assertNotNull
(
o
);
Assert
.
assertEquals
(
obj
.
getIdNo
(),
o
.
getIdNo
());
}
}
}
}
src/test/java/service/UserAuthorizedServiceTests.java
View file @
3d92b780
package
service
;
package
service
;
import
cn.quantgroup.xyqb.Bootstrap
;
import
cn.quantgroup.xyqb.Bootstrap
;
import
cn.quantgroup.xyqb.entity.UserAuthorized
;
import
cn.quantgroup.xyqb.model.AuthPattern
;
import
cn.quantgroup.xyqb.model.AuthPattern
;
import
cn.quantgroup.xyqb.model.UserAuthorizedParam
;
import
cn.quantgroup.xyqb.model.UserAuthorizedParam
;
import
cn.quantgroup.xyqb.service.auth.IUserAuthorizedService
;
import
cn.quantgroup.xyqb.service.auth.IUserAuthorizedService
;
...
@@ -8,8 +9,10 @@ import com.ctrip.framework.apollo.spring.config.ApolloPropertySourceInitializer;
...
@@ -8,8 +9,10 @@ import com.ctrip.framework.apollo.spring.config.ApolloPropertySourceInitializer;
import
demo.BaseParametersTests
;
import
demo.BaseParametersTests
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.junit.Assert
;
import
org.junit.Assert
;
import
org.junit.FixMethodOrder
;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.junit.runner.RunWith
;
import
org.junit.runners.MethodSorters
;
import
org.junit.runners.Parameterized
;
import
org.junit.runners.Parameterized
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.test.annotation.Rollback
;
import
org.springframework.test.annotation.Rollback
;
...
@@ -27,8 +30,9 @@ import java.util.Optional;
...
@@ -27,8 +30,9 @@ import java.util.Optional;
* @date 2018-01-05
* @date 2018-01-05
*/
*/
@Slf4j
@Slf4j
@Rollback
@Rollback
(
true
)
@Transactional
@Transactional
@FixMethodOrder
(
MethodSorters
.
NAME_ASCENDING
)
@RunWith
(
value
=
Parameterized
.
class
)
@RunWith
(
value
=
Parameterized
.
class
)
@SpringBootTest
(
classes
=
Bootstrap
.
class
)
@SpringBootTest
(
classes
=
Bootstrap
.
class
)
@ContextConfiguration
(
initializers
=
ApolloPropertySourceInitializer
.
class
)
@ContextConfiguration
(
initializers
=
ApolloPropertySourceInitializer
.
class
)
...
@@ -48,10 +52,10 @@ public class UserAuthorizedServiceTests extends BaseParametersTests {
...
@@ -48,10 +52,10 @@ public class UserAuthorizedServiceTests extends BaseParametersTests {
@Parameterized
.
Parameters
@Parameterized
.
Parameters
public
static
Collection
<
Object
[]>
data
()
{
public
static
Collection
<
Object
[]>
data
()
{
Object
[][]
data
=
new
Object
[][]{
Object
[][]
data
=
new
Object
[][]{
{
1L
,
"350504198805144101"
,
"史书一"
,
AuthPattern
.
ZMXY
,
true
},
{
"55544ae9-a1dd-458b-a7ac-2b4e64e59f99"
,
"350504198805144101"
,
"史书一"
,
AuthPattern
.
ZMXY
,
true
},
{
10L
,
"350504198805144102"
,
"史书二"
,
AuthPattern
.
ZMXY
,
true
},
{
"2f7715f1-e59e-4169-8214-89aef11d2291"
,
"350504198805144102"
,
"史书二"
,
AuthPattern
.
ZMXY
,
true
},
{
20L
,
"350504198805144103"
,
"史书三"
,
AuthPattern
.
FOUR_ELEMENTS_OF_BANK_CARD
,
true
},
{
"7addad2f-100b-49fa-ac44-bb729dfca06e"
,
"350504198805144103"
,
"史书三"
,
AuthPattern
.
FOUR_ELEMENTS_OF_BANK_CARD
,
true
},
{
1L
,
"IDNO-1"
,
"王-1"
,
AuthPattern
.
ZMXY
,
true
}
{
"2dae9875-71ba-47bd-9332-0e4922f75f12"
,
"IDNO-1"
,
"王-1"
,
AuthPattern
.
ZMXY
,
true
}
};
};
return
Arrays
.
asList
(
data
);
return
Arrays
.
asList
(
data
);
}
}
...
@@ -59,22 +63,23 @@ public class UserAuthorizedServiceTests extends BaseParametersTests {
...
@@ -59,22 +63,23 @@ public class UserAuthorizedServiceTests extends BaseParametersTests {
@Test
@Test
public
void
testExist
()
throws
Exception
{
public
void
testExist
()
throws
Exception
{
log
.
info
(
"testExist: name:{}, idNo:{}, userId:{}, authPattern:{}"
,
obj
.
getName
(),
obj
.
getIdNo
(),
obj
.
getUserUuid
(),
obj
.
getAuthPattern
());
log
.
info
(
"testExist: name:{}, idNo:{}, userId:{}, authPattern:{}"
,
obj
.
getName
(),
obj
.
getIdNo
(),
obj
.
getUserUuid
(),
obj
.
getAuthPattern
());
Object
obj
=
userAuthorizedService
.
hasUserAuthorized
(
this
.
obj
.
getIdNo
());
Boolean
exist
=
userAuthorizedService
.
hasUserAuthorized
(
this
.
obj
.
getIdNo
());
Assert
.
assert
NotNull
(
obj
);
Assert
.
assert
False
(
exist
);
}
}
@Test
@Test
public
void
testSave
()
throws
Exception
{
public
void
testSave
()
throws
Exception
{
log
.
info
(
"testSave: name:{}, idNo:{}, userId:{}, authPattern:{}"
,
obj
.
getName
(),
obj
.
getIdNo
(),
obj
.
getUserUuid
(),
obj
.
getAuthPattern
());
log
.
info
(
"testSave: name:{}, idNo:{}, userId:{}, authPattern:{}"
,
obj
.
getName
(),
obj
.
getIdNo
(),
obj
.
getUserUuid
(),
obj
.
getAuthPattern
());
Object
obj
=
userAuthorizedService
.
createUserAuthorized
(
this
.
obj
);
UserAuthorized
o
=
userAuthorizedService
.
createUserAuthorized
(
this
.
obj
);
Assert
.
assertNotNull
(
obj
);
Assert
.
assertNotNull
(
o
);
Assert
.
assertEquals
(
obj
.
getIdNo
(),
o
.
getIdNo
());
}
}
@Test
@Test
public
void
testQuery
(){
public
void
test
Then
Query
(){
log
.
info
(
"testQuery: name:{}, idNo:{}, userId:{}, authPattern:{}"
,
obj
.
getName
(),
obj
.
getIdNo
(),
obj
.
getUserUuid
(),
obj
.
getAuthPattern
());
log
.
info
(
"testQuery: name:{}, idNo:{}, userId:{}, authPattern:{}"
,
obj
.
getName
(),
obj
.
getIdNo
(),
obj
.
getUserUuid
(),
obj
.
getAuthPattern
());
Object
o
bj
=
userAuthorizedService
.
getUserAuthorizedId
(
this
.
obj
.
getUserUuid
());
Object
o
=
userAuthorizedService
.
getUserAuthorizedId
(
this
.
obj
.
getUserUuid
());
Assert
.
assertNotNull
(
o
bj
);
Assert
.
assertNotNull
(
o
);
}
}
}
}
src/test/java/web/UserAuthorizedControllerTests.java
View file @
3d92b780
...
@@ -38,12 +38,12 @@ public class UserAuthorizedControllerTests extends BaseParametersTests {
...
@@ -38,12 +38,12 @@ public class UserAuthorizedControllerTests extends BaseParametersTests {
private
TestRestTemplate
restTemplate
;
private
TestRestTemplate
restTemplate
;
private
UserAuthorizedParam
obj
=
new
UserAuthorizedParam
();
private
UserAuthorizedParam
obj
=
new
UserAuthorizedParam
();
{
{
Long
userId
=
1L
;
String
userUuid
=
"711892ae-191b-445a-a4eb-3c0b7bab7840"
;
String
idNo
=
"350504198805144101"
;
String
idNo
=
"350504198805144101"
;
String
name
=
"史书一"
;
String
name
=
"史书一"
;
AuthPattern
authPattern
=
AuthPattern
.
ZMXY
;
AuthPattern
authPattern
=
AuthPattern
.
ZMXY
;
Boolean
available
=
true
;
Boolean
available
=
true
;
obj
.
setUser
Id
(
userI
d
);
obj
.
setUser
Uuid
(
userUui
d
);
obj
.
setIdNo
(
idNo
);
obj
.
setIdNo
(
idNo
);
obj
.
setName
(
name
);
obj
.
setName
(
name
);
obj
.
setAuthPattern
(
Optional
.
ofNullable
(
authPattern
).
orElse
(
AuthPattern
.
ZMXY
).
name
());
obj
.
setAuthPattern
(
Optional
.
ofNullable
(
authPattern
).
orElse
(
AuthPattern
.
ZMXY
).
name
());
...
@@ -52,20 +52,20 @@ public class UserAuthorizedControllerTests extends BaseParametersTests {
...
@@ -52,20 +52,20 @@ public class UserAuthorizedControllerTests extends BaseParametersTests {
@Test
@Test
public
void
testExist
()
throws
Exception
{
public
void
testExist
()
throws
Exception
{
ResponseEntity
<
String
>
phil
=
restTemplate
.
getForEntity
(
"/user/auth/{model}?idNo={idNo}"
,
String
.
class
,
"hasUserAuthorized"
,
obj
.
getIdNo
());
ResponseEntity
<
String
>
phil
=
restTemplate
.
getForEntity
(
"/user/auth/{model}?idNo={idNo}"
,
String
.
class
,
"hasUserAuthorized"
,
obj
.
getIdNo
());
log
.
info
(
"testExist: name:{}, idNo:{}, userId:{}, authPattern:{}"
,
obj
.
getName
(),
obj
.
getIdNo
(),
obj
.
get
UserId
(),
obj
.
get
AuthPattern
());
log
.
info
(
"testExist: name:{}, idNo:{}, userId:{}, authPattern:{}"
,
obj
.
getName
(),
obj
.
getIdNo
(),
obj
.
getAuthPattern
());
Assert
.
assertEquals
(
phil
.
getStatusCode
(),
HttpStatus
.
OK
);
Assert
.
assertEquals
(
phil
.
getStatusCode
(),
HttpStatus
.
OK
);
}
}
@Test
@Test
public
void
testSave
()
throws
Exception
{
public
void
testSave
()
throws
Exception
{
ResponseEntity
<
String
>
phil
=
restTemplate
.
postForEntity
(
"/user/auth/{model}"
,
this
.
obj
,
String
.
class
,
"createUserAuthorized"
);
ResponseEntity
<
String
>
phil
=
restTemplate
.
postForEntity
(
"/user/auth/{model}"
,
this
.
obj
,
String
.
class
,
"createUserAuthorized"
);
log
.
info
(
"testSave: name:{}, idNo:{}, userId:{}, authPattern:{}"
,
obj
.
getName
(),
obj
.
getIdNo
(),
obj
.
get
UserId
(),
obj
.
get
AuthPattern
());
log
.
info
(
"testSave: name:{}, idNo:{}, userId:{}, authPattern:{}"
,
obj
.
getName
(),
obj
.
getIdNo
(),
obj
.
getAuthPattern
());
Assert
.
assertEquals
(
phil
.
getStatusCode
(),
HttpStatus
.
OK
);
Assert
.
assertEquals
(
phil
.
getStatusCode
(),
HttpStatus
.
OK
);
}
}
@Test
@Test
public
void
testQuery
(){
public
void
testQuery
(){
ResponseEntity
<
String
>
phil
=
restTemplate
.
getForEntity
(
"/user/auth/{model}?user
Id={userId}"
,
String
.
class
,
"getUserAuthorizedId"
,
obj
.
getUserI
d
());
ResponseEntity
<
String
>
phil
=
restTemplate
.
getForEntity
(
"/user/auth/{model}?user
Uuid={userUuid}"
,
String
.
class
,
"getUserAuthorizedId"
,
obj
.
getUserUui
d
());
Assert
.
assertEquals
(
phil
.
getStatusCode
(),
HttpStatus
.
OK
);
Assert
.
assertEquals
(
phil
.
getStatusCode
(),
HttpStatus
.
OK
);
}
}
...
...
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