|
@@ -1,9 +1,11 @@
|
|
package com.example.service.impl;
|
|
package com.example.service.impl;
|
|
|
|
|
|
|
|
+import com.example.constant.MessageConstant;
|
|
import com.example.context.BaseContext;
|
|
import com.example.context.BaseContext;
|
|
import com.example.dto.ThesisDTO;
|
|
import com.example.dto.ThesisDTO;
|
|
import com.example.entity.Awards;
|
|
import com.example.entity.Awards;
|
|
import com.example.entity.Thesis;
|
|
import com.example.entity.Thesis;
|
|
|
|
+import com.example.exception.ThesisNotFoundException;
|
|
import com.example.mapper.ThesisMapper;
|
|
import com.example.mapper.ThesisMapper;
|
|
import com.example.service.ThesisService;
|
|
import com.example.service.ThesisService;
|
|
import com.example.vo.ThesisVO;
|
|
import com.example.vo.ThesisVO;
|
|
@@ -16,11 +18,12 @@ public class ThesisServiceImpl implements ThesisService {
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private ThesisMapper thesisMapper;
|
|
private ThesisMapper thesisMapper;
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public void uploadThesis(ThesisDTO thesisDTO) {
|
|
public void uploadThesis(ThesisDTO thesisDTO) {
|
|
Thesis thesis = new Thesis();
|
|
Thesis thesis = new Thesis();
|
|
BeanUtils.copyProperties(thesisDTO, thesis);
|
|
BeanUtils.copyProperties(thesisDTO, thesis);
|
|
- Long id= BaseContext.getCurrentId();
|
|
|
|
|
|
+ Long id = BaseContext.getCurrentId();
|
|
thesis.setTeacherId(id);
|
|
thesis.setTeacherId(id);
|
|
thesisMapper.uploadThesis(thesis);
|
|
thesisMapper.uploadThesis(thesis);
|
|
thesisMapper.addThesisNum(id);
|
|
thesisMapper.addThesisNum(id);
|
|
@@ -28,17 +31,20 @@ public class ThesisServiceImpl implements ThesisService {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void updateThesis(ThesisDTO thesisDTO, Long id) {
|
|
public void updateThesis(ThesisDTO thesisDTO, Long id) {
|
|
- Thesis thesis=new Thesis();
|
|
|
|
- BeanUtils.copyProperties(thesisDTO,thesis);
|
|
|
|
|
|
+ Thesis thesis = new Thesis();
|
|
|
|
+ BeanUtils.copyProperties(thesisDTO, thesis);
|
|
thesis.setId(id);
|
|
thesis.setId(id);
|
|
thesisMapper.updateThesis(thesis);
|
|
thesisMapper.updateThesis(thesis);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public ThesisVO getById(Long id) {
|
|
public ThesisVO getById(Long id) {
|
|
- ThesisVO thesisVO=new ThesisVO();
|
|
|
|
- Thesis thesis=thesisMapper.getById(id);
|
|
|
|
- BeanUtils.copyProperties(thesis,thesisVO);
|
|
|
|
|
|
+ ThesisVO thesisVO = new ThesisVO();
|
|
|
|
+ Thesis thesis = thesisMapper.getById(id);
|
|
|
|
+ if (thesis == null) {
|
|
|
|
+ throw new ThesisNotFoundException(MessageConstant.THESIS_NOT_FOUND);
|
|
|
|
+ }
|
|
|
|
+ BeanUtils.copyProperties(thesis, thesisVO);
|
|
return thesisVO;
|
|
return thesisVO;
|
|
}
|
|
}
|
|
|
|
|