Commit 646d2c24 by zhouhb

[+]公共方法添加

1 parent 1d5259eb
...@@ -37,5 +37,16 @@ ...@@ -37,5 +37,16 @@
<artifactId>dozer-spring-boot-starter</artifactId> <artifactId>dozer-spring-boot-starter</artifactId>
<version>6.5.2</version> <version>6.5.2</version>
</dependency> </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> </dependencies>
</project> </project>
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.merchants.config; package cn.com.glsx.merchants.config;
import cn.com.glsx.merchants.remote.*; import cn.com.glsx.merchants.remote.*;
import com.glsx.biz.common.base.service.CarbrandService;
import org.oreframework.boot.autoconfigure.dubbo.reference.ReferenceBuilderFactory; import org.oreframework.boot.autoconfigure.dubbo.reference.ReferenceBuilderFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
...@@ -17,61 +18,67 @@ public class DubboConfig { ...@@ -17,61 +18,67 @@ public class DubboConfig {
@Bean @Bean
public MerchantProductRemote getMerchantProductRemote() { 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 @Bean
public MerchantProductMenuRemote getMerchantProductMenuRemote() { 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 @Bean
public MerchantDictTypeRemote getMerchantDictTypeRemote() { 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 @Bean
public MerchantDictDataRemote getMerchantDictDataRemote() { 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 @Bean
public MerchantProductFunctionRemote getMerchantProductFunctionRemote() { 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 @Bean
public MerchantLogRemote getMerchantLogRemote() { 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 @Bean
public MerchantUserRemote getMerchantUserRemote() { 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 @Bean
public MerchantFileRemote getMerchantFileRemote() { 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 @Bean
public MerchantAccountTypeRemote getMerchantAccountTypeRemote() { 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 @Bean
public MerchantRoleRemote getMerchantRoleRemote() { 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 @Bean
public MerchantRemote getMerchantRemote() { 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 @Bean
public MerchantStaffRemote getMerchantStaffRemote() { 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();
}
} }
...@@ -50,31 +50,33 @@ public class UserAspect { ...@@ -50,31 +50,33 @@ public class UserAspect {
*/ */
public void setUser(JoinPoint joinPoint) throws Exception { public void setUser(JoinPoint joinPoint) throws Exception {
Object[] args = joinPoint.getArgs(); Object[] args = joinPoint.getArgs();
Object object = args[0]; if (args != null && args.length != 0) {
try { Object object = args[0];
if (object instanceof DefaultRequest) { try {
MerchantUser user = getUser((AbstractRopRequest) object); if (object instanceof DefaultRequest) {
Class userCla = (Class) object.getClass(); MerchantUser user = getUser((AbstractRopRequest) object);
Class superclass = userCla.getSuperclass(); Class userCla = (Class) object.getClass();
Field field = superclass.getDeclaredField("createdBy"); Class superclass = userCla.getSuperclass();
Field field1 = superclass.getDeclaredField("createdAccount"); Field field = superclass.getDeclaredField("createdBy");
Field field2 = superclass.getDeclaredField("updatedBy"); Field field1 = superclass.getDeclaredField("createdAccount");
Field field3 = superclass.getDeclaredField("updatedAccount"); Field field2 = superclass.getDeclaredField("updatedBy");
Field field4 = superclass.getDeclaredField("source"); Field field3 = superclass.getDeclaredField("updatedAccount");
field.setAccessible(true); Field field4 = superclass.getDeclaredField("source");
field.set(object, user.getId()); field.setAccessible(true);
field3.setAccessible(true); field.set(object, user.getId());
field3.set(object, user.getUsername()); field3.setAccessible(true);
field1.setAccessible(true); field3.set(object, user.getUsername());
field1.set(object, user.getUsername()); field1.setAccessible(true);
field2.setAccessible(true); field1.set(object, user.getUsername());
field2.set(object, user.getId()); field2.setAccessible(true);
field4.setAccessible(true); field2.set(object, user.getId());
field4.set(object, user.getSource()); 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);
} }
} }
......
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());
}
}
}
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;
}
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;
}
}
...@@ -53,7 +53,9 @@ public class StaffService { ...@@ -53,7 +53,9 @@ public class StaffService {
private MerchantStaffRequest converRequest(StaffSaveRequest staffSaveRequest) { private MerchantStaffRequest converRequest(StaffSaveRequest staffSaveRequest) {
MerchantStaffRequest merchantStaffRequest = ConvertRequest.convertRequest(staffSaveRequest, new MerchantStaffRequest()); MerchantStaffRequest merchantStaffRequest = ConvertRequest.convertRequest(staffSaveRequest, new MerchantStaffRequest());
FileSaveRequest merchantFileRequest = staffSaveRequest.getMerchantFileRequest(); FileSaveRequest merchantFileRequest = staffSaveRequest.getMerchantFileRequest();
merchantStaffRequest.setMerchantFileRequest(ConvertRequest.convertRequest(merchantFileRequest, new MerchantFileRequest())); if(merchantFileRequest!=null) {
merchantStaffRequest.setMerchantFileRequest(ConvertRequest.convertRequest(merchantFileRequest, new MerchantFileRequest()));
}
return merchantStaffRequest; return merchantStaffRequest;
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!