|
|
|
@ -4,10 +4,7 @@ import cn.hutool.core.lang.UUID;
|
|
|
|
|
import cn.teammodel.common.ErrorCode;
|
|
|
|
|
import cn.teammodel.common.PK;
|
|
|
|
|
import cn.teammodel.config.exception.ServiceException;
|
|
|
|
|
import cn.teammodel.model.dto.weekDuty.DeleteDutyNodeDto;
|
|
|
|
|
import cn.teammodel.model.dto.weekDuty.DutyVoteDto;
|
|
|
|
|
import cn.teammodel.model.dto.weekDuty.InsertDutyNodeDto;
|
|
|
|
|
import cn.teammodel.model.dto.weekDuty.UpdateDutyNodeDto;
|
|
|
|
|
import cn.teammodel.model.dto.weekDuty.*;
|
|
|
|
|
import cn.teammodel.model.entity.User;
|
|
|
|
|
import cn.teammodel.model.entity.school.ClassInfo;
|
|
|
|
|
import cn.teammodel.model.entity.school.School;
|
|
|
|
@ -76,7 +73,8 @@ public class DutyServiceImpl implements DutyService {
|
|
|
|
|
String pid = insertDutyNodeDto.getPid();
|
|
|
|
|
String name = insertDutyNodeDto.getName();
|
|
|
|
|
Integer order = insertDutyNodeDto.getOrder();
|
|
|
|
|
Integer score = insertDutyNodeDto.getScore();
|
|
|
|
|
Boolean positive = insertDutyNodeDto.getPositive();
|
|
|
|
|
Integer score = positive ? insertDutyNodeDto.getScore() : -insertDutyNodeDto.getScore();
|
|
|
|
|
String desc = insertDutyNodeDto.getDesc();
|
|
|
|
|
|
|
|
|
|
User user = SecurityUtil.getLoginUser();
|
|
|
|
@ -115,7 +113,7 @@ public class DutyServiceImpl implements DutyService {
|
|
|
|
|
newNode.setDesc(desc);
|
|
|
|
|
newNode.setPath(path);
|
|
|
|
|
newNode.setScore(score);
|
|
|
|
|
newNode.setPositive(score >= 0);
|
|
|
|
|
newNode.setPositive(positive);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -273,6 +271,38 @@ public class DutyServiceImpl implements DutyService {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<WeekDuty.DutySpot> insertSpot(InsertSpotDto insertSpotDto) {
|
|
|
|
|
String schoolId = SecurityUtil.getLoginUser().getSchoolId();
|
|
|
|
|
WeekDuty duty = dutyRepository.findBySchoolIdAndCode(schoolId, PK.WEEK_DUTY);
|
|
|
|
|
if (duty == null) {
|
|
|
|
|
throw new ServiceException("值周树不存在");
|
|
|
|
|
}
|
|
|
|
|
String name = insertSpotDto.getName();
|
|
|
|
|
CosmosPatchOperations operations = CosmosPatchOperations.create().add("/spots/-", new WeekDuty.DutySpot(UUID.randomUUID().toString(), name));
|
|
|
|
|
duty = dutyRepository.save(
|
|
|
|
|
duty.getId(),
|
|
|
|
|
PK.of(PK.WEEK_DUTY),
|
|
|
|
|
WeekDuty.class,
|
|
|
|
|
operations
|
|
|
|
|
);
|
|
|
|
|
return duty.getSpots();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<WeekDuty.DutySpot> deleteSpot(String id) {
|
|
|
|
|
String schoolId = SecurityUtil.getLoginUser().getSchoolId();
|
|
|
|
|
WeekDuty duty = dutyRepository.findBySchoolIdAndCode(schoolId, PK.WEEK_DUTY);
|
|
|
|
|
if (duty == null) {
|
|
|
|
|
throw new ServiceException("值周树不存在");
|
|
|
|
|
}
|
|
|
|
|
List<WeekDuty.DutySpot> spots = duty.getSpots();
|
|
|
|
|
WeekDuty.DutySpot spot = spots.stream().filter(x -> id.equals(x.getId())).findFirst().orElseThrow(() -> new ServiceException("值周评价地点不存在"));
|
|
|
|
|
spots.remove(spot);
|
|
|
|
|
duty = dutyRepository.save(duty);
|
|
|
|
|
return duty.getSpots();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 刷新值周树和 spots 的 id
|
|
|
|
|
*/
|
|
|
|
|