|
@@ -0,0 +1,107 @@
|
|
|
+package com.dragoninfo.dcuc.authweb.restcontroller.api.authservice.v3.controller;
|
|
|
+
|
|
|
+import com.dragoninfo.dcuc.auth.auth.dto.ServiceAuthFlowDTO;
|
|
|
+import com.dragoninfo.dcuc.auth.auth.enumresources.WorkFlowApplyTypeEnum;
|
|
|
+import com.dragoninfo.dcuc.auth.auth.enumresources.WorkFlowTypeEnum;
|
|
|
+import com.dragoninfo.dcuc.auth.auth.facade.IServiceAuthFlowFacade;
|
|
|
+import com.dragoninfo.dcuc.authweb.restcontroller.api.authservice.v1.vo.ResourceAuthInfoVo;
|
|
|
+import com.dragoninfo.dcuc.authweb.restcontroller.api.authservice.v1.vo.ServiceAuthFlowAcceptVo;
|
|
|
+import com.dragoninfo.dcuc.common.Constants;
|
|
|
+import com.dragoninfo.dcuc.common.entity.ApiResult;
|
|
|
+import com.dragonsoft.duceap.base.entity.http.ResponseDTO;
|
|
|
+import com.dragonsoft.duceap.base.entity.http.ResponseStatus;
|
|
|
+import com.dragonsoft.duceap.commons.util.string.StringUtils;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiImplicitParam;
|
|
|
+import io.swagger.annotations.ApiImplicitParams;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Controller;
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
+
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author mazq
|
|
|
+ * @date 2021/2/24
|
|
|
+ */
|
|
|
+@Api(tags = {"服务授权审批工单处理接口"})
|
|
|
+@Controller
|
|
|
+@RequestMapping(value = "/api/auth-service/v3/workflow/")
|
|
|
+public class WorkFlowApiV3Controller {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IServiceAuthFlowFacade serviceAuthFacade;
|
|
|
+
|
|
|
+ //流程code
|
|
|
+ private final static String BS_CODE="service-auth-apply";
|
|
|
+ //名称(名称随便)
|
|
|
+ private final static String BS_NAME="权限新增";
|
|
|
+ //流程业务类型
|
|
|
+ private final static String BS_TYPE="auth-update";
|
|
|
+ //权限移除流程code
|
|
|
+ private final static String BS_REMOVE_CODE="service-auth-remove";
|
|
|
+ //权限移除流程业务类型
|
|
|
+ private final static String BS_REMOVE_TYPE="auth-update";
|
|
|
+ //权限移除流程业务类型
|
|
|
+ private final static String BS_REMOVE_NAME="权限移除";
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 服务授权工作单保存
|
|
|
+ */
|
|
|
+ @ApiOperation(value = "服务授权工单保存")
|
|
|
+ @ApiImplicitParams({@ApiImplicitParam(name = "serviceAuthFlowVo", value = "服务授权工单保存Vo")})
|
|
|
+ @PostMapping("service")
|
|
|
+ @ResponseBody
|
|
|
+ public ApiResult serviceAuthFlowSave(@RequestBody ServiceAuthFlowAcceptVo serviceAuthFlowVo, HttpServletRequest request) {
|
|
|
+ String idcard = request.getHeader(Constants.IDCARD);
|
|
|
+ String tonken = request.getHeader(Constants.DCUC_USER_TOKEN);
|
|
|
+ String user = StringUtils.isNotBlank(idcard) ? idcard : tonken;
|
|
|
+ if (StringUtils.isEmpty(serviceAuthFlowVo.getFlowType())){
|
|
|
+ return ApiResult.setFailMessage("工作单类型不能为空");
|
|
|
+ }
|
|
|
+ //放入流程标识码
|
|
|
+ if (serviceAuthFacade.checkApplicantId(serviceAuthFlowVo.getApplicantId())) {
|
|
|
+ return ApiResult.setFailMessage(String.format("申请单号 %s 不是唯一", serviceAuthFlowVo.getApplicantId()));
|
|
|
+ }
|
|
|
+ ServiceAuthFlowDTO dto = new ServiceAuthFlowDTO();
|
|
|
+ setAppServiceInfo(dto, serviceAuthFlowVo);
|
|
|
+ //销权
|
|
|
+// if (WorkFlowTypeEnum.SERVICE_AUTH_CANCEL.getValue().equals(serviceAuthFlowVo.getFlowType())){
|
|
|
+// dto.setProcessName(BS_REMOVE_NAME);
|
|
|
+// dto.setProcessType(BS_REMOVE_TYPE);
|
|
|
+// dto.setBusinessCode(BS_REMOVE_CODE);
|
|
|
+// }else {
|
|
|
+ //授权
|
|
|
+ dto.setProcessName(BS_NAME);
|
|
|
+ dto.setProcessType(BS_TYPE);
|
|
|
+ dto.setBusinessCode(BS_CODE);
|
|
|
+// }
|
|
|
+ BeanUtils.copyProperties(serviceAuthFlowVo, dto, "serviceCodes", "serviceNames");
|
|
|
+ dto.setUser(user);
|
|
|
+ ResponseDTO responseDTO = serviceAuthFacade.serviceAuthFlowSave(dto);
|
|
|
+ String statusCode = responseDTO.getStatusCode();
|
|
|
+ if (ResponseStatus.SUCCESS_CODE.equals(statusCode)) {
|
|
|
+ return ApiResult.setSuccess();
|
|
|
+ } else {
|
|
|
+ return ApiResult.setFailMessage(responseDTO.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 设置申请单appCode和serviceCode信息
|
|
|
+ */
|
|
|
+ private void setAppServiceInfo(ServiceAuthFlowDTO dto, ServiceAuthFlowAcceptVo serviceAuthFlowVo) {
|
|
|
+ ResourceAuthInfoVo resourceInfo = serviceAuthFlowVo.getResourceInfo();
|
|
|
+ dto.setAppName(resourceInfo.getVisitorName());
|
|
|
+ dto.setAppCode(resourceInfo.getVisitorCode());
|
|
|
+ dto.setServiceCodes(resourceInfo.getVisitResourceCode());
|
|
|
+ dto.setServiceNames(resourceInfo.getVisitResourceName());
|
|
|
+ }
|
|
|
+
|
|
|
+}
|