|
@@ -4,6 +4,7 @@ import com.xhkjedu.sstudy.listener.MessageSender;
|
4
|
4
|
import com.xhkjedu.sstudy.mapper.gradeclass.ClassMapper;
|
5
|
5
|
import com.xhkjedu.sstudy.mapper.resource.*;
|
6
|
6
|
import com.xhkjedu.sstudy.mapper.subjectbook.SubjectMapper;
|
|
7
|
+import com.xhkjedu.sstudy.mapper.subjectbook.TeacherSubjectbookMapper;
|
7
|
8
|
import com.xhkjedu.sstudy.mapper.system.SchoolMapper;
|
8
|
9
|
import com.xhkjedu.sstudy.model.resource.*;
|
9
|
10
|
import com.xhkjedu.sstudy.utils.ConvertUtil;
|
|
@@ -55,6 +56,8 @@ public class GuideService {
|
55
|
56
|
private MessageSender messageSender;
|
56
|
57
|
@Autowired
|
57
|
58
|
private ConvertUtil convertUtil;
|
|
59
|
+ @Resource
|
|
60
|
+ private TeacherSubjectbookMapper teacherSubjectbookMapper;
|
58
|
61
|
|
59
|
62
|
//学生预习列表--教师网页端
|
60
|
63
|
public List<GuideVo> listGuidesForTeacherWeb(TGuide guide){
|
|
@@ -95,57 +98,62 @@ public class GuideService {
|
95
|
98
|
//保存学生预习
|
96
|
99
|
@Transactional(rollbackFor = Exception.class)
|
97
|
100
|
public ResultVo save(TGuide guide){
|
98
|
|
-
|
99
|
101
|
try {
|
100
|
|
- Integer timestamp = N_Utils.getSecondTimestamp();
|
101
|
|
- guide.setCreatetime(timestamp);
|
102
|
|
- Integer hashb = 0;
|
103
|
|
- if (N_Utils.isListNotEmpty(guide.getJtrclist())) {
|
104
|
|
- hashb = 1;
|
105
|
|
- }
|
106
|
|
- guide.setHashb(hashb);
|
107
|
|
- int year = schoolMapper.getYearById(guide.getSchoolid());
|
108
|
|
- guide.setYear(year);
|
109
|
|
- guideMapper.insertUseGeneratedKeys(guide);
|
110
|
|
- Integer guideid = guide.getId();//预习id
|
111
|
|
- guide.setGuideid(guideid);
|
112
|
|
-
|
113
|
|
- //保存资源
|
114
|
|
- List<TResource> resources = guide.getResources();
|
115
|
|
- for(TResource r : resources) {
|
116
|
|
- r.setCreateid(guide.getCreateid());
|
117
|
|
- r.setCreatetime(guide.getCreatetime());
|
118
|
|
- r.setLevel(3);
|
119
|
|
- r.setResourcestate(1);
|
120
|
|
- r.setResourcetype(10);
|
121
|
|
- r.setBelong(4);
|
122
|
|
- r.setSchoolid(guide.getSchoolid());
|
123
|
|
- r.setSubjectid(guide.getSubjectid());
|
124
|
|
-
|
125
|
|
- String resourceid = StudyUtil.getId();//资源id
|
126
|
|
- r.setResourceid(resourceid);
|
127
|
|
- Integer resourceclass = r.getResourceclass();
|
128
|
|
- if (resourceclass == 3 || resourceclass == 4 || resourceclass == 6) {
|
129
|
|
- r.setConverted(1);
|
130
|
|
- } else if (resourceclass == 5 && ("flv".equals(r.getSuffix()) || "h264".equals(r.getMp4code()))) {
|
131
|
|
- r.setConverted(1);
|
|
102
|
+ //根据用户id获取用户权限科目,如果上传科目和权限科目不一致,不允许保存
|
|
103
|
+ String subjectid = teacherSubjectbookMapper.listSubjectidByTeacherid(guide.getCreateid());
|
|
104
|
+ if(!subjectid.equals(guide.getSubjectid())){
|
|
105
|
+ return new ResultVo(1,"保存失败");
|
|
106
|
+ }else{
|
|
107
|
+ Integer timestamp = N_Utils.getSecondTimestamp();
|
|
108
|
+ guide.setCreatetime(timestamp);
|
|
109
|
+ Integer hashb = 0;
|
|
110
|
+ if (N_Utils.isListNotEmpty(guide.getJtrclist())) {
|
|
111
|
+ hashb = 1;
|
|
112
|
+ }
|
|
113
|
+ guide.setHashb(hashb);
|
|
114
|
+ int year = schoolMapper.getYearById(guide.getSchoolid());
|
|
115
|
+ guide.setYear(year);
|
|
116
|
+ guideMapper.insertUseGeneratedKeys(guide);
|
|
117
|
+ Integer guideid = guide.getId();//预习id
|
|
118
|
+ guide.setGuideid(guideid);
|
|
119
|
+
|
|
120
|
+ //保存资源
|
|
121
|
+ List<TResource> resources = guide.getResources();
|
|
122
|
+ for(TResource r : resources) {
|
|
123
|
+ r.setCreateid(guide.getCreateid());
|
|
124
|
+ r.setCreatetime(guide.getCreatetime());
|
|
125
|
+ r.setLevel(3);
|
|
126
|
+ r.setResourcestate(1);
|
|
127
|
+ r.setResourcetype(10);
|
|
128
|
+ r.setBelong(4);
|
|
129
|
+ r.setSchoolid(guide.getSchoolid());
|
|
130
|
+ r.setSubjectid(guide.getSubjectid());
|
|
131
|
+
|
|
132
|
+ String resourceid = StudyUtil.getId();//资源id
|
|
133
|
+ r.setResourceid(resourceid);
|
|
134
|
+ Integer resourceclass = r.getResourceclass();
|
|
135
|
+ if (resourceclass == 3 || resourceclass == 4 || resourceclass == 6) {
|
|
136
|
+ r.setConverted(1);
|
|
137
|
+ } else if (resourceclass == 5 && ("flv".equals(r.getSuffix()) || "h264".equals(r.getMp4code()))) {
|
|
138
|
+ r.setConverted(1);
|
|
139
|
+ }
|
|
140
|
+ //保存资源信息
|
|
141
|
+ resourceMapper.insertSelective(r);
|
|
142
|
+ //保存预习资源关联关系
|
|
143
|
+ TGuideResource gr = new TGuideResource();
|
|
144
|
+ gr.setGuideid(guideid);
|
|
145
|
+ gr.setResourceid(resourceid);
|
|
146
|
+ gr.setCreateid(guide.getCreateid());
|
|
147
|
+ gr.setCreatetime(guide.getCreatetime());
|
|
148
|
+ guideResourceMapper.insertUseGeneratedKeys(gr);
|
|
149
|
+
|
|
150
|
+ convertUtil.convertResource(r);//资源转换(word或ppt转为pdf,视频非h264编码转码,压缩包解压)
|
132
|
151
|
}
|
133
|
|
- //保存资源信息
|
134
|
|
- resourceMapper.insertSelective(r);
|
135
|
|
- //保存预习资源关联关系
|
136
|
|
- TGuideResource gr = new TGuideResource();
|
137
|
|
- gr.setGuideid(guideid);
|
138
|
|
- gr.setResourceid(resourceid);
|
139
|
|
- gr.setCreateid(guide.getCreateid());
|
140
|
|
- gr.setCreatetime(guide.getCreatetime());
|
141
|
|
- guideResourceMapper.insertUseGeneratedKeys(gr);
|
142
|
|
-
|
143
|
|
- convertUtil.convertResource(r);//资源转换(word或ppt转为pdf,视频非h264编码转码,压缩包解压)
|
144
|
|
- }
|
145
|
152
|
|
146
|
|
- //保存预习学生关联信息
|
147
|
|
- batchSaveGuideStudent(guide);
|
148
|
|
- return new ResultVo(0,"保存成功");
|
|
153
|
+ //保存预习学生关联信息
|
|
154
|
+ batchSaveGuideStudent(guide);
|
|
155
|
+ return new ResultVo(0,"保存成功");
|
|
156
|
+ }
|
149
|
157
|
}catch (Exception e){
|
150
|
158
|
log.error("保存预习失败:" + e.getMessage());
|
151
|
159
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
@@ -159,29 +167,35 @@ public class GuideService {
|
159
|
167
|
public ResultVo shareGuide(TGuide guide){
|
160
|
168
|
|
161
|
169
|
try {
|
162
|
|
- String resourceid = guide.getResourceid();
|
163
|
|
- Integer timestamp = N_Utils.getSecondTimestamp();
|
164
|
|
- guide.setCreatetime(timestamp);
|
165
|
|
- Integer hashb = 0;
|
166
|
|
- if (N_Utils.isListNotEmpty(guide.getJtrclist())) {
|
167
|
|
- hashb = 1;
|
|
170
|
+ //根据用户id获取用户权限科目,如果上传科目和权限科目不一致,不允许保存
|
|
171
|
+ String subjectid = teacherSubjectbookMapper.listSubjectidByTeacherid(guide.getCreateid());
|
|
172
|
+ if(!subjectid.equals(guide.getSubjectid())){
|
|
173
|
+ return new ResultVo(1,"分享失败");
|
|
174
|
+ }else{
|
|
175
|
+ String resourceid = guide.getResourceid();
|
|
176
|
+ Integer timestamp = N_Utils.getSecondTimestamp();
|
|
177
|
+ guide.setCreatetime(timestamp);
|
|
178
|
+ Integer hashb = 0;
|
|
179
|
+ if (N_Utils.isListNotEmpty(guide.getJtrclist())) {
|
|
180
|
+ hashb = 1;
|
|
181
|
+ }
|
|
182
|
+ guide.setHashb(hashb);
|
|
183
|
+ guideMapper.insertUseGeneratedKeys(guide);
|
|
184
|
+ Integer guideid = guide.getId();//预习id
|
|
185
|
+
|
|
186
|
+ //保存预习资源
|
|
187
|
+ TGuideResource guideResource = new TGuideResource();
|
|
188
|
+ guideResource.setGuideid(guideid);
|
|
189
|
+ guideResource.setResourceid(resourceid);
|
|
190
|
+ guideResource.setCreateid(guide.getCreateid());
|
|
191
|
+ guideResource.setCreatetime(timestamp);
|
|
192
|
+ guideResourceMapper.insert(guideResource);
|
|
193
|
+ guide.setGuideid(guideid);
|
|
194
|
+
|
|
195
|
+ //保存预习学生关联信息
|
|
196
|
+ batchSaveGuideStudent(guide);
|
|
197
|
+ return new ResultVo(0,"分享成功");
|
168
|
198
|
}
|
169
|
|
- guide.setHashb(hashb);
|
170
|
|
- guideMapper.insertUseGeneratedKeys(guide);
|
171
|
|
- Integer guideid = guide.getId();//预习id
|
172
|
|
-
|
173
|
|
- //保存预习资源
|
174
|
|
- TGuideResource guideResource = new TGuideResource();
|
175
|
|
- guideResource.setGuideid(guideid);
|
176
|
|
- guideResource.setResourceid(resourceid);
|
177
|
|
- guideResource.setCreateid(guide.getCreateid());
|
178
|
|
- guideResource.setCreatetime(timestamp);
|
179
|
|
- guideResourceMapper.insert(guideResource);
|
180
|
|
- guide.setGuideid(guideid);
|
181
|
|
-
|
182
|
|
- //保存预习学生关联信息
|
183
|
|
- batchSaveGuideStudent(guide);
|
184
|
|
- return new ResultVo(0,"分享成功");
|
185
|
199
|
}catch (Exception e){
|
186
|
200
|
log.error("分享预习失败:" + e.getMessage());
|
187
|
201
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|