first commit

This commit is contained in:
niuge
2021-11-29 14:06:41 +08:00
parent 9fe956e941
commit 9450445e2a
259 changed files with 27872 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
server.port=8085
server.servlet.context-path=/Riskmanage
logging.config=classpath:logging-config.xml
# mysql
spring.datasource.default.url = jdbc:mysql://47.102.125.25:3306/zsxntest?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true
spring.datasource.default.username = root
spring.datasource.default.password = enginex513
spring.datasource.default.driver-class-name = com.mysql.cj.jdbc.Driver
# redis
redis.host=47.102.125.25
redis.port=6379
redis.db=0
redis.password=enginex123
redis.pool.maxTotal=3000
redis.pool.maxIdle=100
redis.pool.maxWait=1000
redis.pool.timeout=100000
runner.url: http://localhost:8081
# \u76D1\u63A7\u4E2D\u5FC3 \u6570\u636E\u5B58\u50A8\u65B9\u5F0F mysql \u6216\u8005 hbase
monitor.data.storage.type=mysql

View File

@@ -0,0 +1,27 @@
server.port=8080
server.servlet.context-path=/Riskmanage
logging.config=classpath:logging-config.xml
# mysql
spring.datasource.default.url = jdbc:mysql://localhost:3306/riskmanage?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true
spring.datasource.default.username = root
spring.datasource.default.password = enginex513!
spring.datasource.default.driver-class-name = com.mysql.cj.jdbc.Driver
# redis
redis.host=localhost
redis.port=6379
redis.db=0
redis.password=enginex123!
redis.pool.maxTotal=3000
redis.pool.maxIdle=100
redis.pool.maxWait=1000
redis.pool.timeout=100000
runner.url: http://localhost:8082
# \u76D1\u63A7\u4E2D\u5FC3 \u6570\u636E\u5B58\u50A8\u65B9\u5F0F mysql \u6216\u8005 hbase
monitor.data.storage.type=mysql

View File

@@ -0,0 +1,25 @@
server.port=8080
server.servlet.context-path=/Riskmanage
logging.config=classpath:logging-config.xml
# mysql
spring.datasource.default.url = jdbc:mysql://localhost:3306/riskmanage?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true
spring.datasource.default.username = root
spring.datasource.default.password = enginex513
spring.datasource.default.driver-class-name = com.mysql.cj.jdbc.Driver
# redis
redis.host=localhost
redis.port=6379
redis.db=0
redis.password=enginex123
redis.pool.maxTotal=3000
redis.pool.maxIdle=100
redis.pool.maxWait=1000
redis.pool.timeout=100000
runner.url: http://localhost:8081
# \u76D1\u63A7\u4E2D\u5FC3 \u6570\u636E\u5B58\u50A8\u65B9\u5F0F mysql \u6216\u8005 hbase
monitor.data.storage.type=mysql

View File

@@ -0,0 +1 @@
spring.profiles.active=dev

View File

@@ -0,0 +1,52 @@
<?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.risk.riskmanage.datamanage.mapper.FieldCondMapper">
<cache></cache>
<resultMap type="fieldCond" id="fieldCondMap">
<id column="id" property="id"/>
<result column="field_id" property="fieldId"/>
<result column="condition_value" property="conditionValue"/>
<result column="content" property="content"/>
<result column="cond_field_id" property="condFieldId"/>
<result column="cond_field_operator" property="condFieldOperator"/>
<result column="cond_field_value" property="condFieldValue"/>
<result column="cond_field_logical" property="condFieldLogical"/>
<result column="created" property="created"/>
</resultMap>
<insert id="createFieldCond" parameterType="java.util.List">
insert into t_field_condition ( field_id, condition_value, content
, cond_field_id, cond_field_operator, cond_field_value, cond_field_logical
, created)
values
<foreach collection="list" item="fieldCond" index="index" separator=",">
( #{fieldCond.fieldId}, #{fieldCond.conditionValue}, #{fieldCond.content}
, #{fieldCond.condFieldId}, #{fieldCond.condFieldOperator}, #{fieldCond.condFieldValue}, #{fieldCond.condFieldLogical}
, now() )
</foreach>
</insert>
<select id="getFieldCondListById" parameterType="java.lang.Long" resultType="fieldCond">
select field_id as fieldId, condition_value as conditionValue, content
, cond_field_id as condFieldId, cond_field_operator as condFieldOperator
, cond_field_value as condFieldValue, cond_field_logical as condFieldLogical
from t_field_condition
where field_id = #{fieldId}
</select>
<select id="getFieldCondList" parameterType="long" resultType="fieldCond">
select field_id as fieldId, condition_value as conditionValue, content
from t_field_condition
where field_id = #{id}
group by field_id,condition_value,content
</select>
<delete id="deleteFieldCondById" parameterType="java.lang.Long" >
delete from t_field_condition where field_id = #{id}
</delete>
</mapper>

View File

