package com.product.org.admin.controller;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import com.product.util.BaseUtil;
|
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 com.product.admin.config.SystemCode;
|
import com.product.core.config.CoreConst;
|
import com.product.core.controller.support.AbstractBaseController;
|
import com.product.core.entity.DataTableEntity;
|
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.module.sys.config.SystemErrorCode;
|
import com.product.module.sys.version.ApiVersion;
|
import com.product.org.admin.service.ProxyApprovalService;
|
import com.product.org.admin.service.idel.IProxyApprovalService;
|
|
/**
|
*
|
* Copyright LX-BASE
|
*
|
* @Title: ProxyApprovalController
|
* @Project: LX-BASE-SERVER
|
* @Date: 2020年5月29日 上午10:59:54
|
* @Author: 郑盟
|
* @Description:流程代理配置,对应流程代理表
|
*/
|
@RequestMapping("/api/proxy_approval")
|
@RestController
|
public class ProxyApprovalController extends AbstractBaseController {
|
/**
|
* 数据查询 ,spring 注入
|
*/
|
@Autowired
|
public ProxyApprovalService proxyApprovalService;
|
|
@Autowired
|
PermissionService permissionService;
|
|
/**
|
* 根据流程审批代理详情(含子表) @param request @return String @throws
|
*/
|
@RequestMapping(value = "/find-approval/{varsion}", method = RequestMethod.POST)
|
@ApiVersion(1)
|
public String findApproval(HttpServletRequest request) {
|
try {
|
Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
|
RequestParameterEntity reqp = (RequestParameterEntity) bean;
|
FieldSetEntity fse = reqp.getFormData();
|
//数据操作的权限验证
|
if(!permissionService.validDataPermission(fse,CoreConst.DATA_PERMISSION_VALID_TYPE_ORG)) {
|
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());
|
}
|
FieldSetEntity fs = proxyApprovalService.findApproval(fse);
|
return OK_List(fs);
|
} catch (BaseException e) {
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
return this.error(e.getCode(), e.getMessageInfo());
|
}catch (Exception e) {
|
e.printStackTrace();
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
return error(SystemCode.SYSTEM_APPROVAL_LIST_FAIL.getValue(),
|
SystemCode.SYSTEM_APPROVAL_LIST_FAIL.getText()+ e.getMessage());
|
}
|
}
|
|
/**
|
* 流程审批代理列表查询 @param request @return String @throws
|
*/
|
@RequestMapping(value = "/list-approval/{varsion}", method = RequestMethod.POST)
|
@ApiVersion(1)
|
public String listApproval(HttpServletRequest request) {
|
try {
|
Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
|
RequestParameterEntity reqp = (RequestParameterEntity) bean;
|
FieldSetEntity fse = reqp.getFormData();
|
DataTableEntity dt = proxyApprovalService.listApproval(fse);
|
return OK_List(dt);
|
} catch (BaseException e) {
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
return this.error(e.getCode(), e.getMessageInfo());
|
}catch (Exception e) {
|
e.printStackTrace();
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
return error(SystemCode.SYSTEM_APPROVAL_LIST_FAIL.getValue(),
|
SystemCode.SYSTEM_APPROVAL_LIST_FAIL.getText() + e.getMessage());
|
}
|
}
|
|
/**
|
* 流程审批代理新增
|
*
|
* @param request
|
* @return
|
*/
|
@RequestMapping(value = "/add-approval/{varsion}", method = RequestMethod.POST)
|
@ApiVersion(1)
|
public String addApproval(HttpServletRequest request) {
|
try {
|
Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
|
RequestParameterEntity reqp = (RequestParameterEntity) bean;
|
FieldSetEntity fse = reqp.getFormData();
|
IProxyApprovalService service = (IProxyApprovalService) getProxyInstance(proxyApprovalService);
|
return OK_Add(service.addApprovalList(fse));
|
} catch (BaseException e) {
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
return this.error(e.getCode(), e.getMessageInfo());
|
}catch (Exception e) {
|
e.printStackTrace();
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
return error(SystemCode.SYSTEM_APPROVA_ADD_FAIL.getValue(),
|
SystemCode.SYSTEM_APPROVA_ADD_FAIL.getText()+ e.getMessage());
|
}
|
}
|
|
/**
|
* 流程审批代理修改
|
*
|
* @param request
|
* @return
|
*/
|
@RequestMapping(value = "/update-approval/{varsion}", method = RequestMethod.POST)
|
@ApiVersion(1)
|
public String updateApproval(HttpServletRequest request) {
|
try {
|
Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
|
RequestParameterEntity reqp = (RequestParameterEntity) bean;
|
FieldSetEntity fse = reqp.getFormData();
|
//数据操作的权限验证
|
if(!permissionService.validDataPermission(fse,CoreConst.DATA_PERMISSION_VALID_TYPE_ORG)) {
|
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());
|
}
|
IProxyApprovalService service = (IProxyApprovalService) getProxyInstance(proxyApprovalService);
|
//罗鑫2021年3月1日 开始时间不能大于结束时间
|
String effective_start = fse.getString("effective_start");
|
if(BaseUtil.strIsNull(effective_start)){
|
SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_START_TIME_IS_NOTNULL.getValue(),
|
SystemCode.SYSTEM_START_TIME_IS_NOTNULL.getText());
|
return error(SystemCode.SYSTEM_START_TIME_IS_NOTNULL.getValue(), SystemCode.SYSTEM_START_TIME_IS_NOTNULL.getText());
|
}
|
String effective_end = fse.getString("effective_end");
|
if(!BaseUtil.strIsNull(effective_end)) {
|
if (BaseUtil.temporalComparison(effective_start, effective_end)) {
|
SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_START_TIME_FAIL.getValue(),
|
SystemCode.SYSTEM_START_TIME_FAIL.getText());
|
return error(SystemCode.SYSTEM_START_TIME_FAIL.getValue(), SystemCode.SYSTEM_START_TIME_FAIL.getText());
|
}
|
}
|
return service.updateApprovalList(fse) ? OK()
|
: this.error(SystemCode.SYSTEM_APPROVA_UPDATE_FAIL.getValue(),
|
SystemCode.SYSTEM_APPROVA_UPDATE_FAIL.getText());
|
} catch (BaseException e) {
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
return this.error(e.getCode(), e.getMessageInfo());
|
}catch (Exception e) {
|
e.printStackTrace();
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
return error(SystemCode.SYSTEM_APPROVA_UPDATE_FAIL.getValue(),
|
SystemCode.SYSTEM_APPROVA_UPDATE_FAIL.getText()+ e.getMessage());
|
}
|
}
|
|
/**
|
* 根据UUID删除流程审批代理
|
*
|
* @return
|
*/
|
@RequestMapping(value = "/delete-approval/{varsion}", method = RequestMethod.POST)
|
@ApiVersion(1)
|
public String deleteApproval(HttpServletRequest request) {
|
try {
|
Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
|
RequestParameterEntity reqp = (RequestParameterEntity) bean;
|
FieldSetEntity fse = reqp.getFormData();
|
//数据操作的权限验证
|
if(!permissionService.validDataPermission(fse,CoreConst.DATA_PERMISSION_VALID_TYPE_ORG)) {
|
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());
|
}
|
IProxyApprovalService service = (IProxyApprovalService) getProxyInstance(proxyApprovalService);
|
return service.deleteApprovalList(fse) ? OK()
|
: error(SystemCode.SYSTEM_APPROVA_DELETE_FAIL.getValue(),
|
SystemCode.SYSTEM_APPROVA_DELETE_FAIL.getText());
|
} catch (BaseException e) {
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
return this.error(e.getCode(), e.getMessageInfo());
|
}catch (Exception e) {
|
e.printStackTrace();
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
return error(SystemCode.SYSTEM_APPROVA_DELETE_FAIL.getValue(),
|
SystemCode.SYSTEM_APPROVA_DELETE_FAIL.getText()+ e.getMessage());
|
}
|
}
|
|
/**
|
* 根据流程审批代理类型详情
|
*/
|
@RequestMapping(value = "/find-approval_type/{varsion}", method = RequestMethod.POST)
|
@ApiVersion(1)
|
public String findApprovalType(HttpServletRequest request) {
|
try {
|
Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
|
RequestParameterEntity reqp = (RequestParameterEntity) bean;
|
FieldSetEntity fse = reqp.getFormData();
|
FieldSetEntity fs = proxyApprovalService.findApprovalType(fse);
|
return OK_List(fs);
|
} catch (BaseException e) {
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
return this.error(e.getCode(), e.getMessageInfo());
|
}catch (Exception e) {
|
e.printStackTrace();
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
return error(SystemCode.SYSTEM_APPROVAL_TYPE_LIST_FAIL.getValue(),
|
SystemCode.SYSTEM_APPROVAL_TYPE_LIST_FAIL.getText()+ e.getMessage());
|
}
|
}
|
|
/**
|
* 流程审批代理类型新增
|
*
|
* @param request
|
* @return
|
*/
|
@RequestMapping(value = "/add-approval_type/{varsion}", method = RequestMethod.POST)
|
@ApiVersion(1)
|
public String addApprovalType(HttpServletRequest request) {
|
try {
|
Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
|
RequestParameterEntity reqp = (RequestParameterEntity) bean;
|
FieldSetEntity fse = reqp.getFormData();
|
IProxyApprovalService service = (IProxyApprovalService) getProxyInstance(proxyApprovalService);
|
return OK_Add(service.addApprovalType(fse));
|
} catch (BaseException e) {
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
return this.error(e.getCode(), e.getMessageInfo());
|
}catch (Exception e) {
|
e.printStackTrace();
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
return error(SystemCode.SYSTEM_APPROVA_TYPE_ADD_FAIL.getValue(),
|
SystemCode.SYSTEM_APPROVA_TYPE_ADD_FAIL.getText()+ e.getMessage());
|
}
|
}
|
|
/**
|
* 流程审批代理类型修改
|
*
|
* @param request
|
* @return
|
*/
|
@RequestMapping(value = "/update-approval_type/{varsion}", method = RequestMethod.POST)
|
@ApiVersion(1)
|
public String updateApprovalType(HttpServletRequest request) {
|
try {
|
Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
|
RequestParameterEntity reqp = (RequestParameterEntity) bean;
|
FieldSetEntity fse = reqp.getFormData();
|
IProxyApprovalService service = (IProxyApprovalService) getProxyInstance(proxyApprovalService);
|
return service.updateApprovalList(fse) ? OK()
|
: this.error(SystemCode.SYSTEM_APPROVA_TYPE_UPDATE_FAIL.getValue(),
|
SystemCode.SYSTEM_APPROVA_TYPE_UPDATE_FAIL.getText());
|
} catch (BaseException e) {
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
return this.error(e.getCode(), e.getMessageInfo());
|
}catch (Exception e) {
|
e.printStackTrace();
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
return error(SystemCode.SYSTEM_APPROVA_TYPE_UPDATE_FAIL.getValue(),
|
SystemCode.SYSTEM_APPROVA_TYPE_UPDATE_FAIL.getText()+ e.getMessage());
|
}
|
}
|
|
/**
|
* 流程审批代理类型列表查询 @param request @return String @throws
|
*/
|
@RequestMapping(value = "/list-approval_type/{varsion}", method = RequestMethod.POST)
|
@ApiVersion(1)
|
public String listApprovalType(HttpServletRequest request) {
|
try {
|
Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
|
RequestParameterEntity reqp = (RequestParameterEntity) bean;
|
FieldSetEntity fse = reqp.getFormData();
|
DataTableEntity dt = proxyApprovalService.listApprovalType(fse);
|
return OK_List(dt);
|
} catch (BaseException e) {
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
return this.error(e.getCode(), e.getMessageInfo());
|
}catch (Exception e) {
|
e.printStackTrace();
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
return error(SystemCode.SYSTEM_APPROVAL_TYPE_LIST_FAIL.getValue(),
|
SystemCode.SYSTEM_APPROVAL_TYPE_LIST_FAIL.getText()+ e.getMessage());
|
}
|
}
|
|
/**
|
* 根据UUID删除流程审批代理类型
|
*
|
* @return
|
*/
|
@RequestMapping(value = "/delete-approval_type/{varsion}", method = RequestMethod.POST)
|
@ApiVersion(1)
|
public String deleteApprovalType(HttpServletRequest request) {
|
try {
|
Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
|
RequestParameterEntity reqp = (RequestParameterEntity) bean;
|
FieldSetEntity fse = reqp.getFormData();
|
IProxyApprovalService service = (IProxyApprovalService) getProxyInstance(proxyApprovalService);
|
return service.deleteApprovalType(fse) ? OK()
|
: error(SystemCode.SYSTEM_APPROVA_TYPE_DELETE_FAIL.getValue(),
|
SystemCode.SYSTEM_APPROVA_TYPE_DELETE_FAIL.getText());
|
} catch (BaseException e) {
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
return this.error(e.getCode(), e.getMessageInfo());
|
}catch (Exception e) {
|
e.printStackTrace();
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
return error(SystemCode.SYSTEM_APPROVA_TYPE_DELETE_FAIL.getValue(),
|
SystemCode.SYSTEM_APPROVA_TYPE_DELETE_FAIL.getText()+ e.getMessage());
|
}
|
}
|
}
|