select type,
count(1) as num
from message_record
where state in (2,3)
and is_delete = 0
and to_id = #{identityId}
and receive_type = #{receiveType}
and person_id = #{personId}
and relation_id in (
select id from message_relation where is_delete = 0 and module_id in (
select id from message_module where is_delete = 0 and biz_type = #{bizType}
)
)
group by type
select record.id msgId,
record.title as msgTitle,
record.content as content,
record.receive_type as receiveType,
record.terminal_id as terminalId,
record.terminal_type as terminalType,
record.terminal_name as terminalName,
record.state,
record.create_at as msgDate,
record.extra as ext,
record.router_params as routerParam,
record.relation_id as relationId,
record.old_type_id as oldTypeId
from message_record record
join message_relation relation
on record.relation_id = relation.id and relation.is_delete = 0
join message_module moud
on relation.module_id = moud.id and moud.is_delete = 0
and moud.id = #{req.moduleId}
where record.type = #{req.msgType}
and record.is_delete = 0
and (
(record.to_id = #{identityId} and record.receive_type = #{receiveType})
)
and record.state in
#{item}
and record.create_at > DATE_FORMAT((CURDATE() - INTERVAL 3 YEAR),'%Y-%m-%d')
order by record.create_at desc,record.id desc
select record.id msgId,
record.title as msgTitle,
record.content as content,
record.receive_type as receiveType,
record.terminal_id as terminalId,
record.terminal_type as terminalType,
record.terminal_name as terminalName,
record.state,
record.create_at as msgDate,
record.extra as ext,
record.router_params as routerParam,
record.relation_id as relationId,
record.old_type_id as oldTypeId
from message_record record
join message_relation relation
on record.relation_id = relation.id and relation.is_delete = 0
join message_module moud
on relation.module_id = moud.id and moud.is_delete = 0
and moud.id = #{req.moduleId}
where record.type = #{req.msgType}
and record.state in (2,3,4,5)
and record.is_delete = 0
and (
(
record.to_id in
#{identityId}
and record.receive_type in (1,2)) or
(record.to_id = 0 and record.receive_type = 9 and person_id = #{personId})
)
and record.state in
#{item}
and record.create_at > DATE_FORMAT((CURDATE() - INTERVAL 3 YEAR),'%Y-%m-%d')
order by record.create_at desc,record.id desc
select record.id msgId,
record.title as msgTitle,
record.content as content,
record.receive_type as receiveType,
record.terminal_id as terminalId,
record.terminal_type as terminalType,
record.terminal_name as terminalName,
record.state,
record.create_at as msgDate,
record.extra as ext,
record.router_params as routerParam,
record.relation_id as relationId,
record.old_type_id as oldTypeId
from message_record record
join message_relation relation
on record.relation_id = relation.id and relation.is_delete = 0
join message_module moud
on relation.module_id = moud.id and moud.is_delete = 0
and moud.id = #{req.moduleId}
WHERE record.person_id = #{personId}
and record.module_id in
#{item}
and record.state in
#{item}
and record.create_at > DATE_FORMAT((CURDATE() - INTERVAL 3 YEAR),'%Y-%m-%d')
order by record.create_at desc,record.id desc
update message_record set state = 4
where id in
#{id}
update message_record set state=4
where is_delete=0
AND id IN
#{msgId}
AND module_id = #{req.moduleId}
AND type = #{req.msgType}
AND tenant_id = #{req.tenantId}
AND to_id=#{req.toId}
AND from_id=#{req.fromId}
select record.id msgId,
record.title as msgTitle,
record.content as content,
record.receive_type as receiveType,
record.terminal_id as terminalId,
record.terminal_type as terminalType,
record.terminal_name as terminalName,
record.state,
record.create_at as msgDate,
record.extra as ext,
record.router_params as routerParam,
record.relation_id as relationId,
record.old_type_id as oldTypeId
from message_record AS record
where to_id=#{req.toId}
AND type = #{req.msgType}
AND from_id = #{req.fromId}
AND tenant_id = #{req.tenantId}
and module_id = #{req.moduleId}
and state in (2,3)
and is_delete = 0
order by create_at desc,id desc
select record.id msgId,
record.title as msgTitle,
record.content as content,
record.receive_type as receiveType,
record.terminal_id as terminalId,
record.terminal_type as terminalType,
record.terminal_name as terminalName,
record.state,
record.create_at as msgDate,
record.extra as ext,
record.router_params as routerParam,
record.relation_id as relationId,
record.old_type_id as oldTypeId,
record.tenant_id AS tenantId,
record.from_id AS fromId,
record.to_id AS toId,
record.create_at AS createAt
from message_record AS record
where to_id=#{req.toId}
AND type = #{req.msgType}
AND from_id = #{req.fromId}
AND tenant_id = #{req.tenantId}
AND module_id = #{req.moduleId}
and state=2
and is_delete = 0
order by create_at desc,id desc