Merge branch 'dev' into test
This commit is contained in:
@@ -4,6 +4,9 @@ import com.zt.plat.framework.common.pojo.CommonResult;
|
||||
import com.zt.plat.framework.common.pojo.PageResult;
|
||||
import com.zt.plat.framework.common.util.object.BeanUtils;
|
||||
import com.zt.plat.framework.excel.core.util.ExcelUtils;
|
||||
import com.zt.plat.framework.tenant.core.aop.TenantIgnore;
|
||||
import com.zt.plat.module.infra.api.file.FileApi;
|
||||
import com.zt.plat.module.infra.api.file.dto.FileRespDTO;
|
||||
import com.zt.plat.module.system.controller.admin.portal.vo.PortalPageReqVO;
|
||||
import com.zt.plat.module.system.controller.admin.portal.vo.PortalRespVO;
|
||||
import com.zt.plat.module.system.controller.admin.portal.vo.PortalSaveReqVO;
|
||||
@@ -13,6 +16,7 @@ import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.annotation.security.PermitAll;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
@@ -20,7 +24,12 @@ import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import static com.zt.plat.framework.common.pojo.CommonResult.success;
|
||||
import static com.zt.plat.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
||||
@@ -39,6 +48,9 @@ public class PortalController {
|
||||
@Resource
|
||||
private PortalService portalService;
|
||||
|
||||
@Resource
|
||||
private FileApi fileApi;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建门户网站")
|
||||
@PreAuthorize("@ss.hasPermission('system:portal:create')")
|
||||
@@ -97,9 +109,60 @@ public class PortalController {
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
@Operation(summary = "获取我的门户列表")
|
||||
@PermitAll
|
||||
@TenantIgnore
|
||||
public CommonResult<List<PortalRespVO>> getMyPortalList() {
|
||||
Long userId = getLoginUserId();
|
||||
List<PortalDO> portals = portalService.getPortalListByUserId(userId);
|
||||
Long userId = null;
|
||||
try {
|
||||
userId = getLoginUserId();
|
||||
} catch (Exception ignored) {
|
||||
// 未登录时获取公开门户
|
||||
}
|
||||
List<PortalDO> portals = (userId == null)
|
||||
? portalService.getPublicPortalList()
|
||||
: portalService.getPortalListByUserId(userId);
|
||||
return success(BeanUtils.toBean(portals, PortalRespVO.class));
|
||||
}
|
||||
|
||||
/**
|
||||
* 匿名获取公开门户的图标文件信息
|
||||
* 仅允许访问门户中已配置的图标文件
|
||||
*/
|
||||
@GetMapping("/public-icon-files")
|
||||
@Operation(summary = "获取公开门户图标文件信息")
|
||||
@PermitAll
|
||||
@TenantIgnore
|
||||
public CommonResult<List<FileRespDTO>> getPublicPortalIconFiles(@RequestParam("fileIds") List<Long> fileIds) {
|
||||
if (fileIds == null || fileIds.isEmpty()) {
|
||||
return success(java.util.Collections.emptyList());
|
||||
}
|
||||
|
||||
List<PortalDO> portals = portalService.getPublicPortalList();
|
||||
Set<Long> allowedFileIds = new HashSet<>();
|
||||
for (PortalDO portal : portals) {
|
||||
if (portal.getIconType() == null || portal.getIconType() != 2) {
|
||||
continue;
|
||||
}
|
||||
if (!StringUtils.hasText(portal.getIconFileId())) {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
allowedFileIds.add(Long.parseLong(portal.getIconFileId()));
|
||||
} catch (NumberFormatException ignored) {
|
||||
// ignore invalid fileId
|
||||
}
|
||||
}
|
||||
|
||||
List<FileRespDTO> result = new ArrayList<>();
|
||||
for (Long fileId : fileIds) {
|
||||
if (!allowedFileIds.contains(fileId)) {
|
||||
continue;
|
||||
}
|
||||
CommonResult<FileRespDTO> fileResult = fileApi.getFileInfo(fileId);
|
||||
if (fileResult != null && fileResult.isSuccess() && fileResult.getData() != null) {
|
||||
result.add(fileResult.getData());
|
||||
}
|
||||
}
|
||||
return success(result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
package com.zt.plat.module.system.controller.app.portal;
|
||||
|
||||
import com.zt.plat.framework.common.pojo.CommonResult;
|
||||
import com.zt.plat.framework.common.util.object.BeanUtils;
|
||||
import com.zt.plat.module.system.controller.admin.portal.vo.PortalRespVO;
|
||||
import com.zt.plat.module.system.dal.dataobject.portal.PortalDO;
|
||||
import com.zt.plat.module.system.service.portal.PortalService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static com.zt.plat.framework.common.pojo.CommonResult.success;
|
||||
import static com.zt.plat.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
||||
|
||||
/**
|
||||
* 用户端 - 门户网站 Controller
|
||||
*
|
||||
* @author 中铜数字供应链平台
|
||||
*/
|
||||
@Tag(name = "用户端 - 门户网站")
|
||||
@RestController
|
||||
@RequestMapping("/system/portal")
|
||||
@Validated
|
||||
public class AppPortalController {
|
||||
|
||||
@Resource
|
||||
private PortalService portalService;
|
||||
|
||||
/**
|
||||
* 获取当前用户可访问的门户列表
|
||||
* 此接口无需权限验证,因为已经通过登录验证,
|
||||
* 返回的门户列表已经根据用户权限进行了过滤
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
@Operation(summary = "获取我的门户列表")
|
||||
public CommonResult<List<PortalRespVO>> getMyPortalList() {
|
||||
Long userId = getLoginUserId();
|
||||
List<PortalDO> portals = portalService.getPortalListByUserId(userId);
|
||||
return success(BeanUtils.toBean(portals, PortalRespVO.class));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -60,4 +60,11 @@ public interface PortalService {
|
||||
*/
|
||||
List<PortalDO> getPortalListByUserId(Long userId);
|
||||
|
||||
/**
|
||||
* 获得公开门户列表(无需登录)
|
||||
*
|
||||
* @return 门户列表
|
||||
*/
|
||||
List<PortalDO> getPublicPortalList();
|
||||
|
||||
}
|
||||
|
||||
@@ -126,6 +126,11 @@ public class PortalServiceImpl implements PortalService {
|
||||
return portalMapper.selectListByPermissions(permissions);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PortalDO> getPublicPortalList() {
|
||||
return portalMapper.selectListByPermissions(Collections.emptyList());
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public PortalDO validatePortalExists(Long id) {
|
||||
if (id == null) {
|
||||
|
||||
Reference in New Issue
Block a user