Browse Source

陌生人导览接口添加token参数 走注册中心测试成功

dev
sunyuchao 6 years ago
parent
commit
d443a0ebd8
  1. 3
      epmet-gateway/src/main/resources/bootstrap.yml
  2. 21
      epmet-module/epmet-demo/epmet-demo-server/src/main/java/com/epmet/feign/GovOrgFeignClient.java
  3. 25
      epmet-module/epmet-demo/epmet-demo-server/src/main/java/com/epmet/feign/impl/GovOrgFeignClientFallBack.java
  4. 1
      epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/controller/HomeController.java
  5. 33
      epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/HomeServiceImpl.java
  6. 6
      epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/controller/StrangerResiGuideController.java
  7. 3
      epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/service/StrangerAccessRecordService.java
  8. 14
      epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/service/impl/StrangerAccessRecordServiceImpl.java
  9. 5
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/GridVisitedServiceImpl.java

3
epmet-gateway/src/main/resources/bootstrap.yml

@ -127,6 +127,7 @@ spring:
- Path=${server.servlet.context-path}/resi/guide/**
filters:
- StripPrefix=1
- CpAuth=true
#政府端组织管理
- id: gov-org-server
uri: @gateway.routes.gov-org-server.uri@
@ -179,6 +180,7 @@ renren:
- /epmetuser/**
- /gov/org/**
- /oper/access/**
- /resi/guide/**
management:
endpoints:
web:
@ -239,6 +241,7 @@ epmet:
- /epmetuser/**
- /gov/org/**
- /oper/access/**
- /resi/guide/**
swaggerUrls:
jwt:

21
epmet-module/epmet-demo/epmet-demo-server/src/main/java/com/epmet/feign/GovOrgFeignClient.java

@ -18,25 +18,4 @@ public interface GovOrgFeignClient {
@GetMapping("gov/org/customergrid/getcustomergrid/{id}")
Result<CustomerGridDTO> getcustomergrid(@PathVariable("id") String id);
import com.epmet.commons.tools.constant.ServiceConstant;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.CustomerGridDTO;
import com.epmet.feign.impl.GovOrgFeignClientFallBack;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
/**
* Created by 11 on 2020/3/18.
*/
@FeignClient(name = ServiceConstant.GOV_ORG_SERVER, fallback = GovOrgFeignClientFallBack.class, url="http://localhost:8092")
public interface GovOrgFeignClient {
@GetMapping("gov/org/customergrid/page")
Result<PageData<CustomerGridDTO>> page();
}

25
epmet-module/epmet-demo/epmet-demo-server/src/main/java/com/epmet/feign/impl/GovOrgFeignClientFallBack.java

@ -1,25 +0,0 @@
package com.epmet.feign.impl;/**
* Created by 11 on 2020/3/18.
*/
import com.epmet.commons.tools.constant.ServiceConstant;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.utils.ModuleUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.CustomerGridDTO;
import com.epmet.feign.GovOrgFeignClient;
import org.springframework.stereotype.Component;
/**
* @Description
* @ClassName GovOrgFeignClientFallBack
* @Author wangc
* @date 2020.03.18 14:52
*/
@Component
public class GovOrgFeignClientFallBack implements GovOrgFeignClient{
@Override
public Result<PageData<CustomerGridDTO>> page() {
return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "page");
}
}

1
epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/controller/HomeController.java

