Pārlūkot izejas kodu

专业,评卷员后台增删改查,加导出

weiwenhai 7 gadi atpakaļ
vecāks
revīzija
02336342ea

+ 65 - 0
core-api/src/main/java/cn/com/qmth/examcloud/service/core/api/CourseSpeciatlyApi.java

@@ -0,0 +1,65 @@
+package cn.com.qmth.examcloud.service.core.api;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+
+import io.swagger.annotations.ApiOperation;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import cn.com.qmth.examcloud.common.uac.entity.AccessUser;
+import cn.com.qmth.examcloud.service.core.entity.Course;
+import cn.com.qmth.examcloud.service.core.repo.CourseRepo;
+import cn.com.qmth.examcloud.service.core.service.CourseSpeciatlyService;
+
+/**
+ * @Description 课程专业关联API
+ * @author Administrator
+ * @Date  2017年8月8号
+ */
+@RestController
+@RequestMapping("${app.api.root}/CourseSpeciatly")
+public class CourseSpeciatlyApi {
+
+	@Autowired
+	CourseSpeciatlyService courseSpeciatlyService;
+	
+	@Autowired
+	CourseRepo courseRepo;
+	
+	/**
+	 * 根据专业ID查询课程
+	 * @param speciatlyId
+	 * @return
+	 */
+	@ApiOperation(value="根据专业ID取课程",notes="根据专业ID取课程")
+	@GetMapping("/allCourses/{speciatlyId}")
+	public ResponseEntity getAllCoursesBySpeciatly(@PathVariable String speciatlyId){
+		List<Course> courses = courseSpeciatlyService.getAllCoursesBySpeciatlyId(speciatlyId);
+		//List<Course> list = courseSpeciatlyService.getCoursesNotInSpeciatly(courses);
+		List<Course> list = courseRepo.findAll();
+		Map map = new HashMap();
+		map.put("courseList", courses);
+		map.put("courseDate", list);
+		return new ResponseEntity(map,HttpStatus.OK);
+	}
+	
+	@ApiOperation(value="新增关联课程专业",notes="新增关联课程专业")
+	@PostMapping("/addCourseSpecialty/{speciallyId}")
+	public ResponseEntity addCourseSpeciatly(@RequestBody List<String> list,@PathVariable String speciallyId,HttpServletRequest request){
+		AccessUser  accessUser = (AccessUser)request.getAttribute("accessUser");
+		courseSpeciatlyService.addCourseSpecialty(accessUser.getUserId(), list, speciallyId);
+		return new ResponseEntity(HttpStatus.OK);
+	}
+}

+ 184 - 0
core-api/src/main/java/cn/com/qmth/examcloud/service/core/api/SpecialtyApi.java

@@ -0,0 +1,184 @@
+package cn.com.qmth.examcloud.service.core.api;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.function.Consumer;
+
+
+
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+
+
+
+import io.swagger.annotations.ApiOperation;
+
+
+
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.PageRequest;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.ModelAttribute;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+
+
+
+import cn.com.qmth.examcloud.common.uac.entity.AccessUser;
+import cn.com.qmth.examcloud.common.util.ErrorMsg;
+import cn.com.qmth.examcloud.service.core.dto.SpecialtyDTO;
+import cn.com.qmth.examcloud.service.core.entity.Specialty;
+import cn.com.qmth.examcloud.service.core.repo.SpecialtyRepo;
+import cn.com.qmth.examcloud.service.core.service.SpecialtyService;
+import cn.com.qmth.examcloud.service.core.util.ExportUtils;
+
+/**
+ * @Description: 专业服务API
+ * @author weiwenhai
+ * @Date  2017年8月7号
+ */
+@RestController
+@RequestMapping("${app.api.root}/specialty")
+public class SpecialtyApi {
+
+	@Autowired
+	SpecialtyService specialtyService;
+	
+	@Autowired
+	SpecialtyRepo specialtyRepo;
+	
+	/**
+	 * 带分页查询
+	 * @param specialty
+	 * @param curPage
+	 * @param pageSize
+	 * @param request
+	 * @return
+	 */
+	@ApiOperation(value="查询专业带分页", notes="查询专业带分页")
+	@GetMapping("/all/{curPage}/{pageSize}")
+	public ResponseEntity getAllOrg(@ModelAttribute Specialty specialty,
+									@PathVariable Integer curPage,
+									@PathVariable Integer pageSize,
+									HttpServletRequest request){
+		AccessUser accessUser = (AccessUser)request.getAttribute("accessUser");
+		if(accessUser != null){
+			specialty.setOrgId(accessUser.getRootOrgId());
+		}else {
+			return new ResponseEntity(HttpStatus.NOT_FOUND);
+		}
+		return new ResponseEntity(specialtyService.findAll(specialty, new PageRequest(curPage-1, pageSize)),HttpStatus.OK);
+	}
+	
+	/**
+	 * 查询专业不带分页
+	 * @param specialty
+	 * @param request
+	 * @return
+	 */
+	@ApiOperation(value="查询专业不带分页",notes="查询专业不带分页")
+	@GetMapping("/all")
+	public ResponseEntity getAll(@ModelAttribute Specialty specialty,HttpServletRequest request){
+		AccessUser accessUser = (AccessUser)request.getAttribute("accessUser");
+		if(accessUser != null){
+			specialty.setOrgId(accessUser.getRootOrgId());
+		}
+		specialty.setEnable(true);
+		return new ResponseEntity(specialtyService.findAll(specialty),HttpStatus.OK);
+	}
+	
+	/**
+	 * 新增专业
+	 * @param specialty
+	 * @param request
+	 * @return
+	 */
+	@ApiOperation(value="新增专业", notes="新增专业")
+	@PostMapping("/addSpecialty")
+	public ResponseEntity addSpecialty(@RequestBody Specialty specialty,HttpServletRequest request){
+		specialty.setCreateTime(new Date());
+		AccessUser accessUser = (AccessUser)request.getAttribute("accessUser");
+		if(accessUser != null){
+			specialty.setOrgId(accessUser.getRootOrgId());
+		}else {
+			return new ResponseEntity(HttpStatus.NOT_FOUND);
+		}
+		try{
+			specialtyService.save(specialty);
+			return new ResponseEntity(HttpStatus.CREATED);
+		} catch (Exception e) {
+			 e.printStackTrace();
+			 return new ResponseEntity(new ErrorMsg(e.getMessage()), HttpStatus.INTERNAL_SERVER_ERROR);
+		}
+	}
+	
+	/**
+	 * 更新专业
+	 * @param specialty
+	 * @param request
+	 * @return
+	 */
+	@ApiOperation(value="更新专业",notes="更新专业")
+	@PutMapping("/updateSpecialty")
+	public ResponseEntity updateSpecialty(@RequestBody Specialty specialty,HttpServletRequest request){
+		AccessUser accessUser = (AccessUser) request.getAttribute("accessUser");
+		if(accessUser != null){
+			specialty.setOrgId(accessUser.getRootOrgId());
+		}else {
+			return new ResponseEntity(HttpStatus.NOT_FOUND);
+		}
+		try{
+			specialtyService.updateSpecialty(specialty);
+			return new ResponseEntity(HttpStatus.OK);
+		} catch (Exception e) {
+			 e.printStackTrace();
+			 return new ResponseEntity(new ErrorMsg(e.getMessage()), HttpStatus.INTERNAL_SERVER_ERROR);
+		}
+	}
+	
+	/**
+	 * 根据ID删除专业
+	 * @param ids
+	 * @return
+	 */
+	@ApiOperation(value="根据ID删除专业",notes="根据ID删除专业")
+	@DeleteMapping("/{ids}")
+	public ResponseEntity deleteSpecialtyIds(@PathVariable String ids){
+		specialtyService.deleteSpecialty(ids);
+		return new ResponseEntity(HttpStatus.OK);
+	}
+	
+	@ApiOperation(value="根据ID删除专业",notes="根据ID删除专业")
+	@DeleteMapping("/delete/{id}")
+	public ResponseEntity deleteSpecialtyId(@PathVariable String id){
+		specialtyRepo.delete(Long.parseLong(id));
+		return new ResponseEntity(HttpStatus.OK);
+	}
+	
+	/**
+	 * 导出专业
+	 * @param specialty
+	 * @param response
+	 */
+	@ApiOperation(value="导出专业", notes="导出专业")
+	@GetMapping("/export")
+	public void exportSpecialty(@ModelAttribute Specialty specialty,HttpServletResponse response){
+		List<SpecialtyDTO> list = new ArrayList<SpecialtyDTO>();
+		specialtyService.findAll(specialty).forEach(c -> {
+			list.add(new SpecialtyDTO(c));
+		});
+		ExportUtils.exportEXCEL("专业列表", SpecialtyDTO.class, list, response);
+	}
+}

+ 13 - 0
core-api/src/main/java/cn/com/qmth/examcloud/service/core/api/UserApi.java

@@ -265,4 +265,17 @@ public class UserApi {
             return new ResponseEntity(HttpStatus.OK);
         }
     }
+    
+    @ApiOperation(value="查询评卷员带分页",notes="查询评卷员带分页")
+    @GetMapping("/all/marker/{curPage}/{pageSize}")
+    public ResponseEntity getAllMark(@ModelAttribute User user,
+    								 @PathVariable Integer curPage,
+    								 @PathVariable Integer pageSize,
+    								 HttpServletRequest request){
+    	AccessUser accessUser = (AccessUser)request.getAttribute("accessUser");
+    	if(accessUser != null){
+    		return new ResponseEntity(userService.getALLMaker(accessUser.getRootOrgId(),new PageRequest(curPage-1, pageSize)),HttpStatus.OK);
+    	}
+        return new ResponseEntity(HttpStatus.NOT_FOUND);
+    }
 }

+ 87 - 0
core-api/src/main/java/cn/com/qmth/examcloud/service/core/service/CourseSpeciatlyService.java

@@ -0,0 +1,87 @@
+package cn.com.qmth.examcloud.service.core.service;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import cn.com.qmth.examcloud.service.core.entity.Course;
+import cn.com.qmth.examcloud.service.core.entity.CourseSpeciatly;
+import cn.com.qmth.examcloud.service.core.repo.CourseRepo;
+import cn.com.qmth.examcloud.service.core.repo.CourseSpeciatlyRepo;
+
+@Service
+public class CourseSpeciatlyService {
+
+	@Autowired
+	CourseSpeciatlyRepo courseSpeciatlyRepo;
+	
+	@Autowired
+	CourseRepo courseRepo;
+	
+	/**
+	 * 根据专业ID查询关联课程
+	 * @param speciatlyId
+	 * @return
+	 */
+	public List<Course> getAllCoursesBySpeciatlyId(String speciatlyId){
+		//根据专业id查询 专业课程
+		List<CourseSpeciatly> list = courseSpeciatlyRepo.findBySpecialtyId(Long.parseLong(speciatlyId));
+		List<Course> courses = new ArrayList<Course>();
+		if(list == null){
+			return null;
+		}
+		courses = getCoursesByCourseSpeciatly(list);
+		return courses;
+	}
+	
+	//根据课程专业查询课程集合
+	public List<Course> getCoursesByCourseSpeciatly(List<CourseSpeciatly> list){
+		List<Course> courses = new ArrayList<Course>();
+		for(CourseSpeciatly courseSpeciatly:list){
+			Course course = courseRepo.findOne(courseSpeciatly.getCourseId());
+			courses.add(course);
+		}
+		return courses;
+	}
+	
+	/**
+	 * 获取未关联的课程
+	 * @param courses
+	 * @return
+	 */
+	public List<Course> getCoursesNotInSpeciatly(List<Course> courses){
+		List<Course> list = new ArrayList<Course>();
+		if(courses == null || courses.size() < 1){
+			list = courseRepo.findAll();
+			return list;
+		}
+		List<Long> ids = new ArrayList<Long>();
+		for(Course course: courses){
+			ids.add(course.getId());
+		}
+		list = courseRepo.findByIdNotIn(ids);
+		return list;
+	}
+	
+	public void addCourseSpecialty(Long userId,List<String> courseIds,String speciallyId){
+		//首先判断该专业是否有关联的课程
+		List<CourseSpeciatly> list = courseSpeciatlyRepo.findBySpecialtyId(Long.parseLong(speciallyId));
+		if(list != null || list.size()>0){
+			for(CourseSpeciatly courseSpeciatly: list){
+				courseSpeciatlyRepo.delete(courseSpeciatly);
+			}
+		}
+		//保存新关联的课程
+		for(String courseId: courseIds){
+			CourseSpeciatly courseSpeciatly = new CourseSpeciatly();
+			courseSpeciatly.setCourseId(Long.parseLong(courseId));
+			courseSpeciatly.setSpecialtyId(Long.parseLong(speciallyId));
+			courseSpeciatly.setCreator(userId);
+			courseSpeciatly.setCreateTime(new Date());
+			courseSpeciatlyRepo.save(courseSpeciatly);
+		}
+ 	}
+}

+ 114 - 0
core-api/src/main/java/cn/com/qmth/examcloud/service/core/service/SpecialtyService.java

@@ -0,0 +1,114 @@
+package cn.com.qmth.examcloud.service.core.service;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import javax.persistence.criteria.Predicate;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+import org.springframework.data.jpa.domain.Specification;
+import org.springframework.stereotype.Service;
+import org.springframework.util.StringUtils;
+
+import com.rabbitmq.client.AMQP.Basic.Return;
+
+import cn.com.qmth.examcloud.service.core.entity.Specialty;
+import cn.com.qmth.examcloud.service.core.repo.SpecialtyRepo;
+
+@Service
+public class SpecialtyService {
+
+	@Autowired
+	SpecialtyRepo specialtyRepo;
+	
+	/**
+	 * 带分页查询专业
+	 * @param specialty
+	 * @param pageable
+	 * @return
+	 */
+	public Page<Specialty> findAll(Specialty specialty,Pageable pageable){
+		Specification<Specialty> specification = getSpecification(specialty);
+		Page<Specialty> specialties = specialtyRepo.findAll(specification, pageable);
+		return specialties;
+	}
+	
+	public Specification<Specialty> getSpecification(Specialty specialty){
+		Specification<Specialty> specification = (root, query, cb) -> {
+			List<Predicate> predicates = new ArrayList<>();
+			if(!StringUtils.isEmpty(specialty.getOrgId())){
+				predicates.add(cb.equal(root.get("orgId"),specialty.getOrgId()));
+			}
+			if(!StringUtils.isEmpty(specialty.getName())){
+		    	predicates.add(cb.like(root.get("name"),"%"+specialty.getName()+"%"));
+		    }
+		    if(!StringUtils.isEmpty(specialty.getCode())){
+		    	predicates.add(cb.like(root.get("code"),"%"+specialty.getCode()+"%"));
+		    }
+		    if(!StringUtils.isEmpty(specialty.getEnable())){
+		    	predicates.add(cb.equal(root.get("enable"),specialty.getEnable()));
+		    }
+			return cb.and(predicates.toArray(new Predicate[predicates.size()]));
+		};
+		return specification;
+	}
+	
+	/**
+	 * 查询专业不带分页
+	 * @param specialty
+	 * @return
+	 */
+	public List<Specialty> findAll(Specialty specialty){
+		Specification<Specialty> specification = getSpecification(specialty);
+		return specialtyRepo.findAll(specification);
+	}
+	
+	/**
+	 * 保存专业
+	 * @param specialty
+	 * @return
+	 */
+	public void save(Specialty specialty){
+		checkCode(specialty.getOrgId(), specialty.getCode());
+		specialty.setCreateTime(new Date());
+		specialtyRepo.save(specialty);
+	}
+	
+	//验证专业代码是否存在
+	private void checkCode(Long orgId,String code){
+		Specialty specialty = specialtyRepo.findByOrgIdAndCode(orgId, code);
+		if(specialty != null){
+			throw new RuntimeException("专业代码已存在");
+		}
+	}
+	
+	/**
+	 * 更新专业
+	 * @param specialty
+	 */
+	public void updateSpecialty(Specialty specialty){
+		Specialty oldSpecialty = specialtyRepo.findOne(specialty.getId());
+		if(!oldSpecialty.getCode().equals(specialty.getCode())){
+			checkCode(specialty.getOrgId(), specialty.getCode());
+		}
+		specialty.setUpdateTime(new Date());
+		specialtyRepo.save(specialty);
+	}
+	
+	/**
+	 * 根据Id删除专业
+	 * @param ids
+	 */
+	public void deleteSpecialty(String ids){
+		List<Long> specialtyIds = Stream.of(ids.split(",")).map(s->Long.parseLong(s.trim()))
+                .collect(Collectors.toList());
+		for(Long specialtyId: specialtyIds){
+			specialtyRepo.delete(specialtyId);
+		}
+	}
+}

