From 9f7e267b461c46b798c525139088ba82c7d69e53 Mon Sep 17 00:00:00 2001 From: wxz Date: Wed, 19 Aug 2020 15:08:38 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=96=E9=83=A8=E5=BA=94=E7=94=A8=E8=AE=A4?= =?UTF-8?q?=E8=AF=81=E4=BF=AE=E6=94=B9=E8=AF=B7=E6=B1=82=E5=A4=B4=E7=9A=84?= =?UTF-8?q?key=E4=B8=BA=E9=A9=BC=E5=B3=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../aspect/ExternalAppRequestAuthAspect.java | 2 +- .../dto/form/ExternalCustomerFormDTO.java | 15 ++++++ .../dto/result/ExternalCustomerResultDTO.java | 46 ++++++++++++++++++ .../controller/ExternalAppController.java | 5 ++ .../ExternalCustomerController.java | 47 +++++++++++++++++++ .../com/epmet/dao/ExternalCustomerDao.java | 41 ++++++++++++++++ .../epmet/entity/ExternalCustomerEntity.java | 46 ++++++++++++++++++ .../service/ExternalCustomerService.java | 11 +++++ .../impl/ExternalCustomerServiceImpl.java | 26 ++++++++++ .../externalapp/ExtAppJwtTokenUtils.java | 2 +- .../resources/mapper/ExternalCustomerDao.xml | 29 ++++++++++++ 11 files changed, 268 insertions(+), 2 deletions(-) create mode 100644 epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/form/ExternalCustomerFormDTO.java create mode 100644 epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/result/ExternalCustomerResultDTO.java create mode 100644 epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/controller/ExternalCustomerController.java create mode 100644 epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/dao/ExternalCustomerDao.java create mode 100644 epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/entity/ExternalCustomerEntity.java create mode 100644 epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/ExternalCustomerService.java create mode 100644 epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/ExternalCustomerServiceImpl.java create mode 100644 epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/ExternalCustomerDao.xml diff --git a/epmet-commons/epmet-commons-extapp-auth/src/main/java/com/epmet/commons/extappauth/aspect/ExternalAppRequestAuthAspect.java b/epmet-commons/epmet-commons-extapp-auth/src/main/java/com/epmet/commons/extappauth/aspect/ExternalAppRequestAuthAspect.java index db9dc79da3..e64f678937 100644 --- a/epmet-commons/epmet-commons-extapp-auth/src/main/java/com/epmet/commons/extappauth/aspect/ExternalAppRequestAuthAspect.java +++ b/epmet-commons/epmet-commons-extapp-auth/src/main/java/com/epmet/commons/extappauth/aspect/ExternalAppRequestAuthAspect.java @@ -35,7 +35,7 @@ public class ExternalAppRequestAuthAspect { private static Logger logger = LoggerFactory.getLogger(ExternalAppRequestAuthAspect.class); - public static final String ACCESS_TOKEN_HEADER_KEY = "access_token"; + public static final String ACCESS_TOKEN_HEADER_KEY = "AccessToken"; public static final String APP_ID_HEADER_KEY = "appId"; @Autowired diff --git a/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/form/ExternalCustomerFormDTO.java b/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/form/ExternalCustomerFormDTO.java new file mode 100644 index 0000000000..da8c394aea --- /dev/null +++ b/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/form/ExternalCustomerFormDTO.java @@ -0,0 +1,15 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.Min; + +@Data +public class ExternalCustomerFormDTO { + + @Min(0) + private Integer pageNo; + + @Min(0) + private Integer pageSize; +} diff --git a/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/result/ExternalCustomerResultDTO.java b/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/result/ExternalCustomerResultDTO.java new file mode 100644 index 0000000000..79e58686fe --- /dev/null +++ b/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/result/ExternalCustomerResultDTO.java @@ -0,0 +1,46 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dto.result; + +import java.io.Serializable; +import java.util.Date; +import lombok.Data; + + +/** + * + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-08-19 + */ +@Data +public class ExternalCustomerResultDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 客户ID + */ + private String id; + + /** + * 客户名称 + */ + private String customerName; + +} \ No newline at end of file diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/controller/ExternalAppController.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/controller/ExternalAppController.java index 98fa8e9fc9..1e627e5de8 100644 --- a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/controller/ExternalAppController.java +++ b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/controller/ExternalAppController.java @@ -23,6 +23,11 @@ public class ExternalAppController { @Autowired private ExternalAppAuthService externalAppAuthService; + /** + * 外部请求认证 + * @param formDTO + * @return + */ @PostMapping("/auth") public Result auth(@RequestBody ExternalAppAuthFormDTO formDTO) { String appId = formDTO.getAppId(); diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/controller/ExternalCustomerController.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/controller/ExternalCustomerController.java new file mode 100644 index 0000000000..e5ae0ae464 --- /dev/null +++ b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/controller/ExternalCustomerController.java @@ -0,0 +1,47 @@ +package com.epmet.controller; + +import com.epmet.commons.tools.exception.RenException; +import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.dto.form.ExternalAppAuthFormDTO; +import com.epmet.dto.form.ExternalCustomerFormDTO; +import com.epmet.dto.result.ExternalAppAuthResultDTO; +import com.epmet.service.ExternalAppAuthService; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.validation.constraints.Min; + +/** + * 外部客户管理 + */ +@RestController +@RequestMapping("/externalcustomer") +public class ExternalCustomerController { + + private static Logger logger = LoggerFactory.getLogger(ExternalCustomerController.class); + + @Autowired + private ExternalAppAuthService externalAppAuthService; + + /** + * 外部客户管理 + * @return + */ + @PostMapping("/list") + public Result list(@RequestBody ExternalCustomerFormDTO form) { + ValidatorUtils.validateEntity(form); + Integer pageNo = form.getPageNo(); + Integer pageSize = form.getPageSize(); + + + return null; + } + +} diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/dao/ExternalCustomerDao.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/dao/ExternalCustomerDao.java new file mode 100644 index 0000000000..b22be4caf9 --- /dev/null +++ b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/dao/ExternalCustomerDao.java @@ -0,0 +1,41 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.result.ExternalCustomerResultDTO; +import com.epmet.entity.ExternalCustomerEntity; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +/** + * + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-08-19 + */ +@Mapper +public interface ExternalCustomerDao extends BaseDao { + + /** + * 列出客户基本信息 + * @return + */ + List listBaseInfo(); +} \ No newline at end of file diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/entity/ExternalCustomerEntity.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/entity/ExternalCustomerEntity.java new file mode 100644 index 0000000000..fccfbbb6a1 --- /dev/null +++ b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/entity/ExternalCustomerEntity.java @@ -0,0 +1,46 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.entity; + +import com.baomidou.mybatisplus.annotation.TableName; + +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Date; + +/** + * + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-08-19 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("external_customer") +public class ExternalCustomerEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 客户名称 + */ + private String customerName; + +} diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/ExternalCustomerService.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/ExternalCustomerService.java new file mode 100644 index 0000000000..bcc8d10cc6 --- /dev/null +++ b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/ExternalCustomerService.java @@ -0,0 +1,11 @@ +package com.epmet.service; + +import com.epmet.dto.result.ExternalCustomerResultDTO; + +import java.util.List; + +public interface ExternalCustomerService { + + public List list(Integer pageNo, Integer pageSize); + +} diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/ExternalCustomerServiceImpl.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/ExternalCustomerServiceImpl.java new file mode 100644 index 0000000000..9925841b0f --- /dev/null +++ b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/ExternalCustomerServiceImpl.java @@ -0,0 +1,26 @@ +package com.epmet.service.impl; + +import com.epmet.dao.ExternalCustomerDao; +import com.epmet.dto.result.ExternalCustomerResultDTO; +import com.epmet.service.ExternalCustomerService; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +@Service +public class ExternalCustomerServiceImpl implements ExternalCustomerService { + + @Autowired + private ExternalCustomerDao externalCustomerDao; + + @Override + public List list(Integer pageNo, Integer pageSize) { + PageHelper.startPage(pageNo, pageSize); + List customers = externalCustomerDao.listBaseInfo(); + PageInfo pageInfo = new PageInfo<>(customers); + return null; + } +} diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/utils/externalapp/ExtAppJwtTokenUtils.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/utils/externalapp/ExtAppJwtTokenUtils.java index 7355f867cd..1c3a326c75 100644 --- a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/utils/externalapp/ExtAppJwtTokenUtils.java +++ b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/utils/externalapp/ExtAppJwtTokenUtils.java @@ -75,7 +75,7 @@ public class ExtAppJwtTokenUtils { public static void genToken() { HashMap claim = new HashMap<>(); - claim.put("appId", "1"); + claim.put("appId", "227fb75ae4baa820755aaf43bf7f0a69"); claim.put("customerId", "c1"); claim.put("ts", System.currentTimeMillis() - 1000 * 60 * 4); diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/ExternalCustomerDao.xml b/epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/ExternalCustomerDao.xml new file mode 100644 index 0000000000..9d59a01224 --- /dev/null +++ b/epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/ExternalCustomerDao.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file