parent
7a24ec661a
commit
8b73a70c0b
@ -0,0 +1,17 @@
|
||||
package com.infincash.statistics.risk.mapper.stats;
|
||||
|
||||
import com.infincash.statistics.risk.table.stats.TStatsRiskDetail;
|
||||
|
||||
public interface TStatsRiskDetailMapper {
|
||||
int deleteByPrimaryKey(Long id);
|
||||
|
||||
int insert(TStatsRiskDetail record);
|
||||
|
||||
int insertSelective(TStatsRiskDetail record);
|
||||
|
||||
TStatsRiskDetail selectByPrimaryKey(Long id);
|
||||
|
||||
int updateByPrimaryKeySelective(TStatsRiskDetail record);
|
||||
|
||||
int updateByPrimaryKey(TStatsRiskDetail record);
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
package com.infincash.statistics.risk.table.stats;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public class TStatsRiskDetail {
|
||||
private Long id;
|
||||
|
||||
private Date statsTime;
|
||||
|
||||
private Integer aHourCount;
|
||||
|
||||
private String riskRuleId;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Date getStatsTime() {
|
||||
return statsTime;
|
||||
}
|
||||
|
||||
public void setStatsTime(Date statsTime) {
|
||||
this.statsTime = statsTime;
|
||||
}
|
||||
|
||||
public Integer getaHourCount() {
|
||||
return aHourCount;
|
||||
}
|
||||
|
||||
public void setaHourCount(Integer aHourCount) {
|
||||
this.aHourCount = aHourCount;
|
||||
}
|
||||
|
||||
public String getRiskRuleId() {
|
||||
return riskRuleId;
|
||||
}
|
||||
|
||||
public void setRiskRuleId(String riskRuleId) {
|
||||
this.riskRuleId = riskRuleId == null ? null : riskRuleId.trim();
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package com.xxl.job.executor.core.config;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
public class DataSourceConfig {
|
||||
|
||||
@Bean(name = "prd")
|
||||
@ConfigurationProperties(prefix = "spring.datasource.prd") // application.properteis中对应属性的前缀
|
||||
public DataSource dataSource1() {
|
||||
return DataSourceBuilder.create().build();
|
||||
}
|
||||
|
||||
@Bean(name = "stats")
|
||||
@ConfigurationProperties(prefix = "spring.datasource.stats") // application.properteis中对应属性的前缀
|
||||
public DataSource dataSource2() {
|
||||
return DataSourceBuilder.create().build();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package com.xxl.job.executor.core.config;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.apache.ibatis.session.SqlSessionFactory;
|
||||
import org.mybatis.spring.SqlSessionFactoryBean;
|
||||
import org.mybatis.spring.SqlSessionTemplate;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
@MapperScan(basePackages = {"titan.mapper"}, sqlSessionFactoryRef = "sqlSessionFactory1")
|
||||
public class PrdDbConfig {
|
||||
|
||||
@Autowired
|
||||
@Qualifier("titanMasterDS")
|
||||
private DataSource ds1;
|
||||
|
||||
|
||||
@Bean
|
||||
public SqlSessionFactory sqlSessionFactory1() throws Exception {
|
||||
SqlSessionFactoryBean factoryBean = new SqlSessionFactoryBean();
|
||||
factoryBean.setDataSource(ds1); // 使用titan数据源, 连接titan库
|
||||
|
||||
return factoryBean.getObject();
|
||||
|
||||
}
|
||||
|
||||
@Bean
|
||||
public SqlSessionTemplate sqlSessionTemplate1() throws Exception {
|
||||
SqlSessionTemplate template = new SqlSessionTemplate(sqlSessionFactory1()); // 使用上面配置的Factory
|
||||
return template;
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package com.xxl.job.executor.core.config;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.apache.ibatis.session.SqlSessionFactory;
|
||||
import org.mybatis.spring.SqlSessionFactoryBean;
|
||||
import org.mybatis.spring.SqlSessionTemplate;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
@MapperScan(basePackages = {"other.mapper"}, sqlSessionFactoryRef = "sqlSessionFactory2")
|
||||
public class StatsDbConfig {
|
||||
@Autowired
|
||||
@Qualifier("ds2")
|
||||
private DataSource ds2;
|
||||
|
||||
@Bean
|
||||
public SqlSessionFactory sqlSessionFactory2() throws Exception {
|
||||
SqlSessionFactoryBean factoryBean = new SqlSessionFactoryBean();
|
||||
factoryBean.setDataSource(ds2);
|
||||
|
||||
|
||||
return factoryBean.getObject();
|
||||
|
||||
}
|
||||
|
||||
@Bean
|
||||
public SqlSessionTemplate sqlSessionTemplate2() throws Exception {
|
||||
SqlSessionTemplate template = new SqlSessionTemplate(sqlSessionFactory2());
|
||||
return template;
|
||||
}
|
||||
}
|
@ -1,9 +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.infincash.statistics.risk.mapper.TRiskRuleMapper">
|
||||
<select id="countRiskRule" resultType="java.lang.Integer">
|
||||
select
|
||||
count(1)
|
||||
from t_risk_rule
|
||||
</select>
|
||||
</mapper>
|
@ -0,0 +1,17 @@
|
||||
<?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.infincash.statistics.risk.mapper.TRiskRuleMapper">
|
||||
<resultMap type="com.infincash.statistics.risk.table.extend.RiskStatsDTO" id="RiskStatsDTOMap">
|
||||
<id property="id" column="id" />
|
||||
<result property="userName" column="username" />
|
||||
<result property="passW ord" column="password" />
|
||||
</resultMap>
|
||||
|
||||
<select id="countRiskRule" resultMap="RiskStatsDTOMap">
|
||||
select
|
||||
risk_rule_id, count(1), now()
|
||||
from t_user_risk
|
||||
where user_id in (select user_id from t_user where DATE_SUB(NOW(),INTERVAL 1 HOUR) <= register_time)
|
||||
GROUP by risk_rule_id order by risk_rule_id;
|
||||
</select>
|
||||
</mapper>
|
@ -0,0 +1,160 @@
|
||||
<?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.infincash.statistics.risk.mapper.stats.TStatsRiskDetailMapper">
|
||||
<resultMap id="BaseResultMap" type="com.infincash.statistics.risk.table.stats.TStatsRiskDetail">
|
||||
<id column="id" jdbcType="BIGINT" property="id" />
|
||||
<result column="stats_time" jdbcType="TIMESTAMP" property="statsTime" />
|
||||
<result column="a_hour_count" jdbcType="INTEGER" property="aHourCount" />
|
||||
<result column="risk_rule_id" jdbcType="VARCHAR" property="riskRuleId" />
|
||||
</resultMap>
|
||||
<sql id="Base_Column_List">
|
||||
id, stats_time, a_hour_count, risk_rule_id
|
||||
</sql>
|
||||
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
|
||||
select
|
||||
<include refid="Base_Column_List" />
|
||||
from t_stats_risk_detail
|
||||
where id = #{id,jdbcType=BIGINT}
|
||||
</select>
|
||||
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
|
||||
delete from t_stats_risk_detail
|
||||
where id = #{id,jdbcType=BIGINT}
|
||||
</delete>
|
||||
<insert id="insert" parameterType="com.infincash.statistics.risk.table.stats.TStatsRiskDetail">
|
||||
insert into t_stats_risk_detail (id, stats_time, a_hour_count,
|
||||
risk_rule_id)
|
||||
values (#{id,jdbcType=BIGINT}, #{statsTime,jdbcType=TIMESTAMP}, #{aHourCount,jdbcType=INTEGER},
|
||||
#{riskRuleId,jdbcType=VARCHAR})
|
||||
</insert>
|
||||
<insert id="insertSelective" parameterType="com.infincash.statistics.risk.table.stats.TStatsRiskDetail">
|
||||
insert into t_stats_risk_detail
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">
|
||||
id,
|
||||
</if>
|
||||
<if test="statsTime != null">
|
||||
stats_time,
|
||||
</if>
|
||||
<if test="aHourCount != null">
|
||||
a_hour_count,
|
||||
</if>
|
||||
<if test="riskRuleId != null">
|
||||
risk_rule_id,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">
|
||||
#{id,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="statsTime != null">
|
||||
#{statsTime,jdbcType=TIMESTAMP},
|
||||
</if>
|
||||
<if test="aHourCount != null">
|
||||
#{aHourCount,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="riskRuleId != null">
|
||||
#{riskRuleId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
<update id="updateByPrimaryKeySelective" parameterType="com.infincash.statistics.risk.table.stats.TStatsRiskDetail">
|
||||
update t_stats_risk_detail
|
||||
<set>
|
||||
<if test="statsTime != null">
|
||||
stats_time = #{statsTime,jdbcType=TIMESTAMP},
|
||||
</if>
|
||||
<if test="aHourCount != null">
|
||||
a_hour_count = #{aHourCount,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="riskRuleId != null">
|
||||
risk_rule_id = #{riskRuleId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
</set>
|
||||
where id = #{id,jdbcType=BIGINT}
|
||||
</update>
|
||||
<update id="updateByPrimaryKey" parameterType="com.infincash.statistics.risk.table.stats.TStatsRiskDetail">
|
||||
update t_stats_risk_detail
|
||||
set stats_time = #{statsTime,jdbcType=TIMESTAMP},
|
||||
a_hour_count = #{aHourCount,jdbcType=INTEGER},
|
||||
risk_rule_id = #{riskRuleId,jdbcType=VARCHAR}
|
||||
where id = #{id,jdbcType=BIGINT}
|
||||
</update>
|
||||
<resultMap id="BaseResultMap" type="com.infincash.statistics.risk.table.stats.TStatsRiskDetail">
|
||||
<id column="id" jdbcType="BIGINT" property="id" />
|
||||
<result column="stats_time" jdbcType="TIMESTAMP" property="statsTime" />
|
||||
<result column="a_hour_count" jdbcType="INTEGER" property="aHourCount" />
|
||||
<result column="risk_rule_id" jdbcType="VARCHAR" property="riskRuleId" />
|
||||
</resultMap>
|
||||
<sql id="Base_Column_List">
|
||||
id, stats_time, a_hour_count, risk_rule_id
|
||||
</sql>
|
||||
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
|
||||
select
|
||||
<include refid="Base_Column_List" />
|
||||
from t_stats_risk_detail
|
||||
where id = #{id,jdbcType=BIGINT}
|
||||
</select>
|
||||
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
|
||||
delete from t_stats_risk_detail
|
||||
where id = #{id,jdbcType=BIGINT}
|
||||
</delete>
|
||||
<insert id="insert" parameterType="com.infincash.statistics.risk.table.stats.TStatsRiskDetail">
|
||||
insert into t_stats_risk_detail (id, stats_time, a_hour_count,
|
||||
risk_rule_id)
|
||||
values (#{id,jdbcType=BIGINT}, #{statsTime,jdbcType=TIMESTAMP}, #{aHourCount,jdbcType=INTEGER},
|
||||
#{riskRuleId,jdbcType=VARCHAR})
|
||||
</insert>
|
||||
<insert id="insertSelective" parameterType="com.infincash.statistics.risk.table.stats.TStatsRiskDetail">
|
||||
insert into t_stats_risk_detail
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">
|
||||
id,
|
||||
</if>
|
||||
<if test="statsTime != null">
|
||||
stats_time,
|
||||
</if>
|
||||
<if test="aHourCount != null">
|
||||
a_hour_count,
|
||||
</if>
|
||||
<if test="riskRuleId != null">
|
||||
risk_rule_id,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">
|
||||
#{id,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="statsTime != null">
|
||||
#{statsTime,jdbcType=TIMESTAMP},
|
||||
</if>
|
||||
<if test="aHourCount != null">
|
||||
#{aHourCount,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="riskRuleId != null">
|
||||
#{riskRuleId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
<update id="updateByPrimaryKeySelective" parameterType="com.infincash.statistics.risk.table.stats.TStatsRiskDetail">
|
||||
update t_stats_risk_detail
|
||||
<set>
|
||||
<if test="statsTime != null">
|
||||
stats_time = #{statsTime,jdbcType=TIMESTAMP},
|
||||
</if>
|
||||
<if test="aHourCount != null">
|
||||
a_hour_count = #{aHourCount,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="riskRuleId != null">
|
||||
risk_rule_id = #{riskRuleId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
</set>
|
||||
where id = #{id,jdbcType=BIGINT}
|
||||
</update>
|
||||
<update id="updateByPrimaryKey" parameterType="com.infincash.statistics.risk.table.stats.TStatsRiskDetail">
|
||||
update t_stats_risk_detail
|
||||
set stats_time = #{statsTime,jdbcType=TIMESTAMP},
|
||||
a_hour_count = #{aHourCount,jdbcType=INTEGER},
|
||||
risk_rule_id = #{riskRuleId,jdbcType=VARCHAR}
|
||||
where id = #{id,jdbcType=BIGINT}
|
||||
</update>
|
||||
</mapper>
|
Loading…
Reference in new issue