+ 34 - 0
core-api/src/main/java/cn/com/qmth/examcloud/service/core/service/UserService.java

@@ -30,6 +30,7 @@ import cn.com.qmth.examcloud.common.uac.entity.AccessUser;
 import cn.com.qmth.examcloud.common.uac.enums.RoleMeta;
 import cn.com.qmth.examcloud.service.core.dto.UserInfo;
 import cn.com.qmth.examcloud.service.core.entity.Org;
+import cn.com.qmth.examcloud.service.core.entity.Specialty;
 import cn.com.qmth.examcloud.service.core.entity.Student;
 import cn.com.qmth.examcloud.service.core.entity.User;
 import cn.com.qmth.examcloud.service.core.entity.UserLogin;
@@ -335,7 +336,40 @@ public class UserService {
 	public List<User> getMarker(Long rootOrgId) {
 		return userRepo.findMarkerByRootOrgId(rootOrgId);
 	}
+	
+	/**
+	 * 查询评卷员带分页
+	 * @param rootOrgId
+	 * @param pageable
+	 * @return
+	 */
+	public Page<User> getALLMaker(Long rootOrgId,Pageable pageable){
+		//Specification<User> specification = getSpecification(user);
+		return userRepo.findMarkerByRootOrgId(rootOrgId,pageable);
+	}
 
+	public Specification<User> getSpecification(User user){
+		Specification<User> specification = (root, query, cb) -> {
+			List<Predicate> predicates = new ArrayList<>();
+			predicates.add(cb.equal(root.get("type"),user.getType()));
+            predicates.add(cb.equal(root.get("rootOrgId"),user.getRootOrgId()));
+            if(StringUtils.isNotEmpty(user.getLoginName())){
+                predicates.add(cb.like(root.get("loginName"),"%"+user.getLoginName()+"%"));
+            }
+            if(StringUtils.isNotEmpty(user.getName())){
+                predicates.add(cb.like(root.get("name"),"%"+user.getName()+"%"));
+            }
+            if(user.getOrgId() != null){
+                predicates.add(cb.equal(root.get("orgId"),user.getOrgId()));
+            }
+            if(user.getEnable() != null){
+                predicates.add(cb.equal(root.get("enable"),user.getEnable()));
+            }
+			return cb.and(predicates.toArray(new Predicate[predicates.size()]));
+		};
+		return specification;
+	}
+	
 	public User save(User user) throws Exception{
         user.setScope(UserScope.ORG);
         user.setType(UserType.NOT_STUDENT);

+ 61 - 0
core-domain/src/main/java/cn/com/qmth/examcloud/service/core/dto/SpecialtyDTO.java

@@ -0,0 +1,61 @@
+package cn.com.qmth.examcloud.service.core.dto;
+
+import cn.com.qmth.examcloud.common.util.excel.ExcelProperty;
+import cn.com.qmth.examcloud.service.core.entity.Specialty;
+
+/**
+ * @Description 专业
+ * @author weiwenhai
+ * @date 2017年8月7号
+ */
+public class SpecialtyDTO {
+
+	@ExcelProperty(index = 1,name = "专业代码")
+	private String code;
+	
+	@ExcelProperty(index = 0,name = "专业名称")
+	private String name;
+	
+	private Long orgId;
+	
+	private String enable;
+	
+	public SpecialtyDTO(){}
+	
+	public SpecialtyDTO(Specialty specialty){
+		this.code = specialty.getCode();
+		this.name = specialty.getName();
+	}
+
+	public String getCode() {
+		return code;
+	}
+
+	public void setCode(String code) {
+		this.code = code;
+	}
+
+	public String getName() {
+		return name;
+	}
+
+	public void setName(String name) {
+		this.name = name;
+	}
+
+	public Long getOrgId() {
+		return orgId;
+	}
+
+	public void setOrgId(Long orgId) {
+		this.orgId = orgId;
+	}
+
+	public String getEnable() {
+		return enable;
+	}
+
+	public void setEnable(String enable) {
+		this.enable = enable;
+	}
+}

+ 95 - 0
core-domain/src/main/java/cn/com/qmth/examcloud/service/core/entity/CourseSpeciatly.java

@@ -0,0 +1,95 @@
+package cn.com.qmth.examcloud.service.core.entity;
+
+import java.io.Serializable;
+import java.util.Date;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import javax.validation.constraints.NotNull;
+
+import org.springframework.format.annotation.DateTimeFormat;
+
+/**
+ * @Description 专业课程关联
+ * @author Administrator
+ * @date 2017年8月8号
+ */
+@Entity
+@Table(name = "ecs_core_course_specialty")
+public class CourseSpeciatly implements Serializable{
+
+	private static final long serialVersionUID = -250814769612993025L;
+	
+	@Id
+	@GeneratedValue
+	private Long id;
+	
+	@NotNull
+	private Long courseId;
+	
+	@NotNull
+	private Long specialtyId;
+	
+	@NotNull
+	private Long creator;
+	
+	@DateTimeFormat
+	private Date createTime;
+
+	@DateTimeFormat
+	private Date updateTime;
+
+	public Long getId() {
+		return id;
+	}
+
+	public void setId(Long id) {
+		this.id = id;
+	}
+
+	public Long getCourseId() {
+		return courseId;
+	}
+
+	public void setCourseId(Long courseId) {
+		this.courseId = courseId;
+	}
+
+	public Long getSpecialtyId() {
+		return specialtyId;
+	}
+
+	public void setSpecialtyId(Long specialtyId) {
+		this.specialtyId = specialtyId;
+	}
+
+	public Date getCreateTime() {
+		return createTime;
+	}
+
+	public void setCreateTime(Date createTime) {
+		this.createTime = createTime;
+	}
+
+	public Date getUpdateTime() {
+		return updateTime;
+	}
+
+	public Long getCreator() {
+		return creator;
+	}
+
+	public void setCreator(Long creator) {
+		this.creator = creator;
+	}
+
+	public void setUpdateTime(Date updateTime) {
+		this.updateTime = updateTime;
+	}
+
+	public static long getSerialversionuid() {
+		return serialVersionUID;
+	}
+}

+ 109 - 0
core-domain/src/main/java/cn/com/qmth/examcloud/service/core/entity/Specialty.java

@@ -0,0 +1,109 @@
+package cn.com.qmth.examcloud.service.core.entity;
+
+import java.io.Serializable;
+import java.util.Date;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import javax.validation.constraints.NotNull;
+
+import org.springframework.format.annotation.DateTimeFormat;
+
+import cn.com.qmth.examcloud.common.util.excel.ExcelProperty;
+
+/**
+ * @Description: 专业
+ * @author  weiwenhai
+ * @date    2017年8月7号
+ */
+@Entity
+@Table(name = "ecs_core_specialty")
+public class Specialty implements Serializable{
+
+	private static final long serialVersionUID = 239263456816448160L;
+	
+	@Id
+	@GeneratedValue
+	private Long id;
+	
+	@ExcelProperty(index = 1)
+	@NotNull
+	private String code;
+
+	@ExcelProperty(index = 0)
+	@NotNull
+	private String name;
+	
+	@NotNull
+	private Long orgId;
+	
+	@DateTimeFormat
+	private Date createTime;
+	
+	@DateTimeFormat
+	private Date updateTime;
+	
+	private Boolean enable;
+
+	public Long getId() {
+		return id;
+	}
+
+	public void setId(Long id) {
+		this.id = id;
+	}
+
+	public String getCode() {
+		return code;
+	}
+
+	public void setCode(String code) {
+		this.code = code;
+	}
+
+	public String getName() {
+		return name;
+	}
+
+	public void setName(String name) {
+		this.name = name;
+	}
+
+	public Long getOrgId() {
+		return orgId;
+	}
+
+	public void setOrgId(Long orgId) {
+		this.orgId = orgId;
+	}
+
+	public Date getCreateTime() {
+		return createTime;
+	}
+
+	public void setCreateTime(Date createTime) {
+		this.createTime = createTime;
+	}
+
+	public Date getUpdateTime() {
+		return updateTime;
+	}
+
+	public void setUpdateTime(Date updateTime) {
+		this.updateTime = updateTime;
+	}
+
+	public Boolean getEnable() {
+		return enable;
+	}
+
+	public void setEnable(Boolean enable) {
+		this.enable = enable;
+	}
+
+	public static long getSerialversionuid() {
+		return serialVersionUID;
+	}
+}

+ 2 - 0
core-domain/src/main/java/cn/com/qmth/examcloud/service/core/repo/CourseRepo.java

@@ -13,5 +13,7 @@ public interface CourseRepo extends JpaRepository<Course, Long>,QueryByExampleEx
 	List<Course> findByOrgId(Long orgId);
 
 	Course findByOrgIdAndCode(Long orgId, String code);
+	
+	List<Course> findByIdNotIn(List<Long> ids);
 
 }

+ 14 - 0
core-domain/src/main/java/cn/com/qmth/examcloud/service/core/repo/CourseSpeciatlyRepo.java

@@ -0,0 +1,14 @@
+package cn.com.qmth.examcloud.service.core.repo;
+
+import java.util.List;
+
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.data.repository.query.QueryByExampleExecutor;
+
+import cn.com.qmth.examcloud.service.core.entity.CourseSpeciatly;
+
+public interface CourseSpeciatlyRepo extends JpaRepository<CourseSpeciatly, Long>,QueryByExampleExecutor<CourseSpeciatly>,JpaSpecificationExecutor<CourseSpeciatly>{
+
+	List<CourseSpeciatly> findBySpecialtyId(Long specialtyId);
+}

+ 12 - 0
core-domain/src/main/java/cn/com/qmth/examcloud/service/core/repo/SpecialtyRepo.java

@@ -0,0 +1,12 @@
+package cn.com.qmth.examcloud.service.core.repo;
+
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.data.repository.query.QueryByExampleExecutor;
+
+import cn.com.qmth.examcloud.service.core.entity.Specialty;
+
+public interface SpecialtyRepo extends JpaRepository<Specialty, Long>,QueryByExampleExecutor<Specialty>,JpaSpecificationExecutor<Specialty>{
+     
+	Specialty findByOrgIdAndCode(Long orgId,String code);
+}

+ 10 - 0
core-domain/src/main/java/cn/com/qmth/examcloud/service/core/repo/UserRepo.java

@@ -2,6 +2,9 @@ package cn.com.qmth.examcloud.service.core.repo;
 
 import java.util.List;
 
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+import org.springframework.data.jpa.domain.Specification;
 import org.springframework.data.jpa.repository.JpaRepository;
 import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
 import org.springframework.data.jpa.repository.Modifying;
@@ -10,6 +13,7 @@ import org.springframework.data.repository.query.Param;
 import org.springframework.data.repository.query.QueryByExampleExecutor;
 import org.springframework.transaction.annotation.Transactional;
 
+import cn.com.qmth.examcloud.service.core.entity.Specialty;
 import cn.com.qmth.examcloud.service.core.entity.User;
 
 /**
@@ -36,4 +40,10 @@ public interface UserRepo extends JpaRepository<User,Long>,QueryByExampleExecuto
 	
 	@Query(nativeQuery = true,value = "SELECT DISTINCT * FROM ecs_core_user us, ecs_core_user_role ur WHERE us.id = ur.user_id And us.root_org_id = ? And ur.role_code = 'MARKER' And us.enable = 1")
 	List<User> findMarkerByRootOrgId(Long rootOrgId);
+	
+	@Query(value = "SELECT distinct * FROM ecs_core_user us, ecs_core_user_role ur WHERE us.id = ur.user_id " +
+			            "And us.root_org_id = :rootOrgId And ur.role_code = 'MARKER' And us.enable = 1 ORDER BY ?#{#pageable}",
+			    countQuery = "SELECT count(distinct us.id ) FROM ecs_core_user us, ecs_core_user_role ur WHERE us.id  = ur.user_id " +"And us.root_org_id = :rootOrgId And ur.role_code = 'MARKER' And us.enable = 1 ORDER BY ?#{#pageable}",nativeQuery = true)
+	Page<User> findMarkerByRootOrgId(@Param("rootOrgId")long rootOrgId, Pageable pageable);
+
 }