新增学生提交接口
parent
548d918919
commit
c09ceede8d
@ -0,0 +1,12 @@
|
||||
package com.sztzjy.linkCommerce.service;
|
||||
|
||||
import com.sztzjy.linkCommerce.entity.StuGrade;
|
||||
|
||||
/**
|
||||
* @author 17803
|
||||
* @date 2025-04-25 09:31
|
||||
*/
|
||||
|
||||
public interface ScoreService {
|
||||
void submitScoreCalculation(StuGrade stuGrade);
|
||||
}
|
||||
@ -0,0 +1,70 @@
|
||||
package com.sztzjy.linkCommerce.service.impl;
|
||||
|
||||
import com.sztzjy.linkCommerce.entity.StuGrade;
|
||||
import com.sztzjy.linkCommerce.entity.StuGradeExample;
|
||||
import com.sztzjy.linkCommerce.mapper.StuGradeMapper;
|
||||
import com.sztzjy.linkCommerce.service.ScoreService;
|
||||
import org.checkerframework.checker.units.qual.A;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 17803
|
||||
* @date 2025-04-25 09:31
|
||||
*/
|
||||
@Service
|
||||
public class ScoreServiceImpl implements ScoreService {
|
||||
|
||||
@Autowired
|
||||
private StuGradeMapper stuGradeMapper;
|
||||
|
||||
|
||||
@Override
|
||||
public void submitScoreCalculation(StuGrade stuGrade) {
|
||||
|
||||
StuGradeExample stuGradeExample = new StuGradeExample();
|
||||
stuGradeExample.createCriteria()
|
||||
.andModuleEqualTo(stuGrade.getModule())
|
||||
.andProjectEqualTo(stuGrade.getProject())
|
||||
.andUserIdEqualTo(stuGrade.getUserId())
|
||||
.andSchoolIdEqualTo(stuGrade.getSchoolId())
|
||||
.andSchoolClassIdEqualTo(stuGrade.getSchoolClassId());
|
||||
List<StuGrade> stuGradeList = stuGradeMapper.selectByExampleWithBLOBs(stuGradeExample);
|
||||
|
||||
//首次插入
|
||||
if (CollectionUtils.isEmpty(stuGradeList)) {
|
||||
|
||||
//传过来的得分
|
||||
|
||||
|
||||
|
||||
stuGrade = scoreCalculation(stuGrade);
|
||||
|
||||
|
||||
stuGradeMapper.insertSelective(stuGrade);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public StuGrade scoreCalculation(StuGrade stuGrade) {
|
||||
|
||||
BigDecimal info = stuGrade.getScore();
|
||||
if (info.compareTo(new BigDecimal(0)) < 0) {
|
||||
stuGrade.setScore(BigDecimal.ZERO);
|
||||
}
|
||||
|
||||
if (info.compareTo(new BigDecimal(100)) > 0) {
|
||||
|
||||
stuGrade.setScore(BigDecimal.valueOf(100));
|
||||
}
|
||||
return stuGrade;
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue