前端和json优化
This commit is contained in:
@@ -115,8 +115,8 @@ public class CrontabController {
|
||||
String metaId = request.getMetaId();
|
||||
|
||||
// 确保id字段正确传递(用于数据库更新)
|
||||
if (crontabItem.getTaskId() != null && crontabItem.getID() == null) {
|
||||
crontabItem.setID(crontabItem.getTaskId());
|
||||
if (crontabItem.getTaskId() != null && crontabItem.getId() == null) {
|
||||
crontabItem.setId(crontabItem.getTaskId());
|
||||
}
|
||||
|
||||
// 验证元数据ID
|
||||
@@ -141,7 +141,7 @@ public class CrontabController {
|
||||
crontabItem.setMetaId(metaId); // 保存metaId,执行时从数据库读取scriptPath
|
||||
|
||||
logger.info("更新任务 - id: {}, metaId: {}, name: {}, category: {}, defaultRecipient: {}",
|
||||
crontabItem.getID(), metaId, taskMeta.getName(), taskMeta.getCategory(),
|
||||
crontabItem.getId(), metaId, taskMeta.getName(), taskMeta.getCategory(),
|
||||
crontabItem.getDefaultRecipient());
|
||||
|
||||
// 调用带接收人更新的方法
|
||||
|
||||
@@ -46,7 +46,7 @@ public class SchedulerManager {
|
||||
*/
|
||||
public void scheduleTask(TbCrontabTask task) {
|
||||
try {
|
||||
String taskId = task.getID();
|
||||
String taskId = task.getId();
|
||||
|
||||
// 如果任务已经在调度中,先取消
|
||||
if (scheduledTasks.containsKey(taskId)) {
|
||||
@@ -79,7 +79,7 @@ public class SchedulerManager {
|
||||
*/
|
||||
public void unscheduleTask(TbCrontabTask task) {
|
||||
try {
|
||||
String taskId = task.getID();
|
||||
String taskId = task.getId();
|
||||
ScheduledFuture<?> future = scheduledTasks.get(taskId);
|
||||
|
||||
if (future != null) {
|
||||
|
||||
@@ -46,7 +46,7 @@ public class TaskExecutor {
|
||||
public void executeTask(TbCrontabTask task) {
|
||||
Date startTime = new Date();
|
||||
TbCrontabLog log = new TbCrontabLog();
|
||||
log.setID(IDUtils.generateID());
|
||||
log.setId(IDUtils.generateID());
|
||||
log.setTaskId(task.getTaskId());
|
||||
log.setTaskName(task.getTaskName());
|
||||
log.setTaskGroup(task.getTaskGroup());
|
||||
@@ -159,7 +159,7 @@ public class TaskExecutor {
|
||||
|
||||
// 注入taskId、logId和metaId
|
||||
params.put("taskId", task.getTaskId());
|
||||
params.put("logId", log.getID());
|
||||
params.put("logId", log.getId());
|
||||
if (task.getMetaId() != null) {
|
||||
params.put("metaId", task.getMetaId());
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ public class CrontabServiceImpl implements CrontabService {
|
||||
}
|
||||
|
||||
// 生成ID
|
||||
task.setID(IDUtils.generateID());
|
||||
task.setId(IDUtils.generateID());
|
||||
task.setTaskId(IDUtils.generateID());
|
||||
task.setCreateTime(new Date());
|
||||
task.setDeleted(false);
|
||||
@@ -134,7 +134,7 @@ public class CrontabServiceImpl implements CrontabService {
|
||||
try {
|
||||
TbCrontabTask task = request.getTask();
|
||||
TbSysUser user = LoginUtil.getCurrentUser();
|
||||
task.setCreator(user.getID());
|
||||
task.setCreator(user.getId());
|
||||
// 1. 创建任务
|
||||
ResultDomain<TbCrontabTask> createResult = createTask(task);
|
||||
if (!createResult.isSuccess()) {
|
||||
|
||||
@@ -68,7 +68,7 @@ public class DataCollectionItemServiceImpl implements DataCollectionItemService
|
||||
}
|
||||
|
||||
// 生成ID
|
||||
item.setID(IDUtils.generateID());
|
||||
item.setId(IDUtils.generateID());
|
||||
item.setCreateTime(new Date());
|
||||
item.setDeleted(false);
|
||||
|
||||
@@ -118,7 +118,7 @@ public class DataCollectionItemServiceImpl implements DataCollectionItemService
|
||||
}
|
||||
String logId = itemList.get(0).getLogId();
|
||||
TbCrontabLog log = new TbCrontabLog();
|
||||
log.setID(logId);
|
||||
log.setId(logId);
|
||||
log.setExecuteStatus(1);
|
||||
log.setExecuteMessage("爬取成功,共" + itemList.size() + "条,新增" + successCount + "条");
|
||||
int i = logMapper.updateLog(log);
|
||||
@@ -137,7 +137,7 @@ public class DataCollectionItemServiceImpl implements DataCollectionItemService
|
||||
public ResultDomain<TbDataCollectionItem> updateItem(TbDataCollectionItem item) {
|
||||
ResultDomain<TbDataCollectionItem> resultDomain = new ResultDomain<>();
|
||||
try {
|
||||
if (item.getID() == null) {
|
||||
if (item.getId() == null) {
|
||||
resultDomain.fail("采集项ID不能为空");
|
||||
return resultDomain;
|
||||
}
|
||||
@@ -146,7 +146,7 @@ public class DataCollectionItemServiceImpl implements DataCollectionItemService
|
||||
int result = itemMapper.updateById(item);
|
||||
|
||||
if (result > 0) {
|
||||
logger.info("更新采集项成功: {}", item.getID());
|
||||
logger.info("更新采集项成功: {}", item.getId());
|
||||
resultDomain.success("更新采集项成功", item);
|
||||
} else {
|
||||
resultDomain.fail("更新采集项失败");
|
||||
|
||||
@@ -36,7 +36,7 @@ public class EmailDefaultServiceImpl implements EmailDefaultService {
|
||||
try {
|
||||
|
||||
// 生成ID
|
||||
emailDefault.setID(IDUtils.generateID());
|
||||
emailDefault.setId(IDUtils.generateID());
|
||||
if (emailDefault.getDefaultId() == null || emailDefault.getDefaultId().isEmpty()) {
|
||||
emailDefault.setDefaultId(IDUtils.generateID());
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ public class EmailRecipientServiceImpl implements EmailRecipientService {
|
||||
ResultDomain<TbCrontabEmailRecipient> resultDomain = new ResultDomain<>();
|
||||
try {
|
||||
// 生成ID
|
||||
recipient.setID(IDUtils.generateID());
|
||||
recipient.setId(IDUtils.generateID());
|
||||
if (recipient.getRecipientId() == null || recipient.getRecipientId().isEmpty()) {
|
||||
recipient.setRecipientId(IDUtils.generateID());
|
||||
}
|
||||
@@ -64,7 +64,7 @@ public class EmailRecipientServiceImpl implements EmailRecipientService {
|
||||
ResultDomain<Boolean> resultDomain = new ResultDomain<>();
|
||||
try {
|
||||
for (TbCrontabEmailRecipient recipient : recipients) {
|
||||
recipient.setID(IDUtils.generateID());
|
||||
recipient.setId(IDUtils.generateID());
|
||||
if (recipient.getRecipientId() == null || recipient.getRecipientId().isEmpty()) {
|
||||
recipient.setRecipientId(IDUtils.generateID());
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ public class TaskMetaServiceImpl implements TaskMetaService {
|
||||
}
|
||||
|
||||
// 生成ID
|
||||
taskMeta.setID(IDUtils.generateID());
|
||||
taskMeta.setId(IDUtils.generateID());
|
||||
taskMeta.setCreateTime(new Date());
|
||||
taskMeta.setDeleted(false);
|
||||
|
||||
|
||||
@@ -224,7 +224,7 @@ public class NewsCrawlerTask extends PythonCommandTask {
|
||||
TbDataCollectionItem item = new TbDataCollectionItem();
|
||||
|
||||
// 基本信息
|
||||
item.setID(IDUtils.generateID());
|
||||
item.setId(IDUtils.generateID());
|
||||
item.setTaskId(taskId);
|
||||
item.setLogId(logId);
|
||||
item.setTitle(news.getTitle());
|
||||
@@ -314,7 +314,7 @@ public class NewsCrawlerTask extends PythonCommandTask {
|
||||
}
|
||||
if(passList.isEmpty() && notPassList.isEmpty()){
|
||||
TbCrontabLog log = new TbCrontabLog();
|
||||
log.setID(logId);
|
||||
log.setId(logId);
|
||||
log.setExecuteStatus(1);
|
||||
log.setExecuteMessage("未爬取到数据");
|
||||
int i = logMapper.updateLog(log);
|
||||
@@ -535,7 +535,7 @@ public class NewsCrawlerTask extends PythonCommandTask {
|
||||
if(item.getContent().isEmpty()) continue;
|
||||
try {
|
||||
TbResource resource = new TbResource();
|
||||
resource.setID(IDUtils.generateID());
|
||||
resource.setId(IDUtils.generateID());
|
||||
resource.setResourceID(IDUtils.generateID());
|
||||
resource.setTitle(item.getTitle());
|
||||
// 创建者使用任务创建者
|
||||
@@ -614,7 +614,7 @@ public class NewsCrawlerTask extends PythonCommandTask {
|
||||
}
|
||||
|
||||
TbDataCollectionItem update = new TbDataCollectionItem();
|
||||
update.setID(itemVO.getId());
|
||||
update.setId(itemVO.getId());
|
||||
update.setStatus(1); // 已转换为资源
|
||||
update.setResourceId(resourceId);
|
||||
update.setProcessTime(now);
|
||||
|
||||
@@ -213,7 +213,7 @@ public class TopRecommendTask extends BaseTask {
|
||||
*/
|
||||
private TbResourceRecommend createRecommend(String resourceId, int orderNum) {
|
||||
TbResourceRecommend recommend = new TbResourceRecommend();
|
||||
recommend.setID(IDUtils.generateID());
|
||||
recommend.setId(IDUtils.generateID());
|
||||
recommend.setResourceID(resourceId);
|
||||
recommend.setRecommendType(1); // 1-热门资源推荐
|
||||
recommend.setOrderNum(orderNum);
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
<!-- 结果映射 -->
|
||||
<resultMap id="BaseResultMap" type="org.xyzh.common.dto.crontab.TbCrontabLog">
|
||||
<id column="id" property="ID" />
|
||||
<id column="id" property="id" />
|
||||
<result column="task_id" property="taskId" />
|
||||
<result column="task_name" property="taskName" />
|
||||
<result column="task_group" property="taskGroup" />
|
||||
@@ -34,8 +34,8 @@
|
||||
<sql id="Base_Where_Clause">
|
||||
<where>
|
||||
<if test="filter != null">
|
||||
<if test="filter.ID != null and filter.ID != ''">
|
||||
AND id = #{filter.ID}
|
||||
<if test="filter.id != null and filter.id != ''">
|
||||
AND id = #{filter.id}
|
||||
</if>
|
||||
<if test="filter.taskId != null and filter.taskId != ''">
|
||||
AND task_id = #{filter.taskId}
|
||||
@@ -63,7 +63,7 @@
|
||||
<insert id="insertLog">
|
||||
INSERT INTO tb_crontab_log
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="log.ID != null">id,</if>
|
||||
<if test="log.id != null">id,</if>
|
||||
<if test="log.taskId != null">task_id,</if>
|
||||
<if test="log.taskName != null">task_name,</if>
|
||||
<if test="log.taskGroup != null">task_group,</if>
|
||||
@@ -81,7 +81,7 @@
|
||||
</trim>
|
||||
VALUES
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="log.ID != null">#{log.ID},</if>
|
||||
<if test="log.id != null">#{log.id},</if>
|
||||
<if test="log.taskId != null">#{log.taskId},</if>
|
||||
<if test="log.taskName != null">#{log.taskName},</if>
|
||||
<if test="log.taskGroup != null">#{log.taskGroup},</if>
|
||||
@@ -110,7 +110,7 @@
|
||||
<if test="log.endTime != null">end_time = #{log.endTime},</if>
|
||||
<if test="log.executeDuration != null">execute_duration = #{log.executeDuration},</if>
|
||||
update_time = NOW()
|
||||
WHERE id = #{log.ID} AND deleted = 0
|
||||
WHERE id = #{log.id} AND deleted = 0
|
||||
</update>
|
||||
|
||||
<!-- 根据ID查询日志 -->
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
<!-- 结果映射 -->
|
||||
<resultMap id="BaseResultMap" type="org.xyzh.common.dto.crontab.TbCrontabTask">
|
||||
<id column="id" property="ID" />
|
||||
<id column="id" property="id" />
|
||||
<result column="task_id" property="taskId" />
|
||||
<result column="task_name" property="taskName" />
|
||||
<result column="task_group" property="taskGroup" />
|
||||
@@ -66,8 +66,8 @@
|
||||
<sql id="Filter_Where_Clause">
|
||||
<where>
|
||||
<if test="filter != null">
|
||||
<if test="filter.ID != null and filter.ID != ''">
|
||||
AND id = #{filter.ID}
|
||||
<if test="filter.id != null and filter.id != ''">
|
||||
AND id = #{filter.id}
|
||||
</if>
|
||||
<if test="filter.taskId != null and filter.taskId != ''">
|
||||
AND task_id = #{filter.taskId}
|
||||
@@ -129,7 +129,7 @@
|
||||
<insert id="insertTask">
|
||||
INSERT INTO tb_crontab_task
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="task.ID != null">id,</if>
|
||||
<if test="task.id != null">id,</if>
|
||||
<if test="task.taskId != null">task_id,</if>
|
||||
<if test="task.taskName != null">task_name,</if>
|
||||
<if test="task.taskGroup != null">task_group,</if>
|
||||
@@ -149,7 +149,7 @@
|
||||
</trim>
|
||||
VALUES
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="task.ID != null">#{task.ID},</if>
|
||||
<if test="task.id != null">#{task.id},</if>
|
||||
<if test="task.taskId != null">#{task.taskId},</if>
|
||||
<if test="task.taskName != null">#{task.taskName},</if>
|
||||
<if test="task.taskGroup != null">#{task.taskGroup},</if>
|
||||
@@ -188,7 +188,7 @@
|
||||
<if test="task.updater != null">updater = #{task.updater},</if>
|
||||
update_time = NOW()
|
||||
</set>
|
||||
WHERE id = #{task.ID} AND deleted = 0
|
||||
WHERE id = #{task.id} AND deleted = 0
|
||||
</update>
|
||||
|
||||
<!-- 删除任务(逻辑删除) -->
|
||||
@@ -214,8 +214,8 @@
|
||||
<include refid="Permission_Filter" />
|
||||
WHERE ct.deleted = 0
|
||||
<if test="filter != null">
|
||||
<if test="filter.ID != null and filter.ID != ''">
|
||||
AND ct.id = #{filter.ID}
|
||||
<if test="filter.id != null and filter.id != ''">
|
||||
AND ct.id = #{filter.id}
|
||||
</if>
|
||||
<if test="filter.taskId != null and filter.taskId != ''">
|
||||
AND ct.task_id = #{filter.taskId}
|
||||
@@ -264,8 +264,8 @@
|
||||
ON ct.meta_id = m.meta_id AND m.deleted = 0
|
||||
WHERE ct.deleted = 0
|
||||
<if test="filter != null">
|
||||
<if test="filter.ID != null and filter.ID != ''">
|
||||
AND ct.id = #{filter.ID}
|
||||
<if test="filter.id != null and filter.id != ''">
|
||||
AND ct.id = #{filter.id}
|
||||
</if>
|
||||
<if test="filter.taskId != null and filter.taskId != ''">
|
||||
AND ct.task_id = #{filter.taskId}
|
||||
@@ -327,8 +327,8 @@
|
||||
<include refid="Permission_Filter" />
|
||||
WHERE ct.deleted = 0
|
||||
<if test="filter != null">
|
||||
<if test="filter.ID != null and filter.ID != ''">
|
||||
AND ct.id = #{filter.ID}
|
||||
<if test="filter.id != null and filter.id != ''">
|
||||
AND ct.id = #{filter.id}
|
||||
</if>
|
||||
<if test="filter.taskId != null and filter.taskId != ''">
|
||||
AND ct.task_id = #{filter.taskId}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
<!-- 结果映射 -->
|
||||
<resultMap id="BaseResultMap" type="org.xyzh.common.dto.crontab.TbCrontabEmailDefault">
|
||||
<id column="id" property="ID" />
|
||||
<id column="id" property="id" />
|
||||
<result column="default_id" property="defaultId" />
|
||||
<result column="meta_id" property="metaId" />
|
||||
<result column="user_id" property="userId" />
|
||||
@@ -29,7 +29,7 @@
|
||||
INSERT INTO tb_crontab_email_default (
|
||||
id, default_id, meta_id, user_id, creator, create_time
|
||||
) VALUES (
|
||||
#{emailDefault.ID}, #{emailDefault.defaultId}, #{emailDefault.metaId},
|
||||
#{emailDefault.id}, #{emailDefault.defaultId}, #{emailDefault.metaId},
|
||||
#{emailDefault.userId}, #{emailDefault.creator}, NOW()
|
||||
)
|
||||
</insert>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
<!-- 结果映射 -->
|
||||
<resultMap id="BaseResultMap" type="org.xyzh.common.dto.crontab.TbCrontabEmailRecipient">
|
||||
<id column="id" property="ID" />
|
||||
<id column="id" property="id" />
|
||||
<result column="recipient_id" property="recipientId" />
|
||||
<result column="task_id" property="taskId" />
|
||||
<result column="user_id" property="userId" />
|
||||
@@ -48,7 +48,7 @@
|
||||
INSERT INTO tb_crontab_email_recipient (
|
||||
id, recipient_id, task_id, user_id, email, name, creator, create_time
|
||||
) VALUES (
|
||||
#{recipient.ID}, #{recipient.recipientId}, #{recipient.taskId},
|
||||
#{recipient.id}, #{recipient.recipientId}, #{recipient.taskId},
|
||||
#{recipient.userId}, #{recipient.email}, #{recipient.name},
|
||||
#{recipient.creator}, NOW()
|
||||
)
|
||||
@@ -60,7 +60,7 @@
|
||||
id, recipient_id, task_id, user_id, email, name, creator, create_time
|
||||
) VALUES
|
||||
<foreach collection="recipients" item="item" separator=",">
|
||||
(#{item.ID}, #{item.recipientId}, #{item.taskId},
|
||||
(#{item.id}, #{item.recipientId}, #{item.taskId},
|
||||
#{item.userId}, #{item.email}, #{item.name}, #{item.creator}, NOW())
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
<!-- 结果映射 -->
|
||||
<resultMap id="BaseResultMap" type="org.xyzh.common.dto.crontab.TbCrontabTaskMeta">
|
||||
<id column="id" property="ID" />
|
||||
<id column="id" property="id" />
|
||||
<result column="meta_id" property="metaId" />
|
||||
<result column="name" property="name" />
|
||||
<result column="description" property="description" />
|
||||
@@ -52,7 +52,7 @@
|
||||
id, meta_id, name, description, category, bean_name, method_name,
|
||||
script_path, param_schema, auto_publish, sort_order, creator, create_time
|
||||
) VALUES (
|
||||
#{taskMeta.ID}, #{taskMeta.metaId}, #{taskMeta.name}, #{taskMeta.description},
|
||||
#{taskMeta.id}, #{taskMeta.metaId}, #{taskMeta.name}, #{taskMeta.description},
|
||||
#{taskMeta.category}, #{taskMeta.beanName}, #{taskMeta.methodName},
|
||||
#{taskMeta.scriptPath}, #{taskMeta.paramSchema}, #{taskMeta.autoPublish}, #{taskMeta.sortOrder},
|
||||
#{taskMeta.creator}, NOW()
|
||||
|
||||
Reference in New Issue
Block a user