Commit 5162dcee7df230041563157dc0985274e7df12be
1 parent
1523322c
添加上传作业接口
Showing
6 changed files
with
246 additions
and
6 deletions
resources/mybatis1/sunvote/HomeworkProblemMapper.xml
| @@ -137,8 +137,8 @@ | @@ -137,8 +137,8 @@ | ||
| 137 | from | 137 | from |
| 138 | <include refid="tableName"></include> | 138 | <include refid="tableName"></include> |
| 139 | where 1 = 1 | 139 | where 1 = 1 |
| 140 | - <if test="HOMEWORK_ID != null and HOMEWORK_ID != ''"> | ||
| 141 | - and HOMEWORK_ID = #{HOMEWORK_ID} | 140 | + <if test="CODE != null and CODE != ''"> |
| 141 | + and CODE = #{CODE} | ||
| 142 | </if> | 142 | </if> |
| 143 | <if test="P_HOMEWORK_PROBLEM_ID == null or P_HOMEWORK_PROBLEM_ID == ''"> | 143 | <if test="P_HOMEWORK_PROBLEM_ID == null or P_HOMEWORK_PROBLEM_ID == ''"> |
| 144 | and P_HOMEWORK_PROBLEM_ID is NULL | 144 | and P_HOMEWORK_PROBLEM_ID is NULL |
src/com/fh/bean/HomeClass.java
0 → 100644
| 1 | +package com.fh.bean; | ||
| 2 | + | ||
| 3 | +public class HomeClass { | ||
| 4 | + | ||
| 5 | + private String CLASS_ID; | ||
| 6 | + private String COMPLETE_DATE; | ||
| 7 | + public void setCLASS_ID(String CLASS_ID) { | ||
| 8 | + this.CLASS_ID = CLASS_ID; | ||
| 9 | + } | ||
| 10 | + public String getCLASS_ID() { | ||
| 11 | + return CLASS_ID; | ||
| 12 | + } | ||
| 13 | + | ||
| 14 | + public void setCOMPLETE_DATE(String COMPLETE_DATE) { | ||
| 15 | + this.COMPLETE_DATE = COMPLETE_DATE; | ||
| 16 | + } | ||
| 17 | + public String getCOMPLETE_DATE() { | ||
| 18 | + return COMPLETE_DATE; | ||
| 19 | + } | ||
| 20 | +} |
src/com/fh/bean/Homework.java
0 → 100644
| 1 | +package com.fh.bean; | ||
| 2 | + | ||
| 3 | +import java.util.List; | ||
| 4 | + | ||
| 5 | +import com.google.gson.Gson; | ||
| 6 | + | ||
| 7 | +public class Homework { | ||
| 8 | + | ||
| 9 | + private String CODE; | ||
| 10 | + private String NAME; | ||
| 11 | + private String SUBJECT_ID; | ||
| 12 | + private String ALL_SCORE; | ||
| 13 | + private String HOMEWORK_DESC; | ||
| 14 | + private List<HomeClass> CLASSLIST; | ||
| 15 | + private String QUESTION_COUNT; | ||
| 16 | + private String TEACHER_ID; | ||
| 17 | + private List<HomeworkQuestion> QUESTIOMS; | ||
| 18 | + | ||
| 19 | + public void setCODE(String CODE) { | ||
| 20 | + this.CODE = CODE; | ||
| 21 | + } | ||
| 22 | + | ||
| 23 | + public String getCODE() { | ||
| 24 | + return CODE; | ||
| 25 | + } | ||
| 26 | + | ||
| 27 | + public void setNAME(String NAME) { | ||
| 28 | + this.NAME = NAME; | ||
| 29 | + } | ||
| 30 | + | ||
| 31 | + public String getNAME() { | ||
| 32 | + return NAME; | ||
| 33 | + } | ||
| 34 | + | ||
| 35 | + public void setSUBJECT_ID(String SUBJECT_ID) { | ||
| 36 | + this.SUBJECT_ID = SUBJECT_ID; | ||
| 37 | + } | ||
| 38 | + | ||
| 39 | + public String getSUBJECT_ID() { | ||
| 40 | + return SUBJECT_ID; | ||
| 41 | + } | ||
| 42 | + | ||
| 43 | + public void setALL_SCORE(String ALL_SCORE) { | ||
| 44 | + this.ALL_SCORE = ALL_SCORE; | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | + public String getALL_SCORE() { | ||
| 48 | + return ALL_SCORE; | ||
| 49 | + } | ||
| 50 | + | ||
| 51 | + public void setHOMEWORK_DESC(String HOMEWORK_DESC) { | ||
| 52 | + this.HOMEWORK_DESC = HOMEWORK_DESC; | ||
| 53 | + } | ||
| 54 | + | ||
| 55 | + public String getHOMEWORK_DESC() { | ||
| 56 | + return HOMEWORK_DESC; | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | + public void setCLASSLIST(List<HomeClass> CLASSLIST) { | ||
| 60 | + this.CLASSLIST = CLASSLIST; | ||
| 61 | + } | ||
| 62 | + | ||
| 63 | + public List<HomeClass> getCLASSLIST() { | ||
| 64 | + return CLASSLIST; | ||
| 65 | + } | ||
| 66 | + | ||
| 67 | + public void setQUESTIOM_COUNT(String QUESTIOM_COUNT) { | ||
| 68 | + this.QUESTION_COUNT = QUESTIOM_COUNT; | ||
| 69 | + } | ||
| 70 | + | ||
| 71 | + public String getQUESTION_COUNT() { | ||
| 72 | + return QUESTION_COUNT; | ||
| 73 | + } | ||
| 74 | + | ||
| 75 | + public void setQUESTIOMS(List<HomeworkQuestion> QUESTIOMS) { | ||
| 76 | + this.QUESTIOMS = QUESTIOMS; | ||
| 77 | + } | ||
| 78 | + | ||
| 79 | + public List<HomeworkQuestion> getQUESTIOMS() { | ||
| 80 | + return QUESTIOMS; | ||
| 81 | + } | ||
| 82 | + | ||
| 83 | + | ||
| 84 | + | ||
| 85 | + public String getTEACHER_ID() { | ||
| 86 | + return TEACHER_ID; | ||
| 87 | + } | ||
| 88 | + | ||
| 89 | + public void setTEACHER_ID(String tEACHER_ID) { | ||
| 90 | + TEACHER_ID = tEACHER_ID; | ||
| 91 | + } | ||
| 92 | + | ||
| 93 | + public void setQUESTION_COUNT(String qUESTION_COUNT) { | ||
| 94 | + QUESTION_COUNT = qUESTION_COUNT; | ||
| 95 | + } | ||
| 96 | + | ||
| 97 | + public static Homework parse(String json) { | ||
| 98 | + Gson gson = new Gson(); | ||
| 99 | + return gson.fromJson(json, Homework.class); | ||
| 100 | + } | ||
| 101 | +} |
src/com/fh/bean/HomeworkQuestion.java
0 → 100644
| 1 | +package com.fh.bean; | ||
| 2 | + | ||
| 3 | +public class HomeworkQuestion { | ||
| 4 | + | ||
| 5 | + private String RANK; | ||
| 6 | + private String NAME; | ||
| 7 | + private String OPTION_NUM; | ||
| 8 | + private String SCORE; | ||
| 9 | + private String RIGHT_ANSWER; | ||
| 10 | + private String TYPE; | ||
| 11 | + | ||
| 12 | + public void setRANK(String RANK) { | ||
| 13 | + this.RANK = RANK; | ||
| 14 | + } | ||
| 15 | + | ||
| 16 | + public String getRANK() { | ||
| 17 | + return RANK; | ||
| 18 | + } | ||
| 19 | + | ||
| 20 | + public void setNAME(String NAME) { | ||
| 21 | + this.NAME = NAME; | ||
| 22 | + } | ||
| 23 | + | ||
| 24 | + public String getNAME() { | ||
| 25 | + return NAME; | ||
| 26 | + } | ||
| 27 | + | ||
| 28 | + public void setOPTION_NUM(String OPTION_NUM) { | ||
| 29 | + this.OPTION_NUM = OPTION_NUM; | ||
| 30 | + } | ||
| 31 | + | ||
| 32 | + public String getOPTION_NUM() { | ||
| 33 | + return OPTION_NUM; | ||
| 34 | + } | ||
| 35 | + | ||
| 36 | + public void setSCORE(String SCORE) { | ||
| 37 | + this.SCORE = SCORE; | ||
| 38 | + } | ||
| 39 | + | ||
| 40 | + public String getSCORE() { | ||
| 41 | + return SCORE; | ||
| 42 | + } | ||
| 43 | + | ||
| 44 | + public void setRIGHT_ANSWER(String RIGHT_ANSWER) { | ||
| 45 | + this.RIGHT_ANSWER = RIGHT_ANSWER; | ||
| 46 | + } | ||
| 47 | + | ||
| 48 | + public String getRIGHT_ANSWER() { | ||
| 49 | + return RIGHT_ANSWER; | ||
| 50 | + } | ||
| 51 | + | ||
| 52 | + public void setTYPE(String TYPE) { | ||
| 53 | + this.TYPE = TYPE; | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + public String getTYPE() { | ||
| 57 | + return TYPE; | ||
| 58 | + } | ||
| 59 | + | ||
| 60 | +} |
src/com/fh/controller/api/V1.java
| @@ -2851,6 +2851,7 @@ public class V1 extends BaseController { | @@ -2851,6 +2851,7 @@ public class V1 extends BaseController { | ||
| 2851 | public String homework() throws Exception { | 2851 | public String homework() throws Exception { |
| 2852 | ResponseGson<List<PageData>> res = new ResponseGson<List<PageData>>(); | 2852 | ResponseGson<List<PageData>> res = new ResponseGson<List<PageData>>(); |
| 2853 | PageData pageData = this.getPageData(); | 2853 | PageData pageData = this.getPageData(); |
| 2854 | + pageData.put("CODE", pageData.get("HOMEWORK_ID")); | ||
| 2854 | List<PageData> list = homeworkproblemService.listProblem(pageData); | 2855 | List<PageData> list = homeworkproblemService.listProblem(pageData); |
| 2855 | for(PageData pd : list){ | 2856 | for(PageData pd : list){ |
| 2856 | if(pd.get("P_HOMEWORK_PROBLEM_ID") != null){ | 2857 | if(pd.get("P_HOMEWORK_PROBLEM_ID") != null){ |
src/com/fh/controller/sunvote/homework/HomeworkController.java
| @@ -19,11 +19,15 @@ import org.springframework.web.bind.annotation.RequestMapping; | @@ -19,11 +19,15 @@ import org.springframework.web.bind.annotation.RequestMapping; | ||
| 19 | import org.springframework.web.bind.annotation.ResponseBody; | 19 | import org.springframework.web.bind.annotation.ResponseBody; |
| 20 | import org.springframework.web.servlet.ModelAndView; | 20 | import org.springframework.web.servlet.ModelAndView; |
| 21 | 21 | ||
| 22 | +import com.fh.bean.HomeClass; | ||
| 23 | +import com.fh.bean.Homework; | ||
| 24 | +import com.fh.bean.HomeworkQuestion; | ||
| 22 | import com.fh.controller.api.ResponseGson; | 25 | import com.fh.controller.api.ResponseGson; |
| 23 | import com.fh.controller.base.BaseController; | 26 | import com.fh.controller.base.BaseController; |
| 24 | import com.fh.entity.Page; | 27 | import com.fh.entity.Page; |
| 25 | import com.fh.service.sunvote.homework.HomeworkManager; | 28 | import com.fh.service.sunvote.homework.HomeworkManager; |
| 26 | import com.fh.service.sunvote.homework.HomeworkReportManager; | 29 | import com.fh.service.sunvote.homework.HomeworkReportManager; |
| 30 | +import com.fh.service.sunvote.homeworkproblem.HomeworkProblemManager; | ||
| 27 | import com.fh.util.AppUtil; | 31 | import com.fh.util.AppUtil; |
| 28 | import com.fh.util.Jurisdiction; | 32 | import com.fh.util.Jurisdiction; |
| 29 | import com.fh.util.ObjectExcelView; | 33 | import com.fh.util.ObjectExcelView; |
| @@ -42,6 +46,9 @@ public class HomeworkController extends BaseController { | @@ -42,6 +46,9 @@ public class HomeworkController extends BaseController { | ||
| 42 | private HomeworkManager homeworkService; | 46 | private HomeworkManager homeworkService; |
| 43 | @Resource(name = "homeworkReporService") | 47 | @Resource(name = "homeworkReporService") |
| 44 | private HomeworkReportManager homeworkReporService; | 48 | private HomeworkReportManager homeworkReporService; |
| 49 | + | ||
| 50 | + @Resource(name="homeworkproblemService") | ||
| 51 | + private HomeworkProblemManager homeworkproblemService; | ||
| 45 | 52 | ||
| 46 | /** | 53 | /** |
| 47 | * 保存 | 54 | * 保存 |
| @@ -155,6 +162,7 @@ public class HomeworkController extends BaseController { | @@ -155,6 +162,7 @@ public class HomeworkController extends BaseController { | ||
| 155 | mv.addObject("pd", pd); | 162 | mv.addObject("pd", pd); |
| 156 | return mv; | 163 | return mv; |
| 157 | } | 164 | } |
| 165 | + | ||
| 158 | /** | 166 | /** |
| 159 | * 去修改页面 | 167 | * 去修改页面 |
| 160 | * | 168 | * |
| @@ -278,7 +286,7 @@ public class HomeworkController extends BaseController { | @@ -278,7 +286,7 @@ public class HomeworkController extends BaseController { | ||
| 278 | Gson gson = new Gson(); | 286 | Gson gson = new Gson(); |
| 279 | return gson.toJson(pd); | 287 | return gson.toJson(pd); |
| 280 | } | 288 | } |
| 281 | - | 289 | + |
| 282 | /** | 290 | /** |
| 283 | * 列表 | 291 | * 列表 |
| 284 | * | 292 | * |
| @@ -299,15 +307,65 @@ public class HomeworkController extends BaseController { | @@ -299,15 +307,65 @@ public class HomeworkController extends BaseController { | ||
| 299 | Gson gson = new Gson(); | 307 | Gson gson = new Gson(); |
| 300 | return gson.toJson(varList); | 308 | return gson.toJson(varList); |
| 301 | } | 309 | } |
| 302 | - | ||
| 303 | - @RequestMapping(value = "/savedata") | 310 | + |
| 311 | + @RequestMapping(value = "/savedata", produces = "application/json;charset=UTF-8") | ||
| 312 | + @ResponseBody | ||
| 304 | public String savedata() throws Exception { | 313 | public String savedata() throws Exception { |
| 305 | PageData pd = new PageData(); | 314 | PageData pd = new PageData(); |
| 306 | pd = this.getPageData(); | 315 | pd = this.getPageData(); |
| 307 | - pd.put("HOMEWORK_ID", this.get32UUID()); // 主键 | 316 | + pd.put("HOMEWORK_ID", this.get32UUID()); |
| 308 | homeworkService.save(pd); | 317 | homeworkService.save(pd); |
| 309 | ResponseGson<String> responseGson = new ResponseGson<String>(); | 318 | ResponseGson<String> responseGson = new ResponseGson<String>(); |
| 310 | responseGson.setData(pd.getString("HOMEWORK_ID")); | 319 | responseGson.setData(pd.getString("HOMEWORK_ID")); |
| 311 | return responseGson.toJson(); | 320 | return responseGson.toJson(); |
| 312 | } | 321 | } |
| 322 | + | ||
| 323 | + @RequestMapping(value = "/uploadHomework", produces = "application/json;charset=UTF-8") | ||
| 324 | + @ResponseBody | ||
| 325 | + public String uploadHomework() throws Exception { | ||
| 326 | + PageData pd = new PageData(); | ||
| 327 | + pd = this.getPageData(); | ||
| 328 | + DateFormat format = new SimpleDateFormat("yyyy-MM-dd"); | ||
| 329 | + String data = pd.getJsonString(); | ||
| 330 | + ResponseGson<String> responseGson = new ResponseGson<String>(); | ||
| 331 | + | ||
| 332 | + Homework homework = Homework.parse(data); | ||
| 333 | + | ||
| 334 | + PageData hpd = new PageData(); | ||
| 335 | + hpd.put("CODE", get32UUID()); | ||
| 336 | + hpd.put("NAME", homework.getNAME()); | ||
| 337 | + hpd.put("SUBJECT_ID", homework.getSUBJECT_ID()); | ||
| 338 | + hpd.put("ALL_SCORE", homework.getALL_SCORE()); | ||
| 339 | + hpd.put("HOMEWORK_DESC", homework.getHOMEWORK_DESC()); | ||
| 340 | + hpd.put("QUESTION_COUNT", homework.getQUESTION_COUNT()); | ||
| 341 | + hpd.put("CREATE_DATE", format.format(new Date())); | ||
| 342 | + hpd.put("MODIFY_DATE", format.format(new Date())); | ||
| 343 | + hpd.put("COMPLETE_COUNT", 0); | ||
| 344 | + hpd.put("TEACHER_ID", homework.getTEACHER_ID()); | ||
| 345 | + hpd.put("COMPLETE_DESC", ""); | ||
| 346 | + | ||
| 347 | + for(HomeClass homeclass : homework.getCLASSLIST()){ | ||
| 348 | + hpd.put("CLASS_ID", homeclass.getCLASS_ID()); | ||
| 349 | + hpd.put("COMPLETE_DATE", homeclass.getCOMPLETE_DATE()); | ||
| 350 | + hpd.put("HOMEWORK_ID", this.get32UUID()); | ||
| 351 | + homeworkService.save(hpd); | ||
| 352 | + } | ||
| 353 | + | ||
| 354 | + for(HomeworkQuestion homeworkQuestion:homework.getQUESTIOMS()){ | ||
| 355 | + PageData qpd = new PageData(); | ||
| 356 | + qpd.put("RANK", homeworkQuestion.getRANK()); | ||
| 357 | + qpd.put("CODE", hpd.get("CODE")); | ||
| 358 | + qpd.put("NAME", homeworkQuestion.getNAME()); | ||
| 359 | + qpd.put("OPTION_NUM", homeworkQuestion.getOPTION_NUM()); | ||
| 360 | + qpd.put("SCORE", homeworkQuestion.getSCORE()); | ||
| 361 | + qpd.put("RIGHT_ANSWER", homeworkQuestion.getRIGHT_ANSWER()); | ||
| 362 | + qpd.put("TYPE", homeworkQuestion.getTYPE()); | ||
| 363 | + qpd.put("HOMEWORKPROBLEM_ID", this.get32UUID()); | ||
| 364 | + qpd.put("HOMEWORK_ID", hpd.get("CODE")); | ||
| 365 | + homeworkproblemService.save(qpd); | ||
| 366 | + } | ||
| 367 | + | ||
| 368 | + responseGson.setData(pd.getString("CODE")); | ||
| 369 | + return responseGson.toJson(); | ||
| 370 | + } | ||
| 313 | } | 371 | } |