培训-init
parent
906402f7db
commit
578f51f2c3
|
|
@ -44,6 +44,11 @@
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.qinan</groupId>
|
||||||
|
<artifactId>safety-eval-client</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- MapStruct -->
|
<!-- MapStruct -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.mapstruct</groupId>
|
<groupId>org.mapstruct</groupId>
|
||||||
|
|
@ -56,6 +61,10 @@
|
||||||
<version>${mapstruct.version}</version>
|
<version>${mapstruct.version}</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.qinan</groupId>
|
||||||
|
<artifactId>safety-eval-infrastructure</artifactId>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
|
||||||
|
|
@ -5,18 +5,13 @@ import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import io.swagger.annotations.ApiParam;
|
import io.swagger.annotations.ApiParam;
|
||||||
import org.qinan.cedu.model.dto.CourseManagementDTO;
|
import org.qinan.cedu.model.dto.CourseManagementDTO;
|
||||||
import org.qinan.cedu.model.query.CourseManagementPageQuery;
|
|
||||||
import org.qinan.cedu.model.dto.CourseManagementVO;
|
import org.qinan.cedu.model.dto.CourseManagementVO;
|
||||||
import org.qinan.cedu.model.dto.PageResponse;
|
import org.qinan.cedu.model.query.CourseManagementPageQuery;
|
||||||
import org.qinan.cedu.model.dto.SingleResponse;
|
|
||||||
import org.qinan.cedu.service.CourseManagementService;
|
import org.qinan.cedu.service.CourseManagementService;
|
||||||
|
import org.qinan.safetyeval.client.dto.PageResponse;
|
||||||
|
import org.qinan.safetyeval.client.dto.SingleResponse;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 课程管理
|
* 课程管理
|
||||||
|
|
|
||||||
|
|
@ -6,16 +6,11 @@ import io.swagger.annotations.ApiOperation;
|
||||||
import io.swagger.annotations.ApiParam;
|
import io.swagger.annotations.ApiParam;
|
||||||
import org.qinan.cedu.model.dto.CourseRelCoursewareDTO;
|
import org.qinan.cedu.model.dto.CourseRelCoursewareDTO;
|
||||||
import org.qinan.cedu.model.dto.CourseRelCoursewareVO;
|
import org.qinan.cedu.model.dto.CourseRelCoursewareVO;
|
||||||
import org.qinan.cedu.model.dto.PageResponse;
|
|
||||||
import org.qinan.cedu.model.dto.SingleResponse;
|
|
||||||
import org.qinan.cedu.service.CourseRelCoursewareService;
|
import org.qinan.cedu.service.CourseRelCoursewareService;
|
||||||
|
import org.qinan.safetyeval.client.dto.PageResponse;
|
||||||
|
import org.qinan.safetyeval.client.dto.SingleResponse;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,18 +5,13 @@ import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import io.swagger.annotations.ApiParam;
|
import io.swagger.annotations.ApiParam;
|
||||||
import org.qinan.cedu.model.dto.CoursewareManagementDTO;
|
import org.qinan.cedu.model.dto.CoursewareManagementDTO;
|
||||||
import org.qinan.cedu.model.query.CoursewareManagementPageQuery;
|
|
||||||
import org.qinan.cedu.model.dto.CoursewareManagementVO;
|
import org.qinan.cedu.model.dto.CoursewareManagementVO;
|
||||||
import org.qinan.cedu.model.dto.PageResponse;
|
import org.qinan.cedu.model.query.CoursewareManagementPageQuery;
|
||||||
import org.qinan.cedu.model.dto.SingleResponse;
|
|
||||||
import org.qinan.cedu.service.CoursewareManagementService;
|
import org.qinan.cedu.service.CoursewareManagementService;
|
||||||
|
import org.qinan.safetyeval.client.dto.PageResponse;
|
||||||
|
import org.qinan.safetyeval.client.dto.SingleResponse;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 课件管理
|
* 课件管理
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 课程管理
|
* 课程管理
|
||||||
|
|
@ -64,4 +65,7 @@ public class CourseManagementDTO{
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty("是否已被使用(0-未使用,1-已使用)")
|
@ApiModelProperty("是否已被使用(0-未使用,1-已使用)")
|
||||||
private Integer used;
|
private Integer used;
|
||||||
|
|
||||||
|
@ApiModelProperty("归属课件")
|
||||||
|
private List<CourseRelCoursewareDTO> courseRelCoursewareDTOList;
|
||||||
}
|
}
|
||||||
|
|
@ -5,6 +5,7 @@ import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 课程管理
|
* 课程管理
|
||||||
|
|
@ -61,4 +62,7 @@ public class CourseManagementVO extends BaseVO {
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty("是否已被使用(0-未使用,1-已使用)")
|
@ApiModelProperty("是否已被使用(0-未使用,1-已使用)")
|
||||||
private Integer used;
|
private Integer used;
|
||||||
|
|
||||||
|
@ApiModelProperty("归属课件")
|
||||||
|
private List<CourseRelCoursewareVO> courseRelCoursewareVOList;
|
||||||
}
|
}
|
||||||
|
|
@ -73,4 +73,7 @@ public class CoursewareManagementVO extends BaseVO {
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty("课件描述")
|
@ApiModelProperty("课件描述")
|
||||||
private String coursewareDescription;
|
private String coursewareDescription;
|
||||||
|
|
||||||
|
@ApiModelProperty("习题数")
|
||||||
|
private Integer exerciseCount;
|
||||||
}
|
}
|
||||||
|
|
@ -1,27 +0,0 @@
|
||||||
package org.qinan.cedu.model.dto;
|
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 通用分页响应体
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
public class PageResponse<T> extends SingleResponse<List<T>> {
|
|
||||||
|
|
||||||
@ApiModelProperty(value = "总条数")
|
|
||||||
private Long total;
|
|
||||||
|
|
||||||
public static <T> PageResponse<T> of(List<T> list, Long total) {
|
|
||||||
PageResponse<T> response = new PageResponse<>();
|
|
||||||
response.setSuccess(true);
|
|
||||||
response.setCode("0");
|
|
||||||
response.setData(list);
|
|
||||||
response.setTotal(total);
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,50 +0,0 @@
|
||||||
package org.qinan.cedu.model.dto;
|
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 通用单条数据响应体
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class SingleResponse<T> {
|
|
||||||
|
|
||||||
@ApiModelProperty(value = "是否成功")
|
|
||||||
private boolean success;
|
|
||||||
|
|
||||||
@ApiModelProperty(value = "响应码")
|
|
||||||
private String code;
|
|
||||||
|
|
||||||
@ApiModelProperty(value = "响应消息")
|
|
||||||
private String message;
|
|
||||||
|
|
||||||
@ApiModelProperty(value = "错误响应消息")
|
|
||||||
private String errMessage;
|
|
||||||
|
|
||||||
@ApiModelProperty(value = "响应数据")
|
|
||||||
private T data;
|
|
||||||
|
|
||||||
public static <T> SingleResponse<T> success(T data) {
|
|
||||||
SingleResponse<T> response = new SingleResponse<>();
|
|
||||||
response.setSuccess(true);
|
|
||||||
response.setCode("0");
|
|
||||||
response.setData(data);
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static SingleResponse<Void> success() {
|
|
||||||
SingleResponse<Void> response = new SingleResponse<>();
|
|
||||||
response.setSuccess(true);
|
|
||||||
response.setCode("0");
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T> SingleResponse<T> error(String code, String message) {
|
|
||||||
SingleResponse<T> response = new SingleResponse<>();
|
|
||||||
response.setSuccess(false);
|
|
||||||
response.setCode(code);
|
|
||||||
response.setMessage(message);
|
|
||||||
response.setErrMessage(message);
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,21 +1,28 @@
|
||||||
package org.qinan.cedu.service.impl;
|
package org.qinan.cedu.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import org.qinan.cedu.convertor.CourseManagementConvertor;
|
import org.qinan.cedu.convertor.CourseManagementConvertor;
|
||||||
|
import org.qinan.cedu.convertor.CourseRelCoursewareConvertor;
|
||||||
|
import org.qinan.cedu.enums.DeleteEnum;
|
||||||
|
import org.qinan.cedu.mapper.CourseManagementMapper;
|
||||||
|
import org.qinan.cedu.mapper.CourseRelCoursewareMapper;
|
||||||
import org.qinan.cedu.model.dto.CourseManagementDTO;
|
import org.qinan.cedu.model.dto.CourseManagementDTO;
|
||||||
import org.qinan.cedu.model.query.CourseManagementPageQuery;
|
import org.qinan.cedu.model.query.CourseManagementPageQuery;
|
||||||
import org.qinan.cedu.model.dto.CourseManagementVO;
|
import org.qinan.cedu.model.dto.CourseManagementVO;
|
||||||
import org.qinan.cedu.model.entity.CourseManagementDO;
|
import org.qinan.cedu.model.entity.CourseManagementDO;
|
||||||
import org.qinan.cedu.enums.DeleteEnum;
|
import org.qinan.cedu.model.entity.CourseRelCoursewareDO;
|
||||||
import org.qinan.cedu.mapper.CourseManagementMapper;
|
|
||||||
import org.qinan.cedu.service.CourseManagementService;
|
import org.qinan.cedu.service.CourseManagementService;
|
||||||
|
import org.qinan.safetyeval.infrastructure.support.InsertFieldDefaults;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 课程管理服务实现
|
* 课程管理服务实现
|
||||||
|
|
@ -26,18 +33,30 @@ public class CourseManagementServiceImpl extends ServiceImpl<CourseManagementMap
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private CourseManagementConvertor courseManagementConvertor;
|
private CourseManagementConvertor courseManagementConvertor;
|
||||||
|
@Autowired
|
||||||
|
private CourseRelCoursewareConvertor courseRelCoursewareConvertor;
|
||||||
|
@Autowired
|
||||||
|
private CourseRelCoursewareMapper courseRelCoursewareMapper;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IPage<CourseManagementVO> pageQuery(CourseManagementPageQuery query) {
|
public IPage<CourseManagementVO> pageQuery(CourseManagementPageQuery query) {
|
||||||
long current = query.getCurrent() == null ? 1L : query.getCurrent();
|
|
||||||
long size = query.getSize() == null ? 10L : query.getSize();
|
|
||||||
IPage<CourseManagementDO> page = this.lambdaQuery()
|
IPage<CourseManagementDO> page = this.lambdaQuery()
|
||||||
.eq(CourseManagementDO::getDeleteEnum, DeleteEnum.FALSE.getCode())
|
.eq(CourseManagementDO::getDeleteEnum, DeleteEnum.FALSE.getCode())
|
||||||
.like(StringUtils.hasText(query.getCourseName()), CourseManagementDO::getCourseName, query.getCourseName())
|
.like(StringUtils.hasText(query.getCourseName()), CourseManagementDO::getCourseName, query.getCourseName())
|
||||||
.eq(query.getStatus() != null, CourseManagementDO::getStatus, query.getStatus())
|
.eq(query.getStatus() != null, CourseManagementDO::getStatus, query.getStatus())
|
||||||
|
.eq(query.getTrainingType() != null, CourseManagementDO::getTrainingType, query.getTrainingType())
|
||||||
.orderByDesc(CourseManagementDO::getCreateTime)
|
.orderByDesc(CourseManagementDO::getCreateTime)
|
||||||
.page(new Page<>(current, size));
|
.page(new Page<>(query.getCurrent(), query.getSize()));
|
||||||
return page.convert(courseManagementConvertor::convertEToVo);
|
IPage<CourseManagementVO> convert = page.convert(courseManagementConvertor::convertEToVo);
|
||||||
|
convert.getRecords().forEach(vo -> {
|
||||||
|
vo.setCourseRelCoursewareVOList(courseRelCoursewareConvertor.convertEListToVoList(
|
||||||
|
courseRelCoursewareMapper.selectList(new LambdaQueryWrapper<CourseRelCoursewareDO>()
|
||||||
|
.eq(CourseRelCoursewareDO::getCourseId, vo.getId())
|
||||||
|
.orderByAsc(CourseRelCoursewareDO::getSort))
|
||||||
|
));
|
||||||
|
});
|
||||||
|
return convert;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -46,27 +65,48 @@ public class CourseManagementServiceImpl extends ServiceImpl<CourseManagementMap
|
||||||
.eq(CourseManagementDO::getId, id)
|
.eq(CourseManagementDO::getId, id)
|
||||||
.eq(CourseManagementDO::getDeleteEnum, DeleteEnum.FALSE.getCode())
|
.eq(CourseManagementDO::getDeleteEnum, DeleteEnum.FALSE.getCode())
|
||||||
.one();
|
.one();
|
||||||
return courseManagementConvertor.convertEToVo(entity);
|
CourseManagementVO courseManagementVO = courseManagementConvertor.convertEToVo(entity);
|
||||||
|
courseManagementVO.setCourseRelCoursewareVOList(courseRelCoursewareConvertor.convertEListToVoList(
|
||||||
|
courseRelCoursewareMapper.selectList(new LambdaQueryWrapper<CourseRelCoursewareDO>()
|
||||||
|
.eq(CourseRelCoursewareDO::getCourseId, courseManagementVO.getId())
|
||||||
|
.orderByAsc(CourseRelCoursewareDO::getSort))
|
||||||
|
));
|
||||||
|
return courseManagementVO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public boolean saveCourse(CourseManagementDTO dto) {
|
public boolean saveCourse(CourseManagementDTO dto) {
|
||||||
CourseManagementDO entity = courseManagementConvertor.convertDtoToE(dto);
|
CourseManagementDO entity = courseManagementConvertor.convertDtoToE(dto);
|
||||||
|
InsertFieldDefaults.applyIgnoreOrgId(entity);
|
||||||
LocalDateTime now = LocalDateTime.now();
|
LocalDateTime now = LocalDateTime.now();
|
||||||
entity.setCreateTime(now);
|
|
||||||
entity.setUpdateTime(now);
|
entity.setUpdateTime(now);
|
||||||
entity.setVersion(0);
|
|
||||||
if (entity.getUsed() == null) {
|
if (entity.getUsed() == null) {
|
||||||
entity.setUsed(0);
|
entity.setUsed(0);
|
||||||
}
|
}
|
||||||
return this.save(entity);
|
this.save(entity);
|
||||||
|
List<CourseRelCoursewareDO> courseRelCoursewareDOS = courseRelCoursewareConvertor.convertDtoListToEList(dto.getCourseRelCoursewareDTOList());
|
||||||
|
for (CourseRelCoursewareDO courseRelCoursewareDO : courseRelCoursewareDOS) {
|
||||||
|
courseRelCoursewareDO.setCourseId(entity.getId());
|
||||||
|
courseRelCoursewareMapper.insert(courseRelCoursewareDO);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public boolean updateCourse(CourseManagementDTO dto) {
|
public boolean updateCourse(CourseManagementDTO dto) {
|
||||||
CourseManagementDO entity = courseManagementConvertor.convertDtoToE(dto);
|
CourseManagementDO entity = courseManagementConvertor.convertDtoToE(dto);
|
||||||
entity.setUpdateTime(LocalDateTime.now());
|
InsertFieldDefaults.applyForUpdateIgnoreOrgId(entity);
|
||||||
return this.updateById(entity);
|
this.updateById(entity);
|
||||||
|
courseRelCoursewareMapper.delete(new LambdaQueryWrapper<CourseRelCoursewareDO>()
|
||||||
|
.eq(CourseRelCoursewareDO::getCourseId, entity.getId()));
|
||||||
|
List<CourseRelCoursewareDO> courseRelCoursewareDOS = courseRelCoursewareConvertor.convertDtoListToEList(dto.getCourseRelCoursewareDTOList());
|
||||||
|
for (CourseRelCoursewareDO courseRelCoursewareDO : courseRelCoursewareDOS) {
|
||||||
|
courseRelCoursewareDO.setCourseId(entity.getId());
|
||||||
|
courseRelCoursewareMapper.insert(courseRelCoursewareDO);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -4,10 +4,10 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import org.qinan.cedu.convertor.CourseRelCoursewareConvertor;
|
import org.qinan.cedu.convertor.CourseRelCoursewareConvertor;
|
||||||
|
import org.qinan.cedu.mapper.CourseRelCoursewareMapper;
|
||||||
import org.qinan.cedu.model.dto.CourseRelCoursewareDTO;
|
import org.qinan.cedu.model.dto.CourseRelCoursewareDTO;
|
||||||
import org.qinan.cedu.model.dto.CourseRelCoursewareVO;
|
import org.qinan.cedu.model.dto.CourseRelCoursewareVO;
|
||||||
import org.qinan.cedu.model.entity.CourseRelCoursewareDO;
|
import org.qinan.cedu.model.entity.CourseRelCoursewareDO;
|
||||||
import org.qinan.cedu.mapper.CourseRelCoursewareMapper;
|
|
||||||
import org.qinan.cedu.service.CourseRelCoursewareService;
|
import org.qinan.cedu.service.CourseRelCoursewareService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ import org.qinan.cedu.model.entity.CoursewareManagementDO;
|
||||||
import org.qinan.cedu.enums.DeleteEnum;
|
import org.qinan.cedu.enums.DeleteEnum;
|
||||||
import org.qinan.cedu.mapper.CoursewareManagementMapper;
|
import org.qinan.cedu.mapper.CoursewareManagementMapper;
|
||||||
import org.qinan.cedu.service.CoursewareManagementService;
|
import org.qinan.cedu.service.CoursewareManagementService;
|
||||||
|
import org.qinan.safetyeval.infrastructure.support.InsertFieldDefaults;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
@ -29,15 +30,19 @@ public class CoursewareManagementServiceImpl extends ServiceImpl<CoursewareManag
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IPage<CoursewareManagementVO> pageQuery(CoursewareManagementPageQuery query) {
|
public IPage<CoursewareManagementVO> pageQuery(CoursewareManagementPageQuery query) {
|
||||||
long current = query.getCurrent() == null ? 1L : query.getCurrent();
|
|
||||||
long size = query.getSize() == null ? 10L : query.getSize();
|
|
||||||
IPage<CoursewareManagementDO> page = this.lambdaQuery()
|
IPage<CoursewareManagementDO> page = this.lambdaQuery()
|
||||||
.eq(CoursewareManagementDO::getDeleteEnum, DeleteEnum.FALSE.getCode())
|
.eq(CoursewareManagementDO::getDeleteEnum, DeleteEnum.FALSE.getCode())
|
||||||
.like(StringUtils.hasText(query.getCoursewareName()), CoursewareManagementDO::getCoursewareName, query.getCoursewareName())
|
.like(StringUtils.hasText(query.getCoursewareName()), CoursewareManagementDO::getCoursewareName, query.getCoursewareName())
|
||||||
.eq(query.getStatus() != null, CoursewareManagementDO::getStatus, query.getStatus())
|
.eq(query.getStatus() != null, CoursewareManagementDO::getStatus, query.getStatus())
|
||||||
|
.eq(query.getTrainingType() != null, CoursewareManagementDO::getTrainingType, query.getTrainingType())
|
||||||
.orderByDesc(CoursewareManagementDO::getCreateTime)
|
.orderByDesc(CoursewareManagementDO::getCreateTime)
|
||||||
.page(new Page<>(current, size));
|
.page(new Page<>(query.getCurrent(), query.getSize()));
|
||||||
return page.convert(coursewareManagementConvertor::convertEToVo);
|
IPage<CoursewareManagementVO> convert = page.convert(coursewareManagementConvertor::convertEToVo);
|
||||||
|
for (CoursewareManagementVO record : convert.getRecords()) {
|
||||||
|
// todo 统计课件题数
|
||||||
|
record.setExerciseCount(1);
|
||||||
|
}
|
||||||
|
return convert;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -46,23 +51,22 @@ public class CoursewareManagementServiceImpl extends ServiceImpl<CoursewareManag
|
||||||
.eq(CoursewareManagementDO::getId, id)
|
.eq(CoursewareManagementDO::getId, id)
|
||||||
.eq(CoursewareManagementDO::getDeleteEnum, DeleteEnum.FALSE.getCode())
|
.eq(CoursewareManagementDO::getDeleteEnum, DeleteEnum.FALSE.getCode())
|
||||||
.one();
|
.one();
|
||||||
return coursewareManagementConvertor.convertEToVo(entity);
|
CoursewareManagementVO coursewareManagementVO = coursewareManagementConvertor.convertEToVo(entity);
|
||||||
|
coursewareManagementVO.setExerciseCount(1);
|
||||||
|
return coursewareManagementVO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean saveCourseware(CoursewareManagementDTO dto) {
|
public boolean saveCourseware(CoursewareManagementDTO dto) {
|
||||||
CoursewareManagementDO entity = coursewareManagementConvertor.convertDtoToE(dto);
|
CoursewareManagementDO entity = coursewareManagementConvertor.convertDtoToE(dto);
|
||||||
LocalDateTime now = LocalDateTime.now();
|
InsertFieldDefaults.applyIgnoreOrgId(entity);
|
||||||
entity.setCreateTime(now);
|
|
||||||
entity.setUpdateTime(now);
|
|
||||||
entity.setVersion(0);
|
|
||||||
return this.save(entity);
|
return this.save(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean updateCourseware(CoursewareManagementDTO dto) {
|
public boolean updateCourseware(CoursewareManagementDTO dto) {
|
||||||
CoursewareManagementDO entity = coursewareManagementConvertor.convertDtoToE(dto);
|
CoursewareManagementDO entity = coursewareManagementConvertor.convertDtoToE(dto);
|
||||||
entity.setUpdateTime(LocalDateTime.now());
|
InsertFieldDefaults.applyForUpdateIgnoreOrgId(entity);
|
||||||
return this.updateById(entity);
|
return this.updateById(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -116,6 +116,23 @@ public final class InsertFieldDefaults {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void applyForUpdateIgnoreOrgId(Object dataObject) {
|
||||||
|
if (dataObject == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
LocalDateTime now = LocalDateTime.now();
|
||||||
|
Long userId = AuthUserContextAdapter.getCurrentUserId();
|
||||||
|
String userName = AuthUserContextAdapter.getCurrentUserName();
|
||||||
|
|
||||||
|
setIfNull(dataObject, "updateTime", now);
|
||||||
|
if (userId != null) {
|
||||||
|
setIfNull(dataObject, "updateId", userId);
|
||||||
|
}
|
||||||
|
if (userName != null) {
|
||||||
|
setIfNull(dataObject, "updateName", userName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static void setIfNull(Object target, String property, Object value) {
|
private static void setIfNull(Object target, String property, Object value) {
|
||||||
try {
|
try {
|
||||||
String getterName = "get" + Character.toUpperCase(property.charAt(0)) + property.substring(1);
|
String getterName = "get" + Character.toUpperCase(property.charAt(0)) + property.substring(1);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue