Browse Source
SavedViewController(与列偏好同处 /api/preference 前缀,挂 /view 子路径): - GET /list 列出当前用户某 scope 视图(按 seqNo) - POST /save 保存(@RequestBody SavedView;viewId 空=新建/非空=编辑) - POST /delete 删除 - POST /set-default 图钉设默认(单值互斥) userId 从 SecurityContext,不接受前端传入;scope 由业务方约定(商机本期 opportunity.sales);内置视图不走本接口。mvn -pl crm-preference test 16 全绿。master
1 changed files with 71 additions and 0 deletions
@ -0,0 +1,71 @@ |
|||
package com.crm.preference.controller; |
|||
|
|||
import com.crm.base.domain.result.Result; |
|||
import com.crm.base.security.SecurityUtils; |
|||
import com.crm.preference.domain.dto.SavedView; |
|||
import com.crm.preference.service.SavedViewService; |
|||
import io.swagger.v3.oas.annotations.Operation; |
|||
import lombok.RequiredArgsConstructor; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
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.RequestParam; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 自定义视图接口(票 14)。 |
|||
* |
|||
* <p>平台级第二种偏好,与 {@link ColumnPreferenceController} 同处 {@code /api/preference} 前缀下、 |
|||
* 挂 {@code /view} 子路径。权限策略同列偏好:不种子化权限点,ApiPermissionInterceptor 对未注册 URL |
|||
* fail-open。视图为用户私有,userId 从 SecurityContext 获取,不接受前端传入。</p> |
|||
* |
|||
* <p>scope 由业务方约定(商机销售机会工作区本期传 {@code opportunity.sales});内置视图不走本接口 |
|||
* (内置口径硬编码在业务方),本接口只管理用户自建视图。</p> |
|||
*/ |
|||
@RestController |
|||
@RequestMapping("/api/preference/view") |
|||
@RequiredArgsConstructor |
|||
public class SavedViewController { |
|||
|
|||
private final SavedViewService savedViewService; |
|||
|
|||
@Operation(summary = "列出当前用户在某 scope 的自定义视图(按 seqNo)", |
|||
tags = {"销售机会/自定义视图"}) |
|||
@GetMapping("/list") |
|||
public Result<List<SavedView>> list(@RequestParam("scopeKey") String scopeKey) { |
|||
Long userId = Long.valueOf(SecurityUtils.getRequiredUserId()); |
|||
return Result.success(savedViewService.list(userId, scopeKey)); |
|||
} |
|||
|
|||
@Operation(summary = "保存自定义视图(viewId 空=新建,非空=覆盖编辑;isDefault 单值互斥)", |
|||
tags = {"销售机会/自定义视图"}) |
|||
@PostMapping("/save") |
|||
public Result<String> save(@RequestParam("scopeKey") String scopeKey, |
|||
@RequestBody SavedView view) { |
|||
Long userId = Long.valueOf(SecurityUtils.getRequiredUserId()); |
|||
return Result.success(savedViewService.save(userId, scopeKey, view)); |
|||
} |
|||
|
|||
@Operation(summary = "删除自定义视图", |
|||
tags = {"销售机会/自定义视图"}) |
|||
@PostMapping("/delete") |
|||
public Result<Void> delete(@RequestParam("scopeKey") String scopeKey, |
|||
@RequestParam("viewId") String viewId) { |
|||
Long userId = Long.valueOf(SecurityUtils.getRequiredUserId()); |
|||
savedViewService.delete(userId, scopeKey, viewId); |
|||
return Result.success(); |
|||
} |
|||
|
|||
@Operation(summary = "图钉:设为该 scope 的默认视图(单值互斥)", |
|||
tags = {"销售机会/自定义视图"}) |
|||
@PostMapping("/set-default") |
|||
public Result<Void> setDefault(@RequestParam("scopeKey") String scopeKey, |
|||
@RequestParam("viewId") String viewId) { |
|||
Long userId = Long.valueOf(SecurityUtils.getRequiredUserId()); |
|||
savedViewService.setDefault(userId, scopeKey, viewId); |
|||
return Result.success(); |
|||
} |
|||
} |
|||
Loading…
Reference in new issue