Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
scrm
/
rop-merchant
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 646d2c24
authored
Aug 01, 2021
by
zhouhb
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
[+]公共方法添加
1 parent
1d5259eb
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
173 additions
and
37 deletions
pom.xml
src/main/java/cn/com/glsx/merchants/config/DubboConfig.java
src/main/java/cn/com/glsx/merchants/config/UserAspect.java
src/main/java/cn/com/glsx/merchants/controller/MerchantCommonController.java
src/main/java/cn/com/glsx/merchants/response/CarbrandResponse.java
src/main/java/cn/com/glsx/merchants/service/MerchantCommonService.java
src/main/java/cn/com/glsx/merchants/service/StaffService.java
pom.xml
View file @
646d2c2
...
...
@@ -37,5 +37,16 @@
<artifactId>
dozer-spring-boot-starter
</artifactId>
<version>
6.5.2
</version>
</dependency>
<dependency>
<groupId>
com.glsx.biz
</groupId>
<artifactId>
biz-base-service
</artifactId>
<version>
3.0.0-SNAPSHOT
</version>
<exclusions>
<exclusion>
<groupId>
org.slf4j
</groupId>
<artifactId>
slf4j-api
</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</project>
\ No newline at end of file
src/main/java/cn/com/glsx/merchants/config/DubboConfig.java
View file @
646d2c2
package
cn
.
com
.
glsx
.
merchants
.
config
;
import
cn.com.glsx.merchants.remote.*
;
import
com.glsx.biz.common.base.service.CarbrandService
;
import
org.oreframework.boot.autoconfigure.dubbo.reference.ReferenceBuilderFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Bean
;
...
...
@@ -17,61 +18,67 @@ public class DubboConfig {
@Bean
public
MerchantProductRemote
getMerchantProductRemote
()
{
return
factory
.
builder
(
MerchantProductRemote
.
class
).
check
(
false
).
timeout
(
30000
).
version
(
"2.0.0"
).
build
();
return
factory
.
builder
(
MerchantProductRemote
.
class
).
check
(
false
).
timeout
(
30000
).
version
(
"2.0.0"
).
url
(
"dubbo://192.168.3.191:22889"
).
build
();
}
@Bean
public
MerchantProductMenuRemote
getMerchantProductMenuRemote
()
{
return
factory
.
builder
(
MerchantProductMenuRemote
.
class
).
check
(
false
).
timeout
(
30000
).
version
(
"2.0.0"
).
build
();
return
factory
.
builder
(
MerchantProductMenuRemote
.
class
).
check
(
false
).
timeout
(
30000
).
version
(
"2.0.0"
).
url
(
"dubbo://192.168.3.191:22889"
).
build
();
}
@Bean
public
MerchantDictTypeRemote
getMerchantDictTypeRemote
()
{
return
factory
.
builder
(
MerchantDictTypeRemote
.
class
).
check
(
false
).
timeout
(
30000
).
version
(
"2.0.0"
).
build
();
return
factory
.
builder
(
MerchantDictTypeRemote
.
class
).
check
(
false
).
timeout
(
30000
).
version
(
"2.0.0"
).
url
(
"dubbo://192.168.3.191:22889"
).
build
();
}
@Bean
public
MerchantDictDataRemote
getMerchantDictDataRemote
()
{
return
factory
.
builder
(
MerchantDictDataRemote
.
class
).
check
(
false
).
timeout
(
30000
).
version
(
"2.0.0"
).
build
();
return
factory
.
builder
(
MerchantDictDataRemote
.
class
).
check
(
false
).
timeout
(
30000
).
version
(
"2.0.0"
).
url
(
"dubbo://192.168.3.191:22889"
).
build
();
}
@Bean
public
MerchantProductFunctionRemote
getMerchantProductFunctionRemote
()
{
return
factory
.
builder
(
MerchantProductFunctionRemote
.
class
).
check
(
false
).
timeout
(
30000
).
version
(
"2.0.0"
).
build
();
return
factory
.
builder
(
MerchantProductFunctionRemote
.
class
).
check
(
false
).
timeout
(
30000
).
version
(
"2.0.0"
).
url
(
"dubbo://192.168.3.191:22889"
).
build
();
}
@Bean
public
MerchantLogRemote
getMerchantLogRemote
()
{
return
factory
.
builder
(
MerchantLogRemote
.
class
).
check
(
false
).
timeout
(
30000
).
version
(
"2.0.0"
).
build
();
return
factory
.
builder
(
MerchantLogRemote
.
class
).
check
(
false
).
timeout
(
30000
).
version
(
"2.0.0"
).
url
(
"dubbo://192.168.3.191:22889"
).
build
();
}
@Bean
public
MerchantUserRemote
getMerchantUserRemote
()
{
return
factory
.
builder
(
MerchantUserRemote
.
class
).
check
(
false
).
timeout
(
30000
).
version
(
"2.0.0"
).
build
();
return
factory
.
builder
(
MerchantUserRemote
.
class
).
check
(
false
).
timeout
(
30000
).
version
(
"2.0.0"
).
url
(
"dubbo://192.168.3.191:22889"
).
build
();
}
@Bean
public
MerchantFileRemote
getMerchantFileRemote
()
{
return
factory
.
builder
(
MerchantFileRemote
.
class
).
check
(
false
).
timeout
(
30000
).
version
(
"2.0.0"
).
build
();
return
factory
.
builder
(
MerchantFileRemote
.
class
).
check
(
false
).
timeout
(
30000
).
version
(
"2.0.0"
).
url
(
"dubbo://192.168.3.191:22889"
).
build
();
}
@Bean
public
MerchantAccountTypeRemote
getMerchantAccountTypeRemote
()
{
return
factory
.
builder
(
MerchantAccountTypeRemote
.
class
).
check
(
false
).
timeout
(
30000
).
version
(
"2.0.0"
).
build
();
return
factory
.
builder
(
MerchantAccountTypeRemote
.
class
).
check
(
false
).
timeout
(
30000
).
version
(
"2.0.0"
).
url
(
"dubbo://192.168.3.191:22889"
).
build
();
}
@Bean
public
MerchantRoleRemote
getMerchantRoleRemote
()
{
return
factory
.
builder
(
MerchantRoleRemote
.
class
).
check
(
false
).
timeout
(
30000
).
version
(
"2.0.0"
).
build
();
return
factory
.
builder
(
MerchantRoleRemote
.
class
).
check
(
false
).
timeout
(
30000
).
version
(
"2.0.0"
).
url
(
"dubbo://192.168.3.191:22889"
).
build
();
}
@Bean
public
MerchantRemote
getMerchantRemote
()
{
return
factory
.
builder
(
MerchantRemote
.
class
).
check
(
false
).
timeout
(
30000
).
version
(
"2.0.0"
).
build
();
return
factory
.
builder
(
MerchantRemote
.
class
).
check
(
false
).
timeout
(
30000
).
version
(
"2.0.0"
).
url
(
"dubbo://192.168.3.191:22889"
).
build
();
}
@Bean
public
MerchantStaffRemote
getMerchantStaffRemote
()
{
return
factory
.
builder
(
MerchantStaffRemote
.
class
).
check
(
false
).
timeout
(
30000
).
version
(
"2.0.0"
).
build
();
return
factory
.
builder
(
MerchantStaffRemote
.
class
).
check
(
false
).
timeout
(
30000
).
version
(
"2.0.0"
).
url
(
"dubbo://192.168.3.191:22889"
).
build
();
}
@Bean
public
CarbrandService
getCarbrandService
(){
return
factory
.
builder
(
CarbrandService
.
class
).
check
(
false
).
timeout
(
30000
).
version
(
"2.2.0"
).
build
();
}
}
src/main/java/cn/com/glsx/merchants/config/UserAspect.java
View file @
646d2c2
...
...
@@ -50,31 +50,33 @@ public class UserAspect {
*/
public
void
setUser
(
JoinPoint
joinPoint
)
throws
Exception
{
Object
[]
args
=
joinPoint
.
getArgs
();
Object
object
=
args
[
0
];
try
{
if
(
object
instanceof
DefaultRequest
)
{
MerchantUser
user
=
getUser
((
AbstractRopRequest
)
object
);
Class
userCla
=
(
Class
)
object
.
getClass
();
Class
superclass
=
userCla
.
getSuperclass
();
Field
field
=
superclass
.
getDeclaredField
(
"createdBy"
);
Field
field1
=
superclass
.
getDeclaredField
(
"createdAccount"
);
Field
field2
=
superclass
.
getDeclaredField
(
"updatedBy"
);
Field
field3
=
superclass
.
getDeclaredField
(
"updatedAccount"
);
Field
field4
=
superclass
.
getDeclaredField
(
"source"
);
field
.
setAccessible
(
true
);
field
.
set
(
object
,
user
.
getId
());
field3
.
setAccessible
(
true
);
field3
.
set
(
object
,
user
.
getUsername
());
field1
.
setAccessible
(
true
);
field1
.
set
(
object
,
user
.
getUsername
());
field2
.
setAccessible
(
true
);
field2
.
set
(
object
,
user
.
getId
());
field4
.
setAccessible
(
true
);
field4
.
set
(
object
,
user
.
getSource
());
if
(
args
!=
null
&&
args
.
length
!=
0
)
{
Object
object
=
args
[
0
];
try
{
if
(
object
instanceof
DefaultRequest
)
{
MerchantUser
user
=
getUser
((
AbstractRopRequest
)
object
);
Class
userCla
=
(
Class
)
object
.
getClass
();
Class
superclass
=
userCla
.
getSuperclass
();
Field
field
=
superclass
.
getDeclaredField
(
"createdBy"
);
Field
field1
=
superclass
.
getDeclaredField
(
"createdAccount"
);
Field
field2
=
superclass
.
getDeclaredField
(
"updatedBy"
);
Field
field3
=
superclass
.
getDeclaredField
(
"updatedAccount"
);
Field
field4
=
superclass
.
getDeclaredField
(
"source"
);
field
.
setAccessible
(
true
);
field
.
set
(
object
,
user
.
getId
());
field3
.
setAccessible
(
true
);
field3
.
set
(
object
,
user
.
getUsername
());
field1
.
setAccessible
(
true
);
field1
.
set
(
object
,
user
.
getUsername
());
field2
.
setAccessible
(
true
);
field2
.
set
(
object
,
user
.
getId
());
field4
.
setAccessible
(
true
);
field4
.
set
(
object
,
user
.
getSource
());
}
}
catch
(
NoSuchFieldException
|
IllegalAccessException
e
)
{
e
.
printStackTrace
();
throw
new
RpcServiceException
(
DefaultErrorEnum
.
SERVER_ERROR
);
}
}
catch
(
NoSuchFieldException
|
IllegalAccessException
e
)
{
e
.
printStackTrace
();
throw
new
RpcServiceException
(
DefaultErrorEnum
.
SERVER_ERROR
);
}
}
...
...
src/main/java/cn/com/glsx/merchants/controller/MerchantCommonController.java
0 → 100644
View file @
646d2c2
package
cn
.
com
.
glsx
.
merchants
.
controller
;
import
cn.com.glsx.framework.core.exception.RpcServiceException
;
import
cn.com.glsx.framework.rop.response.RopResponse
;
import
cn.com.glsx.merchants.request.DefaultRequest
;
import
cn.com.glsx.merchants.request.accounttype.AccountTypeSearchRequest
;
import
cn.com.glsx.merchants.response.AccountTypeResponse
;
import
cn.com.glsx.merchants.response.CarbrandResponse
;
import
cn.com.glsx.merchants.service.MerchantCommonService
;
import
com.rop.AbstractRopRequest
;
import
com.rop.annotation.NeedInSessionType
;
import
com.rop.annotation.ServiceMethod
;
import
com.rop.annotation.ServiceMethodBean
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
java.util.List
;
/**
* @author zhouhaibao
* @version 1.0
* @description: 商户公共服务
* @date 2021/8/1 10:16
*/
@Slf4j
@Api
(
"商户公共服务"
)
@ServiceMethodBean
(
version
=
"1.0.0"
,
needInSession
=
NeedInSessionType
.
NO
)
public
class
MerchantCommonController
{
@Autowired
private
MerchantCommonService
merchantCommonService
;
/**
* 获取车辆品牌树
*
* @param defaultRequest
* @return
*/
@ServiceMethod
(
method
=
"cn.com.glsx.merchants.merchantCommon.getCarbrandTree"
,
needInSession
=
NeedInSessionType
.
NO
)
@ApiOperation
(
"获取车辆品牌树"
)
public
RopResponse
<
List
<
CarbrandResponse
>>
getCarbrandTree
(
DefaultRequest
defaultRequest
)
{
try
{
return
RopResponse
.
success
(
merchantCommonService
.
getCarbrandTree
());
}
catch
(
RpcServiceException
e
)
{
log
.
info
(
"=======MerchantCommonController__invoke__getCarbrandTree__exception:{}"
,
e
.
getMessage
());
return
RopResponse
.
error
(
e
.
getErrId
(),
e
.
getMessage
());
}
}
}
src/main/java/cn/com/glsx/merchants/response/CarbrandResponse.java
0 → 100644
View file @
646d2c2
package
cn
.
com
.
glsx
.
merchants
.
response
;
import
lombok.Data
;
import
java.util.List
;
/**
* @author zhouhaibao
* @version 1.0
* @description: TODO
* @date 2021/8/1 10:17
*/
@Data
public
class
CarbrandResponse
{
private
Integer
id
;
private
String
label
;
private
List
<
CarbrandResponse
>
childrens
;
}
src/main/java/cn/com/glsx/merchants/service/MerchantCommonService.java
0 → 100644
View file @
646d2c2
package
cn
.
com
.
glsx
.
merchants
.
service
;
import
cn.com.glsx.merchants.response.CarbrandResponse
;
import
com.glsx.biz.common.base.entity.Carbrand
;
import
com.glsx.biz.common.base.service.CarbrandService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
import
java.util.stream.Collectors
;
/**
* @author zhouhaibao
* @version 1.0
* @description: 商户公共服务
* @date 2021/8/1 10:20
*/
@Service
public
class
MerchantCommonService
{
@Autowired
private
CarbrandService
carbrandService
;
public
List
<
CarbrandResponse
>
getCarbrandTree
()
{
List
<
Carbrand
>
parentCarbrandList
=
carbrandService
.
getParentCarbrandList
();
List
<
Carbrand
>
allList
=
carbrandService
.
getAllList
();
List
<
CarbrandResponse
>
collect
=
parentCarbrandList
.
stream
().
map
(
index
->
{
CarbrandResponse
carbrandResponse
=
new
CarbrandResponse
();
carbrandResponse
.
setId
(
index
.
getBid
());
carbrandResponse
.
setLabel
(
index
.
getBrand
());
List
<
CarbrandResponse
>
childrens
=
allList
.
stream
().
filter
(
child
->
child
.
getParentId
().
equals
(
index
.
getBid
())).
map
(
in
->
{
CarbrandResponse
carbrandResponse1
=
new
CarbrandResponse
();
carbrandResponse1
.
setId
(
in
.
getBid
());
carbrandResponse1
.
setLabel
(
in
.
getBrand
());
return
carbrandResponse1
;
}).
collect
(
Collectors
.
toList
());
carbrandResponse
.
setChildrens
(
childrens
);
return
carbrandResponse
;
}).
collect
(
Collectors
.
toList
());
return
collect
;
}
}
src/main/java/cn/com/glsx/merchants/service/StaffService.java
View file @
646d2c2
...
...
@@ -53,7 +53,9 @@ public class StaffService {
private
MerchantStaffRequest
converRequest
(
StaffSaveRequest
staffSaveRequest
)
{
MerchantStaffRequest
merchantStaffRequest
=
ConvertRequest
.
convertRequest
(
staffSaveRequest
,
new
MerchantStaffRequest
());
FileSaveRequest
merchantFileRequest
=
staffSaveRequest
.
getMerchantFileRequest
();
merchantStaffRequest
.
setMerchantFileRequest
(
ConvertRequest
.
convertRequest
(
merchantFileRequest
,
new
MerchantFileRequest
()));
if
(
merchantFileRequest
!=
null
)
{
merchantStaffRequest
.
setMerchantFileRequest
(
ConvertRequest
.
convertRequest
(
merchantFileRequest
,
new
MerchantFileRequest
()));
}
return
merchantStaffRequest
;
}
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment