|
@@ -23,12 +23,9 @@ import org.springframework.data.domain.PageRequest;
|
|
import org.springframework.data.domain.Pageable;
|
|
import org.springframework.data.domain.Pageable;
|
|
import org.springframework.data.domain.Sort;
|
|
import org.springframework.data.domain.Sort;
|
|
import org.springframework.data.jpa.domain.Specification;
|
|
import org.springframework.data.jpa.domain.Specification;
|
|
-import org.springframework.http.HttpStatus;
|
|
|
|
-import org.springframework.http.ResponseEntity;
|
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
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.PathVariable;
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
import org.springframework.web.bind.annotation.PutMapping;
|
|
import org.springframework.web.bind.annotation.PutMapping;
|
|
@@ -70,59 +67,31 @@ public class OrgController extends ControllerSupport {
|
|
@Autowired
|
|
@Autowired
|
|
private JdbcTemplate jdbcTemplate;
|
|
private JdbcTemplate jdbcTemplate;
|
|
|
|
|
|
- @ApiOperation(value = "查询机构分页带查询", notes = "分页带查询")
|
|
|
|
- @GetMapping("/all/{curPage}/{pageSize}")
|
|
|
|
- public ResponseEntity getAllOrg(@ModelAttribute Org orgCriteria, @PathVariable Integer curPage,
|
|
|
|
- @PathVariable Integer pageSize) {
|
|
|
|
- return new ResponseEntity(
|
|
|
|
- orgService.findAll(orgCriteria, new PageRequest(curPage - 1, pageSize)),
|
|
|
|
- HttpStatus.OK);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @ApiOperation(value = "查询顶层机构分页带查询", notes = "分页带查询")
|
|
|
|
- @GetMapping("/parent/{curPage}/{pageSize}")
|
|
|
|
- public ResponseEntity getParentOrg(@ModelAttribute Org orgCriteria,
|
|
|
|
- @PathVariable Integer curPage, @PathVariable Integer pageSize) {
|
|
|
|
- orgCriteria.setParentId(0L);
|
|
|
|
- orgCriteria.setRootId(0L);
|
|
|
|
- return new ResponseEntity(
|
|
|
|
- orgService.findAll(orgCriteria, new PageRequest(curPage - 1, pageSize)),
|
|
|
|
- HttpStatus.OK);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @ApiOperation(value = "查询机构不分页带查询", notes = "不分页带查询")
|
|
|
|
- // @GetMapping("/alls/{type}")
|
|
|
|
- public ResponseEntity getAllExam(@PathVariable String type, HttpServletRequest request) {
|
|
|
|
- cn.com.qmth.examcloud.commons.web.security.bean.User accessUser = getAccessUser();
|
|
|
|
- if (accessUser != null) {
|
|
|
|
- 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(null, HttpStatus.OK);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 方法注释
|
|
|
|
+ *
|
|
|
|
+ * @author WANGWEI
|
|
|
|
+ * @param id
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
@ApiOperation(value = "按ID查询机构", notes = "ID查询")
|
|
@ApiOperation(value = "按ID查询机构", notes = "ID查询")
|
|
@GetMapping("/{id}")
|
|
@GetMapping("/{id}")
|
|
- public ResponseEntity<Org> getOrgById(@PathVariable Long id) {
|
|
|
|
- return new ResponseEntity(orgService.findOne(id), HttpStatus.OK);
|
|
|
|
|
|
+ public Org getOrg(@PathVariable Long id) {
|
|
|
|
+ Org org = orgService.findOne(id);
|
|
|
|
+ return org;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 方法注释
|
|
|
|
+ *
|
|
|
|
+ * @author WANGWEI
|
|
|
|
+ * @param parentId
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
@ApiOperation(value = "查询下属机构不带分页", notes = "不分页")
|
|
@ApiOperation(value = "查询下属机构不带分页", notes = "不分页")
|
|
@GetMapping("/sub/{parentId}")
|
|
@GetMapping("/sub/{parentId}")
|
|
- public List<Org> getOrgByParentId(@PathVariable Long parentId, HttpServletRequest request) {
|
|
|
|
- List<Org> orgList = orgRepo.findByParentId(parentId);
|
|
|
|
- return orgList;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @ApiOperation(value = "查询下属机构不带分页", notes = "不分页")
|
|
|
|
- @GetMapping("/sub/both/{parentId}")
|
|
|
|
- public List<Org> getBothOrg(@PathVariable Long parentId, HttpServletRequest request) {
|
|
|
|
- List<Org> orgList = orgRepo.findBothByParentId(parentId);
|
|
|
|
|
|
+ public List<Org> getSubOrgList(@PathVariable Long parentId) {
|
|
|
|
+ List<Org> orgList = orgRepo.findByParentIdAndEnable(parentId, true);
|
|
return orgList;
|
|
return orgList;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -251,11 +220,7 @@ public class OrgController extends ControllerSupport {
|
|
}
|
|
}
|
|
|
|
|
|
org.setParentId(null);
|
|
org.setParentId(null);
|
|
- // 临时
|
|
|
|
- org.setRootId(-1L);
|
|
|
|
Org saved = orgService.save(org);
|
|
Org saved = orgService.save(org);
|
|
- saved.setRootId(saved.getId());
|
|
|
|
- saved = orgService.save(org);
|
|
|
|
return saved;
|
|
return saved;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -276,8 +241,8 @@ public class OrgController extends ControllerSupport {
|
|
|
|
|
|
org.setParentId(null);
|
|
org.setParentId(null);
|
|
org.setRootId(org.getId());
|
|
org.setRootId(org.getId());
|
|
- Org updated = orgService.update(org.getId(), org);
|
|
|
|
- return updated;
|
|
|
|
|
|
+ Org saved = orgService.save(org);
|
|
|
|
+ return saved;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -312,8 +277,8 @@ public class OrgController extends ControllerSupport {
|
|
|
|
|
|
org.setParentId(accessUser.getRootOrgId());
|
|
org.setParentId(accessUser.getRootOrgId());
|
|
org.setRootId(accessUser.getRootOrgId());
|
|
org.setRootId(accessUser.getRootOrgId());
|
|
- Org updated = orgService.update(org.getId(), org);
|
|
|
|
- return updated;
|
|
|
|
|
|
+ Org saved = orgService.save(org);
|
|
|
|
+ return saved;
|
|
}
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "按ID删除机构", notes = "删除")
|
|
@ApiOperation(value = "按ID删除机构", notes = "删除")
|
|
@@ -360,48 +325,25 @@ public class OrgController extends ControllerSupport {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- @ApiOperation(value = "按code查询机构(学习中心)", notes = "code查询")
|
|
|
|
- @GetMapping()
|
|
|
|
- public Org getCourseByCode(@RequestParam Long parentId, @RequestParam String code) {
|
|
|
|
- Org org = orgRepo.findFirstByParentIdAndCode(parentId, code);
|
|
|
|
- return org;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @ApiOperation(value = "按code查询机构(学习中心)", notes = "code查询")
|
|
|
|
|
|
+ @ApiOperation(value = "查询logo")
|
|
@GetMapping("/logo")
|
|
@GetMapping("/logo")
|
|
- public void logo(@RequestParam("domain") String domain, HttpServletResponse response)
|
|
|
|
|
|
+ public void getLogo(@RequestParam("domain") String domain, HttpServletResponse response)
|
|
throws IOException {
|
|
throws IOException {
|
|
- Org org = orgRepo.findFirstByParentIdAndCode(0L, domain);
|
|
|
|
|
|
+ Org org = orgRepo.findRootOrg(domain);
|
|
String logo = org.getLogo();
|
|
String logo = org.getLogo();
|
|
IOUtils.copy(new FileInputStream(logo), response.getOutputStream());
|
|
IOUtils.copy(new FileInputStream(logo), response.getOutputStream());
|
|
response.flushBuffer();
|
|
response.flushBuffer();
|
|
}
|
|
}
|
|
|
|
|
|
- @ApiOperation(value = "查询机构不分页带查询", notes = "不分页带查询")
|
|
|
|
- @GetMapping("/all")
|
|
|
|
- public ResponseEntity getAllExam(@ModelAttribute Org orgCriteria, HttpServletRequest request) {
|
|
|
|
- cn.com.qmth.examcloud.commons.web.security.bean.User accessUser = getAccessUser();
|
|
|
|
- if (accessUser != null) {
|
|
|
|
- return new ResponseEntity(orgRepo.findAllSchoolByParentId(accessUser.getRootOrgId()),
|
|
|
|
- HttpStatus.OK);
|
|
|
|
- }
|
|
|
|
- return new ResponseEntity(orgService.findAll(orgCriteria), HttpStatus.OK);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @ApiOperation(value = "查询所有学校", notes = "查询所有学校")
|
|
|
|
- // @GetMapping("/getAllParentOrg")
|
|
|
|
- public List<Org> getAllParentOrg() {
|
|
|
|
- List<Org> list = orgRepo.findAllParentOrg();
|
|
|
|
- return list;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @ApiOperation(value = "查询所有印刷机构", notes = "查询所有印刷机构")
|
|
|
|
- // @GetMapping("/allPrint")
|
|
|
|
- public List<Org> getAllPrintOrg() {
|
|
|
|
- List<Org> orgList = orgRepo.findAllPrintByParentId(0L);
|
|
|
|
- return orgList;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 方法注释
|
|
|
|
+ *
|
|
|
|
+ * @author WANGWEI
|
|
|
|
+ * @param id
|
|
|
|
+ * @param request
|
|
|
|
+ * @param file
|
|
|
|
+ * @throws IOException
|
|
|
|
+ */
|
|
@ApiOperation(value = "导入logo", notes = "导入logo")
|
|
@ApiOperation(value = "导入logo", notes = "导入logo")
|
|
@PostMapping("/importLogo/{id}")
|
|
@PostMapping("/importLogo/{id}")
|
|
public void importLogo(@PathVariable Long id, HttpServletRequest request,
|
|
public void importLogo(@PathVariable Long id, HttpServletRequest request,
|
|
@@ -427,15 +369,6 @@ public class OrgController extends ControllerSupport {
|
|
jdbcTemplate.update("update ecs_core_org t set t.logo=? where t.id=?", filePath, id);
|
|
jdbcTemplate.update("update ecs_core_org t set t.logo=? where t.id=?", filePath, id);
|
|
}
|
|
}
|
|
|
|
|
|
- @ApiOperation(value = "按机构名称模糊查询机构列表", notes = "")
|
|
|
|
- @PostMapping("getOrgListByNameLike")
|
|
|
|
- public List<Org> getOrgListByNameLike(@RequestParam String orgName) {
|
|
|
|
- User accessUser = getAccessUser();
|
|
|
|
- orgName = "%" + orgName + "%";
|
|
|
|
- List<Org> list = orgRepo.findByRootIdAndNameLike(accessUser.getRootOrgId(), orgName);
|
|
|
|
- return list;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* 修改请通知作者
|
|
* 修改请通知作者
|
|
*
|
|
*
|