|
@@ -3,10 +3,11 @@ package com.xhkjedu.sstudy.service.subjectbook;
|
3
|
3
|
import com.xhkjedu.sstudy.mapper.subjectbook.PointMapper;
|
4
|
4
|
import com.xhkjedu.sstudy.model.subjectbook.TPoint;
|
5
|
5
|
import com.xhkjedu.sstudy.utils.StudyUtil;
|
6
|
|
-import com.xhkjedu.utils.N_Utils;
|
7
|
6
|
import com.xhkjedu.sstudy.vo.subjectbook.PointVo;
|
|
7
|
+import com.xhkjedu.utils.N_Utils;
|
8
|
8
|
import org.springframework.beans.factory.annotation.Autowired;
|
9
|
9
|
import org.springframework.stereotype.Service;
|
|
10
|
+import org.springframework.transaction.annotation.Transactional;
|
10
|
11
|
|
11
|
12
|
import java.util.ArrayList;
|
12
|
13
|
import java.util.List;
|
|
@@ -35,7 +36,18 @@ public class PointService {
|
35
|
36
|
if ("".equals(point.getPointpid())) {
|
36
|
37
|
point.setPointpid(null);
|
37
|
38
|
}
|
|
39
|
+
|
38
|
40
|
point.setCreatetime(N_Utils.getSecondTimestamp());
|
|
41
|
+
|
|
42
|
+ if (N_Utils.isEmpty(point.getPointpid())) {
|
|
43
|
+ //说明是1级知识点
|
|
44
|
+ point.setPointall(point.getPointname());
|
|
45
|
+ }else{
|
|
46
|
+ //非1级知识点,获取该父知识点的pointall字段值
|
|
47
|
+ String pointall = pointMapper.getPointallByPointid(point.getPointpid());
|
|
48
|
+ point.setPointall(pointall + ";" + point.getPointname());
|
|
49
|
+ }
|
|
50
|
+
|
39
|
51
|
return pointMapper.insertSelective(point);
|
40
|
52
|
}
|
41
|
53
|
|
|
@@ -46,7 +58,18 @@ public class PointService {
|
46
|
58
|
* @param * @param point
|
47
|
59
|
* @return java.lang.Integer
|
48
|
60
|
*/
|
|
61
|
+ @Transactional(rollbackFor = Exception.class)
|
49
|
62
|
public Integer updatePoint(TPoint point){
|
|
63
|
+ TPoint oldPoint = pointMapper.selectByPrimaryKey(point.getPointid());
|
|
64
|
+ if(oldPoint.getPointlevel() == 1){
|
|
65
|
+ //说明第一层
|
|
66
|
+ point.setPointall(point.getPointname());
|
|
67
|
+ }else{
|
|
68
|
+ //设置本层pointall字段
|
|
69
|
+ String pointall = oldPoint.getPointall().replaceAll(oldPoint.getPointname(),point.getPointname());
|
|
70
|
+ point.setPointall(pointall);
|
|
71
|
+ }
|
|
72
|
+ pointMapper.updatePointAll(point.getPointid(),point.getPointall(),oldPoint.getPointlevel());
|
50
|
73
|
point.setCreatetime(N_Utils.getSecondTimestamp());
|
51
|
74
|
return pointMapper.updateByPrimaryKeySelective(point);
|
52
|
75
|
}
|