package com.product.file.controller; import com.product.core.config.CoreConst; import com.product.core.controller.support.AbstractBaseController; import com.product.core.entity.FieldSetEntity; import com.product.core.entity.RequestParameterEntity; import com.product.core.exception.BaseException; import com.product.core.permission.PermissionService; import com.product.core.spring.context.SpringMVCContextHolder; import com.product.file.config.CmnConst; import com.product.file.config.DocumentCode; import com.product.file.service.DocumentDirectoryService; import com.product.file.service.ide.IDocumentDirectoryService; import com.product.file.util.ResultInfo; import com.product.module.sys.config.SystemErrorCode; import com.product.module.sys.entity.SystemUser; import com.product.module.sys.version.ApiVersion; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; import javax.servlet.http.HttpServletRequest; /** * Copyright LX-BASE * * @Title: ClaimExpenseController * @Project: LX-BASE-SERVER * @Date: 2020-11-18 11:30:48 * @Author: luoxin * @Description: 文件夹管理Constoller */ @RequestMapping("/api/directory") @RestController public class DocumentDirectoryConstoller extends AbstractBaseController { @Autowired public DocumentDirectoryService documentDirectoryService; /** * 数据权限验证 */ @Autowired PermissionService permissionService; /** * 新增文件夹数据 * @param request * @return */ @RequestMapping(value = "/addDocumentDirectory/{version}", method = RequestMethod.POST) @ApiVersion(1) public String addDocumentDirectory(HttpServletRequest request) { try { //获取参数 FieldSetEntity fse = null; Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA); if (bean != null) { RequestParameterEntity reqp = (RequestParameterEntity) bean; fse = reqp.getFormData(); } //判断参数是否为空 if (fse == null) { SpringMVCContextHolder.getSystemLogger().error(DocumentCode.DOCUMENT_FORM_NODATA.getValue(), DocumentCode.DOCUMENT_FORM_NODATA.getText()); return this.error(DocumentCode.DOCUMENT_FORM_NODATA.getValue(), DocumentCode.DOCUMENT_FORM_NODATA.getText()); } IDocumentDirectoryService service = (IDocumentDirectoryService)getProxyInstance(documentDirectoryService); return OK_Add(service.addDocumentDirectory(fse)); } catch (BaseException e) { SpringMVCContextHolder.getSystemLogger().error(e); return this.error(e); }catch (Exception e) { e.printStackTrace(); SpringMVCContextHolder.getSystemLogger().error(e); return this.error(DocumentCode.DOCUMENT_CATALOG_SAVE_FAIL.getValue(), DocumentCode.DOCUMENT_CATALOG_SAVE_FAIL.getText()); } } /** * 修改文件夹 * @param request * @return */ @RequestMapping(value = "/upDocumentDirectory/{version}", method = RequestMethod.POST) @ApiVersion(1) public String upDocumentDirectory(HttpServletRequest request) { try { //获取参数 FieldSetEntity fse = null; Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA); if (bean != null) { RequestParameterEntity reqp = (RequestParameterEntity) bean; fse = reqp.getFormData(); } //判断参数是否为空 if (fse == null) { SpringMVCContextHolder .getSystemLogger().error(DocumentCode.DOCUMENT_FORM_NODATA.getValue(), DocumentCode.DOCUMENT_FORM_NODATA.getText()); return this.error(DocumentCode.DOCUMENT_FORM_NODATA.getValue(), DocumentCode.DOCUMENT_FORM_NODATA.getText()); } String uuid = fse.getString(CmnConst.UUID);//表uuid //超级管理员为1 普通单位管理员2 SystemUser currentUser = SpringMVCContextHolder.getCurrentUser(); int type; if(currentUser.getUserType() == 2){ type = CoreConst.DATA_PERMISSION_VALID_TYPE_ORG; }else { type = CoreConst.DATA_PERMISSION_VALID_TYPE_USER; } //数据操作的权限验证 if(!permissionService.validDataPermission(CmnConst.product_oa_DIRECTORY,uuid,type)) { SpringMVCContextHolder.getSystemLogger().error(SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getValue(), SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getText()); return this.error(SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getValue(), SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getText()); } IDocumentDirectoryService service = (IDocumentDirectoryService)getProxyInstance(documentDirectoryService); if(service.upDocumentDirectory(fse)) { return OK(); } return this.error(DocumentCode.DOCUMENT_CATALOG_SAVE_FAIL.getValue(), DocumentCode.DOCUMENT_CATALOG_SAVE_FAIL.getText()); } catch (BaseException e) { SpringMVCContextHolder.getSystemLogger().error(e); return this.error(e); }catch (Exception e) { e.printStackTrace(); SpringMVCContextHolder.getSystemLogger().error(e); return this.error(DocumentCode.DOCUMENT_CATALOG_SAVE_FAIL.getValue(), DocumentCode.DOCUMENT_CATALOG_SAVE_FAIL.getText()); } } /** * 个人文件夹重命名 * @param request * @return */ @RequestMapping(value = "/upDocumentDirectoryName/{version}", method = RequestMethod.POST) @ApiVersion(1) public String upDocumentDirectoryName(HttpServletRequest request) { try { //获取参数 FieldSetEntity fse = null; Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA); if (bean != null) { RequestParameterEntity reqp = (RequestParameterEntity) bean; fse = reqp.getFormData(); } //判断参数是否为空 if (fse == null) { SpringMVCContextHolder .getSystemLogger().error(DocumentCode.DOCUMENT_FORM_NODATA.getValue(), DocumentCode.DOCUMENT_FORM_NODATA.getText()); return this.error(DocumentCode.DOCUMENT_FORM_NODATA.getValue(), DocumentCode.DOCUMENT_FORM_NODATA.getText()); } String uuid = fse.getString(CmnConst.UUID);//表uuid //超级管理员为1 普通单位管理员2 SystemUser currentUser = SpringMVCContextHolder.getCurrentUser(); int type; if(currentUser.getUserType() == 2){ type = CoreConst.DATA_PERMISSION_VALID_TYPE_ORG; }else { type = CoreConst.DATA_PERMISSION_VALID_TYPE_USER; } //数据操作的权限验证 if(!permissionService.validDataPermission(CmnConst.product_oa_DIRECTORY,uuid,type)) { SpringMVCContextHolder.getSystemLogger().error(SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getValue(), SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getText()); return this.error(SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getValue(), SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getText()); } IDocumentDirectoryService service = (IDocumentDirectoryService)getProxyInstance(documentDirectoryService); if(service.upDocumentDirectoryName(fse)) { return OK(); } return this.error(DocumentCode.DOCUMENT_DIRECTORY_NAME_FAIL.getValue(), DocumentCode.DOCUMENT_DIRECTORY_NAME_FAIL.getText()); } catch (BaseException e) { SpringMVCContextHolder.getSystemLogger().error(e); return this.error(e); }catch (Exception e) { e.printStackTrace(); SpringMVCContextHolder.getSystemLogger().error(e); return this.error(DocumentCode.DOCUMENT_DIRECTORY_NAME_FAIL.getValue(), DocumentCode.DOCUMENT_DIRECTORY_NAME_FAIL.getText()); } } /** * 删除文件夹 * @param request * @return */ @RequestMapping(value = "/delDocumentDirectory/{version}", method = RequestMethod.POST) @ApiVersion(1) public String delDocumentDirectory(HttpServletRequest request) { try { //获取参数 FieldSetEntity fse = null; Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA); if (bean != null) { RequestParameterEntity reqp = (RequestParameterEntity) bean; fse = reqp.getFormData(); } //判断参数是否为空 if (fse == null) { SpringMVCContextHolder .getSystemLogger().error(DocumentCode.DOCUMENT_FORM_NODATA.getValue(), DocumentCode.DOCUMENT_FORM_NODATA.getText()); return this.error(DocumentCode.DOCUMENT_FORM_NODATA.getValue(), DocumentCode.DOCUMENT_FORM_NODATA.getText()); } String uuid = fse.getString(CmnConst.UUID);//表uuid //超级管理员为1 普通单位管理员2 SystemUser currentUser = SpringMVCContextHolder.getCurrentUser(); int type; if(currentUser.getUserType() == 2){ type = CoreConst.DATA_PERMISSION_VALID_TYPE_ORG; }else { type = CoreConst.DATA_PERMISSION_VALID_TYPE_USER; } //数据操作的权限验证 if(!permissionService.validDataPermission(CmnConst.product_oa_DIRECTORY,uuid,type)) { SpringMVCContextHolder.getSystemLogger().error(SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getValue(), SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getText()); return this.error(SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getValue(), SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getText()); } IDocumentDirectoryService service = (IDocumentDirectoryService)getProxyInstance(documentDirectoryService); if(service.delDocumentDirectory(fse)){ return OK(); } return this.error(DocumentCode.DOCUMENT_CATALOG_DELETE_FAIL.getValue(), DocumentCode.DOCUMENT_CATALOG_DELETE_FAIL.getText()); } catch (BaseException e) { SpringMVCContextHolder.getSystemLogger().error(e); return this.error(e); }catch (Exception e) { e.printStackTrace(); SpringMVCContextHolder.getSystemLogger().error(e); return this.error(DocumentCode.DOCUMENT_CATALOG_DELETE_FAIL.getValue(), DocumentCode.DOCUMENT_CATALOG_DELETE_FAIL.getText()); } } /** * 文件目录列表展示 * @param request * @return */ @RequestMapping(value = "/moveToList/{version}", method = RequestMethod.POST) @ApiVersion(1) public String moveToList(HttpServletRequest request) { try { //获取参数 FieldSetEntity fse = null; Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA); if (bean != null) { RequestParameterEntity reqp = (RequestParameterEntity) bean; fse = reqp.getFormData(); } //判断参数是否为空 if (fse == null) { SpringMVCContextHolder .getSystemLogger().error(DocumentCode.DOCUMENT_FORM_NODATA.getValue(), DocumentCode.DOCUMENT_FORM_NODATA.getText()); return this.error(DocumentCode.DOCUMENT_FORM_NODATA.getValue(), DocumentCode.DOCUMENT_FORM_NODATA.getText()); } return OK_List(documentDirectoryService.moveToList(fse)); } catch (BaseException e) { SpringMVCContextHolder.getSystemLogger().error(e); return this.error(e); }catch (Exception e) { e.printStackTrace(); SpringMVCContextHolder.getSystemLogger().error(e); return this.error(DocumentCode.DOCUMENT_CATALOG_GET_FAIL.getValue(), DocumentCode.DOCUMENT_CATALOG_GET_FAIL.getText()); } } /** * 获取文档目录树形列表 * @param request * @return */ @RequestMapping(value = "/treeListAll/{version}", method = RequestMethod.POST) @ApiVersion(1) public String treeListAll(HttpServletRequest request) { try { //获取参数 FieldSetEntity fse = null; Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA); if (bean != null) { RequestParameterEntity reqp = (RequestParameterEntity) bean; fse = reqp.getFormData(); } //判断参数是否为空 if (fse == null) { SpringMVCContextHolder .getSystemLogger().error(DocumentCode.DOCUMENT_FORM_NODATA.getValue(), DocumentCode.DOCUMENT_FORM_NODATA.getText()); return this.error(DocumentCode.DOCUMENT_FORM_NODATA.getValue(), DocumentCode.DOCUMENT_FORM_NODATA.getText()); } return ResultInfo.success(documentDirectoryService.treeListAll(fse)); } catch (BaseException e) { SpringMVCContextHolder.getSystemLogger().error(e); return this.error(e); }catch (Exception e) { e.printStackTrace(); SpringMVCContextHolder.getSystemLogger().error(e); return this.error(DocumentCode.DOCUMENT_CATALOG_GET_TREE_FAIL.getValue(), DocumentCode.DOCUMENT_CATALOG_GET_TREE_FAIL.getText()); } } /** * 获取文档目录详情 * @param request * @return */ @RequestMapping(value = "/documentDirectoryInfo/{version}", method = RequestMethod.POST) @ApiVersion(1) public String documentDirectoryInfo(HttpServletRequest request) { try { //获取参数 FieldSetEntity fse = null; Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA); if (bean != null) { RequestParameterEntity reqp = (RequestParameterEntity) bean; fse = reqp.getFormData(); } //判断参数是否为空 if (fse == null) { SpringMVCContextHolder .getSystemLogger().error(DocumentCode.DOCUMENT_FORM_NODATA.getValue(), DocumentCode.DOCUMENT_FORM_NODATA.getText()); return this.error(DocumentCode.DOCUMENT_FORM_NODATA.getValue(), DocumentCode.DOCUMENT_FORM_NODATA.getText()); } String uuid = fse.getString(CmnConst.UUID);//表uuid //超级管理员为1 普通单位管理员2 SystemUser currentUser = SpringMVCContextHolder.getCurrentUser(); int type; if(currentUser.getUserType() == 2){ type = CoreConst.DATA_PERMISSION_VALID_TYPE_ORG; }else { type = CoreConst.DATA_PERMISSION_VALID_TYPE_USER; } //数据操作的权限验证 if(!permissionService.validDataPermission(CmnConst.product_oa_DIRECTORY,uuid,type)) { SpringMVCContextHolder.getSystemLogger().error(SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getValue(), SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getText()); return this.error(SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getValue(), SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getText()); } return OK_List(documentDirectoryService.documentDirectoryInfo(fse)); } catch (BaseException e) { SpringMVCContextHolder.getSystemLogger().error(e); return this.error(e); }catch (Exception e) { e.printStackTrace(); SpringMVCContextHolder.getSystemLogger().error(e); return this.error(DocumentCode.DOCUMENT_CATALOG_GET_FAIL.getValue(), DocumentCode.DOCUMENT_CATALOG_GET_FAIL.getText()); } } }