Jelajahi Sumber

后端课程属性列表和课程属性树

weiwenhai 7 tahun lalu
induk
melakukan
51e121127f

+ 50 - 0
cqb-paper/src/main/java/com/qmth/cqb/paper/assemble/PropertyAssembler.java

@@ -0,0 +1,50 @@
+package com.qmth.cqb.paper.assemble;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.springframework.stereotype.Component;
+
+import com.qmth.cqb.paper.dto.PropertyDto;
+import com.qmth.cqb.paper.model.Property;
+
+@Component
+public class PropertyAssembler {
+
+	/**
+	 * 得到父节点对象
+	 * @param propertyDto
+	 * @return
+	 */
+	public Property toProperty(PropertyDto propertyDto){
+		Property property = null;
+		if(propertyDto != null){
+			property = new Property();
+			property.setId(propertyDto.getId());
+			property.setCoursePropertyId(propertyDto.getCoursePropertyId());
+			property.setName(propertyDto.getName());
+			property.setParentId(propertyDto.getCoursePropertyId());
+			property.setRemark(propertyDto.getRemark());
+		}
+		return property;
+	}
+	
+	/**
+	 * 得到子类节点对象
+	 * @param propertyDto
+	 * @return
+	 */
+	public List<Property> toPropertySon(PropertyDto propertyDto){
+		Property property = null;
+		List<PropertyDto> propertyDtos = propertyDto.getPropertyDtos();
+		if(propertyDtos != null && propertyDtos.size()>0){
+			List<Property> properties = new ArrayList<Property>();
+			for(PropertyDto propertyDto2:propertyDtos){
+				property = toProperty(propertyDto2);
+				properties.add(property);
+			}
+			return properties;
+		}
+		return null;
+	}
+}

+ 26 - 0
cqb-paper/src/main/java/com/qmth/cqb/paper/dao/CoursePropertyRepo.java

@@ -0,0 +1,26 @@
+package com.qmth.cqb.paper.dao;
+
+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 com.qmth.cqb.paper.model.CourseProperty;
+/**
+ * @describle 课程属性repo
+ * @author weiwenhai
+ * @date   2017.11.2
+ */
+public interface CoursePropertyRepo extends JpaRepository<CourseProperty, Long>,QueryByExampleExecutor<CourseProperty>,JpaSpecificationExecutor<CourseProperty>{
+	
+	//查询所有课程属性
+	List<CourseProperty> findByOrgId(Long orgId);
+	
+	//根据属性名查询
+	CourseProperty findByNameAndOrgId(String name, Long orgId);
+	
+	//根据课程id查询
+	List<CourseProperty> findByCourseId(Long courseId);
+
+}

+ 23 - 0
cqb-paper/src/main/java/com/qmth/cqb/paper/dao/PropertyRepo.java

@@ -0,0 +1,23 @@
+package com.qmth.cqb.paper.dao;
+
+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 com.qmth.cqb.paper.model.Property;
+/**
+ * @describle 课程属性repo
+ * @author weiwenhai
+ * @date   2017.11.6
+ */
+public interface PropertyRepo extends JpaRepository<Property, Long>, QueryByExampleExecutor<Property> ,JpaSpecificationExecutor<Property>{
+	
+	//查询所有节点
+	List<Property> findByOrgIdAndCoursePropertyIdAndParentIdOrderByNumber(Long orgId, Long coursePropertyId, Long parentId);
+	
+	//查询子节点
+	List<Property> findByParentIdOrderByNumber(Long parentId);
+
+}

+ 60 - 0
cqb-paper/src/main/java/com/qmth/cqb/paper/dto/CoursePropertyDto.java

@@ -0,0 +1,60 @@
+package com.qmth.cqb.paper.dto;
+
+/**
+ * @describle 课程属性Dto
+ * @author weiwenhai
+ * @date   2017.11.2
+ */
+public class CoursePropertyDto {
+
+	private Long id;
+	
+	private String name;
+	
+	private Long courseId;
+	
+	private Long orgId;
+	
+	private String enable;
+
+	public Long getId() {
+		return id;
+	}
+
+	public void setId(Long id) {
+		this.id = id;
+	}
+
+	public String getName() {
+		return name;
+	}
+
+	public void setName(String name) {
+		this.name = name;
+	}
+
+	public Long getCourseId() {
+		return courseId;
+	}
+
+	public void setCourseId(Long courseId) {
+		this.courseId = courseId;
+	}
+
+	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
cqb-paper/src/main/java/com/qmth/cqb/paper/dto/PropertyDto.java

@@ -0,0 +1,95 @@
+package com.qmth.cqb.paper.dto;
+
+import java.util.List;
+
+import com.qmth.cqb.paper.model.Property;
+
+/**
+ * @describle 属性Dto
+ * @author weiwenhai
+ * @date   2017.11.6
+ */
+public class PropertyDto {
+
+	private Long id;
+	
+	private Long coursePropertyId;
+	
+	private String name;
+	
+	private Integer number;
+	
+	private Long parentId;
+	
+	private String remark;
+	
+	private List<PropertyDto> propertyDtos;
+	
+	public PropertyDto(){}
+	
+	public PropertyDto(Property property){
+		this.id = property.getId();
+		this.coursePropertyId = property.getCoursePropertyId();
+		this.name = property.getName();
+		this.number = property.getNumber();
+		this.remark = property.getRemark();
+		this.parentId = property.getParentId();
+	}
+
+	public Long getId() {
+		return id;
+	}
+
+	public void setId(Long id) {
+		this.id = id;
+	}
+
+	public Long getCoursePropertyId() {
+		return coursePropertyId;
+	}
+
+	public void setCoursePropertyId(Long coursePropertyId) {
+		this.coursePropertyId = coursePropertyId;
+	}
+
+	public String getName() {
+		return name;
+	}
+
+	public void setName(String name) {
+		this.name = name;
+	}
+
+	public Integer getNumber() {
+		return number;
+	}
+
+	public void setNumber(Integer number) {
+		this.number = number;
+	}
+
+	public Long getParentId() {
+		return parentId;
+	}
+
+	public void setParentId(Long parentId) {
+		this.parentId = parentId;
+	}
+
+	public String getRemark() {
+		return remark;
+	}
+
+	public void setRemark(String remark) {
+		this.remark = remark;
+	}
+
+	public List<PropertyDto> getPropertyDtos() {
+		return propertyDtos;
+	}
+
+	public void setPropertyDtos(List<PropertyDto> propertyDtos) {
+		this.propertyDtos = propertyDtos;
+	}
+
+}

+ 99 - 0
cqb-paper/src/main/java/com/qmth/cqb/paper/model/CourseProperty.java

@@ -0,0 +1,99 @@
+package com.qmth.cqb.paper.model;
+
+import java.io.Serializable;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import javax.validation.constraints.NotNull;
+
+import com.qmth.cqb.paper.dto.CoursePropertyDto;
+
+/**
+ * @describle 课程属性
+ * @author weiwenhai
+ * @date   2017.11.2
+ */
+@Entity
+@Table(name ="ecs_ques_course_property")
+public class CourseProperty implements Serializable{
+
+	private static final long serialVersionUID = 3370756666063937765L;
+
+	@Id
+	@GeneratedValue
+	private Long id;
+	
+	@NotNull
+	private String name;
+	
+	@NotNull
+	private Long courseId;
+	
+	@NotNull
+	private Long orgId;
+	
+	private Boolean enable;
+
+	public CourseProperty(){}
+	
+	public CourseProperty(CoursePropertyDto coursePropertyDto){
+		this.id = coursePropertyDto.getId();
+		this.name = coursePropertyDto.getName();
+		this.courseId = coursePropertyDto.getCourseId();
+		this.orgId = coursePropertyDto.getOrgId();
+		if(coursePropertyDto.getEnable() != null && coursePropertyDto.getEnable().equals("0")){
+			this.enable = false;
+		}else if(coursePropertyDto.getEnable() != null && coursePropertyDto.getEnable().equals("1")){
+			this.enable = true;
+		}else {
+			this.enable = null;
+		}
+	}
+	
+	public Long getId() {
+		return id;
+	}
+
+	public void setId(Long id) {
+		this.id = id;
+	}
+
+	public String getName() {
+		return name;
+	}
+
+	public void setName(String name) {
+		this.name = name;
+	}
+
+	public Long getCourseId() {
+		return courseId;
+	}
+
+	public void setCourseId(Long courseId) {
+		this.courseId = courseId;
+	}
+
+	public Long getOrgId() {
+		return orgId;
+	}
+
+	public void setOrgId(Long orgId) {
+		this.orgId = orgId;
+	}
+
+	public static long getSerialversionuid() {
+		return serialVersionUID;
+	}
+
+	public Boolean getEnable() {
+		return enable;
+	}
+
+	public void setEnable(Boolean enable) {
+		this.enable = enable;
+	}
+	
+}

+ 117 - 0
cqb-paper/src/main/java/com/qmth/cqb/paper/model/Property.java

@@ -0,0 +1,117 @@
+package com.qmth.cqb.paper.model;
+
+import java.io.Serializable;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import javax.validation.constraints.NotNull;
+
+import com.qmth.cqb.paper.dto.PropertyDto;
+/**
+ * @describle  属性 
+ * @author weiwenhai
+ * @date   2017.11.6
+ */
+@Entity
+@Table(name = "ecs_ques_property")
+public class Property implements Serializable{
+
+	private static final long serialVersionUID = -417218505125002677L;
+	
+	@Id
+	@GeneratedValue
+	private Long id;
+	
+	@NotNull
+	private String name;
+	
+	@NotNull
+	private Long parentId;
+	
+	@NotNull
+	private Integer number;//序号
+	
+	@NotNull
+	private Long coursePropertyId;
+	
+	private String remark;
+	
+	@NotNull
+	private Long orgId;
+	
+	public Property(){
+		
+	}
+	
+	public Property(PropertyDto propertyDto){
+		this.id = propertyDto.getId();
+		this.name = propertyDto.getName();
+		this.parentId = propertyDto.getParentId();
+		this.number = propertyDto.getNumber();
+		this.coursePropertyId = propertyDto.getCoursePropertyId();
+		this.remark = propertyDto.getRemark();
+	}
+
+	public Long getId() {
+		return id;
+	}
+
+	public void setId(Long id) {
+		this.id = id;
+	}
+
+	public String getName() {
+		return name;
+	}
+
+	public void setName(String name) {
+		this.name = name;
+	}
+
+	public Long getParentId() {
+		return parentId;
+	}
+
+	public void setParentId(Long parentId) {
+		this.parentId = parentId;
+	}
+
+	public Integer getNumber() {
+		return number;
+	}
+
+	public void setNumber(Integer number) {
+		this.number = number;
+	}
+
+	public Long getCoursePropertyId() {
+		return coursePropertyId;
+	}
+
+	public void setCoursePropertyId(Long coursePropertyId) {
+		this.coursePropertyId = coursePropertyId;
+	}
+
+	public String getRemark() {
+		return remark;
+	}
+
+	public void setRemark(String remark) {
+		this.remark = remark;
+	}
+
+	public Long getOrgId() {
+		return orgId;
+	}
+
+	public void setOrgId(Long orgId) {
+		this.orgId = orgId;
+	}
+
+	public static long getSerialversionuid() {
+		return serialVersionUID;
+	}
+	
+}

+ 59 - 0
cqb-paper/src/main/java/com/qmth/cqb/paper/service/CoursePropertyService.java

@@ -0,0 +1,59 @@
+package com.qmth.cqb.paper.service;
+
+import java.util.List;
+
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+
+import com.qmth.cqb.paper.dto.CoursePropertyDto;
+import com.qmth.cqb.paper.model.CourseProperty;
+
+/**
+ * @describle 课程属性 coursePropertyService
+ * @author weiwenhai
+ * @date   2017.11.2
+ */
+public interface CoursePropertyService {
+
+	/**
+	 * 查询所有课程属性
+	 * @param orgId
+	 * @return
+	 */
+	public List<CourseProperty> findAllByOrgId(Long orgId);
+	
+	/**
+	 * 查询所有课程属性带分页
+	 * @param coursePropertyDto
+	 * @param pageable
+	 * @return
+	 */
+	public Page<CourseProperty> findAllByOrg(CoursePropertyDto coursePropertyDto, Pageable pageable);
+	
+	/**
+	 * 保存课程属性
+	 * @param coursePropertyDto
+	 */
+	public void saveCourseProperty(CoursePropertyDto coursePropertyDto) throws Exception;
+	
+	/**
+	 * 启用
+	 * @param id
+	 * @param orgId
+	 */
+	public void openCourseProperty(Long id, Long orgId);
+	
+	/**
+	 * 禁用
+	 * @param id
+	 * @param orgId
+	 */
+	public void closeCourseProperty(Long id ,Long orgId);
+	
+	/**
+	 * 根据课程id查询所有课程属性
+	 * @param courseId
+	 * @return
+	 */
+	public List<CourseProperty> findAllByCourseId(Long courseId);
+}

+ 58 - 0
cqb-paper/src/main/java/com/qmth/cqb/paper/service/PropertyService.java

@@ -0,0 +1,58 @@
+package com.qmth.cqb.paper.service;
+
+import java.util.List;
+
+import cn.com.qmth.examcloud.common.uac.entity.AccessUser;
+
+import com.qmth.cqb.paper.dto.PropertyDto;
+import com.qmth.cqb.paper.model.Property;
+
+/**
+ * @describle 属性service
+ * @author    weiwenhai
+ * @date      2017.11.6
+ */
+public interface PropertyService {
+
+	/**
+	 * 保存属性
+	 * @param propertyDtos
+	 */
+	public void saveProperty(List<PropertyDto> propertyDtos, AccessUser user);
+	
+	/**
+	 * 查询属性
+	 * @param coursePropertyId
+	 * @param user
+	 * @return
+	 */
+	public List<PropertyDto> propertyDtos(Long coursePropertyId, AccessUser user);
+	
+	/**
+	 * 新增属性
+	 * @param property
+	 * @param user
+	 */
+	public void saveProperty(Property property, AccessUser user);
+	
+	/**
+	 * 删除属性
+	 * @param propertyId
+	 */
+	public void deleteProperty(Long propertyId, Long coursePropertyId, AccessUser user);
+	
+	/**
+	 * 查询所有属性
+	 * @param coursePropertyId
+	 * @param user
+	 * @return
+	 */
+	public List<Property> findAll(Long coursePropertyId, AccessUser user);
+	
+	/**
+	 * 查询某个树下的子节点
+	 * @param property
+	 * @return
+	 */
+	public List<Property> findPropertySons(Property property);
+}

+ 103 - 0
cqb-paper/src/main/java/com/qmth/cqb/paper/service/impl/CoursePropertyServiceImpl.java

@@ -0,0 +1,103 @@
+package com.qmth.cqb.paper.service.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.persistence.criteria.Predicate;
+import javax.persistence.criteria.Root;
+import javax.persistence.criteria.Subquery;
+
+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.qmth.cqb.paper.dao.CoursePropertyRepo;
+import com.qmth.cqb.paper.dto.CoursePropertyDto;
+import com.qmth.cqb.paper.model.CourseProperty;
+import com.qmth.cqb.paper.service.CoursePropertyService;
+
+/**
+ * @describle 课程属性 coursePropertyServiceImpl
+ * @author weiwenhai
+ * @date   2017.11.2
+ */
+@Service("coursePropertyService")
+public class CoursePropertyServiceImpl implements CoursePropertyService{
+	
+	@Autowired
+	private CoursePropertyRepo coursePropertyRepo;
+
+	@Override
+	public List<CourseProperty> findAllByOrgId(Long orgId) {
+		List<CourseProperty> courseProperties = coursePropertyRepo.findByOrgId(orgId);
+		return courseProperties;
+	}
+
+	@Override
+	public void saveCourseProperty(CoursePropertyDto coursePropertyDto) throws Exception {
+		coursePropertyDto.setEnable("1");
+		CourseProperty courseProperty = coursePropertyRepo.findByNameAndOrgId(coursePropertyDto.getName(), coursePropertyDto.getOrgId());
+		if(courseProperty != null){
+			throw new Exception("课程属性名已经存在");
+		}
+		courseProperty = new CourseProperty(coursePropertyDto);
+		coursePropertyRepo.save(courseProperty);
+	}
+
+	@Override
+	public Page<CourseProperty> findAllByOrg(CoursePropertyDto coursePropertyDto, Pageable pageable) {
+		Specification<CourseProperty> specification = getSpecification(coursePropertyDto);
+		Page<CourseProperty> coursePropertyies = coursePropertyRepo.findAll(specification, pageable);
+		return coursePropertyies;
+	}
+
+	private Specification<CourseProperty> getSpecification(CoursePropertyDto coursePropertyDto) {
+		CourseProperty courseProperty = new CourseProperty(coursePropertyDto);
+		Specification<CourseProperty> specification = (root, query, cb) -> {
+		    List<Predicate> predicates = new ArrayList<>();
+		    if(!StringUtils.isEmpty(courseProperty.getOrgId())){
+		    	predicates.add(cb.equal(root.get("orgId"),courseProperty.getOrgId()));
+		    }
+		    if(!StringUtils.isEmpty(courseProperty.getName())){
+		    	predicates.add(cb.like(root.get("name"),"%"+courseProperty.getName()+"%"));
+		    }
+		    if(!StringUtils.isEmpty(courseProperty.getCourseId())){
+		    	predicates.add(cb.equal(root.get("courseId"),courseProperty.getCourseId()));
+		    }
+		    if(!StringUtils.isEmpty(courseProperty.getEnable())){
+		    	predicates.add(cb.equal(root.get("enable"),courseProperty.getEnable()));
+		    }
+		    return cb.and(predicates.toArray(new Predicate[predicates.size()]));
+		};
+		return specification;
+	}
+
+	@Override
+	public void openCourseProperty(Long id, Long orgId) {
+		CourseProperty courseProperty = coursePropertyRepo.findOne(id);
+		courseProperty.setEnable(true);
+		coursePropertyRepo.save(courseProperty);
+	}
+
+	@Override
+	public void closeCourseProperty(Long id, Long orgId) {
+		CourseProperty courseProperty = coursePropertyRepo.findOne(id);
+		courseProperty.setEnable(false);
+		coursePropertyRepo.save(courseProperty);
+	}
+
+	@Override
+	public List<CourseProperty> findAllByCourseId(Long courseId) {
+		List<CourseProperty> courseProperties = coursePropertyRepo.findByCourseId(courseId);
+		return courseProperties;
+	}
+}

+ 123 - 0
cqb-paper/src/main/java/com/qmth/cqb/paper/service/impl/PropertyServiceImpl.java

@@ -0,0 +1,123 @@
+package com.qmth.cqb.paper.service.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import cn.com.qmth.examcloud.common.uac.entity.AccessUser;
+
+import com.netflix.infix.lang.infix.antlr.EventFilterParser.null_predicate_return;
+import com.qmth.cqb.paper.assemble.PropertyAssembler;
+import com.qmth.cqb.paper.dao.PropertyRepo;
+import com.qmth.cqb.paper.dto.PropertyDto;
+import com.qmth.cqb.paper.model.Property;
+import com.qmth.cqb.paper.service.PropertyService;
+/**
+ * @describle 课程属性 coursePropertyServiceImpl
+ * @author weiwenhai
+ * @date   2017.11.8
+ */
+@Service("propertyService")
+public class PropertyServiceImpl implements PropertyService{
+	
+	@Autowired
+	private PropertyRepo propertyRepo;
+
+	@Override
+	public void saveProperty(List<PropertyDto> propertyDtos, AccessUser user) {
+		PropertyAssembler propertyAssembler = new PropertyAssembler();
+		for(int i=0;i<propertyDtos.size();i++){
+			//取到父类节点对象
+			Property property = propertyAssembler.toProperty(propertyDtos.get(i));
+			property.setNumber(i+1);
+			property.setOrgId(user.getRootOrgId());
+			property = propertyRepo.save(property);
+			List<Property> properties = propertyAssembler.toPropertySon(propertyDtos.get(i));
+			if(properties != null && properties.size()>0){
+				for(int j=0;j<properties.size();j++){
+					properties.get(j).setParentId(property.getId());
+					properties.get(j).setNumber(j+1);
+				}
+				propertyRepo.save(properties);
+			}
+		}
+	}
+
+	@Override
+	public List<PropertyDto> propertyDtos(Long coursePropertyId, AccessUser user) {
+		List<PropertyDto> propertyDtos = new ArrayList<PropertyDto>();
+		//查询所有父节点对象
+		List<Property> propertieParents = propertyRepo.findByOrgIdAndCoursePropertyIdAndParentIdOrderByNumber(user.getRootOrgId(), coursePropertyId, 0l);
+		if(propertieParents != null && propertieParents.size()>0){
+			for(Property property:propertieParents){
+				PropertyDto propertyDtoParent = new PropertyDto(property);
+				//查询所有子节点对象
+				List<Property> propertiesSons = propertyRepo.findByOrgIdAndCoursePropertyIdAndParentIdOrderByNumber(user.getRootOrgId(), coursePropertyId, property.getId());
+				if(propertiesSons != null && propertiesSons.size()>0){
+					List<PropertyDto> propertyDtosSons = new ArrayList<PropertyDto>();
+					for(Property property2:propertiesSons){
+						PropertyDto propertyDto2 = new PropertyDto(property2);
+						propertyDtosSons.add(propertyDto2);
+					}
+					propertyDtoParent.setPropertyDtos(propertyDtosSons);
+				}
+				propertyDtos.add(propertyDtoParent);
+			}
+		}
+		return propertyDtos;
+	}
+
+	@Override
+	public void saveProperty(Property property, AccessUser user) {
+		if(property.getId() == null){
+			Integer number = 0;
+			List<Property> propertieParents = propertyRepo.findByOrgIdAndCoursePropertyIdAndParentIdOrderByNumber(user.getRootOrgId(), property.getCoursePropertyId(), property.getParentId());
+			if(propertieParents != null && propertieParents.size()>0){
+				number = propertieParents.get(propertieParents.size()-1).getNumber();
+			}
+			property.setNumber(number+1);
+		}
+		property.setOrgId(user.getRootOrgId());
+		propertyRepo.save(property);
+	}
+
+	@Override
+	public void deleteProperty(Long propertyId, Long coursePropertyId, AccessUser user) {
+		//查询子节点对象
+		List<Property> properties = propertyRepo.findByOrgIdAndCoursePropertyIdAndParentIdOrderByNumber(user.getRootOrgId(), coursePropertyId, propertyId);
+		if(properties != null && properties.size()>0){
+			for(Property property:properties){
+				propertyRepo.delete(property);
+			}
+		}
+		propertyRepo.delete(propertyId);
+	}
+
+	@Override
+	public List<Property> findAll(Long coursePropertyId, AccessUser user) {
+		List<PropertyDto> propertyDtos = propertyDtos(coursePropertyId, user);
+		List<Property> properties = new ArrayList<Property>();
+		if(propertyDtos != null && propertyDtos.size() >0){
+			for(PropertyDto propertyDto:propertyDtos){
+				Property property = new Property(propertyDto);
+				properties.add(property);
+				if(propertyDto.getPropertyDtos() != null && propertyDto.getPropertyDtos().size() > 0){
+					for(PropertyDto propertyDtoSon:propertyDto.getPropertyDtos()){
+						Property propertySon = new Property(propertyDtoSon);
+						properties.add(propertySon);
+					}
+				}
+			}
+		}
+		return properties;
+	}
+
+	@Override
+	public List<Property> findPropertySons(Property property) {
+		List<Property> properySonsList = propertyRepo.findByParentIdOrderByNumber(property.getId());
+		return properySonsList;
+	}
+
+}

+ 118 - 0
cqb-paper/src/main/java/com/qmth/cqb/paper/web/CoursePropertyController.java

@@ -0,0 +1,118 @@
+package com.qmth.cqb.paper.web;
+
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+
+import io.swagger.annotations.ApiOperation;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.PageRequest;
+import org.springframework.data.domain.Pageable;
+import org.springframework.data.domain.Sort;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Controller;
+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.RequestParam;
+
+import cn.com.qmth.examcloud.common.uac.entity.AccessUser;
+
+import com.qmth.cqb.paper.dto.CoursePropertyDto;
+import com.qmth.cqb.paper.model.CourseProperty;
+import com.qmth.cqb.paper.service.CoursePropertyService;
+
+/**
+ * @describle 课程属性  coursePropertyController
+ * @author weiwenhai
+ * @date   2017.11.2
+ */
+@Controller
+@RequestMapping("${api_cqb}/")
+public class CoursePropertyController {
+
+	@Autowired
+	private CoursePropertyService coursePropertyService;
+	
+	@ApiOperation(value="根据orgId查询所有课程属性", notes="不带分页")
+	@GetMapping(value="/courseProperty/all")
+	public ResponseEntity<Object> findAllByOrg(HttpServletRequest request){
+		AccessUser accessUser = (AccessUser)request.getAttribute("accessUser");
+		if(accessUser != null){
+			List<CourseProperty> courseProperties = coursePropertyService.findAllByOrgId(accessUser.getRootOrgId());
+			return new ResponseEntity<Object>(courseProperties,HttpStatus.OK);
+		}
+		return new ResponseEntity<Object>(HttpStatus.NOT_FOUND);
+	}
+	
+	@ApiOperation(value="根据orgId查询所有课程属性", notes="带分页")
+	@GetMapping(value="/courseProperty/all/{curPage}/{pageSize}")
+	public ResponseEntity<Object> findAllByOrgId(@ModelAttribute CoursePropertyDto coursePropertyDto,
+												 @PathVariable Integer curPage,
+												 @PathVariable Integer pageSize,
+												 HttpServletRequest request){
+		 AccessUser accessUser = (AccessUser) request.getAttribute("accessUser");
+		 if(accessUser == null){
+			 return new ResponseEntity(HttpStatus.NOT_FOUND);
+		 }
+		 coursePropertyDto.setOrgId(accessUser.getRootOrgId());
+		 Page<CourseProperty> coursePropertiesPage = coursePropertyService.findAllByOrg(coursePropertyDto, new PageRequest(curPage - 1,pageSize));
+		 return new ResponseEntity<Object>(coursePropertiesPage,HttpStatus.OK);
+	}
+	
+	@ApiOperation(value="新增课程属性" ,notes="新增课程属性")
+	@PostMapping(value="/courseProperty/save")
+	public ResponseEntity<Object> saveCourseProperty(HttpServletRequest request,@RequestBody CoursePropertyDto coursePropertyDto){
+		AccessUser accessUser = (AccessUser)request.getAttribute("accessUser");
+		if(accessUser != null){
+			try {
+				coursePropertyDto.setOrgId(accessUser.getRootOrgId());
+				coursePropertyService.saveCourseProperty(coursePropertyDto);
+			} catch (Exception e) {
+				return new ResponseEntity<Object>(HttpStatus.INTERNAL_SERVER_ERROR);
+			}
+			return new ResponseEntity<Object>(HttpStatus.OK);
+		}
+		return new ResponseEntity<Object>(HttpStatus.NOT_FOUND);
+	}
+	
+	@ApiOperation(value="启用", notes="启用")
+	@PutMapping(value="/courseProperty/open/{id}")
+	public ResponseEntity<Object> openCourseProperty(HttpServletRequest request, @PathVariable Long id){
+		AccessUser accessUser = (AccessUser) request.getAttribute("accessUser");
+		if(accessUser != null){
+			coursePropertyService.openCourseProperty(id, accessUser.getRootOrgId());
+			return new ResponseEntity<Object>(HttpStatus.OK);
+		}
+		return new ResponseEntity<Object>(HttpStatus.NOT_FOUND);
+	}
+	
+	@ApiOperation(value="禁用", notes="禁用")
+	@PutMapping(value="/courseProperty/close/{id}")
+	public ResponseEntity<Object> closeCourseProperty(HttpServletRequest request, @PathVariable Long id){
+		AccessUser accessUser = (AccessUser) request.getAttribute("accessUser");
+		if(accessUser != null){
+			coursePropertyService.closeCourseProperty(id, accessUser.getRootOrgId());
+			return new ResponseEntity<Object>(HttpStatus.OK);
+		}
+		return new ResponseEntity<Object>(HttpStatus.NOT_FOUND);
+	}
+	
+	@ApiOperation(value="根据courseId查询所有课程属性", notes="不带分页")
+	@GetMapping(value="/courseProperty/all/{courseId}")
+	public ResponseEntity<Object> findAllByCourseId(HttpServletRequest request,@PathVariable Long courseId){
+		AccessUser accessUser = (AccessUser) request.getAttribute("accessUser");
+		if(accessUser != null){
+			List<CourseProperty> courseProperties = coursePropertyService.findAllByCourseId(courseId);
+			return new ResponseEntity<Object>(courseProperties,HttpStatus.OK);
+		}
+		return new ResponseEntity<Object>(HttpStatus.NOT_FOUND);
+	}
+}

+ 93 - 0
cqb-paper/src/main/java/com/qmth/cqb/paper/web/PropertyController.java

@@ -0,0 +1,93 @@
+package com.qmth.cqb.paper.web;
+
+import java.util.List;
+
+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.stereotype.Controller;
+import org.springframework.web.bind.annotation.DeleteMapping;
+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.PutMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import cn.com.qmth.examcloud.common.uac.entity.AccessUser;
+
+import com.qmth.cqb.paper.dto.PropertyDto;
+import com.qmth.cqb.paper.model.Property;
+import com.qmth.cqb.paper.service.PropertyService;
+
+/**
+ * @describle 属性 PropertyController
+ * @author weiwenhai
+ * @date   2017.11.8
+ */
+@Controller
+@RequestMapping("${api_cqb}/")
+public class PropertyController {
+
+	@Autowired
+	private PropertyService propertyService;
+	
+	@ApiOperation(value="新增属性", notes="新增属性")
+	@PostMapping(value="/property/save")
+	public ResponseEntity<Object> saveProperty(HttpServletRequest request, @RequestBody Property property){
+		AccessUser accessUser = (AccessUser)request.getAttribute("accessUser");
+		if(accessUser != null){
+			propertyService.saveProperty(property, accessUser);
+			return new ResponseEntity<Object>(HttpStatus.OK);
+		}
+		return new ResponseEntity<Object>(HttpStatus.NOT_FOUND);
+	}
+	
+	@ApiOperation(value="查询所有属性dto", notes="树形结构")
+	@GetMapping(value="/property/all/{coursePropertyId}")
+	public ResponseEntity<Object> findAllProperty(HttpServletRequest request, @PathVariable String coursePropertyId){
+		AccessUser accessUser = (AccessUser) request.getAttribute("accessUser");
+		 if(accessUser == null){
+			 return new ResponseEntity<Object>(HttpStatus.NOT_FOUND);
+		 }
+		 List<PropertyDto> propertyDtos = propertyService.propertyDtos(Long.parseLong(coursePropertyId), accessUser);
+		return new ResponseEntity<Object>(propertyDtos,HttpStatus.OK);
+	}
+	
+	@ApiOperation(value="更新属性", notes="更新属性")
+	@PutMapping(value="/property/save")
+	public ResponseEntity<Object> updateProperty(HttpServletRequest request, @RequestBody Property property){
+		AccessUser accessUser = (AccessUser)request.getAttribute("accessUser");
+		if(accessUser != null){
+			propertyService.saveProperty(property, accessUser);
+			return new ResponseEntity<Object>(HttpStatus.OK);
+		}
+		return new ResponseEntity<Object>(HttpStatus.NOT_FOUND);
+	}
+	
+	@ApiOperation(value="删除属性", notes="删除属性")
+	@DeleteMapping(value="/property/delete/{propertyId}/{coursePropertyId}")
+	public ResponseEntity<Object> deleteProperty(HttpServletRequest request, @PathVariable Long propertyId, @PathVariable Long coursePropertyId){
+		AccessUser accessUser = (AccessUser)request.getAttribute("accessUser");
+		if(accessUser != null){
+			propertyService.deleteProperty(propertyId, coursePropertyId, accessUser);
+			return new ResponseEntity<Object>(HttpStatus.OK);
+		}
+		return new ResponseEntity<Object>(HttpStatus.NOT_FOUND);
+	}
+	
+	@ApiOperation(value="查询所有属性", notes="查询所有属性")
+	@GetMapping(value="/property/{coursePropertyId}")
+	public ResponseEntity<Object> findAll(HttpServletRequest request, @PathVariable String coursePropertyId){
+		AccessUser accessUser = (AccessUser)request.getAttribute("accessUser");
+		if(accessUser != null){
+			List<Property> properties = propertyService.findAll(Long.parseLong(coursePropertyId), accessUser);
+			return new ResponseEntity<Object>(properties,HttpStatus.OK);
+		}
+		return new ResponseEntity<Object>(HttpStatus.NOT_FOUND);
+	}
+}