|
@@ -1,19 +1,36 @@
|
|
package com.dragoninfo.dcuc.authweb.restcontroller.api.authservice.v1.controller;
|
|
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.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.authweb.util.VersionUtils;
|
|
import com.dragoninfo.dcuc.common.entity.ApiResult;
|
|
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.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.Api;
|
|
import io.swagger.annotations.ApiImplicitParam;
|
|
import io.swagger.annotations.ApiImplicitParam;
|
|
import io.swagger.annotations.ApiImplicitParams;
|
|
import io.swagger.annotations.ApiImplicitParams;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
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.PostMapping;
|
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
+import java.util.HashMap;
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.Map;
|
|
|
|
|
|
/**
|
|
/**
|
|
* @Author yica
|
|
* @Author yica
|
|
@@ -27,6 +44,11 @@ public class AuthServiceController {
|
|
@Autowired
|
|
@Autowired
|
|
private IServiceAuthFacade serviceAuthFacade;
|
|
private IServiceAuthFacade serviceAuthFacade;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private IServiceAuthResultFacade serviceAuthResultFacade;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IApplyInfoFacade applyInfoFacade;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 服务级鉴权
|
|
* 服务级鉴权
|
|
*
|
|
*
|
|
@@ -39,11 +61,39 @@ public class AuthServiceController {
|
|
public ApiResult authentication(HttpServletRequest request) {
|
|
public ApiResult authentication(HttpServletRequest request) {
|
|
String appCode = request.getHeader("appCode");
|
|
String appCode = request.getHeader("appCode");
|
|
if (StringUtils.isEmpty(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);
|
|
Object o = serviceAuthFacade.serviceAuthentication(appCode);
|
|
return ApiResult.setSuccessResult(o);
|
|
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);
|
|
|
|
+ }
|
|
}
|
|
}
|