package com.qxueyou.scc.courseware.action;
|
|
import java.util.ArrayList;
|
import java.util.List;
|
import java.util.Map;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Controller;
|
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
import com.qxueyou.scc.admin.classes.service.IClassService;
|
import com.qxueyou.scc.base.dao.CommonDAO;
|
import com.qxueyou.scc.base.model.Result;
|
import com.qxueyou.scc.base.util.ClientUtils;
|
import com.qxueyou.scc.courseware.service.ICourceCategoryService;
|
import com.qxueyou.scc.courseware.service.ICourseService;
|
import com.qxueyou.scc.courseware.service.IOrgCourseService;
|
import com.qxueyou.scc.org.model.OrgCollegeCourse;
|
import com.qxueyou.scc.org.model.OrgCourse;
|
|
/**
|
* ¿ÆÄ¿¹ÜÀícontroller
|
*
|
* @author µÂ»¢
|
* @history 2014-11-25 н¨ Ïĵ»¢
|
*
|
*/
|
@Controller
|
@RequestMapping(value = "/org/cource")
|
public class CourceController {
|
|
@Autowired
|
private CommonDAO commonDAO;
|
|
@Autowired
|
private ICourceCategoryService categoryService;
|
|
@Autowired
|
private IOrgCourseService orgCourseService;
|
|
@SuppressWarnings("unused")
|
@Autowired
|
private IClassService orgClassService;
|
|
@Autowired
|
private ICourseService service;
|
|
/**
|
* APP2.0: ²éѯ¿ÆÄ¿ÄÚÈÝ
|
* URL: /org/cource/queryCourseNew/{courseId}
|
*
|
* @param courseId ¿ÆÄ¿ID
|
* @return
|
*/
|
@RequestMapping(value = "queryCourseNew/{courseId}", method = RequestMethod.GET)
|
public @ResponseBody
|
OrgCollegeCourse queryCourse(@PathVariable String courseId) {
|
|
OrgCollegeCourse course = commonDAO.read(OrgCollegeCourse.class, courseId);
|
|
// // Èç¹ûÊÇÓοͰà 1:±íʾÓοͰà
|
// if(orgClassService.isCurrentVistorClass()){
|
// //Organization org = course.getOrg();
|
// Organization org = commonDAO.read(Organization.class, course.getTopOrgId());
|
// course.setOrgName(org.getName());
|
//// course.setOrgTel(org.getTel());
|
// }
|
|
return course;
|
}
|
|
/**
|
* APP2.0: ÍÆ¼ö¿Î³Ì
|
* URL: /org/cource/recommendCourseNew
|
*
|
* @return
|
*/
|
@RequestMapping(value = "recommendCourseNew", method = RequestMethod.GET)
|
public @ResponseBody
|
List<OrgCollegeCourse> recommendCourse() {
|
|
// 1. ²éѯ¸Ã»ú¹¹ÏÂÍÆ¼ö¿Î³Ì ֻȡǰÈý¸ö
|
String hql = "select courseId,name,price,imgPath,courseCategoryId "
|
+ " from OrgCourse c where c.deleteFlag is false and c.recommend is true";
|
|
List<Object> args = new ArrayList<Object>(1);
|
// Èç¹ûÊÇÓÎ¿Í°à ²éËùÓлú¹¹ 1:±íʾÓοͰà
|
// if(!orgClassService.isCurrentVistorClass()){
|
// hql += " and c.org.organizationId=?";
|
// args = CollectionUtils.newList(ClientUtils.getOrgId());
|
// }
|
|
|
List<OrgCollegeCourse> lstCourse = categoryService.queryOrgCourseList(hql, args);
|
|
if (lstCourse.isEmpty()) {
|
return lstCourse;
|
}
|
|
// ֻȡǰÈýÏîÊý¾Ý
|
List<OrgCollegeCourse> lstResultCourse = new ArrayList<OrgCollegeCourse>();
|
int count = lstCourse.size() >= 3 ? 3 : lstCourse.size();
|
for (int i = 0; i < count; i++) {
|
lstResultCourse.add(lstCourse.get(i));
|
}
|
|
return lstResultCourse;
|
}
|
|
/******************************************************************* ÉÏÃæÎªApp½Ó¿Ú£¬ÏÂÃæÎªºǫ́½Ó¿Ú **************************/
|
|
/**
|
* ¿ÆÄ¿Áбí
|
*
|
* @return
|
*/
|
@RequestMapping(method = RequestMethod.GET)
|
public String list() {
|
return "/org/Course";
|
}
|
|
/**
|
* »ñÈ¡ÁбíÊý¾Ý
|
*
|
* @return
|
*/
|
@RequestMapping(value = "/data", method = RequestMethod.GET)
|
public @ResponseBody
|
List<OrgCollegeCourse> data() {
|
|
return orgCourseService.queryCourseList(ClientUtils.getOrgId());
|
|
}
|
|
/**
|
* ¸ù¾Ý¿ÆÄ¿ID²éѯ¿ÆÄ¿
|
*
|
* @return
|
*/
|
@RequestMapping(value = "/read/{courseId}", method = RequestMethod.GET)
|
public @ResponseBody
|
OrgCollegeCourse read(@PathVariable String courseId) {
|
return commonDAO.read(OrgCollegeCourse.class, courseId);
|
}
|
|
/**
|
* רҵ±à¼ - Ñ¡Ôñ¿ÆÄ¿Àà±ðºó¼ÓÔØ×¨ÒµÁбí
|
*
|
* @return
|
*/
|
@RequestMapping(value = "/loadCourse", method = RequestMethod.GET)
|
public @ResponseBody
|
List<OrgCourse> loadCourse( String courseCategoryId,String courseId) {
|
|
List<OrgCourse> orgCourse = orgCourseService.loadCourse(courseCategoryId, courseId);
|
|
return orgCourse;
|
}
|
|
/**
|
* ÐÂÔö
|
*
|
* @return
|
*/
|
@RequestMapping(value = "/add", method = RequestMethod.POST)
|
public @ResponseBody
|
Result add(OrgCollegeCourse course) {
|
|
return orgCourseService.insertCourse(course);
|
|
}
|
|
/**
|
* ±à¼
|
*
|
* @return
|
*/
|
@RequestMapping(value = "/edit", method = RequestMethod.GET)
|
public String edit() {
|
|
return "/org/CourseEdit";
|
}
|
|
/**
|
* ɾ³ý
|
*
|
* @return
|
*/
|
@RequestMapping(value = "/delete", method = RequestMethod.POST)
|
public @ResponseBody
|
Result delete(String courseIds) {
|
|
// ±£´æµ½·þÎñÆ÷
|
return orgCourseService.deleteCourses(courseIds.split(","));
|
|
}
|
|
/**
|
* ÍÆ¼ö
|
*
|
* @return
|
*/
|
@RequestMapping(value = "/recommend", method = RequestMethod.POST)
|
public @ResponseBody
|
Result recommend(String courseIds) {
|
|
// ±£´æµ½·þÎñÆ÷
|
return orgCourseService.doRecommend(courseIds.split(","));
|
|
}
|
|
/**
|
* È¡ÏûÍÆ¼ö
|
*
|
* @return
|
*/
|
@RequestMapping(value = "/unrecommend", method = RequestMethod.POST)
|
public @ResponseBody
|
Result unrecommend(String courseIds) {
|
|
// ±£´æµ½·þÎñÆ÷
|
return orgCourseService.doUnRecommend(courseIds.split(","));
|
|
}
|
|
/**
|
* ¸üÐÂ
|
*
|
* @return
|
*/
|
@RequestMapping(value = "/update", method = RequestMethod.POST)
|
public @ResponseBody
|
Result update(OrgCollegeCourse course) {
|
return orgCourseService.updateCourse(course);
|
}
|
|
/**
|
* ¿ÆÄ¿½éÉÜÔ¤ÀÀ
|
* @param orgClass
|
* @param mobilePhone
|
* @return
|
*/
|
// @RequestMapping(value = "/preview", method = RequestMethod.POST)
|
// public @ResponseBody Result doPreviewNotice(OrgCollegeCourse orgCourse,String mobilePhone) {
|
// return orgCourseService.doPreviewCourse(orgCourse,mobilePhone);
|
// }
|
|
|
/**
|
* ²éѯËùÓлú¹¹ÏîÄ¿
|
* @return
|
*/
|
@RequestMapping(value="/allCourseName",method=RequestMethod.GET)
|
@ResponseBody
|
public List<Map<String, Object>> getCourseName() {
|
return service.queryCourseName();
|
}
|
|
}
|