ny
昨天 b6f169fe43a2b13f351aefc152374fc7f0bc8cb7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
package jnpf.portal.controller;
 
import cn.dev33.satoken.stp.StpUtil;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import jnpf.base.ActionResult;
import jnpf.base.ModuleApi;
import jnpf.base.controller.SuperController;
import jnpf.base.entity.ModuleEntity;
import jnpf.constant.JnpfConst;
import jnpf.constant.MsgCode;
import jnpf.portal.entity.PortalEntity;
import jnpf.portal.model.*;
import jnpf.portal.service.PortalDataService;
import jnpf.portal.service.PortalService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
 
/**
 * 可视化门户
 *
 * @author JNPF开发平台组
 * @version V3.1.0
 * @copyright 引迈信息技术有限公司(https://www.jnpfsoft.com)
 * @date 2019年9月27日 上午9:18
 */
@Slf4j
@RestController
@Tag(name = "门户展示界面" , description = "Portal" )
@RequestMapping("/Portal" )
public class PortalDataController extends SuperController<PortalService, PortalEntity> {
    @Autowired
    private PortalDataService portalDataService;
    @Autowired
    private PortalService portalService;
    @Autowired
    private ModuleApi moduleService;
 
    @Operation(summary = "设置默认门户")
    @Parameters({
            @Parameter(name = "id", description = "主键"),
    })
    @PutMapping("/{id}/Actions/SetDefault")
    @Transactional
    public ActionResult<String> SetDefault(@PathVariable("id") String id, String platform) {
        ModuleEntity itemInfo = moduleService.getModuleByList(id);
        PortalEntity itemPort = itemInfo != null ? portalService.getById(itemInfo.getModuleId()) : null;
        if (itemPort == null) {
            return ActionResult.fail(MsgCode.VS415.get());
        }
        portalDataService.setCurrentDefault(null, null, platform, id);
        return ActionResult.success(MsgCode.SU016.get());
    }
 
    @Operation(summary = "门户自定义保存")
    @Parameters({
            @Parameter(name = "id", description = "主键"),
    })
    @PutMapping("/Custom/Save/{menuId}")
    public ActionResult<String> customSave(@PathVariable("menuId") String menuId, @RequestBody PortalDataForm portalDataForm) throws Exception {
        StpUtil.checkPermissionOr("onlineDev.visualPortal", menuId);
        PortalEntity entity = portalService.getInfo(menuId);
        if (entity == null) {
            ModuleEntity info = moduleService.getModuleByList(menuId);
            if (info == null) throw new Exception(MsgCode.FA001.get());
            entity = portalService.getInfo(info.getModuleId());
            if (entity == null) throw new Exception(MsgCode.VS415.get());
        }
        portalDataService.createOrUpdate(new PortalCustomPrimary(portalDataForm.getPlatform(), entity.getId())
                , portalDataForm.getFormData());
        return ActionResult.success(MsgCode.SU002.getMsg());
    }
 
    @Operation(summary = "门户发布(同步)")
    @Parameters({
            @Parameter(name = "portalId", description = "门户主键"),
    })
    @PutMapping("/Actions/release/{portalId}")
    @Transactional(rollbackFor = Exception.class)
    public ActionResult<PortalReleaseVO> release(@PathVariable("portalId") String portalId, @RequestBody @Valid PortalReleaseForm form) throws Exception {
        ReleaseModel releaseSystemModel = new ReleaseModel();
        releaseSystemModel.setPc(form.getPc());
        releaseSystemModel.setPcSystemId(form.getPcSystemId());
        releaseSystemModel.setPcModuleParentId(form.getPcModuleParentId());
        releaseSystemModel.setApp(form.getApp());
        releaseSystemModel.setAppSystemId(form.getAppSystemId());
        releaseSystemModel.setAppModuleParentId(form.getAppModuleParentId());
        releaseSystemModel.setPcModuleParentId(form.getPcModuleParentId());
        releaseSystemModel.setAppModuleParentId(form.getAppModuleParentId());
        releaseSystemModel.setPlatformRelease(form.getPlatformRelease());
        portalDataService.releaseModule(releaseSystemModel, portalId);
 
        return ActionResult.success(MsgCode.SU011.get());
    }
 
    @Operation(summary = "个人门户详情")
    @Parameters({
            @Parameter(name = "id", description = "主键"),
    })
    @GetMapping("/{id}/auth")
    public ActionResult<PortalInfoAuthVO> infoAuth(@PathVariable("id") String id, String platform, String systemId) {
        platform = platform.equalsIgnoreCase("pc") || platform.equalsIgnoreCase(JnpfConst.WEB) ? JnpfConst.WEB : JnpfConst.APP;
        try {
            return ActionResult.success(portalDataService.getDataFormView(id, platform));
        } catch (Exception e) {
            return ActionResult.fail(e.getMessage());
        }
    }
 
}