Browse Source

智慧社区的tree修改

dev
zxc 5 years ago
parent
commit
51acdf7b76
  1. 23
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/HttpClientManager.java
  2. 22
      epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/form/TreeByTypeFormDTO.java
  3. 5
      epmet-module/data-report/data-report-server/pom.xml
  4. 2
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/constant/FactConstant.java
  5. 27
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/controller/backdoor/BackDoorController.java
  6. 4
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/controller/screen/AgencyController.java
  7. 13
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/backdoor/BackDoorService.java
  8. 49
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/backdoor/impl/BackDoorServiceImpl.java
  9. 11
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/AgencyService.java
  10. 5
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/AgencyServiceImpl.java
  11. 32
      epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/result/AppIdInfoResultDTO.java
  12. 8
      epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/feign/EpmetCommonServiceOpenFeignClient.java
  13. 6
      epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/feign/fallback/EpmetCommonServiceOpenFeignClientFallback.java
  14. 11
      epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/controller/ExternalAppController.java
  15. 9
      epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/dao/ExternalAppDao.java
  16. 3
      epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/ExternalAppService.java
  17. 13
      epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/ExternalAppServiceImpl.java
  18. 14
      epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/ExternalAppDao.xml

23
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/HttpClientManager.java

@ -159,6 +159,29 @@ public class HttpClientManager {
} }
public Result<String> sendPostByJSONAndHeader(String url, String jsonStrParam,Map<String,String> headerMap) {
try {
HttpPost httppost = new HttpPost(url);
httppost.setConfig(requestConfig);
httppost.addHeader("Content-Type", "application/json; charset=utf-8");
if (null != headerMap){
headerMap.forEach((k,v) -> {
httppost.addHeader(k,v);
});
}
if (StringUtils.isNotEmpty(jsonStrParam)) {
StringEntity se = new StringEntity(jsonStrParam, "utf-8");
httppost.setEntity(se);
}
return execute(httppost, false);
} catch (Exception e) {
log.error("send exception", e);
throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode(), EpmetErrorCode.SERVER_ERROR.getMsg());
}
}
/** /**
* 上传临时素材 * 上传临时素材
* @author zhaoqifeng * @author zhaoqifeng

22
epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/form/TreeByTypeFormDTO.java

@ -0,0 +1,22 @@
package com.epmet.evaluationindex.screen.dto.form;
import com.epmet.commons.tools.validator.group.CustomerClientShowGroup;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
/**
* @Author zxc
* @DateTime 2020/10/22 10:52 上午
*/
@Data
public class TreeByTypeFormDTO implements Serializable {
private static final long serialVersionUID = -1438758394814978472L;
public interface TreeByType extends CustomerClientShowGroup{}
@NotBlank(message = "bizType不能为空",groups = TreeByType.class)
private String bizType;
}

5
epmet-module/data-report/data-report-server/pom.xml

@ -29,6 +29,11 @@
<artifactId>epmet-user-client</artifactId> <artifactId>epmet-user-client</artifactId>
<version>2.0.0</version> <version>2.0.0</version>
</dependency> </dependency>
<dependency>
<groupId>com.epmet</groupId>
<artifactId>common-service-client</artifactId>
<version>2.0.0</version>
</dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId> <artifactId>spring-boot-starter-web</artifactId>

2
epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/constant/FactConstant.java

@ -61,4 +61,6 @@ public interface FactConstant {
* 评价指标类型-百分比 * 评价指标类型-百分比
*/ */
String PERCENT = "percent"; String PERCENT = "percent";
String URL = "https://epmet-dev.elinkservice.cn/api/";
} }

27
epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/controller/backdoor/BackDoorController.java

@ -0,0 +1,27 @@
package com.epmet.datareport.controller.backdoor;
import com.epmet.commons.tools.utils.Result;
import com.epmet.datareport.service.backdoor.BackDoorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @Author zxc
* @DateTime 2020/10/21 5:17 下午
*/
@RestController
@RequestMapping("backdoor")
public class BackDoorController {
@Autowired
private BackDoorService backDoorService;
@PostMapping("backdoor")
public Result backDoor(@RequestHeader("Data-Type")String dataType, @RequestHeader("AppId")String appId, @RequestHeader("target")String target){
return new Result().ok(backDoorService.backDoor(dataType,appId,target));
}
}

4
epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/controller/screen/AgencyController.java

