首页 > 数据库 >ruoyi(若依)系统使用SqlServer数据库

ruoyi(若依)系统使用SqlServer数据库

时间:2023-05-20 17:45:47浏览次数:53  
标签:sys JOIN name SqlServer ruoyi 若依 WHERE id LEFT

https://blog.csdn.net/op4439/article/details/121469911

近期使用若依前后端分离版开发一个公司内部系统,由于指定使用SqlServer数据库,所以采用若依3.7.0版,自己转换脚本及对应查询。

具体修改如下:

1、admin把mysql引用替换为

<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
</dependency>

2、数据库配置修改:driverClassName: com.microsoft.sqlserver.jdbc.SQLServerDriver

其他就是连接及用户密码信息

# 配置检测连接是否有效
validationQuery: select 'x'

分页pagehelper配置
helperDialect: sqlserver

3、定时任务配置ScheduleConfig类设置sqlserver 启用配置

4、SQL语句函数修改

ifnull 替换为 isnull
find_in_set find_in_set(#{deptId}, ancestors) 替换为 charindex (',' + CONVERT (VARCHAR, #{deptId}), ',' + ancestors) > 0
concat 替换为 ''+''
sysdate 替换为 getdate
date_format date_format(u.create_time,'%y%m%d') >= date_format(#{params.beginTime},'%y%m%d') 替换为 DATEDIFF(day, u.create_time , #{params.endTime}) >= 0
limit 1 替换为 top(1) (注意位置差异)

 

5、生成代码包SQL修改

selectDbTableList 修改为

SELECT
so.name table_name,
sep.value table_comment,
so.create_date create_time,
so.modify_date update_time
FROM
sys.objects AS so
LEFT JOIN sys.extended_properties AS sep ON so.object_id = sep.major_id
WHERE
so.type = 'U'
AND sep.minor_id = 0
AND so.name NOT LIKE 'qrtz_%' AND so.name NOT LIKE 'gen_%'
AND so.name NOT IN (select table_name from gen_table)

selectDbTableListByNames修改为

SELECT
SO.name table_name,
SEP.VALUE table_comment,
SO.create_date create_time,
SO.modify_date update_time
FROM
sys.objects AS SO
LEFT JOIN sys.extended_properties AS SEP ON SO.object_id = SEP.major_id
WHERE
SO.type = 'U'
AND SEP.minor_id = 0
and SO.name NOT LIKE 'qrtz_%' and SO.name NOT LIKE 'gen_%'
and SO.name in
<foreach collection="array" item="name" open="(" separator="," close=")">
#{name}
</foreach>

selectDbTableColumnsByName修改为

SELECT a.name AS column_name,
(
CASE
WHEN a.isnullable = 1 THEN
0
ELSE
1
END
) AS is_required,
(
CASE
WHEN (
SELECT COUNT(*)
FROM sysobjects
WHERE (
name IN (
SELECT name
FROM sysindexes
WHERE (id = a.id)
AND (
indid IN (
SELECT indid
FROM sysindexkeys
WHERE (id = a.id)
AND (
colid IN (
SELECT colid
FROM syscolumns
WHERE (id = a.id)
AND (name = a.name)
)
)
)
)
)
)
AND (xtype = 'PK')
) > 0 THEN
1
ELSE
0
END
) AS is_pk,
a.colorder AS sort,
isnull(g.[value], ' ') AS column_comment,
(
CASE
WHEN COLUMNPROPERTY(a.id, a.name, 'IsIdentity') = 1 THEN
1
ELSE
0
END
) AS is_increment,
b.name AS column_type
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 <![CDATA[ <> ]]> 'dtproperties'
LEFT JOIN syscomments e ON a.cdefault = e.id
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.class
AND f.minor_id = 0
LEFT JOIN sys.objects h ON a.id = h.object_id
LEFT JOIN sys.schemas i ON h.schema_id = i.schema_id
WHERE d.name = #{tableName}
ORDER BY a.colorder

SELECT name
FROM sysindexes
WHERE (id = a.id)
AND (
indid IN (
SELECT indid
FROM sysindexkeys
WHERE (id = a.id)
AND (
colid IN (
SELECT colid
FROM syscolumns
WHERE (id = a.id)
AND (name = a.name)
)
)
)
)
)
)
AND (xtype = 'PK')
) > 0 THEN
1
ELSE
0
END
) AS is_pk,
a.colorder AS sort,
isnull(g.[value], ' ') AS column_comment,
(
CASE
WHEN COLUMNPROPERTY(a.id, a.name, 'IsIdentity') = 1 THEN
1
ELSE
0
END
) AS is_increment,
b.name AS column_type
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 <![CDATA[ <> ]]> 'dtproperties'
LEFT JOIN syscomments e ON a.cdefault = e.id
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.class
AND f.minor_id = 0
LEFT JOIN sys.objects h ON a.id = h.object_id
LEFT JOIN sys.schemas i ON h.schema_id = i.schema_id
WHERE d.name = #{tableName}
ORDER BY a.colorder

