|
@@ -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);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|