|
@@ -1,5 +1,7 @@
|
|
package cn.com.qmth.examcloud.core.basic.api.provider;
|
|
package cn.com.qmth.examcloud.core.basic.api.provider;
|
|
|
|
|
|
|
|
+import java.util.List;
|
|
|
|
+
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -8,13 +10,17 @@ import org.springframework.web.bind.annotation.RequestBody;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
|
|
+import com.google.common.collect.Lists;
|
|
|
|
+
|
|
import cn.com.qmth.examcloud.api.commons.enums.CourseLevel;
|
|
import cn.com.qmth.examcloud.api.commons.enums.CourseLevel;
|
|
import cn.com.qmth.examcloud.commons.exception.StatusException;
|
|
import cn.com.qmth.examcloud.commons.exception.StatusException;
|
|
import cn.com.qmth.examcloud.core.basic.api.CourseCloudService;
|
|
import cn.com.qmth.examcloud.core.basic.api.CourseCloudService;
|
|
import cn.com.qmth.examcloud.core.basic.api.bean.CourseBean;
|
|
import cn.com.qmth.examcloud.core.basic.api.bean.CourseBean;
|
|
import cn.com.qmth.examcloud.core.basic.api.request.GetCourseReq;
|
|
import cn.com.qmth.examcloud.core.basic.api.request.GetCourseReq;
|
|
|
|
+import cn.com.qmth.examcloud.core.basic.api.request.GetCoursesByIdListReq;
|
|
import cn.com.qmth.examcloud.core.basic.api.request.SaveCourseReq;
|
|
import cn.com.qmth.examcloud.core.basic.api.request.SaveCourseReq;
|
|
import cn.com.qmth.examcloud.core.basic.api.response.GetCourseResp;
|
|
import cn.com.qmth.examcloud.core.basic.api.response.GetCourseResp;
|
|
|
|
+import cn.com.qmth.examcloud.core.basic.api.response.GetCoursesByIdListResp;
|
|
import cn.com.qmth.examcloud.core.basic.api.response.SaveCourseResp;
|
|
import cn.com.qmth.examcloud.core.basic.api.response.SaveCourseResp;
|
|
import cn.com.qmth.examcloud.core.basic.dao.CourseRepo;
|
|
import cn.com.qmth.examcloud.core.basic.dao.CourseRepo;
|
|
import cn.com.qmth.examcloud.core.basic.dao.OrgRepo;
|
|
import cn.com.qmth.examcloud.core.basic.dao.OrgRepo;
|
|
@@ -26,7 +32,7 @@ import cn.com.qmth.examcloud.web.helpers.GlobalHelper;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
|
/**
|
|
/**
|
|
- * 类注释
|
|
|
|
|
|
+ * {@link StatusException} 状态码范围:011XXX<br>
|
|
*
|
|
*
|
|
* @author WANGWEI
|
|
* @author WANGWEI
|
|
* @date 2018年7月10日
|
|
* @date 2018年7月10日
|
|
@@ -125,4 +131,31 @@ public class CourseCloudServiceProvider implements CourseCloudService {
|
|
return resp;
|
|
return resp;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @ApiOperation(value = "按ID查询课程")
|
|
|
|
+ @PostMapping("getCoursesByIdList")
|
|
|
|
+ @Override
|
|
|
|
+ public GetCoursesByIdListResp getCoursesByIdList(@RequestBody GetCoursesByIdListReq req) {
|
|
|
|
+ List<Long> courseIdList = req.getCourseIdList();
|
|
|
|
+ final List<CourseBean> list = Lists.newArrayList();
|
|
|
|
+ for (Long cur : courseIdList) {
|
|
|
|
+ CourseEntity c = GlobalHelper.getEntity(courseRepo, cur, CourseEntity.class);
|
|
|
|
+ if (null == c) {
|
|
|
|
+ throw new StatusException("160001", "no course [id=" + cur + "]");
|
|
|
|
+ }
|
|
|
|
+ CourseBean courseBean = new CourseBean();
|
|
|
|
+ courseBean.setId(c.getId());
|
|
|
|
+ courseBean.setCode(c.getCode());
|
|
|
|
+ courseBean.setLevel(c.getLevel().name());
|
|
|
|
+ courseBean.setName(c.getName());
|
|
|
|
+ courseBean.setRootOrgId(c.getRootOrgId());
|
|
|
|
+ courseBean.setEnable(c.getEnable());
|
|
|
|
+
|
|
|
|
+ list.add(courseBean);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ GetCoursesByIdListResp resp = new GetCoursesByIdListResp();
|
|
|
|
+ resp.setCourseList(list);
|
|
|
|
+ return resp;
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|