Commit e82c0cbc authored by Ryan Loong's avatar Ryan Loong

修改增加点名次数的逻辑

parent cc033ddf
...@@ -99,12 +99,16 @@ public class StudentInfoService { ...@@ -99,12 +99,16 @@ public class StudentInfoService {
* @param classId * @param classId
* @return * @return
*/ */
@Transactional(rollbackFor = Exception.class)
public StudentVo selectStudentInfo(Integer classId, Integer maxCall) { public StudentVo selectStudentInfo(Integer classId, Integer maxCall) {
return beanSearcher.searchFirst(StudentVo.class, MapUtils.builder() StudentVo record = beanSearcher.searchFirst(StudentVo.class, MapUtils.builder()
.field(StudentVo::getDeleted, StudentInfo.NOT_DELETED).op(Equal.class) .field(StudentVo::getDeleted, StudentInfo.NOT_DELETED).op(Equal.class)
.field(StudentVo::getClassId, classId).op(Equal.class) .field(StudentVo::getClassId, classId).op(Equal.class)
.field(StudentVo::getCallTimes, maxCall).op(LessThan.class) .field(StudentVo::getCallTimes, maxCall).op(LessThan.class)
.build()); .build());
increaseCallTime(record);
return record;
} }
/** /**
...@@ -396,12 +400,17 @@ public class StudentInfoService { ...@@ -396,12 +400,17 @@ public class StudentInfoService {
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void increaseCallTimeByPrimaryKey(Integer id) { public void increaseCallTimeByPrimaryKey(Integer id) {
StudentInfo studentInfo = selectByPrimaryKey(id); increaseCallTime(studentInfoMapper.selectByPrimaryKey(id));
}
@Transactional(rollbackFor = Exception.class)
public void increaseCallTime(StudentInfo studentInfo) {
Integer callTimes = studentInfo.getCallTimes(); Integer callTimes = studentInfo.getCallTimes();
studentInfo.setCallTimes(callTimes + 1); studentInfo.setCallTimes(callTimes + 1);
studentInfo.setUpdateTime(LocalDateTime.now()); studentInfo.setUpdateTime(LocalDateTime.now());
int i = studentInfoMapper.updateByExampleSelective(studentInfo, int i = studentInfoMapper.updateByExampleSelective(studentInfo,
new StudentInfoExample().createCriteria().andDeletedEqualTo(StudentInfo.NOT_DELETED).andIdEqualTo(id).andCallTimesEqualTo(callTimes).example(), new StudentInfoExample().createCriteria().andDeletedEqualTo(StudentInfo.NOT_DELETED).andIdEqualTo(studentInfo.getId()).andCallTimesEqualTo(callTimes).example(),
StudentInfo.Column.updateTime, StudentInfo.Column.callTimes); StudentInfo.Column.updateTime, StudentInfo.Column.callTimes);
if (i <= 0) { if (i <= 0) {
throw new RuntimeException("更新点名次数失败"); throw new RuntimeException("更新点名次数失败");
......
...@@ -104,8 +104,6 @@ public class StudentPointService { ...@@ -104,8 +104,6 @@ public class StudentPointService {
studentPoint.setAddTime(now); studentPoint.setAddTime(now);
studentPoint.setDeleted(false); studentPoint.setDeleted(false);
studentPointInfoMapper.insert(studentPoint); studentPointInfoMapper.insert(studentPoint);
studentInfoService.increaseCallTimeByPrimaryKey(studentPoint.getStudentId());
return "add OK"; return "add OK";
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment