浏览代码

增加API,增加修改领域模型

宋悦 8 年之前
父节点
当前提交
ac12cdd728
共有 19 个文件被更改,包括 757 次插入20 次删除
  1. 5 0
      core-api/pom.xml
  2. 61 0
      core-api/src/main/java/cn/com/qmth/examcloud/service/core/api/CourseApi.java
  3. 61 0
      core-api/src/main/java/cn/com/qmth/examcloud/service/core/api/LearnCenterApi.java
  4. 61 0
      core-api/src/main/java/cn/com/qmth/examcloud/service/core/api/SchoolApi.java
  5. 61 0
      core-api/src/main/java/cn/com/qmth/examcloud/service/core/api/StudentApi.java
  6. 53 4
      core-api/src/main/java/cn/com/qmth/examcloud/service/core/api/UserApi.java
  7. 0 10
      core-api/src/main/java/cn/com/qmth/examcloud/service/core/service/CoreService.java
  8. 87 0
      core-api/src/main/java/cn/com/qmth/examcloud/service/core/service/CourseService.java
  9. 88 0
      core-api/src/main/java/cn/com/qmth/examcloud/service/core/service/LearnCenterService.java
  10. 86 0
      core-api/src/main/java/cn/com/qmth/examcloud/service/core/service/SchoolService.java
  11. 85 0
      core-api/src/main/java/cn/com/qmth/examcloud/service/core/service/StudentService.java
  12. 88 0
      core-api/src/main/java/cn/com/qmth/examcloud/service/core/service/UserService.java
  13. 2 1
      core-domain/src/main/java/cn/com/qmth/examcloud/service/core/dao/CourseRepo.java
  14. 2 1
      core-domain/src/main/java/cn/com/qmth/examcloud/service/core/dao/LearnCenterRepo.java
  15. 2 1
      core-domain/src/main/java/cn/com/qmth/examcloud/service/core/dao/SchoolRepo.java
  16. 2 1
      core-domain/src/main/java/cn/com/qmth/examcloud/service/core/dao/StudentRepo.java
  17. 2 1
      core-domain/src/main/java/cn/com/qmth/examcloud/service/core/dao/UserRepo.java
  18. 10 0
      core-domain/src/main/java/cn/com/qmth/examcloud/service/core/entity/Student.java
  19. 1 1
      core-main/src/main/resources/application.properties

+ 5 - 0
core-api/pom.xml

@@ -12,6 +12,11 @@
     <artifactId>core-api</artifactId>
 
     <dependencies>
+        <dependency>
+            <groupId>cn.com.qmth.examcloud.service</groupId>
+            <artifactId>core-domain</artifactId>
+            <version>0.1.0</version>
+        </dependency>
         <dependency>
             <groupId>org.springframework.cloud</groupId>
             <artifactId>spring-cloud-starter-feign</artifactId>

+ 61 - 0
core-api/src/main/java/cn/com/qmth/examcloud/service/core/api/CourseApi.java

@@ -0,0 +1,61 @@
+package cn.com.qmth.examcloud.service.core.api;
+
+import cn.com.qmth.examcloud.service.core.dao.CourseRepo;
+import cn.com.qmth.examcloud.service.core.entity.Course;
+import cn.com.qmth.examcloud.service.core.service.CourseService;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.PageRequest;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.*;
+
+/**
+ * 课程服务API
+ * Created by songyue on 17/1/14.
+ */
+@RestController
+@RequestMapping("${app.api.root}")
+public class CourseApi {
+
+    @Autowired
+    CourseRepo courseRepo;
+
+    @Autowired
+    CourseService courseService;
+
+    @ApiOperation(value="查询所有课程",notes = "分页")
+    @GetMapping("/course/all/{curPage}/{pageSize}")
+    public ResponseEntity getAllCourse(@ModelAttribute Course courseCriteria, @PathVariable Integer curPage, @PathVariable Integer pageSize){
+        return courseService.getAllCourse(courseCriteria,new PageRequest(curPage - 1,pageSize));
+    }
+
+    @ApiOperation(value="查询所有课程",notes = "不分页")
+    @GetMapping("/course/all")
+    public ResponseEntity getAllCourse(@ModelAttribute Course courseCriteria){
+        return courseService.getAllCourse(courseCriteria);
+    }
+
+    @ApiOperation(value="按ID查询课程",notes = "ID查询")
+    @GetMapping("/course/{id}")
+    public ResponseEntity<Course> getCourseById(@PathVariable Long id){
+        return courseService.getCourseById(id);
+    }
+
+    @ApiOperation(value="新增课程",notes = "新增")
+    @PostMapping("/course")
+    public ResponseEntity addCourse(@ModelAttribute Course course){
+        return courseService.saveCourse(course);
+    }
+
+    @ApiOperation(value="更新课程",notes = "更新")
+    @PutMapping("/course")
+    public ResponseEntity updateCourse(@ModelAttribute Course course){
+        return courseService.saveCourse(course);
+    }
+
+    @ApiOperation(value="按ID删除课程",notes = "删除")
+    @DeleteMapping("/course/{id}")
+    public ResponseEntity deleteCourse(@PathVariable Long id){
+        return courseService.deleteCourse(id);
+    }
+}

+ 61 - 0
core-api/src/main/java/cn/com/qmth/examcloud/service/core/api/LearnCenterApi.java

@@ -0,0 +1,61 @@
+package cn.com.qmth.examcloud.service.core.api;
+
+import cn.com.qmth.examcloud.service.core.dao.LearnCenterRepo;
+import cn.com.qmth.examcloud.service.core.entity.LearnCenter;
+import cn.com.qmth.examcloud.service.core.service.LearnCenterService;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.PageRequest;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.*;
+
+/**
+ * 学校中心服务API
+ * Created by songyue on 17/1/14.
+ */
+@RestController
+@RequestMapping("${app.api.root}")
+public class LearnCenterApi {
+
+    @Autowired
+    LearnCenterRepo learnCenterRepo;
+
+    @Autowired
+    LearnCenterService learnCenterService;
+
+    @ApiOperation(value="查询所有学习中心",notes = "分页")
+    @GetMapping("/learn_enter/all/{curPage}/{pageSize}")
+    public ResponseEntity getAllLearnCenter(@ModelAttribute LearnCenter learnCenterCriteria, @PathVariable Integer curPage, @PathVariable Integer pageSize){
+        return learnCenterService.getAllLearnCenter(learnCenterCriteria,new PageRequest(curPage - 1,pageSize));
+    }
+
+    @ApiOperation(value="查询所有学习中心",notes = "不分页")
+    @GetMapping("/learn_enter/all")
+    public ResponseEntity getAllLearnCenter(@ModelAttribute LearnCenter learnCenterCriteria){
+        return learnCenterService.getAllLearnCenter(learnCenterCriteria);
+    }
+
+    @ApiOperation(value="按ID查询学习中心",notes = "ID查询")
+    @GetMapping("/learn_enter/{id}")
+    public ResponseEntity<LearnCenter> getLearnCenterById(@PathVariable Long id){
+        return learnCenterService.getLearnCenterById(id);
+    }
+
+    @ApiOperation(value="新增学习中心",notes = "新增")
+    @PostMapping("/learn_enter")
+    public ResponseEntity addLearnCenter(@ModelAttribute LearnCenter learnCenter){
+        return learnCenterService.saveLearnCenter(learnCenter);
+    }
+
+    @ApiOperation(value="更新学习中心",notes = "更新")
+    @PutMapping("/learn_enter")
+    public ResponseEntity updateLearnCenter(@ModelAttribute LearnCenter learnCenter){
+        return learnCenterService.saveLearnCenter(learnCenter);
+    }
+
+    @ApiOperation(value="按ID删除学习中心",notes = "删除")
+    @DeleteMapping("/learn_enter/{id}")
+    public ResponseEntity deleteLearnCenter(@PathVariable Long id){
+        return learnCenterService.deleteLearnCenter(id);
+    }
+}

+ 61 - 0
core-api/src/main/java/cn/com/qmth/examcloud/service/core/api/SchoolApi.java

@@ -0,0 +1,61 @@
+package cn.com.qmth.examcloud.service.core.api;
+
+import cn.com.qmth.examcloud.service.core.dao.SchoolRepo;
+import cn.com.qmth.examcloud.service.core.entity.School;
+import cn.com.qmth.examcloud.service.core.service.SchoolService;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.PageRequest;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.*;
+
+/**
+ * 学校服务API
+ * Created by songyue on 17/1/14.
+ */
+@RestController
+@RequestMapping("${app.api.root}")
+public class SchoolApi {
+
+    @Autowired
+    SchoolRepo schoolRepo;
+
+    @Autowired
+    SchoolService schoolService;
+
+    @ApiOperation(value="查询所有学校",notes = "分页")
+    @GetMapping("/school/all/{curPage}/{pageSize}")
+    public ResponseEntity getAllSchool(@ModelAttribute School schoolCriteria, @PathVariable Integer curPage, @PathVariable Integer pageSize){
+        return schoolService.getAllSchool(schoolCriteria,new PageRequest(curPage - 1,pageSize));
+    }
+
+    @ApiOperation(value="查询所有学校",notes = "不分页")
+    @GetMapping("/school/all")
+    public ResponseEntity getAllSchool(@ModelAttribute School schoolCriteria){
+        return schoolService.getAllSchool(schoolCriteria);
+    }
+
+    @ApiOperation(value="按ID查询学校",notes = "ID查询")
+    @GetMapping("/school/{id}")
+    public ResponseEntity<School> getSchoolById(@PathVariable Long id){
+        return schoolService.getSchoolById(id);
+    }
+
+    @ApiOperation(value="新增学校",notes = "新增")
+    @PostMapping("/school")
+    public ResponseEntity addSchool(@ModelAttribute School school){
+        return schoolService.saveSchool(school);
+    }
+
+    @ApiOperation(value="更新学校",notes = "更新")
+    @PutMapping("/school")
+    public ResponseEntity updateSchool(@ModelAttribute School school){
+        return schoolService.saveSchool(school);
+    }
+
+    @ApiOperation(value="按ID删除学校",notes = "删除")
+    @DeleteMapping("/school/{id}")
+    public ResponseEntity deleteSchool(@PathVariable Long id){
+        return schoolService.deleteSchool(id);
+    }
+}

+ 61 - 0
core-api/src/main/java/cn/com/qmth/examcloud/service/core/api/StudentApi.java

@@ -0,0 +1,61 @@
+package cn.com.qmth.examcloud.service.core.api;
+
+import cn.com.qmth.examcloud.service.core.dao.StudentRepo;
+import cn.com.qmth.examcloud.service.core.entity.Student;
+import cn.com.qmth.examcloud.service.core.service.StudentService;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.PageRequest;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.*;
+
+/**
+ * 学生服务API
+ * Created by songyue on 17/1/14.
+ */
+@RestController
+@RequestMapping("${app.api.root}")
+public class StudentApi {
+
+    @Autowired
+    StudentRepo studentRepo;
+
+    @Autowired
+    StudentService studentService;
+
+    @ApiOperation(value="查询所有学生",notes = "分页")
+    @GetMapping("/student/all/{curPage}/{pageSize}")
+    public ResponseEntity getAllStudent(@ModelAttribute Student studentCriteria, @PathVariable Integer curPage, @PathVariable Integer pageSize){
+        return studentService.getAllStudent(studentCriteria,new PageRequest(curPage - 1,pageSize));
+    }
+
+    @ApiOperation(value="查询所有学生",notes = "不分页")
+    @GetMapping("/student/all")
+    public ResponseEntity getAllStudent(@ModelAttribute Student studentCriteria){
+        return studentService.getAllStudent(studentCriteria);
+    }
+
+    @ApiOperation(value="按ID查询学生",notes = "ID查询")
+    @GetMapping("/student/{id}")
+    public ResponseEntity<Student> getStudentById(@PathVariable Long id){
+        return studentService.getStudentById(id);
+    }
+
+    @ApiOperation(value="新增学生",notes = "新增")
+    @PostMapping("/student")
+    public ResponseEntity addStudent(@ModelAttribute Student student){
+        return studentService.saveStudent(student);
+    }
+
+    @ApiOperation(value="更新学生",notes = "更新")
+    @PutMapping("/student")
+    public ResponseEntity updateStudent(@ModelAttribute Student student){
+        return studentService.saveStudent(student);
+    }
+
+    @ApiOperation(value="按ID删除学生",notes = "删除")
+    @DeleteMapping("/student/{id}")
+    public ResponseEntity deleteStudent(@PathVariable Long id){
+        return studentService.deleteStudent(id);
+    }
+}

+ 53 - 4
core-api/src/main/java/cn/com/qmth/examcloud/service/core/api/UserApi.java

@@ -1,12 +1,61 @@
-package cn.com.qmth.examcloud.service.core.api;
+package cn.com.qmth.usercloud.service.core.api;
 
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import cn.com.qmth.examcloud.service.core.dao.UserRepo;
+import cn.com.qmth.examcloud.service.core.entity.User;
+import cn.com.qmth.examcloud.service.core.service.UserService;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.PageRequest;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.*;
 
 /**
+ * 用户服务API
  * Created by songyue on 17/1/13.
  */
 @RestController
-@RequestMapping("${app.api.root}/user")
+@RequestMapping("${app.api.root}")
 public class UserApi {
+
+    @Autowired
+    UserService userService;
+
+    @Autowired
+    UserRepo userRepo;
+
+    @ApiOperation(value="查询所有用户",notes = "分页")
+    @GetMapping("/user/all/{curPage}/{pageSize}")
+    public ResponseEntity getAllUser(@ModelAttribute User userCriteria, @PathVariable Integer curPage, @PathVariable Integer pageSize){
+        return userService.getAllUser(userCriteria,new PageRequest(curPage - 1,pageSize));
+    }
+
+    @ApiOperation(value="查询所有用户",notes = "不分页")
+    @GetMapping("/user/all")
+    public ResponseEntity getAllUser(@ModelAttribute User userCriteria){
+        return userService.getAllUser(userCriteria);
+    }
+
+    @ApiOperation(value="按ID查询用户",notes = "ID查询")
+    @GetMapping("/user/{id}")
+    public ResponseEntity<User> getUserById(@PathVariable Long id){
+        return userService.getUserById(id);
+    }
+
+    @ApiOperation(value="新增用户",notes = "新增")
+    @PostMapping("/user")
+    public ResponseEntity addUser(@ModelAttribute User user){
+        return userService.saveUser(user);
+    }
+
+    @ApiOperation(value="更新用户",notes = "更新")
+    @PutMapping("/user")
+    public ResponseEntity updateUser(@ModelAttribute User user){
+        return userService.saveUser(user);
+    }
+
+    @ApiOperation(value="按ID删除用户",notes = "删除")
+    @DeleteMapping("/user/{id}")
+    public ResponseEntity deleteUser(@PathVariable Long id){
+        return userService.deleteUser(id);
+    }
 }

+ 0 - 10
core-api/src/main/java/cn/com/qmth/examcloud/service/core/service/CoreService.java

@@ -1,10 +0,0 @@
-package cn.com.qmth.examcloud.service.core.service;
-
-import org.springframework.stereotype.Service;
-
-/**
- * Created by songyue on 17/1/13.
- */
-@Service
-public class CoreService {
-}

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

@@ -0,0 +1,87 @@
+package cn.com.qmth.examcloud.service.core.service;
+
+import cn.com.qmth.examcloud.service.core.dao.CourseRepo;
+import cn.com.qmth.examcloud.service.core.entity.Course;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Example;
+import org.springframework.data.domain.ExampleMatcher;
+import org.springframework.data.domain.Pageable;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Service;
+
+import static org.springframework.data.domain.ExampleMatcher.GenericPropertyMatchers.startsWith;
+
+/**
+ * Created by songyue on 17/1/14.
+ */
+@Service
+public class CourseService {
+
+    @Autowired
+    CourseRepo courseRepo;
+
+    /**
+     * 获取所有课程(分页)
+     * @param courseCriteria
+     * @param pageable
+     * @return
+     */
+    public ResponseEntity getAllCourse(Course courseCriteria, Pageable pageable){
+        ExampleMatcher exampleMatcher = ExampleMatcher.matching()
+                .withMatcher("code",startsWith())
+                .withMatcher("name",startsWith());
+        Example<Course> courseExample = Example.of(courseCriteria, exampleMatcher);
+        return new ResponseEntity(courseRepo.findAll(courseExample,pageable), HttpStatus.OK);
+    }
+
+    /**
+     * 获取所有课程
+     * @param courseCriteria
+     * @return
+     */
+    public ResponseEntity getAllCourse(Course courseCriteria){
+        ExampleMatcher exampleMatcher = ExampleMatcher.matching()
+                .withMatcher("code",startsWith())
+                .withMatcher("name",startsWith());
+        Example<Course> courseExample = Example.of(courseCriteria, exampleMatcher);
+        return new ResponseEntity(courseRepo.findAll(courseExample), HttpStatus.OK);
+    }
+
+    /**
+     * 按ID获取课程
+     * @param id
+     * @return
+     */
+    public ResponseEntity<Course> getCourseById(Long id){
+        return new ResponseEntity<Course>(courseRepo.findOne(id),HttpStatus.OK);
+    }
+
+    /**
+     * 保存课程
+     * @param course
+     * @return
+     */
+    public ResponseEntity saveCourse(Course course){
+        return new ResponseEntity(courseRepo.save(course),HttpStatus.OK);
+    }
+
+    /**
+     * 删除课程
+     * @param id
+     * @return
+     */
+    public ResponseEntity deleteCourse(Long id){
+        courseRepo.delete(id);
+        return new ResponseEntity(HttpStatus.OK);
+    }
+
+    /**
+     * 删除所有课程
+     * @return
+     */
+    public ResponseEntity deleteAllCourse(){
+        courseRepo.deleteAll();
+        return new ResponseEntity(HttpStatus.OK);
+    }
+}

+ 88 - 0
core-api/src/main/java/cn/com/qmth/examcloud/service/core/service/LearnCenterService.java

@@ -0,0 +1,88 @@
+package cn.com.qmth.examcloud.service.core.service;
+
+import cn.com.qmth.examcloud.service.core.dao.LearnCenterRepo;
+import cn.com.qmth.examcloud.service.core.entity.LearnCenter;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Example;
+import org.springframework.data.domain.ExampleMatcher;
+import org.springframework.data.domain.Pageable;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Service;
+
+import static org.springframework.data.domain.ExampleMatcher.GenericPropertyMatchers.startsWith;
+
+/**
+ * Created by songyue on 17/1/14.
+ */
+@Service
+public class LearnCenterService {
+    @Autowired
+    LearnCenterRepo learnCenterRepo;
+
+    /**
+     * 获取所有学习中心(分页)
+     * @param learnCenterCriteria
+     * @param pageable
+     * @return
+     */
+    public ResponseEntity getAllLearnCenter(LearnCenter learnCenterCriteria, Pageable pageable){
+        ExampleMatcher exampleMatcher = ExampleMatcher.matching()
+                .withMatcher("code",startsWith())
+                .withMatcher("name",startsWith());
+        Example<LearnCenter> learnCenterExample = Example.of(learnCenterCriteria, exampleMatcher);
+        return new ResponseEntity(learnCenterRepo.findAll(learnCenterExample,pageable), HttpStatus.OK);
+    }
+
+    /**
+     * 获取所有学习中心
+     * @param learnCenterCriteria
+     * @return
+     */
+    public ResponseEntity getAllLearnCenter(LearnCenter learnCenterCriteria){
+        ExampleMatcher exampleMatcher = ExampleMatcher.matching()
+                .withMatcher("code",startsWith())
+                .withMatcher("name",startsWith());
+        Example<LearnCenter> learnCenterExample = Example.of(learnCenterCriteria, exampleMatcher);
+        return new ResponseEntity(learnCenterRepo.findAll(learnCenterExample), HttpStatus.OK);
+    }
+
+    /**
+     * 按ID获取学习中心
+     * @param id
+     * @return
+     */
+    public ResponseEntity<LearnCenter> getLearnCenterById(Long id){
+        return new ResponseEntity<LearnCenter>(learnCenterRepo.findOne(id),HttpStatus.OK);
+    }
+
+    /**
+     * 保存学习中心
+     * @param learnCenter
+     * @return
+     */
+    public ResponseEntity saveLearnCenter(LearnCenter learnCenter){
+        return new ResponseEntity(learnCenterRepo.save(learnCenter),HttpStatus.OK);
+    }
+
+    /**
+     * 删除学习中心
+     * @param id
+     * @return
+     */
+    public ResponseEntity deleteLearnCenter(Long id){
+        learnCenterRepo.delete(id);
+        return new ResponseEntity(HttpStatus.OK);
+    }
+
+    /**
+     * 删除所有学习中心
+     * @return
+     */
+    public ResponseEntity deleteAllLearnCenter(){
+        learnCenterRepo.deleteAll();
+        return new ResponseEntity(HttpStatus.OK);
+    }
+
+
+}

+ 86 - 0
core-api/src/main/java/cn/com/qmth/examcloud/service/core/service/SchoolService.java

@@ -0,0 +1,86 @@
+package cn.com.qmth.examcloud.service.core.service;
+
+import cn.com.qmth.examcloud.service.core.dao.SchoolRepo;
+import cn.com.qmth.examcloud.service.core.entity.School;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Example;
+import org.springframework.data.domain.ExampleMatcher;
+import org.springframework.data.domain.Pageable;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Service;
+
+import static org.springframework.data.domain.ExampleMatcher.GenericPropertyMatchers.startsWith;
+
+/**
+ * 学校服务类
+ * Created by songyue on 17/1/14.
+ */
+@Service
+public class SchoolService {
+
+    @Autowired
+    SchoolRepo schoolRepo;
+
+    /**
+     * 获取所有学校(分页)
+     * @param schoolCriteria
+     * @param pageable
+     * @return
+     */
+    public ResponseEntity getAllSchool(School schoolCriteria, Pageable pageable){
+        ExampleMatcher exampleMatcher = ExampleMatcher.matching()
+                .withMatcher("name",startsWith());
+        Example<School> schoolExample = Example.of(schoolCriteria, exampleMatcher);
+        return new ResponseEntity(schoolRepo.findAll(schoolExample,pageable), HttpStatus.OK);
+    }
+
+    /**
+     * 获取所有学校
+     * @param schoolCriteria
+     * @return
+     */
+    public ResponseEntity getAllSchool(School schoolCriteria){
+        ExampleMatcher exampleMatcher = ExampleMatcher.matching()
+                .withMatcher("name",startsWith());
+        Example<School> schoolExample = Example.of(schoolCriteria, exampleMatcher);
+        return new ResponseEntity(schoolRepo.findAll(schoolExample), HttpStatus.OK);
+    }
+
+    /**
+     * 按ID获取学校
+     * @param id
+     * @return
+     */
+    public ResponseEntity<School> getSchoolById(Long id){
+        return new ResponseEntity<School>(schoolRepo.findOne(id),HttpStatus.OK);
+    }
+
+    /**
+     * 保存学校
+     * @param school
+     * @return
+     */
+    public ResponseEntity saveSchool(School school){
+        return new ResponseEntity(schoolRepo.save(school),HttpStatus.OK);
+    }
+
+    /**
+     * 删除学校
+     * @param id
+     * @return
+     */
+    public ResponseEntity deleteSchool(Long id){
+        schoolRepo.delete(id);
+        return new ResponseEntity(HttpStatus.OK);
+    }
+
+    /**
+     * 删除所有学校
+     * @return
+     */
+    public ResponseEntity deleteAllSchool(){
+        schoolRepo.deleteAll();
+        return new ResponseEntity(HttpStatus.OK);
+    }
+}

+ 85 - 0
core-api/src/main/java/cn/com/qmth/examcloud/service/core/service/StudentService.java