@ -4,6 +4,7 @@ import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.datareport.service.evaluationindex.screen.AgencyService; import com.epmet.datareport.service.evaluationindex.screen.AgencyService;
import com.epmet.evaluationindex.screen.dto.form.CompartmentFormDTO; import com.epmet.evaluationindex.screen.dto.form.CompartmentFormDTO;
import com.epmet.evaluationindex.screen.dto.form.TreeByTypeFormDTO;
import com.epmet.evaluationindex.screen.dto.result.CompartmentResultDTO; import com.epmet.evaluationindex.screen.dto.result.CompartmentResultDTO;
import com.epmet.evaluationindex.screen.dto.result.TreeResultDTO; import com.epmet.evaluationindex.screen.dto.result.TreeResultDTO;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -41,7 +42,8 @@ public class AgencyController {
* @date 2020/10/21 2:49 下午 * @date 2020/10/21 2:49 下午
*/ */
@PostMapping("treebytype") @PostMapping("treebytype")
public Result<TreeResultDTO> treeByType(@RequestHeader("CustomerId") String customerId,@RequestParam("bizType")String bizType){ public Result<TreeResultDTO> treeByType(@RequestHeader("CustomerId") String customerId,@RequestBody TreeByTypeFormDTO bizType){
ValidatorUtils.validateEntity(bizType, TreeByTypeFormDTO.TreeByType.class);
return new Result<TreeResultDTO>().ok(agencyService.treeByType(customerId,bizType)); return new Result<TreeResultDTO>().ok(agencyService.treeByType(customerId,bizType));
} }

13
epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/backdoor/BackDoorService.java

@ -0,0 +1,13 @@
package com.epmet.datareport.service.backdoor;
import com.epmet.commons.tools.utils.Result;
/**
* @Author zxc
* @DateTime 2020/10/21 5:17 下午
*/
public interface BackDoorService {
Object backDoor(String dataType, String appId, String target);
}

49
epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/backdoor/impl/BackDoorServiceImpl.java

@ -0,0 +1,49 @@
package com.epmet.datareport.service.backdoor.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.utils.HttpClientManager;
import com.epmet.commons.tools.utils.Result;
import com.epmet.datareport.constant.*;
import com.epmet.datareport.service.backdoor.BackDoorService;
import com.epmet.dto.result.AppIdInfoResultDTO;
import com.epmet.feign.EpmetCommonServiceOpenFeignClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.Map;
/**
* @Author zxc
* @DateTime 2020/10/21 5:17 下午
*/
@Service
public class BackDoorServiceImpl implements BackDoorService {
@Autowired
private EpmetCommonServiceOpenFeignClient commonServiceOpenFeignClient;
@Override
public Object backDoor(String dataType, String appId, String target) {
Result<AppIdInfoResultDTO> appIdInfoResultDTOResult = commonServiceOpenFeignClient.appIdInfo(appId);
if (!appIdInfoResultDTOResult.success()){
throw new RenException("获取accessToken失败......");
}
AppIdInfoResultDTO data = appIdInfoResultDTOResult.getData();
String url = FactConstant.URL.concat(target);
Map map = new HashMap(16);
Map<String,String> headerMap = new HashMap<>(16);
headerMap.put("AccessToken",data.getAccessToken());
headerMap.put("AppId",data.getAppId());
headerMap.put("AuthType","jwt");
headerMap.put("Data-Type",dataType);
// headerMap.put("Authorization","eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJhcHAiOiJnb3YiLCJjbGllbnQiOiJ3eG1wIiwiZXhwIjoxNjAzODY2MjY2LCJ1c2VySWQiOiI0ZWYwYTA4YTBiNWVmOTM0ZjBiOGE4YzQ2ODJjMzY2NSIsImlhdCI6MTYwMzI2MTQ2Nn0.pW1Wzss-xtj6vUuJbvglUltdDWlUKqTyVQ6rGQ7WpSaE_Iz1uAd5XWI5OGLajyU4-aYCW14Dw3C-XoFepyiZJQ");
map.put("bizType","community");
Result<String> stringResult = HttpClientManager.getInstance().sendPostByJSONAndHeader(url, JSON.toJSONString(map),headerMap);
JSONObject jsonObject = JSON.parseObject(stringResult.getData());
System.out.println(jsonObject);
return jsonObject;
}
}

11
epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/AgencyService.java

@ -1,6 +1,7 @@
package com.epmet.datareport.service.evaluationindex.screen; package com.epmet.datareport.service.evaluationindex.screen;
import com.epmet.evaluationindex.screen.dto.form.CompartmentFormDTO; import com.epmet.evaluationindex.screen.dto.form.CompartmentFormDTO;
import com.epmet.evaluationindex.screen.dto.form.TreeByTypeFormDTO;
import com.epmet.evaluationindex.screen.dto.result.CompartmentResultDTO; import com.epmet.evaluationindex.screen.dto.result.CompartmentResultDTO;
import com.epmet.evaluationindex.screen.dto.result.TreeResultDTO; import com.epmet.evaluationindex.screen.dto.result.TreeResultDTO;
@ -20,14 +21,8 @@ public interface AgencyService {
*/ */
TreeResultDTO tree(String customerId); TreeResultDTO tree(String customerId);
/**
* @Description 智慧社区的tree TreeResultDTO treeByType(String customerId, TreeByTypeFormDTO bizType);
* @Param customerId
* @Param bizType
* @author zxc
* @date 2020/10/21 2:49 下午
*/
TreeResultDTO treeByType(String customerId,String bizType);
/** /**
* @Description 2组织区域查询 * @Description 2组织区域查询

5
epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/AgencyServiceImpl.java

@ -9,6 +9,7 @@ import com.epmet.datareport.dao.evaluationindex.screen.ScreenCustomerGridDao;
import com.epmet.datareport.service.evaluationindex.screen.AgencyService; import com.epmet.datareport.service.evaluationindex.screen.AgencyService;
import com.epmet.evaluationindex.screen.constant.ScreenConstant; import com.epmet.evaluationindex.screen.constant.ScreenConstant;
import com.epmet.evaluationindex.screen.dto.form.CompartmentFormDTO; import com.epmet.evaluationindex.screen.dto.form.CompartmentFormDTO;
import com.epmet.evaluationindex.screen.dto.form.TreeByTypeFormDTO;
import com.epmet.evaluationindex.screen.dto.result.AgencyDistributionResultDTO; import com.epmet.evaluationindex.screen.dto.result.AgencyDistributionResultDTO;
import com.epmet.evaluationindex.screen.dto.result.CompartmentResultDTO; import com.epmet.evaluationindex.screen.dto.result.CompartmentResultDTO;
import com.epmet.evaluationindex.screen.dto.result.TreeResultDTO; import com.epmet.evaluationindex.screen.dto.result.TreeResultDTO;
@ -75,10 +76,10 @@ public class AgencyServiceImpl implements AgencyService {
*/ */
@DataSource(value = DataSourceConstant.EVALUATION_INDEX, datasourceNameFromArg = true) @DataSource(value = DataSourceConstant.EVALUATION_INDEX, datasourceNameFromArg = true)
@Override @Override
public TreeResultDTO treeByType(String customerId, String bizType) { public TreeResultDTO treeByType(String customerId, TreeByTypeFormDTO bizType) {
TreeResultDTO rootAgency = null; TreeResultDTO rootAgency = null;
try { try {
rootAgency = screenCustomerAgencyDao.selectRootAgencyIdByBizType(customerId,bizType); rootAgency = screenCustomerAgencyDao.selectRootAgencyIdByBizType(customerId,bizType.getBizType());
if (null == rootAgency) { if (null == rootAgency) {
return new TreeResultDTO(); return new TreeResultDTO();
} }

32
epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/result/AppIdInfoResultDTO.java

@ -0,0 +1,32 @@
package com.epmet.dto.result;
import lombok.Data;
import java.io.Serializable;
/**
* @Author zxc
* @DateTime 2020/10/21 5:30 下午
*/
@Data
public class AppIdInfoResultDTO implements Serializable {
private static final long serialVersionUID = 4556971930323763712L;
/**
* 应用ID
*/
private String appId;
/**
* 客户ID
*/
private String customerId;
/**
* 密钥
*/
private String secret;
private String accessToken;
}

8
epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/feign/EpmetCommonServiceOpenFeignClient.java

@ -5,6 +5,7 @@ import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.form.ExternalAppAuthFormDTO; import com.epmet.dto.form.ExternalAppAuthFormDTO;
import com.epmet.dto.form.GetJwtAccessTokenFormDTO; import com.epmet.dto.form.GetJwtAccessTokenFormDTO;
import com.epmet.dto.form.WorkDayFormDTO; import com.epmet.dto.form.WorkDayFormDTO;
import com.epmet.dto.result.AppIdInfoResultDTO;
import com.epmet.dto.result.ExternalAppAuthResultDTO; import com.epmet.dto.result.ExternalAppAuthResultDTO;
import com.epmet.dto.result.WorkDayResultDTO; import com.epmet.dto.result.WorkDayResultDTO;
import com.epmet.feign.fallback.EpmetCommonServiceOpenFeignClientFallback; import com.epmet.feign.fallback.EpmetCommonServiceOpenFeignClientFallback;
@ -20,8 +21,8 @@ import java.util.List;
* @author yinzuomei@elink-cn.com * @author yinzuomei@elink-cn.com
* @date 2020/6/4 10:28 * @date 2020/6/4 10:28
*/ */
@FeignClient(name = ServiceConstant.EPMET_COMMON_SERVICE, fallback = EpmetCommonServiceOpenFeignClientFallback.class) //@FeignClient(name = ServiceConstant.EPMET_COMMON_SERVICE, fallback = EpmetCommonServiceOpenFeignClientFallback.class)
//@FeignClient(name = ServiceConstant.EPMET_COMMON_SERVICE, fallback = EpmetCommonServiceOpenFeignClientFallback.class, url = "http://localhost:8103") @FeignClient(name = ServiceConstant.EPMET_COMMON_SERVICE, fallback = EpmetCommonServiceOpenFeignClientFallback.class, url = "localhost:8103")
public interface EpmetCommonServiceOpenFeignClient { public interface EpmetCommonServiceOpenFeignClient {
/** /**
* @param formDTO * @param formDTO
@ -63,4 +64,7 @@ public interface EpmetCommonServiceOpenFeignClient {
*/ */
@PostMapping("/commonservice/externalapp/get-jwt-accesstoken") @PostMapping("/commonservice/externalapp/get-jwt-accesstoken")
Result getAccessToken(@RequestBody GetJwtAccessTokenFormDTO form); Result getAccessToken(@RequestBody GetJwtAccessTokenFormDTO form);
@PostMapping("/commonservice/externalapp/appidinfo")
Result<AppIdInfoResultDTO> appIdInfo(@RequestBody String appId);
} }

6
epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/feign/fallback/EpmetCommonServiceOpenFeignClientFallback.java

@ -5,6 +5,7 @@ import com.epmet.commons.tools.utils.ModuleUtils;
import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.form.ExternalAppAuthFormDTO; import com.epmet.dto.form.ExternalAppAuthFormDTO;
import com.epmet.dto.form.WorkDayFormDTO; import com.epmet.dto.form.WorkDayFormDTO;
import com.epmet.dto.result.AppIdInfoResultDTO;
import com.epmet.dto.result.ExternalAppAuthResultDTO; import com.epmet.dto.result.ExternalAppAuthResultDTO;
import com.epmet.dto.result.WorkDayResultDTO; import com.epmet.dto.result.WorkDayResultDTO;
import com.epmet.feign.EpmetCommonServiceOpenFeignClient; import com.epmet.feign.EpmetCommonServiceOpenFeignClient;
@ -39,4 +40,9 @@ public class EpmetCommonServiceOpenFeignClientFallback implements EpmetCommonSer
public Result getSecret(String appId) { public Result getSecret(String appId) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_COMMON_SERVICE, "getSecret", appId); return ModuleUtils.feignConError(ServiceConstant.EPMET_COMMON_SERVICE, "getSecret", appId);
} }
@Override
public Result<AppIdInfoResultDTO> appIdInfo(String appId) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_COMMON_SERVICE, "appIdInfo", appId);
}
} }

