Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
cash-loan-flow-boss
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
QG
cash-loan-flow-boss
Commits
ac214743
Commit
ac214743
authored
Mar 03, 2020
by
王向伟
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
用户管理和角色管理
parent
d0c5016a
Changes
22
Hide whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
623 additions
and
165 deletions
+623
-165
MavenWrapperDownloader.java
.mvn/wrapper/MavenWrapperDownloader.java
+0
-114
maven-wrapper.jar
.mvn/wrapper/maven-wrapper.jar
+0
-0
maven-wrapper.properties
.mvn/wrapper/maven-wrapper.properties
+0
-1
Permission.java
...hloanflowboss/api/permissionmodule/entity/Permission.java
+2
-0
PermissionRepository.java
...api/permissionmodule/repository/PermissionRepository.java
+15
-0
RoleController.java
.../cashloanflowboss/api/role/controller/RoleController.java
+26
-16
Role.java
.../cn/quantgroup/cashloanflowboss/api/role/entity/Role.java
+8
-0
RoleModelVo.java
...antgroup/cashloanflowboss/api/role/model/RoleModelVo.java
+27
-0
RoleQueryModel.java
...group/cashloanflowboss/api/role/model/RoleQueryModel.java
+14
-0
RoleRepository.java
.../cashloanflowboss/api/role/repository/RoleRepository.java
+10
-1
RoleService.java
...tgroup/cashloanflowboss/api/role/service/RoleService.java
+14
-19
RoleServiceImpl.java
...up/cashloanflowboss/api/role/service/RoleServiceImpl.java
+142
-0
UserController.java
.../cashloanflowboss/api/user/controller/UserController.java
+60
-4
User.java
.../cn/quantgroup/cashloanflowboss/api/user/entity/User.java
+20
-1
QueryUserListModel.java
...p/cashloanflowboss/api/user/model/QueryUserListModel.java
+2
-0
UserModelVo.java
...antgroup/cashloanflowboss/api/user/model/UserModelVo.java
+53
-0
UserRepository.java
.../cashloanflowboss/api/user/repository/UserRepository.java
+15
-0
UserService.java
...tgroup/cashloanflowboss/api/user/service/UserService.java
+21
-3
UserServiceImpl.java
...up/cashloanflowboss/api/user/service/UserServiceImpl.java
+93
-6
ChannelApplyInfoStrategyTest.java
...owboss/service/contract/ChannelApplyInfoStrategyTest.java
+4
-0
RoleTest.java
...uantgroup/cashloanflowboss/service/contract/RoleTest.java
+41
-0
UserTest.java
...uantgroup/cashloanflowboss/service/contract/UserTest.java
+56
-0
No files found.
.mvn/wrapper/MavenWrapperDownloader.java
deleted
100644 → 0
View file @
d0c5016a
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.net.URL
;
import
java.nio.channels.Channels
;
import
java.nio.channels.ReadableByteChannel
;
import
java.util.Properties
;
public
class
MavenWrapperDownloader
{
/**
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
*/
private
static
final
String
DEFAULT_DOWNLOAD_URL
=
"https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar"
;
/**
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
* use instead of the default one.
*/
private
static
final
String
MAVEN_WRAPPER_PROPERTIES_PATH
=
".mvn/wrapper/maven-wrapper.properties"
;
/**
* Path where the maven-wrapper.jar will be saved to.
*/
private
static
final
String
MAVEN_WRAPPER_JAR_PATH
=
".mvn/wrapper/maven-wrapper.jar"
;
/**
* Name of the property which should be used to override the default download url for the wrapper.
*/
private
static
final
String
PROPERTY_NAME_WRAPPER_URL
=
"wrapperUrl"
;
public
static
void
main
(
String
args
[])
{
System
.
out
.
println
(
"- Downloader started"
);
File
baseDirectory
=
new
File
(
args
[
0
]);
System
.
out
.
println
(
"- Using base directory: "
+
baseDirectory
.
getAbsolutePath
());
// If the maven-wrapper.properties exists, read it and check if it contains a custom
// wrapperUrl parameter.
File
mavenWrapperPropertyFile
=
new
File
(
baseDirectory
,
MAVEN_WRAPPER_PROPERTIES_PATH
);
String
url
=
DEFAULT_DOWNLOAD_URL
;
if
(
mavenWrapperPropertyFile
.
exists
())
{
FileInputStream
mavenWrapperPropertyFileInputStream
=
null
;
try
{
mavenWrapperPropertyFileInputStream
=
new
FileInputStream
(
mavenWrapperPropertyFile
);
Properties
mavenWrapperProperties
=
new
Properties
();
mavenWrapperProperties
.
load
(
mavenWrapperPropertyFileInputStream
);
url
=
mavenWrapperProperties
.
getProperty
(
PROPERTY_NAME_WRAPPER_URL
,
url
);
}
catch
(
IOException
e
)
{
System
.
out
.
println
(
"- ERROR loading '"
+
MAVEN_WRAPPER_PROPERTIES_PATH
+
"'"
);
}
finally
{
try
{
if
(
mavenWrapperPropertyFileInputStream
!=
null
)
{
mavenWrapperPropertyFileInputStream
.
close
();
}
}
catch
(
IOException
e
)
{
// Ignore ...
}
}
}
System
.
out
.
println
(
"- Downloading from: : "
+
url
);
File
outputFile
=
new
File
(
baseDirectory
.
getAbsolutePath
(),
MAVEN_WRAPPER_JAR_PATH
);
if
(!
outputFile
.
getParentFile
().
exists
())
{
if
(!
outputFile
.
getParentFile
().
mkdirs
())
{
System
.
out
.
println
(
"- ERROR creating output direcrory '"
+
outputFile
.
getParentFile
().
getAbsolutePath
()
+
"'"
);
}
}
System
.
out
.
println
(
"- Downloading to: "
+
outputFile
.
getAbsolutePath
());
try
{
downloadFileFromURL
(
url
,
outputFile
);
System
.
out
.
println
(
"Done"
);
System
.
exit
(
0
);
}
catch
(
Throwable
e
)
{
System
.
out
.
println
(
"- Error downloading"
);
e
.
printStackTrace
();
System
.
exit
(
1
);
}
}
private
static
void
downloadFileFromURL
(
String
urlString
,
File
destination
)
throws
Exception
{
URL
website
=
new
URL
(
urlString
);
ReadableByteChannel
rbc
;
rbc
=
Channels
.
newChannel
(
website
.
openStream
());
FileOutputStream
fos
=
new
FileOutputStream
(
destination
);
fos
.
getChannel
().
transferFrom
(
rbc
,
0
,
Long
.
MAX_VALUE
);
fos
.
close
();
rbc
.
close
();
}
}
.mvn/wrapper/maven-wrapper.jar
deleted
100644 → 0
View file @
d0c5016a
File deleted
.mvn/wrapper/maven-wrapper.properties
deleted
100644 → 0
View file @
d0c5016a
distributionUrl
=
https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip
src/main/java/cn/quantgroup/cashloanflowboss/api/permissionmodule/entity/Permission.java
View file @
ac214743
...
@@ -4,6 +4,7 @@ import cn.quantgroup.cashloanflowboss.component.security.Authority;
...
@@ -4,6 +4,7 @@ import cn.quantgroup.cashloanflowboss.component.security.Authority;
import
lombok.AllArgsConstructor
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
lombok.NoArgsConstructor
;
import
org.hibernate.annotations.Proxy
;
import
javax.persistence.*
;
import
javax.persistence.*
;
import
java.util.List
;
import
java.util.List
;
...
@@ -16,6 +17,7 @@ import java.util.List;
...
@@ -16,6 +17,7 @@ import java.util.List;
@AllArgsConstructor
@AllArgsConstructor
@Entity
@Entity
@Table
(
name
=
"permission"
)
@Table
(
name
=
"permission"
)
@Proxy
(
lazy
=
false
)
public
class
Permission
{
public
class
Permission
{
/**
/**
...
...
src/main/java/cn/quantgroup/cashloanflowboss/api/permissionmodule/repository/PermissionRepository.java
0 → 100644
View file @
ac214743
package
cn
.
quantgroup
.
cashloanflowboss
.
api
.
permissionmodule
.
repository
;
import
cn.quantgroup.cashloanflowboss.api.permissionmodule.entity.Permission
;
import
cn.quantgroup.cashloanflowboss.core.persistence.CashLoanFlowBossPubConfDataSource
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.stereotype.Repository
;
/**
* @author Wang Xiangwei
* @version 2020/3/2
*/
@CashLoanFlowBossPubConfDataSource
@Repository
public
interface
PermissionRepository
extends
JpaRepository
<
Permission
,
Long
>
{
}
src/main/java/cn/quantgroup/cashloanflowboss/api/role/controller/RoleController.java
View file @
ac214743
package
cn
.
quantgroup
.
cashloanflowboss
.
api
.
role
.
controller
;
package
cn
.
quantgroup
.
cashloanflowboss
.
api
.
role
.
controller
;
import
cn.quantgroup.cashloanflowboss.api.role.entity.Role
;
import
cn.quantgroup.cashloanflowboss.api.role.entity.Role
;
import
cn.quantgroup.cashloanflowboss.api.role.model.RoleModelVo
;
import
cn.quantgroup.cashloanflowboss.api.role.model.RoleQueryModel
;
import
cn.quantgroup.cashloanflowboss.api.role.model.RoleVO
;
import
cn.quantgroup.cashloanflowboss.api.role.model.RoleVO
;
import
cn.quantgroup.cashloanflowboss.api.role.service.RoleService
;
import
cn.quantgroup.cashloanflowboss.component.security.annotiation.Security
;
import
cn.quantgroup.cashloanflowboss.component.security.annotiation.Security
;
import
cn.quantgroup.cashloanflowboss.core.base.Result
;
import
cn.quantgroup.cashloanflowboss.core.base.Result
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.data.domain.Page
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.validation.Valid
;
/**
/**
* function:
* function:
...
@@ -19,28 +23,34 @@ import org.springframework.web.bind.annotation.RestController;
...
@@ -19,28 +23,34 @@ import org.springframework.web.bind.annotation.RestController;
@RequestMapping
(
"role"
)
@RequestMapping
(
"role"
)
public
class
RoleController
{
public
class
RoleController
{
@Autowired
private
RoleService
roleService
;
@GetMapping
(
"list"
)
@GetMapping
(
"list"
)
@Security
(
authorityId
=
"Role.roleList"
)
//@Security(authorityId = "Role.roleList")
public
Result
roleList
()
{
public
Result
<
Page
<
Role
>>
roleList
(
@Valid
RoleQueryModel
roleQueryModel
)
{
return
roleService
.
getRoleByName
(
roleQueryModel
);
return
null
;
}
}
@GetMapping
(
"delete"
)
@DeleteMapping
(
"delete/{roleId}"
)
@Security
(
authorityId
=
"Role.delete"
)
//@Security(authorityId = "Role.delete")
public
Result
deleteRole
()
{
public
Result
<
Boolean
>
deleteRole
(
@PathVariable
Long
roleId
)
{
return
roleService
.
deleteRole
(
roleId
);
return
null
;
}
}
@PostMapping
(
"save"
)
@PostMapping
(
"save"
)
@Security
(
authorityId
=
"Role.saveRole"
)
//@Security(authorityId = "Role.saveRole")
public
Result
saveRole
(
RoleVO
role
)
{
public
Result
<
Boolean
>
saveRole
(
@RequestBody
@Valid
RoleModelVo
roleModelVo
)
{
return
roleService
.
addRole
(
roleModelVo
);
}
return
null
;
@PutMapping
(
"update"
)
// @Security(authorityId = "Role.update")
public
Result
<
Boolean
>
updateRole
(
@RequestBody
@Valid
RoleModelVo
roleModelVo
){
return
roleService
.
modifyRole
(
roleModelVo
);
}
}
...
...
src/main/java/cn/quantgroup/cashloanflowboss/api/role/entity/Role.java
View file @
ac214743
...
@@ -3,6 +3,7 @@ package cn.quantgroup.cashloanflowboss.api.role.entity;
...
@@ -3,6 +3,7 @@ package cn.quantgroup.cashloanflowboss.api.role.entity;
import
cn.quantgroup.cashloanflowboss.api.permissionmodule.entity.Permission
;
import
cn.quantgroup.cashloanflowboss.api.permissionmodule.entity.Permission
;
import
cn.quantgroup.cashloanflowboss.core.persistence.Primary
;
import
cn.quantgroup.cashloanflowboss.core.persistence.Primary
;
import
lombok.Data
;
import
lombok.Data
;
import
org.hibernate.annotations.Proxy
;
import
javax.persistence.*
;
import
javax.persistence.*
;
import
java.util.List
;
import
java.util.List
;
...
@@ -14,6 +15,7 @@ import java.util.function.UnaryOperator;
...
@@ -14,6 +15,7 @@ import java.util.function.UnaryOperator;
@Data
@Data
@Entity
@Entity
@Table
(
name
=
"role"
)
@Table
(
name
=
"role"
)
@Proxy
(
lazy
=
false
)
public
class
Role
extends
Primary
implements
UnaryOperator
<
Role
>
{
public
class
Role
extends
Primary
implements
UnaryOperator
<
Role
>
{
/**
/**
...
@@ -29,6 +31,12 @@ public class Role extends Primary implements UnaryOperator<Role> {
...
@@ -29,6 +31,12 @@ public class Role extends Primary implements UnaryOperator<Role> {
@Column
(
name
=
"name"
)
@Column
(
name
=
"name"
)
private
String
name
;
private
String
name
;
/**
* 角色描述
*/
@Column
(
name
=
"[desc]"
)
private
String
desc
;
/**
/**
* 授权列表
* 授权列表
*/
*/
...
...
src/main/java/cn/quantgroup/cashloanflowboss/api/role/model/RoleModelVo.java
0 → 100644
View file @
ac214743
package
cn
.
quantgroup
.
cashloanflowboss
.
api
.
role
.
model
;
import
cn.quantgroup.cashloanflowboss.component.validator.constraints.NotEmpty
;
import
lombok.Data
;
import
java.util.List
;
/**
* @author Wang Xiangwei
* @version 2020/3/2
*/
@Data
public
class
RoleModelVo
{
private
Long
id
;
private
Long
parentId
;
@NotEmpty
(
message
=
"角色名不能为空"
)
private
String
name
;
private
String
desc
;
private
List
<
Long
>
permissions
;
}
src/main/java/cn/quantgroup/cashloanflowboss/api/role/model/RoleQueryModel.java
0 → 100644
View file @
ac214743
package
cn
.
quantgroup
.
cashloanflowboss
.
api
.
role
.
model
;
import
cn.quantgroup.cashloanflowboss.core.base.Pagination
;
import
lombok.Data
;
/**
* @author Wang Xiangwei
* @version 2020/3/2
*/
@Data
public
class
RoleQueryModel
extends
Pagination
{
private
String
name
;
}
src/main/java/cn/quantgroup/cashloanflowboss/api/role/repository/RoleRepository.java
View file @
ac214743
...
@@ -3,7 +3,11 @@ package cn.quantgroup.cashloanflowboss.api.role.repository;
...
@@ -3,7 +3,11 @@ package cn.quantgroup.cashloanflowboss.api.role.repository;
import
cn.quantgroup.cashloanflowboss.api.role.entity.Role
;
import
cn.quantgroup.cashloanflowboss.api.role.entity.Role
;
import
cn.quantgroup.cashloanflowboss.core.persistence.CashLoanFlowBossDataSource
;
import
cn.quantgroup.cashloanflowboss.core.persistence.CashLoanFlowBossDataSource
;
import
cn.quantgroup.cashloanflowboss.core.persistence.CashLoanFlowBossPubConfDataSource
;
import
cn.quantgroup.cashloanflowboss.core.persistence.CashLoanFlowBossPubConfDataSource
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.JpaSpecificationExecutor
;
import
org.springframework.data.jpa.repository.Query
;
import
org.springframework.stereotype.Repository
;
import
org.springframework.stereotype.Repository
;
/**
/**
...
@@ -11,5 +15,10 @@ import org.springframework.stereotype.Repository;
...
@@ -11,5 +15,10 @@ import org.springframework.stereotype.Repository;
*/
*/
@CashLoanFlowBossPubConfDataSource
@CashLoanFlowBossPubConfDataSource
@Repository
@Repository
public
interface
RoleRepository
extends
JpaRepository
<
Role
,
Long
>
{
public
interface
RoleRepository
extends
JpaRepository
<
Role
,
Long
>
,
JpaSpecificationExecutor
<
Role
>
{
Role
getByName
(
String
name
);
}
}
src/main/java/cn/quantgroup/cashloanflowboss/api/role/service/RoleService.java
View file @
ac214743
package
cn
.
quantgroup
.
cashloanflowboss
.
api
.
role
.
service
;
package
cn
.
quantgroup
.
cashloanflowboss
.
api
.
role
.
service
;
import
cn.quantgroup.cashloanflowboss.api.role.entity.Role
;
import
cn.quantgroup.cashloanflowboss.api.role.entity.Role
;
import
cn.quantgroup.cashloanflowboss.api.role.
repository.RoleRepository
;
import
cn.quantgroup.cashloanflowboss.api.role.
model.RoleModelVo
;
import
lombok.extern.slf4j.Slf4j
;
import
cn.quantgroup.cashloanflowboss.api.role.model.RoleQueryModel
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
cn.quantgroup.cashloanflowboss.core.base.Result
;
import
org.springframework.
stereotype.Servic
e
;
import
org.springframework.
data.domain.Pag
e
;
import
java.util.List
;
/**
* @author Wang Xiangwei
* @version 2020/3/2
*/
public
interface
RoleService
{
@Slf4j
Result
<
Boolean
>
addRole
(
RoleModelVo
roleModelVo
);
@Service
public
class
RoleService
{
@Autowired
Result
<
Page
<
Role
>>
getRoleByName
(
RoleQueryModel
roleQueryModel
);
private
RoleRepository
roleRepository
;
/**
Result
<
Boolean
>
modifyRole
(
RoleModelVo
roleModelVo
);
* 获取用户角色列表
*
Result
<
Boolean
>
deleteRole
(
Long
roleId
);
* @param ids 角色ID
* @return
*/
public
List
<
Role
>
getRoles
(
List
<
Long
>
ids
)
{
return
this
.
roleRepository
.
findAll
(
ids
);
}
}
}
src/main/java/cn/quantgroup/cashloanflowboss/api/role/service/RoleServiceImpl.java
0 → 100644
View file @
ac214743
package
cn
.
quantgroup
.
cashloanflowboss
.
api
.
role
.
service
;
import
cn.quantgroup.cashloanflowboss.api.permissionmodule.entity.Permission
;
import
cn.quantgroup.cashloanflowboss.api.permissionmodule.repository.PermissionRepository
;
import
cn.quantgroup.cashloanflowboss.api.role.entity.Role
;
import
cn.quantgroup.cashloanflowboss.api.role.model.RoleModelVo
;
import
cn.quantgroup.cashloanflowboss.api.role.model.RoleQueryModel
;
import
cn.quantgroup.cashloanflowboss.api.role.repository.RoleRepository
;
import
cn.quantgroup.cashloanflowboss.core.base.Result
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.PageRequest
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.persistence.criteria.Predicate
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
@Slf4j
@Service
public
class
RoleServiceImpl
implements
RoleService
{
@Autowired
private
RoleRepository
roleRepository
;
@Autowired
private
PermissionRepository
permissionRepository
;
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
Result
<
Boolean
>
addRole
(
RoleModelVo
roleModelVo
)
{
final
String
LOG_PRE
=
"RoleServiceImpl.addRole"
;
log
.
info
(
"{} 添加角色 roleModelVo={}"
,
LOG_PRE
,
roleModelVo
);
String
name
=
roleModelVo
.
getName
();
Role
exist
=
roleRepository
.
getByName
(
name
);
if
(
exist
!=
null
){
log
.
error
(
"{} 已存在角色 name={}"
,
LOG_PRE
,
name
);
return
Result
.
buildFail
(
name
+
"已存在,请更换角色名"
);
}
Role
role
=
new
Role
();
BeanUtils
.
copyProperties
(
roleModelVo
,
role
);
Long
parentId
=
roleModelVo
.
getParentId
();
if
(
parentId
!=
null
){
log
.
info
(
"{},父角色查询 parentId={}"
,
LOG_PRE
,
parentId
);
Role
parent
=
roleRepository
.
getOne
(
parentId
);
role
.
setParent
(
parent
);
}
List
<
Long
>
permissions
=
roleModelVo
.
getPermissions
();
if
(
CollectionUtils
.
isNotEmpty
(
permissions
)){
List
<
Permission
>
all
=
permissionRepository
.
findAll
(
permissions
);
log
.
info
(
"{} 权限ids={} 对应的权限size={}"
,
LOG_PRE
,
permissions
,
all
.
size
());
role
.
setPermissions
(
all
);
}
roleRepository
.
save
(
role
);
return
Result
.
buildSuccess
(
true
);
}
@Override
public
Result
<
Page
<
Role
>>
getRoleByName
(
RoleQueryModel
roleQueryModel
)
{
final
String
LOG_PRE
=
"RoleServiceImpl.getRoleByName"
;
log
.
info
(
"{} 查询角色 roleQueryModel={}"
,
LOG_PRE
,
roleQueryModel
);
Page
<
Role
>
rolePage
=
roleRepository
.
findAll
((
root
,
criteriaQuery
,
criteriaBuilder
)
->
{
List
<
Predicate
>
predicates
=
new
ArrayList
<>();
if
(
StringUtils
.
isNotEmpty
(
roleQueryModel
.
getName
()))
{
predicates
.
add
(
criteriaBuilder
.
equal
(
root
.
get
(
"name"
),
roleQueryModel
.
getName
()));
}
criteriaQuery
.
where
(
criteriaBuilder
.
and
(
predicates
.
toArray
(
new
Predicate
[
predicates
.
size
()])));
// 指定排序
criteriaQuery
.
orderBy
(
criteriaBuilder
.
desc
(
root
.
get
(
"id"
)));
return
criteriaQuery
.
getRestriction
();
},
new
PageRequest
(
roleQueryModel
.
getPageNumber
(),
roleQueryModel
.
getPageSize
()));
return
Result
.
buildSuccess
(
rolePage
);
}
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
Result
<
Boolean
>
modifyRole
(
RoleModelVo
roleModelVo
)
{
final
String
LOG_PRE
=
"RoleServiceImpl.modifyRole"
;
log
.
info
(
"{} 更新角色 roleQueryModel={}"
,
LOG_PRE
,
roleModelVo
);
Long
id
=
roleModelVo
.
getId
();
if
(
id
==
null
){
log
.
error
(
"{} 更新的角色没有Id,无法更新 roleModelVo={}"
,
LOG_PRE
,
roleModelVo
);
return
Result
.
buildFail
(
"角色没有id,无法更新"
);
}
Role
exist
=
roleRepository
.
getOne
(
id
);
if
(
exist
==
null
){
log
.
error
(
"{},没有对应的角色 id={}"
,
LOG_PRE
,
id
);
return
Result
.
buildFail
(
"没有对应的角色"
);
}
BeanUtils
.
copyProperties
(
roleModelVo
,
exist
);
Long
parentId
=
roleModelVo
.
getParentId
();
if
(
parentId
!=
null
){
Role
parent
=
roleRepository
.
getOne
(
parentId
);
log
.
info
(
"{},id={},parentId={},父角色为{}"
,
LOG_PRE
,
id
,
parentId
,
parent
);
exist
.
setParent
(
parent
);
}
List
<
Long
>
permissions
=
roleModelVo
.
getPermissions
();
if
(
CollectionUtils
.
isEmpty
(
permissions
)){
exist
.
setPermissions
(
null
);
}
else
{
List
<
Permission
>
permissionList
=
permissionRepository
.
findAll
(
permissions
);
exist
.
setPermissions
(
permissionList
);
}
exist
.
setUpdateTime
(
new
Date
());
roleRepository
.
save
(
exist
);
return
Result
.
buildSuccess
(
true
);
}
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
Result
<
Boolean
>
deleteRole
(
Long
roleId
)
{
final
String
LOG_PRE
=
"RoleServiceImpl.deleteRole"
;
log
.
info
(
"{} 删除角色 roleId={}"
,
LOG_PRE
,
roleId
);
roleRepository
.
delete
(
roleId
);
return
Result
.
buildSuccess
(
true
);
}
}
src/main/java/cn/quantgroup/cashloanflowboss/api/user/controller/UserController.java
View file @
ac214743
package
cn
.
quantgroup
.
cashloanflowboss
.
api
.
user
.
controller
;
package
cn
.
quantgroup
.
cashloanflowboss
.
api
.
user
.
controller
;
import
cn.quantgroup.cashloanflowboss.api.user.dictionary.UserRank
;
import
cn.quantgroup.cashloanflowboss.api.user.dictionary.UserStatus
;
import
cn.quantgroup.cashloanflowboss.api.user.entity.User
;
import
cn.quantgroup.cashloanflowboss.api.user.entity.User
;
import
cn.quantgroup.cashloanflowboss.api.user.model.
QueryUserListModel
;
import
cn.quantgroup.cashloanflowboss.api.user.model.
*
;
import
cn.quantgroup.cashloanflowboss.core.base.Pagination
;
import
cn.quantgroup.cashloanflowboss.core.base.Pagination
;
import
cn.quantgroup.cashloanflowboss.api.user.model.RegisterUserFormModel
;
import
cn.quantgroup.cashloanflowboss.api.user.model.UserDetailInfo
;
import
cn.quantgroup.cashloanflowboss.api.user.model.UserInfoModel
;
import
cn.quantgroup.cashloanflowboss.api.user.service.UserService
;
import
cn.quantgroup.cashloanflowboss.api.user.service.UserService
;
import
cn.quantgroup.cashloanflowboss.component.security.annotiation.Security
;
import
cn.quantgroup.cashloanflowboss.component.security.annotiation.Security
;
import
cn.quantgroup.cashloanflowboss.component.validator.constraints.NotEmpty
;
import
cn.quantgroup.cashloanflowboss.component.validator.constraints.NotEmpty
;
...
@@ -18,6 +17,7 @@ import javax.validation.constraints.NotNull;
...
@@ -18,6 +17,7 @@ import javax.validation.constraints.NotNull;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Page
;
import
org.springframework.http.MediaType
;
import
org.springframework.web.bind.annotation.DeleteMapping
;
import
org.springframework.web.bind.annotation.DeleteMapping
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
...
@@ -27,6 +27,9 @@ import org.springframework.web.bind.annotation.RequestMapping;
...
@@ -27,6 +27,9 @@ import org.springframework.web.bind.annotation.RequestMapping;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
/**
* Created by WeiWei on 2019/7/22.
* Created by WeiWei on 2019/7/22.
*/
*/
...
@@ -147,4 +150,57 @@ public class UserController {
...
@@ -147,4 +150,57 @@ public class UserController {
return
true
;
return
true
;
}
}
/**
* 添加用户
* @param userModelVo
* @return
*/
// @Security(authorityId = "User.add")
@PostMapping
(
value
=
"/add"
)
public
Result
<
Boolean
>
addUser
(
@RequestBody
@Valid
UserModelVo
userModelVo
){
return
userService
.
addUser
(
userModelVo
);
}
@PutMapping
(
"/modify"
)
// @Security(authorityId = "User.update")
public
Result
<
Boolean
>
modifyUser
(
@RequestBody
@Valid
UserModelVo
userModelVo
){
return
userService
.
modifyUser
(
userModelVo
);
}
/**
* 根据用户名、角色分页查询
* @param queryUserListModel
* @return
*/
@GetMapping
(
"/list/get"
)
//@Security(authorityId = "User.list")
public
Result
<
Page
<
User
>>
UserList
(
@Valid
QueryUserListModel
queryUserListModel
){
return
userService
.
getUserList
(
queryUserListModel
);
}
@GetMapping
(
"/rank"
)
public
Result
<
List
<
String
>>
userRank
(){
List
<
String
>
list
=
new
ArrayList
<>();
for
(
UserRank
value
:
UserRank
.
values
())
{
if
(
value
==
UserRank
.
ADMINISTRATOR
||
value
==
UserRank
.
SUPER_ADMINISTRATOR
){
continue
;
}
list
.
add
(
value
.
name
());
}
return
Result
.
buildSuccess
(
list
);
}
@GetMapping
(
"/status"
)
public
Result
<
List
<
String
>>
userStatus
(){
List
<
String
>
list
=
new
ArrayList
<>();
for
(
UserStatus
value
:
UserStatus
.
values
())
{
list
.
add
(
value
.
name
());
}
return
Result
.
buildSuccess
(
list
);
}
}
}
src/main/java/cn/quantgroup/cashloanflowboss/api/user/entity/User.java
View file @
ac214743
...
@@ -3,13 +3,17 @@ package cn.quantgroup.cashloanflowboss.api.user.entity;
...
@@ -3,13 +3,17 @@ package cn.quantgroup.cashloanflowboss.api.user.entity;
import
cn.quantgroup.cashloanflowboss.api.role.entity.Role
;
import
cn.quantgroup.cashloanflowboss.api.role.entity.Role
;
import
cn.quantgroup.cashloanflowboss.api.user.dictionary.UserRank
;
import
cn.quantgroup.cashloanflowboss.api.user.dictionary.UserRank
;
import
cn.quantgroup.cashloanflowboss.api.user.dictionary.UserStatus
;
import
cn.quantgroup.cashloanflowboss.api.user.dictionary.UserStatus
;
import
cn.quantgroup.cashloanflowboss.api.user.model.UserModelVo
;
import
cn.quantgroup.cashloanflowboss.core.persistence.Primary
;
import
cn.quantgroup.cashloanflowboss.core.persistence.Primary
;
import
cn.quantgroup.cashloanflowboss.utils.MD5Tools
;
import
lombok.Data
;
import
lombok.Data
;
import
org.hibernate.annotations.Proxy
;
import
org.springframework.beans.BeanUtils
;
import
javax.persistence.*
;
import
javax.persistence.*
;
import
java.util.Collections
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Set
;
/**
/**
* Created by WeiWei on 2019/7/22.
* Created by WeiWei on 2019/7/22.
...
@@ -17,6 +21,7 @@ import java.util.Set;
...
@@ -17,6 +21,7 @@ import java.util.Set;
@Data
@Data
@Entity
@Entity
@Table
(
name
=
"user"
)
@Table
(
name
=
"user"
)
@Proxy
(
lazy
=
false
)
public
class
User
extends
Primary
{
public
class
User
extends
Primary
{
/**
/**
...
@@ -70,4 +75,18 @@ public class User extends Primary {
...
@@ -70,4 +75,18 @@ public class User extends Primary {
@Column
(
name
=
"last_login_time"
)
@Column
(
name
=
"last_login_time"
)
private
Date
lastLoginTime
;
private
Date
lastLoginTime
;
public
static
User
valueOf
(
UserModelVo
userModelVo
,
Role
role
)
{
if
(
userModelVo
==
null
)
{
return
null
;
}
User
user
=
new
User
();
BeanUtils
.
copyProperties
(
userModelVo
,
user
);
user
.
setPassword
(
MD5Tools
.
md5
(
userModelVo
.
getPassword
()));
if
(
role
!=
null
)
{
user
.
setRoles
(
Collections
.
singletonList
(
role
));
}
return
user
;
}
}
}
src/main/java/cn/quantgroup/cashloanflowboss/api/user/model/QueryUserListModel.java
View file @
ac214743
...
@@ -12,4 +12,6 @@ import lombok.Data;
...
@@ -12,4 +12,6 @@ import lombok.Data;
@Data
@Data
public
class
QueryUserListModel
extends
Pagination
{
public
class
QueryUserListModel
extends
Pagination
{
private
String
nickname
;
private
String
nickname
;
private
Long
roleId
;
}
}
src/main/java/cn/quantgroup/cashloanflowboss/api/user/model/UserModelVo.java
0 → 100644
View file @
ac214743
package
cn
.
quantgroup
.
cashloanflowboss
.
api
.
user
.
model
;
import
cn.quantgroup.cashloanflowboss.api.user.dictionary.UserRank
;
import
cn.quantgroup.cashloanflowboss.api.user.dictionary.UserStatus
;
import
cn.quantgroup.cashloanflowboss.component.validator.constraints.NotEmpty
;
import
lombok.Data
;
/**
* @author Wang Xiangwei
* @version 2020/3/2
*/
@Data
public
class
UserModelVo
{
private
Long
id
;
/**
* 用户名
*/
@NotEmpty
(
message
=
"用户名不能为空"
)
private
String
username
;
/**
* 昵称
*/
@NotEmpty
(
message
=
"用户昵称不能为空"
)
private
String
nickname
;
/**
* 密码
*/
@NotEmpty
(
message
=
"用户密码不能为空"
)
private
String
password
;
/**
* 渠道ID
*/
private
Long
channelId
;
/**
* 用户级别
*/
@NotEmpty
(
message
=
"用户级别不能为空"
)
private
UserRank
rank
;
private
Long
roleId
;
/**
* 用户状态
*/
@NotEmpty
(
message
=
"用户活跃状态不能为空"
)
private
UserStatus
status
;
}
src/main/java/cn/quantgroup/cashloanflowboss/api/user/repository/UserRepository.java
View file @
ac214743
...
@@ -3,8 +3,12 @@ package cn.quantgroup.cashloanflowboss.api.user.repository;
...
@@ -3,8 +3,12 @@ package cn.quantgroup.cashloanflowboss.api.user.repository;
import
cn.quantgroup.cashloanflowboss.api.user.entity.User
;
import
cn.quantgroup.cashloanflowboss.api.user.entity.User
;
import
cn.quantgroup.cashloanflowboss.core.persistence.CashLoanFlowBossDataSource
;
import
cn.quantgroup.cashloanflowboss.core.persistence.CashLoanFlowBossDataSource
;
import
cn.quantgroup.cashloanflowboss.core.persistence.CashLoanFlowBossPubConfDataSource
;
import
cn.quantgroup.cashloanflowboss.core.persistence.CashLoanFlowBossPubConfDataSource
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.JpaSpecificationExecutor
;
import
org.springframework.data.jpa.repository.JpaSpecificationExecutor
;
import
org.springframework.data.jpa.repository.Query
;
import
org.springframework.data.repository.query.Param
;
import
org.springframework.stereotype.Repository
;
import
org.springframework.stereotype.Repository
;
/**
/**
...
@@ -23,4 +27,15 @@ public interface UserRepository extends JpaRepository<User, Long>, JpaSpecificat
...
@@ -23,4 +27,15 @@ public interface UserRepository extends JpaRepository<User, Long>, JpaSpecificat
User
getUserByUsername
(
String
username
);
User
getUserByUsername
(
String
username
);
@Query
(
value
=
"select user.* from user,user_role_mapping urm where urm.user_id= user.id "
+
"and IF ( ?1 =\"\",1=1, user.nickname = ?1) "
+
"and IF (?2 =\"\", 1=1, urm.role_id= ?2) "
+
"ORDER BY ?#{#pageable}"
,
countQuery
=
"select count(user.id) from user,user_role_mapping urm where urm.user_id= user.id "
+
"and IF ( ?1 =\"\",1=1, user.nickname = ?1) "
+
"and IF (?2 =\"\", 1=1, urm.role_id= ?2) "
,
nativeQuery
=
true
)
Page
<
User
>
getUserByNicknameAndRoleId
(
String
nickname
,
String
roleId
,
Pageable
pageable
);
}
}
src/main/java/cn/quantgroup/cashloanflowboss/api/user/service/UserService.java
View file @
ac214743
package
cn
.
quantgroup
.
cashloanflowboss
.
api
.
user
.
service
;
package
cn
.
quantgroup
.
cashloanflowboss
.
api
.
user
.
service
;
import
cn.quantgroup.cashloanflowboss.api.user.entity.User
;
import
cn.quantgroup.cashloanflowboss.api.user.entity.User
;
import
cn.quantgroup.cashloanflowboss.api.user.model.QueryUserListModel
;
import
cn.quantgroup.cashloanflowboss.api.user.model.*
;
import
cn.quantgroup.cashloanflowboss.api.user.model.UserDetailInfo
;
import
cn.quantgroup.cashloanflowboss.core.base.Result
;
import
cn.quantgroup.cashloanflowboss.api.user.model.UserInfoModel
;
import
cn.quantgroup.cashloanflowboss.core.base.Tuple
;
import
cn.quantgroup.cashloanflowboss.core.base.Tuple
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Page
;
...
@@ -33,4 +32,23 @@ public interface UserService {
...
@@ -33,4 +32,23 @@ public interface UserService {
User
saveUserInfo
(
UserInfoModel
user
);
User
saveUserInfo
(
UserInfoModel
user
);
Tuple
<
Boolean
,
String
>
cleanUserActiveOrder
(
String
mobile
);
Tuple
<
Boolean
,
String
>
cleanUserActiveOrder
(
String
mobile
);
/**
* 添加用户,账号校验
* @param
* @return
*/
Result
<
Boolean
>
addUser
(
UserModelVo
userModelVo
);
/**
* 更新用户,账号不能更改
* @param
* @return
*/
Result
<
Boolean
>
modifyUser
(
UserModelVo
userModelVo
);
Result
<
Page
<
User
>>
getUserList
(
QueryUserListModel
queryUserListModel
);
}
}
src/main/java/cn/quantgroup/cashloanflowboss/api/user/service/UserServiceImpl.java
View file @
ac214743
package
cn
.
quantgroup
.
cashloanflowboss
.
api
.
user
.
service
;
package
cn
.
quantgroup
.
cashloanflowboss
.
api
.
user
.
service
;
import
cn.quantgroup.cashloanflowboss.api.login.model.Principal
;
import
cn.quantgroup.cashloanflowboss.api.login.model.Principal
;
import
cn.quantgroup.cashloanflowboss.api.role.entity.Role
;
import
cn.quantgroup.cashloanflowboss.api.role.repository.RoleRepository
;
import
cn.quantgroup.cashloanflowboss.api.user.dictionary.UserStatus
;
import
cn.quantgroup.cashloanflowboss.api.user.dictionary.UserStatus
;
import
cn.quantgroup.cashloanflowboss.api.user.entity.User
;
import
cn.quantgroup.cashloanflowboss.api.user.entity.User
;
import
cn.quantgroup.cashloanflowboss.api.user.model.QueryUserListModel
;
import
cn.quantgroup.cashloanflowboss.api.user.model.QueryUserListModel
;
import
cn.quantgroup.cashloanflowboss.api.user.model.UserDetailInfo
;
import
cn.quantgroup.cashloanflowboss.api.user.model.UserDetailInfo
;
import
cn.quantgroup.cashloanflowboss.api.user.model.UserInfoModel
;
import
cn.quantgroup.cashloanflowboss.api.user.model.UserInfoModel
;
import
cn.quantgroup.cashloanflowboss.api.user.model.UserModelVo
;
import
cn.quantgroup.cashloanflowboss.api.user.repository.UserRepository
;
import
cn.quantgroup.cashloanflowboss.api.user.repository.UserRepository
;
import
cn.quantgroup.cashloanflowboss.core.Application
;
import
cn.quantgroup.cashloanflowboss.core.Application
;
import
cn.quantgroup.cashloanflowboss.core.asserts.Assert
;
import
cn.quantgroup.cashloanflowboss.core.asserts.Assert
;
import
cn.quantgroup.cashloanflowboss.core.base.Result
;
import
cn.quantgroup.cashloanflowboss.core.base.Tuple
;
import
cn.quantgroup.cashloanflowboss.core.base.Tuple
;
import
cn.quantgroup.cashloanflowboss.core.dictionary.ApplicationStatus
;
import
cn.quantgroup.cashloanflowboss.core.dictionary.ApplicationStatus
;
import
cn.quantgroup.cashloanflowboss.spi.user.service.XyqbUserService
;
import
cn.quantgroup.cashloanflowboss.spi.user.service.XyqbUserService
;
...
@@ -21,20 +25,20 @@ import org.springframework.beans.BeanUtils;
...
@@ -21,20 +25,20 @@ import org.springframework.beans.BeanUtils;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.PageRequest
;
import
org.springframework.data.domain.PageRequest
;
import
org.springframework.data.domain.Sort
;
import
org.springframework.scheduling.annotation.Async
;
import
org.springframework.scheduling.annotation.Async
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.persistence.criteria.Predicate
;
import
javax.persistence.criteria.Predicate
;
import
java.util.ArrayList
;
import
java.util.*
;
import
java.util.List
;
import
java.util.Objects
;
/**
/**
* Created by WeiWei on 2019/7/22.
* Created by WeiWei on 2019/7/22.
*/
*/
@Slf4j
@Slf4j
@Service
@Service
public
class
UserServiceImpl
implements
UserService
{
public
class
UserServiceImpl
implements
UserService
{
@Autowired
@Autowired
private
UserRepository
userRepository
;
private
UserRepository
userRepository
;
...
@@ -43,6 +47,8 @@ public class UserServiceImpl implements UserService{
...
@@ -43,6 +47,8 @@ public class UserServiceImpl implements UserService{
@Autowired
@Autowired
private
XyqbUserService
xyqbUserService
;
private
XyqbUserService
xyqbUserService
;
@Autowired
private
RoleRepository
roleRepository
;
/**
/**
...
@@ -197,12 +203,93 @@ public class UserServiceImpl implements UserService{
...
@@ -197,12 +203,93 @@ public class UserServiceImpl implements UserService{
@Async
(
"commonAsyncExecutor"
)
@Async
(
"commonAsyncExecutor"
)
//@OperationAnno(channelNo = "#this[0]", opt = OptEnumName.USER_ORDER_CLEAN, succSPEL = "#this.key", optDetailSPEL = "#this.value")
//@OperationAnno(channelNo = "#this[0]", opt = OptEnumName.USER_ORDER_CLEAN, succSPEL = "#this.key", optDetailSPEL = "#this.value")
@Override
@Override
public
Tuple
<
Boolean
,
String
>
cleanUserActiveOrder
(
String
mobile
)
{
public
Tuple
<
Boolean
,
String
>
cleanUserActiveOrder
(
String
mobile
)
{
XUser
user
=
xyqbUserService
.
findUserByPhoneNo
(
mobile
);
XUser
user
=
xyqbUserService
.
findUserByPhoneNo
(
mobile
);
if
(
user
==
null
)
{
if
(
user
==
null
)
{
log
.
info
(
"cleanUserOrder,清除用户活跃订单失败,未找到用户 phoneNo={}"
,
mobile
);
log
.
info
(
"cleanUserOrder,清除用户活跃订单失败,未找到用户 phoneNo={}"
,
mobile
);
return
new
Tuple
<>(
false
,
"清除用户活跃订单失败,未找到用户"
);
return
new
Tuple
<>(
false
,
"清除用户活跃订单失败,未找到用户"
);
}
}
return
xyqbCenterService
.
cleanUserActiveOrder
(
user
.
getId
());
return
xyqbCenterService
.
cleanUserActiveOrder
(
user
.
getId
());
}
}
@Override
@Transactional
public
Result
<
Boolean
>
addUser
(
UserModelVo
userModelVo
)
{
final
String
LOG_PRE
=
"UserServiceImpl.addUser"
;
log
.
info
(
"{} 添加用户 rank={}"
,
LOG_PRE
,
userModelVo
);
String
username
=
userModelVo
.
getUsername
();
User
exist
=
this
.
getUser
(
username
);
if
(
exist
!=
null
)
{
log
.
error
(
"{},用户已存在 userName={}"
,
LOG_PRE
,
username
);
return
Result
.
buildFail
(
username
+
"用户已存在"
);
}
Long
roleId
=
userModelVo
.
getRoleId
();
Role
role
=
roleRepository
.
getOne
(
roleId
);
if
(
role
==
null
)
{
log
.
error
(
"{},不存在对应的角色 roleId={}"
,
LOG_PRE
,
roleId
);
return
Result
.
buildFail
(
"不存在对应的角色"
);
}
User
user
=
User
.
valueOf
(
userModelVo
,
role
);
userRepository
.
save
(
user
);
return
Result
.
buildSuccess
(
true
);
}
@Override
@Transactional
public
Result
<
Boolean
>
modifyUser
(
UserModelVo
userModelVo
)
{
final
String
LOG_PRE
=
"UserServiceImpl.modifyUser"
;
Long
id
=
userModelVo
.
getId
();
if
(
id
==
null
)
{
log
.
error
(
"{} 缺少主键id, userModelVo={}"
,
LOG_PRE
,
userModelVo
);
return
Result
.
buildFail
(
"缺少用户Id"
);
}
User
exist
=
userRepository
.
getOne
(
id
);
if
(
exist
==
null
)
{
log
.
error
(
"{}不存在相应的用户,不能更新 userModelVo={}"
,
LOG_PRE
,
userModelVo
);
return
Result
.
buildFail
(
"不存在相应的用户,不能更新"
);
}
String
existUsername
=
exist
.
getUsername
();
String
username
=
userModelVo
.
getUsername
();
if
(!
existUsername
.
equals
(
username
))
{
log
.
error
(
"{}用户名不能修改,userModelVo={}"
,
LOG_PRE
,
userModelVo
);
return
Result
.
buildFail
(
"用户名不能修改"
);
}
Long
roleId
=
userModelVo
.
getRoleId
();
Role
role
=
roleRepository
.
getOne
(
roleId
);
if
(
role
==
null
)
{
log
.
error
(
"{},不存在对应的角色 roleId={}"
,
LOG_PRE
,
roleId
);
return
Result
.
buildFail
(
"不存在对应的角色"
);
}
BeanUtils
.
copyProperties
(
userModelVo
,
exist
);
exist
.
setPassword
(
MD5Tools
.
md5
(
userModelVo
.
getPassword
()));
exist
.
setRoles
(
Collections
.
singletonList
(
role
));
exist
.
setUpdateTime
(
new
Date
());
userRepository
.
save
(
exist
);
return
Result
.
buildSuccess
(
true
);
}
@Override
public
Result
<
Page
<
User
>>
getUserList
(
QueryUserListModel
queryUserListModel
)
{
final
String
LOG_PRE
=
"UserServiceImpl.getUserList"
;
log
.
info
(
"{},查询用户列表,queryUserListModel={}"
,
LOG_PRE
,
queryUserListModel
);
String
nickname
=
queryUserListModel
.
getNickname
();
Long
roleId
=
queryUserListModel
.
getRoleId
();
PageRequest
pageRequest
=
new
PageRequest
(
queryUserListModel
.
getPageNumber
(),
queryUserListModel
.
getPageSize
(),
new
Sort
(
Sort
.
Direction
.
DESC
,
"id"
));
Page
<
User
>
userPage
=
userRepository
.
getUserByNicknameAndRoleId
(
nickname
==
null
?
""
:
nickname
,
roleId
==
null
?
""
:
roleId
.
toString
(),
pageRequest
);
return
Result
.
buildSuccess
(
userPage
);
}
}
}
src/test/java/cn/quantgroup/cashloanflowboss/service/contract/ChannelApplyInfoStrategyTest.java
View file @
ac214743
...
@@ -55,6 +55,10 @@ public class ChannelApplyInfoStrategyTest extends CashLoanFlowBossApplicationTes
...
@@ -55,6 +55,10 @@ public class ChannelApplyInfoStrategyTest extends CashLoanFlowBossApplicationTes
channelApplyInfoStrategy
.
setChannelUserId
(
true
);
channelApplyInfoStrategy
.
setChannelUserId
(
true
);
channelConfService
.
editChannelConfInfo
(
channelConf
);
channelConfService
.
editChannelConfInfo
(
channelConf
);
//数据恢复
channelApplyInfoStrategy
.
setChannelUserId
(
false
);
channelConfService
.
editChannelConfInfo
(
channelConf
);
}
}
...
...
src/test/java/cn/quantgroup/cashloanflowboss/service/contract/RoleTest.java
0 → 100644
View file @
ac214743
package
cn
.
quantgroup
.
cashloanflowboss
.
service
.
contract
;
import
cn.quantgroup.cashloanflowboss.CashLoanFlowBossApplicationTests
;
import
cn.quantgroup.cashloanflowboss.api.role.entity.Role
;
import
cn.quantgroup.cashloanflowboss.api.role.model.RoleQueryModel
;
import
cn.quantgroup.cashloanflowboss.api.role.service.RoleService
;
import
cn.quantgroup.cashloanflowboss.core.base.Result
;
import
org.junit.Test
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Page
;
/**
* @author Wang Xiangwei
* @version 2020/3/2
*/
public
class
RoleTest
extends
CashLoanFlowBossApplicationTests
{
@Autowired
private
RoleService
roleService
;
@Test
public
void
roleTest
(){
// RoleModelVo roleModel = new RoleModelVo();
// roleModel.setName("测试角色");
// roleModel.setDesc("测试");
// Result<Role> roleResult = roleService.addRole(roleModel);
RoleQueryModel
roleQueryModel
=
new
RoleQueryModel
();
// roleQueryModel.setName("测试角色");
roleQueryModel
.
setPageNumber
(
1
);
roleQueryModel
.
setPageSize
(
5
);
Result
<
Page
<
Role
>>
roleByName
=
roleService
.
getRoleByName
(
roleQueryModel
);
// roleModel.setName("测试");
// Long id = roleResult.getData().getId();
// roleModel.setId(id);
// roleService.modifyRole(roleModel);
//
// Result<Boolean> booleanResult = roleService.deleteRole(roleResult.getData().getId());
}
}
src/test/java/cn/quantgroup/cashloanflowboss/service/contract/UserTest.java
0 → 100644
View file @
ac214743
package
cn
.
quantgroup
.
cashloanflowboss
.
service
.
contract
;
import
cn.quantgroup.cashloanflowboss.CashLoanFlowBossApplicationTests
;
import
cn.quantgroup.cashloanflowboss.api.user.entity.User
;
import
cn.quantgroup.cashloanflowboss.api.user.model.QueryUserListModel
;
import
cn.quantgroup.cashloanflowboss.api.user.service.UserService
;
import
cn.quantgroup.cashloanflowboss.core.base.Result
;
import
org.junit.Test
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Page
;
/**
* @author Wang Xiangwei
* @version 2020/3/2
*/
public
class
UserTest
extends
CashLoanFlowBossApplicationTests
{
@Autowired
UserService
userService
;
@Test
public
void
testUser
(){
// UserModelVo userModel = new UserModelVo();
//
// userModel.setNickname("测试账号");
// userModel.setUsername("test11111111111");
// userModel.setPassword("123456");
// userModel.setRank(UserRank.OPERATOR);
// userModel.setRoleId(9L);
// userModel.setStatus(UserStatus.ENABLED);
// Result<User> result = userService.addUser(userModel);
//
// User rank = result.getData();
//
// userModel.setId(rank.getId());
// userModel.setNickname("测试账号123");
//
// Result<User> result1 = userService.modifyUser(userModel);
QueryUserListModel
model
=
new
QueryUserListModel
();
// model.setNickname("小丽");
model
.
setRoleId
(
9L
);
model
.
setPageNumber
(
1
);
model
.
setPageSize
(
4
);
Result
<
Page
<
User
>>
userList
=
userService
.
getUserList
(
model
);
System
.
out
.
println
(
userList
.
getData
().
getContent
().
size
());
// userService.removeUser(rank.getId());
}
}
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