fase()远程调用
parent
91ceda487b
commit
20c771be2c
|
@ -29,6 +29,13 @@
|
|||
<artifactId>muyu-goods-edition-remote</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-modules-system</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
package com.muyu.efition.clinet;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class MuyuClinetApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(MuyuClinetApplication.class);
|
||||
}
|
||||
}
|
|
@ -3,6 +3,9 @@ package com.muyu.efition.clinet.config;
|
|||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
/**
|
||||
* 规则引擎客户端配置类
|
||||
*/
|
||||
@ComponentScan
|
||||
@Import(value = AccessConfigRunner.class)
|
||||
public class AccessConfig {
|
||||
|
|
|
@ -1,24 +1,102 @@
|
|||
package com.muyu.efition.clinet.config;
|
||||
|
||||
import com.alibaba.druid.pool.DruidDataSource;
|
||||
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.utils.StringUtils;
|
||||
import com.muyu.common.core.web.page.TableDataInfo;
|
||||
import com.muyu.edition.domain.RuleEngine;
|
||||
import com.muyu.edition.domain.vo.UnitVo;
|
||||
import com.muyu.goods.edition.remote.RemoteDataManagerService;
|
||||
import com.muyu.system.domain.DataAccess;
|
||||
import com.muyu.system.domain.vo.FrimaryVo;
|
||||
import com.muyu.system.remote.RemoteSystemManageService;
|
||||
import com.muyu.system.remote.factory.DataMangSystemFactory;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.ApplicationArguments;
|
||||
import org.springframework.boot.ApplicationRunner;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* 初始化加载
|
||||
*/
|
||||
@Log4j2
|
||||
public class AccessConfigRunner implements ApplicationRunner {
|
||||
@Autowired
|
||||
private RemoteDataManagerService remoteDataManagerService;
|
||||
private RemoteSystemManageService remoteSystemManageService;
|
||||
|
||||
@Override
|
||||
public void run(ApplicationArguments args) throws Exception {
|
||||
Result<TableDataInfo<RuleEngine>> list = remoteDataManagerService.list(null);
|
||||
//远程调用
|
||||
Result<TableDataInfo<DataAccess>> listed = remoteSystemManageService.list(null);
|
||||
//判断非空
|
||||
if (listed.getData().getRows() == null || listed.getData().getRows().isEmpty()){
|
||||
log.error("数据为空");
|
||||
return;
|
||||
}
|
||||
//获取数据源集合
|
||||
List<DataAccess> listResultData = listed.getData().getRows();
|
||||
//存入map
|
||||
//创建map
|
||||
HashMap<Long, DataAccess> frimaryVoHashMap = new HashMap<>();
|
||||
//遍历循环存入map
|
||||
listResultData.forEach(res -> {
|
||||
frimaryVoHashMap.put(res.getId(),res);
|
||||
});
|
||||
HashMap<String, UnitVo> hashMap = new HashMap<>();
|
||||
//遍历添加到hashMap
|
||||
for (DataAccess listResultDatum : listResultData) {
|
||||
if (listResultDatum.getType() == "MySql"){
|
||||
//主机地址
|
||||
String host = listResultDatum.getHost();
|
||||
//端口号
|
||||
String port = listResultDatum.getPort();
|
||||
//数据库名
|
||||
String databaseName = listResultDatum.getDatabaseName();
|
||||
// url
|
||||
String url = String.format("jdbc:mysql://"+ host+":"+port+":"+databaseName);
|
||||
log.info("集成化的url:{}",url);
|
||||
//连接对象 url/用户名/密码
|
||||
Connection connection = DriverManager.getConnection(url,listResultDatum.getUsername(),listResultDatum.getPassword());
|
||||
log.info("连接对象:{}",connection);
|
||||
DruidDataSource dataSource = new DruidDataSource();
|
||||
//初始化链接池数量
|
||||
dataSource.setInitialSize(listResultDatum.getInitNum().intValue());
|
||||
//最大线程池
|
||||
dataSource.setMaxActive(listResultDatum.getMaxNum().intValue());
|
||||
//最大等待时间
|
||||
dataSource.setMaxWait(listResultDatum.getMaxWaitTime());
|
||||
//配置数据库的基本信息
|
||||
dataSource.setDriverClassName("com.mysql/jdbc.Driver");
|
||||
//数据库连接池
|
||||
dataSource.setUrl("jdbc:mysql://"+
|
||||
listResultDatum.getHost()+":"+listResultDatum.getPort()+":"+listResultDatum.getDatabaseName());
|
||||
//数据库用户名
|
||||
dataSource.setUsername(listResultDatum.getUsername());
|
||||
//数据库密码
|
||||
dataSource.setPassword(listResultDatum.getPassword());
|
||||
log.info("获取连接池对象:{}",dataSource);
|
||||
//封装对象
|
||||
//SuperBuilder方法
|
||||
UnitVo build = UnitVo.builder()
|
||||
.connection(connection)
|
||||
.dataSource(dataSource)
|
||||
.build();
|
||||
//存入map
|
||||
hashMap.put(host+"_"+port+"_"+databaseName,build);
|
||||
}
|
||||
|
||||
log.info("远程调用成功,效果为:{}", list);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
package com.muyu.edition.domain.vo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.sql.Connection;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@SuperBuilder
|
||||
public class UnitVo {
|
||||
private Connection connection;
|
||||
private DataSource dataSource;
|
||||
}
|
|
@ -6,14 +6,21 @@ import com.muyu.common.core.web.page.TableDataInfo;
|
|||
import com.muyu.edition.domain.RuleEngine;
|
||||
import com.muyu.goods.edition.remote.factory.DataMangFacrory;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 远程调用
|
||||
*/
|
||||
@FeignClient(
|
||||
contextId = "RemoteSys",
|
||||
value = ServiceNameConstants.EDITION_MUYU,
|
||||
fallbackFactory = DataMangFacrory.class,
|
||||
path = "/engine"
|
||||
)
|
||||
@Service
|
||||
public interface RemoteDataManagerService {
|
||||
@GetMapping("/list")
|
||||
public Result<TableDataInfo<RuleEngine>> list(RuleEngine ruleEngine);
|
||||
|
|
|
@ -5,9 +5,14 @@ import com.muyu.common.core.web.page.TableDataInfo;
|
|||
import com.muyu.edition.domain.RuleEngine;
|
||||
import com.muyu.goods.edition.remote.RemoteDataManagerService;
|
||||
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||
import org.w3c.dom.stylesheets.LinkStyle;
|
||||
|
||||
//熔断
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* 熔断
|
||||
*/
|
||||
public class DataMangFacrory implements FallbackFactory<RemoteDataManagerService> {
|
||||
@Override
|
||||
public RemoteDataManagerService create(Throwable cause) {
|
||||
|
|
|
@ -33,7 +33,6 @@ public class RuleEngineController extends BaseController {
|
|||
@RequiresPermissions("goods:engine:list")
|
||||
@GetMapping("/list")
|
||||
public Result<TableDataInfo<RuleEngine>> list(RuleEngine ruleEngine) {
|
||||
startPage();
|
||||
List<RuleEngine> list = ruleEngineService.selectRuleEngineList(ruleEngine);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
|
|
@ -25,4 +25,5 @@
|
|||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
|
||||
</project>
|
||||
|
|
|
@ -28,9 +28,97 @@
|
|||
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-goods</artifactId>
|
||||
<artifactId>muyu-goods-edition</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</dependency>
|
||||
<!-- SpringCloud Alibaba Nacos -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringCloud Alibaba Nacos Config -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringCloud Alibaba Sentinel -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringBoot Actuator -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Swagger UI -->
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger-ui</artifactId>
|
||||
<version>${swagger.fox.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Mysql Connector -->
|
||||
<dependency>
|
||||
<groupId>com.mysql</groupId>
|
||||
<artifactId>mysql-connector-j</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- MuYu Common DataSource -->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-common-datasource</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- MuYu Common DataScope -->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-common-datascope</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- MuYu Common Log -->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-common-log</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- MuYu Common Swagger -->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-common-swagger</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<finalName>${project.artifactId}</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<!-- 加入maven deploy插件,当在deploy时,忽略些model-->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-deploy-plugin</artifactId>
|
||||
<configuration>
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
||||
|
||||
</project>
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
package com.muyu.goods.unit;
|
||||
|
||||
import com.muyu.common.security.annotation.EnableCustomConfig;
|
||||
import com.muyu.common.security.annotation.EnableMyFeignClients;
|
||||
import com.muyu.common.swagger.annotation.EnableCustomSwagger2;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||
import org.springframework.scheduling.annotation.EnableAsync;
|
||||
|
||||
/**
|
||||
* 测试启动类
|
||||
*/
|
||||
@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
|
||||
@EnableCustomConfig
|
||||
@EnableCustomSwagger2
|
||||
@EnableMyFeignClients
|
||||
@EnableAsync
|
||||
public class MuyuGoodsUnitApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(MuyuGoodsUnitApplication.class);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
# Tomcat
|
||||
server:
|
||||
port: 9505
|
||||
|
||||
# Spring
|
||||
spring:
|
||||
application:
|
||||
# 应用名称
|
||||
name: muyu-test
|
||||
profiles:
|
||||
# 环境配置
|
||||
active: dev
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 129.211.23.219:8848
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 129.211.23.219:8848
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
shared-configs:
|
||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||
logging:
|
||||
level:
|
||||
com.muyu.edition.mapper: DEBUG
|
|
@ -0,0 +1,74 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration scan="true" scanPeriod="60 seconds" debug="false">
|
||||
<!-- 日志存放路径 -->
|
||||
<property name="log.path" value="logs/muyu-visual-monitor"/>
|
||||
<!-- 日志输出格式 -->
|
||||
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n"/>
|
||||
|
||||
<!-- 控制台输出 -->
|
||||
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>${log.pattern}</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<!-- 系统日志输出 -->
|
||||
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${log.path}/info.log</file>
|
||||
<!-- 循环政策:基于时间创建日志文件 -->
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!-- 日志文件名格式 -->
|
||||
<fileNamePattern>${log.path}/info.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||
<!-- 日志最大的历史 60天 -->
|
||||
<maxHistory>60</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>${log.pattern}</pattern>
|
||||
</encoder>
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<!-- 过滤的级别 -->
|
||||
<level>INFO</level>
|
||||
<!-- 匹配时的操作:接收(记录) -->
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<!-- 不匹配时的操作:拒绝(不记录) -->
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${log.path}/error.log</file>
|
||||
<!-- 循环政策:基于时间创建日志文件 -->
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!-- 日志文件名格式 -->
|
||||
<fileNamePattern>${log.path}/error.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||
<!-- 日志最大的历史 60天 -->
|
||||
<maxHistory>60</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>${log.pattern}</pattern>
|
||||
</encoder>
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<!-- 过滤的级别 -->
|
||||
<level>ERROR</level>
|
||||
<!-- 匹配时的操作:接收(记录) -->
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<!-- 不匹配时的操作:拒绝(不记录) -->
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
<!-- 系统模块日志级别控制 -->
|
||||
<logger name="com.muyu" level="info"/>
|
||||
<!-- Spring日志级别控制 -->
|
||||
<logger name="org.springframework" level="warn"/>
|
||||
|
||||
<root level="info">
|
||||
<appender-ref ref="console"/>
|
||||
</root>
|
||||
|
||||
<!--系统操作日志-->
|
||||
<root level="info">
|
||||
<appender-ref ref="file_info"/>
|
||||
<appender-ref ref="file_error"/>
|
||||
</root>
|
||||
</configuration>
|
|
@ -1,74 +0,0 @@
|
|||
<?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.muyu.goods.mapper.ConfigMapper">
|
||||
|
||||
<resultMap type="com.muyu.edition.domain.Config" id="ConfigResult">
|
||||
<result property="id" column="id"/>
|
||||
<result property="versionCode" column="version_code"/>
|
||||
<result property="ruleContent" column="rule_content"/>
|
||||
<result property="remark" column="remark"/>
|
||||
<result property="ruleId" column="rule_id"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectConfigVo">
|
||||
select id, version_code, rule_content, remark, rule_id
|
||||
from config
|
||||
</sql>
|
||||
|
||||
<select id="selectConfigList" parameterType="com.muyu.edition.domain.Config" resultMap="ConfigResult">
|
||||
<include refid="selectConfigVo"/>
|
||||
<where>
|
||||
<if test="versionCode != null and versionCode != ''">and version_code = #{versionCode}</if>
|
||||
<if test="ruleContent != null and ruleContent != ''">and rule_content = #{ruleContent}</if>
|
||||
<if test="ruleId != null ">and rule_id = #{ruleId}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectConfigById" parameterType="Long" resultMap="ConfigResult">
|
||||
<include refid="selectConfigVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
<select id="listConfigEs" resultType="com.muyu.edition.domain.Config">
|
||||
<include refid="selectConfigVo"/>
|
||||
where rule_id = #{ruleId}
|
||||
</select>
|
||||
|
||||
<insert id="insertConfig" parameterType="com.muyu.edition.domain.Config" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into config
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="versionCode != null">version_code,</if>
|
||||
<if test="ruleContent != null">rule_content,</if>
|
||||
<if test="ruleId != null">rule_id,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="versionCode != null">#{versionCode},</if>
|
||||
<if test="ruleContent != null">#{ruleContent},</if>
|
||||
<if test="ruleId != null">#{ruleId},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateConfig" parameterType="com.muyu.edition.domain.Config">
|
||||
update config
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="versionCode != null">version_code = #{versionCode},</if>
|
||||
<if test="ruleContent != null">rule_content = #{ruleContent},</if>
|
||||
<if test="ruleId != null">rule_id = #{ruleId},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteConfigById" parameterType="Long">
|
||||
delete
|
||||
from config
|
||||
where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteConfigByIds" parameterType="String">
|
||||
delete from config where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
|
@ -1,11 +0,0 @@
|
|||
<?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.muyu.goods.mapper.CopeMapper">
|
||||
|
||||
<select id="list" resultType="com.muyu.edition.domain.Cope">
|
||||
select *
|
||||
from cope
|
||||
</select>
|
||||
</mapper>
|
|
@ -1,85 +0,0 @@
|
|||
<?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.muyu.goods.mapper.EditionMapper">
|
||||
|
||||
<resultMap type="com.muyu.edition.domain.Edition" id="EditionResult">
|
||||
<result property="id" column="id"/>
|
||||
<result property="ruleId" column="rule_id"/>
|
||||
<result property="versionClass" column="version_class"/>
|
||||
<result property="name" column="name"/>
|
||||
<result property="versionCode" column="version_code"/>
|
||||
<result property="editionStatus" column="edition_status"/>
|
||||
<result property="ruleStatus" column="rule_status"/>
|
||||
<result property="ruleIsTest" column="rule_is_test"/>
|
||||
<result property="editionContent" column="edition_content"/>
|
||||
<result property="ruleContent" column="rule_content"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectEditionVo">
|
||||
select id,
|
||||
rule_id,
|
||||
version_class,
|
||||
name,
|
||||
version_code,
|
||||
edition_status,
|
||||
rule_status,
|
||||
rule_is_test,
|
||||
edition_content,
|
||||
rule_content
|
||||
from edition
|
||||
</sql>
|
||||
|
||||
<select id="selectEditionList" parameterType="com.muyu.edition.domain.Edition" resultMap="EditionResult">
|
||||
<include refid="selectEditionVo"/>
|
||||
</select>
|
||||
|
||||
<select id="selectEditionById" parameterType="Long" resultMap="EditionResult">
|
||||
<include refid="selectEditionVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertEdition" parameterType="com.muyu.edition.domain.Edition" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into edition
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="ruleId != null">rule_id,</if>
|
||||
<if test="versionClass != null">version_class,</if>
|
||||
<if test="name != null">name,</if>
|
||||
<if test="versionCode != null">version_code,</if>
|
||||
<if test="editionContent != null">edition_content,</if>
|
||||
<if test="ruleContent != null">rule_content,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="ruleId != null">#{ruleId},</if>
|
||||
<if test="versionClass != null">#{versionClass},</if>
|
||||
<if test="name != null">#{name},</if>
|
||||
<if test="versionCode != null">#{versionCode},</if>
|
||||
<if test="editionContent != null">#{editionContent},</if>
|
||||
<if test="ruleContent != null">#{ruleContent},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateEdition" parameterType="com.muyu.edition.domain.Edition">
|
||||
update edition
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="name != null">name = #{name},</if>
|
||||
<if test="editionContent != null">edition_content = #{editionContent},</if>
|
||||
<if test="ruleContent != null">rule_content = #{ruleContent},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteEditionById" parameterType="Long">
|
||||
delete
|
||||
from edition
|
||||
where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteEditionByIds" parameterType="String">
|
||||
delete from edition where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
|
@ -1,115 +0,0 @@
|
|||
<?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.muyu.goods.mapper.RuleEngineMapper">
|
||||
|
||||
<resultMap type="com.muyu.edition.domain.RuleEngine" id="RuleEngineResult">
|
||||
<result property="ruleId" column="rule_id"/>
|
||||
<result property="ruleName" column="rule_name"/>
|
||||
<result property="ruleCode" column="rule_code"/>
|
||||
<result property="ruleLevel" column="rule_level"/>
|
||||
<result property="ruleType" column="rule_type"/>
|
||||
<result property="ruleIsActivate" column="rule_is_activate"/>
|
||||
<result property="ruleStatus" column="rule_status"/>
|
||||
<result property="description" column="description"/>
|
||||
<result property="remark" column="remark"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectRuleEngineVo">
|
||||
select rule_id,
|
||||
rule_name,
|
||||
rule_code,
|
||||
rule_level,
|
||||
rule_type,
|
||||
rule_is_activate,
|
||||
rule_status,
|
||||
description,
|
||||
remark
|
||||
from rule_engine
|
||||
</sql>
|
||||
|
||||
<select id="selectRuleEngineList" parameterType="com.muyu.edition.domain.RuleEngine" resultMap="RuleEngineResult">
|
||||
<include refid="selectRuleEngineVo"/>
|
||||
<where>
|
||||
<if test="ruleName != null and ruleName != ''">and rule_name like concat('%', #{ruleName}, '%')</if>
|
||||
<if test="ruleLevel != null and ruleLevel != ''">and rule_level = #{ruleLevel}</if>
|
||||
<if test="ruleType != null and ruleType != ''">and rule_type = #{ruleType}</if>
|
||||
<if test="ruleIsActivate != null and ruleIsActivate != ''">and rule_is_activate = #{ruleIsActivate}</if>
|
||||
<if test="ruleStatus != null and ruleStatus != ''">and rule_status = #{ruleStatus}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectRuleEngineByRuleId" parameterType="Long" resultMap="RuleEngineResult">
|
||||
<include refid="selectRuleEngineVo"/>
|
||||
where rule_id = #{ruleId}
|
||||
</select>
|
||||
<select id="description" resultType="java.lang.String">
|
||||
select description
|
||||
from rule_engine
|
||||
where rule_id = #{ruleId};
|
||||
</select>
|
||||
|
||||
<insert id="insertRuleEngine" parameterType="com.muyu.edition.domain.RuleEngine" useGeneratedKeys="true"
|
||||
keyProperty="ruleId">
|
||||
insert into rule_engine
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="ruleName != null">rule_name,</if>
|
||||
<if test="ruleCode != null">rule_code,</if>
|
||||
<if test="ruleLevel != null">rule_level,</if>
|
||||
<if test="ruleType != null">rule_type,</if>
|
||||
<if test="ruleIsActivate != null">rule_is_activate,</if>
|
||||
<if test="ruleStatus != null">rule_status,</if>
|
||||
<if test="description != null">description,</if>
|
||||
<if test="remark != null">remark,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="ruleName != null">#{ruleName},</if>
|
||||
<if test="ruleCode != null">#{ruleCode},</if>
|
||||
<if test="ruleLevel != null">#{ruleLevel},</if>
|
||||
<if test="ruleType != null">#{ruleType},</if>
|
||||
<if test="ruleIsActivate != null">#{ruleIsActivate},</if>
|
||||
<if test="ruleStatus != null">#{ruleStatus},</if>
|
||||
<if test="description != null">#{description},</if>
|
||||
<if test="remark != null">#{remark},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateRuleEngine" parameterType="com.muyu.edition.domain.RuleEngine">
|
||||
update rule_engine
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="ruleName != null">rule_name = #{ruleName},</if>
|
||||
<if test="ruleCode != null">rule_code = #{ruleCode},</if>
|
||||
<if test="ruleLevel != null">rule_level = #{ruleLevel},</if>
|
||||
<if test="ruleType != null">rule_type = #{ruleType},</if>
|
||||
<if test="ruleIsActivate != null">rule_is_activate = #{ruleIsActivate},</if>
|
||||
<if test="ruleStatus != null">rule_status = #{ruleStatus},</if>
|
||||
<if test="description != null">description = #{description},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
</trim>
|
||||
where rule_id = #{ruleId}
|
||||
</update>
|
||||
<update id="updateRuleIsActivate">
|
||||
update rule_engine
|
||||
set rule_is_activate = #{ruleIsActivate}
|
||||
where rule_id = #{ruleId};
|
||||
</update>
|
||||
<update id="updateRuleStatus">
|
||||
update rule_engine
|
||||
set rule_status = #{ruleStatus}
|
||||
where rule_id = #{ruleId};
|
||||
</update>
|
||||
|
||||
<delete id="deleteRuleEngineByRuleId" parameterType="Long">
|
||||
delete
|
||||
from rule_engine
|
||||
where rule_id = #{ruleId}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteRuleEngineByRuleIds" parameterType="String">
|
||||
delete from rule_engine where rule_id in
|
||||
<foreach item="ruleId" collection="array" open="(" separator="," close=")">
|
||||
#{ruleId}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
|
@ -0,0 +1,27 @@
|
|||
package com.muyu.system.remote;
|
||||
|
||||
import com.muyu.common.core.constant.ServiceNameConstants;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.web.page.TableDataInfo;
|
||||
import com.muyu.system.domain.DataAccess;
|
||||
import com.muyu.system.domain.vo.FrimaryVo;
|
||||
import com.muyu.system.remote.factory.DataMangSystemFactory;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 远程调用
|
||||
*/
|
||||
@FeignClient(
|
||||
contextId = "RemoteSys",
|
||||
value = ServiceNameConstants.SYSTEM_SERVICE,
|
||||
fallbackFactory = DataMangSystemFactory.class,
|
||||
path = "/access"
|
||||
)
|
||||
public interface RemoteSystemManageService {
|
||||
@GetMapping("/list")
|
||||
public Result<TableDataInfo<DataAccess>> list(DataAccess dataAccess);
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package com.muyu.system.remote.factory;
|
||||
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.web.page.TableDataInfo;
|
||||
import com.muyu.system.domain.DataAccess;
|
||||
import com.muyu.system.domain.vo.FrimaryVo;
|
||||
import com.muyu.system.remote.RemoteSystemManageService;
|
||||
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 熔断
|
||||
*/
|
||||
public class DataMangSystemFactory implements FallbackFactory<RemoteSystemManageService> {
|
||||
@Override
|
||||
public RemoteSystemManageService create(Throwable cause) {
|
||||
return new RemoteSystemManageService() {
|
||||
|
||||
@Override
|
||||
public Result<TableDataInfo<DataAccess>> list(DataAccess dataAccess) {
|
||||
return Result.error(cause.getMessage());
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue