|
@@ -1,21 +1,32 @@
|
|
|
package cn.iselab.mooctest.site.rpc.Oauth2.impl;
|
|
package cn.iselab.mooctest.site.rpc.Oauth2.impl;
|
|
|
|
|
|
|
|
|
|
+import cn.iselab.mooctest.site.dao.OpenId2UserIdDao;
|
|
|
|
|
+import cn.iselab.mooctest.site.models.AssignedTask;
|
|
|
|
|
+import cn.iselab.mooctest.site.models.OpenId2UserId;
|
|
|
|
|
+import cn.iselab.mooctest.site.models.Task;
|
|
|
import cn.iselab.mooctest.site.rpc.oauth2.api.UserService;
|
|
import cn.iselab.mooctest.site.rpc.oauth2.api.UserService;
|
|
|
|
|
+import cn.iselab.mooctest.site.rpc.oauth2.data.CaseDetailDTO;
|
|
|
|
|
+import cn.iselab.mooctest.site.rpc.oauth2.data.ScoreDetails;
|
|
|
|
|
+import cn.iselab.mooctest.site.rpc.oauth2.data.TaskResultDTO;
|
|
|
import cn.iselab.mooctest.site.rpc.oauth2.data.UserDTO;
|
|
import cn.iselab.mooctest.site.rpc.oauth2.data.UserDTO;
|
|
|
|
|
+import cn.iselab.mooctest.site.service.AssignedTaskService;
|
|
|
|
|
+import cn.iselab.mooctest.site.service.ExamService;
|
|
|
import cn.iselab.mooctest.site.service.GroupService;
|
|
import cn.iselab.mooctest.site.service.GroupService;
|
|
|
import cn.iselab.mooctest.site.web.data.UserVO;
|
|
import cn.iselab.mooctest.site.web.data.UserVO;
|
|
|
import cn.iselab.mooctest.site.web.logic.UserLogic;
|
|
import cn.iselab.mooctest.site.web.logic.UserLogic;
|
|
|
import com.alibaba.dubbo.config.annotation.Service;
|
|
import com.alibaba.dubbo.config.annotation.Service;
|
|
|
|
|
+import org.json.JSONArray;
|
|
|
|
|
+import org.json.JSONObject;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
|
|
import java.sql.Timestamp;
|
|
import java.sql.Timestamp;
|
|
|
-import java.util.ArrayList;
|
|
|
|
|
|
|
+import java.util.HashMap;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* Created by csc on 2017/8/11.
|
|
* Created by csc on 2017/8/11.
|
|
|
*/
|
|
*/
|
|
|
-@Service(version = "1.0.7")
|
|
|
|
|
|
|
+@Service(version = "1.0.12")
|
|
|
@Component
|
|
@Component
|
|
|
public class Oauth2ServiceImpl implements UserService{
|
|
public class Oauth2ServiceImpl implements UserService{
|
|
|
|
|
|
|
@@ -25,6 +36,15 @@ public class Oauth2ServiceImpl implements UserService{
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private GroupService groupService;
|
|
private GroupService groupService;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private ExamService examService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private AssignedTaskService assignedTaskService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private OpenId2UserIdDao openId2UserIdDao;
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public UserDTO registerNewUser(String s, String s1, String s2, String s3, String s4) {
|
|
public UserDTO registerNewUser(String s, String s1, String s2, String s3, String s4) {
|
|
|
UserVO userVO = new UserVO();
|
|
UserVO userVO = new UserVO();
|
|
@@ -48,4 +68,58 @@ public class Oauth2ServiceImpl implements UserService{
|
|
|
public void joinGroup(long l, long l1) {
|
|
public void joinGroup(long l, long l1) {
|
|
|
groupService.addUserIntoGroupForOauth2(l,l1);
|
|
groupService.addUserIntoGroupForOauth2(l,l1);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public UserDTO getUserById(long l) {
|
|
|
|
|
+ UserDTO result = new UserDTO();
|
|
|
|
|
+ UserVO userVO = userLogic.findUserById(l);
|
|
|
|
|
+ result.setName(userVO.getName());
|
|
|
|
|
+ result.setMobile(userVO.getMobile());
|
|
|
|
|
+ result.setEmail(userVO.getEmail());
|
|
|
|
|
+ result.setSchool(userVO.getSchool());
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public boolean saveTaskResult(TaskResultDTO taskResultDTO) {
|
|
|
|
|
+ long taskId = taskResultDTO.getTask_id();
|
|
|
|
|
+ HashMap<Long, String> caseNameMap = taskResultDTO.getTask_case_list();
|
|
|
|
|
+ AssignedTask assignedTask;
|
|
|
|
|
+ Task task;
|
|
|
|
|
+ long participantId;
|
|
|
|
|
+ for(ScoreDetails scoreDetails: taskResultDTO.getScoreDetails()) {
|
|
|
|
|
+
|
|
|
|
|
+ OpenId2UserId openId2UserId = openId2UserIdDao.findByOpenId(scoreDetails.getOpen_id());
|
|
|
|
|
+ participantId = openId2UserId.getUserId();
|
|
|
|
|
+ task = examService.getExamByIdAndParticipantIdIfPermited(taskId, openId2UserId.getUserId());
|
|
|
|
|
+ assignedTask = new AssignedTask();
|
|
|
|
|
+ assignedTask.setWorkerId(participantId);
|
|
|
|
|
+ assignedTask.setName(task.getName());
|
|
|
|
|
+ assignedTask.setTaskId(task.getId());
|
|
|
|
|
+ assignedTask.setManagerId(task.getManagerId());
|
|
|
|
|
+ assignedTask.setContent("");
|
|
|
|
|
+ assignedTask.setScore(0.0);
|
|
|
|
|
+ assignedTask.setOwnerId(task.getOwnerId());
|
|
|
|
|
+ assignedTask.setParticipantId(participantId);
|
|
|
|
|
+
|
|
|
|
|
+ JSONObject assignedResults = new JSONObject();
|
|
|
|
|
+ JSONObject assignedResultObj = new JSONObject();
|
|
|
|
|
+
|
|
|
|
|
+ for(CaseDetailDTO caseDetailDTO: scoreDetails.getDetail()) {
|
|
|
|
|
+ JSONObject caseDetail = new JSONObject();
|
|
|
|
|
+ caseDetail.put("id", caseDetailDTO.getCase_id());
|
|
|
|
|
+ caseDetail.put("maxScore", caseDetailDTO.getScore());
|
|
|
|
|
+ JSONArray scores = new JSONArray();
|
|
|
|
|
+ scores.put(caseDetailDTO.getScore());
|
|
|
|
|
+ caseDetail.put("scores", scores);
|
|
|
|
|
+ caseDetail.put("name", caseNameMap.get(caseDetailDTO.getCase_id()));
|
|
|
|
|
+ caseDetail.put("resultUrls", new JSONArray());
|
|
|
|
|
+ assignedResults.put(String.valueOf(caseDetailDTO.getCase_id()), caseDetail);
|
|
|
|
|
+ }
|
|
|
|
|
+ assignedResultObj.put("results", assignedResults);
|
|
|
|
|
+ assignedTask.setResult(assignedResultObj.toString());
|
|
|
|
|
+ assignedTaskService.saveOrUpdateAssignedTask(assignedTask);
|
|
|
|
|
+ }
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|