weiwenhai преди 7 години
родител
ревизия
9b8a6146f7

+ 22 - 5
core-api/src/main/java/cn/com/qmth/examcloud/service/core/api/OrgApi.java

@@ -76,14 +76,18 @@ public class OrgApi {
     }
 
     @ApiOperation(value = "查询机构不分页带查询", notes = "不分页带查询")
-    @GetMapping("/all")
-    public ResponseEntity getAllExam(@ModelAttribute Org orgCriteria,
+    @GetMapping("/alls/{type}")
+    public ResponseEntity getAllExam(@PathVariable String type,
                                      HttpServletRequest request) {
         AccessUser accessUser = (AccessUser) request.getAttribute("accessUser");
         if (accessUser != null) {
-            return new ResponseEntity(orgRepo.findAllByParentId(accessUser.getRootOrgId()), HttpStatus.OK);
+        	if(type.equals("school")){
+        		return new ResponseEntity(orgRepo.findAllSchoolByParentId(accessUser.getRootOrgId()), HttpStatus.OK);
+        	}else {
+        		return new ResponseEntity(orgRepo.findAllPrintByParentId(accessUser.getRootOrgId()), HttpStatus.OK);
+			}
         }
-        return new ResponseEntity(orgService.findAll(orgCriteria), HttpStatus.OK);
+        return new ResponseEntity(null, HttpStatus.OK);
     }
 
     @ApiOperation(value = "按ID查询机构", notes = "ID查询")
@@ -224,7 +228,8 @@ public class OrgApi {
     @ApiOperation(value = "按code查询机构(学习中心)", notes = "code查询")
     @GetMapping()
     public ResponseEntity getCourseByCode(@RequestParam Long parentId, @RequestParam String code) {
-        return new ResponseEntity(orgRepo.findFirstByParentIdAndCode(parentId, code), HttpStatus.OK);
+    	Org org = orgRepo.findFirstByParentIdAndCode(parentId, code);
+        return new ResponseEntity(org, HttpStatus.OK);
     }
 
     @ApiOperation(value = "按code查询机构(学习中心)", notes = "code查询")
@@ -241,4 +246,16 @@ public class OrgApi {
         }
 
     }
+    /**
+    @ApiOperation(value = "查询机构不分页带查询", notes = "不分页带查询")
+    @GetMapping("/all")
+    public ResponseEntity getAllExam(@ModelAttribute Org orgCriteria,
+                                     HttpServletRequest request) {
+        AccessUser accessUser = (AccessUser) request.getAttribute("accessUser");
+        if (accessUser != null) {
+            return new ResponseEntity(orgRepo.findAllByParentId(accessUser.getRootOrgId()), HttpStatus.OK);
+        }
+        return new ResponseEntity(orgService.findAll(orgCriteria), HttpStatus.OK);
+    }
+    */
 }

+ 292 - 294
core-api/src/main/java/cn/com/qmth/examcloud/service/core/api/UserApi.java

@@ -1,294 +1,292 @@
-package cn.com.qmth.examcloud.service.core.api;
-
-import io.swagger.annotations.ApiOperation;
-
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
-import javax.servlet.http.HttpServletRequest;
-
-import org.apache.commons.lang.StringEscapeUtils;
-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.util.StringUtils;
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.ModelAttribute;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
-
-import cn.com.qmth.examcloud.common.uac.annotation.Uac;
-import cn.com.qmth.examcloud.common.uac.entity.AccessUser;
-import cn.com.qmth.examcloud.common.uac.enums.RoleMeta;
-import cn.com.qmth.examcloud.common.uac.enums.UacPolicy;
-import cn.com.qmth.examcloud.common.util.ErrorMsg;
-import cn.com.qmth.examcloud.service.core.dto.UserInfo;
-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.service.UserService;
-
-/**
- * 用户服务API
- * Created by songyue on 17/1/13.
- */
-@RestController
-@RequestMapping("${app.api.root}/user")
-public class UserApi {
-
-    @Autowired
-    UserService userService;
-
-    @Autowired
-    UserRepo userRepo;
-
-
-    @ApiOperation(value = "查询所有用户", notes = "分页带查询")
-    @GetMapping("/all/{curPage}/{pageSize}")
-    public ResponseEntity getAllUser(@ModelAttribute User userCriteria,
-                                     @PathVariable Integer curPage,
-                                     @PathVariable Integer pageSize,
-                                     HttpServletRequest request) {
-
-        userCriteria.setType(UserType.NOT_STUDENT);
-        AccessUser accessUser = (AccessUser) request.getAttribute("accessUser");
-        if (accessUser != null) {
-            if (accessUser.getRootOrgId() == 0) {
-                return new ResponseEntity(userService.findOrgUser(userCriteria,
-                        new PageRequest(curPage - 1, pageSize)), HttpStatus.OK);
-            } else {
-                userCriteria.setRootOrgId(accessUser.getRootOrgId());
-            }
-        } else {
-            return new ResponseEntity(HttpStatus.NOT_FOUND);
-        }
-        return new ResponseEntity(userService.findAll(userCriteria,
-                new PageRequest(curPage - 1, pageSize)), HttpStatus.OK);
-    }
-
-    @ApiOperation(value = "按id查询用户", notes = "id查询")
-    @GetMapping("/{id}")
-    public ResponseEntity getUserById(@PathVariable long id) {
-        return new ResponseEntity(userRepo.findOne(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, HttpServletRequest request) {
-        AccessUser accessUser = (AccessUser) request.getAttribute("accessUser");
-        if (accessUser != null) {
-            if (accessUser.getRootOrgId() != 0) {
-                user.setRootOrgId(accessUser.getRootOrgId());
-            } else {
-                user.setRootOrgId(user.getOrgId());
-            }
-        } else {
-            return new ResponseEntity(HttpStatus.NOT_FOUND);
-        }
-        try {
-            return new ResponseEntity(userService.save(user), HttpStatus.CREATED);
-        } catch (Exception e) {
-            return new ResponseEntity(new ErrorMsg(e.getMessage()), HttpStatus.INTERNAL_SERVER_ERROR);
-        }
-    }
-
-    @ApiOperation(value = "更新用户", notes = "更新")
-    @PutMapping
-    public ResponseEntity updateUser(@RequestBody User user, HttpServletRequest request) {
-        AccessUser accessUser = (AccessUser) request.getAttribute("accessUser");
-        if (accessUser != null) {
-            if (accessUser.getRootOrgId() != 0) {
-                user.setRootOrgId(accessUser.getRootOrgId());
-            } else {
-                user.setRootOrgId(user.getOrgId());
-            }
-        } else {
-            return new ResponseEntity(HttpStatus.NOT_FOUND);
-        }
-        try {
-            return new ResponseEntity(userService.update(user.getId(), user), HttpStatus.OK);
-        } catch (Exception e) {
-            return new ResponseEntity(new ErrorMsg(e.getMessage()), HttpStatus.INTERNAL_SERVER_ERROR);
-        }
-    }
-
-    @ApiOperation(value = "重置用户密码", notes = "重置密码")
-    @PutMapping("/resetPass/{id}")
-    public ResponseEntity resetPass(@PathVariable String id) {
-        List<Long> ids = Stream.of(id.split(",")).map(s -> Long.parseLong(s.trim()))
-                .collect(Collectors.toList());
-        for (Long userId : ids) {
-            userService.initPassword(userId);
-        }
-        return new ResponseEntity(HttpStatus.OK);
-    }
-
-    @ApiOperation(value = "启用用户", notes = "启用用户")
-    @PutMapping("/enable/{ids}")
-    public ResponseEntity enableUser(@PathVariable String ids) {
-        List<Long> userIds = Stream.of(ids.split(",")).map(s -> Long.parseLong(s.trim()))
-                .collect(Collectors.toList());
-        for (Long userId : userIds) {
-            User user = userRepo.findOne(userId);
-            user.setEnable(true);
-            user.setUpdateTime(new Date());
-            userRepo.save(user);
-        }
-        return new ResponseEntity(HttpStatus.OK);
-    }
-
-    @ApiOperation(value = "禁用用户", notes = "禁用用户")
-    @PutMapping("/disable/{ids}")
-    public ResponseEntity disableUser(@PathVariable String ids) {
-        List<Long> userIds = Stream.of(ids.split(",")).map(s -> Long.parseLong(s.trim()))
-                .collect(Collectors.toList());
-        for (Long userId : userIds) {
-            User user = userRepo.findOne(userId);
-            user.setEnable(false);
-            user.setUpdateTime(new Date());
-            userRepo.save(user);
-        }
-        return new ResponseEntity(HttpStatus.OK);
-    }
-
-    @ApiOperation(value = "修改用户密码", notes = "修改密码")
-    @PutMapping("/password")
-    public ResponseEntity updatePass(@RequestParam long userId, @RequestParam String password) {
-        String realPassword = StringEscapeUtils.unescapeJavaScript(password);
-        userRepo.updatePasswordById(userId, realPassword);
-        return new ResponseEntity(HttpStatus.OK);
-    }
-
-    @ApiOperation(value = "修改用户密码", notes = "修改密码")
-    @PutMapping("/stu-password")
-    @Uac(roles = {RoleMeta.STUDENT}, policy = UacPolicy.IN)
-    public ResponseEntity stuPassword(@RequestParam("oldPassword") String oldPassword,
-                                      @RequestParam("newPassword") String newPassword,
-                                      HttpServletRequest request) {
-        AccessUser accessUser = (AccessUser) request.getAttribute("accessUser");
-//        String oldPassword = params.get("oldPassword");
-//        String newPassword = params.get("newPassword");
-        if (StringUtils.isEmpty(oldPassword) || StringUtils.isEmpty(newPassword)) {
-            return new ResponseEntity(new ErrorMsg("原密码不正确"), HttpStatus.BAD_REQUEST);
-        } else {
-            Long userId = accessUser.getUserId();
-            User user = userRepo.findOne(userId);
-            if (!oldPassword.equals(user.getPassword())) {
-
-                return new ResponseEntity(new ErrorMsg("原密码不正确"), HttpStatus.BAD_REQUEST);
-            }
-            userRepo.updatePasswordById(userId, newPassword);
-            return new ResponseEntity(HttpStatus.OK);
-        }
-    }
-
-    @ApiOperation(value = "按id删除用户", notes = "删除")
-    @DeleteMapping("/{ids}")
-    @Uac(roles = {RoleMeta.SUPER_ADMIN}, policy = UacPolicy.IN)
-    public ResponseEntity deleteUser(@PathVariable String ids) {
-        List<Long> userIds = Stream.of(ids.split(",")).map(s -> Long.parseLong(s.trim()))
-                .collect(Collectors.toList());
-        for (Long userId : userIds) {
-            userRepo.delete(userId);
-        }
-        return new ResponseEntity(HttpStatus.OK);
-    }
-
-    @ApiOperation(value = "一般登录", notes = "登录")
-    @PostMapping("/login")
-    public ResponseEntity login(@RequestParam String loginName,
-                                @RequestParam String password) {
-        try {
-            UserInfo userInfo = userService.login(loginName, password);
-            return new ResponseEntity(userInfo, HttpStatus.OK);
-        } catch (Exception e) {
-            return new ResponseEntity(new ErrorMsg(e.getMessage()), HttpStatus.INTERNAL_SERVER_ERROR);
-        }
-    }
-
-    @ApiOperation(value = "二级登录", notes = "二级登录")
-    @PostMapping("/login/{orgId}")
-    public ResponseEntity login(@PathVariable long orgId,
-                                @RequestParam String loginName,
-                                @RequestParam String password) {
-        try {
-            UserInfo userInfo = userService.login(orgId, loginName, password);
-            return new ResponseEntity(userInfo, HttpStatus.OK);
-        } catch (Exception e) {
-            return new ResponseEntity(new ErrorMsg(e.getMessage()), HttpStatus.INTERNAL_SERVER_ERROR);
-        }
-    }
-
-    @ApiOperation(value = "登出", notes = "登出")
-    @PostMapping("/logout")
-    public ResponseEntity logout(HttpServletRequest request) {
-        AccessUser accessUser = (AccessUser) request.getAttribute("accessUser");
-        userService.logout(accessUser);
-        return new ResponseEntity(HttpStatus.OK);
-    }
-
-    @ApiOperation(value = "查询评卷员", notes = "查询")
-    @GetMapping("/marker")
-    public ResponseEntity getMarker(HttpServletRequest request) {
-        AccessUser accessUser = (AccessUser) request.getAttribute("accessUser");
-        return new ResponseEntity(userService.getMarker(accessUser.getRootOrgId()), HttpStatus.OK);
-    }
-    
-    @ApiOperation(value = "新增评卷员", notes = "新增")
-    @PostMapping("/marker")
-    public ResponseEntity saveMarker(@RequestParam String loginName,@RequestParam String name,HttpServletRequest request) {
-        AccessUser accessUser = (AccessUser) request.getAttribute("accessUser");
-        return new ResponseEntity(userService.saveMarker(accessUser.getRootOrgId(),loginName,name), HttpStatus.OK);
-    }
-
-    @ApiOperation(value = "校验token", notes = "校验token")
-    @GetMapping("/checkToken")
-    public ResponseEntity checkToken(HttpServletRequest request) {
-        AccessUser accessUser = (AccessUser) request.getAttribute("accessUser");
-        if (accessUser == null) {
-            return new ResponseEntity(HttpStatus.NOT_FOUND);
-        } else if (StringUtils.isEmpty(accessUser.getToken())) {
-            return new ResponseEntity(HttpStatus.NOT_FOUND);
-        } else {
-            return new ResponseEntity(HttpStatus.OK);
-        }
-    }
-    
-    @ApiOperation(value="查询评卷员带分页",notes="查询评卷员带分页")
-    @GetMapping("/all/marker/{curPage}/{pageSize}")
-    public ResponseEntity getAllMark(@ModelAttribute User user,
-    								 @PathVariable Integer curPage,
-    								 @PathVariable Integer pageSize,
-    								 HttpServletRequest request){
-    	AccessUser accessUser = (AccessUser)request.getAttribute("accessUser");
-    	if(accessUser != null){
-    		user.setRootOrgId(accessUser.getRootOrgId());
-    		return new ResponseEntity(userService.getAllMaker(user,new PageRequest(curPage-1, pageSize)),HttpStatus.OK);
-    	}
-        return new ResponseEntity(HttpStatus.NOT_FOUND);
-    }
-}
+package cn.com.qmth.examcloud.service.core.api;
+
+import io.swagger.annotations.ApiOperation;
+
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.commons.lang.StringEscapeUtils;
+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.util.StringUtils;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.ModelAttribute;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import cn.com.qmth.examcloud.common.uac.annotation.Uac;
+import cn.com.qmth.examcloud.common.uac.entity.AccessUser;
+import cn.com.qmth.examcloud.common.uac.enums.RoleMeta;
+import cn.com.qmth.examcloud.common.uac.enums.UacPolicy;
+import cn.com.qmth.examcloud.common.util.ErrorMsg;
+import cn.com.qmth.examcloud.service.core.dto.UserInfo;
+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.service.UserService;
+
+/**
+ * 用户服务API
+ * Created by songyue on 17/1/13.
+ */
+@RestController
+@RequestMapping("${app.api.root}/user")
+public class UserApi {
+
+    @Autowired
+    UserService userService;
+
+    @Autowired
+    UserRepo userRepo;
+
+
+    @ApiOperation(value = "查询所有用户", notes = "分页带查询")
+    @GetMapping("/all/{curPage}/{pageSize}")
+    public ResponseEntity getAllUser(@ModelAttribute User userCriteria,
+                                     @PathVariable Integer curPage,
+                                     @PathVariable Integer pageSize,
+                                     HttpServletRequest request) {
+        AccessUser accessUser = (AccessUser) request.getAttribute("accessUser");
+        if (accessUser != null) {
+            if (accessUser.getRootOrgId() == 0) {
+                return new ResponseEntity(userService.findOrgUser(userCriteria,
+                        new PageRequest(curPage - 1, pageSize)), HttpStatus.OK);
+            } else {
+                userCriteria.setRootOrgId(accessUser.getRootOrgId());
+            }
+        } else {
+            return new ResponseEntity(HttpStatus.NOT_FOUND);
+        }
+        return new ResponseEntity(userService.findAll(userCriteria,
+                new PageRequest(curPage - 1, pageSize)), HttpStatus.OK);
+    }
+
+    @ApiOperation(value = "按id查询用户", notes = "id查询")
+    @GetMapping("/{id}")
+    public ResponseEntity getUserById(@PathVariable long id) {
+        return new ResponseEntity(userRepo.findOne(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, HttpServletRequest request) {
+        AccessUser accessUser = (AccessUser) request.getAttribute("accessUser");
+        if (accessUser != null) {
+            if (accessUser.getRootOrgId() != 0) {
+                user.setRootOrgId(accessUser.getRootOrgId());
+            } else {
+                user.setRootOrgId(user.getOrgId());
+            }
+        } else {
+            return new ResponseEntity(HttpStatus.NOT_FOUND);
+        }
+        try {
+            return new ResponseEntity(userService.save(user), HttpStatus.CREATED);
+        } catch (Exception e) {
+            return new ResponseEntity(new ErrorMsg(e.getMessage()), HttpStatus.INTERNAL_SERVER_ERROR);
+        }
+    }
+
+    @ApiOperation(value = "更新用户", notes = "更新")
+    @PutMapping
+    public ResponseEntity updateUser(@RequestBody User user, HttpServletRequest request) {
+        AccessUser accessUser = (AccessUser) request.getAttribute("accessUser");
+        if (accessUser != null) {
+            if (accessUser.getRootOrgId() != 0) {
+                user.setRootOrgId(accessUser.getRootOrgId());
+            } else {
+                user.setRootOrgId(user.getOrgId());
+            }
+        } else {
+            return new ResponseEntity(HttpStatus.NOT_FOUND);
+        }
+        try {
+            return new ResponseEntity(userService.update(user.getId(), user), HttpStatus.OK);
+        } catch (Exception e) {
+            return new ResponseEntity(new ErrorMsg(e.getMessage()), HttpStatus.INTERNAL_SERVER_ERROR);
+        }
+    }
+
+    @ApiOperation(value = "重置用户密码", notes = "重置密码")
+    @PutMapping("/resetPass/{id}")
+    public ResponseEntity resetPass(@PathVariable String id) {
+        List<Long> ids = Stream.of(id.split(",")).map(s -> Long.parseLong(s.trim()))
+                .collect(Collectors.toList());
+        for (Long userId : ids) {
+            userService.initPassword(userId);
+        }
+        return new ResponseEntity(HttpStatus.OK);
+    }
+
+    @ApiOperation(value = "启用用户", notes = "启用用户")
+    @PutMapping("/enable/{ids}")
+    public ResponseEntity enableUser(@PathVariable String ids) {
+        List<Long> userIds = Stream.of(ids.split(",")).map(s -> Long.parseLong(s.trim()))
+                .collect(Collectors.toList());
+        for (Long userId : userIds) {
+            User user = userRepo.findOne(userId);
+            user.setEnable(true);
+            user.setUpdateTime(new Date());
+            userRepo.save(user);
+        }
+        return new ResponseEntity(HttpStatus.OK);
+    }
+
+    @ApiOperation(value = "禁用用户", notes = "禁用用户")
+    @PutMapping("/disable/{ids}")
+    public ResponseEntity disableUser(@PathVariable String ids) {
+        List<Long> userIds = Stream.of(ids.split(",")).map(s -> Long.parseLong(s.trim()))
+                .collect(Collectors.toList());
+        for (Long userId : userIds) {
+            User user = userRepo.findOne(userId);
+            user.setEnable(false);
+            user.setUpdateTime(new Date());
+            userRepo.save(user);
+        }
+        return new ResponseEntity(HttpStatus.OK);
+    }
+
+    @ApiOperation(value = "修改用户密码", notes = "修改密码")
+    @PutMapping("/password")
+    public ResponseEntity updatePass(@RequestParam long userId, @RequestParam String password) {
+        String realPassword = StringEscapeUtils.unescapeJavaScript(password);
+        userRepo.updatePasswordById(userId, realPassword);
+        return new ResponseEntity(HttpStatus.OK);
+    }
+
+    @ApiOperation(value = "修改用户密码", notes = "修改密码")
+    @PutMapping("/stu-password")
+    @Uac(roles = {RoleMeta.STUDENT}, policy = UacPolicy.IN)
+    public ResponseEntity stuPassword(@RequestParam("oldPassword") String oldPassword,
+                                      @RequestParam("newPassword") String newPassword,
+                                      HttpServletRequest request) {
+        AccessUser accessUser = (AccessUser) request.getAttribute("accessUser");
+//        String oldPassword = params.get("oldPassword");
+//        String newPassword = params.get("newPassword");
+        if (StringUtils.isEmpty(oldPassword) || StringUtils.isEmpty(newPassword)) {
+            return new ResponseEntity(new ErrorMsg("原密码不正确"), HttpStatus.BAD_REQUEST);
+        } else {
+            Long userId = accessUser.getUserId();
+            User user = userRepo.findOne(userId);
+            if (!oldPassword.equals(user.getPassword())) {
+
+                return new ResponseEntity(new ErrorMsg("原密码不正确"), HttpStatus.BAD_REQUEST);
+            }
+            userRepo.updatePasswordById(userId, newPassword);
+            return new ResponseEntity(HttpStatus.OK);
+        }
+    }
+
+    @ApiOperation(value = "按id删除用户", notes = "删除")
+    @DeleteMapping("/{ids}")
+    @Uac(roles = {RoleMeta.SUPER_ADMIN}, policy = UacPolicy.IN)
+    public ResponseEntity deleteUser(@PathVariable String ids) {
+        List<Long> userIds = Stream.of(ids.split(",")).map(s -> Long.parseLong(s.trim()))
+                .collect(Collectors.toList());
+        for (Long userId : userIds) {
+            userRepo.delete(userId);
+        }
+        return new ResponseEntity(HttpStatus.OK);
+    }
+
+    @ApiOperation(value = "一般登录", notes = "登录")
+    @PostMapping("/login")
+    public ResponseEntity login(@RequestParam String loginName,
+                                @RequestParam String password) {
+        try {
+            UserInfo userInfo = userService.login(loginName, password);
+            return new ResponseEntity(userInfo, HttpStatus.OK);
+        } catch (Exception e) {
+            return new ResponseEntity(new ErrorMsg(e.getMessage()), HttpStatus.INTERNAL_SERVER_ERROR);
+        }
+    }
+
+    @ApiOperation(value = "二级登录", notes = "二级登录")
+    @PostMapping("/login/{orgId}")
+    public ResponseEntity login(@PathVariable long orgId,
+                                @RequestParam String loginName,
+                                @RequestParam String password) {
+        try {
+            UserInfo userInfo = userService.login(orgId, loginName, password);
+            return new ResponseEntity(userInfo, HttpStatus.OK);
+        } catch (Exception e) {
+            return new ResponseEntity(new ErrorMsg(e.getMessage()), HttpStatus.INTERNAL_SERVER_ERROR);
+        }
+    }
+
+    @ApiOperation(value = "登出", notes = "登出")
+    @PostMapping("/logout")
+    public ResponseEntity logout(HttpServletRequest request) {
+        AccessUser accessUser = (AccessUser) request.getAttribute("accessUser");
+        userService.logout(accessUser);
+        return new ResponseEntity(HttpStatus.OK);
+    }
+
+    @ApiOperation(value = "查询评卷员", notes = "查询")
+    @GetMapping("/marker")
+    public ResponseEntity getMarker(HttpServletRequest request) {
+        AccessUser accessUser = (AccessUser) request.getAttribute("accessUser");
+        return new ResponseEntity(userService.getMarker(accessUser.getRootOrgId()), HttpStatus.OK);
+    }
+    
+    @ApiOperation(value = "新增评卷员", notes = "新增")
+    @PostMapping("/marker")
+    public ResponseEntity saveMarker(@RequestParam String loginName,@RequestParam String name,HttpServletRequest request) {
+        AccessUser accessUser = (AccessUser) request.getAttribute("accessUser");
+        return new ResponseEntity(userService.saveMarker(accessUser.getRootOrgId(),loginName,name), HttpStatus.OK);
+    }
+
+    @ApiOperation(value = "校验token", notes = "校验token")
+    @GetMapping("/checkToken")
+    public ResponseEntity checkToken(HttpServletRequest request) {
+        AccessUser accessUser = (AccessUser) request.getAttribute("accessUser");
+        if (accessUser == null) {
+            return new ResponseEntity(HttpStatus.NOT_FOUND);
+        } else if (StringUtils.isEmpty(accessUser.getToken())) {
+            return new ResponseEntity(HttpStatus.NOT_FOUND);
+        } else {
+            return new ResponseEntity(HttpStatus.OK);
+        }
+    }
+    
+    @ApiOperation(value="查询评卷员带分页",notes="查询评卷员带分页")
+    @GetMapping("/all/marker/{curPage}/{pageSize}")
+    public ResponseEntity getAllMark(@ModelAttribute User user,
+    								 @PathVariable Integer curPage,
+    								 @PathVariable Integer pageSize,
+    								 HttpServletRequest request){
+    	AccessUser accessUser = (AccessUser)request.getAttribute("accessUser");
+    	if(accessUser != null){
+    		user.setRootOrgId(accessUser.getRootOrgId());
+    		return new ResponseEntity(userService.getAllMaker(user,new PageRequest(curPage-1, pageSize)),HttpStatus.OK);
+    	}
+        return new ResponseEntity(HttpStatus.NOT_FOUND);
+    }
+}

+ 85 - 73
core-api/src/main/java/cn/com/qmth/examcloud/service/core/api/UserRoleApi.java

@@ -1,73 +1,85 @@
-package cn.com.qmth.examcloud.service.core.api;
-
-import cn.com.qmth.examcloud.service.core.entity.User;
-import cn.com.qmth.examcloud.service.core.entity.UserRole;
-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.UserRoleService;
-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.*;
-
-/**
- * 用户角色服务API
- * Created by songyue on 17/1/13.
- */
-@RestController
-@RequestMapping("${app.api.root}/userRole")
-public class UserRoleApi {
-
-    @Autowired
-    UserRoleService userRoleService;
-
-    @Autowired
-    UserRoleRepo userRoleRepo;
-
-    @Autowired
-    UserRepo userRepo;
-
-    @ApiOperation(value="获取全部角色",notes="获取全部角色")
-    @GetMapping("/all")
-    public ResponseEntity getAllRoles(){
-        return new ResponseEntity(userRoleService.findAllRoles(), HttpStatus.OK);
-    }
-
-    @ApiOperation(value="获取评卷角色",notes="获取评卷角色")
-    @GetMapping("/marker")
-    public ResponseEntity getMarkerRoles(){
-        return new ResponseEntity(userRoleService.findMarkerRoles(), HttpStatus.OK);
-    }
-
-    @ApiOperation(value="获取非评卷角色",notes="获取非评卷角色")
-    @GetMapping("/nonMarker")
-    public ResponseEntity getNonMarkerRoles(){
-        return new ResponseEntity(userRoleService.findNonMarkerRoles(), HttpStatus.OK);
-    }
-
-    @ApiOperation(value="获取管理员角色",notes="获取管理员角色")
-    @GetMapping("/admin")
-    public ResponseEntity getAdminRoles(){
-        return new ResponseEntity(userRoleService.findAdminRoles(), 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);
-    }
-}
+package cn.com.qmth.examcloud.service.core.api;
+
+import cn.com.qmth.examcloud.service.core.entity.User;
+import cn.com.qmth.examcloud.service.core.entity.UserRole;
+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.UserRoleService;
+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.*;
+
+/**
+ * 用户角色服务API
+ * Created by songyue on 17/1/13.
+ */
+@RestController
+@RequestMapping("${app.api.root}/userRole")
+public class UserRoleApi {
+
+    @Autowired
+    UserRoleService userRoleService;
+
+    @Autowired
+    UserRoleRepo userRoleRepo;
+
+    @Autowired
+    UserRepo userRepo;
+
+    @ApiOperation(value="获取全部角色",notes="获取全部角色")
+    @GetMapping("/all")
+    public ResponseEntity getAllRoles(){
+        return new ResponseEntity(userRoleService.findAllRoles(), HttpStatus.OK);
+    }
+
+    @ApiOperation(value="获取评卷角色",notes="获取评卷角色")
+    @GetMapping("/marker")
+    public ResponseEntity getMarkerRoles(){
+        return new ResponseEntity(userRoleService.findMarkerRoles(), HttpStatus.OK);
+    }
+
+    @ApiOperation(value="获取非评卷角色",notes="获取非评卷角色")
+    @GetMapping("/nonMarker")
+    public ResponseEntity getNonMarkerRoles(){
+        return new ResponseEntity(userRoleService.findNonMarkerRoles(), HttpStatus.OK);
+    }
+
+    @ApiOperation(value="获取管理员角色",notes="获取管理员角色")
+    @GetMapping("/admin")
+    public ResponseEntity getAdminRoles(){
+        return new ResponseEntity(userRoleService.findAdminRoles(), 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);
+    }
+    
+    @ApiOperation(value="获取印刷阅卷角色",notes="获取印刷阅卷角色")
+    @GetMapping("/qmther")
+    public ResponseEntity getPrinterRoles(){
+        return new ResponseEntity(userRoleService.findQmthRoles(), HttpStatus.OK);
+    }
+    
+    @ApiOperation(value="获取学校机构角色",notes="获取学校机构角色")
+    @GetMapping("/school")
+    public ResponseEntity<Object> getSchoolRoles(){
+    	return new ResponseEntity<Object>(userRoleService.findSchoolRoles(),HttpStatus.OK);
+    }
+}

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

@@ -6,21 +6,30 @@ import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
 
+import javax.persistence.criteria.Predicate;
+import javax.persistence.criteria.Root;
+import javax.persistence.criteria.Subquery;
+
 import cn.com.qmth.examcloud.service.core.dto.OrgDto;
+import cn.com.qmth.examcloud.service.core.entity.Course;
+import cn.com.qmth.examcloud.service.core.entity.CourseSpeciatly;
 import cn.com.qmth.examcloud.service.core.entity.ExamSite;
 import cn.com.qmth.examcloud.service.core.entity.UserRole;
+import cn.com.qmth.examcloud.service.core.enums.OrgType;
 import cn.com.qmth.examcloud.service.core.enums.UserScope;
 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.ExamSiteRepo;
 import cn.com.qmth.examcloud.service.core.repo.memory.OrgMemRepo;
 import cn.com.qmth.examcloud.service.core.service.sync.DataSendService;
+
 import org.apache.commons.lang3.StringUtils;
 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.data.jpa.domain.Specification;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -188,6 +197,11 @@ public class OrgService {
 	}
 
 	public Page<Org> findAll(Org orgCriteria, Pageable pageable) {
+		if(orgCriteria.getType() == null){
+			Specification<Org> specification = getSpecification(orgCriteria);
+			return orgRepo.findAll(specification,pageable);
+		}
+		//orgCriteria.setType(OrgType.SCHOOL);
 		ExampleMatcher exampleMatcher = ExampleMatcher.matching()
 				.withMatcher("name", contains())
 				.withMatcher("code", contains());
@@ -195,6 +209,22 @@ public class OrgService {
 				exampleMatcher);
 		return orgRepo.findAll(examExamStudentple, pageable);
 	}
+	
+	private Specification<Org> getSpecification(Org orgCriteria) {
+		Specification<Org> specification = (root, query, cb) -> {
+		    List<Predicate> predicates = new ArrayList<>();
+		    if(!StringUtils.isEmpty(orgCriteria.getName())){
+		    	predicates.add(cb.equal(root.get("name"),orgCriteria.getName()));
+		    }
+		    if(!StringUtils.isEmpty(orgCriteria.getCode())){
+		    	predicates.add(cb.equal(root.get("code"),orgCriteria.getCode()));
+		    }
+		    predicates.add(cb.notEqual(root.get("type"), OrgType.SCHOOL));
+		    predicates.add(cb.equal(root.get("parentId"),orgCriteria.getParentId()));
+		    return cb.and(predicates.toArray(new Predicate[predicates.size()]));
+		};
+		return specification;
+	}
 
 	public List<Org> findAll(Org orgCriteria) {
 		ExampleMatcher exampleMatcher = ExampleMatcher.matching()

+ 92 - 61
core-api/src/main/java/cn/com/qmth/examcloud/service/core/service/UserRoleService.java

@@ -1,61 +1,92 @@
-package cn.com.qmth.examcloud.service.core.service;
-
-import cn.com.qmth.examcloud.common.uac.entity.Role;
-import cn.com.qmth.examcloud.common.uac.entity.RolesService;
-import cn.com.qmth.examcloud.common.uac.enums.RoleMeta;
-import cn.com.qmth.examcloud.service.core.repo.UserRoleRepo;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.stream.Collectors;
-
-/**
- * 用户角色服务类
- * Created by songyue on 17/2/22.
- */
-@Service
-public class UserRoleService{
-
-    @Autowired
-    UserRoleRepo userRoleRepo;
-
-
-    /**
-     * 获取全部角色
-     * @return
-     */
-    public List<Role> findAllRoles(){
-        return RolesService.ROLE_LIST;
-    }
-
-    public List<Role> findMarkerRoles(){
-        List<Role> tempRoles = new ArrayList<>(RolesService.ROLE_LIST);
-        tempRoles = tempRoles.stream()
-                .filter(role -> role.getCode().equals(RoleMeta.MARKER.name()))
-                .collect(Collectors.toList());
-        return tempRoles;
-    }
-
-    public List<Role> findNonMarkerRoles(){
-        List<Role> tempRoles = new ArrayList<>(RolesService.ROLE_LIST);
-        tempRoles = tempRoles.stream()
-                .filter(role -> !role.getCode().equals(RoleMeta.MARKER.name()))
-                .filter(role -> !role.getCode().equals(RoleMeta.STUDENT.name()))
-                .collect(Collectors.toList());
-        return tempRoles;
-    }
-
-    public List<Role> findAdminRoles(){
-        List<Role> tempRoles = new ArrayList<>(RolesService.ROLE_LIST);
-        tempRoles = tempRoles.stream()
-                .filter(role -> !role.getCode().equals(RoleMeta.MARKER.name()))
-                .filter(role -> !role.getCode().equals(RoleMeta.STUDENT.name()))
-                .filter(role -> !role.getCode().equals(RoleMeta.LC_USER.name()))
-                .collect(Collectors.toList());
-        return tempRoles;
-    }
-
-
-}
+package cn.com.qmth.examcloud.service.core.service;
+
+import cn.com.qmth.examcloud.common.uac.entity.Role;
+import cn.com.qmth.examcloud.common.uac.entity.RolesService;
+import cn.com.qmth.examcloud.common.uac.enums.RoleMeta;
+import cn.com.qmth.examcloud.service.core.repo.UserRoleRepo;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * 用户角色服务类
+ * Created by songyue on 17/2/22.
+ */
+@Service
+public class UserRoleService{
+
+    @Autowired
+    UserRoleRepo userRoleRepo;
+
+
+    /**
+     * 获取全部角色
+     * @return
+     */
+    public List<Role> findAllRoles(){
+        return RolesService.ROLE_LIST;
+    }
+
+    public List<Role> findMarkerRoles(){
+        List<Role> tempRoles = new ArrayList<>(RolesService.ROLE_LIST);
+        tempRoles = tempRoles.stream()
+                .filter(role -> role.getCode().equals(RoleMeta.MARKER.name()))
+                .collect(Collectors.toList());
+        return tempRoles;
+    }
+    
+    public List<Role> findNonMarkerRoles(){
+        List<Role> tempRoles = new ArrayList<>(RolesService.ROLE_LIST);
+        tempRoles = tempRoles.stream()
+                .filter(role -> !role.getCode().equals(RoleMeta.MARKER.name()))
+                .filter(role -> !role.getCode().equals(RoleMeta.STUDENT.name()))
+                .filter(role -> !role.getCode().equals(RoleMeta.SALES_MANAGER.name()))
+                .filter(role -> !role.getCode().equals(RoleMeta.IMPLEMENTERS_MANAGER.name()))
+                .filter(role -> !role.getCode().equals(RoleMeta.PROJECT_MANAGER.name()))
+                .filter(role -> !role.getCode().equals(RoleMeta.PRINT_MANAGER.name()))
+                .collect(Collectors.toList());
+        return tempRoles;
+    }
+
+    public List<Role> findAdminRoles(){
+        List<Role> tempRoles = new ArrayList<>(RolesService.ROLE_LIST);
+        tempRoles = tempRoles.stream()
+                .filter(role -> !role.getCode().equals(RoleMeta.MARKER.name()))
+                .filter(role -> !role.getCode().equals(RoleMeta.STUDENT.name()))
+                .filter(role -> !role.getCode().equals(RoleMeta.LC_USER.name()))
+                .collect(Collectors.toList());
+        return tempRoles;
+    }
+    
+    public List<Role> findQmthRoles(){
+        List<Role> tempRoles = new ArrayList<>(RolesService.ROLE_LIST);
+        tempRoles = tempRoles.stream()
+                .filter(role -> !role.getCode().equals(RoleMeta.LC_USER.name()))
+                .filter(role -> !role.getCode().equals(RoleMeta.MARKING_ADMIN.name()))
+                .filter(role -> !role.getCode().equals(RoleMeta.MARKER.name()))
+                .filter(role -> !role.getCode().equals(RoleMeta.QUESTION_ADMIN.name()))
+                .filter(role -> !role.getCode().equals(RoleMeta.STUDENT.name()))
+                .filter(role -> !role.getCode().equals(RoleMeta.OE_ADMIN.name()))
+                .filter(role -> !role.getCode().equals(RoleMeta.PRINT_MANAGER.name()))
+                .collect(Collectors.toList());
+        return tempRoles;
+    }
+    
+    public List<Role> findSchoolRoles(){
+    	List<Role> tempRoles = new ArrayList<>(RolesService.ROLE_LIST);
+        tempRoles = tempRoles.stream()
+                .filter(role -> !role.getCode().equals(RoleMeta.MARKER.name()))
+                .filter(role -> !role.getCode().equals(RoleMeta.STUDENT.name()))
+                .filter(role -> !role.getCode().equals(RoleMeta.LC_USER.name()))
+                .filter(role -> !role.getCode().equals(RoleMeta.SALES_MANAGER.name()))
+                .filter(role -> !role.getCode().equals(RoleMeta.IMPLEMENTERS_MANAGER.name()))
+                .filter(role -> !role.getCode().equals(RoleMeta.PROJECT_MANAGER.name()))
+                .filter(role -> !role.getCode().equals(RoleMeta.PRINT_MANAGER.name()))
+                .collect(Collectors.toList());
+        return tempRoles;
+    }
+
+}

+ 4 - 3
core-api/src/main/java/cn/com/qmth/examcloud/service/core/service/UserService.java

@@ -18,6 +18,7 @@ import org.springframework.data.jpa.domain.Specification;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.stereotype.Service;
 
+import ch.qos.logback.core.net.LoginAuthenticator;
 import cn.com.qmth.examcloud.common.uac.AccessCtrlUtil;
 import cn.com.qmth.examcloud.common.uac.AccessUserOps;
 import cn.com.qmth.examcloud.common.uac.AccessUserOpsForRedis;
@@ -30,6 +31,7 @@ import cn.com.qmth.examcloud.service.core.entity.User;
 import cn.com.qmth.examcloud.service.core.entity.UserLogin;
 import cn.com.qmth.examcloud.service.core.entity.UserOpsLog;
 import cn.com.qmth.examcloud.service.core.entity.UserRole;
+import cn.com.qmth.examcloud.service.core.enums.OrgType;
 import cn.com.qmth.examcloud.service.core.enums.UserScope;
 import cn.com.qmth.examcloud.service.core.enums.UserType;
 import cn.com.qmth.examcloud.service.core.params.UserParam;
@@ -87,7 +89,7 @@ public class UserService {
     public Page<User> findAll(User userCriteria, Pageable pageable){
         Specification<User> userSpecification = (root, query, cb) -> {
             List<Predicate> predicates = new ArrayList<>();
-            predicates.add(cb.equal(root.get("type"),UserType.NOT_STUDENT));
+            predicates.add(cb.equal(root.get("type"),userCriteria.getType()));
             predicates.add(cb.equal(root.get("rootOrgId"),userCriteria.getRootOrgId()));
             if(StringUtils.isNotEmpty(userCriteria.getLoginName())){
                 predicates.add(cb.like(root.get("loginName"),"%"+userCriteria.getLoginName()+"%"));
@@ -234,7 +236,7 @@ public class UserService {
         return loginProcess(user,password);
 
     }
-
+    
     /**
      * 二级登录
      * @param orgId
@@ -424,7 +426,6 @@ public class UserService {
 	
 	public User save(User user) throws Exception{
         user.setScope(UserScope.ORG);
-        user.setType(UserType.NOT_STUDENT);
         user.setCreateTime(new Date());
 		checkLoginName(user.getRootOrgId(), user.getLoginName());
 		return userRepo.save(user);

+ 260 - 204
core-domain/src/main/java/cn/com/qmth/examcloud/service/core/entity/Org.java

@@ -1,204 +1,260 @@
-package cn.com.qmth.examcloud.service.core.entity;
-
-import org.springframework.format.annotation.DateTimeFormat;
-
-import cn.com.qmth.examcloud.common.util.excel.ExcelProperty;
-
-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_org")
-public class Org implements Serializable{
-
-    private static final long serialVersionUID = -592353272256492483L;
-
-    @Id
-    @GeneratedValue
-    private Long id;
-    /**
-     * 顶级机构id,无上级时为0;eg.学校即是顶级
-     */
-    @NotNull
-    private Long rootId;
-    /**
-     * 父级机构id,无上级时为0;eg.学习中心的父级为学校
-     */
-    @NotNull
-    private Long parentId;
-
-    private Integer level;
-    
-    @ExcelProperty(name = "机构名称",index = 0)
-    @NotNull
-    private String name;
-    
-    /**
-     * 学习中心代码
-     */
-    @ExcelProperty(name = "机构代码",index = 1)
-    private String code;
-
-    private String logo;
-
-    private String address;
-
-    /**
-     * 可使用的应用模块
-     */
-    private String apps;
-
-    @NotNull
-    private Boolean enable;
-    
-    /**
-     * 联系电话
-     */
-    @ExcelProperty(name = "联系电话",index = 3)
-    private String telphone;
-    /**
-     * 联系人
-     */
-    @ExcelProperty(name = "联系人",index = 2)
-    private String contacts;
-
-    @Temporal(value = TemporalType.DATE)
-    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-    private Date createTime;
-
-    @Temporal(value = TemporalType.DATE)
-    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-    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 String getCode() {
-		return code;
-	}
-
-	public void setCode(String code) {
-		this.code = code;
-	}
-
-	public String getTelphone() {
-		return telphone;
-	}
-
-	public void setTelphone(String telphone) {
-		this.telphone = telphone;
-	}
-
-	public String getContacts() {
-		return contacts;
-	}
-
-	public void setContacts(String contacts) {
-		this.contacts = contacts;
-	}
-
-    public Org(String name, String code, String contacts,String telphone) {
-        this.name = name;
-        this.code = code;
-        this.telphone = telphone;
-        this.contacts = contacts;
-    }
-
-    public Org() {
-    }
-}
+package cn.com.qmth.examcloud.service.core.entity;
+
+import org.springframework.format.annotation.DateTimeFormat;
+
+import cn.com.qmth.examcloud.common.util.excel.ExcelProperty;
+import cn.com.qmth.examcloud.service.core.enums.OrgType;
+
+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_org")
+public class Org implements Serializable{
+
+    private static final long serialVersionUID = -592353272256492483L;
+
+    @Id
+    @GeneratedValue
+    private Long id;
+    /**
+     * 顶级机构id,无上级时为0;eg.学校即是顶级
+     */
+    @NotNull
+    private Long rootId;
+    /**
+     * 父级机构id,无上级时为0;eg.学习中心的父级为学校
+     */
+    @NotNull
+    private Long parentId;
+
+    private Integer level;
+    
+    @ExcelProperty(name = "机构名称",index = 0)
+    @NotNull
+    private String name;
+    
+    /**
+     * 学习中心代码
+     */
+    @ExcelProperty(name = "机构代码",index = 1)
+    private String code;
+
+    private String logo;
+
+    private String address;
+
+    /**
+     * 可使用的应用模块
+     */
+    private String apps;
+
+    @NotNull
+    private Boolean enable;
+    
+    /**
+     * 联系电话
+     */
+    @ExcelProperty(name = "联系电话",index = 3)
+    private String telphone;
+    /**
+     * 联系人
+     */
+    @ExcelProperty(name = "联系人",index = 2)
+    private String contacts;
+
+    @Temporal(value = TemporalType.DATE)
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date createTime;
+
+    @Temporal(value = TemporalType.DATE)
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date updateTime;
+    
+    /**
+     * 机构类型:学校,启明,印刷
+     */
+    @NotNull
+    @Enumerated(EnumType.STRING)
+    private OrgType type;
+    
+    /**
+     * 机器数量
+     */
+    private Integer macNumber;
+    
+    /**
+     * 是否提供人员
+     */
+    private Boolean isProvide;
+    
+    /**
+     * 备注
+     */
+    private String remark;
+    
+    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 String getCode() {
+		return code;
+	}
+
+	public void setCode(String code) {
+		this.code = code;
+	}
+
+	public String getTelphone() {
+		return telphone;
+	}
+
+	public void setTelphone(String telphone) {
+		this.telphone = telphone;
+	}
+
+	public String getContacts() {
+		return contacts;
+	}
+
+	public void setContacts(String contacts) {
+		this.contacts = contacts;
+	}
+
+
+	public OrgType getType() {
+		return type;
+	}
+
+	public void setType(OrgType type) {
+		this.type = type;
+	}
+	
+	public Integer getMacNumber() {
+		return macNumber;
+	}
+
+	public void setMacNumber(Integer macNumber) {
+		this.macNumber = macNumber;
+	}
+
+	public Boolean getIsProvide() {
+		return isProvide;
+	}
+
+	public void setIsProvide(Boolean isProvide) {
+		this.isProvide = isProvide;
+	}
+
+	public String getRemark() {
+		return remark;
+	}
+
+	public void setRemark(String remark) {
+		this.remark = remark;
+	}
+
+	public Org(String name, String code, String contacts,String telphone) {
+        this.name = name;
+        this.code = code;
+        this.telphone = telphone;
+        this.contacts = contacts;
+    }
+
+    public Org() {
+    }
+}

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

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

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

@@ -1,31 +1,37 @@
-package cn.com.qmth.examcloud.service.core.repo;
-
-import java.util.List;
-import org.springframework.data.jpa.repository.JpaRepository;
-import org.springframework.data.jpa.repository.Query;
-import org.springframework.data.repository.query.Param;
-import org.springframework.data.repository.query.QueryByExampleExecutor;
-
-import cn.com.qmth.examcloud.service.core.entity.Org;
-
-/**
- * Created by songyue on 17/1/13.
- */
-public interface OrgRepo extends JpaRepository<Org,Long>,QueryByExampleExecutor<Org>{
-
-    List<Org> findByRootId(long rootId);
-
-    List<Org> findById(long id);
-
-    @Query(nativeQuery = true,value = "select *from ecs_core_org where parent_id=:parentId")
-    List<Org> findBothByParentId(@Param("parentId") long parentId);
-
-    @Query(nativeQuery = true,value = "select *from ecs_core_org where parent_id=:parentId and enable = 1")
-    List<Org> findByParentId(@Param("parentId") long parentId);
-
-    @Query(nativeQuery = true,value = "select *from ecs_core_org where (id=:parentId or parent_id=:parentId) and enable = 1")
-    List<Org> findAllByParentId(@Param("parentId") long parentId);
-
-    @Query(nativeQuery = true,value = "select *from ecs_core_org where parent_id=:parentId and code=:code and enable = 1")
-	Org findFirstByParentIdAndCode(@Param("parentId") Long parentId, @Param("code")String code);
-}
+package cn.com.qmth.examcloud.service.core.repo;
+
+import java.util.List;
+
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.data.jpa.repository.Query;
+import org.springframework.data.repository.query.Param;
+import org.springframework.data.repository.query.QueryByExampleExecutor;
+
+import cn.com.qmth.examcloud.service.core.entity.Course;
+import cn.com.qmth.examcloud.service.core.entity.Org;
+
+/**
+ * Created by songyue on 17/1/13.
+ */
+public interface OrgRepo extends JpaRepository<Org, Long>,QueryByExampleExecutor<Org>, JpaSpecificationExecutor<Org> {
+
+    List<Org> findByRootId(long rootId);
+
+    List<Org> findById(long id);
+
+    @Query(nativeQuery = true,value = "select *from ecs_core_org where parent_id=:parentId")
+    List<Org> findBothByParentId(@Param("parentId") long parentId);
+
+    @Query(nativeQuery = true,value = "select *from ecs_core_org where parent_id=:parentId and enable = 1")
+    List<Org> findByParentId(@Param("parentId") long parentId);
+
+    @Query(nativeQuery = true,value = "select *from ecs_core_org where (id=:parentId or parent_id=:parentId) and enable = 1 and type = \"SCHOOL\"")
+    List<Org> findAllSchoolByParentId(@Param("parentId") long parentId);
+    
+    @Query(nativeQuery = true,value = "select *from ecs_core_org where (id=:parentId or parent_id=:parentId) and enable = 1 and type in (\"PRINT_QMTH\",\"PRINT_SHOP\")")
+    List<Org> findAllPrintByParentId(@Param("parentId") long parentId);
+
+    @Query(nativeQuery = true,value = "select *from ecs_core_org where parent_id=:parentId and code=:code and enable = 1")
+	Org findFirstByParentIdAndCode(@Param("parentId") Long parentId, @Param("code")String code);
+}