123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- package com.qmth.distributed.print.api;
- import com.qmth.boot.api.constant.ApiConstant;
- import com.qmth.distributed.print.business.bean.result.EditResult;
- import com.qmth.distributed.print.business.service.PrintCommonService;
- import com.qmth.teachcloud.common.annotation.OperationLogDetail;
- import com.qmth.teachcloud.common.contant.SystemConstant;
- import com.qmth.teachcloud.common.entity.SysOrg;
- import com.qmth.teachcloud.common.entity.SysUser;
- import com.qmth.teachcloud.common.enums.RoleTypeEnum;
- import com.qmth.teachcloud.common.enums.log.CustomizedOperationTypeEnum;
- import com.qmth.teachcloud.common.service.SysOrgService;
- import com.qmth.teachcloud.common.util.Result;
- import com.qmth.teachcloud.common.util.ResultUtil;
- import com.qmth.teachcloud.common.util.ServletUtil;
- import io.swagger.annotations.*;
- import org.springframework.validation.BindingResult;
- import org.springframework.web.bind.annotation.*;
- import org.springframework.web.multipart.MultipartFile;
- import javax.annotation.Resource;
- import javax.servlet.http.HttpServletResponse;
- import javax.validation.Valid;
- /**
- * <p>
- * 学校组织架构 前端控制器
- * </p>
- *
- * @author xf
- * @since 2021-03-23
- */
- @Api(tags = "组织架构Controller")
- @RestController
- @RequestMapping(ApiConstant.DEFAULT_URI_PREFIX + SystemConstant.PREFIX_URL_SYS + "/org")
- public class SysOrgController {
- @Resource
- private SysOrgService sysOrgService;
- @Resource
- private PrintCommonService printCommonService;
- /**
- * 查询机构树
- *
- * @return
- */
- @ApiOperation(value = "查询")
- @RequestMapping(value = "/list", method = RequestMethod.POST)
- public Result list(@RequestParam(value = "specialPrivilege", required = false) RoleTypeEnum specialPrivilege,
- @RequestParam(value = "withoutPrintingRoom", required = false) boolean withoutPrintingRoom,
- @ApiParam(value = "科目编码") @RequestParam(required = false) String courseCode) {
- return ResultUtil.ok(sysOrgService.listOrgTree(specialPrivilege, withoutPrintingRoom, courseCode));
- }
- /**
- * 新增/修改
- *
- * @param org
- * @return
- */
- @ApiOperation(value = "新增/修改")
- @RequestMapping(value = "/save", method = RequestMethod.POST)
- @OperationLogDetail(customizedOperationType = CustomizedOperationTypeEnum.EDIT)
- public Result save(@Valid @RequestBody SysOrg org, BindingResult bindingResult) {
- if (bindingResult.hasErrors()) {
- return ResultUtil.error(bindingResult.getAllErrors().get(0).getDefaultMessage());
- }
- SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
- return ResultUtil.ok(sysOrgService.saveOrg(org, sysUser));
- }
- /**
- * 启用/禁用
- *
- * @param org
- * @return
- */
- @ApiOperation(value = "启用/禁用")
- @RequestMapping(value = "/enable", method = RequestMethod.POST)
- @OperationLogDetail(customizedOperationType = CustomizedOperationTypeEnum.UPDATE)
- public Result enable(@RequestBody SysOrg org) {
- return ResultUtil.ok(printCommonService.enable(org));
- }
- /**
- * 删除
- *
- * @param org
- * @return
- */
- @ApiOperation(value = "删除")
- @RequestMapping(value = "/remove", method = RequestMethod.POST)
- @OperationLogDetail(customizedOperationType = CustomizedOperationTypeEnum.DELETE)
- public Result remove(@RequestBody SysOrg org) {
- return ResultUtil.ok(printCommonService.sysOrgRemove(org.getId()));
- }
- /**
- * 根据机构类型查询机构
- *
- * @return 结果
- */
- @ApiOperation(value = "根据类型查询机构")
- @RequestMapping(value = "/find_by_type", method = RequestMethod.POST)
- public Result findByType(@ApiParam(value = "机构类型") @RequestParam(required = false) String orgType) {
- return ResultUtil.ok(sysOrgService.findDeepByOrgIdAndType(orgType));
- }
- @ApiOperation(value = "机构管理-批量导入")
- @RequestMapping(value = "/import", method = RequestMethod.POST)
- @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = EditResult.class)})
- @OperationLogDetail(customizedOperationType = CustomizedOperationTypeEnum.IMPORT)
- public Result sysOrgImportAsync(@ApiParam(value = "上传文件", required = true) @RequestParam MultipartFile file) throws Exception {
- sysOrgService.executeImportSysOrgLogic(file);
- return ResultUtil.ok();
- }
- @ApiOperation(value = "机构管理-导出")
- @RequestMapping(value = "/export", method = RequestMethod.POST)
- @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = EditResult.class)})
- @OperationLogDetail(customizedOperationType = CustomizedOperationTypeEnum.EXPORT)
- public void export(HttpServletResponse response) throws Exception {
- sysOrgService.exportOrgData(response, false);
- }
- }
|