Explorar o código

1.新增服务授权列表等

yica %!s(int64=4) %!d(string=hai) anos
pai
achega
6d6bafa818

+ 51 - 1
src/main/java/com/dragoninfo/dcuc/authweb/restcontroller/api/authservice/v1/controller/AuthServiceController.java

@@ -1,19 +1,36 @@
 package com.dragoninfo.dcuc.authweb.restcontroller.api.authservice.v1.controller;
 
+import com.dragoninfo.dcuc.app.entity.ApplyInfo;
+import com.dragoninfo.dcuc.app.facade.IApplyInfoFacade;
+import com.dragoninfo.dcuc.auth.auth.dto.ServiceAuthResultDTO;
 import com.dragoninfo.dcuc.auth.auth.facade.IServiceAuthFacade;
+import com.dragoninfo.dcuc.auth.auth.facade.IServiceAuthResultFacade;
+import com.dragoninfo.dcuc.authweb.restcontroller.api.authservice.v1.vo.ServiceAuthResultVo;
 import com.dragoninfo.dcuc.authweb.util.VersionUtils;
 import com.dragoninfo.dcuc.common.entity.ApiResult;
+import com.dragoninfo.dcuc.common.entity.ApiSearchReq;
+import com.dragoninfo.dcuc.common.utils.SearchableUtil;
+import com.dragonsoft.duceap.base.enums.BooleanEnum;
 import com.dragonsoft.duceap.commons.util.string.StringUtils;
+import com.dragonsoft.duceap.core.search.Searchable;
+import com.dragonsoft.duceap.core.search.enums.SearchOperator;
 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.data.domain.Page;
 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.RestController;
 
 import javax.servlet.http.HttpServletRequest;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 
 /**
  * @Author yica
@@ -27,6 +44,11 @@ public class AuthServiceController {
     @Autowired
     private IServiceAuthFacade serviceAuthFacade;
 
+    @Autowired
+    private IServiceAuthResultFacade serviceAuthResultFacade;
+    @Autowired
+    private IApplyInfoFacade applyInfoFacade;
+
     /**
      * 服务级鉴权
      *
@@ -39,11 +61,39 @@ public class AuthServiceController {
     public ApiResult authentication(HttpServletRequest request) {
         String appCode = request.getHeader("appCode");
         if (StringUtils.isEmpty(appCode)){
-            return ApiResult.setFailMessage("appcode不能为空");
+            return ApiResult.setFailMessage("appCode is not null");
+        }
+        ApplyInfo applyInfo = applyInfoFacade.getAppByCode(appCode);
+        if (applyInfo==null|| BooleanEnum.TRUE.value.equals(applyInfo.getApplyStatus())){
+            return ApiResult.setFailMessage("app is not enabled");
         }
         Object o = serviceAuthFacade.serviceAuthentication(appCode);
         return ApiResult.setSuccessResult(o);
     }
 
 
+    @ApiOperation(value = "授权服务列表")
+    @PostMapping("service/search")
+    public ApiResult policeSearch(@RequestBody ApiSearchReq apiSearchReq){
+        Map<String, SearchOperator[]> requestMap = new HashMap<>();
+        requestMap.put("appCode", new SearchOperator[]{SearchOperator.eq});
+        requestMap.put("serviceCode", new SearchOperator[]{SearchOperator.eq});
+        Searchable searchable;
+        try {
+            searchable = SearchableUtil.parseApiSearchReqToSearchable(apiSearchReq, requestMap, 1000);
+        } catch (IllegalArgumentException e) {
+            String message = e.getMessage();
+            return ApiResult.setFailMessage(message);
+        }
+        Page<ServiceAuthResultDTO> serviceAuthResultDTOS = serviceAuthResultFacade.serviceAuthResultPage(searchable.toSearchDTO());
+        List<ServiceAuthResultDTO> content = serviceAuthResultDTOS.getContent();
+        List<ServiceAuthResultVo> voList = new ArrayList<>(content.size());
+
+        content.forEach(item->{
+            ServiceAuthResultVo vo=new ServiceAuthResultVo();
+            BeanUtils.copyProperties(item,vo);
+            voList.add(vo);
+        });
+        return ApiResult.setSuccessPage(serviceAuthResultDTOS.getTotalElements(),voList);
+    }
 }

+ 30 - 0
src/main/java/com/dragoninfo/dcuc/authweb/restcontroller/api/authservice/v1/vo/ServiceAuthResultVo.java

@@ -0,0 +1,30 @@
+package com.dragoninfo.dcuc.authweb.restcontroller.api.authservice.v1.vo;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * @Author yica
+ * @Date 2021/3/10 15:22
+ **/
+@Data
+public class ServiceAuthResultVo {
+
+
+    @ApiModelProperty(value = "应用code",required = true)
+    private String appCode;
+
+    @ApiModelProperty(value = "应用appName",required = true)
+    private String appName;
+
+    @ApiModelProperty(value = "服务code",required = true)
+    private String serviceCode;
+
+    @ApiModelProperty(value = "服务名称",required = true)
+    private String serviceName;
+
+
+}

