官方代码同步

master
Sxile 4 years ago committed by Limy
parent 4f39acab74
commit 2bbf4ad36d

@ -2,20 +2,20 @@
spring: spring:
datasource: datasource:
type: com.alibaba.druid.pool.DruidDataSource type: com.alibaba.druid.pool.DruidDataSource
driverClassName: com.mysql.cj.jdbc.Driver driverClassName: com.microsoft.sqlserver.jdbc.SQLServerDriver
druid: druid:
# 主库数据源 # 主库数据源
master: master:
url: jdbc:mysql://localhost:3306/ry?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 url: jdbc:sqlserver://127.0.0.1:1433;SelectMethod=cursor;DatabaseName=RuoYi_SqlServer
username: root username: RuoYi_SqlServer
password: password password: password
# 从库数据源 # 从库数据源
slave: slave:
# 从数据源开关/默认关闭 # 从数据源开关/默认关闭
enabled: false enabled: false
url: url:
username: username:
password: password:
# 初始连接数 # 初始连接数
initialSize: 5 initialSize: 5
# 最小连接池数量 # 最小连接池数量
@ -31,27 +31,27 @@ spring:
# 配置一个连接在池中最大生存的时间,单位是毫秒 # 配置一个连接在池中最大生存的时间,单位是毫秒
maxEvictableIdleTimeMillis: 900000 maxEvictableIdleTimeMillis: 900000
# 配置检测连接是否有效 # 配置检测连接是否有效
validationQuery: SELECT 1 FROM DUAL validationQuery: SELECT 1
testWhileIdle: true testWhileIdle: true
testOnBorrow: false testOnBorrow: false
testOnReturn: false testOnReturn: false
webStatFilter: # webStatFilter:
enabled: true # enabled: true
statViewServlet: statViewServlet:
enabled: true enabled: true
# 设置白名单,不填则允许所有访问 # 设置白名单,不填则允许所有访问
allow: allow:
url-pattern: /druid/* url-pattern: /druid/*
# 控制台管理用户名和密码 # 控制台管理用户名和密码
login-username: login-username:
login-password: login-password:
filter: filter:
stat: stat:
enabled: true # enabled: true
# 慢SQL记录 # 慢SQL记录
log-slow-sql: true log-slow-sql: true
slow-sql-millis: 1000 slow-sql-millis: 1000
merge-sql: true merge-sql: true
wall: wall:
config: config:
multi-statement-allow: true multi-statement-allow: true

@ -10,6 +10,7 @@ ruoyi:
demoEnabled: true demoEnabled: true
# 文件路径 示例( Windows配置D:/ruoyi/uploadPathLinux配置 /home/ruoyi/uploadPath # 文件路径 示例( Windows配置D:/ruoyi/uploadPathLinux配置 /home/ruoyi/uploadPath
profile: D:/ruoyi/uploadPath profile: D:/ruoyi/uploadPath
# profile: /Users/sxile/MyWorkSpase/WorkSpase/uploadPath/RuoYi-SqlServer
# 获取ip地址开关 # 获取ip地址开关
addressEnabled: false addressEnabled: false
@ -27,7 +28,7 @@ server:
max-threads: 800 max-threads: 800
# Tomcat启动初始化的线程数默认值25 # Tomcat启动初始化的线程数默认值25
min-spare-threads: 30 min-spare-threads: 30
# 日志配置 # 日志配置
logging: logging:
level: level:
@ -55,7 +56,7 @@ spring:
jackson: jackson:
time-zone: GMT+8 time-zone: GMT+8
date-format: yyyy-MM-dd HH:mm:ss date-format: yyyy-MM-dd HH:mm:ss
profiles: profiles:
active: druid active: druid
# 文件上传 # 文件上传
servlet: servlet:
@ -80,11 +81,11 @@ mybatis:
configLocation: classpath:mybatis/mybatis-config.xml configLocation: classpath:mybatis/mybatis-config.xml
# PageHelper分页插件 # PageHelper分页插件
pagehelper: pagehelper:
helperDialect: mysql helperDialect: sqlserver
reasonable: true reasonable: true
supportMethodsArguments: true supportMethodsArguments: true
params: count=countSql params: count=countSql
# Shiro # Shiro
shiro: shiro:
@ -101,7 +102,7 @@ shiro:
captchaType: math captchaType: math
cookie: cookie:
# 设置Cookie的域名 默认空,即当前访问的域名 # 设置Cookie的域名 默认空,即当前访问的域名
domain: domain:
# 设置cookie的有效访问路径 # 设置cookie的有效访问路径
path: / path: /
# 设置HttpOnly属性 # 设置HttpOnly属性
@ -123,7 +124,7 @@ shiro:
kickoutAfter: false kickoutAfter: false
# 防止XSS攻击 # 防止XSS攻击
xss: xss:
# 过滤开关 # 过滤开关
enabled: true enabled: true
# 排除链接(多个用逗号分隔) # 排除链接(多个用逗号分隔)

@ -2,6 +2,7 @@
<configuration> <configuration>
<!-- 日志存放路径 --> <!-- 日志存放路径 -->
<property name="log.path" value="/home/ruoyi/logs" /> <property name="log.path" value="/home/ruoyi/logs" />
<!-- <property name="log.path" value="/Users/sxile/MyWorkSpase/WorkSpase/logs/RuoYi-SqlServer" />-->
<!-- 日志输出格式 --> <!-- 日志输出格式 -->
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n" /> <property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n" />
@ -11,7 +12,7 @@
<pattern>${log.pattern}</pattern> <pattern>${log.pattern}</pattern>
</encoder> </encoder>
</appender> </appender>
<!-- 系统日志输出 --> <!-- 系统日志输出 -->
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender"> <appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/sys-info.log</file> <file>${log.path}/sys-info.log</file>
@ -34,7 +35,7 @@
<onMismatch>DENY</onMismatch> <onMismatch>DENY</onMismatch>
</filter> </filter>
</appender> </appender>
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender"> <appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/sys-error.log</file> <file>${log.path}/sys-error.log</file>
<!-- 循环政策:基于时间创建日志文件 --> <!-- 循环政策:基于时间创建日志文件 -->
@ -56,7 +57,7 @@
<onMismatch>DENY</onMismatch> <onMismatch>DENY</onMismatch>
</filter> </filter>
</appender> </appender>
<!-- 用户访问日志输出 --> <!-- 用户访问日志输出 -->
<appender name="sys-user" class="ch.qos.logback.core.rolling.RollingFileAppender"> <appender name="sys-user" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/sys-user.log</file> <file>${log.path}/sys-user.log</file>
@ -70,7 +71,7 @@
<pattern>${log.pattern}</pattern> <pattern>${log.pattern}</pattern>
</encoder> </encoder>
</appender> </appender>
<!-- 系统模块日志级别控制 --> <!-- 系统模块日志级别控制 -->
<logger name="com.ruoyi" level="info" /> <logger name="com.ruoyi" level="info" />
<!-- Spring日志级别控制 --> <!-- Spring日志级别控制 -->
@ -79,15 +80,15 @@
<root level="info"> <root level="info">
<appender-ref ref="console" /> <appender-ref ref="console" />
</root> </root>
<!--系统操作日志--> <!--系统操作日志-->
<root level="info"> <root level="info">
<appender-ref ref="file_info" /> <appender-ref ref="file_info" />
<appender-ref ref="file_error" /> <appender-ref ref="file_error" />
</root> </root>
<!--系统用户操作日志--> <!--系统用户操作日志-->
<logger name="sys-user" level="info"> <logger name="sys-user" level="info">
<appender-ref ref="sys-user"/> <appender-ref ref="sys-user"/>
</logger> </logger>
</configuration> </configuration>

@ -3,7 +3,7 @@
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.generator.mapper.GenTableColumnMapper"> <mapper namespace="com.ruoyi.generator.mapper.GenTableColumnMapper">
<resultMap type="GenTableColumn" id="GenTableColumnResult"> <resultMap type="GenTableColumn" id="GenTableColumnResult">
<id property="columnId" column="column_id" /> <id property="columnId" column="column_id" />
<result property="tableId" column="table_id" /> <result property="tableId" column="table_id" />
@ -28,23 +28,33 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="updateBy" column="update_by" /> <result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" /> <result property="updateTime" column="update_time" />
</resultMap> </resultMap>
<sql id="selectGenTableColumnVo"> <sql id="selectGenTableColumnVo">
select column_id, table_id, column_name, column_comment, column_type, java_type, java_field, is_pk, is_increment, is_required, is_insert, is_edit, is_list, is_query, query_type, html_type, dict_type, sort, create_by, create_time, update_by, update_time from gen_table_column select column_id, table_id, column_name, column_comment, column_type, java_type, java_field, is_pk, is_increment, is_required, is_insert, is_edit, is_list, is_query, query_type, html_type, dict_type, sort, create_by, create_time, update_by, update_time from gen_table_column
</sql> </sql>
<select id="selectGenTableColumnListByTableId" parameterType="GenTableColumn" resultMap="GenTableColumnResult"> <select id="selectGenTableColumnListByTableId" parameterType="GenTableColumn" resultMap="GenTableColumnResult">
<include refid="selectGenTableColumnVo"/> <include refid="selectGenTableColumnVo"/>
where table_id = #{tableId} where table_id = #{tableId}
order by sort order by sort
</select> </select>
<select id="selectDbTableColumnsByName" parameterType="String" resultMap="GenTableColumnResult"> <select id="selectDbTableColumnsByName" parameterType="String" resultMap="GenTableColumnResult">
select column_name, (case when (is_nullable = 'no' <![CDATA[ && ]]> column_key != 'PRI') then '1' else null end) as is_required, (case when column_key = 'PRI' then '1' else '0' end) as is_pk, ordinal_position as sort, column_comment, (case when extra = 'auto_increment' then '1' else '0' end) as is_increment, column_type SELECT
from information_schema.columns where table_schema = (select database()) and table_name = (#{tableName}) cast(A.NAME as nvarchar) as column_name,
order by ordinal_position cast(B.NAME as nvarchar) + (case when B.NAME ='numeric' then '('+cast(A.prec as nvarchar)+','+cast(A.scale as nvarchar)+')' else '' end) as column_type,
cast(G.[VALUE] as nvarchar) as column_comment,
(SELECT 1 FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE Z WHERE TABLE_NAME=D.NAME and A.NAME = Z.column_name ) as is_pk,
colorder as sort
FROM SYSCOLUMNS A
LEFT JOIN SYSTYPES B ON A.XTYPE=B.XUSERTYPE
INNER JOIN SYSOBJECTS D ON A.ID=D.ID AND D.XTYPE='U' AND D.NAME!='DTPROPERTIES'
LEFT JOIN SYS.EXTENDED_PROPERTIES G ON A.ID=G.MAJOR_ID AND A.COLID=G.MINOR_ID
LEFT JOIN SYS.EXTENDED_PROPERTIES F ON D.ID=F.MAJOR_ID AND F.MINOR_ID =0
where D.NAME = #{tableName}
ORDER BY A.COLORDER
</select> </select>
<insert id="insertGenTableColumn" parameterType="GenTableColumn" useGeneratedKeys="true" keyProperty="columnId"> <insert id="insertGenTableColumn" parameterType="GenTableColumn" useGeneratedKeys="true" keyProperty="columnId">
insert into gen_table_column ( insert into gen_table_column (
<if test="tableId != null and tableId != ''">table_id,</if> <if test="tableId != null and tableId != ''">table_id,</if>
@ -85,10 +95,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="dictType != null and dictType != ''">#{dictType},</if> <if test="dictType != null and dictType != ''">#{dictType},</if>
<if test="sort != null">#{sort},</if> <if test="sort != null">#{sort},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if> <if test="createBy != null and createBy != ''">#{createBy},</if>
sysdate() GETDATE()
) )
</insert> </insert>
<update id="updateGenTableColumn" parameterType="GenTableColumn"> <update id="updateGenTableColumn" parameterType="GenTableColumn">
update gen_table_column update gen_table_column
<set> <set>
@ -105,16 +115,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
dict_type = #{dictType}, dict_type = #{dictType},
sort = #{sort}, sort = #{sort},
update_by = #{updateBy}, update_by = #{updateBy},
update_time = sysdate() update_time = GETDATE()
</set> </set>
where column_id = #{columnId} where column_id = #{columnId}
</update> </update>
<delete id="deleteGenTableColumnByIds" parameterType="Long"> <delete id="deleteGenTableColumnByIds" parameterType="Long">
delete from gen_table_column where table_id in delete from gen_table_column where table_id in
<foreach collection="array" item="tableId" open="(" separator="," close=")"> <foreach collection="array" item="tableId" open="(" separator="," close=")">
#{tableId} #{tableId}
</foreach> </foreach>
</delete> </delete>
</mapper> </mapper>

@ -27,7 +27,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="remark" column="remark" /> <result property="remark" column="remark" />
<collection property="columns" javaType="java.util.List" resultMap="GenTableColumnResult" /> <collection property="columns" javaType="java.util.List" resultMap="GenTableColumnResult" />
</resultMap> </resultMap>
<resultMap type="GenTableColumn" id="GenTableColumnResult"> <resultMap type="GenTableColumn" id="GenTableColumnResult">
<id property="columnId" column="column_id" /> <id property="columnId" column="column_id" />
<result property="tableId" column="table_id" /> <result property="tableId" column="table_id" />
@ -52,51 +52,54 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="updateBy" column="update_by" /> <result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" /> <result property="updateTime" column="update_time" />
</resultMap> </resultMap>
<sql id="selectGenTableVo"> <sql id="selectGenTableVo">
select table_id, table_name, table_comment, sub_table_name, sub_table_fk_name, class_name, tpl_category, package_name, module_name, business_name, function_name, function_author, gen_type, gen_path, options, create_by, create_time, update_by, update_time, remark from gen_table select table_id, table_name, table_comment, sub_table_name, sub_table_fk_name, class_name, tpl_category, package_name, module_name, business_name, function_name, function_author, gen_type, gen_path, options, create_by, create_time, update_by, update_time, remark from gen_table
</sql> </sql>
<select id="selectGenTableList" parameterType="GenTable" resultMap="GenTableResult"> <select id="selectGenTableList" parameterType="GenTable" resultMap="GenTableResult">
<include refid="selectGenTableVo"/> <include refid="selectGenTableVo"/>
<where> <where>
<if test="tableName != null and tableName != ''"> <if test="tableName != null and tableName != ''">
AND lower(table_name) like lower(concat('%', #{tableName}, '%')) AND lower(table_name) like lower('%'+#{tableName}+ '%')
</if> </if>
<if test="tableComment != null and tableComment != ''"> <if test="tableComment != null and tableComment != ''">
AND lower(table_comment) like lower(concat('%', #{tableComment}, '%')) AND lower(table_comment) like lower('%'+#{tableComment}+ '%')
</if> </if>
</where> </where>
</select> </select>
<select id="selectDbTableList" parameterType="GenTable" resultMap="GenTableResult"> <select id="selectDbTableList" parameterType="GenTable" resultMap="GenTableResult">
select table_name, table_comment, create_time, update_time from information_schema.tables SELECT cast(D.NAME as nvarchar) as table_name,cast(F.VALUE as nvarchar) as table_comment,
where table_schema = (select database()) crdate as create_time,refdate as update_time FROM SYSOBJECTS D
AND table_name NOT LIKE 'qrtz_%' AND table_name NOT LIKE 'gen_%' inner JOIN SYS.EXTENDED_PROPERTIES F ON D.ID=F.MAJOR_ID
AND table_name NOT IN (select table_name from gen_table) AND F.MINOR_ID=0 AND D.XTYPE='U' AND D.NAME!='DTPROPERTIES'
AND D.NAME NOT IN (select table_name from gen_table)
<if test="tableName != null and tableName != ''"> <if test="tableName != null and tableName != ''">
AND lower(table_name) like lower(concat('%', #{tableName}, '%')) AND lower(table_name) like lower('%'+#{tableName}+ '%')
</if> </if>
<if test="tableComment != null and tableComment != ''"> <if test="tableComment != null and tableComment != ''">
AND lower(table_comment) like lower(concat('%', #{tableComment}, '%')) AND lower(table_comment) like lower('%'+#{tableComment}+ '%')
</if> </if>
</select> </select>
<select id="selectDbTableListByNames" resultMap="GenTableResult"> <select id="selectDbTableListByNames" resultMap="GenTableResult">
select table_name, table_comment, create_time, update_time from information_schema.tables SELECT cast(D.NAME as nvarchar) as table_name,cast(F.VALUE as nvarchar) as table_comment,
where table_name NOT LIKE 'qrtz_%' and table_name NOT LIKE 'gen_%' and table_schema = (select database()) crdate as create_time,refdate as update_time FROM SYSOBJECTS D
and table_name in inner JOIN SYS.EXTENDED_PROPERTIES F ON D.ID=F.MAJOR_ID
AND F.MINOR_ID=0 AND D.XTYPE='U' AND D.NAME!='DTPROPERTIES'
AND D.NAME in
<foreach collection="array" item="name" open="(" separator="," close=")"> <foreach collection="array" item="name" open="(" separator="," close=")">
#{name} #{name}
</foreach> </foreach>
</select> </select>
<select id="selectTableByName" parameterType="String" resultMap="GenTableResult"> <select id="selectTableByName" parameterType="String" resultMap="GenTableResult">
select table_name, table_comment, create_time, update_time from information_schema.tables select table_name, table_comment, create_time, update_time from information_schema.tables
where table_comment <![CDATA[ <> ]]> '' and table_schema = (select database()) where table_comment <![CDATA[ <> ]]> '' and table_schema = (Select Name From Master..SysDataBases Where DbId=(Select Dbid From Master..SysProcesses Where Spid = @@spid))
and table_name = #{tableName} and table_name = #{tableName}
</select> </select>
<select id="selectGenTableById" parameterType="Long" resultMap="GenTableResult"> <select id="selectGenTableById" parameterType="Long" resultMap="GenTableResult">
SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.gen_type, t.gen_path, t.options, t.remark, SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.gen_type, t.gen_path, t.options, t.remark,
c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort
@ -104,7 +107,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
LEFT JOIN gen_table_column c ON t.table_id = c.table_id LEFT JOIN gen_table_column c ON t.table_id = c.table_id
where t.table_id = #{tableId} order by c.sort where t.table_id = #{tableId} order by c.sort
</select> </select>
<select id="selectGenTableByName" parameterType="String" resultMap="GenTableResult"> <select id="selectGenTableByName" parameterType="String" resultMap="GenTableResult">
SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.gen_type, t.gen_path, t.options, t.remark, SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.gen_type, t.gen_path, t.options, t.remark,
c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort
@ -112,7 +115,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
LEFT JOIN gen_table_column c ON t.table_id = c.table_id LEFT JOIN gen_table_column c ON t.table_id = c.table_id
where t.table_name = #{tableName} order by c.sort where t.table_name = #{tableName} order by c.sort
</select> </select>
<select id="selectGenTableAll" parameterType="String" resultMap="GenTableResult"> <select id="selectGenTableAll" parameterType="String" resultMap="GenTableResult">
SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.gen_type, t.gen_path, t.options, t.remark, SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.gen_type, t.gen_path, t.options, t.remark,
c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort
@ -120,7 +123,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
LEFT JOIN gen_table_column c ON t.table_id = c.table_id LEFT JOIN gen_table_column c ON t.table_id = c.table_id
order by c.sort order by c.sort
</select> </select>
<insert id="insertGenTable" parameterType="GenTable" useGeneratedKeys="true" keyProperty="tableId"> <insert id="insertGenTable" parameterType="GenTable" useGeneratedKeys="true" keyProperty="tableId">
insert into gen_table ( insert into gen_table (
<if test="tableName != null">table_name,</if> <if test="tableName != null">table_name,</if>
@ -151,10 +154,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="genPath != null and genPath != ''">#{genPath},</if> <if test="genPath != null and genPath != ''">#{genPath},</if>
<if test="remark != null and remark != ''">#{remark},</if> <if test="remark != null and remark != ''">#{remark},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if> <if test="createBy != null and createBy != ''">#{createBy},</if>
sysdate() GETDATE()
) )
</insert> </insert>
<update id="updateGenTable" parameterType="GenTable"> <update id="updateGenTable" parameterType="GenTable">
update gen_table update gen_table
<set> <set>
@ -174,16 +177,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="options != null and options != ''">options = #{options},</if> <if test="options != null and options != ''">options = #{options},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if> <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
<if test="remark != null">remark = #{remark},</if> <if test="remark != null">remark = #{remark},</if>
update_time = sysdate() update_time = GETDATE()
</set> </set>
where table_id = #{tableId} where table_id = #{tableId}
</update> </update>
<delete id="deleteGenTableByIds" parameterType="Long"> <delete id="deleteGenTableByIds" parameterType="Long">
delete from gen_table where table_id in delete from gen_table where table_id in
<foreach collection="array" item="tableId" open="(" separator="," close=")"> <foreach collection="array" item="tableId" open="(" separator="," close=")">
#{tableId} #{tableId}
</foreach> </foreach>
</delete> </delete>
</mapper> </mapper>

@ -3,7 +3,7 @@
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="${packageName}.mapper.${ClassName}Mapper"> <mapper namespace="${packageName}.mapper.${ClassName}Mapper">
<resultMap type="${ClassName}" id="${ClassName}Result"> <resultMap type="${ClassName}" id="${ClassName}Result">
#foreach ($column in $columns) #foreach ($column in $columns)
<result property="${column.javaField}" column="${column.columnName}" /> <result property="${column.javaField}" column="${column.columnName}" />
@ -31,7 +31,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="select${ClassName}List" parameterType="${ClassName}" resultMap="${ClassName}Result"> <select id="select${ClassName}List" parameterType="${ClassName}" resultMap="${ClassName}Result">
<include refid="select${ClassName}Vo"/> <include refid="select${ClassName}Vo"/>
<where> <where>
#foreach($column in $columns) #foreach($column in $columns)
#set($queryType=$column.queryType) #set($queryType=$column.queryType)
#set($javaField=$column.javaField) #set($javaField=$column.javaField)
@ -52,7 +52,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#elseif($queryType == "LTE") #elseif($queryType == "LTE")
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName &lt;= #{$javaField}</if> <if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName &lt;= #{$javaField}</if>
#elseif($queryType == "LIKE") #elseif($queryType == "LIKE")
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName like concat('%', #{$javaField}, '%')</if> <if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName like ('%' + #{$javaField} + '%')</if>
#elseif($queryType == "BETWEEN") #elseif($queryType == "BETWEEN")
<if test="params.begin$AttrName != null and params.begin$AttrName != '' and params.end$AttrName != null and params.end$AttrName != ''"> and $columnName between #{params.begin$AttrName} and #{params.end$AttrName}</if> <if test="params.begin$AttrName != null and params.begin$AttrName != '' and params.end$AttrName != null and params.end$AttrName != ''"> and $columnName between #{params.begin$AttrName} and #{params.end$AttrName}</if>
#end #end
@ -63,7 +63,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
order by ${tree_parent_code} order by ${tree_parent_code}
#end #end
</select> </select>
<select id="select${ClassName}ById" parameterType="${pkColumn.javaType}" resultMap="#if($table.sub)${ClassName}${subClassName}Result#else${ClassName}Result#end"> <select id="select${ClassName}ById" parameterType="${pkColumn.javaType}" resultMap="#if($table.sub)${ClassName}${subClassName}Result#else${ClassName}Result#end">
#if($table.crud) #if($table.crud)
<include refid="select${ClassName}Vo"/> <include refid="select${ClassName}Vo"/>
@ -82,7 +82,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where a.${pkColumn.columnName} = #{${pkColumn.javaField}} where a.${pkColumn.columnName} = #{${pkColumn.javaField}}
#end #end
</select> </select>
<insert id="insert${ClassName}" parameterType="${ClassName}"#if($pkColumn.increment) useGeneratedKeys="true" keyProperty="$pkColumn.javaField"#end> <insert id="insert${ClassName}" parameterType="${ClassName}"#if($pkColumn.increment) useGeneratedKeys="true" keyProperty="$pkColumn.javaField"#end>
insert into ${tableName} insert into ${tableName}
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
@ -118,15 +118,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</delete> </delete>
<delete id="delete${ClassName}ByIds" parameterType="String"> <delete id="delete${ClassName}ByIds" parameterType="String">
delete from ${tableName} where ${pkColumn.columnName} in delete from ${tableName} where ${pkColumn.columnName} in
<foreach item="${pkColumn.javaField}" collection="array" open="(" separator="," close=")"> <foreach item="${pkColumn.javaField}" collection="array" open="(" separator="," close=")">
#{${pkColumn.javaField}} #{${pkColumn.javaField}}
</foreach> </foreach>
</delete> </delete>
#if($table.sub) #if($table.sub)
<delete id="delete${subClassName}By${subTableFkClassName}s" parameterType="String"> <delete id="delete${subClassName}By${subTableFkClassName}s" parameterType="String">
delete from ${subTableName} where ${subTableFkName} in delete from ${subTableName} where ${subTableFkName} in
<foreach item="${subTableFkclassName}" collection="array" open="(" separator="," close=")"> <foreach item="${subTableFkclassName}" collection="array" open="(" separator="," close=")">
#{${subTableFkclassName}} #{${subTableFkclassName}}
</foreach> </foreach>
@ -144,4 +144,4 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</insert> </insert>
#end #end
</mapper> </mapper>

@ -8,7 +8,7 @@ import java.util.Properties;
/** /**
* *
* *
* @author ruoyi * @author ruoyi
*/ */
@Configuration @Configuration
@ -37,7 +37,7 @@ public class ScheduleConfig
prop.put("org.quartz.jobStore.txIsolationLevelSerializable", "true"); prop.put("org.quartz.jobStore.txIsolationLevelSerializable", "true");
// sqlserver 启用 // sqlserver 启用
// prop.put("org.quartz.jobStore.selectWithLockSQL", "SELECT * FROM {0}LOCKS UPDLOCK WHERE LOCK_NAME = ?"); prop.put("org.quartz.jobStore.selectWithLockSQL", "SELECT * FROM {0}LOCKS UPDLOCK WHERE LOCK_NAME = ?");
prop.put("org.quartz.jobStore.misfireThreshold", "12000"); prop.put("org.quartz.jobStore.misfireThreshold", "12000");
prop.put("org.quartz.jobStore.tablePrefix", "QRTZ_"); prop.put("org.quartz.jobStore.tablePrefix", "QRTZ_");
factory.setQuartzProperties(prop); factory.setQuartzProperties(prop);

@ -14,17 +14,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="exceptionInfo" column="exception_info" /> <result property="exceptionInfo" column="exception_info" />
<result property="createTime" column="create_time" /> <result property="createTime" column="create_time" />
</resultMap> </resultMap>
<sql id="selectJobLogVo"> <sql id="selectJobLogVo">
select job_log_id, job_name, job_group, invoke_target, job_message, status, exception_info, create_time select job_log_id, job_name, job_group, invoke_target, job_message, status, exception_info, create_time
from sys_job_log from sys_job_log
</sql> </sql>
<select id="selectJobLogList" parameterType="SysJobLog" resultMap="SysJobLogResult"> <select id="selectJobLogList" parameterType="SysJobLog" resultMap="SysJobLogResult">
<include refid="selectJobLogVo"/> <include refid="selectJobLogVo"/>
<where> <where>
<if test="jobName != null and jobName != ''"> <if test="jobName != null and jobName != ''">
AND job_name like concat('%', #{jobName}, '%') AND job_name like ('%' + #{jobName} + '%')
</if> </if>
<if test="jobGroup != null and jobGroup != ''"> <if test="jobGroup != null and jobGroup != ''">
AND job_group = #{jobGroup} AND job_group = #{jobGroup}
@ -33,41 +33,41 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
AND status = #{status} AND status = #{status}
</if> </if>
<if test="invokeTarget != null and invokeTarget != ''"> <if test="invokeTarget != null and invokeTarget != ''">
AND invoke_target like concat('%', #{invokeTarget}, '%') AND invoke_target like ('%' + #{invokeTarget} + '%')
</if> </if>
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 --> <if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
and date_format(create_time,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d') and datediff(dd,#{params.beginTime},create_time)>= 0
</if> </if>
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 --> <if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
and date_format(create_time,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d') and datediff(dd,create_time,#{params.endTime})>= 0
</if> </if>
</where> </where>
</select> </select>
<select id="selectJobLogAll" resultMap="SysJobLogResult"> <select id="selectJobLogAll" resultMap="SysJobLogResult">
<include refid="selectJobLogVo"/> <include refid="selectJobLogVo"/>
</select> </select>
<select id="selectJobLogById" parameterType="Long" resultMap="SysJobLogResult"> <select id="selectJobLogById" parameterType="Long" resultMap="SysJobLogResult">
<include refid="selectJobLogVo"/> <include refid="selectJobLogVo"/>
where job_log_id = #{jobLogId} where job_log_id = #{jobLogId}
</select> </select>
<delete id="deleteJobLogById" parameterType="Long"> <delete id="deleteJobLogById" parameterType="Long">
delete from sys_job_log where job_log_id = #{jobLogId} delete from sys_job_log where job_log_id = #{jobLogId}
</delete> </delete>
<delete id="deleteJobLogByIds" parameterType="String"> <delete id="deleteJobLogByIds" parameterType="String">
delete from sys_job_log where job_log_id in delete from sys_job_log where job_log_id in
<foreach collection="array" item="jobLogId" open="(" separator="," close=")"> <foreach collection="array" item="jobLogId" open="(" separator="," close=")">
#{jobLogId} #{jobLogId}
</foreach> </foreach>
</delete> </delete>
<update id="cleanJobLog"> <update id="cleanJobLog">
truncate table sys_job_log truncate table sys_job_log
</update> </update>
<insert id="insertJobLog" parameterType="SysJobLog"> <insert id="insertJobLog" parameterType="SysJobLog">
insert into sys_job_log( insert into sys_job_log(
<if test="jobLogId != null and jobLogId != 0">job_log_id,</if> <if test="jobLogId != null and jobLogId != 0">job_log_id,</if>
@ -86,8 +86,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="jobMessage != null and jobMessage != ''">#{jobMessage},</if> <if test="jobMessage != null and jobMessage != ''">#{jobMessage},</if>
<if test="status != null and status != ''">#{status},</if> <if test="status != null and status != ''">#{status},</if>
<if test="exceptionInfo != null and exceptionInfo != ''">#{exceptionInfo},</if> <if test="exceptionInfo != null and exceptionInfo != ''">#{exceptionInfo},</if>
sysdate() GETDATE()
) )
</insert> </insert>
</mapper> </mapper>

@ -19,17 +19,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="updateTime" column="update_time" /> <result property="updateTime" column="update_time" />
<result property="remark" column="remark" /> <result property="remark" column="remark" />
</resultMap> </resultMap>
<sql id="selectJobVo"> <sql id="selectJobVo">
select job_id, job_name, job_group, invoke_target, cron_expression, misfire_policy, concurrent, status, create_by, create_time, remark select job_id, job_name, job_group, invoke_target, cron_expression, misfire_policy, concurrent, status, create_by, create_time, remark
from sys_job from sys_job
</sql> </sql>
<select id="selectJobList" parameterType="SysJob" resultMap="SysJobResult"> <select id="selectJobList" parameterType="SysJob" resultMap="SysJobResult">
<include refid="selectJobVo"/> <include refid="selectJobVo"/>
<where> <where>
<if test="jobName != null and jobName != ''"> <if test="jobName != null and jobName != ''">
AND job_name like concat('%', #{jobName}, '%') AND job_name like ('%' + #{jobName} + '%')
</if> </if>
<if test="jobGroup != null and jobGroup != ''"> <if test="jobGroup != null and jobGroup != ''">
AND job_group = #{jobGroup} AND job_group = #{jobGroup}
@ -38,31 +38,31 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
AND status = #{status} AND status = #{status}
</if> </if>
<if test="invokeTarget != null and invokeTarget != ''"> <if test="invokeTarget != null and invokeTarget != ''">
AND invoke_target like concat('%', #{invokeTarget}, '%') AND invoke_target like ('%' + #{invokeTarget} + '%')
</if> </if>
</where> </where>
</select> </select>
<select id="selectJobAll" resultMap="SysJobResult"> <select id="selectJobAll" resultMap="SysJobResult">
<include refid="selectJobVo"/> <include refid="selectJobVo"/>
</select> </select>
<select id="selectJobById" parameterType="Long" resultMap="SysJobResult"> <select id="selectJobById" parameterType="Long" resultMap="SysJobResult">
<include refid="selectJobVo"/> <include refid="selectJobVo"/>
where job_id = #{jobId} where job_id = #{jobId}
</select> </select>
<delete id="deleteJobById" parameterType="Long"> <delete id="deleteJobById" parameterType="Long">
delete from sys_job where job_id = #{jobId} delete from sys_job where job_id = #{jobId}
</delete> </delete>
<delete id="deleteJobByIds" parameterType="Long"> <delete id="deleteJobByIds" parameterType="Long">
delete from sys_job where job_id in delete from sys_job where job_id in
<foreach collection="array" item="jobId" open="(" separator="," close=")"> <foreach collection="array" item="jobId" open="(" separator="," close=")">
#{jobId} #{jobId}
</foreach> </foreach>
</delete> </delete>
<update id="updateJob" parameterType="SysJob"> <update id="updateJob" parameterType="SysJob">
update sys_job update sys_job
<set> <set>
@ -75,11 +75,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="status !=null">status = #{status},</if> <if test="status !=null">status = #{status},</if>
<if test="remark != null and remark != ''">remark = #{remark},</if> <if test="remark != null and remark != ''">remark = #{remark},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if> <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
update_time = sysdate() update_time = GETDATE()
</set> </set>
where job_id = #{jobId} where job_id = #{jobId}
</update> </update>
<insert id="insertJob" parameterType="SysJob" useGeneratedKeys="true" keyProperty="jobId"> <insert id="insertJob" parameterType="SysJob" useGeneratedKeys="true" keyProperty="jobId">
insert into sys_job( insert into sys_job(
<if test="jobId != null and jobId != 0">job_id,</if> <if test="jobId != null and jobId != 0">job_id,</if>
@ -104,8 +104,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="status != null and status != ''">#{status},</if> <if test="status != null and status != ''">#{status},</if>
<if test="remark != null and remark != ''">#{remark},</if> <if test="remark != null and remark != ''">#{remark},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if> <if test="createBy != null and createBy != ''">#{createBy},</if>
sysdate() GETDATE()
) )
</insert> </insert>
</mapper> </mapper>

@ -17,6 +17,12 @@
<dependencies> <dependencies>
<!-- SqlServer驱动包 -->
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>7.4.1.jre8</version>
</dependency>
<!-- 通用工具--> <!-- 通用工具-->
<dependency> <dependency>
<groupId>com.ruoyi</groupId> <groupId>com.ruoyi</groupId>
@ -25,4 +31,4 @@
</dependencies> </dependencies>
</project> </project>

@ -3,7 +3,7 @@
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.system.mapper.SysConfigMapper"> <mapper namespace="com.ruoyi.system.mapper.SysConfigMapper">
<resultMap type="SysConfig" id="SysConfigResult"> <resultMap type="SysConfig" id="SysConfigResult">
<id property="configId" column="config_id" /> <id property="configId" column="config_id" />
<result property="configName" column="config_name" /> <result property="configName" column="config_name" />
@ -15,12 +15,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="updateBy" column="update_by" /> <result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" /> <result property="updateTime" column="update_time" />
</resultMap> </resultMap>
<sql id="selectConfigVo"> <sql id="selectConfigVo">
select config_id, config_name, config_key, config_value, config_type, create_by, create_time, update_by, update_time, remark select config_id, config_name, config_key, config_value, config_type, create_by, create_time, update_by, update_time, remark
from sys_config from sys_config
</sql> </sql>
<!-- 查询条件 --> <!-- 查询条件 -->
<sql id="sqlwhereSearch"> <sql id="sqlwhereSearch">
<where> <where>
@ -32,38 +32,38 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</if> </if>
</where> </where>
</sql> </sql>
<select id="selectConfig" parameterType="SysConfig" resultMap="SysConfigResult"> <select id="selectConfig" parameterType="SysConfig" resultMap="SysConfigResult">
<include refid="selectConfigVo"/> <include refid="selectConfigVo"/>
<include refid="sqlwhereSearch"/> <include refid="sqlwhereSearch"/>
</select> </select>
<select id="selectConfigList" parameterType="SysConfig" resultMap="SysConfigResult"> <select id="selectConfigList" parameterType="SysConfig" resultMap="SysConfigResult">
<include refid="selectConfigVo"/> <include refid="selectConfigVo"/>
<where> <where>
<if test="configName != null and configName != ''"> <if test="configName != null and configName != ''">
AND config_name like concat('%', #{configName}, '%') AND config_name like ('%' + #{configName} + '%')
</if> </if>
<if test="configType != null and configType != ''"> <if test="configType != null and configType != ''">
AND config_type = #{configType} AND config_type = #{configType}
</if> </if>
<if test="configKey != null and configKey != ''"> <if test="configKey != null and configKey != ''">
AND config_key like concat('%', #{configKey}, '%') AND config_key like ('%' + #{configKey} + '%')
</if> </if>
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 --> <if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
and date_format(create_time,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d') and datediff(dd,#{params.beginTime},create_time)>= 0
</if> </if>
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 --> <if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
and date_format(create_time,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d') and datediff(dd,create_time,#{params.endTime})>= 0
</if> </if>
</where> </where>
</select> </select>
<select id="checkConfigKeyUnique" parameterType="String" resultMap="SysConfigResult"> <select id="checkConfigKeyUnique" parameterType="String" resultMap="SysConfigResult">
<include refid="selectConfigVo"/> <include refid="selectConfigVo"/>
where config_key = #{configKey} where config_key = #{configKey}
</select> </select>
<insert id="insertConfig" parameterType="SysConfig"> <insert id="insertConfig" parameterType="SysConfig">
insert into sys_config ( insert into sys_config (
<if test="configName != null and configName != '' ">config_name,</if> <if test="configName != null and configName != '' ">config_name,</if>
@ -80,12 +80,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="configType != null and configType != ''">#{configType},</if> <if test="configType != null and configType != ''">#{configType},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if> <if test="createBy != null and createBy != ''">#{createBy},</if>
<if test="remark != null and remark != ''">#{remark},</if> <if test="remark != null and remark != ''">#{remark},</if>
sysdate() GETDATE()
) )
</insert> </insert>
<update id="updateConfig" parameterType="SysConfig"> <update id="updateConfig" parameterType="SysConfig">
update sys_config update sys_config
<set> <set>
<if test="configName != null and configName != ''">config_name = #{configName},</if> <if test="configName != null and configName != ''">config_name = #{configName},</if>
<if test="configKey != null and configKey != ''">config_key = #{configKey},</if> <if test="configKey != null and configKey != ''">config_key = #{configKey},</if>
@ -93,16 +93,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="configType != null and configType != ''">config_type = #{configType},</if> <if test="configType != null and configType != ''">config_type = #{configType},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if> <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
<if test="remark != null">remark = #{remark},</if> <if test="remark != null">remark = #{remark},</if>
update_time = sysdate() update_time = GETDATE()
</set> </set>
where config_id = #{configId} where config_id = #{configId}
</update> </update>
<delete id="deleteConfigByIds" parameterType="String"> <delete id="deleteConfigByIds" parameterType="String">
delete from sys_config where config_id in delete from sys_config where config_id in
<foreach item="configId" collection="array" open="(" separator="," close=")"> <foreach item="configId" collection="array" open="(" separator="," close=")">
#{configId} #{configId}
</foreach> </foreach>
</delete> </delete>
</mapper> </mapper>

@ -21,20 +21,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="updateBy" column="update_by" /> <result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" /> <result property="updateTime" column="update_time" />
</resultMap> </resultMap>
<sql id="selectDeptVo"> <sql id="selectDeptVo">
select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status, d.del_flag, d.create_by, d.create_time select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status, d.del_flag, d.create_by, d.create_time
from sys_dept d from sys_dept d
</sql> </sql>
<select id="selectRoleDeptTree" parameterType="Long" resultType="String"> <select id="selectRoleDeptTree" parameterType="Long" resultType="String">
select concat(d.dept_id, d.dept_name) as dept_name select (convert(varchar(100),d.dept_id) + d.dept_name) as dept_name
from sys_dept d from sys_dept d
left join sys_role_dept rd on d.dept_id = rd.dept_id left join sys_role_dept rd on d.dept_id = rd.dept_id
where d.del_flag = '0' and rd.role_id = #{roleId} where d.del_flag = '0' and rd.role_id = #{roleId}
order by d.parent_id, d.order_num order by d.parent_id, d.order_num
</select> </select>
<select id="selectDeptList" parameterType="SysDept" resultMap="SysDeptResult"> <select id="selectDeptList" parameterType="SysDept" resultMap="SysDeptResult">
<include refid="selectDeptVo"/> <include refid="selectDeptVo"/>
where d.del_flag = '0' where d.del_flag = '0'
@ -42,7 +42,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
AND parent_id = #{parentId} AND parent_id = #{parentId}
</if> </if>
<if test="deptName != null and deptName != ''"> <if test="deptName != null and deptName != ''">
AND dept_name like concat('%', #{deptName}, '%') AND dept_name like ('%' + #{deptName} + '%')
</if> </if>
<if test="status != null and status != ''"> <if test="status != null and status != ''">
AND status = #{status} AND status = #{status}
@ -51,18 +51,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
${params.dataScope} ${params.dataScope}
order by d.parent_id, d.order_num order by d.parent_id, d.order_num
</select> </select>
<select id="checkDeptExistUser" parameterType="Long" resultType="int"> <select id="checkDeptExistUser" parameterType="Long" resultType="int">
select count(1) from sys_user where dept_id = #{deptId} and del_flag = '0' select count(1) from sys_user where dept_id = #{deptId} and del_flag = '0'
</select> </select>
<select id="selectDeptCount" parameterType="SysDept" resultType="int"> <select id="selectDeptCount" parameterType="SysDept" resultType="int">
select count(1) from sys_dept select count(1) from sys_dept
where del_flag = '0' where del_flag = '0'
<if test="deptId != null and deptId != 0"> and dept_id = #{deptId} </if> <if test="deptId != null and deptId != 0"> and dept_id = #{deptId} </if>
<if test="parentId != null and parentId != 0"> and parent_id = #{parentId} </if> <if test="parentId != null and parentId != 0"> and parent_id = #{parentId} </if>
</select> </select>
<select id="checkDeptNameUnique" resultMap="SysDeptResult"> <select id="checkDeptNameUnique" resultMap="SysDeptResult">
<include refid="selectDeptVo"/> <include refid="selectDeptVo"/>
where dept_name=#{deptName} and parent_id = #{parentId} where dept_name=#{deptName} and parent_id = #{parentId}
@ -76,13 +76,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select> </select>
<select id="selectChildrenDeptById" parameterType="Long" resultMap="SysDeptResult"> <select id="selectChildrenDeptById" parameterType="Long" resultMap="SysDeptResult">
select * from sys_dept where find_in_set(#{deptId}, ancestors) select * from sys_dept where CHARINDEX(cast(#{deptId} as nvarchar),ancestors)>0
</select> </select>
<select id="selectNormalChildrenDeptById" parameterType="Long" resultType="int"> <select id="selectNormalChildrenDeptById" parameterType="Long" resultType="int">
select count(*) from sys_dept where status = 0 and del_flag = '0' and find_in_set(#{deptId}, ancestors) select count(*) from sys_dept where status = 0 and del_flag = '0' and CHARINDEX(cast(#{deptId} as nvarchar),ancestors)>0
</select> </select>
<insert id="insertDept" parameterType="SysDept"> <insert id="insertDept" parameterType="SysDept">
insert into sys_dept( insert into sys_dept(
<if test="deptId != null and deptId != 0">dept_id,</if> <if test="deptId != null and deptId != 0">dept_id,</if>
@ -107,10 +108,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="email != null and email != ''">#{email},</if> <if test="email != null and email != ''">#{email},</if>
<if test="status != null">#{status},</if> <if test="status != null">#{status},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if> <if test="createBy != null and createBy != ''">#{createBy},</if>
sysdate() GETDATE()
) )
</insert> </insert>
<update id="updateDept" parameterType="SysDept"> <update id="updateDept" parameterType="SysDept">
update sys_dept update sys_dept
<set> <set>
@ -123,11 +124,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="email != null">email = #{email},</if> <if test="email != null">email = #{email},</if>
<if test="status != null and status != ''">status = #{status},</if> <if test="status != null and status != ''">status = #{status},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if> <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
update_time = sysdate() update_time = GETDATE()
</set> </set>
where dept_id = #{deptId} where dept_id = #{deptId}
</update> </update>
<update id="updateDeptChildren" parameterType="java.util.List"> <update id="updateDeptChildren" parameterType="java.util.List">
update sys_dept set ancestors = update sys_dept set ancestors =
<foreach collection="depts" item="item" index="index" <foreach collection="depts" item="item" index="index"
@ -144,15 +145,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<delete id="deleteDeptById" parameterType="Long"> <delete id="deleteDeptById" parameterType="Long">
update sys_dept set del_flag = '2' where dept_id = #{deptId} update sys_dept set del_flag = '2' where dept_id = #{deptId}
</delete> </delete>
<update id="updateDeptStatus" parameterType="SysDept"> <update id="updateDeptStatus" parameterType="SysDept">
update sys_dept update sys_dept
<set> <set>
<if test="status != null and status != ''">status = #{status},</if> <if test="status != null and status != ''">status = #{status},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if> <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
update_time = sysdate() update_time = GETDATE()
</set> </set>
where dept_id in (${ancestors}) where dept_id in (${ancestors})
</update> </update>
</mapper> </mapper>

@ -3,7 +3,7 @@
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.system.mapper.SysDictDataMapper"> <mapper namespace="com.ruoyi.system.mapper.SysDictDataMapper">
<resultMap type="SysDictData" id="SysDictDataResult"> <resultMap type="SysDictData" id="SysDictDataResult">
<id property="dictCode" column="dict_code" /> <id property="dictCode" column="dict_code" />
<result property="dictSort" column="dict_sort" /> <result property="dictSort" column="dict_sort" />
@ -19,9 +19,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="updateBy" column="update_by" /> <result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" /> <result property="updateTime" column="update_time" />
</resultMap> </resultMap>
<sql id="selectDictDataVo"> <sql id="selectDictDataVo">
select dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, status, create_by, create_time, remark select dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, status, create_by, create_time, remark
from sys_dict_data from sys_dict_data
</sql> </sql>
@ -32,44 +32,44 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
AND dict_type = #{dictType} AND dict_type = #{dictType}
</if> </if>
<if test="dictLabel != null and dictLabel != ''"> <if test="dictLabel != null and dictLabel != ''">
AND dict_label like concat('%', #{dictLabel}, '%') AND dict_label like ('%' + #{dictLabel} + '%')
</if> </if>
<if test="status != null and status != ''"> <if test="status != null and status != ''">
AND status = #{status} AND status = #{status}
</if> </if>
</where> </where>
</select> </select>
<select id="selectDictDataByType" parameterType="SysDictData" resultMap="SysDictDataResult"> <select id="selectDictDataByType" parameterType="SysDictData" resultMap="SysDictDataResult">
<include refid="selectDictDataVo"/> <include refid="selectDictDataVo"/>
where status = '0' and dict_type = #{dictType} order by dict_sort asc where status = '0' and dict_type = #{dictType} order by dict_sort asc
</select> </select>
<select id="selectDictLabel" resultType="String"> <select id="selectDictLabel" resultType="String">
select dict_label from sys_dict_data select dict_label from sys_dict_data
where dict_type = #{dictType} and dict_value = #{dictValue} where dict_type = #{dictType} and dict_value = #{dictValue}
</select> </select>
<select id="selectDictDataById" parameterType="Long" resultMap="SysDictDataResult"> <select id="selectDictDataById" parameterType="Long" resultMap="SysDictDataResult">
<include refid="selectDictDataVo"/> <include refid="selectDictDataVo"/>
where dict_code = #{dictCode} where dict_code = #{dictCode}
</select> </select>
<select id="countDictDataByType" resultType="Integer"> <select id="countDictDataByType" resultType="Integer">
select count(1) from sys_dict_data where dict_type=#{dictType} select count(1) from sys_dict_data where dict_type=#{dictType}
</select> </select>
<delete id="deleteDictDataById" parameterType="Long"> <delete id="deleteDictDataById" parameterType="Long">
delete from sys_dict_data where dict_code = #{dictCode} delete from sys_dict_data where dict_code = #{dictCode}
</delete> </delete>
<delete id="deleteDictDataByIds" parameterType="String"> <delete id="deleteDictDataByIds" parameterType="String">
delete from sys_dict_data where dict_code in delete from sys_dict_data where dict_code in
<foreach collection="array" item="dictCode" open="(" separator="," close=")"> <foreach collection="array" item="dictCode" open="(" separator="," close=")">
#{dictCode} #{dictCode}
</foreach> </foreach>
</delete> </delete>
<update id="updateDictData" parameterType="SysDictData"> <update id="updateDictData" parameterType="SysDictData">
update sys_dict_data update sys_dict_data
<set> <set>
@ -83,15 +83,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="status != null">status = #{status},</if> <if test="status != null">status = #{status},</if>
<if test="remark != null">remark = #{remark},</if> <if test="remark != null">remark = #{remark},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if> <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
update_time = sysdate() update_time = GETDATE()
</set> </set>
where dict_code = #{dictCode} where dict_code = #{dictCode}
</update> </update>
<update id="updateDictDataType" parameterType="String"> <update id="updateDictDataType" parameterType="String">
update sys_dict_data set dict_type = #{newDictType} where dict_type = #{oldDictType} update sys_dict_data set dict_type = #{newDictType} where dict_type = #{oldDictType}
</update> </update>
<insert id="insertDictData" parameterType="SysDictData"> <insert id="insertDictData" parameterType="SysDictData">
insert into sys_dict_data( insert into sys_dict_data(
<if test="dictSort != null">dict_sort,</if> <if test="dictSort != null">dict_sort,</if>
@ -116,8 +116,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="status != null">#{status},</if> <if test="status != null">#{status},</if>
<if test="remark != null and remark != ''">#{remark},</if> <if test="remark != null and remark != ''">#{remark},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if> <if test="createBy != null and createBy != ''">#{createBy},</if>
sysdate() GETDATE()
) )
</insert> </insert>
</mapper> </mapper>

@ -14,9 +14,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="updateBy" column="update_by" /> <result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" /> <result property="updateTime" column="update_time" />
</resultMap> </resultMap>
<sql id="selectDictTypeVo"> <sql id="selectDictTypeVo">
select dict_id, dict_name, dict_type, status, create_by, create_time, remark select dict_id, dict_name, dict_type, status, create_by, create_time, remark
from sys_dict_type from sys_dict_type
</sql> </sql>
@ -24,51 +24,51 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectDictTypeVo"/> <include refid="selectDictTypeVo"/>
<where> <where>
<if test="dictName != null and dictName != ''"> <if test="dictName != null and dictName != ''">
AND dict_name like concat('%', #{dictName}, '%') AND dict_name like ('%' + #{dictName} + '%')
</if> </if>
<if test="status != null and status != ''"> <if test="status != null and status != ''">
AND status = #{status} AND status = #{status}
</if> </if>
<if test="dictType != null and dictType != ''"> <if test="dictType != null and dictType != ''">
AND dict_type like concat('%', #{dictType}, '%') AND dict_type like ('%' + #{dictType} + '%')
</if> </if>
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 --> <if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
and date_format(create_time,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d') and datediff(dd,#{params.beginTime},create_time)>= 0
</if> </if>
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 --> <if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
and date_format(create_time,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d') and datediff(dd,create_time,#{params.endTime})>= 0
</if> </if>
</where> </where>
</select> </select>
<select id="selectDictTypeAll" resultMap="SysDictTypeResult"> <select id="selectDictTypeAll" resultMap="SysDictTypeResult">
<include refid="selectDictTypeVo"/> <include refid="selectDictTypeVo"/>
</select> </select>
<select id="selectDictTypeById" parameterType="Long" resultMap="SysDictTypeResult"> <select id="selectDictTypeById" parameterType="Long" resultMap="SysDictTypeResult">
<include refid="selectDictTypeVo"/> <include refid="selectDictTypeVo"/>
where dict_id = #{dictId} where dict_id = #{dictId}
</select> </select>
<select id="selectDictTypeByType" parameterType="String" resultMap="SysDictTypeResult"> <select id="selectDictTypeByType" parameterType="String" resultMap="SysDictTypeResult">
<include refid="selectDictTypeVo"/> <include refid="selectDictTypeVo"/>
where dict_type = #{dictType} where dict_type = #{dictType}
</select> </select>
<select id="checkDictTypeUnique" parameterType="String" resultMap="SysDictTypeResult"> <select id="checkDictTypeUnique" parameterType="String" resultMap="SysDictTypeResult">
<include refid="selectDictTypeVo"/> <include refid="selectDictTypeVo"/>
where dict_type = #{dictType} where dict_type = #{dictType}
</select> </select>
<delete id="deleteDictTypeById" parameterType="Long"> <delete id="deleteDictTypeById" parameterType="Long">
delete from sys_dict_type where dict_id = #{dictId} delete from sys_dict_type where dict_id = #{dictId}
</delete> </delete>
<delete id="deleteDictTypeByIds" parameterType="Long"> <delete id="deleteDictTypeByIds" parameterType="Long">
delete from sys_dict_type where dict_id in delete from sys_dict_type where dict_id in
<foreach collection="array" item="dictId" open="(" separator="," close=")"> <foreach collection="array" item="dictId" open="(" separator="," close=")">
#{dictId} #{dictId}
</foreach> </foreach>
</delete> </delete>
<update id="updateDictType" parameterType="SysDictType"> <update id="updateDictType" parameterType="SysDictType">
@ -79,11 +79,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="status != null">status = #{status},</if> <if test="status != null">status = #{status},</if>
<if test="remark != null">remark = #{remark},</if> <if test="remark != null">remark = #{remark},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if> <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
update_time = sysdate() update_time = GETDATE()
</set> </set>
where dict_id = #{dictId} where dict_id = #{dictId}
</update> </update>
<insert id="insertDictType" parameterType="SysDictType"> <insert id="insertDictType" parameterType="SysDictType">
insert into sys_dict_type( insert into sys_dict_type(
<if test="dictName != null and dictName != ''">dict_name,</if> <if test="dictName != null and dictName != ''">dict_name,</if>
@ -98,8 +98,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="status != null">#{status},</if> <if test="status != null">#{status},</if>
<if test="remark != null and remark != ''">#{remark},</if> <if test="remark != null and remark != ''">#{remark},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if> <if test="createBy != null and createBy != ''">#{createBy},</if>
sysdate() GETDATE()
) )
</insert> </insert>
</mapper> </mapper>

@ -18,39 +18,39 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<insert id="insertLogininfor" parameterType="SysLogininfor"> <insert id="insertLogininfor" parameterType="SysLogininfor">
insert into sys_logininfor (login_name, status, ipaddr, login_location, browser, os, msg, login_time) insert into sys_logininfor (login_name, status, ipaddr, login_location, browser, os, msg, login_time)
values (#{loginName}, #{status}, #{ipaddr}, #{loginLocation}, #{browser}, #{os}, #{msg}, sysdate()) values (#{loginName}, #{status}, #{ipaddr}, #{loginLocation}, #{browser}, #{os}, #{msg}, GETDATE())
</insert> </insert>
<select id="selectLogininforList" parameterType="SysLogininfor" resultMap="SysLogininforResult"> <select id="selectLogininforList" parameterType="SysLogininfor" resultMap="SysLogininforResult">
select info_id,login_name,ipaddr,login_location,browser,os,status,msg,login_time from sys_logininfor select info_id,login_name,ipaddr,login_location,browser,os,status,msg,login_time from sys_logininfor
<where> <where>
<if test="ipaddr != null and ipaddr != ''"> <if test="ipaddr != null and ipaddr != ''">
AND ipaddr like concat('%', #{ipaddr}, '%') AND ipaddr like ('%' + #{ipaddr} + '%')
</if> </if>
<if test="status != null and status != ''"> <if test="status != null and status != ''">
AND status = #{status} AND status = #{status}
</if> </if>
<if test="loginName != null and loginName != ''"> <if test="loginName != null and loginName != ''">
AND login_name like concat('%', #{loginName}, '%') AND login_name like ('%' + #{loginName} + '%')
</if> </if>
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 --> <if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
and date_format(login_time,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d') and datediff(dd,#{params.beginTime},login_time)>= 0
</if> </if>
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 --> <if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
and date_format(login_time,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d') and datediff(dd,login_time,#{params.endTime})>= 0
</if> </if>
</where> </where>
</select> </select>
<delete id="deleteLogininforByIds" parameterType="String"> <delete id="deleteLogininforByIds" parameterType="String">
delete from sys_logininfor where info_id in delete from sys_logininfor where info_id in
<foreach collection="array" item="infoId" open="(" separator="," close=")"> <foreach collection="array" item="infoId" open="(" separator="," close=")">
#{infoId} #{infoId}
</foreach> </foreach>
</delete> </delete>
<update id="cleanLogininfor"> <update id="cleanLogininfor">
truncate table sys_logininfor truncate table sys_logininfor
</update> </update>
</mapper> </mapper>

@ -24,12 +24,12 @@
</resultMap> </resultMap>
<sql id="selectMenuVo"> <sql id="selectMenuVo">
select menu_id, menu_name, parent_id, order_num, url, target, menu_type, visible, ifnull(perms,'') as perms, icon, create_by, create_time select menu_id, menu_name, parent_id, order_num, url, target, menu_type, visible, isnull(perms,'') as perms, icon, create_by, create_time
from sys_menu from sys_menu
</sql> </sql>
<select id="selectMenusByUserId" parameterType="Long" resultMap="SysMenuResult"> <select id="selectMenusByUserId" parameterType="Long" resultMap="SysMenuResult">
select distinct m.menu_id, m.parent_id, m.menu_name, m.url, m.visible, ifnull(m.perms,'') as perms, m.target, m.menu_type, m.icon, m.order_num, m.create_time select distinct m.menu_id, m.parent_id, m.menu_name, m.url, m.visible, isnull(m.perms,'') as perms, m.target, m.menu_type, m.icon, m.order_num, m.create_time
from sys_menu m from sys_menu m
left join sys_role_menu rm on m.menu_id = rm.menu_id left join sys_role_menu rm on m.menu_id = rm.menu_id
left join sys_user_role ur on rm.role_id = ur.role_id left join sys_user_role ur on rm.role_id = ur.role_id
@ -39,7 +39,7 @@
</select> </select>
<select id="selectMenuNormalAll" resultMap="SysMenuResult"> <select id="selectMenuNormalAll" resultMap="SysMenuResult">
select distinct m.menu_id, m.parent_id, m.menu_name, m.url, m.visible, ifnull(m.perms,'') as perms, m.target, m.menu_type, m.icon, m.order_num, m.create_time select distinct m.menu_id, m.parent_id, m.menu_name, m.url, m.visible, isnull(m.perms,'') as perms, m.target, m.menu_type, m.icon, m.order_num, m.create_time
from sys_menu m from sys_menu m
where m.menu_type in ('M', 'C') and m.visible = 0 where m.menu_type in ('M', 'C') and m.visible = 0
order by m.parent_id, m.order_num order by m.parent_id, m.order_num
@ -51,7 +51,7 @@
</select> </select>
<select id="selectMenuAllByUserId" parameterType="Long" resultMap="SysMenuResult"> <select id="selectMenuAllByUserId" parameterType="Long" resultMap="SysMenuResult">
select distinct m.menu_id, m.parent_id, m.menu_name, m.url, m.visible, ifnull(m.perms,'') as perms, m.target, m.menu_type, m.icon, m.order_num, m.create_time select distinct m.menu_id, m.parent_id, m.menu_name, m.url, m.visible, isnull(m.perms,'') as perms, m.target, m.menu_type, m.icon, m.order_num, m.create_time
from sys_menu m from sys_menu m
left join sys_role_menu rm on m.menu_id = rm.menu_id left join sys_role_menu rm on m.menu_id = rm.menu_id
left join sys_user_role ur on rm.role_id = ur.role_id left join sys_user_role ur on rm.role_id = ur.role_id
@ -70,7 +70,7 @@
</select> </select>
<select id="selectMenuTree" parameterType="Long" resultType="String"> <select id="selectMenuTree" parameterType="Long" resultType="String">
select concat(m.menu_id, ifnull(m.perms,'')) as perms select (convert(varchar(100),m.menu_id) + isnull(m.perms,'')) as perms
from sys_menu m from sys_menu m
left join sys_role_menu rm on m.menu_id = rm.menu_id left join sys_role_menu rm on m.menu_id = rm.menu_id
where rm.role_id = #{roleId} where rm.role_id = #{roleId}
@ -81,7 +81,7 @@
<include refid="selectMenuVo"/> <include refid="selectMenuVo"/>
<where> <where>
<if test="menuName != null and menuName != ''"> <if test="menuName != null and menuName != ''">
AND menu_name like concat('%', #{menuName}, '%') AND menu_name like ('%' + #{menuName} + '%')
</if> </if>
<if test="visible != null and visible != ''"> <if test="visible != null and visible != ''">
AND visible = #{visible} AND visible = #{visible}
@ -91,14 +91,14 @@
</select> </select>
<select id="selectMenuListByUserId" parameterType="SysMenu" resultMap="SysMenuResult"> <select id="selectMenuListByUserId" parameterType="SysMenu" resultMap="SysMenuResult">
select distinct m.menu_id, m.parent_id, m.menu_name, m.url, m.visible, ifnull(m.perms,'') as perms, m.target, m.menu_type, m.icon, m.order_num, m.create_time select distinct m.menu_id, m.parent_id, m.menu_name, m.url, m.visible, isnull(m.perms,'') as perms, m.target, m.menu_type, m.icon, m.order_num, m.create_time
from sys_menu m from sys_menu m
left join sys_role_menu rm on m.menu_id = rm.menu_id left join sys_role_menu rm on m.menu_id = rm.menu_id
left join sys_user_role ur on rm.role_id = ur.role_id left join sys_user_role ur on rm.role_id = ur.role_id
LEFT JOIN sys_role ro on ur.role_id = ro.role_id LEFT JOIN sys_role ro on ur.role_id = ro.role_id
where ur.user_id = #{params.userId} where ur.user_id = #{params.userId}
<if test="menuName != null and menuName != ''"> <if test="menuName != null and menuName != ''">
AND m.menu_name like concat('%', #{menuName}, '%') AND m.menu_name like ('%' + #{menuName} + '%')
</if> </if>
<if test="visible != null and visible != ''"> <if test="visible != null and visible != ''">
AND m.visible = #{visible} AND m.visible = #{visible}
@ -118,7 +118,7 @@
</select> </select>
<select id="selectCountMenuByParentId" resultType="Integer"> <select id="selectCountMenuByParentId" resultType="Integer">
select count(1) from sys_menu where parent_id=#{menuId} select count(1) from sys_menu where parent_id=#{menuId}
</select> </select>
<select id="checkMenuNameUnique" parameterType="SysMenu" resultMap="SysMenuResult"> <select id="checkMenuNameUnique" parameterType="SysMenu" resultMap="SysMenuResult">
@ -140,7 +140,7 @@
<if test="icon !=null and icon != ''">icon = #{icon},</if> <if test="icon !=null and icon != ''">icon = #{icon},</if>
<if test="remark != null">remark = #{remark},</if> <if test="remark != null">remark = #{remark},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if> <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
update_time = sysdate() update_time = GETDATE()
</set> </set>
where menu_id = #{menuId} where menu_id = #{menuId}
</update> </update>
@ -173,8 +173,8 @@
<if test="icon != null and icon != ''">#{icon},</if> <if test="icon != null and icon != ''">#{icon},</if>
<if test="remark != null and remark != ''">#{remark},</if> <if test="remark != null and remark != ''">#{remark},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if> <if test="createBy != null and createBy != ''">#{createBy},</if>
sysdate() GETDATE()
) )
</insert> </insert>
</mapper> </mapper>

@ -3,7 +3,7 @@
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.system.mapper.SysNoticeMapper"> <mapper namespace="com.ruoyi.system.mapper.SysNoticeMapper">
<resultMap type="SysNotice" id="SysNoticeResult"> <resultMap type="SysNotice" id="SysNoticeResult">
<result property="noticeId" column="notice_id" /> <result property="noticeId" column="notice_id" />
<result property="noticeTitle" column="notice_title" /> <result property="noticeTitle" column="notice_title" />
@ -16,32 +16,32 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="updateTime" column="update_time" /> <result property="updateTime" column="update_time" />
<result property="remark" column="remark" /> <result property="remark" column="remark" />
</resultMap> </resultMap>
<sql id="selectNoticeVo"> <sql id="selectNoticeVo">
select notice_id, notice_title, notice_type, notice_content, status, create_by, create_time, update_by, update_time, remark select notice_id, notice_title, notice_type, notice_content, status, create_by, create_time, update_by, update_time, remark
from sys_notice from sys_notice
</sql> </sql>
<select id="selectNoticeById" parameterType="Long" resultMap="SysNoticeResult"> <select id="selectNoticeById" parameterType="Long" resultMap="SysNoticeResult">
<include refid="selectNoticeVo"/> <include refid="selectNoticeVo"/>
where notice_id = #{noticeId} where notice_id = #{noticeId}
</select> </select>
<select id="selectNoticeList" parameterType="SysNotice" resultMap="SysNoticeResult"> <select id="selectNoticeList" parameterType="SysNotice" resultMap="SysNoticeResult">
<include refid="selectNoticeVo"/> <include refid="selectNoticeVo"/>
<where> <where>
<if test="noticeTitle != null and noticeTitle != ''"> <if test="noticeTitle != null and noticeTitle != ''">
AND notice_title like concat('%', #{noticeTitle}, '%') AND notice_title like ('%' + #{noticeTitle} + '%')
</if> </if>
<if test="noticeType != null and noticeType != ''"> <if test="noticeType != null and noticeType != ''">
AND notice_type = #{noticeType} AND notice_type = #{noticeType}
</if> </if>
<if test="createBy != null and createBy != ''"> <if test="createBy != null and createBy != ''">
AND create_by like concat('%', #{createBy}, '%') AND create_by like ('%' + #{createBy} + '%')
</if> </if>
</where> </where>
</select> </select>
<insert id="insertNotice" parameterType="SysNotice"> <insert id="insertNotice" parameterType="SysNotice">
insert into sys_notice ( insert into sys_notice (
<if test="noticeTitle != null and noticeTitle != '' ">notice_title, </if> <if test="noticeTitle != null and noticeTitle != '' ">notice_title, </if>
@ -58,28 +58,28 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="status != null and status != ''">#{status}, </if> <if test="status != null and status != ''">#{status}, </if>
<if test="remark != null and remark != ''">#{remark},</if> <if test="remark != null and remark != ''">#{remark},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if> <if test="createBy != null and createBy != ''">#{createBy},</if>
sysdate() GETDATE()
) )
</insert> </insert>
<update id="updateNotice" parameterType="SysNotice"> <update id="updateNotice" parameterType="SysNotice">
update sys_notice update sys_notice
<set> <set>
<if test="noticeTitle != null and noticeTitle != ''">notice_title = #{noticeTitle}, </if> <if test="noticeTitle != null and noticeTitle != ''">notice_title = #{noticeTitle}, </if>
<if test="noticeType != null and noticeType != ''">notice_type = #{noticeType}, </if> <if test="noticeType != null and noticeType != ''">notice_type = #{noticeType}, </if>
<if test="noticeContent != null">notice_content = #{noticeContent}, </if> <if test="noticeContent != null">notice_content = #{noticeContent}, </if>
<if test="status != null and status != ''">status = #{status}, </if> <if test="status != null and status != ''">status = #{status}, </if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if> <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
update_time = sysdate() update_time = GETDATE()
</set> </set>
where notice_id = #{noticeId} where notice_id = #{noticeId}
</update> </update>
<delete id="deleteNoticeByIds" parameterType="String"> <delete id="deleteNoticeByIds" parameterType="String">
delete from sys_notice where notice_id in delete from sys_notice where notice_id in
<foreach item="noticeId" collection="array" open="(" separator="," close=")"> <foreach item="noticeId" collection="array" open="(" separator="," close=")">
#{noticeId} #{noticeId}
</foreach> </foreach>
</delete> </delete>
</mapper> </mapper>

@ -27,17 +27,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
select oper_id, title, business_type, method, request_method, operator_type, oper_name, dept_name, oper_url, oper_ip, oper_location, oper_param, json_result, status, error_msg, oper_time select oper_id, title, business_type, method, request_method, operator_type, oper_name, dept_name, oper_url, oper_ip, oper_location, oper_param, json_result, status, error_msg, oper_time
from sys_oper_log from sys_oper_log
</sql> </sql>
<insert id="insertOperlog" parameterType="SysOperLog"> <insert id="insertOperlog" parameterType="SysOperLog">
insert into sys_oper_log(title, business_type, method, request_method, operator_type, oper_name, dept_name, oper_url, oper_ip, oper_location, oper_param, json_result, status, error_msg, oper_time) insert into sys_oper_log(title, business_type, method, request_method, operator_type, oper_name, dept_name, oper_url, oper_ip, oper_location, oper_param, json_result, status, error_msg, oper_time)
values (#{title}, #{businessType}, #{method}, #{requestMethod}, #{operatorType}, #{operName}, #{deptName}, #{operUrl}, #{operIp}, #{operLocation}, #{operParam}, #{jsonResult}, #{status}, #{errorMsg}, sysdate()) values (#{title}, #{businessType}, #{method}, #{requestMethod}, #{operatorType}, #{operName}, #{deptName}, #{operUrl}, #{operIp}, #{operLocation}, #{operParam}, #{jsonResult}, #{status}, #{errorMsg}, GETDATE())
</insert> </insert>
<select id="selectOperLogList" parameterType="SysOperLog" resultMap="SysOperLogResult"> <select id="selectOperLogList" parameterType="SysOperLog" resultMap="SysOperLogResult">
<include refid="selectOperLogVo"/> <include refid="selectOperLogVo"/>
<where> <where>
<if test="title != null and title != ''"> <if test="title != null and title != ''">
AND title like concat('%', #{title}, '%') AND title like ('%' + #{title} + '%')
</if> </if>
<if test="businessType != null"> <if test="businessType != null">
AND business_type = #{businessType} AND business_type = #{businessType}
@ -46,37 +46,37 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
AND business_type in AND business_type in
<foreach collection="businessTypes" item="businessType" open="(" separator="," close=")"> <foreach collection="businessTypes" item="businessType" open="(" separator="," close=")">
#{businessType} #{businessType}
</foreach> </foreach>
</if> </if>
<if test="status != null"> <if test="status != null">
AND status = #{status} AND status = #{status}
</if> </if>
<if test="operName != null and operName != ''"> <if test="operName != null and operName != ''">
AND oper_name like concat('%', #{operName}, '%') AND oper_name like ('%' + #{operName} + '%')
</if> </if>
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 --> <if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
and date_format(oper_time,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d') and datediff(dd,#{params.beginTime},oper_time)>= 0
</if> </if>
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 --> <if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
and date_format(oper_time,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d') and datediff(dd,oper_time,#{params.endTime})>= 0
</if> </if>
</where> </where>
</select> </select>
<delete id="deleteOperLogByIds" parameterType="String"> <delete id="deleteOperLogByIds" parameterType="String">
delete from sys_oper_log where oper_id in delete from sys_oper_log where oper_id in
<foreach collection="array" item="operId" open="(" separator="," close=")"> <foreach collection="array" item="operId" open="(" separator="," close=")">
#{operId} #{operId}
</foreach> </foreach>
</delete> </delete>
<select id="selectOperLogById" parameterType="Long" resultMap="SysOperLogResult"> <select id="selectOperLogById" parameterType="Long" resultMap="SysOperLogResult">
<include refid="selectOperLogVo"/> <include refid="selectOperLogVo"/>
where oper_id = #{operId} where oper_id = #{operId}
</select> </select>
<update id="cleanOperLog"> <update id="cleanOperLog">
truncate table sys_oper_log truncate table sys_oper_log
</update> </update>
</mapper> </mapper>

@ -16,31 +16,31 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="updateTime" column="update_time" /> <result property="updateTime" column="update_time" />
<result property="remark" column="remark" /> <result property="remark" column="remark" />
</resultMap> </resultMap>
<sql id="selectPostVo"> <sql id="selectPostVo">
select post_id, post_code, post_name, post_sort, status, create_by, create_time, remark select post_id, post_code, post_name, post_sort, status, create_by, create_time, remark
from sys_post from sys_post
</sql> </sql>
<select id="selectPostList" parameterType="SysPost" resultMap="SysPostResult"> <select id="selectPostList" parameterType="SysPost" resultMap="SysPostResult">
<include refid="selectPostVo"/> <include refid="selectPostVo"/>
<where> <where>
<if test="postCode != null and postCode != ''"> <if test="postCode != null and postCode != ''">
AND post_code like concat('%', #{postCode}, '%') AND post_code like ('%' + #{postCode} + '%')
</if> </if>
<if test="status != null and status != ''"> <if test="status != null and status != ''">
AND status = #{status} AND status = #{status}
</if> </if>
<if test="postName != null and postName != ''"> <if test="postName != null and postName != ''">
AND post_name like concat('%', #{postName}, '%') AND post_name like ('%' + #{postName} + '%')
</if> </if>
</where> </where>
</select> </select>
<select id="selectPostAll" resultMap="SysPostResult"> <select id="selectPostAll" resultMap="SysPostResult">
<include refid="selectPostVo"/> <include refid="selectPostVo"/>
</select> </select>
<select id="selectPostsByUserId" parameterType="Long" resultMap="SysPostResult"> <select id="selectPostsByUserId" parameterType="Long" resultMap="SysPostResult">
SELECT p.post_id, p.post_name, p.post_code SELECT p.post_id, p.post_name, p.post_code
FROM sys_user u FROM sys_user u
@ -48,29 +48,29 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
LEFT JOIN sys_post p ON up.post_id = p.post_id LEFT JOIN sys_post p ON up.post_id = p.post_id
WHERE up.user_id = #{userId} WHERE up.user_id = #{userId}
</select> </select>
<select id="selectPostById" parameterType="Long" resultMap="SysPostResult"> <select id="selectPostById" parameterType="Long" resultMap="SysPostResult">
<include refid="selectPostVo"/> <include refid="selectPostVo"/>
where post_id = #{postId} where post_id = #{postId}
</select> </select>
<select id="checkPostNameUnique" parameterType="String" resultMap="SysPostResult"> <select id="checkPostNameUnique" parameterType="String" resultMap="SysPostResult">
<include refid="selectPostVo"/> <include refid="selectPostVo"/>
where post_name=#{postName} where post_name=#{postName}
</select> </select>
<select id="checkPostCodeUnique" parameterType="String" resultMap="SysPostResult"> <select id="checkPostCodeUnique" parameterType="String" resultMap="SysPostResult">
<include refid="selectPostVo"/> <include refid="selectPostVo"/>
where post_code=#{postCode} where post_code=#{postCode}
</select> </select>
<delete id="deletePostByIds" parameterType="Long"> <delete id="deletePostByIds" parameterType="Long">
delete from sys_post where post_id in delete from sys_post where post_id in
<foreach collection="array" item="postId" open="(" separator="," close=")"> <foreach collection="array" item="postId" open="(" separator="," close=")">
#{postId} #{postId}
</foreach> </foreach>
</delete> </delete>
<update id="updatePost" parameterType="SysPost"> <update id="updatePost" parameterType="SysPost">
update sys_post update sys_post
<set> <set>
@ -80,11 +80,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="status != null and status != ''">status = #{status},</if> <if test="status != null and status != ''">status = #{status},</if>
<if test="remark != null">remark = #{remark},</if> <if test="remark != null">remark = #{remark},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if> <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
update_time = sysdate() update_time = GETDATE()
</set> </set>
where post_id = #{postId} where post_id = #{postId}
</update> </update>
<insert id="insertPost" parameterType="SysPost" useGeneratedKeys="true" keyProperty="postId"> <insert id="insertPost" parameterType="SysPost" useGeneratedKeys="true" keyProperty="postId">
insert into sys_post( insert into sys_post(
<if test="postId != null and postId != 0">post_id,</if> <if test="postId != null and postId != 0">post_id,</if>
@ -103,8 +103,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="status != null and status != ''">#{status},</if> <if test="status != null and status != ''">#{status},</if>
<if test="remark != null and remark != ''">#{remark},</if> <if test="remark != null and remark != ''">#{remark},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if> <if test="createBy != null and createBy != ''">#{createBy},</if>
sysdate() GETDATE()
) )
</insert> </insert>
</mapper> </mapper>

@ -18,41 +18,41 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="updateTime" column="update_time" /> <result property="updateTime" column="update_time" />
<result property="remark" column="remark" /> <result property="remark" column="remark" />
</resultMap> </resultMap>
<sql id="selectRoleContactVo"> <sql id="selectRoleContactVo">
select distinct r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, select distinct r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope,
r.status, r.del_flag, r.create_time, r.remark r.status, r.del_flag, r.create_time, r.remark
from sys_role r from sys_role r
left join sys_user_role ur on ur.role_id = r.role_id left join sys_user_role ur on ur.role_id = r.role_id
left join sys_user u on u.user_id = ur.user_id left join sys_user u on u.user_id = ur.user_id
left join sys_dept d on u.dept_id = d.dept_id left join sys_dept d on u.dept_id = d.dept_id
</sql> </sql>
<sql id="selectRoleVo"> <sql id="selectRoleVo">
select r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.status, r.del_flag, r.create_time, r.remark select r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.status, r.del_flag, r.create_time, r.remark
from sys_role r from sys_role r
</sql> </sql>
<select id="selectRoleList" parameterType="SysRole" resultMap="SysRoleResult"> <select id="selectRoleList" parameterType="SysRole" resultMap="SysRoleResult">
<include refid="selectRoleContactVo"/> <include refid="selectRoleContactVo"/>
where r.del_flag = '0' where r.del_flag = '0'
<if test="roleName != null and roleName != ''"> <if test="roleName != null and roleName != ''">
AND r.role_name like concat('%', #{roleName}, '%') AND r.role_name like ('%' + #{roleName} + '%')
</if> </if>
<if test="status != null and status != ''"> <if test="status != null and status != ''">
AND r.status = #{status} AND r.status = #{status}
</if> </if>
<if test="roleKey != null and roleKey != ''"> <if test="roleKey != null and roleKey != ''">
AND r.role_key like concat('%', #{roleKey}, '%') AND r.role_key like ('%' + #{roleKey} + '%')
</if> </if>
<if test="dataScope != null and dataScope != ''"> <if test="dataScope != null and dataScope != ''">
AND r.data_scope = #{dataScope} AND r.data_scope = #{dataScope}
</if> </if>
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 --> <if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
and date_format(r.create_time,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d') and datediff(dd,#{params.beginTime},r.create_time)>= 0
</if> </if>
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 --> <if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
and date_format(r.create_time,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d') and datediff(dd,r.create_time,#{params.endTime})>= 0
</if> </if>
<!-- 数据范围过滤 --> <!-- 数据范围过滤 -->
${params.dataScope} ${params.dataScope}
@ -62,33 +62,33 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectRoleContactVo"/> <include refid="selectRoleContactVo"/>
WHERE r.del_flag = '0' and ur.user_id = #{userId} WHERE r.del_flag = '0' and ur.user_id = #{userId}
</select> </select>
<select id="selectRoleById" parameterType="Long" resultMap="SysRoleResult"> <select id="selectRoleById" parameterType="Long" resultMap="SysRoleResult">
<include refid="selectRoleVo"/> <include refid="selectRoleVo"/>
where r.del_flag = '0' and r.role_id = #{roleId} where r.del_flag = '0' and r.role_id = #{roleId}
</select> </select>
<select id="checkRoleNameUnique" parameterType="String" resultMap="SysRoleResult"> <select id="checkRoleNameUnique" parameterType="String" resultMap="SysRoleResult">
<include refid="selectRoleVo"/> <include refid="selectRoleVo"/>
where r.role_name=#{roleName} where r.role_name=#{roleName}
</select> </select>
<select id="checkRoleKeyUnique" parameterType="String" resultMap="SysRoleResult"> <select id="checkRoleKeyUnique" parameterType="String" resultMap="SysRoleResult">
<include refid="selectRoleVo"/> <include refid="selectRoleVo"/>
where r.role_key=#{roleKey} where r.role_key=#{roleKey}
</select> </select>
<delete id="deleteRoleById" parameterType="Long"> <delete id="deleteRoleById" parameterType="Long">
delete from sys_role where role_id = #{roleId} delete from sys_role where role_id = #{roleId}
</delete> </delete>
<delete id="deleteRoleByIds" parameterType="Long"> <delete id="deleteRoleByIds" parameterType="Long">
update sys_role set del_flag = '2' where role_id in update sys_role set del_flag = '2' where role_id in
<foreach collection="array" item="roleId" open="(" separator="," close=")"> <foreach collection="array" item="roleId" open="(" separator="," close=")">
#{roleId} #{roleId}
</foreach> </foreach>
</delete> </delete>
<update id="updateRole" parameterType="SysRole"> <update id="updateRole" parameterType="SysRole">
update sys_role update sys_role
<set> <set>
@ -99,11 +99,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="status != null and status != ''">status = #{status},</if> <if test="status != null and status != ''">status = #{status},</if>
<if test="remark != null">remark = #{remark},</if> <if test="remark != null">remark = #{remark},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if> <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
update_time = sysdate() update_time = GETDATE()
</set> </set>
where role_id = #{roleId} where role_id = #{roleId}
</update> </update>
<insert id="insertRole" parameterType="SysRole" useGeneratedKeys="true" keyProperty="roleId"> <insert id="insertRole" parameterType="SysRole" useGeneratedKeys="true" keyProperty="roleId">
insert into sys_role( insert into sys_role(
<if test="roleId != null and roleId != 0">role_id,</if> <if test="roleId != null and roleId != 0">role_id,</if>
@ -124,8 +124,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="status != null and status != ''">#{status},</if> <if test="status != null and status != ''">#{status},</if>
<if test="remark != null and remark != ''">#{remark},</if> <if test="remark != null and remark != ''">#{remark},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if> <if test="createBy != null and createBy != ''">#{createBy},</if>
sysdate() GETDATE()
) )
</insert> </insert>
</mapper> </mapper>

@ -28,7 +28,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<association property="dept" column="dept_id" javaType="SysDept" resultMap="deptResult" /> <association property="dept" column="dept_id" javaType="SysDept" resultMap="deptResult" />
<collection property="roles" javaType="java.util.List" resultMap="RoleResult" /> <collection property="roles" javaType="java.util.List" resultMap="RoleResult" />
</resultMap> </resultMap>
<resultMap id="deptResult" type="SysDept"> <resultMap id="deptResult" type="SysDept">
<id property="deptId" column="dept_id" /> <id property="deptId" column="dept_id" />
<result property="parentId" column="parent_id" /> <result property="parentId" column="parent_id" />
@ -37,7 +37,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="leader" column="leader" /> <result property="leader" column="leader" />
<result property="status" column="dept_status" /> <result property="status" column="dept_status" />
</resultMap> </resultMap>
<resultMap id="RoleResult" type="SysRole"> <resultMap id="RoleResult" type="SysRole">
<id property="roleId" column="role_id" /> <id property="roleId" column="role_id" />
<result property="roleName" column="role_name" /> <result property="roleName" column="role_name" />
@ -46,121 +46,121 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="dataScope" column="data_scope" /> <result property="dataScope" column="data_scope" />
<result property="status" column="role_status" /> <result property="status" column="role_status" />
</resultMap> </resultMap>
<sql id="selectUserVo"> <sql id="selectUserVo">
select u.user_id, u.dept_id, u.login_name, u.user_name, u.user_type, u.email, u.avatar, u.phonenumber, u.sex, u.password, u.salt, u.status, u.del_flag, u.login_ip, u.login_date, u.create_time, u.remark, select u.user_id, u.dept_id, u.login_name, u.user_name, u.user_type, u.email, u.avatar, u.phonenumber, u.sex, u.password, u.salt, u.status, u.del_flag, u.login_ip, u.login_date, u.create_time, u.remark,
d.dept_id, d.parent_id, d.dept_name, d.order_num, d.leader, d.status as dept_status, d.dept_id, d.parent_id, d.dept_name, d.order_num, d.leader, d.status as dept_status,
r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.status as role_status r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.status as role_status
from sys_user u from sys_user u
left join sys_dept d on u.dept_id = d.dept_id left join ( SELECT dept_id,parent_id,dept_name,order_num,leader,status FROM sys_dept ) d on u.dept_id = d.dept_id
left join sys_user_role ur on u.user_id = ur.user_id left join sys_user_role ur on u.user_id = ur.user_id
left join sys_role r on r.role_id = ur.role_id left join ( SELECT role_id,role_name,role_key,role_sort,data_scope,status FROM sys_role ) r on r.role_id = ur.role_id
</sql> </sql>
<select id="selectUserList" parameterType="SysUser" resultMap="SysUserResult"> <select id="selectUserList" parameterType="SysUser" resultMap="SysUserResult">
select u.user_id, u.dept_id, u.login_name, u.user_name, u.user_type, u.email, u.avatar, u.phonenumber, u.password, u.sex, u.salt, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, d.dept_name, d.leader from sys_user u select u.user_id, u.dept_id, u.login_name, u.user_name, u.user_type, u.email, u.avatar, u.phonenumber, u.password, u.sex, u.salt, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, d.dept_name, d.leader from sys_user u
left join sys_dept d on u.dept_id = d.dept_id left join ( SELECT dept_id,parent_id,dept_name,order_num,leader,status FROM sys_dept ) d on u.dept_id = d.dept_id
where u.del_flag = '0' where u.del_flag = '0'
<if test="loginName != null and loginName != ''"> <if test="loginName != null and loginName != ''">
AND u.login_name like concat('%', #{loginName}, '%') AND u.login_name like ('%' + #{loginName} + '%')
</if> </if>
<if test="status != null and status != ''"> <if test="status != null and status != ''">
AND u.status = #{status} AND u.status = #{status}
</if> </if>
<if test="phonenumber != null and phonenumber != ''"> <if test="phonenumber != null and phonenumber != ''">
AND u.phonenumber like concat('%', #{phonenumber}, '%') AND u.phonenumber like ('%' + #{phonenumber} + '%')
</if> </if>
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 --> <if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
AND date_format(u.create_time,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d') AND datediff(dd,#{params.beginTime},u.create_time)>=0
</if> </if>
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 --> <if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
AND date_format(u.create_time,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d') AND datediff(dd,u.create_time,#{params.endTime})>=0
</if> </if>
<if test="deptId != null and deptId != 0"> <if test="deptId != null and deptId != 0">
AND (u.dept_id = #{deptId} OR u.dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE FIND_IN_SET (#{deptId},ancestors) )) AND (u.dept_id = #{deptId} OR u.dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE CHARINDEX(cast(#{deptId} as nvarchar),ancestors)>0))
</if> </if>
<!-- 数据范围过滤 --> <!-- 数据范围过滤 -->
${params.dataScope} ${params.dataScope}
</select> </select>
<select id="selectAllocatedList" parameterType="SysUser" resultMap="SysUserResult"> <select id="selectAllocatedList" parameterType="SysUser" resultMap="SysUserResult">
select distinct u.user_id, u.dept_id, u.login_name, u.user_name, u.user_type, u.email, u.avatar, u.phonenumber, u.status, u.create_time select distinct u.user_id, u.dept_id, u.login_name, u.user_name, u.user_type, u.email, u.avatar, u.phonenumber, u.status, u.create_time
from sys_user u from sys_user u
left join sys_dept d on u.dept_id = d.dept_id left join ( SELECT dept_id,parent_id,dept_name,order_num,leader,status FROM sys_dept ) d on u.dept_id = d.dept_id
left join sys_user_role ur on u.user_id = ur.user_id left join sys_user_role ur on u.user_id = ur.user_id
left join sys_role r on r.role_id = ur.role_id left join ( SELECT role_id,role_name,role_key,role_sort,data_scope,status FROM sys_role ) r on r.role_id = ur.role_id
where u.del_flag = '0' and r.role_id = #{roleId} where u.del_flag = '0' and r.role_id = #{roleId}
<if test="loginName != null and loginName != ''"> <if test="loginName != null and loginName != ''">
AND u.login_name like concat('%', #{loginName}, '%') AND u.login_name like ('%' + #{loginName} + '%')
</if> </if>
<if test="phonenumber != null and phonenumber != ''"> <if test="phonenumber != null and phonenumber != ''">
AND u.phonenumber like concat('%', #{phonenumber}, '%') AND u.phonenumber like ('%' + #{phonenumber} + '%')
</if> </if>
<!-- 数据范围过滤 --> <!-- 数据范围过滤 -->
${params.dataScope} ${params.dataScope}
</select> </select>
<select id="selectUnallocatedList" parameterType="SysUser" resultMap="SysUserResult"> <select id="selectUnallocatedList" parameterType="SysUser" resultMap="SysUserResult">
select distinct u.user_id, u.dept_id, u.login_name, u.user_name, u.user_type, u.email, u.avatar, u.phonenumber, u.status, u.create_time select distinct u.user_id, u.dept_id, u.login_name, u.user_name, u.user_type, u.email, u.avatar, u.phonenumber, u.status, u.create_time
from sys_user u from sys_user u
left join sys_dept d on u.dept_id = d.dept_id left join ( SELECT dept_id,parent_id,dept_name,order_num,leader,status FROM sys_dept ) d on u.dept_id = d.dept_id
left join sys_user_role ur on u.user_id = ur.user_id left join sys_user_role ur on u.user_id = ur.user_id
left join sys_role r on r.role_id = ur.role_id left join ( SELECT role_id,role_name,role_key,role_sort,data_scope,status FROM sys_role ) r on r.role_id = ur.role_id
where u.del_flag = '0' and (r.role_id != #{roleId} or r.role_id IS NULL) where u.del_flag = '0' and (r.role_id != #{roleId} or r.role_id IS NULL)
and u.user_id not in (select u.user_id from sys_user u inner join sys_user_role ur on u.user_id = ur.user_id and ur.role_id = #{roleId}) and u.user_id not in (select u.user_id from sys_user u inner join sys_user_role ur on u.user_id = ur.user_id and ur.role_id = #{roleId})
<if test="loginName != null and loginName != ''"> <if test="loginName != null and loginName != ''">
AND u.login_name like concat('%', #{loginName}, '%') AND u.login_name like ('%' + #{loginName} + '%')
</if> </if>
<if test="phonenumber != null and phonenumber != ''"> <if test="phonenumber != null and phonenumber != ''">
AND u.phonenumber like concat('%', #{phonenumber}, '%') AND u.phonenumber like ('%' + #{phonenumber} + '%')
</if> </if>
<!-- 数据范围过滤 --> <!-- 数据范围过滤 -->
${params.dataScope} ${params.dataScope}
</select> </select>
<select id="selectUserByLoginName" parameterType="String" resultMap="SysUserResult"> <select id="selectUserByLoginName" parameterType="String" resultMap="SysUserResult">
<include refid="selectUserVo"/> <include refid="selectUserVo"/>
where u.login_name = #{userName} where u.login_name = #{userName}
</select> </select>
<select id="selectUserByPhoneNumber" parameterType="String" resultMap="SysUserResult"> <select id="selectUserByPhoneNumber" parameterType="String" resultMap="SysUserResult">
<include refid="selectUserVo"/> <include refid="selectUserVo"/>
where u.phonenumber = #{phonenumber} where u.phonenumber = #{phonenumber}
</select> </select>
<select id="selectUserByEmail" parameterType="String" resultMap="SysUserResult"> <select id="selectUserByEmail" parameterType="String" resultMap="SysUserResult">
<include refid="selectUserVo"/> <include refid="selectUserVo"/>
where u.email = #{email} where u.email = #{email}
</select> </select>
<select id="checkLoginNameUnique" parameterType="String" resultType="int"> <select id="checkLoginNameUnique" parameterType="String" resultType="int">
select count(1) from sys_user where login_name=#{loginName} select count(1) from sys_user where login_name=#{loginName}
</select> </select>
<select id="checkPhoneUnique" parameterType="String" resultMap="SysUserResult"> <select id="checkPhoneUnique" parameterType="String" resultMap="SysUserResult">
select user_id, phonenumber from sys_user where phonenumber=#{phonenumber} select user_id, phonenumber from sys_user where phonenumber=#{phonenumber}
</select> </select>
<select id="checkEmailUnique" parameterType="String" resultMap="SysUserResult"> <select id="checkEmailUnique" parameterType="String" resultMap="SysUserResult">
select user_id, email from sys_user where email=#{email} select user_id, email from sys_user where email=#{email}
</select> </select>
<select id="selectUserById" parameterType="Long" resultMap="SysUserResult"> <select id="selectUserById" parameterType="Long" resultMap="SysUserResult">
<include refid="selectUserVo"/> <include refid="selectUserVo"/>
where u.user_id = #{userId} where u.user_id = #{userId}
</select> </select>
<delete id="deleteUserById" parameterType="Long"> <delete id="deleteUserById" parameterType="Long">
update sys_user set del_flag = '2' where user_id = #{userId} update sys_user set del_flag = '2' where user_id = #{userId}
</delete> </delete>
<delete id="deleteUserByIds" parameterType="Long"> <delete id="deleteUserByIds" parameterType="Long">
update sys_user set del_flag = '2' where user_id in update sys_user set del_flag = '2' where user_id in
<foreach collection="array" item="userId" open="(" separator="," close=")"> <foreach collection="array" item="userId" open="(" separator="," close=")">
#{userId} #{userId}
</foreach> </foreach>
</delete> </delete>
<update id="updateUser" parameterType="SysUser"> <update id="updateUser" parameterType="SysUser">
update sys_user update sys_user
<set> <set>
@ -179,11 +179,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="loginDate != null">login_date = #{loginDate},</if> <if test="loginDate != null">login_date = #{loginDate},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if> <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
<if test="remark != null">remark = #{remark},</if> <if test="remark != null">remark = #{remark},</if>
update_time = sysdate() update_time = GETDATE()
</set> </set>
where user_id = #{userId} where user_id = #{userId}
</update> </update>
<insert id="insertUser" parameterType="SysUser" useGeneratedKeys="true" keyProperty="userId"> <insert id="insertUser" parameterType="SysUser" useGeneratedKeys="true" keyProperty="userId">
insert into sys_user( insert into sys_user(
<if test="userId != null and userId != 0">user_id,</if> <if test="userId != null and userId != 0">user_id,</if>
@ -216,8 +216,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="status != null and status != ''">#{status},</if> <if test="status != null and status != ''">#{status},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if> <if test="createBy != null and createBy != ''">#{createBy},</if>
<if test="remark != null and remark != ''">#{remark},</if> <if test="remark != null and remark != ''">#{remark},</if>
sysdate() GETDATE()
) )
</insert> </insert>
</mapper> </mapper>

@ -17,41 +17,60 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="lastAccessTime" column="last_access_time" /> <result property="lastAccessTime" column="last_access_time" />
<result property="expireTime" column="expire_time" /> <result property="expireTime" column="expire_time" />
</resultMap> </resultMap>
<sql id="selectOnlineVo"> <sql id="selectOnlineVo">
select sessionId, login_name, dept_name, ipaddr, login_location, browser, os, status, start_timestamp, last_access_time, expire_time select sessionId, login_name, dept_name, ipaddr, login_location, browser, os, status, start_timestamp, last_access_time, expire_time
from sys_user_online from sys_user_online
</sql> </sql>
<select id="selectOnlineById" parameterType="String" resultMap="SysUserOnlineResult"> <select id="selectOnlineById" parameterType="String" resultMap="SysUserOnlineResult">
<include refid="selectOnlineVo"/> <include refid="selectOnlineVo"/>
where sessionid = #{sessionid} where sessionid = #{sessionid}
</select> </select>
<insert id="saveOnline" parameterType="SysUserOnline"> <insert id="saveOnline" parameterType="SysUserOnline">
replace into sys_user_online(sessionId, login_name, dept_name, ipaddr, login_location, browser, os, status, start_timestamp, last_access_time, expire_time) merge into sys_user_online a
values (#{sessionId}, #{loginName}, #{deptName}, #{ipaddr}, #{loginLocation}, #{browser}, #{os}, #{status}, #{startTimestamp}, #{lastAccessTime}, #{expireTime}) using (select count(*) co
from sys_user_online
where sessionid = #{sessionId}) b
on (b.co <![CDATA[ <> ]]> 0)
when matched then
update
set login_name = #{loginName},
dept_name = #{deptName},
ipaddr = #{ipaddr},
login_location = #{loginLocation},
browser = #{browser},
os = #{os},
status = #{status},
start_timestamp = #{startTimestamp},
last_access_time = #{lastAccessTime},
expire_time = #{expireTime}
when not matched then
insert
values
(#{sessionId}, #{loginName}, #{deptName}, #{ipaddr}, #{loginLocation}, #{browser}, #{os}, #{status}, #{startTimestamp}, #{lastAccessTime}, #{expireTime});
</insert> </insert>
<delete id="deleteOnlineById" parameterType="String"> <delete id="deleteOnlineById" parameterType="String">
delete from sys_user_online where sessionId = #{sessionId} delete from sys_user_online where sessionId = #{sessionId}
</delete> </delete>
<select id="selectUserOnlineList" parameterType="SysUserOnline" resultMap="SysUserOnlineResult"> <select id="selectUserOnlineList" parameterType="SysUserOnline" resultMap="SysUserOnlineResult">
<include refid="selectOnlineVo"/> <include refid="selectOnlineVo"/>
<where> <where>
<if test="ipaddr != null and ipaddr != ''"> <if test="ipaddr != null and ipaddr != ''">
AND ipaddr like concat('%', #{ipaddr}, '%') AND ipaddr like ('%' + #{ipaddr} + '%')
</if> </if>
<if test="loginName != null and loginName != ''"> <if test="loginName != null and loginName != ''">
AND login_name like concat('%', #{loginName}, '%') AND login_name like ('%' + #{loginName} + '%')
</if> </if>
</where> </where>
</select> </select>
<select id="selectOnlineByExpired" parameterType="String" resultMap="SysUserOnlineResult"> <select id="selectOnlineByExpired" parameterType="String" resultMap="SysUserOnlineResult">
<include refid="selectOnlineVo"/> o <include refid="selectOnlineVo"/> o
WHERE o.last_access_time <![CDATA[ <= ]]> #{lastAccessTime} ORDER BY o.last_access_time ASC WHERE o.last_access_time <![CDATA[ <= ]]> #{lastAccessTime} ORDER BY o.last_access_time ASC
</select> </select>
</mapper> </mapper>

@ -8,7 +8,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="userId" column="user_id" /> <result property="userId" column="user_id" />
<result property="roleId" column="role_id" /> <result property="roleId" column="role_id" />
</resultMap> </resultMap>
<select id="selectUserRoleByUserId" parameterType="Long" resultMap="SysUserRoleResult"> <select id="selectUserRoleByUserId" parameterType="Long" resultMap="SysUserRoleResult">
select user_id, role_id from sys_user_role where user_id = #{userId} select user_id, role_id from sys_user_role where user_id = #{userId}
</select> </select>
@ -16,33 +16,33 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<delete id="deleteUserRoleByUserId" parameterType="Long"> <delete id="deleteUserRoleByUserId" parameterType="Long">
delete from sys_user_role where user_id = #{userId} delete from sys_user_role where user_id = #{userId}
</delete> </delete>
<select id="countUserRoleByRoleId" resultType="Integer"> <select id="countUserRoleByRoleId" resultType="Integer">
select count(1) from sys_user_role where role_id = #{roleId} select count(1) from sys_user_role where role_id = #{roleId}
</select> </select>
<delete id="deleteUserRole" parameterType="Long"> <delete id="deleteUserRole" parameterType="Long">
delete from sys_user_role where user_id in delete from sys_user_role where user_id in
<foreach collection="array" item="userId" open="(" separator="," close=")"> <foreach collection="array" item="userId" open="(" separator="," close=")">
#{userId} #{userId}
</foreach> </foreach>
</delete> </delete>
<insert id="batchUserRole"> <insert id="batchUserRole">
insert into sys_user_role(user_id, role_id) values insert into sys_user_role(user_id, role_id) values
<foreach item="item" index="index" collection="list" separator=","> <foreach item="item" index="index" collection="list" separator=",">
(#{item.userId},#{item.roleId}) (#{item.userId},#{item.roleId})
</foreach> </foreach>
</insert> </insert>
<delete id="deleteUserRoleInfo" parameterType="SysUserRole"> <delete id="deleteUserRoleInfo" parameterType="SysUserRole">
delete from sys_user_role where user_id=#{userId} and role_id=#{roleId} delete from sys_user_role where user_id=#{userId} and role_id=#{roleId}
</delete> </delete>
<delete id="deleteUserRoleInfos"> <delete id="deleteUserRoleInfos">
delete from sys_user_role where role_id=#{roleId} and user_id in delete from sys_user_role where role_id=#{roleId} and user_id in
<foreach collection="userIds" item="userId" open="(" separator="," close=")"> <foreach collection="userIds" item="userId" open="(" separator="," close=")">
#{userId} #{userId}
</foreach> </foreach>
</delete> </delete>
</mapper> </mapper>

Loading…
Cancel
Save