|
@@ -0,0 +1,194 @@
|
|
|
|
+/*
|
|
|
|
+ * Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
|
|
|
|
+ *
|
|
|
|
+ * Redistribution and use in source and binary forms, with or without
|
|
|
|
+ * modification, are permitted provided that the following conditions are met:
|
|
|
|
+ *
|
|
|
|
+ * Redistributions of source code must retain the above copyright notice,
|
|
|
|
+ * this list of conditions and the following disclaimer.
|
|
|
|
+ * Redistributions in binary form must reproduce the above copyright
|
|
|
|
+ * notice, this list of conditions and the following disclaimer in the
|
|
|
|
+ * documentation and/or other materials provided with the distribution.
|
|
|
|
+ * Neither the name of the dreamlu.net developer nor the names of its
|
|
|
|
+ * contributors may be used to endorse or promote products derived from
|
|
|
|
+ * this software without specific prior written permission.
|
|
|
|
+ * Author: Chill 庄骞 (smallchill@163.com)
|
|
|
|
+ */
|
|
|
|
+package org.springblade.control.controller;
|
|
|
|
+
|
|
|
|
+import io.swagger.annotations.*;
|
|
|
|
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
|
|
+import lombok.AllArgsConstructor;
|
|
|
|
+
|
|
|
|
+import javax.validation.Valid;
|
|
|
|
+
|
|
|
|
+import lombok.SneakyThrows;
|
|
|
|
+import net.logstash.logback.encoder.org.apache.commons.lang3.StringUtils;
|
|
|
|
+import org.apache.pdfbox.pdmodel.PDDocument;
|
|
|
|
+import org.hibernate.validator.constraints.Length;
|
|
|
|
+import org.springblade.core.mp.support.Condition;
|
|
|
|
+import org.springblade.core.mp.support.Query;
|
|
|
|
+import org.springblade.core.oss.model.BladeFile;
|
|
|
|
+import org.springblade.core.tool.api.R;
|
|
|
|
+import org.springblade.core.tool.utils.FileUtil;
|
|
|
|
+import org.springblade.core.tool.utils.Func;
|
|
|
|
+import org.springblade.resource.entity.Attach;
|
|
|
|
+import org.springblade.resource.entity.LargeFile;
|
|
|
|
+import org.springblade.resource.feign.CommonFileClient;
|
|
|
|
+import org.springblade.resource.feign.NewIOSSClient;
|
|
|
|
+import org.springblade.resource.vo.NewBladeFile;
|
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
+import org.springblade.control.entity.CorporationInfo;
|
|
|
|
+import org.springblade.control.vo.CorporationInfoVO;
|
|
|
|
+import org.springblade.control.service.ICorporationInfoService;
|
|
|
|
+import org.springblade.core.boot.ctrl.BladeController;
|
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
+
|
|
|
|
+import java.util.Objects;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * 公司制度信息表 控制器
|
|
|
|
+ *
|
|
|
|
+ * @author BladeX
|
|
|
|
+ * @since 2023-07-06
|
|
|
|
+ */
|
|
|
|
+@RestController
|
|
|
|
+@AllArgsConstructor
|
|
|
|
+@RequestMapping("/corporationinfo")
|
|
|
|
+@Api(value = "公司制度信息表", tags = "公司制度信息表接口")
|
|
|
|
+public class CorporationInfoController extends BladeController {
|
|
|
|
+
|
|
|
|
+ private final ICorporationInfoService corporationInfoService;
|
|
|
|
+
|
|
|
|
+ // pdf转换
|
|
|
|
+ private final CommonFileClient commonFileClient;
|
|
|
|
+
|
|
|
|
+ private final NewIOSSClient newIOSSClient;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 详情
|
|
|
|
+ */
|
|
|
|
+ @GetMapping("/detail")
|
|
|
|
+ @ApiOperationSupport(order = 1)
|
|
|
|
+ @ApiOperation(value = "详情", notes = "传入corporationInfo")
|
|
|
|
+ public R<CorporationInfo> detail(CorporationInfo corporationInfo) {
|
|
|
|
+ CorporationInfo detail = corporationInfoService.getOne(Condition.getQueryWrapper(corporationInfo));
|
|
|
|
+ return R.data(detail);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 分页 公司制度信息表
|
|
|
|
+ */
|
|
|
|
+ @GetMapping("/page")
|
|
|
|
+ @ApiOperationSupport(order = 3)
|
|
|
|
+ @ApiOperation(value = "分页公司制度信息表", notes = "传入corporationInfo")
|
|
|
|
+ public R<IPage<CorporationInfoVO>> page(CorporationInfoVO corporationInfo, Query query) {
|
|
|
|
+ IPage<CorporationInfoVO> pages = corporationInfoService.selectCorporationInfoPage(Condition.getPage(query), corporationInfo);
|
|
|
|
+ return R.data(pages);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 新增 公司制度信息表
|
|
|
|
+ */
|
|
|
|
+ @PostMapping("/save")
|
|
|
|
+ @ApiOperationSupport(order = 4)
|
|
|
|
+ @ApiOperation(value = "新增", notes = "传入corporationInfo")
|
|
|
|
+ public R save(@Valid @RequestBody CorporationInfo corporationInfo) {
|
|
|
|
+ return R.status(corporationInfoService.save(corporationInfo));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 修改 公司制度信息表
|
|
|
|
+ */
|
|
|
|
+ @PostMapping("/update")
|
|
|
|
+ @ApiOperationSupport(order = 5)
|
|
|
|
+ @ApiOperation(value = "修改", notes = "传入corporationInfo")
|
|
|
|
+ public R update(@Valid @RequestBody CorporationInfo corporationInfo) {
|
|
|
|
+ return R.status(corporationInfoService.updateById(corporationInfo));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 新增或修改 公司制度信息表
|
|
|
|
+ */
|
|
|
|
+ @PostMapping("/submit")
|
|
|
|
+ @ApiOperationSupport(order = 6)
|
|
|
|
+ @ApiOperation(value = "新增或修改", notes = "传入corporationInfo")
|
|
|
|
+ public R submit(@Valid @RequestBody CorporationInfo corporationInfo) {
|
|
|
|
+ return R.status(corporationInfoService.saveOrUpdate(corporationInfo));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 删除 公司制度信息表
|
|
|
|
+ */
|
|
|
|
+ @PostMapping("/remove")
|
|
|
|
+ @ApiOperationSupport(order = 7)
|
|
|
|
+ @ApiOperation(value = "逻辑删除", notes = "传入ids")
|
|
|
|
+ public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
|
|
|
|
+ return R.status(corporationInfoService.deleteLogic(Func.toLongList(ids)));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 上传和重新上传
|
|
|
|
+ */
|
|
|
|
+ @SneakyThrows
|
|
|
|
+ @PostMapping("/put-corporationinfo")
|
|
|
|
+ @ApiOperationSupport(order = 8)
|
|
|
|
+ @ApiOperation(value = "公司制度上传和重新上传", notes = "公司制度上传和重新上传")
|
|
|
|
+ @ApiImplicitParams(value = {
|
|
|
|
+ @ApiImplicitParam(name = "file", value = "文件源", required = true),
|
|
|
|
+ @ApiImplicitParam(name = "id", value = "制度主键Id(重新上传必须传)", required = false)
|
|
|
|
+ })
|
|
|
|
+ public R putFileAttach(@RequestParam("file") MultipartFile file, String id) {
|
|
|
|
+ //
|
|
|
|
+ CorporationInfo corporationInfo = new CorporationInfo();
|
|
|
|
+ NewBladeFile newBladeFile = new NewBladeFile();
|
|
|
|
+ if (Objects.requireNonNull(file.getOriginalFilename()).contains("xlsx")) {
|
|
|
|
+ newBladeFile = this.commonFileClient.excelToPdf(file);
|
|
|
|
+
|
|
|
|
+ } else if (file.getOriginalFilename().contains("xls")) {
|
|
|
|
+ newBladeFile = this.commonFileClient.excelToPdf(file);
|
|
|
|
+
|
|
|
|
+ } else if (file.getOriginalFilename().contains("docx")) {
|
|
|
|
+ newBladeFile = this.commonFileClient.wordToPdf(file);
|
|
|
|
+
|
|
|
|
+ } else if (file.getOriginalFilename().contains("png") || file.getOriginalFilename().contains("jpg")) {
|
|
|
|
+ newBladeFile = this.commonFileClient.pngOrJpgToPdf(file);
|
|
|
|
+
|
|
|
|
+ } else if (file.getOriginalFilename().contains("pdf")) {
|
|
|
|
+ //获取PDF文件
|
|
|
|
+ BladeFile bladeFile = this.newIOSSClient.updateFile(file.getBytes(), file.getOriginalFilename());
|
|
|
|
+ BeanUtils.copyProperties(bladeFile, newBladeFile);
|
|
|
|
+ }
|
|
|
|
+ String fileExtension = FileUtil.getFileExtension(newBladeFile.getOriginalName());
|
|
|
|
+ if (StringUtils.isNotEmpty(id)) {
|
|
|
|
+ corporationInfo = corporationInfoService.getById(id);
|
|
|
|
+ corporationInfo.setName(file.getName());
|
|
|
|
+ corporationInfo.setOriginalName(file.getOriginalFilename());
|
|
|
|
+ corporationInfo.setDomainUrl(newBladeFile.getDomain());
|
|
|
|
+ corporationInfo.setLink(newBladeFile.getPdfUrl());
|
|
|
|
+ corporationInfo.setName(newBladeFile.getName());
|
|
|
|
+
|
|
|
|
+ corporationInfo.setAttachSize(newBladeFile.getFileSize());
|
|
|
|
+ corporationInfo.setExtension(fileExtension);
|
|
|
|
+
|
|
|
|
+ } else {
|
|
|
|
+ corporationInfo.setName(file.getName());
|
|
|
|
+ corporationInfo.setOriginalName(file.getOriginalFilename());
|
|
|
|
+ corporationInfo.setDomainUrl(newBladeFile.getDomain());
|
|
|
|
+ corporationInfo.setLink(newBladeFile.getPdfUrl());
|
|
|
|
+ corporationInfo.setName(newBladeFile.getName());
|
|
|
|
+ corporationInfo.setAttachSize(newBladeFile.getFileSize());
|
|
|
|
+ corporationInfo.setExtension(fileExtension);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ boolean b = corporationInfoService.saveOrUpdate(corporationInfo);
|
|
|
|
+ return R.status(b);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+}
|