+ 11 - 5
src/main/java/com/dragoninfo/dcuc/authweb/restcontroller/api/authservice/v3/controller/AuthV3ApiController.java

@@ -1,5 +1,7 @@
 package com.dragoninfo.dcuc.authweb.restcontroller.api.authservice.v3.controller;
 
+import com.dragoninfo.dcuc.app.entity.ApplyInfo;
+import com.dragoninfo.dcuc.app.facade.IApplyInfoFacade;
 import com.dragoninfo.dcuc.auth.auth.dto.AppResourcesDto;
 import com.dragoninfo.dcuc.auth.auth.dto.RoleApiDto;
 import com.dragoninfo.dcuc.auth.auth.facade.IRoleFacade;
@@ -14,6 +16,7 @@ import com.dragoninfo.dcuc.user.user.entity.UserInfo;
 import com.dragoninfo.dcuc.user.user.facade.IUserInfoFacade;
 import com.dragonsoft.duceap.base.entity.http.ResponseDTO;
 import com.dragonsoft.duceap.base.entity.http.ResponseStatus;
+import com.dragonsoft.duceap.base.enums.BooleanEnum;
 import com.dragonsoft.duceap.commons.util.string.StringUtils;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
@@ -47,10 +50,9 @@ public class AuthV3ApiController {
     private IRoleFacade roleFacade;
     @Autowired
     private IUserInfoFacade userInfoFacade;
+
     @Autowired
-    private IServiceAuthFacade serviceAuthFacade;
-    @Resource(name = "redisTemplate")
-    private RedisTemplate<String, Object> redisTemplate;
+    private IApplyInfoFacade applyInfoFacade;
 
     /**
      * 推送资源
@@ -118,10 +120,14 @@ public class AuthV3ApiController {
     @ApiImplicitParams({@ApiImplicitParam(name = "AuthManagerRes", value = "资源vo")})
     public ApiResult getFunctions(@RequestBody AuthManagerRes managerRes) {
         if (StringUtils.isEmpty(managerRes.getAppCode())) {
-            return ApiResult.setFailMessage("appCode不能为空");
+            return ApiResult.setFailMessage("appCode is not null");
+        }
+        ApplyInfo applyInfo = applyInfoFacade.getAppByCode(managerRes.getAppCode());
+        if (applyInfo==null|| BooleanEnum.TRUE.value.equals(applyInfo.getApplyStatus())){
+            return ApiResult.setFailMessage("app is not enabled");
         }
         if (StringUtils.isEmpty(managerRes.getIdcard())) {
-            return ApiResult.setFailMessage("idcard不能为空");
+            return ApiResult.setFailMessage("idcard is not null");
         }
         UserInfo userInfo = userInfoFacade.userDetail("idcard", managerRes.getIdcard());
         if (userInfo == null) {

+ 6 - 0
src/main/java/com/dragoninfo/dcuc/authweb/restcontroller/app/vo/ServiceResourceVo.java

@@ -1,5 +1,7 @@
 package com.dragoninfo.dcuc.authweb.restcontroller.app.vo;
 
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
 /**
@@ -9,18 +11,22 @@ import lombok.Data;
  * @create 2020-11-25 14:21
  */
 @Data
+@Api(value = "服务资源vo")
 public class ServiceResourceVo extends ResourceVo {
 
     /**
      * 服务在用状态
      */
+    @ApiModelProperty(value = "服务在用状态",required = true)
     private String serviceStatus;
     /**
      * 服务编码
      */
+    @ApiModelProperty(value = "服务编码",required = true)
     private String serviceCode;
     /**
      * 服务名称
      */
+    @ApiModelProperty(value = "服务名称",required = true)
     private String serviceName;
 }

+ 0 - 56
src/main/java/com/dragoninfo/dcuc/authweb/restcontroller/auth/ServiceAuthController.java

@@ -1,56 +0,0 @@
-package com.dragoninfo.dcuc.authweb.restcontroller.auth;
-
-import com.dragoninfo.dcuc.app.facade.IResourceFacade;
-import com.dragoninfo.dcuc.auth.auth.dto.ServiceAuthFlowDTO;
-import com.dragoninfo.dcuc.auth.auth.facade.IServiceAuthFacade;
-import com.dragoninfo.dcuc.auth.power.facade.IAppFunInfoFacade;
-import com.dragoninfo.dcuc.authweb.restcontroller.auth.vo.ServiceAuthVo;
-import com.dragoninfo.duceap.core.response.Result;
-import com.dragonsoft.duceap.base.entity.search.SearchDTO;
-import com.dragonsoft.duceap.commons.util.string.StringUtils;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiImplicitParam;
-import io.swagger.annotations.ApiOperation;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.domain.Page;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @Author yica
- * @Date 2021/2/20 17:17
- **/
-@Api(tags = {"服务授权管理接口"})
-@RestController
-@RequestMapping(value = "/authsvr/v2/service/")
-public class ServiceAuthController {
-
-    @Autowired
-    private IServiceAuthFacade serviceAuthFacade;
-
-
-
-
-    @ApiOperation(value = "服务授权列表")
-    @ApiImplicitParam(name = "searchDTO", value = "查询条件")
-    @PostMapping(value = "search")
-    public Result page(SearchDTO searchDTO){
-        Page<ServiceAuthFlowDTO> serviceAuthFlowDTOS = serviceAuthFacade.serviceAuthFlowPage(searchDTO);
-        List<ServiceAuthVo> vos=new ArrayList<>();
-        serviceAuthFlowDTOS.getContent().forEach(item->{
-            ServiceAuthVo vo=new ServiceAuthVo();
-            vo.setApplicantName(item.getApplicantName());
-            vo.setAppName(item.getAppName());
-            vo.setApprovalOrgName(item.getApplicantOrgName());
-            vo.setOrderNo(item.getDesc());
-            vo.setServiceCodes(item.getServiceCodes());
-            vo.setApplyTime(item.getApplyTime());
-            vos.add(vo);
-        });
-        return Result.success(serviceAuthFlowDTOS.getTotalElements(),vos);
-    }
-}

+ 112 - 0
src/main/java/com/dragoninfo/dcuc/authweb/restcontroller/auth/ServiceAuthResultController.java

@@ -0,0 +1,112 @@
+package com.dragoninfo.dcuc.authweb.restcontroller.auth;
+
+import com.dragoninfo.dcuc.app.entity.ApplyInfo;
+import com.dragoninfo.dcuc.app.entity.ServiceResource;
+import com.dragoninfo.dcuc.app.facade.IApplyInfoFacade;
+import com.dragoninfo.dcuc.app.facade.IServiceResourceFacade;
+import com.dragoninfo.dcuc.auth.auth.dto.ServiceAuthResultDTO;
+import com.dragoninfo.dcuc.auth.auth.facade.IServiceAuthResultFacade;
+import com.dragoninfo.dcuc.authweb.restcontroller.auth.vo.ServiceAuthVo;
+import com.dragoninfo.dcuc.authweb.util.VersionUtils;
+import com.dragoninfo.duceap.core.response.Result;
+import com.dragonsoft.duceap.base.entity.http.ResponseDTO;
+import com.dragonsoft.duceap.base.entity.search.SearchDTO;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @Author yica
+ * @Date 2021/2/20 17:17
+ **/
+@Api(tags = {"服务授权管理接口"})
+@RestController
+@RequestMapping(value = "/authsvr/"+ VersionUtils.VERSION_UID +"/service/")
+public class ServiceAuthResultController {
+
+
+
+    @Autowired
+    private IServiceAuthResultFacade serviceAuthResultFacade;
+
+    @Autowired
+    private IApplyInfoFacade applyInfoFacade;
+
+    @Autowired
+    private IServiceResourceFacade serviceResourceFacade;
+
+
+    @ApiOperation(value = "服务授权列表")
+    @ApiImplicitParam(name = "searchDTO", value = "查询条件")
+    @PostMapping(value = "search")
+    public Result page(SearchDTO searchDTO){
+        Page<ServiceAuthResultDTO> serviceAuthResultDTOS = serviceAuthResultFacade.serviceAuthResultPage(searchDTO);
+        List<ServiceAuthVo> list=new ArrayList<>();
+        serviceAuthResultDTOS.forEach(item->{
+            ServiceAuthVo serviceAuthVo=new ServiceAuthVo();
+            BeanUtils.copyProperties(item,serviceAuthVo);
+            list.add(serviceAuthVo);
+        });
+        return Result.success(serviceAuthResultDTOS.getTotalElements(),list);
+    }
+
+
+    @ApiOperation(value = "服务授权修改")
+    @ApiImplicitParam(name = "ServiceAuthVo", value = "服务授权vo")
+    @PutMapping(value = "auth/{id}")
+    public Result updateService(@RequestBody ServiceAuthVo vo){
+        return Result.success();
+    }
+
+    @ApiOperation(value = "服务授权保存")
+    @ApiImplicitParam(name = "ServiceAuthVo", value = "服务授权vo")
+    @PostMapping(value = "auth")
+    public Result saveService(@RequestBody ServiceAuthVo vo){
+        ServiceAuthResultDTO dto=new ServiceAuthResultDTO();
+        BeanUtils.copyProperties(vo,dto);
+        ResponseDTO responseDTO = serviceAuthResultFacade.saveServiceAuthResult(dto);
+        if (ResponseDTO.SUCCESS_CODE.equals(responseDTO.getStatusCode())){
+            return Result.success(responseDTO.getMessage());
+        }
+        return Result.fail(responseDTO.getMessage());
+    }
+
+
+    @ApiOperation(value = "服务授权删除")
+    @ApiImplicitParam(name = "searchDTO", value = "服务授权vo")
+    @DeleteMapping(value = "auth/{id}")
+    public Result delService(@PathVariable("id") String id){
+        ResponseDTO responseDTO = serviceAuthResultFacade.delServiceAuthResult(id);
+        if (ResponseDTO.SUCCESS_CODE.equals(responseDTO.getStatusCode())){
+            return Result.success(responseDTO.getMessage());
+        }
+        return Result.fail(responseDTO.getMessage());
+    }
+
+
+    @ApiOperation(value = "服务授权详情")
+    @ApiImplicitParam(name = "ServiceAuthVo", value = "服务授权vo")
+    @GetMapping(value = "auth/{id}")
+    public Result getService(@PathVariable("id") String id){
+        ServiceAuthResultDTO dto = serviceAuthResultFacade.getDetail(id);
+        ServiceAuthVo vo=new ServiceAuthVo();
+        BeanUtils.copyProperties(dto,vo);
+        ApplyInfo applyInfo = applyInfoFacade.applyDetail(dto.getAppId());
+        if (applyInfo!=null){
+            vo.setAppName(applyInfo.getApplyName());
+        }
+        ServiceResource serviceResource = serviceResourceFacade.detailByCode(dto.getServiceCode());
+        if (serviceResource!=null) {
+            vo.setServiceName(serviceResource.getServiceName());
+        }
+        return Result.success(vo);
+    }
+
+}

+ 51 - 0
src/main/java/com/dragoninfo/dcuc/authweb/restcontroller/auth/ServiceResourceController.java

@@ -0,0 +1,51 @@
+package com.dragoninfo.dcuc.authweb.restcontroller.auth;
+
+import com.dragoninfo.dcuc.app.entity.ServiceResource;
+import com.dragoninfo.dcuc.app.facade.IServiceResourceFacade;
+import com.dragoninfo.dcuc.authweb.restcontroller.app.vo.ServiceResourceVo;
+import com.dragoninfo.dcuc.authweb.util.VersionUtils;
+import com.dragoninfo.duceap.core.response.Result;
+import com.dragonsoft.duceap.base.entity.search.SearchDTO;
+import com.dragonsoft.duceap.core.search.Searchable;
+import com.dragonsoft.duceap.core.search.enums.SearchOperator;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @Author yica
+ * @Date 2021/3/11 13:33
+ **/
+@Api(tags = {"服务资源管理接口"})
+@RestController
+@RequestMapping(value = "/authsvr/"+ VersionUtils.VERSION_UID +"/resource/")
+public class ServiceResourceController {
+    @Autowired
+    private IServiceResourceFacade serviceResourceFacade;
+
+    @ApiOperation(value = "服务资源列表")
+    @ApiImplicitParam(name = "serviceName", value = "查询条件")
+    @PostMapping(value = "search/drop")
+    public Result droplist(@RequestBody ServiceResourceVo vo){
+        SearchDTO searchDTO=new SearchDTO();
+        searchDTO.setSize("100");
+        searchDTO.setPage("0");
+        Searchable searchable=Searchable.toSearchable(searchDTO);
+        searchable.addSearchFilter("serviceName", SearchOperator.like,vo.getServiceName());
+        Page<ServiceResource> serviceResources = serviceResourceFacade.resourcePages(searchable.toSearchDTO());
+        List<ServiceResourceVo> list=new ArrayList<>();
+        serviceResources.getContent().forEach(item->{
+            ServiceResourceVo resourceVo=new ServiceResourceVo();
+            BeanUtils.copyProperties(item,resourceVo);
+            list.add(resourceVo);
+        });
+        return Result.success(list);
+    }
+}

+ 13 - 13
src/main/java/com/dragoninfo/dcuc/authweb/restcontroller/auth/vo/ServiceAuthVo.java

@@ -13,30 +13,30 @@ import java.util.Date;
  **/
 @Data
 @Api(value = "服务授权vo")
-public class ServiceAuthVo {
+public class  ServiceAuthVo {
     @ApiModelProperty(value = "id",required = true)
     private String id;
 
-    @ApiModelProperty(value = "申请人",required = true)
-    private String applicantName;
+    @ApiModelProperty(value = "应用id",required = true)
+    private String appId;
 
-    @ApiModelProperty(value = "申请单位",required = true)
-    private String approvalOrgName;
-
-    @ApiModelProperty(value = "工单号",required = true)
-    private String orderNo;
+    @ApiModelProperty(value = "应用code",required = true)
+    private String appCode;
 
     @ApiModelProperty(value = "应用名称",required = true)
     private String appName;
 
+
+    @ApiModelProperty(value = "服务id",required = true)
+    private String serviceId;
+
     @ApiModelProperty(value = "服务code",required = true)
-    private String serviceCodes;
+    private String serviceCode;
 
     @ApiModelProperty(value = "服务名称",required = true)
-    private String serviceNames;
-
+    private String serviceName;
 
-    @ApiModelProperty(value = "申请时间",required = true)
+    @ApiModelProperty(value = "创建时间")
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
-    private Date applyTime;
+    private Date createTime;
 }

+ 54 - 0
src/main/java/com/dragoninfo/dcuc/authweb/restcontroller/auth/vo/ServiceResourceBackVo.java

@@ -0,0 +1,54 @@
+package com.dragoninfo.dcuc.authweb.restcontroller.auth.vo;
+
+import com.baomidou.mybatisplus.annotation.TableLogic;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * @Author yica
+ * @Date 2021/3/11 13:37
+ **/
+@Data
+@Api(value = "服务资源vo")
+public class ServiceResourceBackVo {
+
+    @ApiModelProperty(value = "id",required = true)
+    private String id;
+
+
+
+    @ApiModelProperty(value = "资源枚举类-资源类型",required = true)
+    private String resourceType;
+
+    /**
+     * 服务编码
+     */
+    @ApiModelProperty(value = "服务编码",required = true)
+    private String serviceCode;
+
+    /**
+     * 服务名称
+     */
+    @ApiModelProperty(value = "服务名称")
+    private String serviceName;
+
+    /**
+     * 服务资源状态代码 0:未激活;1:启用;2:停止;3:撤销;
+     */
+    @ApiModelProperty(value = "服务资源状态代码 0:未激活;1:启用;2:停止;3:撤销")
+    private String serviceStatus;
+
+    /**
+     * 服务访问地址
+     */
+    @ApiModelProperty(value = "服务访问地址")
+    private String serviceUrl;
+
+
+
+
+
+}