教师端新增实训教案
parent
379a03f7e1
commit
44fdd9ba13
@ -0,0 +1,17 @@
|
||||
package com.sztzjy.forex.trading_trading.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@ApiModel("新增实训教案入参")
|
||||
@Getter
|
||||
@Setter
|
||||
@Data
|
||||
public class TrainingLessonPlanBO {
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,83 @@
|
||||
package com.sztzjy.forex.trading_trading.service;
|
||||
|
||||
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.sztzjy.forex.trading_trading.config.security.JwtUser;
|
||||
import com.sztzjy.forex.trading_trading.entity.TrainingLessonPlan;
|
||||
import com.sztzjy.forex.trading_trading.entity.TrainingLessonPlanExample;
|
||||
import com.sztzjy.forex.trading_trading.mappers.TrainingLessonPlanMapper;
|
||||
import com.sztzjy.forex.trading_trading.util.file.IFileUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class TrainingLessonPlanService {
|
||||
|
||||
|
||||
@Autowired
|
||||
TrainingLessonPlanMapper trainingLessonPlanMapper;
|
||||
@Autowired
|
||||
IFileUtil fileUtil;
|
||||
|
||||
|
||||
public void create(String name, MultipartFile file, JwtUser currentUser) {
|
||||
Assert.isTrue(findByName(name) == null, "教案名称已存在");
|
||||
String filePath = fileUtil.upload(file);
|
||||
|
||||
TrainingLessonPlan trainingLessonPlan = new TrainingLessonPlan();
|
||||
trainingLessonPlan.setName(name);
|
||||
trainingLessonPlan.setFilePath(filePath);
|
||||
trainingLessonPlan.setId(IdUtil.simpleUUID());
|
||||
trainingLessonPlan.setCreateTime(new Date());
|
||||
trainingLessonPlan.setCreatorId(Integer.valueOf(currentUser.getUserId()));
|
||||
trainingLessonPlan.setCreatorName(currentUser.getName());
|
||||
trainingLessonPlan.setSchoolId(currentUser.getSchoolId());
|
||||
trainingLessonPlanMapper.insert(trainingLessonPlan);
|
||||
}
|
||||
|
||||
|
||||
public TrainingLessonPlan findByName(String name) {
|
||||
TrainingLessonPlanExample example = new TrainingLessonPlanExample();
|
||||
TrainingLessonPlanExample.Criteria criteria = example.createCriteria();
|
||||
criteria.andNameEqualTo(name);
|
||||
List<TrainingLessonPlan> trainingLessonPlans = trainingLessonPlanMapper.selectByExample(example);
|
||||
if (trainingLessonPlans == null || trainingLessonPlans.size() == 0) {
|
||||
return null;
|
||||
}
|
||||
return trainingLessonPlans.get(0);
|
||||
}
|
||||
|
||||
public PageInfo<TrainingLessonPlan> findByConditions(String name,JwtUser currentUser, Integer pageNum, Integer pageSize) {
|
||||
TrainingLessonPlanExample example = new TrainingLessonPlanExample();
|
||||
TrainingLessonPlanExample.Criteria criteria = example.createCriteria();
|
||||
PageHelper.startPage(pageNum, pageSize);
|
||||
if (StringUtils.hasText(name)) {
|
||||
criteria.andNameLike('%' + name + '%');
|
||||
}
|
||||
criteria.andSchoolIdEqualTo(currentUser.getSchoolId());
|
||||
|
||||
return new PageInfo<>(trainingLessonPlanMapper.selectByExample(example));
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void deleteById(String id) {
|
||||
TrainingLessonPlan trainingLessonPlan = findById(id);
|
||||
Assert.notNull(trainingLessonPlan, "教案不存在");
|
||||
fileUtil.remove(trainingLessonPlan.getFilePath());
|
||||
trainingLessonPlanMapper.deleteByPrimaryKey(id);
|
||||
}
|
||||
|
||||
|
||||
public TrainingLessonPlan findById(String id) {
|
||||
return trainingLessonPlanMapper.selectByPrimaryKey(id);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue