forked from rongchao/epmet-cloud-rizhao
13 changed files with 395 additions and 25 deletions
@ -0,0 +1,20 @@ |
|||||
|
package com.epmet.dto.result; |
||||
|
|
||||
|
import lombok.AllArgsConstructor; |
||||
|
import lombok.Data; |
||||
|
import lombok.NoArgsConstructor; |
||||
|
|
||||
|
@Data |
||||
|
@AllArgsConstructor |
||||
|
@NoArgsConstructor |
||||
|
public class CorsConfigResultDTO { |
||||
|
/** |
||||
|
* 首部类型 |
||||
|
*/ |
||||
|
private String headerType; |
||||
|
|
||||
|
/** |
||||
|
* 首部值 |
||||
|
*/ |
||||
|
private String headerValue; |
||||
|
} |
@ -0,0 +1,24 @@ |
|||||
|
package com.epmet.feign; |
||||
|
|
||||
|
import com.epmet.commons.tools.constant.ServiceConstant; |
||||
|
import com.epmet.commons.tools.utils.Result; |
||||
|
import com.epmet.dto.result.CorsConfigResultDTO; |
||||
|
import com.epmet.feign.fallback.EpmetAdminOpenFeignClientFallback; |
||||
|
import org.springframework.cloud.openfeign.FeignClient; |
||||
|
import org.springframework.web.bind.annotation.PostMapping; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
@FeignClient(name = ServiceConstant.EPMET_ADMIN_SERVER, fallback = EpmetAdminOpenFeignClientFallback.class) |
||||
|
//@FeignClient(name = ServiceConstant.EPMET_ADMIN_SERVER, fallback = EpmetAdminOpenFeignClientFallback.class, url = "localhost:8082")
|
||||
|
public interface EpmetAdminOpenFeignClient { |
||||
|
|
||||
|
/** |
||||
|
* @Description 查询跨域配置列表 |
||||
|
* @return |
||||
|
* @author wxz |
||||
|
* @date 2021.06.25 10:00 |
||||
|
*/ |
||||
|
@PostMapping("/sys/cors-config/list") |
||||
|
Result<List<CorsConfigResultDTO>> list(); |
||||
|
} |
@ -0,0 +1,18 @@ |
|||||
|
package com.epmet.feign.fallback; |
||||
|
|
||||
|
import com.epmet.commons.tools.constant.ServiceConstant; |
||||
|
import com.epmet.commons.tools.utils.ModuleUtils; |
||||
|
import com.epmet.commons.tools.utils.Result; |
||||
|
import com.epmet.dto.result.CorsConfigResultDTO; |
||||
|
import com.epmet.feign.EpmetAdminOpenFeignClient; |
||||
|
import org.springframework.stereotype.Component; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
@Component |
||||
|
public class EpmetAdminOpenFeignClientFallback implements EpmetAdminOpenFeignClient { |
||||
|
@Override |
||||
|
public Result<List<CorsConfigResultDTO>> list() { |
||||
|
return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "list", null); |
||||
|
} |
||||
|
} |
@ -0,0 +1,32 @@ |
|||||
|
package com.epmet.controller; |
||||
|
|
||||
|
import com.epmet.commons.tools.utils.Result; |
||||
|
import com.epmet.dto.result.CorsConfigResultDTO; |
||||
|
import com.epmet.service.CorsConfigService; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.web.bind.annotation.PostMapping; |
||||
|
import org.springframework.web.bind.annotation.RequestMapping; |
||||
|
import org.springframework.web.bind.annotation.RestController; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
@RestController |
||||
|
@RequestMapping("cors-config") |
||||
|
public class CorsConfigController { |
||||
|
|
||||
|
@Autowired |
||||
|
private CorsConfigService corsConfigService; |
||||
|
|
||||
|
/** |
||||
|
* @Description 查询跨域配置列表 |
||||
|
* @return |
||||
|
* @author wxz |
||||
|
* @date 2021.06.25 10:00 |
||||
|
*/ |
||||
|
@PostMapping("/list") |
||||
|
public Result<List<CorsConfigResultDTO>> list() { |
||||
|
List<CorsConfigResultDTO> list = corsConfigService.list(); |
||||
|
return new Result<List<CorsConfigResultDTO>>().ok(list); |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,33 @@ |
|||||
|
/** |
||||
|
* 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.entity.CorsConfigEntity; |
||||
|
import org.apache.ibatis.annotations.Mapper; |
||||
|
|
||||
|
/** |
||||
|
* 跨域配置表 |
||||
|
* |
||||
|
* @author generator generator@elink-cn.com |
||||
|
* @since v1.0.0 2021-06-25 |
||||
|
*/ |
||||
|
@Mapper |
||||
|
public interface CorsConfigDao extends BaseDao<CorsConfigEntity> { |
||||
|
|
||||
|
} |
@ -0,0 +1,51 @@ |
|||||
|
/** |
||||
|
* 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 2021-06-25 |
||||
|
*/ |
||||
|
@Data |
||||
|
@EqualsAndHashCode(callSuper=false) |
||||
|
@TableName("cors_config") |
||||
|
public class CorsConfigEntity extends BaseEpmetEntity { |
||||
|
|
||||
|
private static final long serialVersionUID = 1L; |
||||
|
|
||||
|
/** |
||||
|
* 首部类型 |
||||
|
*/ |
||||
|
private String headerType; |
||||
|
|
||||
|
/** |
||||
|
* 首部值 |
||||
|
*/ |
||||
|
private String headerValue; |
||||
|
|
||||
|
} |
@ -0,0 +1,14 @@ |
|||||
|
package com.epmet.service; |
||||
|
|
||||
|
import com.epmet.dto.result.CorsConfigResultDTO; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @Description 跨域配置service接口 |
||||
|
* @author wxz |
||||
|
* @date 2021-06-44 09:52:44 |
||||
|
*/ |
||||
|
public interface CorsConfigService { |
||||
|
List<CorsConfigResultDTO> list(); |
||||
|
} |
@ -0,0 +1,36 @@ |
|||||
|
package com.epmet.service.impl; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||
|
import com.epmet.commons.tools.utils.ConvertUtils; |
||||
|
import com.epmet.dao.CorsConfigDao; |
||||
|
import com.epmet.dto.result.CorsConfigResultDTO; |
||||
|
import com.epmet.entity.CorsConfigEntity; |
||||
|
import com.epmet.service.CorsConfigService; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @Description 跨域配置 |
||||
|
* @author wxz |
||||
|
* @date 2021.06.25 09:53:57 |
||||
|
*/ |
||||
|
@Service |
||||
|
public class CorsConfigServiceImpl implements CorsConfigService { |
||||
|
|
||||
|
@Autowired |
||||
|
private CorsConfigDao corsConfigDao; |
||||
|
|
||||
|
/** |
||||
|
* @Description 查询配置列表 |
||||
|
* @return |
||||
|
* @author wxz |
||||
|
* @date 2021.06.25 09:58 |
||||
|
*/ |
||||
|
@Override |
||||
|
public List<CorsConfigResultDTO> list() { |
||||
|
LambdaQueryWrapper<CorsConfigEntity> conditions = new LambdaQueryWrapper<>(); |
||||
|
return ConvertUtils.sourceToTarget(corsConfigDao.selectList(conditions), CorsConfigResultDTO.class); |
||||
|
} |
||||
|
} |
@ -0,0 +1,19 @@ |
|||||
|
<?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.CorsConfigDao"> |
||||
|
|
||||
|
<resultMap type="com.epmet.entity.CorsConfigEntity" id="corsConfigMap"> |
||||
|
<result property="id" column="ID"/> |
||||
|
<result property="headerType" column="HEADER_TYPE"/> |
||||
|
<result property="headerValue" column="HEADER_VALUE"/> |
||||
|
<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> |
||||
|
|
||||
|
|
||||
|
</mapper> |
@ -0,0 +1,21 @@ |
|||||
|
package com.epmet.bean; |
||||
|
|
||||
|
import lombok.AllArgsConstructor; |
||||
|
import lombok.Data; |
||||
|
import lombok.NoArgsConstructor; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @Description 跨域配置缓存 |
||||
|
* @author wxz |
||||
|
* @date 2021.06.25 10:59:44 |
||||
|
*/ |
||||
|
@Data |
||||
|
@AllArgsConstructor |
||||
|
@NoArgsConstructor |
||||
|
public class CorsConfigCache { |
||||
|
|
||||
|
private List<String> accessControlAllowOrigins; |
||||
|
|
||||
|
} |
Loading…
Reference in new issue