|
@@ -0,0 +1,146 @@
|
|
|
+package com.dragoninfo.dcuc.authweb.restcontroller.sub;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.TypeReference;
|
|
|
+import com.dragoninfo.dcuc.app.entity.ApplyInfo;
|
|
|
+import com.dragoninfo.dcuc.auth.sub.dto.AttrInfoTreeDTO;
|
|
|
+import com.dragoninfo.dcuc.auth.sub.dto.AttrRelAcceptDTO;
|
|
|
+import com.dragoninfo.dcuc.auth.sub.dto.RelSearchDTO;
|
|
|
+import com.dragoninfo.dcuc.auth.auth.enumresources.sub.AttrBelongTypeEnum;
|
|
|
+import com.dragoninfo.dcuc.auth.auth.enumresources.sub.AttrTypeEnum;
|
|
|
+import com.dragoninfo.dcuc.auth.sub.facade.IAttrFacade;
|
|
|
+import com.dragoninfo.dcuc.authweb.restcontroller.sub.vo.attr.AttrInfoTreeVo;
|
|
|
+import com.dragoninfo.dcuc.authweb.restcontroller.sub.vo.attr.AttrRelAcceptVo;
|
|
|
+import com.dragoninfo.dcuc.authweb.util.VersionUtils;
|
|
|
+import com.dragoninfo.duceap.core.response.Result;
|
|
|
+import com.dragonsoft.duceap.base.entity.http.ResponseStatus;
|
|
|
+import com.dragonsoft.duceap.core.search.Searchable;
|
|
|
+import com.dragonsoft.duceap.core.search.filter.Condition;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiImplicitParam;
|
|
|
+import io.swagger.annotations.ApiImplicitParams;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+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.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 主客体属性管理controller
|
|
|
+ * @author mazq
|
|
|
+ * @date 2021/5/20
|
|
|
+ */
|
|
|
+@Slf4j
|
|
|
+@Api(tags = {"主客体授权-属性管理接口"})
|
|
|
+@RestController
|
|
|
+@RequestMapping(value = "/attrsvr/"+ VersionUtils.VERSION_UID)
|
|
|
+public class AttrController {
|
|
|
+
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IAttrFacade attrFacade;
|
|
|
+
|
|
|
+ @ApiOperation(value = "添加主客体属性")
|
|
|
+ @ApiImplicitParam(name = "AttrInfoTreeVo", value = "主客体属性Vo")
|
|
|
+ @PostMapping(value = "attrAdds")
|
|
|
+ public Result attrAdds(@RequestBody AttrInfoTreeVo vo){
|
|
|
+ String voStr = JSON.toJSONString(vo);
|
|
|
+ AttrInfoTreeDTO dto = JSON.parseObject(voStr, new TypeReference<AttrInfoTreeDTO>() {{
|
|
|
+ }});
|
|
|
+ BeanUtils.copyProperties(vo,dto);
|
|
|
+ ResponseStatus response = attrFacade.attrSave(dto);
|
|
|
+ if (ResponseStatus.SUCCESS_CODE.equals(response.getStatusCode())) {
|
|
|
+ return Result.success();
|
|
|
+ } else {
|
|
|
+ return Result.fail(response.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "根据id,删除本级下的所有主客体属性,包括本级")
|
|
|
+ @ApiImplicitParams(value = {
|
|
|
+ @ApiImplicitParam(name = "id", value = "本级id"),
|
|
|
+ @ApiImplicitParam(name = "attrType", value = "属性类别 SUB:主体属性 OBJ:客体属性"),
|
|
|
+ @ApiImplicitParam(name = "attrBelongType", value = "属性所属的主客体类别 USER:人员 ORG:机构 APP:应用 FUN:功能 SER:服务")
|
|
|
+ })
|
|
|
+ @GetMapping(value = "deleteAllById")
|
|
|
+ public Result deleteAllById(@RequestParam("id") String id,
|
|
|
+ @RequestParam("attrType") String attrType,
|
|
|
+ @RequestParam("attrBelongType") String attrBelongType) {
|
|
|
+ Boolean b = attrFacade.deleteAllById(id,attrBelongType,attrType);
|
|
|
+ if (b) {
|
|
|
+ return Result.success();
|
|
|
+ } else {
|
|
|
+ return Result.fail();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "根据属性所属类别获取属性列表,返回树结构")
|
|
|
+ @ApiImplicitParam(name = "attrType", value = "属性类别 SUB:主体属性 OBJ:客体属性")
|
|
|
+ @GetMapping(value = "getAttrTreeList")
|
|
|
+ public Result getAttrTreeList(@RequestParam("attrType") String attrType) {
|
|
|
+ List<AttrInfoTreeDTO> list = attrFacade.getAttrTreeList(attrType);
|
|
|
+ String dtoStr = JSON.toJSONString(list);
|
|
|
+ List<AttrInfoTreeVo> voList = JSON.parseObject(dtoStr, new TypeReference<List<AttrInfoTreeVo>>() {{
|
|
|
+ }});
|
|
|
+ return Result.success(voList);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "属性关联主客体关系添加")
|
|
|
+ @ApiImplicitParam(name = "attrRelAcceptVo", value = "主客体-属性关联关系添加对象")
|
|
|
+ @PostMapping(value = "attrRelAdd")
|
|
|
+ public Result attrRelAdd(@RequestBody AttrRelAcceptVo vo) {
|
|
|
+ AttrRelAcceptDTO dto = new AttrRelAcceptDTO();
|
|
|
+ BeanUtils.copyProperties(vo,dto);
|
|
|
+ Boolean b = attrFacade.relAdd(dto);
|
|
|
+ if (b) {
|
|
|
+ return Result.success();
|
|
|
+ } else {
|
|
|
+ return Result.fail();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "查询属性关联的id集合")
|
|
|
+ @ApiImplicitParams(value = {
|
|
|
+ @ApiImplicitParam(name = "attrId", value = "parentId属性父类id"),
|
|
|
+ @ApiImplicitParam(name = "attrType", value = "属性类别 SUB:主体属性 OBJ:客体属性"),
|
|
|
+ @ApiImplicitParam(name = "attrBelongType", value = "属性所属的主客体类别 USER:人员 ORG:机构 APP:应用 FUN:功能 SER:服务")
|
|
|
+ })
|
|
|
+ @GetMapping(value = "attrRelToIds")
|
|
|
+ public Result<List<String>> attrRelToIds(@RequestParam("attrId") String attrId,
|
|
|
+ @RequestParam("attrType") String attrType,
|
|
|
+ @RequestParam("attrBelongType") String attrBelongType) {
|
|
|
+ List<String> relIds = attrFacade.attrRelToIds(attrId, attrType, attrBelongType);
|
|
|
+ return Result.success(relIds);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "查询属性关联的应用列表")
|
|
|
+ @ApiImplicitParam(name = "RelSearchVo",
|
|
|
+ value = "searchable 应用列表查询条件[attrId: 属性id op: eq] [name: 应用名称 op:like][status: 在用状态 op: eq]")
|
|
|
+ @PostMapping(value = "relAppPage")
|
|
|
+ public Result relAppPage(Searchable searchable) {
|
|
|
+ RelSearchDTO dto = convertToRelSearch(searchable);
|
|
|
+ Page<ApplyInfo> page = attrFacade.relAppPage(dto);
|
|
|
+ return Result.success(page.getTotalElements(),page.getContent());
|
|
|
+ }
|
|
|
+
|
|
|
+ private RelSearchDTO convertToRelSearch(Searchable searchable) {
|
|
|
+ Condition nameCondition = searchable.getSearchFilterByKey("name_like");
|
|
|
+ Condition attrIdEq = searchable.getSearchFilterByKey("attrId_eq");
|
|
|
+ RelSearchDTO dto = new RelSearchDTO(attrIdEq.getValue().toString(),
|
|
|
+ AttrTypeEnum.OBJ.getCode(),
|
|
|
+ AttrBelongTypeEnum.APP.getCode());
|
|
|
+ if(null != nameCondition) {
|
|
|
+ dto.setName(nameCondition.getValue().toString());
|
|
|
+ }
|
|
|
+ Condition statusCondition = searchable.getSearchFilterByKey("status_eq");
|
|
|
+ if(null != statusCondition) {
|
|
|
+ dto.setStatus(statusCondition.getValue().toString());
|
|
|
+ }
|
|
|
+ dto.setPage(searchable.getPageNumber());
|
|
|
+ dto.setSize(searchable.getPageSize());
|
|
|
+ return dto;
|
|
|
+ }
|
|
|
+}
|