PaperBasicInfo
parent
43383b701f
commit
c68ccbe003
|
|
@ -14,6 +14,8 @@ import org.qinan.safetyeval.infrastructure.dataobject.base.Req;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 班级课程
|
* 班级课程
|
||||||
*/
|
*/
|
||||||
|
|
@ -31,6 +33,15 @@ public class ClassCourseController {
|
||||||
return SingleResponse.success(classCourseService.saveCourse(dto));
|
return SingleResponse.success(classCourseService.saveCourse(dto));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量新增班级课程
|
||||||
|
*/
|
||||||
|
@ApiOperation("批量新增班级课程")
|
||||||
|
@PostMapping("/batchSave")
|
||||||
|
public SingleResponse<Boolean> batchSave(@RequestBody List<ClassCourseDTO> dtoList) {
|
||||||
|
return SingleResponse.success(classCourseService.saveCourseBatch(dtoList));
|
||||||
|
}
|
||||||
|
|
||||||
@ApiOperation("班级课程详情")
|
@ApiOperation("班级课程详情")
|
||||||
@GetMapping("/get")
|
@GetMapping("/get")
|
||||||
public SingleResponse<ClassCourseVO> get(@ApiParam("主键ID") @RequestParam Long id) {
|
public SingleResponse<ClassCourseVO> get(@ApiParam("主键ID") @RequestParam Long id) {
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,8 @@ import org.qinan.cedu.model.entity.ClassCourseDO;
|
||||||
import org.qinan.cedu.model.query.ClassCoursePageQuery;
|
import org.qinan.cedu.model.query.ClassCoursePageQuery;
|
||||||
import org.qinan.cedu.model.vo.ClassCourseVO;
|
import org.qinan.cedu.model.vo.ClassCourseVO;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 班级课程服务
|
* 班级课程服务
|
||||||
*/
|
*/
|
||||||
|
|
@ -18,6 +20,14 @@ public interface ClassCourseService extends IService<ClassCourseDO> {
|
||||||
|
|
||||||
boolean saveCourse(ClassCourseDTO dto);
|
boolean saveCourse(ClassCourseDTO dto);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量新增班级课程
|
||||||
|
*
|
||||||
|
* @param dtoList 课程信息列表
|
||||||
|
* @return 是否全部保存成功
|
||||||
|
*/
|
||||||
|
boolean saveCourseBatch(List<ClassCourseDTO> dtoList);
|
||||||
|
|
||||||
boolean updateCourse(ClassCourseDTO dto);
|
boolean updateCourse(ClassCourseDTO dto);
|
||||||
|
|
||||||
boolean deleteById(Long id);
|
boolean deleteById(Long id);
|
||||||
|
|
|
||||||
|
|
@ -88,10 +88,32 @@ public class ClassCourseServiceImpl extends ServiceImpl<ClassCourseMapper, Class
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean saveCourse(ClassCourseDTO dto) {
|
public boolean saveCourse(ClassCourseDTO dto) {
|
||||||
|
return this.save(buildEntity(dto));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量新增班级课程
|
||||||
|
*
|
||||||
|
* @param dtoList 课程信息列表
|
||||||
|
* @return 是否全部保存成功
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean saveCourseBatch(List<ClassCourseDTO> dtoList) {
|
||||||
|
List<ClassCourseDO> entities = dtoList.stream().map(this::buildEntity).collect(Collectors.toList());
|
||||||
|
return this.saveBatch(entities);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将 DTO 转换为实体并填充默认值
|
||||||
|
*
|
||||||
|
* @param dto 课程信息
|
||||||
|
* @return 班级课程实体
|
||||||
|
*/
|
||||||
|
private ClassCourseDO buildEntity(ClassCourseDTO dto) {
|
||||||
ClassCourseDO entity = classCourseConvertor.convertDtoToE(dto);
|
ClassCourseDO entity = classCourseConvertor.convertDtoToE(dto);
|
||||||
InsertFieldDefaults.applyIgnoreOrgId(entity);
|
InsertFieldDefaults.applyIgnoreOrgId(entity);
|
||||||
entity.setUpdateTime(LocalDateTime.now());
|
entity.setUpdateTime(LocalDateTime.now());
|
||||||
return this.save(entity);
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue