大改:重构项目

This commit is contained in:
2025-07-27 03:57:05 +08:00
parent 4f34e9d22c
commit 1f796ab000
6 changed files with 313 additions and 133 deletions

View File

@@ -9,13 +9,14 @@ import org.beetl.core.GroupTemplate;
import org.beetl.core.Template;
import org.beetl.core.resource.ClasspathResourceLoader;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.MimeMessageHelper;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import javax.mail.MessagingException;
import javax.mail.internet.MimeMessage;
import java.io.IOException;
@@ -31,13 +32,17 @@ import java.util.Map;
public class EmailRecordServiceImpl extends ServiceImpl<EmailRecordMapper, EmailRecord>
implements EmailRecordService {
// 发件邮箱
@Value("${spring.mail.username}")
@Value("${spring.mail.username:}")
private String formEmail;
@Resource
@Autowired(required = false)
private JavaMailSender mailSender;
@Override
public void sendTextEmail(String title, String content, String[] toEmails) {
if (mailSender == null) {
System.out.println("邮件服务未配置,跳过发送邮件: " + title);
return;
}
SimpleMailMessage message = new SimpleMailMessage();
message.setFrom(formEmail);
message.setTo(toEmails);
@@ -48,6 +53,10 @@ public class EmailRecordServiceImpl extends ServiceImpl<EmailRecordMapper, Email
@Override
public void sendFullTextEmail(String title, String html, String[] toEmails) throws MessagingException {
if (mailSender == null) {
System.out.println("邮件服务未配置,跳过发送邮件: " + title);
return;
}
MimeMessage mimeMessage = mailSender.createMimeMessage();
MimeMessageHelper helper = new MimeMessageHelper(mimeMessage, true);
helper.setFrom(formEmail);
@@ -79,7 +88,11 @@ public class EmailRecordServiceImpl extends ServiceImpl<EmailRecordMapper, Email
emailRecord.setContent(content);
emailRecord.setReceiver(receiver);
emailRecord.setCreateUserId(42);
sendTextEmail(title,content,receiver.split(","));
if (mailSender != null) {
sendTextEmail(title,content,receiver.split(","));
} else {
System.out.println("邮件服务未配置,跳过发送邮件: " + title);
}
save(emailRecord);
}

View File

@@ -1,61 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.gxwebsoft.oa.mapper.OaAppRenewMapper">
<!-- 关联查询sql -->
<sql id="selectSql">
SELECT a.*,
b.company_name,b.short_name,b.company_logo,
c.app_name
FROM oa_app_renew a
LEFT JOIN oa_company b ON a.company_id = b.company_id
LEFT JOIN oa_app c ON a.app_id = c.app_id
<where>
<if test="param.appRenewId != null">
AND a.app_renew_id = #{param.appRenewId}
</if>
<if test="param.money != null">
AND a.money = #{param.money}
</if>
<if test="param.comments != null">
AND a.comments LIKE CONCAT('%', #{param.comments}, '%')
</if>
<if test="param.startTime != null">
AND a.start_time LIKE CONCAT('%', #{param.startTime}, '%')
</if>
<if test="param.endTime != null">
AND a.end_time LIKE CONCAT('%', #{param.endTime}, '%')
</if>
<if test="param.userId != null">
AND a.user_id = #{param.userId}
</if>
<if test="param.appId != null">
AND a.app_id = #{param.appId}
</if>
<if test="param.companyId != null">
AND a.company_id = #{param.companyId}
</if>
<if test="param.status != null">
AND a.status = #{param.status}
</if>
<if test="param.createTimeStart != null">
AND a.create_time &gt;= #{param.createTimeStart}
</if>
<if test="param.createTimeEnd != null">
AND a.create_time &lt;= #{param.createTimeEnd}
</if>
</where>
</sql>
<!-- 分页查询 -->
<select id="selectPageRel" resultType="com.gxwebsoft.oa.entity.OaAppRenew">
<include refid="selectSql"></include>
</select>
<!-- 查询全部 -->
<select id="selectListRel" resultType="com.gxwebsoft.oa.entity.OaAppRenew">
<include refid="selectSql"></include>
</select>
</mapper>

View File

@@ -1,68 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.gxwebsoft.oa.mapper.OaTaskRecordMapper">
<!-- 关联查询sql -->
<sql id="selectSql">
SELECT a.*
FROM oa_task_record a
<where>
<if test="param.taskRecordId != null">
AND a.task_record_id = #{param.taskRecordId}
</if>
<if test="param.parentId != null">
AND a.parent_id = #{param.parentId}
</if>
<if test="param.taskId != null">
AND a.task_id = #{param.taskId}
</if>
<if test="param.content != null">
AND a.content LIKE CONCAT('%', #{param.content}, '%')
</if>
<if test="param.confidential != null">
AND a.confidential LIKE CONCAT('%', #{param.confidential}, '%')
</if>
<if test="param.phone != null">
AND a.phone LIKE CONCAT('%', #{param.phone}, '%')
</if>
<if test="param.files != null">
AND a.files LIKE CONCAT('%', #{param.files}, '%')
</if>
<if test="param.userId != null">
AND a.user_id = #{param.userId}
</if>
<if test="param.sortNumber != null">
AND a.sort_number = #{param.sortNumber}
</if>
<if test="param.comments != null">
AND a.comments LIKE CONCAT('%', #{param.comments}, '%')
</if>
<if test="param.status != null">
AND a.status = #{param.status}
</if>
<if test="param.deleted != null">
AND a.deleted = #{param.deleted}
</if>
<if test="param.deleted == null">
AND a.deleted = 0
</if>
<if test="param.createTimeStart != null">
AND a.create_time &gt;= #{param.createTimeStart}
</if>
<if test="param.createTimeEnd != null">
AND a.create_time &lt;= #{param.createTimeEnd}
</if>
</where>
</sql>
<!-- 分页查询 -->
<select id="selectPageRel" resultType="com.gxwebsoft.oa.entity.OaTaskRecord">
<include refid="selectSql"></include>
</select>
<!-- 查询全部 -->
<select id="selectListRel" resultType="com.gxwebsoft.oa.entity.OaTaskRecord">
<include refid="selectSql"></include>
</select>
</mapper>