package jnpf.base.controller; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import jnpf.base.ActionResult; import jnpf.base.entity.PortalManageEntity; import jnpf.base.model.portalManage.*; import jnpf.base.service.PortalManageService; import jnpf.base.vo.PageListVO; import jnpf.constant.MsgCode; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import jakarta.validation.Valid; import java.util.List; import java.util.stream.Collectors; /** * 门户管理 * * @author JNPF开发平台组 YanYu * @version v3.4.6 * @copyrignt 引迈信息技术有限公司 * @date 2023-02-16 */ @Slf4j @RestController @Tag(name = "门户管理", description = "PortalManage") @RequestMapping("/api/system/PortalManage") public class PortalManageController extends SuperController { @Autowired PortalManageService portalManageService; // @Autowired // PortalService portalApi; // @Autowired // private AuthorizeService authorizeService; @Operation(summary = "新增") @PostMapping public ActionResult create(@RequestBody @Valid PortalManageCreForm portalManageForm) { PortalManageEntity entity = portalManageForm.convertEntity(); try { portalManageService.checkCreUp(entity); } catch (Exception e) { return ActionResult.fail(e.getMessage()); } portalManageService.save(entity); return ActionResult.success(MsgCode.SU018.get()); } @Operation(summary = "删除") @DeleteMapping("/{id}") public ActionResult delete(@PathVariable String id) { boolean flag = portalManageService.removeById(id); if(flag){ // 删除绑定的所有权限 // authorizeService.remove(new AuthorizePortalManagePrimary(null, id).getQuery()); return ActionResult.success(MsgCode.SU003.get()); } else { return ActionResult.fail(MsgCode.FA003.get()); } } @Operation(summary = "编辑") @PutMapping("/{id}") public ActionResult update(@PathVariable("id") String id, @RequestBody @Valid PortalManageUpForm portalManageUpForm){ PortalManageEntity update = portalManageUpForm.convertEntity(); try { portalManageService.checkCreUp(update); } catch (Exception e) { return ActionResult.fail(e.getMessage()); } portalManageService.updateById(update); return ActionResult.success(MsgCode.SU004.get()); } @Operation(summary = "查看") @GetMapping("/{id}") public ActionResult getOne(@PathVariable("id") String id) { PortalManageEntity entity = portalManageService.getById(id); return ActionResult.success(portalManageService.convertVO(entity)); } @Operation(summary = "列表") @GetMapping("/list/{systemId}") public ActionResult> getPage(@PathVariable("systemId") String systemId, PortalManagePage pmPage) { pmPage.setSystemId(systemId); return ActionResult.page( portalManageService.getPage(pmPage).getRecords() .stream().map(PortalManagePageDO::convert).collect(Collectors.toList()), pmPage.getPaginationVO()); } }