[AppleScript] 纯文本查看 复制代码
//保存CoursePub
public CoursePub saveCoursePub(String id, CoursePub coursePub){
if(StringUtils.isNotEmpty(id)){
ExceptionCast.cast(CourseCode.COURSE_PUBLISH_COURSEIDISNULL);
}
CoursePub coursePubNew = null;
Optional<CoursePub> coursePubOptional =
coursePubRepository
.findById(id);
if(coursePubOptional.isPresent()){
coursePubNew =
coursePubOptional.
get();
}
if(coursePubNew == null){
coursePubNew = new CoursePub();
}
BeanUtils.copyProperties(coursePub,coursePubNew);
//设置主键
coursePubNew.setId(id);
//更新时间戳为最新时间
coursePub.setTimestamp(new Date());
//发布时间
SimpleDateFormat simpleDateFormat
= new SimpleDateFormat(
"
YYYY
‐
MM
‐
dd HH:mm:ss
"
);
String date
=
simpleDateFormat.format(new Date());
coursePub.setPubTime(date);
coursePubRepository
.save(coursePub);
return coursePub;
}
//创建coursePub对象
private CoursePub createCoursePub(String id){
CoursePub coursePub
= new CoursePub();
coursePub.setId(id);
//基础信息
Optional<CourseBase> courseBaseOptional =
courseBaseRepository
.findById(id);
if(courseBaseOptional == null){
CourseBase courseBase
=
courseBaseOptional.
get();
BeanUtils.copyProperties(courseBase, coursePub);
}
//查询课程图片
Optional<CoursePic> picOptional =
coursePicRepository
.findById(id);
if(picOptional.isPresent()){
CoursePic coursePic
=
picOptional.
get();
BeanUtils.copyProperties(coursePic, coursePub);
}
//课程营销信息
Optional<CourseMarket> marketOptional =
courseMarketRepository
.findById(id);
if(marketOptional.isPresent()){
CourseMarket courseMarket
= marketOptional.
get();
BeanUtils.copyProperties(courseMarket, coursePub);
}
//课程计划
TeachplanNode teachplanNode
=
teachplanMapper.selectList(id);
//将课程计划转成json
String teachplanString
=
JSON.toJSONString(teachplanNode);
coursePub.setTeachplan(teachplanString);
return coursePub;
}