11
epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/controller/ExternalAppController.java

@ -9,6 +9,7 @@ import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.dto.form.ExternalAppAuthFormDTO; import com.epmet.dto.form.ExternalAppAuthFormDTO;
import com.epmet.dto.form.ExternalAppFormDTO; import com.epmet.dto.form.ExternalAppFormDTO;
import com.epmet.dto.form.GetJwtAccessTokenFormDTO; import com.epmet.dto.form.GetJwtAccessTokenFormDTO;
import com.epmet.dto.result.AppIdInfoResultDTO;
import com.epmet.dto.result.ExternalAppAuthResultDTO; import com.epmet.dto.result.ExternalAppAuthResultDTO;
import com.epmet.dto.result.ExternalAppResultDTO; import com.epmet.dto.result.ExternalAppResultDTO;
import com.epmet.dto.result.GetJwtAccessTokenResultDTO; import com.epmet.dto.result.GetJwtAccessTokenResultDTO;
@ -19,10 +20,7 @@ import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List; import java.util.List;
@ -162,4 +160,9 @@ public class ExternalAppController {
return new Result().ok(jwtAccessToken); return new Result().ok(jwtAccessToken);
} }
@PostMapping("appidinfo")
public Result<AppIdInfoResultDTO> appIdInfo(@RequestBody String appId){
return new Result<AppIdInfoResultDTO>().ok(externalAppService.appIdInfo(appId));
}
} }

9
epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/dao/ExternalAppDao.java

@ -18,6 +18,7 @@
package com.epmet.dao; package com.epmet.dao;
import com.epmet.commons.mybatis.dao.BaseDao; import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.result.AppIdInfoResultDTO;
import com.epmet.dto.result.ExternalAppResultDTO; import com.epmet.dto.result.ExternalAppResultDTO;
import com.epmet.entity.ExternalAppEntity; import com.epmet.entity.ExternalAppEntity;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
@ -41,4 +42,12 @@ public interface ExternalAppDao extends BaseDao<ExternalAppEntity> {
List<ExternalAppResultDTO> list(@Param("customerId") String customerId); List<ExternalAppResultDTO> list(@Param("customerId") String customerId);
List<String> getCustomerIds(); List<String> getCustomerIds();
/**
* @Description 根据appId查询客户ID和密钥
* @Param appId
* @author zxc
* @date 2020/10/21 5:50 下午
*/
AppIdInfoResultDTO appIdInfo(@Param("appId")String appId);
} }

3
epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/ExternalAppService.java

@ -18,6 +18,7 @@
package com.epmet.service; package com.epmet.service;
import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.page.PageData;
import com.epmet.dto.result.AppIdInfoResultDTO;
import com.epmet.dto.result.ExternalAppResultDTO; import com.epmet.dto.result.ExternalAppResultDTO;
import com.epmet.dto.result.GetJwtAccessTokenResultDTO; import com.epmet.dto.result.GetJwtAccessTokenResultDTO;
@ -41,4 +42,6 @@ public interface ExternalAppService {
String resetSecret(String appId); String resetSecret(String appId);
GetJwtAccessTokenResultDTO getJwtAccessToken(String appId); GetJwtAccessTokenResultDTO getJwtAccessToken(String appId);
AppIdInfoResultDTO appIdInfo(String appId);
} }

