瀏覽代碼

重构代码,完善权限功能

宋悦 8 年之前
父節點
當前提交
7c8746df38
共有 35 個文件被更改,包括 1027 次插入852 次删除
  1. 9 20
      core-api/src/main/java/cn/com/qmth/examcloud/service/core/api/CourseApi.java
  2. 0 68
      core-api/src/main/java/cn/com/qmth/examcloud/service/core/api/LearnCenterApi.java
  3. 69 0
      core-api/src/main/java/cn/com/qmth/examcloud/service/core/api/OrgApi.java
  4. 0 68
      core-api/src/main/java/cn/com/qmth/examcloud/service/core/api/SchoolApi.java
  5. 12 17
      core-api/src/main/java/cn/com/qmth/examcloud/service/core/api/StudentApi.java
  6. 57 22
      core-api/src/main/java/cn/com/qmth/examcloud/service/core/api/UserApi.java
  7. 55 0
      core-api/src/main/java/cn/com/qmth/examcloud/service/core/api/UserRoleApi.java
  8. 3 65
      core-api/src/main/java/cn/com/qmth/examcloud/service/core/service/CourseService.java
  9. 0 88
      core-api/src/main/java/cn/com/qmth/examcloud/service/core/service/LearnCenterService.java
  10. 26 0
      core-api/src/main/java/cn/com/qmth/examcloud/service/core/service/OrgService.java
  11. 0 86
      core-api/src/main/java/cn/com/qmth/examcloud/service/core/service/SchoolService.java
  12. 11 46
      core-api/src/main/java/cn/com/qmth/examcloud/service/core/service/StudentService.java
  13. 14 0
      core-api/src/main/java/cn/com/qmth/examcloud/service/core/service/UserRoleService.java
  14. 75 40
      core-api/src/main/java/cn/com/qmth/examcloud/service/core/service/UserService.java
  15. 37 18
      core-domain/src/main/java/cn/com/qmth/examcloud/service/core/dao/Course.java
  16. 0 11
      core-domain/src/main/java/cn/com/qmth/examcloud/service/core/dao/LearnCenterRepo.java
  17. 149 0
      core-domain/src/main/java/cn/com/qmth/examcloud/service/core/dao/Org.java
  18. 0 11
      core-domain/src/main/java/cn/com/qmth/examcloud/service/core/dao/SchoolRepo.java
  19. 32 1
      core-domain/src/main/java/cn/com/qmth/examcloud/service/core/dao/Student.java
  20. 186 0
      core-domain/src/main/java/cn/com/qmth/examcloud/service/core/dao/User.java
  21. 0 11
      core-domain/src/main/java/cn/com/qmth/examcloud/service/core/dao/UserRepo.java
  22. 66 0
      core-domain/src/main/java/cn/com/qmth/examcloud/service/core/dao/UserRole.java
  23. 109 0
      core-domain/src/main/java/cn/com/qmth/examcloud/service/core/dto/UserInfo.java
  24. 0 99
      core-domain/src/main/java/cn/com/qmth/examcloud/service/core/entity/LearnCenter.java
  25. 0 88
      core-domain/src/main/java/cn/com/qmth/examcloud/service/core/entity/School.java
  26. 0 89
      core-domain/src/main/java/cn/com/qmth/examcloud/service/core/entity/User.java
  27. 8 0
      core-domain/src/main/java/cn/com/qmth/examcloud/service/core/enums/Gender.java
  28. 8 0
      core-domain/src/main/java/cn/com/qmth/examcloud/service/core/enums/UserScope.java
  29. 8 0
      core-domain/src/main/java/cn/com/qmth/examcloud/service/core/enums/UserType.java
  30. 9 0
      core-domain/src/main/java/cn/com/qmth/examcloud/service/core/params/UserParam.java
  31. 7 2
      core-domain/src/main/java/cn/com/qmth/examcloud/service/core/repo/CourseRepo.java
  32. 21 0
      core-domain/src/main/java/cn/com/qmth/examcloud/service/core/repo/OrgRepo.java
  33. 6 2
      core-domain/src/main/java/cn/com/qmth/examcloud/service/core/repo/StudentRepo.java
  34. 35 0
      core-domain/src/main/java/cn/com/qmth/examcloud/service/core/repo/UserRepo.java
  35. 15 0
      core-domain/src/main/java/cn/com/qmth/examcloud/service/core/repo/UserRoleRepo.java

+ 9 - 20
core-api/src/main/java/cn/com/qmth/examcloud/service/core/api/CourseApi.java

@@ -1,7 +1,7 @@
 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.repo.CourseRepo;
+import cn.com.qmth.examcloud.service.core.dao.Course;
 import cn.com.qmth.examcloud.service.core.service.CourseService;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -24,19 +24,7 @@ public class CourseApi {
     @Autowired
     CourseService courseService;
 
-    @ApiOperation(value="查询所有课程",notes="分页")
-    @GetMapping("/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("/all")
-    public ResponseEntity getAllCourse(@ModelAttribute Course courseCriteria){
-        return courseService.getAllCourse(courseCriteria);
-    }
-
-    @ApiOperation(value="查询所有课程",notes="不分页不带查询")
+    @ApiOperation(value="查询所有课程")
     @GetMapping
     public ResponseEntity getAllCourse(){
         return new ResponseEntity(courseRepo.findAll(), HttpStatus.OK);
@@ -44,25 +32,26 @@ public class CourseApi {
 
     @ApiOperation(value="按ID查询课程",notes="ID查询")
     @GetMapping("/{id}")
-    public ResponseEntity<Course> getCourseById(@PathVariable Long id){
-        return courseService.getCourseById(id);
+    public ResponseEntity getCourseById(@PathVariable Long id){
+        return new ResponseEntity(courseRepo.findById(id),HttpStatus.OK);
     }
 
     @ApiOperation(value="新增课程",notes="新增")
     @PostMapping
     public ResponseEntity addCourse(@RequestBody Course course){
-        return courseService.saveCourse(course);
+        return new ResponseEntity(courseRepo.save(course),HttpStatus.CREATED);
     }
 
     @ApiOperation(value="更新课程",notes="更新")
     @PutMapping
     public ResponseEntity updateCourse(@RequestBody Course course){
-        return courseService.saveCourse(course);
+        return new ResponseEntity(courseRepo.save(course),HttpStatus.OK);
     }
 
     @ApiOperation(value="按ID删除课程",notes="删除")
     @DeleteMapping("/{id}")
     public ResponseEntity deleteCourse(@PathVariable Long id){
-        return courseService.deleteCourse(id);
+        courseRepo.delete(id);
+        return new ResponseEntity(HttpStatus.OK);
     }
 }

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

@@ -1,68 +0,0 @@
-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.HttpStatus;
-import org.springframework.http.ResponseEntity;
-import org.springframework.web.bind.annotation.*;
-
-/**
- * 学校中心服务API
- * Created by songyue on 17/1/14.
- */
-@RestController
-@RequestMapping("${app.api.root}/learn_enter")
-public class LearnCenterApi {
-
-    @Autowired
-    LearnCenterRepo learnCenterRepo;
-
-    @Autowired
-    LearnCenterService learnCenterService;
-
-    @ApiOperation(value="查询所有学习中心",notes="分页")
-    @GetMapping("/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("/all")
-    public ResponseEntity getAllLearnCenter(@ModelAttribute LearnCenter learnCenterCriteria){
-        return learnCenterService.getAllLearnCenter(learnCenterCriteria);
-    }
-
-    @ApiOperation(value="查询所有学习中心",notes="不分页不带查询")
-    @GetMapping
-    public ResponseEntity getAllLearnCenter(){
-        return new ResponseEntity(learnCenterRepo.findAll(), HttpStatus.OK);
-    }
-
-    @ApiOperation(value="按ID查询学习中心",notes="ID查询")
-    @GetMapping("/{id}")
-    public ResponseEntity<LearnCenter> getLearnCenterById(@PathVariable Long id){
-        return learnCenterService.getLearnCenterById(id);
-    }
-
-    @ApiOperation(value="新增学习中心",notes="新增")
-    @PostMapping
-    public ResponseEntity addLearnCenter(@RequestBody LearnCenter learnCenter){
-        return learnCenterService.saveLearnCenter(learnCenter);
-    }
-
-    @ApiOperation(value="更新学习中心",notes="更新")
-    @PutMapping
-    public ResponseEntity updateLearnCenter(@RequestBody LearnCenter learnCenter){
-        return learnCenterService.saveLearnCenter(learnCenter);
-    }
-
-    @ApiOperation(value="按ID删除学习中心",notes="删除")
-    @DeleteMapping("/{id}")
-    public ResponseEntity deleteLearnCenter(@PathVariable Long id){
-        return learnCenterService.deleteLearnCenter(id);
-    }
-}

+ 69 - 0
core-api/src/main/java/cn/com/qmth/examcloud/service/core/api/OrgApi.java

@@ -0,0 +1,69 @@
+package cn.com.qmth.examcloud.service.core.api;
+
+import cn.com.qmth.examcloud.service.core.repo.OrgRepo;
+import cn.com.qmth.examcloud.service.core.dao.Org;
+import cn.com.qmth.examcloud.service.core.service.OrgService;
+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.*;
+
+/**
+ * 学校服务API
+ * Created by songyue on 17/1/14.
+ */
+@RestController
+@RequestMapping("${app.api.root}/org")
+public class OrgApi {
+
+    @Autowired
+    OrgRepo orgRepo;
+
+    @Autowired
+    OrgService orgService;
+
+    @ApiOperation(value="查询所有机构")
+    @GetMapping
+    public ResponseEntity getAllOrg(){
+        return new ResponseEntity(orgRepo.findAll(), HttpStatus.OK);
+    }
+
+    @ApiOperation(value="按ID查询机构",notes="ID查询")
+    @GetMapping("/{id}")
+    public ResponseEntity<Org> getOrgById(@PathVariable Long id){
+        return new ResponseEntity(orgRepo.findById(id),HttpStatus.OK);
+    }
+
+    @ApiOperation(value="按parentId查询下属机构",notes="下属机构查询")
+    @GetMapping("/sub/{parentId}")
+    public ResponseEntity<Org> getOrgByParentId(@PathVariable Long parentId){
+        return new ResponseEntity(orgRepo.findByParentId(parentId),HttpStatus.OK);
+    }
+
+    @ApiOperation(value="按rootId查询下属机构",notes="下属机构查询")
+    @GetMapping("/allSub/{rootId}")
+    public ResponseEntity<Org> getOrgByRootId(@PathVariable Long rootId){
+        return new ResponseEntity(orgRepo.findByRootId(rootId),HttpStatus.OK);
+    }
+
+    @ApiOperation(value="新增机构",notes="新增")
+    @PostMapping
+    public ResponseEntity addSchool(@RequestBody Org org){
+        return new ResponseEntity(orgRepo.save(org),HttpStatus.CREATED);
+    }
+
+    @ApiOperation(value="更新机构",notes="更新")
+    @PutMapping
+    public ResponseEntity updateSchool(@RequestBody Org org){
+        return new ResponseEntity(orgRepo.save(org),HttpStatus.OK);
+    }
+
+    @ApiOperation(value="按ID删除机构",notes="删除")
+    @DeleteMapping("/{id}")
+    public ResponseEntity deleteSchool(@PathVariable Long id){
+        orgRepo.delete(id);
+        return new ResponseEntity(HttpStatus.OK);
+    }
+}

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

@@ -1,68 +0,0 @@
-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.HttpStatus;
-import org.springframework.http.ResponseEntity;
-import org.springframework.web.bind.annotation.*;
-
-/**
- * 学校服务API
- * Created by songyue on 17/1/14.
- */
-@RestController
-@RequestMapping("${app.api.root}/school")
-public class SchoolApi {
-
-    @Autowired
-    SchoolRepo schoolRepo;
-
-    @Autowired
-    SchoolService schoolService;
-
-    @ApiOperation(value="查询所有学校",notes="分页")
-    @GetMapping("/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("/all")
-    public ResponseEntity getAllSchool(@ModelAttribute School schoolCriteria){
-        return schoolService.getAllSchool(schoolCriteria);
-    }
-
-    @ApiOperation(value="查询所有学校",notes="不分页不带查询")
-    @GetMapping
-    public ResponseEntity getAllSchool(){
-        return new ResponseEntity(schoolRepo.findAll(), HttpStatus.OK);
-    }
-
-    @ApiOperation(value="按ID查询学校",notes="ID查询")
-    @GetMapping("/{id}")
-    public ResponseEntity<School> getSchoolById(@PathVariable Long id){
-        return schoolService.getSchoolById(id);
-    }
-
-    @ApiOperation(value="新增学校",notes="新增")
-    @PostMapping
-    public ResponseEntity addSchool(@RequestBody School school){
-        return schoolService.saveSchool(school);
-    }
-
-    @ApiOperation(value="更新学校",notes="更新")
-    @PutMapping
-    public ResponseEntity updateSchool(@RequestBody School school){
-        return schoolService.saveSchool(school);
-    }
-
-    @ApiOperation(value="按ID删除学校",notes="删除")
-    @DeleteMapping("/{id}")
-    public ResponseEntity deleteSchool(@PathVariable Long id){
-        return schoolService.deleteSchool(id);
-    }
-}

+ 12 - 17
core-api/src/main/java/cn/com/qmth/examcloud/service/core/api/StudentApi.java

@@ -1,7 +1,7 @@
 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.repo.StudentRepo;
+import cn.com.qmth.examcloud.service.core.dao.Student;
 import cn.com.qmth.examcloud.service.core.service.StudentService;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -25,44 +25,39 @@ public class StudentApi {
     StudentService studentService;
 
     @ApiOperation(value="查询所有学生",notes="分页")
-    @GetMapping("/all/{curPage}/{pageSize}")
+    @GetMapping("/{curPage}/{pageSize}")
     public ResponseEntity getAllStudent(@ModelAttribute Student studentCriteria, @PathVariable Integer curPage, @PathVariable Integer pageSize){
-        return studentService.getAllStudent(studentCriteria,new PageRequest(curPage - 1,pageSize));
+        return new ResponseEntity(studentService.getAllStudent(studentCriteria,new PageRequest(curPage - 1,pageSize)),HttpStatus.OK);
     }
 
     @ApiOperation(value="查询所有学生",notes="不分页")
-    @GetMapping("/all")
-    public ResponseEntity getAllStudent(@ModelAttribute Student studentCriteria){
-        return studentService.getAllStudent(studentCriteria);
-    }
-
-    @ApiOperation(value="查询所有学生",notes="不分页不带查询")
     @GetMapping
-    public ResponseEntity getAllStudent(){
-        return new ResponseEntity(studentRepo.findAll(), HttpStatus.OK);
+    public ResponseEntity getAllStudent(@ModelAttribute Student studentCriteria){
+        return new ResponseEntity(studentService.getAllStudent(studentCriteria),HttpStatus.OK);
     }
 
     @ApiOperation(value="按ID查询学生",notes="ID查询")
     @GetMapping("/{id}")
-    public ResponseEntity<Student> getStudentById(@PathVariable Long id){
-        return studentService.getStudentById(id);
+    public ResponseEntity getStudentById(@PathVariable Long id){
+        return new ResponseEntity(studentRepo.findById(id),HttpStatus.OK);
     }
 
     @ApiOperation(value="新增学生",notes="新增")
     @PostMapping
     public ResponseEntity addStudent(@RequestBody Student student){
-        return studentService.saveStudent(student);
+        return new ResponseEntity(studentRepo.save(student),HttpStatus.CREATED);
     }
 
     @ApiOperation(value="更新学生",notes="更新")
     @PutMapping
     public ResponseEntity updateStudent(@RequestBody Student student){
-        return studentService.saveStudent(student);
+        return new ResponseEntity(studentRepo.save(student),HttpStatus.OK);
     }
 
     @ApiOperation(value="按ID删除学生",notes="删除")
     @DeleteMapping("/{id}")
     public ResponseEntity deleteStudent(@PathVariable Long id){
-        return studentService.deleteStudent(id);
+        studentRepo.delete(id);
+        return new ResponseEntity(HttpStatus.OK);
     }
 }

+ 57 - 22
core-api/src/main/java/cn/com/qmth/examcloud/service/core/api/UserApi.java

@@ -1,7 +1,8 @@
 package cn.com.qmth.examcloud.service.core.api;
 
-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.enums.UserType;
+import cn.com.qmth.examcloud.service.core.repo.UserRepo;
+import cn.com.qmth.examcloud.service.core.dao.User;
 import cn.com.qmth.examcloud.service.core.service.UserService;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -10,6 +11,8 @@ import org.springframework.http.HttpStatus;
 import org.springframework.http.ResponseEntity;
 import org.springframework.web.bind.annotation.*;
 
+import java.util.List;
+
 /**
  * 用户服务API
  * Created by songyue on 17/1/13.
@@ -24,45 +27,77 @@ public class UserApi {
     @Autowired
     UserRepo userRepo;
 
-    @ApiOperation(value="查询所有用户",notes="分页")
-    @GetMapping("/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("/all")
-    public ResponseEntity getAllUser(@ModelAttribute User userCriteria){
-        return userService.getAllUser(userCriteria);
-    }
 
-    @ApiOperation(value="查询所有用户",notes="不分页不带查询")
+    @ApiOperation(value="查询所有用户")
     @GetMapping
     public ResponseEntity getAllUser(){
         return new ResponseEntity(userRepo.findAll(), HttpStatus.OK);
     }
 
-    @ApiOperation(value="按ID查询用户",notes="ID查询")
+    @ApiOperation(value="按id查询用户",notes="id查询")
     @GetMapping("/{id}")
-    public ResponseEntity<User> getUserById(@PathVariable Long id){
-        return userService.getUserById(id);
+    public ResponseEntity getUserById(@PathVariable long id){
+        return new ResponseEntity(userRepo.findById(id), HttpStatus.OK);
+    }
+
+    @ApiOperation(value="按orgId查询用户",notes="机构id查询")
+    @GetMapping("/org/{orgId}")
+    public ResponseEntity getUserByOrgId(@PathVariable long orgId){
+        List<User> userList = userRepo.findByOrgIdAndType(orgId, UserType.NOT_STUDENT.name());
+        return new ResponseEntity(userList, HttpStatus.OK);
+    }
+
+    @ApiOperation(value="按rootOrgId查询用户",notes="根机构id查询")
+    @GetMapping("/rootOrg/{rootOrgId}")
+    public ResponseEntity getUserByRootOrgId(@PathVariable long rootOrgId){
+        List<User> userList = userRepo.findByRootOrgIdAndType(rootOrgId, UserType.NOT_STUDENT.name());
+        return new ResponseEntity(userList, HttpStatus.OK);
     }
 
     @ApiOperation(value="新增用户",notes="新增")
     @PostMapping
     public ResponseEntity addUser(@RequestBody User user){
-        return userService.saveUser(user);
+        return new ResponseEntity(userRepo.save(user), HttpStatus.CREATED);
     }
 
     @ApiOperation(value="更新用户",notes="更新")
     @PutMapping
     public ResponseEntity updateUser(@RequestBody User user){
-        return userService.saveUser(user);
+        return new ResponseEntity(userRepo.save(user), HttpStatus.OK);
     }
 
-    @ApiOperation(value="按ID删除用户",notes="删除")
+    @ApiOperation(value="重置用户密码",notes="重置密码")
+    @PutMapping("/resetPass/{id}")
+    public ResponseEntity resetPass(@PathVariable long id){
+        userService.initPassword(id);
+        return new ResponseEntity(HttpStatus.OK);
+    }
+
+    @ApiOperation(value="修改用户密码",notes="修改密码")
+    @PutMapping("/password")
+    public ResponseEntity updatePass(@RequestParam long userId,@RequestParam String password){
+        userRepo.updatePasswordById(userId,password);
+        return new ResponseEntity(HttpStatus.OK);
+    }
+
+    @ApiOperation(value="按id删除用户",notes="删除")
     @DeleteMapping("/{id}")
-    public ResponseEntity deleteUser(@PathVariable Long id){
-        return userService.deleteUser(id);
+    public ResponseEntity deleteUser(@PathVariable long id){
+        userRepo.delete(id);
+        return new ResponseEntity(HttpStatus.OK);
+    }
+
+    @ApiOperation(value="一般登录",notes="登录")
+    @PostMapping("/login")
+    public ResponseEntity login(@RequestParam String loginName,@RequestParam String password){
+        return userService.login(loginName,password);
+    }
+
+    @ApiOperation(value="二级登录",notes="二级登录")
+    @PostMapping("/login/{orgId}")
+    public ResponseEntity login(@PathVariable long orgId,
+                                @RequestParam String loginName,
+                                @RequestParam String password){
+        return userService.login(orgId,loginName,password);
     }
 }

+ 55 - 0
core-api/src/main/java/cn/com/qmth/examcloud/service/core/api/UserRoleApi.java

@@ -0,0 +1,55 @@
+package cn.com.qmth.examcloud.service.core.api;
+
+import cn.com.qmth.examcloud.service.core.dao.User;
+import cn.com.qmth.examcloud.service.core.dao.UserRole;
+import cn.com.qmth.examcloud.service.core.enums.UserType;
+import cn.com.qmth.examcloud.service.core.repo.UserRepo;
+import cn.com.qmth.examcloud.service.core.repo.UserRoleRepo;
+import cn.com.qmth.examcloud.service.core.service.UserService;
+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.*;
+
+import java.util.List;
+
+/**
+ * 用户角色服务API
+ * Created by songyue on 17/1/13.
+ */
+@RestController
+@RequestMapping("${app.api.root}/userRole")
+public class UserRoleApi {
+
+    @Autowired
+    UserService userRoleService;
+
+    @Autowired
+    UserRoleRepo userRoleRepo;
+
+    @ApiOperation(value="按userId查询用户角色",notes="id查询角色")
+    @GetMapping("/{userId}")
+    public ResponseEntity getRoleByUserId(@PathVariable Long userId){
+        return new ResponseEntity(userRoleRepo.findByUserId(userId), HttpStatus.OK);
+    }
+
+    @ApiOperation(value="新增用户角色",notes="新增角色")
+    @PostMapping
+    public ResponseEntity addUserRole(@RequestBody UserRole userRole){
+        return new ResponseEntity(userRoleRepo.save(userRole), HttpStatus.CREATED);
+    }
+
+    @ApiOperation(value="更新用户角色",notes="更新角色")
+    @PutMapping
+    public ResponseEntity updateUserRole(@RequestBody UserRole userRole){
+        return new ResponseEntity(userRoleRepo.save(userRole), HttpStatus.OK);
+    }
+
+    @ApiOperation(value="按id删除用户",notes="删除")
+    @DeleteMapping("/{id}")
+    public ResponseEntity deleteUserRole(@PathVariable Long id){
+        userRoleRepo.delete(id);
+        return new ResponseEntity(HttpStatus.OK);
+    }
+}

+ 3 - 65
core-api/src/main/java/cn/com/qmth/examcloud/service/core/service/CourseService.java

@@ -1,10 +1,11 @@
 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 cn.com.qmth.examcloud.service.core.repo.CourseRepo;
+import cn.com.qmth.examcloud.service.core.dao.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.Page;
 import org.springframework.data.domain.Pageable;
 import org.springframework.http.HttpStatus;
 import org.springframework.http.ResponseEntity;
@@ -21,67 +22,4 @@ 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);
-    }
 }

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

@@ -1,88 +0,0 @@
-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);
-    }
-
-
-}

+ 26 - 0
core-api/src/main/java/cn/com/qmth/examcloud/service/core/service/OrgService.java

@@ -0,0 +1,26 @@
+package cn.com.qmth.examcloud.service.core.service;
+
+import cn.com.qmth.examcloud.service.core.repo.OrgRepo;
+import cn.com.qmth.examcloud.service.core.dao.Org;
+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 OrgService {
+
+    @Autowired
+    OrgRepo orgRepo;
+
+
+}

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

@@ -1,86 +0,0 @@
-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);
-    }
-}

+ 11 - 46
core-api/src/main/java/cn/com/qmth/examcloud/service/core/service/StudentService.java

@@ -1,15 +1,18 @@
 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 cn.com.qmth.examcloud.service.core.repo.StudentRepo;
+import cn.com.qmth.examcloud.service.core.dao.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.Page;
 import org.springframework.data.domain.Pageable;
 import org.springframework.http.HttpStatus;
 import org.springframework.http.ResponseEntity;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+
 import static org.springframework.data.domain.ExampleMatcher.GenericPropertyMatchers.startsWith;
 
 /**
@@ -27,11 +30,10 @@ public class StudentService {
      * @param pageable
      * @return
      */
-    public ResponseEntity getAllStudent(Student studentCriteria, Pageable pageable){
-        ExampleMatcher exampleMatcher = ExampleMatcher.matching()
-                .withMatcher("name",startsWith());
+    public Page<Student> getAllStudent(Student studentCriteria, Pageable pageable){
+        ExampleMatcher exampleMatcher = ExampleMatcher.matching();
         Example<Student> studentExample = Example.of(studentCriteria, exampleMatcher);
-        return new ResponseEntity(studentRepo.findAll(studentExample,pageable), HttpStatus.OK);
+        return studentRepo.findAll(studentExample,pageable);
     }
 
     /**
@@ -39,47 +41,10 @@ public class StudentService {
      * @param studentCriteria
      * @return
      */
-    public ResponseEntity getAllStudent(Student studentCriteria){
-        ExampleMatcher exampleMatcher = ExampleMatcher.matching()
-                .withMatcher("name",startsWith());
+    public List<Student> getAllStudent(Student studentCriteria){
+        ExampleMatcher exampleMatcher = ExampleMatcher.matching();
         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 studentRepo.findAll(studentExample);
     }
 
-    /**
-     * 删除所有学生
-     * @return
-     */
-    public ResponseEntity deleteAllStudent(){
-        studentRepo.deleteAll();
-        return new ResponseEntity(HttpStatus.OK);
-    }
 }

+ 14 - 0
core-api/src/main/java/cn/com/qmth/examcloud/service/core/service/UserRoleService.java

@@ -0,0 +1,14 @@
+package cn.com.qmth.examcloud.service.core.service;
+
+import cn.com.qmth.examcloud.service.core.repo.UserRoleRepo;
+import org.springframework.beans.factory.annotation.Autowired;
+
+/**
+ * 用户角色服务类
+ * Created by songyue on 17/2/22.
+ */
+public class UserRoleService {
+
+    @Autowired
+    UserRoleRepo userRoleRepo;
+}

+ 75 - 40
core-api/src/main/java/cn/com/qmth/examcloud/service/core/service/UserService.java

@@ -1,7 +1,15 @@
 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 cn.com.qmth.examcloud.service.core.dao.Org;
+import cn.com.qmth.examcloud.service.core.dao.Student;
+import cn.com.qmth.examcloud.service.core.dto.UserInfo;
+import cn.com.qmth.examcloud.service.core.enums.UserType;
+import cn.com.qmth.examcloud.service.core.params.UserParam;
+import cn.com.qmth.examcloud.service.core.repo.OrgRepo;
+import cn.com.qmth.examcloud.service.core.repo.StudentRepo;
+import cn.com.qmth.examcloud.service.core.repo.UserRepo;
+import cn.com.qmth.examcloud.service.core.dao.User;
+import org.apache.commons.lang.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.Example;
 import org.springframework.data.domain.ExampleMatcher;
@@ -22,67 +30,94 @@ public class UserService {
     @Autowired
     UserRepo userRepo;
 
+    @Autowired
+    StudentRepo studentRepo;
+
+    @Autowired
+    OrgRepo orgRepo;
+
     /**
-     * 获取所有用户(分页)
-     * @param userCriteria
-     * @param pageable
-     * @return
+     * 初始化密码
+     * @param userId
      */
-    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);
+    public void initPassword(long userId){
+        User user = userRepo.findById(userId);
+        //根据用户类型采用不同的初始化策略
+        if(user.getType() == UserType.NOT_STUDENT){
+            //初始化为默认密码
+            user.setPassword(UserParam.DEFAULT_PASSWORD);
+
+        }else if(user.getType() == UserType.STUDENT){
+            //截取身份证后6位为学生登录密码
+            Student student = studentRepo.findByUserId(userId);
+            user.setPassword(StringUtils.substring(student.getIdentityNumber(),-6,-1));
+        }
+        userRepo.save(user);
     }
 
+
     /**
-     * 获取所有用户
-     * @param userCriteria
+     * 一般登录
+     * @param loginName
+     * @param password
      * @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);
+    public ResponseEntity login(String loginName,String password){
+        User user = userRepo.findByLoginName(loginName);
+        return loginProcess(user,password);
+
     }
 
     /**
-     * 按ID获取用户
-     * @param id
+     * 二级登录
+     * @param orgId
+     * @param loginName
+     * @param password
      * @return
      */
-    public ResponseEntity<User> getUserById(Long id){
-        return new ResponseEntity<User>(userRepo.findOne(id),HttpStatus.OK);
+    public ResponseEntity login(long orgId,String loginName,String password){
+        User user = userRepo.findByRootOrgIdAndLoginName(orgId,loginName);
+        return loginProcess(user,password);
     }
 
     /**
-     * 保存用户
+     * 登录处理
      * @param user
+     * @param password
      * @return
      */
-    public ResponseEntity saveUser(User user){
-        return new ResponseEntity(userRepo.save(user),HttpStatus.OK);
-    }
+    public ResponseEntity loginProcess(User user,String password){
+        if(user == null){
+            return new ResponseEntity("该用户不存在",HttpStatus.NOT_FOUND);
+        }else if(!user.getPassword().equals(password)){
+            return new ResponseEntity("密码错误",HttpStatus.EXPECTATION_FAILED);
+        }else{
+            String token = "";
+            return new ResponseEntity(getUserInfo(user,token),HttpStatus.OK);
+        }
 
-    /**
-     * 删除用户
-     * @param id
-     * @return
-     */
-    public ResponseEntity deleteUser(Long id){
-        userRepo.delete(id);
-        return new ResponseEntity(HttpStatus.OK);
     }
 
     /**
-     * 删除所有用户
+     * 获取用户信息DTO
+     * @param user
+     * @param token
      * @return
      */
-    public ResponseEntity deleteAllUser(){
-        userRepo.deleteAll();
-        return new ResponseEntity(HttpStatus.OK);
+    public UserInfo getUserInfo(User user,String token){
+        UserInfo userInfo = new UserInfo();
+        Org org = orgRepo.findById(user.getOrgId());
+        Org rootOrg = orgRepo.findById(user.getRootOrgId());
+        userInfo.setUserId(user.getId());
+        userInfo.setName(user.getName());
+        userInfo.setAvatar(user.getAvatar());
+        userInfo.setLoginName(user.getLoginName());
+        userInfo.setOrgName(org.getName());
+        userInfo.setRootOrgLogo(rootOrg.getLogo());
+        userInfo.setRootOrgName(rootOrg.getName());
+        userInfo.setToken(token);
+        userInfo.setType(user.getType().toString());
+        return userInfo;
     }
+
 }

+ 37 - 18
core-domain/src/main/java/cn/com/qmth/examcloud/service/core/entity/Course.java → core-domain/src/main/java/cn/com/qmth/examcloud/service/core/dao/Course.java

@@ -1,4 +1,6 @@
-package cn.com.qmth.examcloud.service.core.entity;
+package cn.com.qmth.examcloud.service.core.dao;
+
+import org.springframework.format.annotation.DateTimeFormat;
 
 import java.io.Serializable;
 import java.util.Date;
@@ -28,11 +30,24 @@ public class Course implements Serializable{
 	@NotNull
     private String name;
 
-	@Temporal(TemporalType.DATE)
+	@Temporal(value = TemporalType.DATE)
+	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+	@Column(columnDefinition = "default now()")
 	private Date createTime;
 
-	private Boolean isValid;
-    
+	@Temporal(value = TemporalType.DATE)
+	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+	@Column(columnDefinition = "default now()",updatable = true,insertable = false)
+	private Date updateTime;
+
+	@NotNull
+	@Column(columnDefinition = "default 1")
+	private Boolean enable;
+
+	public static long getSerialVersionUID() {
+		return serialVersionUID;
+	}
+
 	public Long getId() {
 		return id;
 	}
@@ -41,14 +56,6 @@ public class Course implements Serializable{
 		this.id = id;
 	}
 
-	public String getName() {
-		return name;
-	}
-
-	public void setName(String name) {
-		this.name = name;
-	}
-
 	public String getCode() {
 		return code;
 	}
@@ -57,8 +64,12 @@ public class Course implements Serializable{
 		this.code = code;
 	}
 
-	public static long getSerialVersionUID() {
-		return serialVersionUID;
+	public String getName() {
+		return name;
+	}
+
+	public void setName(String name) {
+		this.name = name;
 	}
 
 	public Date getCreateTime() {
@@ -69,12 +80,20 @@ public class Course implements Serializable{
 		this.createTime = createTime;
 	}
 
-	public Boolean getValid() {
-		return isValid;
+	public Date getUpdateTime() {
+		return updateTime;
+	}
+
+	public void setUpdateTime(Date updateTime) {
+		this.updateTime = updateTime;
+	}
+
+	public Boolean getEnable() {
+		return enable;
 	}
 
-	public void setValid(Boolean valid) {
-		isValid = valid;
+	public void setEnable(Boolean enable) {
+		this.enable = enable;
 	}
 
 	public Course() {

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

@@ -1,11 +0,0 @@
-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>,QueryByExampleExecutor<LearnCenter>{
-}

+ 149 - 0
core-domain/src/main/java/cn/com/qmth/examcloud/service/core/dao/Org.java

@@ -0,0 +1,149 @@
+package cn.com.qmth.examcloud.service.core.dao;
+
+import org.springframework.format.annotation.DateTimeFormat;
+
+import javax.persistence.*;
+import javax.validation.constraints.NotNull;
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * Created by songyue on 17/1/13.
+ */
+@Entity
+@Table(name = "ecs_org")
+public class Org implements Serializable{
+
+    private static final long serialVersionUID = -592353272256492483L;
+
+    @Id
+    @GeneratedValue
+    private Long id;
+
+    @NotNull
+    private Long rootId;
+
+    @NotNull
+    private Long parentId;
+
+    private Integer level;
+
+    @NotNull
+    private String name;
+
+    private String logo;
+
+    private String address;
+
+    @NotNull
+    private String apps;
+
+    @NotNull
+    @Column(columnDefinition = "default 1")
+    private Boolean enable;
+
+    @Temporal(value = TemporalType.DATE)
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @Column(columnDefinition = "default now()")
+    private Date createTime;
+
+    @Temporal(value = TemporalType.DATE)
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @Column(columnDefinition = "default now()",updatable = true,insertable = false)
+    private Date updateTime;
+
+    public static long getSerialVersionUID() {
+        return serialVersionUID;
+    }
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public Long getRootId() {
+        return rootId;
+    }
+
+    public void setRootId(Long rootId) {
+        this.rootId = rootId;
+    }
+
+    public Long getParentId() {
+        return parentId;
+    }
+
+    public void setParentId(Long parentId) {
+        this.parentId = parentId;
+    }
+
+    public Integer getLevel() {
+        return level;
+    }
+
+    public void setLevel(Integer level) {
+        this.level = level;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getLogo() {
+        return logo;
+    }
+
+    public void setLogo(String logo) {
+        this.logo = logo;
+    }
+
+    public String getAddress() {
+        return address;
+    }
+
+    public void setAddress(String address) {
+        this.address = address;
+    }
+
+    public String getApps() {
+        return apps;
+    }
+
+    public void setApps(String apps) {
+        this.apps = apps;
+    }
+
+    public Boolean getEnable() {
+        return enable;
+    }
+
+    public void setEnable(Boolean enable) {
+        this.enable = enable;
+    }
+
+    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 Org() {
+    }
+}

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

@@ -1,11 +0,0 @@
-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>,QueryByExampleExecutor<School>{
-}

+ 32 - 1
core-domain/src/main/java/cn/com/qmth/examcloud/service/core/entity/Student.java → core-domain/src/main/java/cn/com/qmth/examcloud/service/core/dao/Student.java

@@ -1,8 +1,11 @@
-package cn.com.qmth.examcloud.service.core.entity;
+package cn.com.qmth.examcloud.service.core.dao;
+
+import org.springframework.format.annotation.DateTimeFormat;
 
 import javax.persistence.*;
 import javax.validation.constraints.NotNull;
 import java.io.Serializable;
+import java.util.Date;
 
 /**
  * Created by songyue on 17/1/13.
@@ -24,8 +27,10 @@ public class Student implements Serializable {
 	@NotNull
 	private String name;
 
+	@NotNull
 	private String studentCode;
 
+	@NotNull
 	private String identityNumber;
 
 	private String examNumber;
@@ -38,6 +43,16 @@ public class Student implements Serializable {
 
 	private String remark;
 
+	@Temporal(value = TemporalType.DATE)
+	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+	@Column(columnDefinition = "default now()")
+	private Date createTime;
+
+	@Temporal(value = TemporalType.DATE)
+	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+	@Column(columnDefinition = "default now()",updatable = true,insertable = false)
+	private Date updateTime;
+
 	public static long getSerialVersionUID() {
 		return serialVersionUID;
 	}
@@ -122,6 +137,22 @@ public class Student implements Serializable {
 		this.name = name;
 	}
 
+	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 Student() {
 	}
 }

+ 186 - 0
core-domain/src/main/java/cn/com/qmth/examcloud/service/core/dao/User.java

@@ -0,0 +1,186 @@
+package cn.com.qmth.examcloud.service.core.dao;
+
+import cn.com.qmth.examcloud.service.core.enums.Gender;
+import cn.com.qmth.examcloud.service.core.enums.UserScope;
+import cn.com.qmth.examcloud.service.core.enums.UserType;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import javax.persistence.*;
+import javax.validation.constraints.NotNull;
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * Created by songyue on 17/1/13.
+ */
+@Entity
+@Table(name = "ecs_core_user")
+public class User implements Serializable{
+
+    private static final long serialVersionUID = 9190180279768027647L;
+
+    @Id
+    @GeneratedValue
+    private Long id;
+
+    private Long rootOrgId;
+
+    private Long orgId;
+
+    @NotNull
+    private String name;
+
+    @NotNull
+    private String loginName;
+
+    @NotNull
+    private String password;
+
+    private String mobile;
+
+    @Enumerated(EnumType.STRING)
+    private Gender gender;
+
+    @NotNull
+    @Enumerated(EnumType.STRING)
+    private UserScope scope;
+
+    private String avatar;
+
+    @NotNull
+    @Enumerated(EnumType.STRING)
+    private UserType type;
+
+    @NotNull
+    @Column(columnDefinition = "default 1")
+    private Boolean enable;
+
+    @Temporal(value = TemporalType.DATE)
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @Column(columnDefinition = "default now()")
+    private Date createTime;
+
+    @Temporal(value = TemporalType.DATE)
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @Column(columnDefinition = "default now()",updatable = true,insertable = false)
+    private Date updateTime;
+
+    public static long getSerialVersionUID() {
+        return serialVersionUID;
+    }
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public Long getRootOrgId() {
+        return rootOrgId;
+    }
+
+    public void setRootOrgId(Long rootOrgId) {
+        this.rootOrgId = rootOrgId;
+    }
+
+    public Long getOrgId() {
+        return orgId;
+    }
+
+    public void setOrgId(Long orgId) {
+        this.orgId = orgId;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getLoginName() {
+        return loginName;
+    }
+
+    public void setLoginName(String loginName) {
+        this.loginName = loginName;
+    }
+
+    public String getPassword() {
+        return password;
+    }
+
+    public void setPassword(String password) {
+        this.password = password;
+    }
+
+    public String getMobile() {
+        return mobile;
+    }
+
+    public void setMobile(String mobile) {
+        this.mobile = mobile;
+    }
+
+    public Gender getGender() {
+        return gender;
+    }
+
+    public void setGender(Gender gender) {
+        this.gender = gender;
+    }
+
+    public UserScope getScope() {
+        return scope;
+    }
+
+    public void setScope(UserScope scope) {
+        this.scope = scope;
+    }
+
+    public String getAvatar() {
+        return avatar;
+    }
+
+    public void setAvatar(String avatar) {
+        this.avatar = avatar;
+    }
+
+    public UserType getType() {
+        return type;
+    }
+
+    public void setType(UserType type) {
+        this.type = type;
+    }
+
+    public Boolean getEnable() {
+        return enable;
+    }
+
+    public void setEnable(Boolean enable) {
+        this.enable = enable;
+    }
+
+    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 User() {
+    }
+}

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

@@ -1,11 +0,0 @@
-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>,QueryByExampleExecutor<User>{
-}

+ 66 - 0
core-domain/src/main/java/cn/com/qmth/examcloud/service/core/dao/UserRole.java

@@ -0,0 +1,66 @@
+package cn.com.qmth.examcloud.service.core.dao;
+
+import org.springframework.data.annotation.Id;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Table;
+import java.io.Serializable;
+
+/**
+ * Created by songyue on 17/2/22.
+ */
+@Entity
+@Table(name = "ecs_core_user_role")
+public class UserRole implements Serializable{
+    private static final long serialVersionUID = -5202947216906275866L;
+
+    @Id
+    @GeneratedValue
+    private Long id;
+
+    private Long userId;
+
+    private String appCode;
+
+    private String roleCode;
+
+    public static long getSerialVersionUID() {
+        return serialVersionUID;
+    }
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public Long getUserId() {
+        return userId;
+    }
+
+    public void setUserId(Long userId) {
+        this.userId = userId;
+    }
+
+    public String getAppCode() {
+        return appCode;
+    }
+
+    public void setAppCode(String appCode) {
+        this.appCode = appCode;
+    }
+
+    public String getRoleCode() {
+        return roleCode;
+    }
+
+    public void setRoleCode(String roleCode) {
+        this.roleCode = roleCode;
+    }
+
+    public UserRole() {
+    }
+}

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

@@ -0,0 +1,109 @@
+package cn.com.qmth.examcloud.service.core.dto;
+
+import cn.com.qmth.examcloud.service.core.enums.UserType;
+
+import java.io.Serializable;
+
+/**
+ * Created by songyue on 17/2/22.
+ */
+public class UserInfo implements Serializable{
+    private static final long serialVersionUID = 7939545789907406883L;
+
+    private Long userId;
+
+    private String name;
+
+    private String loginName;
+
+    private String type;
+
+    private String token;
+
+    private String avatar;
+
+    private String orgName;
+
+    private String rootOrgName;
+
+    private String rootOrgLogo;
+
+    public static long getSerialVersionUID() {
+        return serialVersionUID;
+    }
+
+    public Long getUserId() {
+        return userId;
+    }
+
+    public void setUserId(Long userId) {
+        this.userId = userId;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getLoginName() {
+        return loginName;
+    }
+
+    public void setLoginName(String loginName) {
+        this.loginName = loginName;
+    }
+
+    public String getType() {
+        return type;
+    }
+
+    public void setType(String type) {
+        this.type = type;
+    }
+
+    public String getToken() {
+        return token;
+    }
+
+    public void setToken(String token) {
+        this.token = token;
+    }
+
+    public String getAvatar() {
+        return avatar;
+    }
+
+    public void setAvatar(String avatar) {
+        this.avatar = avatar;
+    }
+
+    public String getOrgName() {
+        return orgName;
+    }
+
+    public void setOrgName(String orgName) {
+        this.orgName = orgName;
+    }
+
+    public String getRootOrgName() {
+        return rootOrgName;
+    }
+
+    public void setRootOrgName(String rootOrgName) {
+        this.rootOrgName = rootOrgName;
+    }
+
+    public String getRootOrgLogo() {
+        return rootOrgLogo;
+    }
+
+    public void setRootOrgLogo(String rootOrgLogo) {
+        this.rootOrgLogo = rootOrgLogo;
+    }
+
+    public UserInfo() {
+    }
+}

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

@@ -1,99 +0,0 @@
-package cn.com.qmth.examcloud.service.core.entity;
-
-import javax.persistence.*;
-import javax.validation.constraints.NotNull;
-import java.io.Serializable;
-import java.util.Date;
-
-/**
- * Created by songyue on 17/1/13.
- */
-@Entity
-@Table(name = "ecs_core_learn_center")
-public class LearnCenter implements Serializable{
-    private static final long serialVersionUID = -6213266550004743423L;
-
-    @Id
-    @GeneratedValue
-    private Long id;
-
-    @NotNull
-    private String code;
-
-    @NotNull
-    private String name;
-
-    private Boolean isValid;
-
-    @ManyToOne
-    @JoinColumn(name = "schoolId")
-    private School school;
-
-    @Temporal(value = TemporalType.DATE)
-    private Date createTime;
-
-    private String remark;
-
-    public static long getSerialVersionUID() {
-        return serialVersionUID;
-    }
-
-    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 Boolean getIsValid() {
-        return isValid;
-    }
-
-    public void setIsValid(Boolean isvalid) {
-        this.isValid = isvalid;
-    }
-
-    public School getSchool() {
-        return school;
-    }
-
-    public void setSchool(School school) {
-        this.school = school;
-    }
-
-    public Date getCreateTime() {
-        return createTime;
-    }
-
-    public void setCreateTime(Date createTime) {
-        this.createTime = createTime;
-    }
-
-    public String getRemark() {
-        return remark;
-    }
-
-    public void setRemark(String remark) {
-        this.remark = remark;
-    }
-
-    public LearnCenter() {
-    }
-}

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

@@ -1,88 +0,0 @@
-package cn.com.qmth.examcloud.service.core.entity;
-
-import javax.persistence.*;
-import javax.validation.constraints.NotNull;
-import java.io.Serializable;
-import java.util.Date;
-
-/**
- * Created by songyue on 17/1/13.
- */
-@Entity
-@Table(name = "ecs_core_school")
-public class School implements Serializable{
-
-    private static final long serialVersionUID = -592353272256492483L;
-
-    @Id
-    @GeneratedValue
-    private Long id;
-
-    @NotNull
-    private String code;
-
-    @NotNull
-    private String name;
-
-    @Temporal(value = TemporalType.DATE)
-    private Date createTime;
-
-    private Boolean isValid;
-
-    private String remark;
-
-    public static long getSerialVersionUID() {
-        return serialVersionUID;
-    }
-
-    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 Date getCreateTime() {
-        return createTime;
-    }
-
-    public void setCreateTime(Date createTime) {
-        this.createTime = createTime;
-    }
-
-    public Boolean getIsValid() {
-        return isValid;
-    }
-
-    public void setIsValid(Boolean isvalid) {
-        this.isValid = isvalid;
-    }
-
-    public String getRemark() {
-        return remark;
-    }
-
-    public void setRemark(String remark) {
-        this.remark = remark;
-    }
-
-    public School() {
-    }
-}

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

@@ -1,89 +0,0 @@
-package cn.com.qmth.examcloud.service.core.entity;
-
-import javax.persistence.*;
-import javax.validation.constraints.NotNull;
-import java.io.Serializable;
-import java.util.Date;
-
-/**
- * Created by songyue on 17/1/13.
- */
-@Entity
-@Table(name = "ecs_core_user")
-public class User implements Serializable{
-
-    private static final long serialVersionUID = 9190180279768027647L;
-
-    @Id
-    @GeneratedValue
-    private Long id;
-
-    @NotNull
-    private String userName;
-
-    @NotNull
-    private String loginName;
-
-    @Temporal(value = TemporalType.DATE)
-    private Date createTime;
-
-    @NotNull
-    private String password;
-
-    private Boolean isValid;
-
-    public static long getSerialVersionUID() {
-        return serialVersionUID;
-    }
-
-    public Long getId() {
-        return id;
-    }
-
-    public void setId(Long id) {
-        this.id = id;
-    }
-
-    public String getUserName() {
-        return userName;
-    }
-
-    public void setUserName(String userName) {
-        this.userName = userName;
-    }
-
-    public String getLoginName() {
-        return loginName;
-    }
-
-    public void setLoginName(String loginName) {
-        this.loginName = loginName;
-    }
-
-    public Date getCreateTime() {
-        return createTime;
-    }
-
-    public void setCreateTime(Date createTime) {
-        this.createTime = createTime;
-    }
-
-    public String getPassword() {
-        return password;
-    }
-
-    public void setPassword(String password) {
-        this.password = password;
-    }
-
-    public Boolean getIsValid() {
-        return isValid;
-    }
-
-    public void setIsValid(Boolean isvalid) {
-        this.isValid = isvalid;
-    }
-
-    public User() {
-    }
-}

+ 8 - 0
core-domain/src/main/java/cn/com/qmth/examcloud/service/core/enums/Gender.java

@@ -0,0 +1,8 @@
+package cn.com.qmth.examcloud.service.core.enums;
+
+/**
+ * Created by songyue on 17/2/22.
+ */
+public enum Gender {
+    MAN,WOMAN
+}

+ 8 - 0
core-domain/src/main/java/cn/com/qmth/examcloud/service/core/enums/UserScope.java

@@ -0,0 +1,8 @@
+package cn.com.qmth.examcloud.service.core.enums;
+
+/**
+ * Created by songyue on 17/2/22.
+ */
+public enum UserScope {
+    ALL,ORG
+}

+ 8 - 0
core-domain/src/main/java/cn/com/qmth/examcloud/service/core/enums/UserType.java

@@ -0,0 +1,8 @@
+package cn.com.qmth.examcloud.service.core.enums;
+
+/**
+ * Created by songyue on 17/2/22.
+ */
+public enum UserType {
+    NOT_STUDENT,STUDENT
+}

+ 9 - 0
core-domain/src/main/java/cn/com/qmth/examcloud/service/core/params/UserParam.java

@@ -0,0 +1,9 @@
+package cn.com.qmth.examcloud.service.core.params;
+
+/**
+ * 用户相关常量
+ * Created by songyue on 17/2/22.
+ */
+public final class UserParam {
+    public static final String DEFAULT_PASSWORD = "123456";
+}

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

@@ -1,9 +1,14 @@
-package cn.com.qmth.examcloud.service.core.dao;
+package cn.com.qmth.examcloud.service.core.repo;
 
 import org.springframework.data.jpa.repository.JpaRepository;
 
-import cn.com.qmth.examcloud.service.core.entity.Course;
+import cn.com.qmth.examcloud.service.core.dao.Course;
 import org.springframework.data.repository.query.QueryByExampleExecutor;
 
 public interface CourseRepo extends JpaRepository<Course, Long>,QueryByExampleExecutor<Course> {
+
+    Course findById(long id);
+
+    Course findByCode(String code);
+
 }

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

@@ -0,0 +1,21 @@
+package cn.com.qmth.examcloud.service.core.repo;
+
+import cn.com.qmth.examcloud.service.core.dao.Org;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.repository.query.QueryByExampleExecutor;
+
+import java.util.List;
+
+/**
+ * Created by songyue on 17/1/13.
+ */
+public interface OrgRepo extends JpaRepository<Org,Long>,QueryByExampleExecutor<Org>{
+
+    Org findById(long id);
+
+    List<Org> findByRootId(long rootId);
+
+    List<Org> findByParentId(long parentId);
+
+    List<Org> findByLevel(int level);
+}

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

@@ -1,6 +1,6 @@
-package cn.com.qmth.examcloud.service.core.dao;
+package cn.com.qmth.examcloud.service.core.repo;
 
-import cn.com.qmth.examcloud.service.core.entity.Student;
+import cn.com.qmth.examcloud.service.core.dao.Student;
 import org.springframework.data.jpa.repository.JpaRepository;
 import org.springframework.data.repository.query.QueryByExampleExecutor;
 
@@ -8,4 +8,8 @@ import org.springframework.data.repository.query.QueryByExampleExecutor;
  * Created by songyue on 17/1/13.
  */
 public interface StudentRepo extends JpaRepository<Student,Long>,QueryByExampleExecutor<Student>{
+
+    Student findById(long id);
+
+    Student findByUserId(long userId);
 }

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

@@ -0,0 +1,35 @@
+package cn.com.qmth.examcloud.service.core.repo;
+
+import cn.com.qmth.examcloud.service.core.dao.User;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.Modifying;
+import org.springframework.data.jpa.repository.Query;
+import org.springframework.data.repository.query.Param;
+import org.springframework.data.repository.query.QueryByExampleExecutor;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.List;
+
+/**
+ * Created by songyue on 17/1/13.
+ */
+public interface UserRepo extends JpaRepository<User,Long>,QueryByExampleExecutor<User>{
+
+    User findById(long id);
+
+    User findByRootOrgIdAndLoginName(long rootOrgId,String loginName);
+
+    User findByLoginName(String loginName);
+
+    @Transactional
+    @Modifying
+    @Query("update User set password = :password where id = :id")
+    void updatePasswordById(@Param("id")long id,@Param("password")String password);
+
+    int countByLoginName(String loginName);
+
+    List<User> findByOrgIdAndType(long orgId,String userType);
+
+    List<User> findByRootOrgIdAndType(long rootOrgId,String userType);
+
+}

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

@@ -0,0 +1,15 @@
+package cn.com.qmth.examcloud.service.core.repo;
+
+import cn.com.qmth.examcloud.service.core.dao.UserRole;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.repository.query.QueryByExampleExecutor;
+
+import java.util.Set;
+
+/**
+ * Created by songyue on 17/2/22.
+ */
+public interface UserRoleRepo extends JpaRepository<UserRole,Long>,QueryByExampleExecutor<UserRole> {
+
+    Set<UserRole> findByUserId(long userId);
+}