Browse Source

添加时记录创建时间

dzx 1 year ago
parent
commit
a42fddc351

+ 6 - 0
src/main/java/com/xjrsoft/module/textbook/service/impl/SubjectGroupServiceImpl.java

@@ -1,5 +1,6 @@
 package com.xjrsoft.module.textbook.service.impl;
 
+import cn.dev33.satoken.stp.StpUtil;
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.util.ObjectUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@@ -17,6 +18,7 @@ import lombok.AllArgsConstructor;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.util.Date;
 import java.util.List;
 
 /**
@@ -35,6 +37,8 @@ public class SubjectGroupServiceImpl extends MPJBaseServiceImpl<SubjectGroupMapp
     @Transactional
     public Boolean add(AddSubjectGroupDto dto) {
         SubjectGroup subjectGroup = BeanUtil.toBean(dto, SubjectGroup.class);
+        subjectGroup.setCreateDate(new Date());
+        subjectGroup.setCreateUserId(StpUtil.getLoginIdAsLong());
         boolean isSuccess = this.save(subjectGroup);
 
         LambdaQueryWrapper<SubjectGroup> queryWrapper = new LambdaQueryWrapper<>();
@@ -49,6 +53,8 @@ public class SubjectGroupServiceImpl extends MPJBaseServiceImpl<SubjectGroupMapp
                 SubjectGroupCourse subjectGroupCourse = new SubjectGroupCourse();
                 subjectGroupCourse.setSubjectGroupId(result.getId());
                 subjectGroupCourse.setCourseSubjectId(subjectGroupCourseId);
+                subjectGroupCourse.setCreateDate(new Date());
+                subjectGroupCourse.setCreateUserId(StpUtil.getLoginIdAsLong());
                 isSuccess = subjectGroupCourseService.save(subjectGroupCourse);
                 if(!isSuccess){
                     throw new MyException("出现未知错误,联系管理员");