|
@@ -2,32 +2,66 @@ package cn.cslg.report.service.business;
|
|
|
|
|
|
import cn.cslg.report.common.model.BaseVO;
|
|
|
import cn.cslg.report.common.utils.DataUtils;
|
|
|
+import cn.cslg.report.common.utils.LogExceptionUtil;
|
|
|
import cn.cslg.report.common.utils.Response;
|
|
|
import cn.cslg.report.entity.Task;
|
|
|
import cn.cslg.report.mapper.TaskMapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
|
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.Date;
|
|
|
import java.util.List;
|
|
|
|
|
|
@Service
|
|
|
+@Slf4j
|
|
|
public class TaskService extends ServiceImpl<TaskMapper, Task> {
|
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public String addTask(Task task) {
|
|
|
- this.save(task);
|
|
|
- return Response.success();
|
|
|
+ try {
|
|
|
+ this.save(task);
|
|
|
+ return Response.success();
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("添加任务异常,异常信息:" + LogExceptionUtil.getMessage(e));
|
|
|
+ log.info("添加任务异常,开始回滚! 时间: " + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+ log.info("回滚完毕! 时间: " + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
|
|
|
+ return Response.error();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public String deleteTask(Integer id) {
|
|
|
- this.removeById(id);
|
|
|
- return Response.success();
|
|
|
+ try {
|
|
|
+ this.removeById(id);
|
|
|
+ return Response.success();
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("删除任务异常,异常信息:" + LogExceptionUtil.getMessage(e));
|
|
|
+ log.info("删除任务异常,开始回滚! 时间: " + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+ log.info("回滚完毕! 时间: " + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
|
|
|
+ return Response.error();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public String updateTask(Task task) {
|
|
|
- this.updateById(task);
|
|
|
- return Response.success();
|
|
|
+ try {
|
|
|
+ this.updateById(task);
|
|
|
+ return Response.success();
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("修改任务异常,异常信息:" + LogExceptionUtil.getMessage(e));
|
|
|
+ log.info("修改任务异常,开始回滚! 时间: " + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+ log.info("回滚完毕! 时间: " + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
|
|
|
+ return Response.error();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public String queryPageList(Task task, BaseVO baseVO) {
|