13
epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/ExternalAppServiceImpl.java

@ -27,6 +27,7 @@ import com.epmet.dao.ExternalAppDao;
import com.epmet.dao.ExternalAppSecretDao; import com.epmet.dao.ExternalAppSecretDao;
import com.epmet.dao.ExternalCustomerDao; import com.epmet.dao.ExternalCustomerDao;
import com.epmet.dto.CustomerDTO; import com.epmet.dto.CustomerDTO;
import com.epmet.dto.result.AppIdInfoResultDTO;
import com.epmet.dto.result.ExternalAppResultDTO; import com.epmet.dto.result.ExternalAppResultDTO;
import com.epmet.dto.result.GetJwtAccessTokenResultDTO; import com.epmet.dto.result.GetJwtAccessTokenResultDTO;
import com.epmet.entity.ExternalAppEntity; import com.epmet.entity.ExternalAppEntity;
@ -43,6 +44,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
@ -212,4 +214,15 @@ public class ExternalAppServiceImpl implements ExternalAppService {
String token = tokenUtils.genToken(secret, appId, customerId, ts); String token = tokenUtils.genToken(secret, appId, customerId, ts);
return new GetJwtAccessTokenResultDTO(customerId, token, ts); return new GetJwtAccessTokenResultDTO(customerId, token, ts);
} }
@Override
public AppIdInfoResultDTO appIdInfo(String appId) {
AppIdInfoResultDTO appIdInfoResultDTO = externalAppDao.appIdInfo(appId);
if (null == appIdInfoResultDTO){
throw new RenException("没查到对应appId【"+appId+"】的信息");
}
String accessToken = tokenUtils.genToken(appIdInfoResultDTO.getSecret(), appId, appIdInfoResultDTO.getCustomerId(), System.currentTimeMillis());
appIdInfoResultDTO.setAccessToken(accessToken);
return appIdInfoResultDTO;
}
} }

14
epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/ExternalAppDao.xml

@ -66,5 +66,19 @@
SELECT CUSTOMER_ID FROM external_app WHERE DEL_FLAG = 0 SELECT CUSTOMER_ID FROM external_app WHERE DEL_FLAG = 0
</select> </select>
<!-- 根据appId查询客户ID和密钥 -->
<select id="appIdInfo" resultType="com.epmet.dto.result.AppIdInfoResultDTO">
SELECT
ea.ID AS appId,
ea.CUSTOMER_ID,
eas.SECRET
FROM external_app ea
LEFT JOIN external_app_secret eas ON eas.APP_ID = ea.id
WHERE
ea.DEL_FLAG = 0
AND eas.DEL_FLAG = 0
AND ea.ID = #{appId}
</select>
</mapper> </mapper>
Loading…
Cancel
Save