|
@@ -11,6 +11,7 @@ import cn.com.qmth.stmms.ms.core.domain.Work;
|
|
|
import cn.com.qmth.stmms.ms.core.repository.*;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.domain.Sort;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
@@ -105,6 +106,7 @@ public class WorkApi {
|
|
|
* @param work
|
|
|
* @return
|
|
|
*/
|
|
|
+ @Transactional
|
|
|
@RequestMapping(value = "{workId}", method = RequestMethod.PUT)
|
|
|
public Work update(@PathVariable Long workId, @RequestBody Work work) {
|
|
|
List<MarkSubject> subjects = markSubjectRepo.findAllByWorkId(workId);
|
|
@@ -113,10 +115,13 @@ public class WorkApi {
|
|
|
// throw new RuntimeException("已有分档数据,不可更改");
|
|
|
// }
|
|
|
|
|
|
+ levelRepo.deleteByWorkId(work.getId());
|
|
|
+
|
|
|
//根据A~Z排序后,重新设置levelValue
|
|
|
List<Level> levels = work.getLevels();
|
|
|
AtomicInteger ai = new AtomicInteger(0);
|
|
|
levels.stream().sorted(Comparator.comparing(Level::getCode)).map(l->{
|
|
|
+ l.setId(null);
|
|
|
l.setLevelValue(ai.getAndIncrement());
|
|
|
return l;
|
|
|
}).collect(Collectors.toList());
|