@@ -0,0 +1,836 @@
<?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.risk.riskmanage.datamanage.mapper.FieldMapper">
<cache></cache>
<resultMap type="com.risk.riskmanage.datamanage.model.Field" id="fieldMap">
<id column="id" property="id"/>
<result column="field_en" property="fieldEn"/>
<result column="field_cn" property="fieldCn"/>
<result column="field_typeid" property="fieldTypeId"/>
<result column="value_type" property="valueType"/>
<result column="value_scope" property="valueScope"/>
<result column="is_derivative" property="isDerivative"/>
<result column="is_output" property="isOutput"/>
<result column="is_common" property="isCommon"/>
<result column="formula" property="formula"/>
<result column="formula_show" property="formulaShow"/>
<result column="orig_fieldid" property="origFieldId"/>
<result column="used_fieldid" property="usedFieldId"/>
<result column="author" property="author"/>
<result column="nickName" property="nickName"/>
<result column="created" property="created"/>
<result column="field_type" property="fieldType"/>
<result column="engine_id" property="engineId"/>
<result column="engineName" property="engineName"/>
<result column="status" property="status"/>
<result column="fieldRelId" property="fieldRelId"/>
<result column="is_use_sql" property="isUseSql"/>
<result column="data_source_id" property="dataSourceId"/>
<result column="sql_statement" property="sqlStatement"/>
<result column="is_interface" property="isInterface"/>
<result column="interface_id" property="interfaceId"/>
<result column="json_value" property="jsonValue"/>
<result column="dict_variable" property="dictVariable"/>
<result column="interface_parse_field" property="interfaceParseField"/>
<collection property="fieldCondList" ofType="fieldCond" column="id" select ="com.risk.riskmanage.datamanage.mapper.FieldCondMapper.getFieldCondList"></collection>
</resultMap>
<!--
<select id="findByFieldType" parameterType="java.util.Map" resultType="com.risk.riskmanage.datamanage.model.Field">
select f.id, f.field_en as fieldEn, f.field_cn as fieldCn, f.field_typeid as fieldTypeId
, p.field_type as fieldType
, f.value_type as valueType, f.value_scope as valueScope
, f.is_derivative as isDerivative
, f.is_output as isOutput
, f.is_common as isCommon, f.formula, f.formula_show as formulaShow
, f.author, u.nick_name as nickName ,f.created
, r.status
from t_field f, t_field_user_rel r, t_field_type p, t_user u
where f.id = r.field_id and f.field_typeid = p.id and r.user_id = u.user_id
and r.organ_id = ( select organ_id from t_user where user_id = #{userId} )
<if test="searchKey != null">
and (f.field_en like '%${searchKey}%' or f.field_cn like '%${searchKey}%' )
</if>
<if test="fieldTypeId == null and engineId == null and isCommon == 1 and status == null">
and r.engine_id is null
and f.is_common = 1
and r.status != -1
</if>
<if test="fieldTypeId != null and engineId == null and isCommon == 1 and status == null">
and f.field_typeid = #{fieldTypeId}
and r.engine_id is null
and f.is_common = 1
and r.status != -1
</if>
<if test="fieldTypeId == null and engineId != null and isCommon == 0 and status == null">
and r.engine_id = #{engineId}
and r.status != -1
</if>
<if test="fieldTypeId == null and engineId != null and isCommon == 1 and status == 1">
and r.engine_id is null
and f.is_common = 1
and r.status = 1
</if>
<if test="fieldTypeId != null and engineId != null and isCommon == 1 and status == 1">
and f.field_typeid = #{fieldTypeId}
and r.engine_id is null
and f.is_common = 1
and r.status = 1
</if>
<if test="fieldTypeId != null and engineId != null and isCommon == 0 and status == null">
and f.field_typeid = #{fieldTypeId}
and r.engine_id = #{engineId}
and r.status != -1
</if>
<if test="fieldTypeId == null and engineId != null and isCommon == 0 and status == -1">
and r.engine_id = #{engineId}
and r.status = -1
</if>
order by f.created desc
</select>
-->
<sql id="Base_Column">
id, field_en, field_cn, field_typeid, value_type, value_scope, is_derivative, is_output, is_common, formula, formula_show, used_fieldid, orig_fieldid, author, created, is_use_sql, data_source_id, sql_statement, sql_variable, is_interface, interface_id, interface_parse_field, json_value,dict_variable
</sql>
<select id="findByFieldType" parameterType="java.util.Map" resultType="com.risk.riskmanage.datamanage.model.Field">
select f.id, f.field_en as fieldEn, f.field_cn as fieldCn, f.field_typeid as fieldTypeId
, p.field_type as fieldType
, f.value_type as valueType, f.value_scope as valueScope
, f.is_derivative as isDerivative
, f.is_output as isOutput
, f.is_common as isCommon, f.formula, f.formula_show as formulaShow
, f.author, u.nick_name as nickName ,f.created
, r.status
, f.is_use_sql, f.data_source_id, f.sql_statement
,f.is_interface,f.interface_id
,f.interface_parse_field
,f.json_value
,f.dict_variable
from t_field f, t_field_user_rel r, t_field_type p, t_user u
where f.id = r.field_id
and f.field_typeid = p.id
and r.user_id = u.user_id
and r.organ_id = ( select organ_id from t_user where user_id = #{userId} )
<if test="searchKey != null">
and (f.field_en like '%${searchKey}%' or f.field_cn like '%${searchKey}%' )
</if>
<if test="fieldTypeId == null and engineId == null and isCommon == 1 and status == null">
and r.engine_id is null
and f.is_common = 1
and r.status != -1
</if>
<if test="fieldTypeId != null and engineId == null and isCommon == 1 and status == null">
and f.field_typeid = #{fieldTypeId}
and r.engine_id is null
and f.is_common = 1
and r.status != -1
</if>
<if test="fieldTypeId == null and engineId != null and isCommon == 0 and status == null">
and r.engine_id = #{engineId}
and r.status != -1
</if>
<if test="fieldTypeId == null and engineId != null and isCommon == 1 and status == 1">
and r.engine_id is null
and f.is_common = 1
and r.status = 1
</if>
<if test="fieldTypeId != null and engineId != null and isCommon == 1 and status == 1">
and f.field_typeid = #{fieldTypeId}
and r.engine_id is null
and f.is_common = 1
and r.status = 1
</if>
<if test="fieldTypeId != null and engineId != null and isCommon == 0 and status == null">
and f.field_typeid = #{fieldTypeId}
and r.engine_id = #{engineId}
and r.status != -1
</if>
<if test="fieldTypeId == null and engineId != null and isCommon == 0 and status == -1">
and r.engine_id = #{engineId}
and r.status = -1
</if>
<if test="fType == 1">
AND f.is_use_sql = FALSE
AND f.is_derivative = FALSE
AND f.is_interface = FALSE
</if>
<if test="fType == 2">
AND f.is_use_sql = TRUE
</if>
<if test="fType == 3">
AND f.is_derivative = TRUE
</if>
<if test="fType == 4">
AND f.is_interface = TRUE
</if>
AND f.is_common = 1
<if test="fieldTypeId != null">
AND f.field_typeid = #{fieldTypeId}
</if>
ORDER BY f.created DESC
</select>
<select id="searchByName" parameterType="map" resultType="field">
select f.id, f.field_en as fieldEn, f.field_cn as fieldCn, f.field_typeid as fieldTypeId
, p.field_type as fieldType
, f.value_type as valueType, f.value_scope as valueScope
, f.is_derivative as isDerivative
, f.is_output as isOutput
, f.is_common as isCommon, f.formula, f.formula_show as formulaShow
, f.author, u.nick_name as nickName ,f.created
, r.status
,f.is_interface,f.interface_id
,f.interface_parse_field
,f.json_value
,f.dict_variable
from t_field f, t_field_user_rel r, t_field_type p, t_user u
where f.id = r.field_id and f.field_typeid = p.id and r.user_id = u.user_id
<if test="searchKey != null">
and f.field_cn like '%${searchKey}%'
</if>
and r.status = 1
and r.organ_id = ( select organ_id from t_user where user_id = #{userId} )
<if test="engineId != null">
and r.engine_id = #{engineId}
</if>
<if test="engineId == null">
and r.engine_id is null
</if>
</select>
<select id="findFieldTypeId" parameterType="map" resultType="long">
select distinct f.field_typeid as fieldTypeId
from t_field f,t_field_user_rel r
where f.id = r.field_id
and r.organ_id = ( select organ_id from t_user where user_id = #{userId} )
<if test="engineId != null">
and r.engine_id = #{engineId}
</if>
<if test="engineId == null">
and r.engine_id is null
</if>
and r.field_id in
<foreach collection="Ids" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
</select>
<select id="findFieldTypeIdById" parameterType="map" resultType="long">
select distinct f.field_typeid as fieldTypeId
from t_field f,t_field_user_rel r
where f.id = r.field_id
and r.organ_id = ( select organ_id from t_user where user_id = #{userId} )
<if test="engineId != null">
and r.engine_id = #{engineId}
</if>
<if test="engineId == null">
and r.engine_id is null
</if>
and r.field_id in
<foreach collection="Ids" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
</select>
<select id="findFieldTypeIdsByFieldId" parameterType="map" resultType="String">
select group_concat(distinct(f.field_typeid)) as parentId
from t_field f,t_field_user_rel r
where f.id = r.field_id
and r.organ_id = ( select organ_id from t_user where user_id = #{userId} )
and r.engine_id = #{engineId}
and f.id in
<foreach collection="Ids" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
</select>
<select id="findByUser" parameterType="map" resultType="com.risk.riskmanage.datamanage.model.Field">
select f.id
, r.id as fieldRelId
, f.field_en as fieldEn
, f.field_cn as fieldCn
, f.field_typeid as fieldTypeId
, f.value_type as valueType
, f.value_scope as valueScope
, p.field_type as fieldType
, f.is_derivative
, f.is_output
, f.is_common
, f.formula
, f.formula_show
, f.used_fieldid
, f.orig_fieldid
, f.author
, f.is_use_sql
, f.data_source_id
, f.sql_statement
, f.sql_variable
, f.is_interface
, f.interface_id
, f.interface_parse_field
, f.json_value
,f.dict_variable
from t_field f,t_field_user_rel r,t_field_type p
where f.id = r.field_id
and f.field_typeid = p.id
and r.status = 1
and r.organ_id = ( select organ_id from t_user where user_id = #{userId} )
<if test="searchKey != null">
and f.field_cn like '%${searchKey}%'
</if>
<if test="engineId != null">
and r.engine_id = #{engineId}
</if>
<if test="engineId == null">
and r.engine_id is null
</if>
<if test="fieldId != null">
and f.id != #{fieldId}
</if>
ORDER BY f.created DESC
</select>
<select id="countByParams" parameterType="map" resultType="java.lang.Integer">
select count(f.id)
from t_field f,t_field_user_rel r
where f.id = r.field_id
<if test="searchKey != null">
and f.field_en like '%${searchKey}%'
</if>
and f.field_typeid = #{fieldTypeId}
and r.status = 1
and r.organ_id = ( select organ_id from t_user where user_id = #{userId} )
<if test="engineId != null">
and r.engine_id = #{engineId}
</if>
<if test="engineId == null">
and r.engine_id is null
</if>
</select>
<select id="findByFieldId" parameterType="map" resultMap="fieldMap">
select f.id, f.field_en, f.field_cn, f.field_typeid
, f.value_type, f.value_scope, f.is_derivative
, f.is_output, f.is_common, f.formula, f.formula_show
, f.orig_fieldid, used_fieldid
, r.engine_id
, p.field_type
, f.is_use_sql
, f.data_source_id
, f.sql_statement
, f.sql_variable
,f.is_interface
,f.interface_id
,f.json_value
,f.interface_parse_field
,f.dict_variable
from t_field f,t_field_user_rel r,t_field_type p
where f.id = r.field_id
and f.field_typeid = p.id
and r.organ_id = ( select organ_id from t_user where user_id = #{userId} )
<if test="engineId != null">
and r.engine_id = #{engineId}
</if>
<if test="engineId == null">
and r.engine_id is null
</if>
and f.id = #{id}
</select>
<select id="findByFieldIdbyorganId" parameterType="map" resultMap="fieldMap">
select f.id, f.field_en as field_en, f.field_cn as field_cn, f.field_typeid as field_typeid
, f.value_type as value_type, f.value_scope as value_scope, f.is_derivative as is_derivative
, f.is_output as is_output, f.is_common as is_common, f.formula, f.formula_show as formula_show
, f.orig_fieldid as orig_fieldid, used_fieldid as used_fieldid
, r.engine_id as engine_id
, p.field_type as field_type
,f.is_interface,f.interface_id
,f.interface_parse_field
,f.json_value
,f.dict_variable
from t_field f,t_field_user_rel r,t_field_type p
where f.id = r.field_id
and f.field_typeid = p.id
and r.organ_id = #{organId}
<if test="engineId != null">
and r.engine_id = #{engineId}
</if>
<if test="engineId == null">
and r.engine_id is null
</if>
and f.id = #{id}
</select>
<select id="findFieldByIds" parameterType="map" resultMap="fieldMap">
select f.id, f.field_en as fieldEn, f.field_cn as fieldCn, f.field_typeid as fieldTypeId
, f.value_type as valueType, f.value_scope as valueScope, f.is_derivative as isDerivative
, f.is_output as isOutput, f.is_common as isCommon, f.formula, f.formula_show as formulaShow
, r.engine_id as engineId
, f.orig_fieldid as origFieldId
, p.field_type as fieldType
,f.is_interface,f.interface_id
,f.interface_parse_field
,f.json_value
,f.dict_variable
from t_field f,t_field_user_rel r,t_field_type p
where f.id = r.field_id
and f.field_typeid = p.id
and r.organ_id = ( select organ_id from t_user where user_id = #{userId} )
<if test="engineId != null">
and r.engine_id = #{engineId}
</if>
<if test="isDerivative != null">
and f.is_derivative = #{isDerivative}
</if>
<if test="engineId == null">
and r.engine_id is null
</if>
and f.id in
<foreach collection="Ids" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
</select>
<select id="findFieldByIdsbyorganId" parameterType="map" resultMap="fieldMap">
select f.id, f.field_en as fieldEn, f.field_cn as fieldCn, f.field_typeid as fieldTypeId
, f.value_type as valueType, f.value_scope as valueScope, f.is_derivative as isDerivative
, f.is_output as isOutput, f.is_common as isCommon, f.formula, f.formula_show as formulaShow
, r.engine_id as engineId
, f.orig_fieldid as origFieldId
, p.field_type as fieldType
,f.is_interface,f.interface_id
,f.interface_parse_field
,f.json_value
,f.dict_variable
from t_field f,t_field_user_rel r,t_field_type p
where f.id = r.field_id
and f.field_typeid = p.id
and r.organ_id = #{organId}
<if test="engineId != null">
and r.engine_id = #{engineId}
</if>
<if test="isDerivative != null">
and f.is_derivative = #{isDerivative}
</if>
<if test="engineId == null">
and r.engine_id is null
</if>
and f.id in
<foreach collection="Ids" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
</select>
<select id="findFieldIdsByTypeIds" parameterType="map" resultType="String">
select group_concat(f.id) as id
from t_field f,t_field_user_rel r
where f.id = r.field_id
and r.organ_id = ( select organ_id from t_user where user_id = #{userId} )
and r.status in (0,1)
and r.engine_id = #{engineId}
and f.field_typeid in
<foreach collection="fieldTypeIds" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
</select>
<select id="findFieldByIdsForCheckField" parameterType="map" resultMap="fieldMap">
select f.id, f.field_en as fieldEn, f.field_cn as fieldCn, f.field_typeid as fieldTypeId
, f.value_type as valueType, f.value_scope as valueScope, f.is_derivative as isDerivative
, f.is_output as isOutput, f.is_common as isCommon, f.formula, f.formula_show as formulaShow
, r.engine_id as engineId, e.name as engineName
, p.field_type as fieldType
,f.is_interface,f.interface_id
,f.interface_parse_field
,f.json_value
,f.dict_variable
from t_field f,t_field_type p
,t_field_user_rel r left join t_engine e on (r.engine_id = e.id)
where f.id = r.field_id
and f.field_typeid = p.id
and r.organ_id = ( select organ_id from t_user where user_id = #{userId} )
<if test="engineId != null">
and r.engine_id = #{engineId}
</if>
<if test="engineId == null">
and ( (f.is_common = 0 and r.engine_id is not null) or (f.is_common = 1 and r.engine_id is null) )
</if>
and f.id in
<foreach collection="Ids" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
</select>
<select id="isExists" parameterType="map" resultType="java.lang.Integer">
select count(f.id)
from t_field f,t_field_user_rel r
where f.id = r.field_id
and r.status != -1
<if test="fieldEn != null">
and f.field_en = #{fieldEn}
</if>
<if test="fieldCn != null">
and f.field_cn = #{fieldCn}
</if>
and r.organ_id = ( select organ_id from t_user where user_id = #{userId} )
<if test="engineId != null">
and r.engine_id = #{engineId}
</if>
<if test="engineId == null">
and r.engine_id is null
</if>
<if test="Id != null">
and f.id != #{Id}
</if>
</select>
<select id="findByFieldName" parameterType="map" resultType="Field">
select f.id, f.field_en as fieldEn, f.field_cn as fieldCn, f.field_typeid as fieldTypeId
, f.value_type as valueType, f.value_scope as valueScope, f.is_derivative as isDerivative
, f.is_output as isOutput, f.is_common as isCommon, f.formula, f.formula_show as formulaShow
,f.is_interface,f.interface_id
,f.interface_parse_field
,f.json_value
,f.dict_variable
from t_field f,t_field_user_rel r
where f.id = r.field_id
and (f.field_en = #{fieldEn} or f.field_cn = #{fieldCn})
and r.organ_id = ( select organ_id from t_user where user_id = #{userId} )
<if test="engineId != null">
and r.engine_id = #{engineId}
</if>
<if test="engineId == null">
and r.engine_id is null
</if>
</select>
<insert id="createField" useGeneratedKeys="true" keyProperty="id" parameterType="com.risk.riskmanage.datamanage.model.Field">
insert into t_field ( field_en, field_cn, field_typeid
, value_type, value_scope, is_derivative
, is_output, formula, formula_show, orig_fieldid, used_fieldid
, is_common, author, created, is_use_sql, data_source_id, sql_statement, sql_variable
, is_interface, interface_id, interface_parse_field, json_value, organ_id,dict_variable)
values ( #{fieldEn}, #{fieldCn}, #{fieldTypeId}
, #{valueType}, #{valueScope}, #{isDerivative}
, #{isOutput}, #{formula}, #{formulaShow}, #{origFieldId}, #{usedFieldId}
, #{isCommon}, #{author}, now(), #{isUseSql}, #{dataSourceId}, #{sqlStatement}, #{sqlVariable}
, #{isInterface}, #{interfaceId}, #{interfaceParseField}, #{jsonValue}, #{organId},#{dictVariable})
</insert>
<insert id="batchCreateField" parameterType="java.util.List">
insert into t_field ( field_en, field_cn, field_typeid
, value_type, value_scope, is_derivative
, is_output, formula, formula_show, is_common, author, created,
, is_interface, interface_id, interface_parse_field, json_value,dict_variable)
values
<foreach collection="list" item="field" index="index" separator=",">
(
#{field.fieldEn}, #{field.fieldCn}, #{field.fieldTypeId}
, #{field.valueType}, #{field.valueScope}, #{field.isDerivative}
, #{field.isOutput}, #{field.formula}, #{field.formulaShow}, #{field.isCommon}, #{field.author}, now()
, #{isInterface}, #{interfaceId}, #{interfaceParseField}, #{jsonValue},#{dictVariable}
)
</foreach>
</insert>
<update id="updateField" parameterType="java.util.Map">
update t_field
set field_en = #{fieldEn}, field_cn = #{fieldCn}, field_typeid = #{fieldTypeId}
, value_type = #{valueType}, value_scope = #{valueScope}, is_derivative = #{isDerivative}
, is_output = #{isOutput}, formula = #{formula}, formula_show = #{formulaShow}
, orig_fieldid = #{origFieldId}, used_fieldid = #{usedFieldId}, is_common = #{isCommon}
, is_use_sql = #{isUseSql}, data_source_id = #{dataSourceId}, sql_statement = #{sqlStatement}, sql_variable = #{sqlVariable}
,is_interface = #{isInterface}, interface_id = #{interfaceId}, interface_parse_field = #{interfaceParseField}, json_value = #{jsonValue},dict_variable = #{dictVariable}
where id = #{id}
<!-- where id = (select field_id-->
<!-- from t_field_user_rel-->
<!-- where organ_id = ( select organ_id from t_user where user_id = #{userId} )-->
<!-- <if test="engineId != null">-->
<!-- and engine_id = #{engineId}-->
<!-- </if>-->
<!-- <if test="engineId == null">-->
<!-- and engine_id is null-->
<!-- </if>-->
<!-- and field_id = #{id}-->
<!-- )-->
</update>
<select id = "getFieldList" parameterType="map" resultType="com.risk.riskmanage.datamanage.model.Field">
select
t.id,
t.field_en as fieldEn,
t.field_cn as fieldCn,
t.field_typeid as fieldTypeId,
t.value_type as valueType,
t.value_scope as valueScope,
t.is_output as isOutput,
r.id as fieldRelId,
p.field_type as fieldType
,t.is_interface,t.interface_id
,t.interface_parse_field
,t.json_value
,t.dict_variable
from t_field t LEFT JOIN t_field_user_rel r on t.id = r.field_id LEFT JOIN t_field_type p on t.field_typeid = p.id where r.organ_id = #{organId} and status = 1
<if test="ids != null and ids !=''">
and t.id in (ids)
</if>
<if test="searchKey != null">
and t.field_cn like CONCAT('%',#{searchKey},'%' )
</if>
<if test="isOutput != null">
and t.is_output = #{isOutput}
</if>
<if test="engineId != null and engineId!=''">
and r.engine_id = #{engineId}
</if>
<if test="valueType != null">
and t.value_type = #{valueType}
</if>
<if test="engineId == null">
and r.engine_id is null
</if>
</select>
<select id="findByFieldEnbyorganId" parameterType="map" resultMap="fieldMap">
select f.id, f.field_en as fieldEn, f.field_cn as fieldCn, f.field_typeid as fieldTypeId
, f.value_type as valueType, f.value_scope as valueScope, f.is_derivative as isDerivative
, f.is_output as isOutput, f.is_common as isCommon, f.formula, f.formula_show as formulaShow,f.dict_variable as dictVariable
from t_field f,t_field_user_rel r
where f.id = r.field_id
and f.field_en = #{fieldEn}
and r.organ_id = #{organId}
and r.engine_id = #{engineId}
and r.status = 1
</select>
<select id="findByFieldEn" parameterType="map" resultMap="fieldMap">
select f.id, f.field_en as fieldEn, f.field_cn as fieldCn, f.field_typeid as fieldTypeId
, f.value_type as valueType, f.value_scope as valueScope, f.is_derivative as isDerivative
, f.is_output as isOutput, f.is_common as isCommon, f.formula, f.formula_show as formulaShow,f.dict_variable as dictVariable
from t_field f,t_field_user_rel r
where f.id = r.field_id
and f.field_en = #{fieldEn}
and r.organ_id = ( select organ_id from t_user where user_id = #{userId} )
and r.engine_id = #{engineId}
and r.status = 1
</select>
<select id="findByFieldCn" parameterType="map" resultMap="fieldMap">
select f.id, f.field_en, f.field_cn, f.field_typeid
, f.value_type, f.value_scope, f.is_derivative
, f.is_output, f.is_common, f.formula, f.formula_show
, f.orig_fieldid,f.dict_variable
from t_field f,t_field_user_rel r
where f.id = r.field_id
and f.field_cn = #{fieldCn}
and r.organ_id = ( select organ_id from t_user where user_id = #{userId} )
<if test="engineId != null">
and r.engine_id = #{engineId}
</if>
<if test="engineId == null">
and r.engine_id is null
</if>
and r.status = 1
</select>
<select id="findByFieldCnbyorganId" parameterType="map" resultMap="fieldMap">
select f.id, f.field_en as fieldEn, f.field_cn as fieldCn, f.field_typeid as fieldTypeId
, f.value_type as valueType, f.value_scope as valueScope, f.is_derivative as isDerivative
, f.is_output as isOutput, f.is_common as isCommon, f.formula, f.formula_show as formulaShow
, f.orig_fieldid as origFieldId,f.dict_variable as dictVariable
from t_field f,t_field_user_rel r
where f.id = r.field_id
and f.field_cn = #{fieldCn}
and r.organ_id = #{organId}
<if test="engineId != null">
and r.engine_id = #{engineId}
</if>
<if test="engineId == null">
and r.engine_id is null
</if>
and r.status = 1
</select>
<select id="checkField" parameterType="map" resultType="String">
select group_concat(f.id) as ids
from t_field f,t_field_user_rel r
where f.id = r.field_id
<if test="engineId != null">
and r.engine_id = #{engineId}
</if>
and r.organ_id = ( select organ_id from t_user where user_id = #{userId} )
and r.status = 1 and instr(f.used_fieldid,#{fieldId}) > 0
</select>
<select id="findByFieldCnNoEngineId" parameterType="map" resultMap="fieldMap">
select f.id, f.field_en as fieldEn, f.field_cn as fieldCn, f.field_typeid as fieldTypeId
, f.value_type as valueType, f.value_scope as valueScope, f.is_derivative as isDerivative
, f.is_output as isOutput, f.is_common as isCommon, f.formula, f.formula_show as formulaShow
, f.orig_fieldid as origFieldId,f.dict_variable as dictVariable
from t_field f,t_field_user_rel r
where f.id = r.field_id
and f.field_cn = #{fieldCn}
and r.organ_id = ( select organ_id from t_user where user_id = #{userId} )
and r.engine_id is null
and r.status = 1
</select>
<select id="findByFieldCnNoEngineIdbyorganId" parameterType="map" resultMap="fieldMap">
select f.id, f.field_en as fieldEn, f.field_cn as fieldCn, f.field_typeid as fieldTypeId
, f.value_type as valueType, f.value_scope as valueScope, f.is_derivative as isDerivative
, f.is_output as isOutput, f.is_common as isCommon, f.formula, f.formula_show as formulaShow
, f.orig_fieldid as origFieldId,f.dict_variable as dictVariable
from t_field f,t_field_user_rel r
where f.id = r.field_id
and f.field_cn = #{fieldCn}
and r.organ_id = #{organId}
and r.engine_id is null
and r.status = 1
</select>
<select id="findByFieldIdNoEngineId" parameterType="map" resultMap="fieldMap">
select f.id, f.field_en as fieldEn, f.field_cn as fieldCn, f.field_typeid as fieldTypeId
, f.value_type as valueType, f.value_scope as valueScope, f.is_derivative as isDerivative
, f.is_output as isOutput, f.is_common as isCommon, f.formula, f.formula_show as formulaShow
, f.orig_fieldid as origFieldId
, r.engine_id as engineId
, p.field_type as fieldType
,f.dict_variable as dictVariable
from t_field f,t_field_user_rel r,t_field_type p
where f.id = r.field_id
and f.field_typeid = p.id
and r.organ_id = ( select organ_id from t_user where user_id = #{userId} )
and r.engine_id is null
and f.id = #{id}
</select>
<select id="findFieldByIdsAndIsderivative" parameterType="map" resultMap="fieldMap">
select f.id, f.field_en as fieldEn, f.field_cn as fieldCn, f.field_typeid as fieldTypeId
, f.value_type as valueType, f.value_scope as valueScope, f.is_derivative as isDerivative
, f.is_output as isOutput, f.is_common as isCommon, f.formula, f.formula_show as formulaShow,f.dict_variable as dictVariable
from t_field f
where
is_derivative=#{isDerivative}
and f.id in
<foreach collection="Ids" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
</select>
<select id="findExcelByFieldType" parameterType="map" resultType="com.risk.riskmanage.datamanage.model.Field">
select f.id, f.field_en as fieldEn, f.field_cn as fieldCn, t.field_type as fieldType
, f.value_type as valueType,f.dict_variable as dictVariable
, CASE WHEN f.value_type=1 THEN '数值型' WHEN f.value_type=2 THEN '字符型' WHEN f.value_type=3 THEN '枚举型' WHEN f.value_type=4 THEN '小数型' END valueTypeName
, f.value_scope as valueScope
, f.is_derivative as isDerivative
, CASE WHEN f.is_derivative=0 THEN 'N' WHEN f.is_derivative=1 THEN 'Y' END isDerivativeName
, f.is_output as isOutput
, CASE WHEN f.is_output=0 THEN 'N' WHEN f.is_output=1 THEN 'Y' END isOutputName
, f.formula, u.nick_name as nickName, f.created
from t_field f,t_field_user_rel r,t_field_type t,t_user u
where f.id = r.field_id
and f.field_typeid = t.id
and r.organ_id = ( select organ_id from t_user where user_id = #{userId} )
and f.author = u.user_id
<if test="searchKey != null">
and f.field_en like '%${searchKey}%'
</if>
<if test="fieldTypeId != null">
and f.field_typeid = #{fieldTypeId}
</if>
<if test="engineId != null">
and r.engine_id = #{engineId}
</if>
<if test="engineId == null">
and r.engine_id is null
</if>
</select>
<select id="getSourceField" parameterType="map" resultType="String">
select used_fieldid as usedFieldId,orig_fieldid as origFieldId
from t_field f,t_field_user_rel r
where f.id = r.field_id
and r.organ_id = ( select organ_id from t_user where user_id = #{userId} )
and f.id = #{fieldId}
and r.engine_id is null
</select>
<select id="findOrgFieldTypeIdsByIds" parameterType="map" resultType="String">
select group_concat(distinct(f.field_typeid))
from t_field f,t_field_user_rel r
where f.id = r.field_id
and r.organ_id = ( select organ_id from t_user where user_id = #{userId} )
and f.id in
<foreach collection="fieldIds" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
and r.engine_id is null
</select>
<select id="findOrgFieldIdsByTypeIds" parameterType="map" resultType="String">
select group_concat(f.id) as id
from t_field f,t_field_user_rel r
where f.id = r.field_id
and r.organ_id = ( select organ_id from t_user where user_id = #{userId} )
and r.status = 1
and f.field_typeid in
<foreach collection="fieldTypeIds" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
and r.engine_id is null
</select>
<select id="findFieldNameById" parameterType="long" resultType="string">
select t_field.field_en
from t_field
where id = #{fieldId}
</select>
<update id="updateFieldFolder">
update t_field
set field_typeid = #{folderId}
where id in
<foreach collection="ids" item="id" separator="," open="(" close=")">
#{id}
</foreach>
</update>
<select id="selectByIds" resultType="com.risk.riskmanage.datamanage.model.Field">
select
<include refid="Base_Column" ></include>
from t_field
where id in
<foreach collection="ids" open="(" close=")" separator="," item="id">
#{id}
</foreach>
</select>
<select id="selectByEns" resultType="com.risk.riskmanage.datamanage.model.Field">
select
<include refid="Base_Column"></include>
from t_field
where field_en in
<foreach collection="ens" open="(" close=")" separator="," item="en">
#{en}
</foreach>
</select>
<select id="selectByOrganCns" resultType="com.risk.riskmanage.datamanage.model.Field">
select
<include refid="Base_Column"></include>
from t_field
where organ_id = #{organId}
and field_cn in
<foreach collection="cns" open="(" close=")" separator="," item="cn">
#{cn}
</foreach>
</select>
</mapper>

View File

@@ -0,0 +1,196 @@
<?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.risk.riskmanage.datamanage.mapper.FieldTypeMapper">
<cache></cache>
<resultMap type="com.risk.riskmanage.datamanage.model.FieldType" id="fieldTypeMap">
<id column="id" property="id"/>
<result column="field_type" property="fieldType"/>
<result column="parent_id" property="parentId"/>
<result column="is_common" property="isCommon"/>
<result column="type" property="type"/>
</resultMap>
<select id="getFieldTypeList" parameterType="map" resultType="fieldType">
select r.field_typeid as id,t.field_type as fieldType,t.parent_id as parentId,t.is_common as isCommon,#{engineId} as engineId
from t_field_type_user_rel r, t_field_type t
where r.field_typeid = t.id
and r.organ_id = ( select organ_id from t_user where user_id = #{userId} )
<if test="isCommon != null">
and t.is_common = #{isCommon}
</if>
<if test="engineId == null">
and r.engine_id is null
</if>
<if test="engineId != null">
and r.engine_id = #{engineId}
</if>
<if test="parentId == null">
and t.parent_id = 0
</if>
<if test="parentId != null">
and t.parent_id = #{parentId}
</if>
<if test="status != null">
and r.status = #{status}
</if>
order by t.is_common desc,r.created,t.id
</select>
<select id='findIdByFieldType' parameterType="map" resultType="java.lang.Long">
select IFNULL(MAX(t.id),0) as id
from t_field_type t,t_field_type_user_rel r
where t.id = r.field_typeid
and t.field_type = #{fieldType}
and r.organ_id = ( select organ_id from t_user where user_id = #{userId} )
<if test="engineId != null">
and r.engine_id = #{engineId}
</if>
<if test="engineId == null">
and r.engine_id is null
</if>
<if test="parentId == null">
and t.parent_id = 0
</if>
<if test="parentId != null">
and t.parent_id = #{parentId}
</if>
</select>
<select id='findFieldTypeById' parameterType="java.lang.Integer" resultType="fieldType">
select id, field_type as fieldType, parent_id as parentId
from t_field_type
where id = #{id}
</select>
<select id='findTypeIdByParentId' parameterType="map" resultType="String">
select group_concat(t.id) as id
from t_field_type t,t_field_type_user_rel r
where t.id = r.field_typeid
and r.organ_id = ( select organ_id from t_user where user_id = #{userId} )
and r.engine_id = #{engineId}
and t.parent_id = #{parentId}
</select>
<select id='findParentIdByTypeId' parameterType="map" resultType="String">
select t.parent_id as parentId
from t_field_type t,t_field_type_user_rel r
where t.id = r.field_typeid
and r.organ_id = ( select organ_id from t_user where user_id = #{userId} )
<if test="engineId != null">
and r.engine_id = #{engineId}
</if>
<if test="engineId == null">
and r.engine_id is null
</if>
and t.id = ${fieldTypeId}
</select>
<select id='findFieldType' parameterType="java.lang.Integer" resultType="fieldType">
select t.id, t.field_type as fieldType, t.parent_id as parentId
from t_field_type t,t_field_type_user_rel r
where t.id = r.field_typeid
and r.organ_id = ( select organ_id from t_user where user_id = #{userId} )
<if test="engineId != null">
and r.engine_id = #{engineId}
and r.field_typeid not in ( select field_typeid from t_field_type_user_rel where engine_id is null )
</if>
<if test="engineId == null">
and r.engine_id is null
</if>
</select>
<insert id="createFieldType" useGeneratedKeys="true" keyProperty="id" parameterType="fieldType">
insert into t_field_type ( field_type, parent_id, is_common ,type)
values ( #{fieldType}, #{parentId}, #{isCommon} ,#{type})
</insert>
<update id="updateFieldType" parameterType="map">
update t_field_type
set field_type = #{fieldType}
where id = #{id}
</update>
<update id="updateFieldTypeByTypeIds" parameterType="map">
update t_field_type_user_rel
set status = -1
where organ_id = ( select organ_id from t_user where user_id = #{userId} )
and engine_id = #{engineId}
and field_typeid in
<foreach collection="fieldTypeIds" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
and status = 1
</update>
<update id="deleteFieldTypeByTypeIds" parameterType="map">
delete from t_field_type_user_rel
where organ_id = ( select organ_id from t_user where user_id = #{userId} )
and engine_id = #{engineId}
and field_typeid in
<foreach collection="fieldTypeIds" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
and field_typeid not in
( select field_typeid
from t_field f,t_field_user_rel r
where f.id = r.field_id
and f.field_typeid in
<foreach collection="fieldTypeIds" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
)
</update>
<update id="backFieldTypeByTypeIds" parameterType="map">
update t_field_type_user_rel
set status = 1
where organ_id = ( select organ_id from t_user where user_id = #{userId} )
and engine_id = #{engineId}
and field_typeid in
<foreach collection="fieldTypeIds" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
and status = -1
</update>
<select id="isExists" parameterType="map" resultType="java.lang.Integer">
select count(ft.id)
from t_field_type ft,t_field_type_user_rel r
where ft.id = r.field_typeid
and r.organ_id = ( select organ_id from t_user where user_id = #{userId} )
and ft.field_type = #{fieldType}
<if test="Id != null">
and ft.id != #{Id}
</if>
<if test="engineId != null">
and r.engine_id = #{engineId}
</if>
<if test="engineId == null">
and r.engine_id is null
</if>
and ft.parent_id = #{parentId}
</select>
<select id="isExistsDefaultTreeName" parameterType="map" resultType="java.lang.Integer">
select count(ft.id)
from t_field_type ft,t_field_type_user_rel r
where ft.id = r.field_typeid
and r.organ_id = ( select organ_id from t_user where user_id = #{userId} )
and ft.field_type = #{fieldType}
<if test="engineId != null">
and r.engine_id = #{engineId}
</if>
<if test="engineId == null">
and r.engine_id is null
</if>
and ft.parent_id = #{parentId}
</select>
<select id="selectFieldTypeList" resultMap="fieldTypeMap">
select id,field_type,parent_id,is_common,`type`
from t_field_type
where id in (select distinct field_typeid from t_field_type_user_rel where organ_id = #{organId} and status !=-1)
and `type` = #{type}
</select>
</mapper>

View File

@@ -0,0 +1,67 @@
<?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.risk.riskmanage.datamanage.mapper.FieldTypeUserMapper">
<cache></cache>
<resultMap type="fieldTypeUser" id="fieldTypeUserMap">
<id column="id" property="id"/>
<result column="field_typeid" property="fieldTypeId"/>
<result column="organ_id" property="organId"/>
<result column="engine_id" property="engineId"/>
<result column="user_id" property="userId"/>
</resultMap>
<insert id="createFieldTypeUserRel" useGeneratedKeys="true" keyProperty="id" parameterType="fieldTypeUser">
insert into t_field_type_user_rel ( field_typeid, organ_id, engine_id, user_id, created )
values ( #{fieldTypeId}, #{organId}, #{engineId}, #{userId}, now() )
</insert>
<insert id="batchBindEngineFieldTypeUserRel" parameterType="map">
insert into t_field_type_user_rel ( field_typeid, organ_id, engine_id, user_id, created )
select field_typeid, organ_id, #{engineId}, #{userId}, now()
from t_field_type_user_rel r
where r.field_typeid in
<foreach collection="fieldTypeIds" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
and field_typeid not in ( select field_typeid from t_field_type_user_rel where engine_id = #{engineId})
and engine_id is null
</insert>
<select id="findNodeIds" parameterType="map" resultType="String">
select group_concat(field_typeid)
from t_field_type_user_rel x
where organ_id = ( select organ_id from t_user where user_id = #{userId} )
and engine_id = #{engineId}
and exists (select field_typeid
from t_field_type_user_rel y
where x.field_typeid = y.field_typeid
and y.organ_id = ( select organ_id from t_user where user_id = #{userId} )
and y.engine_id is null
)
</select>
<insert id="deleteFieldTypeUserRel" parameterType="map">
delete from t_field_type_user_rel
where
organ_id = ( select organ_id from t_user where user_id = #{userId} )
<if test="engineId != null">
and engine_id = #{engineId}
</if>
<if test="engineId == null">
and engine_id is null
</if>
and field_typeid = #{fieldTypeId}
</insert>
<update id="updateFieldTypeUserRel" >
update t_field_type_user_rel
set user_id = #{userId}, created = now()
<if test="status != null">
,status = #{status}
</if>
where organ_id =#{organId}
and field_typeid = #{id}
</update>
</mapper>

View File

@@ -0,0 +1,117 @@
<?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.risk.riskmanage.datamanage.mapper.FieldUserMapper">
<cache></cache>
<resultMap type="fieldUser" id="fieldUserMap">
<id column="id" property="id"/>
<result column="field_id" property="fieldId"/>
<result column="organ_id" property="organId"/>
<result column="engine_id" property="engineId"/>
<result column="user_id" property="userId"/>
<result column="status" property="status"/>
</resultMap>
<insert id="createFieldUserRel" useGeneratedKeys="true" keyProperty="id" parameterType="fieldUser">
insert into t_field_user_rel (field_id, organ_id, engine_id, user_id, status, created, updated)
values (#{fieldId}, #{organId}, #{engineId}, #{userId}, #{status}, now(), now())
</insert>
<insert id="batchCreateFieldUserRel" parameterType="map">
insert into t_field_user_rel (field_id, organ_id, engine_id, user_id, status, created, updated)
select id, #{organId}, #{engineId}, #{userId}, #{status}, now(), now()
from t_field t
where t.author = #{author}
and not exists ( select r.field_id from t_field_user_rel r where t.id = r.field_id )
</insert>
<insert id="batchCreateEngineFieldUserRel" parameterType="map">
insert into t_field_user_rel (field_id, organ_id, engine_id, user_id, status, created, updated)
select id, #{organId}, #{engineId}, #{userId}, #{status}, now(), now()
from t_field f
where f.field_typeid in
<foreach collection="fieldTypeIds" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
and not exists ( select 1
from ( select f.id,f.field_en,f.field_cn
from t_field f,t_field_user_rel fu
where f.id = fu.field_id
and fu.organ_id = ( select organ_id from t_user where user_id = #{userId} )
and fu.engine_id = ${engineId} )y
where f.field_en = y.field_en or f.field_cn = y.field_cn or f.id = y.id
)
</insert>
<insert id="batchBindEngineFieldUserRel" parameterType="map">
insert into t_field_user_rel (field_id, organ_id, engine_id, user_id, status, created, updated)
select id, #{organId}, #{engineId}, #{userId}, 1, now(), now()
from t_field f
where f.id in
<foreach collection="fieldIds" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
and not exists ( select 1
from ( select f.id,f.field_en,f.field_cn
from t_field f,t_field_user_rel fu
where f.id = fu.field_id
and fu.organ_id = ( select organ_id from t_user where user_id = #{userId} )
and fu.engine_id = ${engineId} )y
where f.field_en = y.field_en or f.field_cn = y.field_cn or f.id = y.id
)
</insert>
<update id="updateFieldUserRel" parameterType="map">
update t_field_user_rel
set user_id = #{userId} , updated = now()
where organ_id = ( select organ_id from t_user where user_id = #{userId} )
<if test="engineId != null">
and engine_id = #{engineId}
</if>
<if test="engineId == null">
and engine_id is null
</if>
and field_id = #{Id}
</update>
<update id="updateStatus" parameterType="map">
update t_field_user_rel
set status=#{status}
where organ_id = ( select organ_id from t_user where user_id = #{userId} )
<if test="engineId != null">
and engine_id = #{engineId}
</if>
<if test="engineId == null and status!=-1 and status!=0">
and engine_id is null
</if>
and field_id in
<foreach collection="Ids" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
</update>
<update id="deleteFieldByIds" parameterType="map">
update t_field_user_rel
set status = -1
where organ_id = ( select organ_id from t_user where user_id = #{userId} )
and engine_id = #{engineId}
and field_id in
<foreach collection="fieldIds" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
and status = 1
</update>
<update id="backFieldByIds" parameterType="map">
update t_field_user_rel
set status = 1
where organ_id = ( select organ_id from t_user where user_id = #{userId} )
and engine_id = #{engineId}
and field_id in
<foreach collection="Ids" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
and status = -1
</update>
</mapper>

View File

@@ -0,0 +1,75 @@
<?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.risk.riskmanage.interfacemanage.mapper.InterfaceMapper">
<resultMap type="com.risk.riskmanage.interfacemanage.model.InterfaceInfo" id="InterfaceMap">
<result property="id" column="id" jdbcType="INTEGER"/>
<result property="name" column="name" jdbcType="VARCHAR"/>
<result property="url" column="url" jdbcType="VARCHAR"/>
<result property="method" column="method" jdbcType="VARCHAR"/>
<result property="requestHeaders" column="request_headers" jdbcType="VARCHAR"/>
<result property="requestBody" column="request_body" jdbcType="VARCHAR"/>
<result property="responseBody" column="response_body" jdbcType="VARCHAR"/>
<result property="status" column="status" jdbcType="INTEGER"/>
<result property="creator" column="creator" jdbcType="INTEGER"/>
<result property="modifier" column="modifier" jdbcType="INTEGER"/>
<result property="organId" column="organ_id" jdbcType="INTEGER"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
<result property="requestType" column="request_type" jdbcType="VARCHAR"/>
</resultMap>
<update id="updateStatus" >
update riskmanage.t_field_interface set status = #{status}
where id in
<foreach collection="ids" item="interfaceId" open="(" separator="," close=")">
#{interfaceId}
</foreach>
</update>
<!--查询单个-->
<select id="queryLimit" resultMap="InterfaceMap">
select *
from riskmanage.t_field_interface
limit #{start},#{size}
</select>
<select id = "queryInterfaceList" parameterType="com.risk.riskmanage.interfacemanage.model.InterfaceInfo" resultMap="InterfaceMap">
select *
from riskmanage.t_field_interface
<where>
<if test="id != null">
and id = #{id}
</if>
<if test="name != null and name != ''">
and name = #{name}
</if>
<if test="url != null and url != ''">
and url = #{url}
</if>
<if test="method != null and method != ''">
and method = #{method}
</if>
<if test="request_headers != null">
and request_headers = #{request_headers}
</if>
<if test="request_body != null">
and request_body = #{request_body}
</if>
<if test="response_body != null">
and response_body = #{response_body}
</if>
<if test="creator != null">
and creator = #{creator}
</if>
<if test="modifier != null">
and modifier = #{modifier}
</if>
<if test="organ_id != null">
and organ_id = #{organ_id}
</if>
</where>
</select>
</mapper>

View File

@@ -0,0 +1,39 @@
<?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.risk.riskmanage.knowledge.mapper.EngineRuleRelMapper">
<cache></cache>
<resultMap type="engineRuleRel" id="engineRuleRelMap">
<id column="id" property="id"/>
<result column="engine_id" property="engineId"/>
<result column="knowledge_tree_id" property="treeId"/>
</resultMap>
<sql id ="Base_Column">
id
engine_id as engineId,
rule_id as ruleId
</sql>
<select id ="getRuleIdsByEngineId" parameterType="long" resultType="long">
select rule_id from t_engine_rule_rel td where engine_id = #{engineId}
</select>
<insert id = "insertRel" parameterType="map">
insert into t_engine_rule_rel (engine_id,rule_id)
values
<foreach collection="idList" index="index" item="item" separator=",">
(#{engineId},#{item})
</foreach>
</insert>
<delete id="deleteRel" parameterType="map">
delete from t_engine_rule_rel where engine_id =#{engineId}
<if test ="idList.size() > 0">
and rule_id in
<foreach collection="idList" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
</delete>
</mapper>

View File

@@ -0,0 +1,398 @@
<?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.risk.riskmanage.knowledge.mapper.KnowledgeTreeMapper">
<cache></cache>
<resultMap type="com.risk.riskmanage.knowledge.model.KnowledgeTree" id="knowledgeTreeMap">
<id column="id" property="id"/>
<result column="name" property="name"/>
<result column="parent_id" property="parentId"/>
<result column="user_id" property="userId"/>
<result column="organ_id" property="organId"/>
<result column="engine_id" property="engineId"/>
<result column="status" property="status"/>
<result column="type" property="type"/>
<result column="tree_type" property="treeType"/>
<result column="created" property="created"/>
<result column="updated" property="updated"/>
</resultMap>
<sql id="Base_Column">
id,
name,
parent_id,
user_id,
organ_id,
engine_id,
status,
type,
tree_type,
created,
updated
</sql>
<sql id="Base_Column_1">
k.id,
k.name,
k.parent_id,
k.user_id,
k.organ_id,
k.engine_id,
k.status,
k.type,
k.tree_type,
k.created,
k.updated
</sql>
<select id="getTreeList" parameterType="Map" resultMap="knowledgeTreeMap">
<if test="type == 2">
select
<include refid="Base_Column"/>
from (
</if>
<if test="type == 2">
select
<include refid="Base_Column"/>
from t_knowledge_tree
where 1=1
<if test="parentId != null">
and parent_id = #{parentId}
</if>
<if test="status != null">
and status in
<foreach collection="status" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="tree_type != null">
and tree_type in
<foreach collection="tree_type" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
and organ_id = #{organId}
and type = 1
and id in (select knowledge_tree_id from t_engine_knowledge_tree_rel td where engine_id = #{engineId})
union
</if>
select
<include refid="Base_Column"/>
from t_knowledge_tree
where 1=1
<if test="parentId != null">
and parent_id = #{parentId}
</if>
<if test="status != null">
and status in
<foreach collection="status" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="tree_type != null">
and tree_type in
<foreach collection="tree_type" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="type == 0">
and type = 0
</if>
<if test="type == 1">
and organ_id = #{organId}
and type = 1
<if test="sort == true">
order by tree_type,id
</if>
</if>
<if test="type == 2">
and engine_id = #{engineId}
and type = 2
) y
<if test="sort == true">
order by y.tree_type,y.id
</if>
</if>
</select>
<!-- 新加的 评分卡树 -->
<select id="getTreeListV2" parameterType="Map" resultMap="knowledgeTreeMap">
select
<include refid="Base_Column"/>
from t_knowledge_tree
where 1=1
<if test="parentId != null">
and parent_id = #{parentId}
</if>
<if test="status != null">
and status in
<foreach collection="status" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="tree_type != null">
and tree_type in
<foreach collection="tree_type" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
and organ_id = #{organId}
and type = #{type}
<if test="sort == true">
order by tree_type,id
</if>
</select>
<select id="getTreeDataForEngine" parameterType="Map" resultMap="knowledgeTreeMap">
<if test="type == 2">
select
<include refid="Base_Column"/>
from (
</if>
<if test="type == 2">
select
<include refid="Base_Column_1"/>
from t_knowledge_tree k
where 1=1
<if test="parentId != null">
and k.parent_id = #{parentId}
</if>
<if test="status != null">
and k.status in
<foreach collection="status" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="tree_type != null">
and k.tree_type in
<foreach collection="tree_type" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
and k.organ_id = #{organId}
and k.type = 1
and k.id in (select knowledge_tree_id from t_engine_knowledge_tree_rel td where td.engine_id = #{engineId})
and (select count(r.parent_id) from t_rule r where r.parent_id = k.id <if
test="complexType != null and complexType == 1">and r.rule_type=1</if>) &gt; 0
union
</if>
select
<include refid="Base_Column_1"/>
from t_knowledge_tree k
where 1=1
<if test="parentId != null">
and k.parent_id = #{parentId}
</if>
<if test="status != null">
and k.status in
<foreach collection="status" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="tree_type != null">
and k.tree_type in
<foreach collection="tree_type" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="type == 0">
and k.type = 0
</if>
<if test="type == 1">
and k.organ_id = #{organId}
and k.type = 1
<if test="sort == true">
order by k.tree_type,k.id
</if>
</if>
<if test="type == 2">
and k.engine_id = #{engineId}
and k.type = 2
and (select count(r.parent_id) from t_rule r where r.parent_id = k.id <if
test="complexType != null and complexType == 1">and r.rule_type=1</if>) &gt; 0
) y
<if test="sort == true">
order by y.tree_type,y.id
</if>
</if>
</select>
<select id="getTreeDataForEngineV2" parameterType="Map" resultMap="knowledgeTreeMap">
<if test="type == 2">
select
<include refid="Base_Column"/>
from (
</if>
<if test="type == 2">
select
<include refid="Base_Column_1"/>
from t_knowledge_tree k
where 1=1
<if test="parentId != null">
and k.parent_id = #{parentId}
</if>
<if test="status != null">
and k.status in
<foreach collection="status" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="tree_type != null">
and k.tree_type in
<foreach collection="tree_type" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
and k.organ_id = #{organId}
and k.type = 1
and k.id in (select knowledge_tree_id from t_engine_knowledge_tree_rel td)
and (select count(r.parent_id) from t_rule r where r.parent_id = k.id <if
test="complexType != null and complexType == 1">and r.rule_type=1</if>) &gt; 0
union
</if>
select
<include refid="Base_Column_1"/>
from t_knowledge_tree k
where 1=1
<if test="parentId != null">
and k.parent_id = #{parentId}
</if>
<if test="status != null">
and k.status in
<foreach collection="status" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="tree_type != null">
and k.tree_type in
<foreach collection="tree_type" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="type == 0">
and k.type = 0
</if>
<if test="type == 1">
and k.organ_id = #{organId}
and k.type = 1
<if test="sort == true">
order by k.tree_type,k.id
</if>
</if>
<if test="type == 2">
and k.type = 2
and (select count(r.parent_id) from t_rule r where r.parent_id = k.id <if
test="complexType != null and complexType == 1">and r.rule_type=1</if>) &gt; 0
) y
<if test="sort == true">
order by y.tree_type,y.id
</if>
</if>
</select>
<insert id="insertSelective" parameterType="knowledgeTree" useGeneratedKeys="true" keyProperty="id">
insert into t_knowledge_tree (name,parent_id,user_id,
<if test="organId != null">
organ_id,
</if>
<if test="engineId != null">
engine_id,
</if>
status,type,tree_type,created,updated)
values(#{name},#{parentId},#{userId},
<if test="organId != null">
#{organId},
</if>
<if test="engineId != null">
#{engineId},
</if>
#{status},#{type},#{treeType},now(), now())
</insert>
<insert id="batchInsert" parameterType="java.util.List">
<foreach collection="list" index="index" item="item" separator=";">
insert into t_knowledge_tree (name,parent_id,user_id,
<if test="item.organId != null">
organ_id,
</if>
<if test="item.engineId != null">
engine_id,
</if>
status,type,tree_type,created,updated)
values(#{item.name},#{item.parentId},#{item.userId},
<if test="item.organId != null">
#{item.organId},
</if>
<if test="item.engineId != null">
#{item.engineId},
</if>
#{item.status},#{item.type},#{item.treeType},now(), now())
</foreach>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="knowledgeTree">
update t_knowledge_tree set
<if test="name != null">
name = #{name},
</if>
<if test="status != null">
status = #{status},
</if>
<if test="type != null">
type = #{type},
</if>
<if test="parentId != null">
parent_id = #{parentId},
</if>
updated = now() where id = #{id}
</update>
<select id="selectByPrimaryKey" parameterType="long" resultMap="knowledgeTreeMap">
select
<include refid="Base_Column"/>
from t_knowledge_tree where id = #{id}
</select>
<select id="getTreeId" parameterType="com.risk.riskmanage.knowledge.model.KnowledgeTree" resultType="long">
select
id
from t_knowledge_tree
<where>
<if test="name != null">
and `name` = #{name}
</if>
<if test="parentId != null">
and parent_id = #{parentId}
</if>
<if test="status != null">
and status = #{status}
</if>
<if test="tree_type != null">
and tree_type = #{treeType}
</if>
<if test="user_id != null">
and user_id = #{userId}
</if>
<if test="organ_id != null">
and organ_id = #{organId}
</if>
</where>
</select>
<select id="selectFolderList" parameterType="com.risk.riskmanage.engine.model.request.KnowledgeTreeListParam" resultMap="knowledgeTreeMap">
select id ,`name`
from t_knowledge_tree
where organ_id = #{organId}
<if test="status != null">
and status = #{status}
</if>
<if test="treeType!=null">
and tree_type = #{treeType}
</if>
</select>
</mapper>

View File

@@ -0,0 +1,33 @@
<?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.risk.riskmanage.knowledge.mapper.KnowledgeTreeRelMapper">
<cache></cache>
<resultMap type="knowledgeTreeRel" id="knowledgeTreeRelMap">
<id column="id" property="id"/>
<result column="engine_id" property="engineId"/>
<result column="knowledge_tree_id" property="treeId"/>
</resultMap>
<sql id ="Base_Column">
id
engine_id as engineId,
knowledge_tree_id as treeId
</sql>
<insert id = "insertRel" parameterType="map">
insert into t_engine_knowledge_tree_rel (engine_id,knowledge_tree_id)
values
<foreach collection="idList" index="index" item="item" separator=",">
(#{engineId},#{item})
</foreach>
</insert>
<delete id="deleteRel" parameterType="long">
delete from t_engine_knowledge_tree_rel where engine_id =#{engineId}
</delete>
<select id ="findTreeIdsByEngineId" parameterType="long" resultType ="long">
select knowledge_tree_id from t_engine_knowledge_tree_rel where engine_id =#{engineId}
</select>
</mapper>

View File

@@ -0,0 +1,72 @@
<?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.risk.riskmanage.knowledge.mapper.RuleContentMapper">
<cache></cache>
<resultMap type="com.risk.riskmanage.knowledge.model.RuleContent" id="ruleContentMap">
<id column="id" property="id"/>
<result column="field" property="field"/>
<result column="field_id" property="fieldId"/>
<result column="field_value" property="fieldValue"/>
<result column="rule_id" property="ruleId"/>
<result column="fieldEn" property="fieldEn"/>
<result column="valueType" property="valueType"/>
<result column="valueScope" property="valueScope"/>
<result column="variable_type" property="variableType"/>
</resultMap>
<sql id ="Base_Column">
r.id,
t.field_cn as field,
r.field_id as fieldId,
r.field_value as fieldValue,
r.rule_id as ruleId,
t.field_en as fieldEn,
t.value_type as valueType,
t.value_scope as valueScope,
r.variable_type as variableType
</sql>
<select id = "getRuleContentList" parameterType = "long" resultType = "ruleContent">
select <include refid="Base_Column"/> from t_rule_content r left join t_field t on r.field_id = t.id where rule_id = #{id} order by id
</select>
<insert id = "insertRuleContent" parameterType="java.util.List">
insert into t_rule_content (field_id,field_value,rule_id,variable_type)
values
<foreach collection="list" index="index" item="item" separator=",">
(#{item.fieldId},#{item.fieldValue},#{item.ruleId},#{item.variableType})
</foreach>
</insert>
<select id = "selectByPrimaryKey" parameterType = "long" resultType="ruleContent">
select <include refid="Base_Column"/> from t_rule_content where id = #{id}
</select>
<update id = "updateRuleContent" parameterType="java.util.List" >
<foreach collection="list" index="index" item="item" separator=";" >
update t_rule_content set
<if test ="item.fieldId!= null">
field_id = #{item.fieldId}
</if>
<if test ="item.fieldValue != null">
,field_value = #{item.fieldValue}
</if>
<if test ="item.variableType != null">
,variable_type = #{item.variableType}
</if>
where id = #{item.id}
</foreach>
</update>
<delete id="deleteRuleContent" parameterType="java.util.List">
<foreach collection="list" index="index" item="item" separator=";" >
delete from t_rule_content where id = #{item.id}
</foreach>
</delete>
<select id = "selectNodeByRuleList" parameterType = "nodeKnowledge" resultType="ruleContent">
select <include refid="Base_Column"/> from t_rule_content WHERE t_rule_content.rule_id IN( SELECT knowledge_id FROM t_node_knowledge_rel WHERE t_node_knowledge_rel.`node_id`=#{id}
AND t_node_knowledge_rel.`knowledge_type`=#{knowledge_type}
</select>
</mapper>

View File

@@ -0,0 +1,97 @@
<?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.risk.riskmanage.knowledge.mapper.RuleFieldMapper">
<cache></cache>
<resultMap type="ruleField" id="ruleFieldMap">
<id column="id" property="id"/>
<result column="logical" property="logical"/>
<result column="operator" property="operator"/>
<result column="field" property="field"/>
<result column="field_value" property="fieldValue"/>
<result column="rule_id" property="ruleId"/>
<result column="field_id" property="fieldId"/>
<result column="fieldEn" property="fieldEn"/>
<result column="valueType" property="valueType"/>
<result column="valueScope" property="valueScope"/>
</resultMap>
<sql id ="Base_Column">
r.id ,
r.logical,
r.operator,
t.field_cn as field,
r.field_value as fieldValue,
r.rule_id as ruleId,
r.field_id as fieldId,
t.field_en as fieldEn,
t.value_type as valueType,
t.value_scope as valueScope
</sql>
<select id = "getFieldList" parameterType = "long" resultType = "ruleField">
select <include refid="Base_Column"/> from t_rule_field r left join t_field t on r.field_id = CONCAT(t.id,'|',t.field_en) where r.rule_id = #{id} order by id
</select>
<insert id = "insertField" parameterType="java.util.List" >
insert into t_rule_field
(logical,operator,field_value,rule_id,field_id)
values
<foreach collection="list" index="index" item="item" separator="," >
(
#{item.logical},
#{item.operator},
#{item.fieldValue},
#{item.ruleId},
TRIM(#{item.fieldId})
)
</foreach>
</insert>
<select id = "selectByPrimaryKey" parameterType = "long" resultType="ruleField">
select <include refid="Base_Column"/> from t_rule_field where id = #{id}
</select>
<update id = "updateField" parameterType="java.util.List" >
<foreach collection="list" index="index" item="item" separator=";" >
update t_rule_field set
<if test ="item.logical != null">
logical = #{item.logical}
</if>
<if test ="item.operator != null">
,operator = #{item.operator}
</if>
<if test ="item.fieldValue != null">
,field_value = #{item.fieldValue}
</if>
<if test ="item.fieldId != null">
,field_id = TRIM(#{item.fieldId})
</if>
where id = #{item.id}
</foreach>
</update>
<delete id="deleteField" parameterType="java.util.List">
<foreach collection="list" index="index" item="item" separator=";" >
delete from t_rule_field where id = #{item.id}
</foreach>
</delete>
<select id = "getNodeByList" parameterType = "nodeKnowledge" resultMap = "ruleFieldMap">
select t_rule_field.`field_id` fieldId from t_rule_field WHERE t_rule_field.rule_id IN( SELECT knowledge_id FROM t_node_knowledge_rel WHERE t_node_knowledge_rel.`node_id`=#{nodeId}
AND t_node_knowledge_rel.`knowledge_type`=#{knowledgeType} )
</select>
<select id = "selectNodeByRuleList" parameterType = "nodeKnowledge" resultType="ruleField">
select t_rule_field.`field_id` fieldId from t_rule_field WHERE t_rule_field.rule_id IN( SELECT knowledge_id FROM t_node_knowledge_rel WHERE t_node_knowledge_rel.`node_id`=#{nodeId}
AND t_node_knowledge_rel.`knowledge_type`=#{knowledgeType})
</select>
<!-- 普通规则查询字段 -->
<select id = "selectByRuleList" parameterType="map" resultType="ruleField">
select t_rule_field.`field_id` fieldId from t_rule_field WHERE t_rule_field.rule_id in
<foreach collection="Ids" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
</select>
</mapper>

View File

@@ -0,0 +1,509 @@
<?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.risk.riskmanage.knowledge.mapper.RuleMapper">
<cache></cache>
<resultMap type="com.risk.riskmanage.knowledge.model.Rule" id="ruleMap">
<id column="id" property="id"/>
<result column="name" property="name"/>
<result column="code" property="code"/>
<result column="description" property="description"/>
<result column="priority" property="priority"/>
<result column="parent_id" property="parentId"/>
<result column="user_id" property="userId"/>
<result column="author" property="author"/>
<result column="nick_name" property="authorName"/>
<result column="organ_id" property="organId"/>
<result column="engine_id" property="engineId"/>
<result column="status" property="status"/>
<result column="type" property="type"/>
<result column="is_non" property="isNon"/>
<result column="created" property="created"/>
<result column="updated" property="updated"/>
<result column="rule_type" property="ruleType"/>
<result column="rule_audit" property="ruleAudit"/>
<result column="score" property="score"/>
<result column="last_logical" property="lastLogical"/>
<result column="engineName" property="engineName"/>
<collection property="ruleFieldList" ofType="ruleField" column="id" select ="com.risk.riskmanage.knowledge.mapper.RuleFieldMapper.getFieldList"></collection>
<collection property="ruleContentList" ofType="ruleContent" column="id" select = "com.risk.riskmanage.knowledge.mapper.RuleContentMapper.getRuleContentList"></collection>
</resultMap>
<!--
<sql id ="Base_Column">
r.id,
r.name,
r.versionCode,
r.description,
r.priority,
r.parent_id as parentId,
r.user_id as userId,
r.author,
u.nick_name as authorName,
r.organ_id as organId,
r.engine_id as engineId,
r.status,
r.rule_audit as ruleAudit,
r.type,
r.score,
r.last_logical as lastLogical,
r.is_non as isNon,
r.created,
r.updated,
r.rule_type
</sql>
-->
<sql id="Base_Column">
r.id,
r.name,
r.code,
r.description,
r.priority,
r.parent_id,
r.user_id,
r.author,
u.nick_name as nick_name,
r.organ_id,
r.engine_id,
r.status,
r.rule_audit,
r.type,
r.score,
r.last_logical,
r.is_non,
r.created,
r.updated,
r.rule_type,
r.difficulty
</sql>
<sql id ="Base_Column_1">
r.id,
r.name,
r.code,
r.description,
r.priority,
r.parent_id,
r.user_id,
r.author,
u.nick_name,
r.organ_id,
r.engine_id,
(CASE r.STATUS
WHEN r.id IN (
SELECT
rule_id
FROM
t_engine_rule_rel td
WHERE
engine_id =#{engineId}
) THEN
1
ELSE
0
END) AS status,
r.rule_audit,
r.type,
r.score,
r.last_logical,
r.is_non,
r.created,
r.updated,
r.rule_type
</sql>
<sql id ="Base_Column_2">
r.id,
r.name,
r.code,
r.description,
r.engine_id,
r.priority,
r.parent_id,
r.user_id,
r.author,
r.organ_id,
r.engine_id,
r.status,
r.type,
r.is_non,
r.rule_audit,
r.score,
r.last_logical,
r.created,
r.updated,
r.rule_type
</sql>
<select id="getRuleList" parameterType="Map" resultMap="ruleMap">
<if test="type == 2">
select * from (
</if>
select
<include refid="Base_Column"/>
from t_rule r left join t_user u on r.author = u.user_id
where 1=1
<if test="parentIds != null and parentIds.size() > 0">
and r.parent_id in
<foreach collection="parentIds" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="status != null">
and r.status in
<foreach collection="status" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="key!=null and value!=null">
<choose>
<when test="key=='ruleName'">
and r.name like CONCAT('%',#{value},'%' )
</when>
</choose>
</if>
<if test="type == 0">
and r.type = 0
</if>
<if test="type == 1">
and r.organ_id = #{organId}
and r.type = 1
order by updated desc
</if>
<if test="type == 2">
and r.engine_id = #{engineId}
and r.type = 2
union
select
<choose>
<when test="engineId!='' and engineId!=null">
<include refid="Base_Column_1"/>
</when>
<otherwise>
<include refid="Base_Column"/>
</otherwise>
</choose>
from
t_rule r left join t_user u on r.author = u.user_id
where 1=1
<if test="parentIds != null and parentIds!=''">
and r.parent_id in
<foreach collection="parentIds" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="status != null">
and r.status in
<foreach collection="status" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
and r.organ_id = #{organId}
<if test="key!=null and value!=null">
<choose>
<when test="key=='ruleName'">
and r.name like CONCAT('%',#{value},'%' )
</when>
</choose>
</if>
and r.type = 1
and r.id in (select rule_id from t_engine_rule_rel td where engine_id = #{engineId})
order by updated desc
) y
</if>
</select>
<select id = "getRuleIdsByParentId" parameterType="Map" resultType="long">
select id from t_rule r left join t_user u on r.author = u.user_id
where 1=1 and r.status = 1
<if test ="parentIds != null and parentIds != ''">
and r.parent_id in
<foreach collection="parentIds" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
</select>
<insert id = "insertSelective" parameterType="rule" useGeneratedKeys="true" keyProperty="id">
insert into t_rule (
name,
code,
description,
priority,
parent_id,
user_id,
author,
<if test ="content !=null">
content,
</if>
<if test ="organId !=null">
organ_id,
</if>
<if test ="engineId!=null">
engine_id,
</if>
<if test ="ruleAudit!=null">
rule_audit,
</if>
<if test ="score!=null">
score,
</if>
<if test ="lastLogical!=null">
last_logical,
</if>
status,type,is_non,created,updated,rule_type,difficulty)
values(
#{name},
#{code},
#{description},
#{priority},
#{parentId},
#{userId},
#{author},
<if test ="content !=null">
#{content},
</if>
<if test ="organId !=null">
#{organId},
</if>
<if test ="engineId!=null">
#{engineId},
</if>
<if test ="ruleAudit!=null">
#{ruleAudit},
</if>
<if test ="score!=null">
#{score},
</if>
<if test ="lastLogical!=null">
#{lastLogical},
</if>
#{status},#{type},#{isNon},now(), now(),#{ruleType},#{difficulty}
)
</insert>
<update id = "updateByPrimaryKeySelective" parameterType="rule" >
update t_rule set
<if test ="name != null">
name = #{name},
</if>
<if test ="code != null">
code = #{code},
</if>
<if test ="content != null">
content = #{content},
</if>
<if test ="description != null">
description = #{description},
</if>
<if test ="priority != null">
priority = #{priority},
</if>
<if test ="status != null">
status = #{status},
</if>
<if test = "type != null">
type = #{type},
</if>
<if test = "isNon != null">
is_non = #{isNon},
</if>
<if test = "ruleType != null">
rule_type = #{ruleType},
</if>
<if test ="ruleAudit!=null">
rule_audit = #{ruleAudit},
</if>
<if test ="lastLogical!=null">
last_logical = #{lastLogical},
</if>
<if test ="difficulty!=null">
difficulty = #{difficulty},
</if>
score = #{score},
updated = now() where id = #{id}
</update>
<update id = "updateRuleStatus" parameterType="Map" >
update t_rule set status = #{status} where id in
<foreach collection="idList" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</update>
<select id = "selectByPrimaryKey" parameterType = "long" resultMap = "ruleMap">
select <include refid = "Base_Column"/> from t_rule r left join t_user u on r.author = u.user_id where r.id = #{id}
</select>
<select id = "selectByInRoleid" resultMap = "ruleMap">
select <include refid = "Base_Column"/> from t_rule
id in
<foreach item="item" index="index" collection="array" open="(" separator="," close=")">
#{item}
</foreach>
</select>
<select id = "getNodeByRuleList" parameterType = "nodeKnowledge" resultMap = "ruleMap">
select <include refid = "Base_Column"/> from t_rule r WHERE t_rule.id IN( SELECT knowledge_id FROM t_node_knowledge_rel WHERE t_node_knowledge_rel.`node_id`=#{id}
AND t_node_knowledge_rel.`knowledge_type`=#{knowledge_type}
</select>
<select id = "selectnodeByInRoleid" resultMap = "ruleMap">
select r.id,
r.name,
r.code,
r.description,
r.priority,
r.parent_id,
r.user_id,
r.author,
r.organ_id,
r.engine_id,
r.status,
r.rule_audit,
r.type,
r.score,
r.content,
r.last_logical,
r.is_non,
r.created,
r.updated,
r.rule_type,
r.score_field_en,
r.result_field_en
from t_rule r
where r.id in
<foreach item="item" index="index" collection="list" open="(" separator="," close=")">
#{item}
</foreach>
ORDER BY priority ASC
</select>
<select id = "checkByField" parameterType = "map" resultMap = "ruleMap">
select r.id,r.name,r.engine_id,e.name as engineName
from (
select id,name,engine_id
from t_rule
where organ_id = ( select organ_id from t_user where user_id = #{userId} )
<if test="engineId != null">
and engine_id = #{engineId}
</if>
and status = 1
union all
select r.id,r.name,er.engine_id
from t_engine_rule_rel er left join t_rule r on er.rule_id = r.id
where r.organ_id = ( select organ_id from t_user where user_id = #{userId} )
<if test="engineId != null">
and er.engine_id = #{engineId}
</if>
and r.status = 1
)r left join t_engine e on r.engine_id = e.id
where (exists (select 1 from (select rule_id, left(field_id,LOCATE('|',field_id)-1) as f from t_rule_field) rf
where r.id = rf.rule_id
and rf.f in
<foreach collection="fieldIds" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
)
or exists (select 1 from (select rule_id, left(field_id,LOCATE('|',field_id)-1) as f from t_rule_content) rc
where r.id = rc.rule_id
and rc.f in
<foreach collection="fieldIds" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
)
)
</select>
<select id="countOnlyRuleName" parameterType = "map" resultType = "int">
select count(name) from t_rule where organ_id = #{organId} and status != -1 and name = TRIM(#{name})
<if test="id !=null and id!=''">
and id != #{id}
</if>
</select>
<select id="countOnlyRuleCode" parameterType = "map" resultType = "int">
select count(code) from t_rule where organ_id = #{organId} and status != -1 and code=TRIM(#{code})
<if test="id !=null and id!=''">
and id != #{id}
</if>
</select>
<select id="getFieldIdsByRuleId" parameterType ="java.util.List" resultType = "string">
select field_id from t_rule_field where rule_id in
<foreach collection="list" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
union
select field_id from t_rule_content where rule_id in
<foreach collection="list" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</select>
<select id="getRuleListByType" parameterType ="map" resultMap = "ruleMap">
select
<include refid = "Base_Column_2"/>
from t_rule r
where r.parent_id = #{parentId}
<if test="type != 2">
and r.rule_type = #{type}
</if>
<choose>
<when test="ids != null">
and r.id in
<foreach collection="ids" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
or r.engine_id = #{engineId}
</when>
<otherwise>
and r.engine_id = #{engineId}
</otherwise>
</choose>
</select>
<select id = "getNodeAddOrSubRulesByNodeId" parameterType="Long" resultMap="ruleMap">
select
r.id,
r.name,
r.code,
r.description,
r.priority,
r.parent_id,
r.user_id,
r.author,
r.organ_id,
r.engine_id,
r.status,
r.rule_audit,
r.type,
r.score,
r.content,
r.last_logical,
r.is_non,
r.created,
r.updated,
r.rule_type
from t_node_knowledge_rel n left join t_rule r
on r.id = n.knowledge_id where n.node_id = #{nodeId} and n.knowledge_type = 1
and r.rule_type = 1
</select>
<select id="getRuleListByIds" parameterType="java.util.Map" resultType="com.risk.riskmanage.knowledge.model.Rule">
SELECT *
FROM `t_rule`
WHERE `id` IN
<foreach collection="ids" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</select>
<select id="getAllCodeNameParentId" resultType="com.risk.riskmanage.knowledge.model.Rule">
select code,name,parent_id from t_rule where status !=-1
</select>
</mapper>

View File

@@ -0,0 +1,71 @@
<?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.risk.riskmanage.logger.mapper.LoggerMapper">
<resultMap type="com.risk.riskmanage.logger.model.Logger" id="loggerMap">
<id column="id" property="id"/>
<result column="op_type" property="opType"/>
<result column="op_name" property="opName"/>
<result column="op_user_id" property="opUserId"/>
<result column="nick_name" property="opUserName"/>
<result column="organ_id" property="organId"/>
<result column="organ_name" property="organName"/>
<result column="method" property="method"/>
<result column="request_path" property="requestPath"/>
<result column="request_param" property="requestParam"/>
<result column="response_param" property="responseParam"/>
<result column="ip" property="ip"/>
<result column="start_time" property="startTime"/>
<result column="end_time" property="endTime"/>
</resultMap>
<sql id="Base_Column">
l.id,
l.op_type,
l.op_name,
l.op_user_id,
u.nick_name,
o.name as organ_name,
l.organ_id,
l.method,
l.request_path,
l.request_param,
l.response_param,
l.ip,
l.start_time,
l.end_time
</sql>
<insert id = "insertSelective" parameterType="map">
insert into t_logger (op_type,op_name,op_user_id,organ_id,method,request_path,request_param,response_param,ip,start_time,end_time)
values(#{opType},#{opName},#{opUserId},#{organId},#{method},#{requestPath},#{requestParam},#{responseParam},#{ip},#{startTime},#{endTime})
</insert>
<select id ="getLogList" parameterType="map" resultMap="loggerMap">
select <include refid="Base_Column"/> from t_logger l left join t_user u on l.op_user_id = u.user_id left join t_organization o on u.organ_id = o.organ_id where 1=1 and
<if test ="organId != null">
l.organ_id = #{organId} and
</if>
<if test="searchKey!=null and searchKey!=''">
l.op_name like CONCAT('%',#{searchKey},'%' ) and
</if>
date(l.start_time) &gt;= #{startDate} and date(l.start_time) &lt;=#{endDate} order by l.start_time desc
</select>
<select id ="selectByPrimaryKey" parameterType="map" resultMap="loggerMap">
select <include refid="Base_Column"/> from t_logger l left join t_user u on l.op_user_id = u.user_id left join t_organization o on u.organ_id = o.organ_id where l.id = #{id}
</select>
<select id ="getLastLoginInfo" parameterType="java.lang.Long" resultType="java.util.Date">
SELECT
t.`start_time`
FROM
`t_logger` t
WHERE t.`op_user_id` = #{userId}
AND t.`op_type` = 'login'
ORDER BY t.`start_time` DESC
LIMIT 2
</select>
</mapper>

View File

@@ -0,0 +1,98 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--Configuration后面的status这个用于设置log4j2自身内部的信息输出可以不设置当设置成trace时你会看到log4j2内部各种详细输出-->
<!--monitorIntervalLog4j能够自动检测修改配置 文件和重新配置本身,设置间隔秒数-->
<configuration monitorInterval="5">
<!--日志级别以及优先级排序: OFF > FATAL > ERROR > WARN > INFO > DEBUG > TRACE > ALL -->
<!--变量配置-->
<Properties>
<!-- 格式化输出:%date表示日期%thread表示线程名%-5level级别从左显示5个字符宽度 %msg日志消息%n是换行符-->
<!-- %logger{36} 表示 Logger 名字最长36个字符 -->
<property name="LOG_PATTERN" value="%date{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n" />
<!-- 定义日志存储的路径 -->
<property name="FILE_PATH" value="logs/manager" />
<property name="FILE_NAME" value="manager" />
</Properties>
<appenders>
<console name="Console" target="SYSTEM_OUT">
<!--输出日志的格式-->
<PatternLayout pattern="${LOG_PATTERN}"/>
<!--控制台只输出level及其以上级别的信息onMatch其他的直接拒绝onMismatch-->
<ThresholdFilter level="debug" onMatch="ACCEPT" onMismatch="DENY"/>
</console>
<!--文件会打印出所有信息这个log每次运行程序会自动清空由append属性决定适合临时测试用-->
<File name="Filelog" fileName="${FILE_PATH}/test.log" append="false">
<PatternLayout pattern="${LOG_PATTERN}"/>
</File>
<!-- 这个会打印出所有的info及以下级别的信息每次大小超过size则这size大小的日志会自动存入按年份-月份建立的文件夹下面并进行压缩,作为存档-->
<RollingFile name="RollingFileInfo" fileName="${FILE_PATH}/info.log" filePattern="${FILE_PATH}/${FILE_NAME}-INFO-%d{yyyy-MM-dd}_%i.log.gz">
<!--控制台只输出level及以上级别的信息onMatch其他的直接拒绝onMismatch-->
<ThresholdFilter level="info" onMatch="ACCEPT" onMismatch="DENY"/>
<PatternLayout pattern="${LOG_PATTERN}"/>
<Policies>
<!--interval属性用来指定多久滚动一次默认是1 hour-->
<TimeBasedTriggeringPolicy interval="1"/>
<SizeBasedTriggeringPolicy size="10MB"/>
</Policies>
<!-- DefaultRolloverStrategy属性如不设置则默认为最多同一文件夹下7个文件开始覆盖-->
<DefaultRolloverStrategy max="15"/>
</RollingFile>
<!-- 这个会打印出所有的warn及以下级别的信息每次大小超过size则这size大小的日志会自动存入按年份-月份建立的文件夹下面并进行压缩,作为存档-->
<RollingFile name="RollingFileWarn" fileName="${FILE_PATH}/warn.log" filePattern="${FILE_PATH}/${FILE_NAME}-WARN-%d{yyyy-MM-dd}_%i.log.gz">
<!--控制台只输出level及以上级别的信息onMatch其他的直接拒绝onMismatch-->
<ThresholdFilter level="warn" onMatch="ACCEPT" onMismatch="DENY"/>
<PatternLayout pattern="${LOG_PATTERN}"/>
<Policies>
<!--interval属性用来指定多久滚动一次默认是1 hour-->
<TimeBasedTriggeringPolicy interval="1"/>
<SizeBasedTriggeringPolicy size="10MB"/>
</Policies>
<!-- DefaultRolloverStrategy属性如不设置则默认为最多同一文件夹下7个文件开始覆盖-->
<DefaultRolloverStrategy max="15"/>
</RollingFile>
<!-- 这个会打印出所有的error及以下级别的信息每次大小超过size则这size大小的日志会自动存入按年份-月份建立的文件夹下面并进行压缩,作为存档-->
<RollingFile name="RollingFileError" fileName="${FILE_PATH}/error.log" filePattern="${FILE_PATH}/${FILE_NAME}-ERROR-%d{yyyy-MM-dd}_%i.log.gz">
<!--控制台只输出level及以上级别的信息onMatch其他的直接拒绝onMismatch-->
<ThresholdFilter level="error" onMatch="ACCEPT" onMismatch="DENY"/>
<PatternLayout pattern="${LOG_PATTERN}"/>
<Policies>
<!--interval属性用来指定多久滚动一次默认是1 hour-->
<TimeBasedTriggeringPolicy interval="1"/>
<SizeBasedTriggeringPolicy size="10MB"/>
</Policies>
<!-- DefaultRolloverStrategy属性如不设置则默认为最多同一文件夹下7个文件开始覆盖-->
<DefaultRolloverStrategy max="15"/>
</RollingFile>
</appenders>
<!--Logger节点用来单独指定日志的形式比如要为指定包下的class指定不同的日志级别等。-->
<!--然后定义loggers只有定义了logger并引入的appenderappender才会生效-->
<loggers>
<!--过滤掉spring和mybatis的一些无用的DEBUG信息-->
<logger name="org.mybatis" level="info" additivity="false">
<AppenderRef ref="Console"/>
</logger>
<!--监控系统信息-->
<!--若是additivity设为false则 子Logger 只会在自己的appender里输出而不会在 父Logger 的appender里输出。-->
<Logger name="org.springframework" level="info" additivity="false">
<AppenderRef ref="Console"/>
</Logger>
<root level="debug">
<appender-ref ref="Console"/>
<appender-ref ref="Filelog"/>
<appender-ref ref="RollingFileInfo"/>
<appender-ref ref="RollingFileWarn"/>
<appender-ref ref="RollingFileError"/>
</root>
</loggers>
</configuration>

View File

@@ -0,0 +1,141 @@
<?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.risk.riskmanage.rule.mapper.RuleInfoMapper">
<resultMap type="com.risk.riskmanage.rule.model.RuleInfo" id="RuleMap">
<result property="id" column="id" jdbcType="INTEGER"/>
<result property="name" column="name" jdbcType="VARCHAR"/>
<result property="code" column="code" jdbcType="VARCHAR"/>
<result property="description" column="description" jdbcType="VARCHAR"/>
<result property="priority" column="priority" jdbcType="INTEGER"/>
<result property="parentId" column="parent_id" jdbcType="INTEGER"/>
<result property="author" column="author" jdbcType="INTEGER"/>
<result property="userId" column="user_id" jdbcType="INTEGER"/>
<result property="organId" column="organ_id" jdbcType="INTEGER"/>
<result property="engineId" column="engine_id" jdbcType="INTEGER"/>
<result property="status" column="status" jdbcType="INTEGER"/>
<result property="type" column="type" jdbcType="INTEGER"/>
<result property="isNon" column="is_non" jdbcType="INTEGER"/>
<result property="content" column="content" jdbcType="VARCHAR"/>
<result property="created" column="created" jdbcType="TIMESTAMP"/>
<result property="updated" column="updated" jdbcType="TIMESTAMP"/>
<result property="ruleType" column="rule_type" jdbcType="INTEGER"/>
<result property="ruleAudit" column="rule_audit" jdbcType="INTEGER"/>
<result property="score" column="score" jdbcType="INTEGER"/>
<result property="difficulty" column="difficulty" jdbcType="INTEGER"/>
<result property="scriptType" column="script_type" jdbcType="VARCHAR"/>
<result property="lastLogical" column="last_logical" jdbcType="VARCHAR"/>
</resultMap>
<sql id="Base_column">
id, name, code, description, priority, parent_id, author, user_id, organ_id, engine_id, status, type, is_non, content, created, updated, rule_type, rule_audit, score, last_logical,difficulty,script_type,result_field_en,score_field_en
</sql>
<!--查询单个-->
<select id="queryById" resultMap="RuleMap">
select
<include refid="Base_column"></include>
from t_rule
where id = #{id}
</select>
<select id = "queryRuleList" parameterType="com.risk.riskmanage.rule.model.RuleInfo" resultMap="RuleMap">
select
<include refid="Base_column"></include>
from t_rule
<where>
<if test="id != null">
and id = #{id}
</if>
<if test="name != null and name != ''">
and `name` like #{name}
</if>
<if test="code != null and code != ''">
and code = #{code}
</if>
<if test="description != null and description != ''">
and description = #{description}
</if>
<if test="priority != null">
and priority = #{priority}
</if>
<if test="parentId != null">
and parent_id = #{parentId}
</if>
<if test="parentIds != null and parentIds.size>0">
and parent_id in
<foreach collection = "parentIds" item="pId" open="(" separator="," close=")">
#{pId}
</foreach>
</if>
<if test="author != null">
and author = #{author}
</if>
<if test="userId != null">
and user_id = #{userId}
</if>
<if test="organId != null">
and organ_id = #{organId}
</if>
<if test="engineId != null">
and engine_id = #{engineId}
</if>
<if test="status != null">
and status = #{status}
</if>
<if test="status==null">
and status >= 0
</if>
<if test="type != null">
and `type` = #{type}
</if>
<if test="isNon != null">
and is_non = #{isNon}
</if>
<if test="content != null and content != ''">
and content = #{content}
</if>
<if test="created != null">
and created >= #{created}
</if>
<if test="updated != null">
and updated >= #{updated}
</if>
<if test="ruleType != null">
and rule_type = #{ruleType}
</if>
<if test="ruleAudit != null">
and rule_audit = #{ruleAudit}
</if>
<if test="score != null">
and score = #{score}
</if>
<if test="lastLogical != null and lastLogical != ''">
and last_logical = #{lastLogical}
</if>
<if test="difficulty != null">
and difficulty = #{difficulty}
</if>
<if test="scriptType != null and scriptType!= ''">
and script_type = #{scriptType}
</if>
</where>
order by updated desc
</select>
<update id="updateStatus" >
update t_rule set status = #{status}
where id in
<foreach collection="ids" item="ruleId" open="(" separator="," close=")">
#{ruleId}
</foreach>
</update>
<update id="updateParent" >
update t_rule set parent_id = #{parentId}
where id in
<foreach collection="ids" item="ruleId" open="(" separator="," close=")">
#{ruleId}
</foreach>
</update>
</mapper>

View File

@@ -0,0 +1,129 @@
<?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.risk.riskmanage.system.mapper.DepartmentMapper">
<resultMap type="department" id="deptMap">
<id column="id" property="id"/>
<result column="org_name" property="deptName"/>
<result column="org_code" property="deptCode"/>
<result column="status" property="status"/>
<result column="updateTime" property="updateTime"/>
</resultMap>
<select id="selectByExample" parameterType="department" resultType="department">
SELECT
id,org_name as deptName,org_code as deptCode,status,
date_format(updateTime,'%Y-%m-%d %T') as updateTime
FROM
manager_organization
<trim prefix="where">
status=1
<if test="id != null">
and id = #{id}
</if>
<if test="deptName != null and deptName !=''">
and org_name like CONCAT('%',TRIM('${deptName}'),'%' )
</if>
<if test="deptCode != null and deptCode !=''">
and org_code like CONCAT('%',TRIM('${deptCode}'),'%' )
</if>
</trim>
ORDER BY updateTime desc
<if test="curRow !=null ">
limit #{curRow},#{rows}
</if>
</select>
<select id="countByExample" parameterType="department" resultType="java.lang.Integer" >
SELECT
COUNT(id)
FROM
manager_organization
where
status=1
<if test="id != null">
and id = #{id}
</if>
<if test="deptName != null and deptName !=''">
and org_name like CONCAT('%',TRIM('${deptName}'),'%' )
</if>
<if test="deptCode != null and deptCode !=''">
and org_code like CONCAT('%',TRIM('${deptCode}'),'%' )
</if>
</select>
<insert id="insertSelective" parameterType="department" >
INSERT INTO
manager_organization
<trim prefix="(" suffix=")">
<if test="deptName != null">
org_name,
</if>
<if test="deptCode != null">
org_code,
</if>
status,
updateTime
</trim>
values
<trim prefix="(" suffix=")">
<if test="deptName != null">
#{deptName},
</if>
<if test="deptCode != null">
#{deptCode},
</if>
1,
now()
</trim>
</insert>
<select id="isExist" parameterType="department" resultType="java.lang.Integer" >
SELECT
COUNT(id)
FROM
manager_organization
<trim prefix="where">
status=1
<if test="id != null">
and id != #{id}
</if>
<if test="deptName != null">
and org_name = #{deptName}
</if>
<if test="deptCode != null">
and org_code = #{deptCode}
</if>
</trim>
</select>
<update id="updateByPrimaryKeySelective" parameterType="department" >
UPDATE manager_organization SET
<if test="deptName != null">
org_name = #{deptName}
</if>
<if test="deptCode != null">
,org_code = #{deptCode}
</if>
,updateTime = now()
WHERE
status=1
<if test="id != null">
and id = #{id}
</if>
</update>
<delete id="deleteDept" parameterType="java.lang.Integer" >
UPDATE manager_organization SET
status=-1
WHERE
id
IN
<foreach collection="array" item="deletIds" open="(" separator="," close=")">
#{deletIds}
</foreach>
</delete>
</mapper>

View File

@@ -0,0 +1,236 @@
<?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.risk.riskmanage.system.mapper.MenuMapper">
<resultMap type="menu" id="roleMap">
<id column="id" property="id"/>
<id column="pid" property="pid"/>
<result column="name" property="name"/>
<result column="type" property="type"/>
<result column="menu_order" property="menuOrder"/>
<result column="url" property="url"/>
<result column="menu_code" property="menuCode"/>
<result column="icon" property="icon"/>
<result column="status" property="status"/>
<result column="updateTime" property="updateTime"/>
</resultMap>
<select id="selectByExample" parameterType="menu" resultType="menu">
SELECT
id,pid as _parentId,name,status,type,
CASE type
WHEN 1 THEN "open"
ELSE "closed" END AS state,
url,menu_code as menuCode,icon,
date_format(updateTime,'%Y-%m-%d %T') as updateTime
FROM
manager_menu
<trim prefix="where">
status=1
<if test="id != null">
and id = #{id}
</if>
<if test="name != null and name !=''">
and name like CONCAT('%',TRIM('${name}'),'%' )
</if>
<if test="menuCode != null and menuCode !=''">
and menu_code like CONCAT('%',TRIM('${menuCode}'),'%' )
</if>
</trim>
ORDER BY updateTime desc
</select>
<select id="selectByRole" parameterType="menu" resultType="menu">
SELECT
menu.id as id,name,status,menu_code as menuCode
FROM
manager_menu menu,manager_menu_role menurole
WHERE
menurole.menu_id = menu.id
and status=1
<if test="roleCode != null and roleCode !=''">
and menurole.role_code = #{roleCode}
</if>
</select>
<select id="countByExample" parameterType="menu" resultType="java.lang.Integer" >
SELECT
COUNT(id)
FROM
manager_menu
where
status=1
<if test="id != null">
and id = #{id}
</if>
<if test="name != null and name !=''">
and name like CONCAT('%',TRIM('${name}'),'%' )
</if>
<if test="menuCode != null and menuCode !=''">
and menu_code like CONCAT('%',TRIM('${menuCode}'),'%' )
</if>
</select>
<insert id="insertSelective" parameterType="menu" >
INSERT INTO
manager_menu
<trim prefix="(" suffix=")">
<if test="pid != null">
pid,
</if>
<if test="name != null">
name,
</if>
<if test="menuCode != null">
menu_code,
</if>
<if test="type != null">
type,
</if>
<if test="url != null">
url,
</if>
<if test="icon != null">
icon,
</if>
status,
updateTime
</trim>
values
<trim prefix="(" suffix=")">
<if test="pid != null">
#{pid},
</if>
<if test="name != null">
#{name},
</if>
<if test="menuCode != null">
#{menuCode},
</if>
<if test="type != null">
#{type},
</if>
<if test="url != null">
#{url},
</if>
<if test="icon != null">
#{icon},
</if>
1,
now()
</trim>
</insert>
<select id="isExist" parameterType="menu" resultType="java.lang.Integer" >
SELECT
COUNT(id)
FROM
manager_menu
<trim prefix="where">
status=1
<if test="id != null">
and id != #{id}
</if>
<if test="name != null">
and name = #{name}
</if>
<if test="menuCode != null">
and menu_code = #{menuCode}
</if>
</trim>
</select>
<update id="updateByPrimaryKeySelective" parameterType="menu" >
UPDATE manager_menu SET
<if test="pid != null">
pid = #{pid},
</if>
<if test="name != null">
name = #{name},
</if>
<if test="type != null">
type = #{type},
</if>
<if test="url != null">
url = #{url},
</if>
<if test="icon != null">
icon = #{icon},
</if>
<if test="name != null">
name = #{name}
</if>
<if test="menuCode != null">
,menu_code = #{menuCode}
</if>
,updateTime = now()
WHERE
status=1
<if test="id != null">
and id = #{id}
</if>
</update>
<delete id="deleteMenu" parameterType="java.lang.Integer" >
UPDATE manager_menu SET
status=-1
WHERE
id
IN
<foreach collection="array" item="deletIds" open="(" separator="," close=")">
#{deletIds}
</foreach>
</delete>
<delete id="deleteMenuRole" parameterType="menu" >
DELETE FROM
manager_menu_role
WHERE
1=1
<if test="roleCode != null">
and role_code = #{roleCode}
</if>
</delete>
<insert id="insertMenuRole" parameterType="menu" >
INSERT INTO
manager_menu_role
<trim prefix="(" suffix=")">
<if test="id != null">
menu_id,
</if>
<if test="roleCode != null">
role_code
</if>
</trim>
values
<trim prefix="(" suffix=")">
<if test="id != null">
#{id},
</if>
<if test="roleCode != null">
#{roleCode}
</if>
</trim>
</insert>
<select id="findUserMenuByUser" resultType="menu">
SELECT DISTINCT
menu.menu_code as menuCode ,menu.id as id , icon,menu.pid as pid,
menu.name as name, url,menu.status as status
FROM
manager_user muser,
manager_user_role userrole,
manager_menu_role menurole,
manager_menu menu
where
muser.id=userrole.user_id and userrole.role_code=menurole.role_code and
menurole.menu_id=menu.id and muser.login_name=#{loginName} and
muser.status !=-1 and
(
menu.pid in( SELECT id from manager_menu menu WHERE menu.pid=1) or menu.pid=1
)
</select>
</mapper>

View File

@@ -0,0 +1,129 @@
<?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.risk.riskmanage.system.mapper.RoleMapper">
<resultMap type="role" id="roleMap">
<id column="id" property="id"/>
<result column="name" property="name"/>
<result column="role_code" property="roleCode"/>
<result column="status" property="status"/>
<result column="updateTime" property="updateTime"/>
</resultMap>
<select id="selectByExample" parameterType="role" resultType="role">
SELECT
id,name,role_code as roleCode,status,
date_format(updateTime,'%Y-%m-%d %T') as updateTime
FROM
manager_role
<trim prefix="where">
status=1
<if test="id != null">
and id = #{id}
</if>
<if test="name != null and name !=''">
and name like CONCAT('%',TRIM('${name}'),'%' )
</if>
<if test="roleCode != null and roleCode !=''">
and role_code like CONCAT('%',TRIM('${roleCode}'),'%' )
</if>
</trim>
ORDER BY updateTime desc
<if test="curRow !=null ">
limit #{curRow},#{rows}
</if>
</select>
<select id="countByExample" parameterType="role" resultType="java.lang.Integer" >
SELECT
COUNT(id)
FROM
manager_role
where
status=1
<if test="id != null">
and id = #{id}
</if>
<if test="name != null and name !=''">
and name like CONCAT('%',TRIM('${name}'),'%' )
</if>
<if test="roleCode != null and roleCode !=''">
and role_code like CONCAT('%',TRIM('${roleCode}'),'%' )
</if>
</select>
<insert id="insertSelective" parameterType="role" >
INSERT INTO
manager_role
<trim prefix="(" suffix=")">
<if test="name != null">
name,
</if>
<if test="roleCode != null">
role_code,
</if>
status,
updateTime
</trim>
values
<trim prefix="(" suffix=")">
<if test="name != null">
#{name},
</if>
<if test="roleCode != null">
#{roleCode},
</if>
1,
now()
</trim>
</insert>
<select id="isExist" parameterType="role" resultType="java.lang.Integer" >
SELECT
COUNT(id)
FROM
manager_role
<trim prefix="where">
status=1
<if test="id != null">
and id != #{id}
</if>
<if test="name != null">
and name = #{name}
</if>
<if test="roleCode != null">
and role_code = #{roleCode}
</if>
</trim>
</select>
<update id="updateByPrimaryKeySelective" parameterType="role" >
UPDATE manager_role SET
<if test="name != null">
name = #{name}
</if>
<if test="roleCode != null">
,role_code = #{roleCode}
</if>
,updateTime = now()
WHERE
status=1
<if test="id != null">
and id = #{id}
</if>
</update>
<delete id="deleteRole" parameterType="java.lang.Integer" >
UPDATE manager_role SET
status=-1
WHERE
id
IN
<foreach collection="array" item="deletIds" open="(" separator="," close=")">
#{deletIds}
</foreach>
</delete>
</mapper>

View File

@@ -0,0 +1,168 @@
<?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.risk.riskmanage.system.mapper.SysMenuMapper">
<resultMap type='SysMenu' id='menuMap'>
<id property='id' column='resource_id' />
<result property='userId' column='user_id' />
<result property='name' column='name' />
<result property='code' column='code' />
<result property='url' column='url' />
<result property='parentId' column='parent_id' />
<result property='des' column='des' />
<result property='birth' column='birth' />
<result property='icon' column='icon' />
<result property='sort' column='sort' />
<result property='status' column='status' />
</resultMap>
<sql id="Base_Column_List" >
resource_id, user_id, name, code, url, parent_id, des, birth, icon, sort, status
</sql>
<select id='getAllSysMenu' resultMap='menuMap'>
select
<include refid="Base_Column_List" />
from t_resource where status != -1
order by resource_id
</select>
<select id='findById' resultMap='menuMap'>
select
<include refid="Base_Column_List" />
from t_resource
where resource_id = #{id} and status !=-1
</select>
<!-- 通过父节点查询子节点 -->
<select id='findChildByParent' resultMap='menuMap'>
select
<include refid="Base_Column_List" />
from t_resource
where parent_id = #{parentId} and status = 1 ORDER BY sort ASC
</select>
<!-- 通过角色菜单关系及父节点查询菜单 -->
<select id='findRoleMenuByParent' resultMap='menuMap'>
select
re.resource_id, re.user_id, re.name, re.code, re.url, re.parent_id, re.des, re.birth, re.icon, re.status
from t_role ro, t_role_resource_rel rr, t_resource re
where ro.role_id = rr.role_id AND rr.resource_id = re.resource_id
and re.parent_id = #{parentId} and rr.role_id = #{roleId} and re.status = 1 ORDER BY re.sort ASC
</select>
<!-- 分配资源树 -->
<select id='findTreeList' resultMap='menuMap'>
select
re.resource_id, re.user_id, re.name, re.code, re.url, re.parent_id, re.des, re.birth, re.icon, re.status
from t_role ro, t_role_resource_rel rr, t_resource re
where ro.role_id = rr.role_id AND rr.resource_id = re.resource_id
and rr.role_id = #{roleId} and re.status = 1 order by re.sort asc
</select>
<!-- 查询所有可用资源 -->
<select id="getAllValidMenu" resultMap="menuMap">
select
<include refid="Base_Column_List" />
from t_resource
where status = 1 order by sort asc
</select>
<!-- 查询引擎树资源 -->
<select id="getEngineTree" resultType="map">
select id_str from t_role_engine where role_id = #{roleId}
</select>
<!-- 验证唯一性 -->
<select id='validateMenuOnly' resultMap='menuMap' parameterType="SysMenu">
select
<include refid="Base_Column_List" />
from t_resource
where (name = #{name} or code = #{code})
and status != -1
<if test="id != null and id !='' and id !=0">
and resource_id != #{id}
</if>
</select>
<!-- 判断是否有权限查看资源 -->
<select id="validatePermission" resultMap ='menuMap'>
select
re.resource_id, re.user_id, re.name, re.code, re.url, re.parent_id, re.des, re.birth, re.icon, re.status
from t_role ro, t_role_resource_rel rr, t_resource re
where ro.role_id = rr.role_id AND rr.resource_id = re.resource_id
and rr.role_id = #{roleId} and re.status = 1 and re.url = #{url}
</select>
<!-- 查看是否有权限访问该引擎 -->
<select id="validateEnginePermission" resultType="map">
select id_str from t_role_engine where role_id = #{roleId} and id_str = #{id_e}
</select>
<insert id="createSysMenu" parameterType="SysMenu">
insert into t_resource (user_id, name, code, url, parent_id, des, birth, icon, sort)
values (#{userId}, #{name}, #{code}, #{url}, #{parentId}, #{des}, now(), #{icon}, #{sort})
</insert>
<!--保存菜单角色关系 -->
<insert id="insertRoleMenu">
insert into t_role_resource_rel (role_id, resource_id)
values
<foreach collection="list" item="ids" index="index" separator="," >
(#{roleId}, #{ids})
</foreach>
</insert>
<!-- 保存引擎树 -->
<insert id="insertRoleEngine">
insert into t_role_engine (role_id, id_str)
values
<foreach collection="list" item="ids" index="index" separator="," >
(#{roleId}, #{ids})
</foreach>
</insert>
<update id="updateSysMenu" parameterType="SysMenu">
update t_resource set name=#{name},
url=#{url},
<if test="des != null and des !=''">
des=#{des},
</if>
<if test="icon != null and icon !=''">
icon=#{icon},
</if>
<if test="userId != null and userId !=''">
user_id=#{userId},
</if>
<if test="parentId != null and parentId !=''">
parent_id=#{parentId},
</if>
<if test="sort != null">
sort=#{sort},
</if>
code=#{code}
where resource_id = #{id}
</update>
<delete id='deleteSysMenu' parameterType='java.lang.Long'>
update t_resource set status = -1 where resource_id = #{id}
</delete>
<!-- 删除菜单角色关系 -->
<delete id="deleteRoleMenu">
delete from t_role_resource_rel where role_id = #{roleId}
</delete>
<!-- 删除引擎树 -->
<delete id="deleteRoleEngine">
delete from t_role_engine where role_id = #{roleId}
</delete>
<update id="updateStatus">
update t_resource set status=#{status}
<where>
<if test="list!=null and list.size()>0">
resource_id in
<foreach collection="list" item="ids" index="index"
open="(" separator="," close=")">#{ids}
</foreach>
</if>
</where>
</update>
</mapper>

View File

@@ -0,0 +1,91 @@
<?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.risk.riskmanage.system.mapper.SysOrganizationMapper">
<resultMap type='sysOrganization' id='organizationMap'>
<id property='id' column='organ_id' />
<result property='name' column='name' />
<result property='code' column='code' />
<result property='email' column='email' />
<result property='telephone' column='telephone' />
<result property='status' column='status' />
<result property='author' column='author' />
<result property='birth' column='birth' />
<result property='token' column='token' />
</resultMap>
<sql id="Base_Column_List" >
organ_id, name, code, email, telephone, status, birth, author,token
</sql>
<select id='getAllSysOrganization' resultMap='organizationMap'>
select
<include refid="Base_Column_List" />
from t_organization where status != -1 and organ_id != 1
order by organ_id desc
</select>
<select id='getAllValidOrgan' resultMap='organizationMap'>
select
<include refid="Base_Column_List" />
from t_organization where status = 1
order by organ_id desc
</select>
<select id='findById' resultMap='organizationMap'>
select
<include refid="Base_Column_List" />
from t_organization
where organ_id = #{id} and status != -1
</select>
<!-- 验证公司唯一性 -->
<select id='validateOrganOnly' resultMap='organizationMap' parameterType="SysOrganization">
select
<include refid="Base_Column_List" />
from t_organization
where (name = #{name} or code = #{code})
and status != -1
<if test="id != null and id !='' and id !=0">
and organ_id != #{id}
</if>
</select>
<insert id="createSysOrganization" parameterType="SysOrganization" useGeneratedKeys="true" keyProperty="id">
insert into t_organization (name, code, email, telephone, status, author, birth, token)
values (#{name}, #{code}, #{email}, #{telephone}, 1, #{author}, now(), #{token})
</insert>
<update id="updateSysOrganization" parameterType="SysOrganization">
update t_organization set name=#{name},
<if test="email != null and email != ''">
email=#{email},
</if>
<if test="telephone != null and telephone!=''">
telephone=#{telephone},
</if>
<if test="author != null and author !=''">
author=#{author},
</if>
code=#{code}
where organ_id=#{id}
</update>
<delete id='deleteSysOrganization' parameterType="java.lang.Long">
update t_organization set status = -1 where organ_id=#{id}
</delete>
<update id="updateStatus">
update t_organization set status=#{status}
<where>
<if test="list!=null and list.size()>0">
organ_id in
<foreach collection="list" item="ids" index="index"
open="(" separator="," close=")">#{ids}
</foreach>
</if>
</where>
</update>
</mapper>

View File

@@ -0,0 +1,140 @@
<?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.risk.riskmanage.system.mapper.SysRoleMapper">
<resultMap type='SysRole' id='roleMap'>
<id property='id' column='role_id' />
<result property='organId' column='organ_id' />
<result property='roleName' column='role_name' />
<result property='roleCode' column='role_code' />
<result property='roleDesc' column='role_desc' />
<result property='author' column='author' />
<result property='birth' column='birth' />
<result property='status' column='status' />
</resultMap>
<sql id="Base_Column_List" >
role_id, organ_id, role_name, role_code, role_desc, author, birth, status
</sql>
<select id='getAllSysRole' resultMap='roleMap'>
select
<include refid="Base_Column_List" />
from t_role where organ_id = #{organId} and status != -1 and author != "超级管理员"
order by role_id desc
</select>
<select id='getAllRoles' resultMap='roleMap'>
select
<include refid="Base_Column_List" />
from t_role where status != -1 and author='超级管理员' order by role_id desc
</select>
<select id='findById' resultMap='roleMap'>
select
<include refid="Base_Column_List" />
from t_role where role_id=#{id} and organ_id = #{organId} and status != -1
</select>
<select id='findByAId' resultMap='roleMap'>
select
<include refid="Base_Column_List" />
from t_role where role_id=#{id} and status != -1
</select>
<select id="getAllValidRole" resultMap='roleMap'>
select
<include refid="Base_Column_List" />
from t_role where organ_id = #{organId} and status = 1
<if test="author =='超级管理员'">
and author = #{author}
</if>
<if test="author != '超级管理员'">
and author != "超级管理员"
</if>
order by role_id
</select>
<select id="getOrganByRoleId" resultType='java.lang.Long'>
select
organ_id
from t_role where role_id = #{roleId}
</select>
<!-- 验证角色唯一性 -->
<select id="validateRoleOnly" resultMap="roleMap">
select
<include refid="Base_Column_List" />
from t_role where organ_id = #{organId} and status !=-1
and role_name = #{roleName}
<if test="id!=null and id!='' and id!=0">
and role_id != #{id}
</if>
</select>
<!-- 查询公司管理员角色id -->
<select id="getOrganRoleByAuthor" resultMap="roleMap">
select
<include refid="Base_Column_List" />
from t_role where organ_id = #{organId} and author = #{author} and status != -1
</select>
<insert id="createSysRole" parameterType="SysRole">
insert into t_role (role_id, organ_id, role_name, role_code, role_desc, author, birth, status)
values (#{id}, #{organId}, #{roleName}, #{roleCode}, #{roleDesc}, #{author}, now(), 1)
</insert>
<insert id="createOrganRole" parameterType="SysRole">
insert into t_role (role_id, organ_id, role_name, role_code, role_desc, author, birth, status)
values (#{id}, #{organId}, #{roleName}, #{roleCode}, #{roleDesc}, #{author}, now(), 1)
</insert>
<update id="updateSysRole" parameterType="SysRole">
update t_role set
<if test="organId != null and organId != ''">
organ_id=#{organId},
</if>
<if test="roleDesc != null and roleDesc != ''">
role_desc=#{roleDesc},
</if>
<if test="roleCode != null and roleCode != ''">
role_code=#{roleCode},
</if>
role_name=#{roleName}
where role_id = #{id}
</update>
<delete id='deleteSysRole' parameterType='java.lang.Long'>
update t_role set status = -1 where role_id = #{id}
</delete>
<update id="updateStatus">
update t_role set status=#{status}
<where>
<if test="list!=null and list.size()>0">
role_id in
<foreach collection="list" item="ids" index="index"
open="(" separator="," close=")">#{ids}
</foreach>
</if>
</where>
</update>
<update id="deleteAllRoles">
update t_role set status = -1 where organ_id = #{organId}
</update>
<update id="deleteRolesByOrgans">
update t_role set status = #{status}
<where>
<if test="list!=null and list.size()>0">
organ_id in
<foreach collection="list" item="ids" index="index"
open="(" separator="," close=")">#{ids}
</foreach>
</if>
</where>
</update>
</mapper>

View File

@@ -0,0 +1,262 @@
<?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.risk.riskmanage.system.mapper.SysUserMapper">
<resultMap type='SysUser' id='userMap'>
<id property='id' column='user_id' />
<result property='organId' column='organ_id' />
<result property='employeeId' column='employee_id' />
<result property='account' column='account' />
<result property='password' column='password' />
<result property='nickName' column='nick_name' />
<result property='email' column='email' />
<result property='cellphone' column='cellphone' />
<result property='qq' column='qq' />
<result property='latestTime' column='latest_time' />
<result property='latestIp' column='latest_ip' />
<result property='status' column='status' />
<result property='birth' column='birth' />
<result property='author' column='author' />
<association property="sysRole" javaType="SysRole">
<id property='id' column='role_id' />
<result property='roleName' column='role_name' />
<result property='roleCode' column='role_code' />
</association>
<association property="sysOrgan" javaType="SysOrganization">
<id property='id' column='organ_id' />
<result property='name' column='name' />
</association>
</resultMap>
<sql id="Base_Column_List" >
user_id, organ_id, employee_id, account, password, nick_name, email, cellphone, qq, latest_time, latest_ip, status, birth, author
</sql>
<!-- 查询搜索用户 -->
<select id='getAllUsers' resultMap='userMap'>
select
u.user_id, u.organ_id, u.employee_id, u.account, u.password, u.nick_name, u.email, u.cellphone, u.qq,u.latest_time,u.latest_ip,u.status,u.birth,u.author,
r.role_id, r.role_name, r.role_code,
g.organ_id, g.name
from
t_user u, t_user_role_rel urr, t_role r, t_organization g
where
u.user_id = urr.user_id and r.role_id = urr.role_id
and g.organ_id = u.organ_id
<if test="account != null and account != ''">
and (u.account = #{account} or u.employee_id = #{account})
</if>
<if test="organId != null and organId !='' and organId != 1">
and u.organ_id = #{organId} and u.author != '超级管理员'
</if>
<if test="organId != null and organId !='' and organId == 1">
and u.author = '超级管理员'
</if>
and u.status != -1
order by user_id desc
</select>
<!-- 查询本组织单条用户 -->
<select id='findById' resultMap='userMap'>
select u.user_id, u.organ_id, u.employee_id,u.account, u.password, u.nick_name, u.email, u.cellphone, u.qq,u.latest_time,u.latest_ip,u.status,u.birth,u.author,
r.role_id, r.role_name, r.role_code
from t_user u, t_user_role_rel urr, t_role r
where u.user_id = urr.user_id and r.role_id = urr.role_id and u.user_id = #{id}
<if test="organId !=null and organId!='' and organId !=1">
and u.organ_id = #{organId}
</if>
and u.status != -1
</select>
<!-- 通过用户id查询角色 -->
<select id="findRoleByUserId" resultMap='userMap'>
select r.role_id, r.role_name from t_user u, t_user_role_rel ur, t_role r
where u.user_id = ur.user_id and r.role_id = ur.role_id and u.user_id = #{userId} and r.status=1
</select>
<!-- 本公司账号员工编号唯一性 -->
<select id="validateUserOnly" resultMap='userMap'>
select account,employee_id
from t_user where (account = #{account} or employee_id = #{employeeId})
and organ_id = #{organId} and STATUS != -1
<if test="id!=null and id!='' and id!=0">
and user_id != #{id}
</if>
</select>
<!-- 查询角色下的所有账号 -->
<select id="getUserIdsByRoleId" resultType ='java.lang.Long'>
select user_id from t_user_role_rel where role_id = #{roleId}
</select>
<!-- 批量查询角色关联的账号 -->
<select id="getBatchUserIdsByRoleId" resultType ='java.lang.Long'>
select user_id from t_user_role_rel
<where>
<if test="list!=null and list.size()>0">
role_id in
<foreach collection="list" item="ids" index="index"
open="(" separator="," close=")">#{ids}
</foreach>
</if>
</where>
</select>
<!-- 保存用户 -->
<insert id="createSysUser" useGeneratedKeys="true" keyProperty="id" parameterType="SysUser">
insert into t_user (organ_id, employee_id, account, password, nick_name, email, cellphone, qq, latest_time, latest_ip, status, birth, author)
values (#{organId}, #{employeeId}, #{account}, #{password}, #{nickName}, #{email}, #{cellphone}, #{qq}, #{latestTime}, #{latestIp}, 1, now(), #{author})
</insert>
<!-- 保存用户角色关系 -->
<insert id="insertUserRole" parameterType="SysUser">
insert into t_user_role_rel (user_id, role_id,organ_id)
values (#{userId}, #{roleId},#{organId})
</insert>
<!-- 修改用户 -->
<update id="updateSysUser" parameterType="SysUser">
update t_user set account=#{account},
<if test="organId != null and organId != ''">
organ_id=#{organId},
</if>
<if test="password != null and password != ''">
password = #{password},
</if>
<if test="employeeId != null and employeeId != ''">
employee_id=#{employeeId},
</if>
<if test="email != null and email != ''">
email=#{email},
</if>
<if test="cellphone != null and cellphone !=''">
cellphone=#{cellphone},
</if>
<if test="qq != null and qq != ''">
qq=#{qq},
</if>
<if test="latestTime != null and latestTime !=''">
latest_time=#{latestTime},
</if>
<if test="latestIp != null and latestIp !=''">
latest_ip=#{latestIp},
</if>
<if test="birth != null and birth !=''">
birth=#{birth},
</if>
<if test="author != null and author != ''">
author=#{author},
</if>
nick_name=#{nickName}
where user_id=#{id}
</update>
<!-- 修改用户角色关系 -->
<update id="updateUserRole" parameterType="SysUser">
update t_user_role_rel set
<if test="organId != null and organId != ''">
organ_id=#{organId},
</if>
user_id=#{id}, role_id=#{sysRole.id}
where user_id=#{id}
</update>
<!-- 删除单个用户 -->
<delete id='deleteSysUser' parameterType='java.lang.Long'>
update t_user set status=-1
where user_id=#{id}
</delete>
<!-- 批量删除、修改用户状态 -->
<update id="updateStates">
update t_user set status=#{status}
<where>
<if test="list!=null and list.size()>0">
user_id in
<foreach collection="list" item="ids" index="index"
open="(" separator="," close=")">#{ids}
</foreach>
</if>
</where>
</update>
<!-- 重置密码 -->
<update id="resetPassword" parameterType="SysUser">
update t_user set password = #{password} where user_id=#{id}
</update>
<!-- 修改密码 -->
<update id="updatePassword" parameterType="SysUser">
update t_user set password = #{password} where user_id=#{id}
</update>
<!-- 删除本公司所有账号 -->
<update id="deleteAllUser">
update t_user set status = -1 where organ_id=#{organId}
</update>
<!-- 删除本公司所有用户角色关系 -->
<update id="deleteAllUserRole">
update t_user_role_rel set status = -1 where organ_id = #{organId}
</update>
<update id="deleteUsersByOrgans">
update t_user set status = #{status}
<where>
<if test="list!=null and list.size()>0">
organ_id in
<foreach collection="list" item="ids" index="index"
open="(" separator="," close=")">#{ids}
</foreach>
</if>
</where>
</update>
<update id="deleteUserRoleByOrgan">
update t_user_role_rel set status = #{status}
<where>
<if test="list!=null and list.size()>0">
organ_id in
<foreach collection="list" item="ids" index="index"
open="(" separator="," close=")">#{ids}
</foreach>
</if>
</where>
</update>
<!-- 删除角色用户关系 -->
<update id="deleteUserRoleById">
update t_user_role_rel set status = -1 where role_id = #{roleId}
</update>
<!-- 删除角色下的所有用户 -->
<update id="deleteUsersByIds">
update t_user set status = #{status}
<where>
<!--<if test="list!=null and list.size()>0">-->
user_id in
<foreach collection="list" item="ids" index="index"
open="(" separator="," close=")">#{ids}
</foreach>
<!--</if>-->
</where>
</update>
<!-- 批量删除角色账号关系 -->
<update id="deleteBatchUserRole">
update t_user_role_rel set status = #{status}
<where>
<if test="list!=null and list.size()>0">
role_id in
<foreach collection="list" item="ids" index="index"
open="(" separator="," close=")">#{ids}
</foreach>
</if>
</where>
</update>
</mapper>

View File

@@ -0,0 +1,259 @@
<?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.risk.riskmanage.system.mapper.UserMapper">
<resultMap type="user" id="userMap">
<id column="id" property="id"/>
<result column="login_name" property="loginName"/>
<result column="name" property="name"/>
<result column="password" property="password"/>
<result column="email" property="email"/>
<result column="phone" property="phone"/>
<result column="dept_code" property="deptCode"/>
<result column="status" property="status"/>
<result column="updateTime" property="updateTime"/>
</resultMap>
<select id="selectByExample" parameterType="user" resultType="user">
SELECT
muser.id as id,muser.name as name,password,
email,phone,muser.status as status,
login_name as login_name, muser.dept_code as dept_code,
dept.org_name as dept_name,b.rolecode as role_code , b.rolename as role_name
FROM manager_user muser LEFT JOIN manager_organization dept ON(dept.org_code = muser.dept_code) LEFT JOIN (
SELECT a.id as id , GROUP_CONCAT(a.urolecode ) as
rolecode,GROUP_CONCAT(role.name) as rolename from
manager_role role,
(
SELECT userrole.role_code as urolecode,muser1.id as id from
manager_user muser1,manager_user_role userrole
where
muser1.id = userrole.user_id
) a
WHERE
a.urolecode = role.role_code
and role.status = 1
GROUP BY id
) b ON(b.id= muser.id)
where muser.status != -1
<if test="id != null and id != ''">
and muser.id = #{id}
</if>
<if test="name != null and name != ''">
and muser.name like CONCAT('%',TRIM('${name}'),'%' )
</if>
<if test="phone != null and phone != ''">
and muser.phone like CONCAT('%',TRIM('${phone}'),'%' )
</if>
<if test="deptCode != null and deptCode != ''">
and muser.dept_code like CONCAT('%',TRIM('${deptCode}'),'%' )
</if>
ORDER BY muser.updateTime desc
<if test="curRow !=null ">
limit #{curRow},#{rows}
</if>
</select>
<select id="countByExample" parameterType="user" resultType="java.lang.Integer">
SELECT
COUNT(id)
FROM
manager_user muser
WHERE
muser.status != -1
<if test="id != null and id != ''">
and muser.id = #{id}
</if>
<if test="name != null and name != ''">
and muser.name like CONCAT('%',TRIM('${name}'),'%' )
</if>
<if test="phone != null and phone != ''">
and muser.phone like CONCAT('%',TRIM('${phone}'),'%' )
</if>
<if test="deptCode != null and deptCode != ''">
and muser.dept_code like CONCAT('%',TRIM('${deptCode}'),'%' )
</if>
</select>
<insert id="insertSelective" useGeneratedKeys="true" keyProperty="id" parameterType="user">
INSERT INTO
manager_user
<trim prefix="(" suffix=")">
<if test="loginName != null">
login_name,
</if>
<if test="name != null">
name,
</if>
<if test="password != null">
password,
</if>
<if test="email != null">
email,
</if>
<if test="phone != null">
phone,
</if>
<if test="deptCode != null">
dept_code,
</if>
status,
updateTime
</trim>
values
<trim prefix="(" suffix=")">
<if test="loginName != null">
#{loginName},
</if>
<if test="name != null">
#{name},
</if>
<if test="password != null">
#{password},
</if>
<if test="email != null">
#{email},
</if>
<if test="phone != null">
#{phone},
</if>
<if test="deptCode != null">
#{deptCode},
</if>
0,
now()
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="user">
UPDATE manager_user SET
<if test="loginName != null">
login_name = #{loginName},
</if>
<if test="name != null">
name = #{name},
</if>
<if test="password != null">
password = #{password},
</if>
<if test="email != null">
email = #{email},
</if>
<if test="phone != null">
phone = #{phone},
</if>
<if test="deptCode != null">
dept_code = #{deptCode},
</if>
updateTime = now()
WHERE
status !=-1
<if test="id != null">
and id = #{id}
</if>
</update>
<insert id="insertUserRole" parameterType="java.util.List">
INSERT INTO manager_user_role
(user_id,role_code)
values
<foreach collection="list" item="item" index="index" separator=",">
(#{item.userId},#{item.roleCode})
</foreach>
</insert>
<select id="isExist" parameterType="user" resultType="java.lang.Integer">
SELECT
COUNT(id)
FROM
manager_user
<trim prefix="where">
status != -1
<if test="id != null">
and id != #{id}
</if>
<if test="loginName != null and loginName != ''">
and login_name = #{loginName}
</if>
<if test="password != null and password != ''">
and password = #{password}
</if>
</trim>
</select>
<select id="selectLoginInfo" parameterType="user" resultType="user">
SELECT
user_id userId , organ_id organId,account,password,nick_name nickName,
email , cellphone,qq,latest_time latestTime,latest_ip latestIp,status,birth
FROM
t_user
<trim prefix="where">
1=1
<if test="userId != null">
and user_id != #{userId}
</if>
<if test="account != null and account != ''">
and account = #{account}
</if>
<if test="password != null and password != ''">
and password = #{password}
</if>
</trim>
</select>
<delete id="deleteUserRole" parameterType="java.lang.Integer">
DELETE FROM
manager_user_role
WHERE
user_id
IN
<foreach collection="array" item="deletIds" open="(" separator="," close=")">
#{deletIds}
</foreach>
</delete>
<delete id="deleteUser" parameterType="user">
UPDATE manager_user SET
status=#{status}
WHERE
id
IN
<foreach item="item" index="index" collection="deletIds" open="(" separator="," close=")">
#{item}
</foreach>
</delete>
<select id="findUserMenuSet" parameterType="java.lang.String" resultType="java.lang.String">
SELECT DISTINCT
menu.menu_code
FROM
manager_user_role userrole,
manager_user user,
manager_menu_role menurole,
manager_menu menu
where
user.id=userrole.user_id and userrole.role_code=menurole.role_code and
menurole.menu_id=menu.id
and user.login_name=#{loginName} and user.status = 1
</select>
<select id="findUserById" parameterType="java.lang.Integer" resultMap="userMap">
select
`user_id`, `organ_id`, `employee_id`, `account`, `password`, `nick_name`, `email`, `cellphone`, `qq`, `latest_time`, `latest_ip`, `status`, `birth`, `author`
from t_user
where user_id = #{user_id,jdbcType=INTEGER}
</select>
<select id="findNickNameById" parameterType="java.lang.Long" resultType="java.lang.String">
SELECT
nick_name
FROM
t_user
where
user_id = #{id}
</select>
</mapper>