@@ -0,0 +1,85 @@
+package cn.com.qmth.examcloud.service.core.service;
+
+import cn.com.qmth.examcloud.service.core.dao.StudentRepo;
+import cn.com.qmth.examcloud.service.core.entity.Student;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Example;
+import org.springframework.data.domain.ExampleMatcher;
+import org.springframework.data.domain.Pageable;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Service;
+
+import static org.springframework.data.domain.ExampleMatcher.GenericPropertyMatchers.startsWith;
+
+/**
+ * 学生服务类
+ * Created by songyue on 17/1/14.
+ */
+@Service
+public class StudentService {
+    @Autowired
+    StudentRepo studentRepo;
+
+    /**
+     * 获取所有学生(分页)
+     * @param studentCriteria
+     * @param pageable
+     * @return
+     */
+    public ResponseEntity getAllStudent(Student studentCriteria, Pageable pageable){
+        ExampleMatcher exampleMatcher = ExampleMatcher.matching()
+                .withMatcher("name",startsWith());
+        Example<Student> studentExample = Example.of(studentCriteria, exampleMatcher);
+        return new ResponseEntity(studentRepo.findAll(studentExample,pageable), HttpStatus.OK);
+    }
+
+    /**
+     * 获取所有学生
+     * @param studentCriteria
+     * @return
+     */
+    public ResponseEntity getAllStudent(Student studentCriteria){
+        ExampleMatcher exampleMatcher = ExampleMatcher.matching()
+                .withMatcher("name",startsWith());
+        Example<Student> studentExample = Example.of(studentCriteria, exampleMatcher);
+        return new ResponseEntity(studentRepo.findAll(studentExample), HttpStatus.OK);
+    }
+
+    /**
+     * 按ID获取学生
+     * @param id
+     * @return
+     */
+    public ResponseEntity<Student> getStudentById(Long id){
+        return new ResponseEntity<Student>(studentRepo.findOne(id),HttpStatus.OK);
+    }
+
+    /**
+     * 保存学生
+     * @param student
+     * @return
+     */
+    public ResponseEntity saveStudent(Student student){
+        return new ResponseEntity(studentRepo.save(student),HttpStatus.OK);
+    }
+
+    /**
+     * 删除学生
+     * @param id
+     * @return
+     */
+    public ResponseEntity deleteStudent(Long id){
+        studentRepo.delete(id);
+        return new ResponseEntity(HttpStatus.OK);
+    }
+
+    /**
+     * 删除所有学生
+     * @return
+     */
+    public ResponseEntity deleteAllStudent(){
+        studentRepo.deleteAll();
+        return new ResponseEntity(HttpStatus.OK);
+    }
+}

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

@@ -0,0 +1,88 @@
+package cn.com.qmth.examcloud.service.core.service;
+
+import cn.com.qmth.examcloud.service.core.dao.UserRepo;
+import cn.com.qmth.examcloud.service.core.entity.User;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Example;
+import org.springframework.data.domain.ExampleMatcher;
+import org.springframework.data.domain.Pageable;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Service;
+
+import static org.springframework.data.domain.ExampleMatcher.GenericPropertyMatchers.startsWith;
+
+/**
+ * 用户服务类
+ * Created by songyue on 17/1/13.
+ */
+@Service
+public class UserService {
+
+    @Autowired
+    UserRepo userRepo;
+
+    /**
+     * 获取所有用户(分页)
+     * @param userCriteria
+     * @param pageable
+     * @return
+     */
+    public ResponseEntity getAllUser(User userCriteria, Pageable pageable){
+        ExampleMatcher exampleMatcher = ExampleMatcher.matching()
+                .withMatcher("userName",startsWith())
+                .withMatcher("loginName",startsWith());
+        Example<User> userExample = Example.of(userCriteria, exampleMatcher);
+        return new ResponseEntity(userRepo.findAll(userExample,pageable), HttpStatus.OK);
+    }
+
+    /**
+     * 获取所有用户
+     * @param userCriteria
+     * @return
+     */
+    public ResponseEntity getAllUser(User userCriteria){
+        ExampleMatcher exampleMatcher = ExampleMatcher.matching()
+                .withMatcher("userName",startsWith())
+                .withMatcher("loginName",startsWith());
+        Example<User> userExample = Example.of(userCriteria, exampleMatcher);
+        return new ResponseEntity(userRepo.findAll(userExample), HttpStatus.OK);
+    }
+
+    /**
+     * 按ID获取用户
+     * @param id
+     * @return
+     */
+    public ResponseEntity<User> getUserById(Long id){
+        return new ResponseEntity<User>(userRepo.findOne(id),HttpStatus.OK);
+    }
+
+    /**
+     * 保存用户
+     * @param user
+     * @return
+     */
+    public ResponseEntity saveUser(User user){
+        return new ResponseEntity(userRepo.save(user),HttpStatus.OK);
+    }
+
+    /**
+     * 删除用户
+     * @param id
+     * @return
+     */
+    public ResponseEntity deleteUser(Long id){
+        userRepo.delete(id);
+        return new ResponseEntity(HttpStatus.OK);
+    }
+
+    /**
+     * 删除所有用户
+     * @return
+     */
+    public ResponseEntity deleteAllUser(){
+        userRepo.deleteAll();
+        return new ResponseEntity(HttpStatus.OK);
+    }
+}

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

@@ -3,6 +3,7 @@ package cn.com.qmth.examcloud.service.core.dao;
 import org.springframework.data.jpa.repository.JpaRepository;
 
 import cn.com.qmth.examcloud.service.core.entity.Course;
+import org.springframework.data.repository.query.QueryByExampleExecutor;
 
-public interface CourseRepo extends JpaRepository<Course, Long> {
+public interface CourseRepo extends JpaRepository<Course, Long>,QueryByExampleExecutor<Course> {
 }

+ 2 - 1
core-domain/src/main/java/cn/com/qmth/examcloud/service/core/dao/LearnCenterRepo.java

@@ -2,9 +2,10 @@ package cn.com.qmth.examcloud.service.core.dao;
 
 import cn.com.qmth.examcloud.service.core.entity.LearnCenter;
 import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.repository.query.QueryByExampleExecutor;
 
 /**
  * Created by songyue on 17/1/13.
  */
-public interface LearnCenterRepo extends JpaRepository<LearnCenter,Long>{
+public interface LearnCenterRepo extends JpaRepository<LearnCenter,Long>,QueryByExampleExecutor<LearnCenter>{
 }

+ 2 - 1
core-domain/src/main/java/cn/com/qmth/examcloud/service/core/dao/SchoolRepo.java

@@ -2,9 +2,10 @@ package cn.com.qmth.examcloud.service.core.dao;
 
 import cn.com.qmth.examcloud.service.core.entity.School;
 import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.repository.query.QueryByExampleExecutor;
 
 /**
  * Created by songyue on 17/1/13.
  */
-public interface SchoolRepo extends JpaRepository<School,Long>{
+public interface SchoolRepo extends JpaRepository<School,Long>,QueryByExampleExecutor<School>{
 }

+ 2 - 1
core-domain/src/main/java/cn/com/qmth/examcloud/service/core/dao/StudentRepo.java

@@ -2,9 +2,10 @@ package cn.com.qmth.examcloud.service.core.dao;
 
 import cn.com.qmth.examcloud.service.core.entity.Student;
 import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.repository.query.QueryByExampleExecutor;
 
 /**
  * Created by songyue on 17/1/13.
  */
-public interface StudentRepo extends JpaRepository<Student,Long>{
+public interface StudentRepo extends JpaRepository<Student,Long>,QueryByExampleExecutor<Student>{
 }

+ 2 - 1
core-domain/src/main/java/cn/com/qmth/examcloud/service/core/dao/UserRepo.java

@@ -2,9 +2,10 @@ package cn.com.qmth.examcloud.service.core.dao;
 
 import cn.com.qmth.examcloud.service.core.entity.User;
 import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.repository.query.QueryByExampleExecutor;
 
 /**
  * Created by songyue on 17/1/13.
  */
-public interface UserRepo extends JpaRepository<User,Long>{
+public interface UserRepo extends JpaRepository<User,Long>,QueryByExampleExecutor<User>{
 }

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

@@ -21,6 +21,8 @@ public class Student implements Serializable {
 	@JoinColumn(name = "userId")
 	private User user;
 
+	private String name;
+
 	private String studentCode;
 
 	private String identityNumber;
@@ -111,6 +113,14 @@ public class Student implements Serializable {
 		this.remark = remark;
 	}
 
+	public String getName() {
+		return name;
+	}
+
+	public void setName(String name) {
+		this.name = name;
+	}
+
 	public Student() {
 	}
 }

+ 1 - 1
core-main/src/main/resources/application.properties

@@ -22,7 +22,7 @@ spring.jpa.hibernate.ddl-auto=update
 spring.http.multipart.max-file-size=10Mb
 
 spring.application.name=ExamCloud-service-core
-server.port=8100
+server.port=8000
 eureka.client.serviceUrl.defaultZone=http://localhost:1111/eureka/
 app.api.root=/api/ecs_core