@ -92,7 +92,6 @@ public class HomeController {
@PostMapping("gethomereleasebycustomer")
public Result<HomeDesignByCustomerResultDTO> getHomeReleaseByCustomer(@RequestBody CustomerHomeFormDTO formDTO) {
formDTO.setStatus(OperCustomizeConstant.STATUS);//已发布数据
formDTO.setClientType("0");//居民端(token中获取)
ValidatorUtils.validateEntity(formDTO);
return homeService.getHomeReleaseByCustomer(formDTO);
}

33
epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/HomeServiceImpl.java

@ -116,24 +116,31 @@ public class HomeServiceImpl implements HomeService {
@Override
public Result<HomeDesignByCustomerResultDTO> getHomeReleaseByCustomer(CustomerHomeFormDTO formDTO) {
HomeDesignByCustomerResultDTO resultDTO = new HomeDesignByCustomerResultDTO();
//根据客户id,所属端获取客户首页配置的设计稿
List<CommonComponentDesignResultDTO> list = customerHomeDetailDao.getHomeReleaseByCustomer(formDTO);
List<CommonComponentDesignResultDTO> flist = new ArrayList<CommonComponentDesignResultDTO>();//功能组件
List<String> usedComponent=new ArrayList<>();//使用的组件集合
List<CommonComponentDesignResultDTO> titlelist=new ArrayList<CommonComponentDesignResultDTO>();
List<CommonComponentDesignResultDTO> toplist=new ArrayList<CommonComponentDesignResultDTO>();
List<CommonComponentDesignResultDTO> functionlist=new ArrayList<CommonComponentDesignResultDTO>();
List<CommonComponentDesignResultDTO> floatlist=new ArrayList<CommonComponentDesignResultDTO>();
//List<String> usedComponent=new ArrayList<>();//使用过的组件集合
for(CommonComponentDesignResultDTO c:list){
usedComponent.add(c.getComponentId());
//usedComponent.add(c.getComponentId());
//所属区域:0.标题区、1.置顶区、2.功能区、3.悬浮区
if("titleList".equals(c.getRegion())){
resultDTO.setTitleList(c);
}else if("topList".equals(c.getRegion())){
resultDTO.setTopList(c);
}else if("functionList".equals(c.getRegion())){
flist.add(c);
}else if("floatingList".equals(c.getRegion())){
resultDTO.setFloatingList(c);
if(ReginConstant.titleList.equals(c.getRegion())){
titlelist.add(c);
}else if(ReginConstant.topList.equals(c.getRegion())){
toplist.add(c);
}else if(ReginConstant.functionList.equals(c.getRegion())){
functionlist.add(c);
}else if(ReginConstant.floatingList.equals(c.getRegion())){
floatlist.add(c);
}
}
resultDTO.setFunctionList(flist);
resultDTO.setUsedComponentIdList(usedComponent);
resultDTO.setTitleList(titlelist);
resultDTO.setTopList(toplist);
resultDTO.setFloatingList(floatlist);
resultDTO.setFunctionList(functionlist);
//resultDTO.setUsedComponentIdList(usedComponent);
return new Result<HomeDesignByCustomerResultDTO>().ok(resultDTO);
}
}

6
epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/controller/StrangerResiGuideController.java

@ -17,6 +17,8 @@
package com.epmet.controller;
import com.epmet.commons.tools.annotation.LoginUser;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.dto.form.CustomerGridListFormDTO;
@ -52,8 +54,8 @@ public class StrangerResiGuideController {
* @Date 2020/3/16
**/
@PostMapping("getgridhome")
public Result<HomeDesignByCustomerResultDTO> getValidCustomerList(@RequestBody StrangerFormDTO formDTO) throws Exception {
return strangerAccessRecordService.getgridhome(formDTO);
public Result<HomeDesignByCustomerResultDTO> getValidCustomerList( @LoginUser TokenDto tokenDTO, @RequestBody StrangerFormDTO formDTO) throws Exception {
return strangerAccessRecordService.getgridhome(tokenDTO, formDTO);
}

3
epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/service/StrangerAccessRecordService.java

@ -2,6 +2,7 @@ package com.epmet.service;
import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.StrangerAccessRecordDTO;
import com.epmet.dto.form.CustomerGridListFormDTO;
@ -105,5 +106,5 @@ public interface StrangerAccessRecordService extends BaseService<StrangerAccessR
* @return void
* @author sun
*/
Result<HomeDesignByCustomerResultDTO> getgridhome(StrangerFormDTO formDTO);
Result<HomeDesignByCustomerResultDTO> getgridhome(TokenDto tokenDTO, StrangerFormDTO formDTO);
}

14
epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/service/impl/StrangerAccessRecordServiceImpl.java

@ -3,6 +3,7 @@ package com.epmet.service.impl;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dao.StrangerAccessRecordDao;
@ -175,31 +176,32 @@ public class StrangerAccessRecordServiceImpl extends BaseServiceImpl<StrangerAcc
* @author sun
*/
@Override
public Result<HomeDesignByCustomerResultDTO> getgridhome(StrangerFormDTO formDTO) {
public Result<HomeDesignByCustomerResultDTO> getgridhome(TokenDto tokenDTO, StrangerFormDTO formDTO) {
//token里边有所属端 userId这些参数 前台传递customerID和gridId
//1:调用epmet-user服务查询数据 新建网格记录数据
VisitedFormDTO vi = new VisitedFormDTO();
vi.setGridId(formDTO.getGridId());
vi.setCustomerId(formDTO.getCustomerId());
//vi.setUserId(token获取);
vi.setUserId(tokenDTO.getUserId());//token中获取userId
epmetUserFeignClient.saveLatestAndVisited(vi);
//2:调用ope-customize服务 获取首页发布数据
Result<HomeDesignByCustomerResultDTO> res = getCustomerHomeData(formDTO.getCustomerId());
Result<HomeDesignByCustomerResultDTO> res = getCustomerHomeData(formDTO.getCustomerId(),tokenDTO.getClient());
return res;
}
/**
* 调用oper-customize服务 获取首页发布数据
* @param customerId
* @param customerId 客户Id
* @param clientType 所属端
* @return
* @author sun
*/
public Result<HomeDesignByCustomerResultDTO> getCustomerHomeData(String customerId){
public Result<HomeDesignByCustomerResultDTO> getCustomerHomeData(String customerId,String clientType){
CustomerHomeFormDTO dto = new CustomerHomeFormDTO();
dto.setCustomerId(customerId);
//dto.setClientType(token中获取);//居民端
dto.setClientType(clientType);//居民端
return operCustomizeFeignClient.getHomeReleaseByCustomer(dto);
}

5
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/GridVisitedServiceImpl.java

@ -143,11 +143,10 @@ public class GridVisitedServiceImpl extends BaseServiceImpl<GridVisitedDao, Grid
public void saveGridVisited(VisitedFormDTO formDTO,CustomerGridDTO cu) {
Date date = new Date();
GridVisitedDTO vi = new GridVisitedDTO();
vi.setIsRegister(getRegister("0"));//token中获取是否注册
vi.setIsRegister(getRegister("0"));//后续再其他服务中获取这个状态值
vi.setCustomerId(cu.getCustomerId());
vi.setGridId(cu.getId());
// vi.setCustomerUserId(formDTO.getUserId());//token传递的值
vi.setCustomerUserId("1111111111");//token传递的值
vi.setCustomerUserId(formDTO.getUserId());
vi.setVisitTime(date);
vi.setUpdatedTime(date);
//查询是否存在历史数据( 一个用户一天对一个网格只存在一条访问记录)

Loading…
Cancel
Save