| | |
| | | import org.apache.commons.io.IOUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | |
| | | @PreAuthorize("@ss.hasPermission('mpk:file:query')") |
| | | public CommonResult<PageData<MpkFileDTO>> page(@RequestParam Map<String, Object> params) { |
| | | PageData<MpkFileDTO> page = mpkFileService.page(params); |
| | | |
| | | return success(page); |
| | | } |
| | | |
| | |
| | | @GetMapping("{id}") |
| | | public CommonResult<MpkFileDTO> info(@PathVariable("id") String id) { |
| | | MpkFileDTO schedule = mpkFileService.get(id); |
| | | |
| | | List<String> menuAndGroup = new ArrayList<>(); |
| | | menuAndGroup.add(schedule.getMenuName()); |
| | | menuAndGroup.add(schedule.getGroupName()); |
| | | schedule.setMenuAndGroup(menuAndGroup); |
| | | return success(schedule); |
| | | } |
| | | |
| | |
| | | @PreAuthorize("@ss.hasPermission('mpk:file:create')") |
| | | @PostMapping |
| | | public CommonResult<Boolean> save(@RequestBody MpkFileDTO dto) { |
| | | if (!CollectionUtils.isEmpty(dto.getMenuAndGroup())) { |
| | | dto.setMenuName(dto.getMenuAndGroup().get(0)); |
| | | if (dto.getMenuAndGroup().size() > 1) { |
| | | dto.setGroupName(dto.getMenuAndGroup().get(1)); |
| | | } |
| | | } |
| | | mpkFileService.save(dto); |
| | | return CommonResult.success(true); |
| | | } |
| | |
| | | @PreAuthorize("@ss.hasPermission('mpk:file:update')") |
| | | @PutMapping |
| | | public CommonResult<Boolean> update(@RequestBody MpkFileDTO dto) { |
| | | if (!CollectionUtils.isEmpty(dto.getMenuAndGroup())) { |
| | | dto.setMenuName(dto.getMenuAndGroup().get(0)); |
| | | if (dto.getMenuAndGroup().size() > 1) { |
| | | dto.setGroupName(dto.getMenuAndGroup().get(1)); |
| | | } |
| | | } |
| | | mpkFileService.update(dto); |
| | | return CommonResult.success(true); |
| | | } |