Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
Y
yzg-util
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
YZG
yzg-util
Commits
3ea8716c
Commit
3ea8716c
authored
Dec 03, 2019
by
yanzg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
接口文档的支持
parent
44cec2dd
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
2 deletions
+21
-2
DbExecute.java
yzg-util-db/src/main/java/com/yanzuoguang/db/DbExecute.java
+2
-2
MessageDaoImpl.java
...main/java/com/yanzuoguang/mq/dao/impl/MessageDaoImpl.java
+19
-0
No files found.
yzg-util-db/src/main/java/com/yanzuoguang/db/DbExecute.java
View file @
3ea8716c
...
@@ -28,8 +28,8 @@ public interface DbExecute {
...
@@ -28,8 +28,8 @@ public interface DbExecute {
* 查询数据
* 查询数据
*
*
* @param targetClass 触发类
* @param targetClass 触发类
* @param sqlName SQL语句名称
* @param cls 查询的结果的类型
* @param cls 查询的结果的类型
* @param sqlName SQL语句名称
* @param rowHandle 通过该类来处理结果
* @param rowHandle 通过该类来处理结果
* @param sql 需要查询的SQL语句
* @param sql 需要查询的SQL语句
* @param paras 查询语句的参数
* @param paras 查询语句的参数
...
@@ -42,8 +42,8 @@ public interface DbExecute {
...
@@ -42,8 +42,8 @@ public interface DbExecute {
* 查询数据,并返回集合
* 查询数据,并返回集合
*
*
* @param targetClass 触发类
* @param targetClass 触发类
* @param sqlName SQL语句名称
* @param cls 查询的结果的类型
* @param cls 查询的结果的类型
* @param sqlName SQL语句名称
* @param sql 需要查询的SQL语句
* @param sql 需要查询的SQL语句
* @param paras 查询语句的参数
* @param paras 查询语句的参数
* @param <T> 返回的集合的类型
* @param <T> 返回的集合的类型
...
...
yzg-util-mq/src/main/java/com/yanzuoguang/mq/dao/impl/MessageDaoImpl.java
View file @
3ea8716c
...
@@ -20,6 +20,20 @@ import java.util.Map;
...
@@ -20,6 +20,20 @@ import java.util.Map;
@Component
@Component
public
class
MessageDaoImpl
extends
BaseDaoImpl
implements
MessageDao
{
public
class
MessageDaoImpl
extends
BaseDaoImpl
implements
MessageDao
{
private
static
final
String
UPDATE_BATCH_SQL
=
"UPDATE_BATCH_SQL"
;
private
static
final
String
UPDATE_BATCH_SQL
=
"UPDATE_BATCH_SQL"
;
private
static
final
String
QUERY_TABLE_SQL
=
"SHOW TABLES LIKE 'queue_message'"
;
private
static
final
String
CREATE_TABLE_SQL
=
"CREATE TABLE `queue_message` ( "
+
" `MessageId` varchar(32) NOT NULL COMMENT '消息编号', "
+
" `ExchangeName` varchar(255) NOT NULL DEFAULT '' COMMENT '交换器', "
+
" `RouteKey` varchar(255) NOT NULL DEFAULT '' COMMENT '路由键', "
+
" `Message` text NOT NULL COMMENT '消息内容', "
+
" `DedTime` int(11) NOT NULL DEFAULT '0' COMMENT '死信时间', "
+
" `HandleCount` int(11) NOT NULL DEFAULT '0' COMMENT '处理次数', "
+
" `HandleTime` datetime NOT NULL COMMENT '上次处理时间', "
+
" `BatchId` varchar(32) NOT NULL COMMENT '发送批次', "
+
" `CreateTime` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', "
+
" PRIMARY KEY (`MessageId`), "
+
" KEY `IndexHandleTime` (`HandleTime`) "
+
") ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='队列消息表'"
;
@Override
@Override
protected
void
init
()
{
protected
void
init
()
{
...
@@ -33,6 +47,11 @@ public class MessageDaoImpl extends BaseDaoImpl implements MessageDao {
...
@@ -33,6 +47,11 @@ public class MessageDaoImpl extends BaseDaoImpl implements MessageDao {
"INNER JOIN ( SELECT * FROM Queue_Message WHERE (HandleTime IS NULL OR HandleTime < NOW()) "
+
"INNER JOIN ( SELECT * FROM Queue_Message WHERE (HandleTime IS NULL OR HandleTime < NOW()) "
+
"ORDER BY HandleTime ASC,MessageId ASC {LIMIT} ) AS b ON a.MessageId = b.MessageId "
+
"ORDER BY HandleTime ASC,MessageId ASC {LIMIT} ) AS b ON a.MessageId = b.MessageId "
+
"SET a.BatchId = ?,a.HandleTime=DATE_ADD(NOW(),INTERVAL 5 MINUTE) "
,
"batchId"
);
"SET a.BatchId = ?,a.HandleTime=DATE_ADD(NOW(),INTERVAL 5 MINUTE) "
,
"batchId"
);
List
<
MapRow
>
tables
=
this
.
db
.
query
(
MessageDaoImpl
.
class
,
"QUERY_TABLE_SQL"
,
QUERY_TABLE_SQL
);
if
(
tables
.
isEmpty
())
{
this
.
db
.
update
(
MessageDaoImpl
.
class
,
"CREATE_TABLE_SQL"
,
CREATE_TABLE_SQL
);
}
}
}
/**
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment