id, create_time, update_time, create_user, update_user, is_deleted, template_name, email_user, subject, body, type, is_default
select
template.*,
create_user.username as create_username,
update_user.username as update_username
from sys_email_template template
left join sys_user create_user on create_user.id = template.create_user
left join sys_user update_user on update_user.id = template.update_user
template.is_deleted = 0
and template.template_name like CONCAT('%',#{dto.templateName},'%')
and template.subject like CONCAT('%',#{dto.subject},'%')
and template.body like CONCAT('%',#{dto.body},'%')
and template.type like CONCAT('%',#{dto.type},'%')
and template.isDefault = #{dto.isDefault}
delete
from sys_email_template
where id in
#{id}