Browse Source

外部应用认证修改请求头的key为驼峰

master
wxz 5 years ago
parent
commit
9f7e267b46
  1. 2
      epmet-commons/epmet-commons-extapp-auth/src/main/java/com/epmet/commons/extappauth/aspect/ExternalAppRequestAuthAspect.java
  2. 15
      epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/form/ExternalCustomerFormDTO.java
  3. 46
      epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/result/ExternalCustomerResultDTO.java
  4. 5
      epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/controller/ExternalAppController.java
  5. 47
      epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/controller/ExternalCustomerController.java
  6. 41
      epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/dao/ExternalCustomerDao.java
  7. 46
      epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/entity/ExternalCustomerEntity.java
  8. 11
      epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/ExternalCustomerService.java
  9. 26
      epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/ExternalCustomerServiceImpl.java
  10. 2
      epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/utils/externalapp/ExtAppJwtTokenUtils.java
  11. 29
      epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/ExternalCustomerDao.xml

2
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

15
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;
}

46
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
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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;
}

5
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<ExternalAppAuthResultDTO> auth(@RequestBody ExternalAppAuthFormDTO formDTO) {
String appId = formDTO.getAppId();

47
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<ExternalAppAuthResultDTO> list(@RequestBody ExternalCustomerFormDTO form) {
ValidatorUtils.validateEntity(form);
Integer pageNo = form.getPageNo();
Integer pageSize = form.getPageSize();
return null;
}
}

41
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
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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<ExternalCustomerEntity> {
/**
* 列出客户基本信息
* @return
*/
List<ExternalCustomerResultDTO> listBaseInfo();
}

46
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
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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;
}

11
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<ExternalCustomerResultDTO> list(Integer pageNo, Integer pageSize);
}

26
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<ExternalCustomerResultDTO> list(Integer pageNo, Integer pageSize) {
PageHelper.startPage(pageNo, pageSize);
List<ExternalCustomerResultDTO> customers = externalCustomerDao.listBaseInfo();
PageInfo<ExternalCustomerResultDTO> pageInfo = new PageInfo<>(customers);
return null;
}
}

2
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<String, Object> claim = new HashMap<>();
claim.put("appId", "1");
claim.put("appId", "227fb75ae4baa820755aaf43bf7f0a69");
claim.put("customerId", "c1");
claim.put("ts", System.currentTimeMillis() - 1000 * 60 * 4);

29
epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/ExternalCustomerDao.xml

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.epmet.dao.ExternalCustomerDao">
<resultMap type="com.epmet.entity.ExternalCustomerEntity" id="externalCustomerMap">
<result property="id" column="ID"/>
<result property="customerName" column="CUSTOMER_NAME"/>
<result property="delFlag" column="DEL_FLAG"/>
<result property="revision" column="REVISION"/>
<result property="createdBy" column="CREATED_BY"/>
<result property="createdTime" column="CREATED_TIME"/>
<result property="updatedBy" column="UPDATED_BY"/>
<result property="updatedTime" column="UPDATED_TIME"/>
</resultMap>
<!-- 列出客户基本信息-->
<select id="listBaseInfo" resultType="com.epmet.dto.result.ExternalCustomerResultDTO">
SELECT
id,
CUSTOMER_NAME
FROM
external_customer
WHERE
DEL_FLAG = 0
</select>
</mapper>
Loading…
Cancel
Save