参考:sqlserver查看表名及表注释_毒牙-CSDN博客_sqlserver获取表注释

sqlserver 获取schema、表、字段等关键信息_aixin999的博客-CSDN博客

标签:sys,JOIN,name,SqlServer,ruoyi,若依,WHERE,id,LEFT
From: https://www.cnblogs.com/chuangsi/p/17417524.html

相关文章

  • 关于Sqlserver动态语句传递表变量的用法
    一、定义[用户定义表类型]   --定义表类型   createtypeIntegerTableTypeastable(Idint)   go二、定义[表类型变量]   --表类型变量   declare@declareTableIntegerTableType   insertinto@declareTableselect1三、动态Sql语句   declare......
  • 【若依框架】定时任务调用异步服务,实现每天定时发送钉钉消息通知
     https://blog.csdn.net/MS_SONG/article/details/129141498【若依框架】定时任务调用异步服务,实现每天定时发送钉钉消息通知后端实现思路实现步骤1.添加依赖2.配置DingTalkUtils工具类3.设置定时任务4.异步任务-发送钉钉消息5.配置白名单代码 后端实......
  • ruoyi-vue接入钉钉,作为h5微应用
    ruoyi-vue接入钉钉,作为h5微应用https://blog.csdn.net/jiaodacailei/article/details/1247099141.安装依赖在ruoyi-ui目录,npm安装依赖:npminstalldingtalk-jsapi--save2.定义全局钉钉企业IDruoyi-ui/.env.developmentruoyi-ui/.env.productionruoyi-ui/.env.staging#......
  • SqlServer查询锁表及解锁
    --查询锁表进程selectrequest_session_idspid,OBJECT_NAME(resource_associated_entity_id)tableNamefromsys.dm_tran_lockswhereresource_type='OBJECT'--解锁进程declare@spidintSet@spid=162--锁表进程declare@sqlvarchar(1000)set@sql='kill......
  • springboot中使用application.properties配置mysql和sqlserver
    1.使用依赖*mysql:<dependency><groupId>mysql</groupId><artifactId>mysql-connector-java</artifactId></dependency>*sqlserver:<dependency><groupId>com.microsoft.sqlserver</groupId><art......
  • SqlServer查询存储过程和视图是否用到表字段
     查询存储过程视图是否用到表和字段selectnamefromsysobjectsassinnerjoinsyscommentsasoons.id=o.idwheretextlikeN'%表名%字段名%'--查询表字段SELECTOBJECT_NAME(object_id)'表名',nameAS'列名称'FROMsys.columns......
  • java 连接 sqlserver 报错
    使用最新的sqlserver驱动报错:com.zaxxer.hikari.pool.HikariPool$PoolInitializationException:Failedtoinitializepool:"encrypt"propertyissetto"true"and"trustServerCertificate"propertyissetto"false"butthedri......
  • SQLSERVER中JSON数组的拆分
    DECLARE@infoParamNVARCHAR(MAX);DECLARE@itemsNVARCHAR(MAX);SET@infoParam='{ "SCHOOL":"某某中学", "SCHOOLCODE":"1234", "USER":[{ "userid":"20XX001", "username......
  • RuoYi-Vue下载与运行
    一、源码下载若依官网:RuoYi若依官方网站鼠标放到"源码地址"上,点击"RuoYi-Vue前端分离版"。跳转至Gitee页面,点击"克隆/下载",复制HTTPS链接即可。源码地址为:https://gitee.com/y_project/RuoYi-Vue.git打开IDEA,选择"GetfromVCS"。将源码地址粘贴到URL输入框中,并选择本......
  • Entity FrameWork 6 与sqlserver数据库建立连接
    1、新建一个控制台项目  2、添加EF6   3、新建2个表并建立外联关系department:departmentId为主键 person:id为主键    4、连接sqlserver数据库             ......