|
|
@ -88,62 +88,6 @@ public class VetQualificationController extends BaseController |
|
|
return AjaxResult.success(options); |
|
|
return AjaxResult.success(options); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 上传资质文件(关联兽医资质ID) |
|
|
|
|
|
*/ |
|
|
|
|
|
@PreAuthorize("@ss.hasPermi('vet:qualification:edit')") |
|
|
|
|
|
@Log(title = "兽医资质文件上传", businessType = BusinessType.UPDATE) |
|
|
|
|
|
@PostMapping("/upload") |
|
|
|
|
|
public AjaxResult uploadQualificationFile(@RequestParam("file") MultipartFile file) { |
|
|
|
|
|
try { |
|
|
|
|
|
if (file.isEmpty()) { |
|
|
|
|
|
return AjaxResult.error("文件不能为空"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
String originalFileName = file.getOriginalFilename(); |
|
|
|
|
|
String ext = FileUtils.getExtension(originalFileName).toLowerCase(); |
|
|
|
|
|
|
|
|
|
|
|
String[] allowedExts = {"jpg", "png", "pdf", "doc", "docx", "xls", "xlsx"}; |
|
|
|
|
|
boolean isAllowed = FileUtils.isAllowedExtension(originalFileName, allowedExts); |
|
|
|
|
|
if (!isAllowed) { |
|
|
|
|
|
return AjaxResult.error("文件类型不允许"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
String basePath = uploadRootPath; |
|
|
|
|
|
String subPath = "vet/qualification"; |
|
|
|
|
|
String datePath = new SimpleDateFormat("yyyy/MM/dd").format(new Date()); |
|
|
|
|
|
String fullPath = basePath + File.separator + subPath + File.separator + datePath; |
|
|
|
|
|
|
|
|
|
|
|
File destDir = new File(fullPath); |
|
|
|
|
|
if (!destDir.exists()) { |
|
|
|
|
|
destDir.mkdirs(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
String uuid = UUID.randomUUID().toString().replace("-", ""); |
|
|
|
|
|
String fileName = uuid + "_" + originalFileName; |
|
|
|
|
|
String filePath = fullPath + File.separator + fileName; |
|
|
|
|
|
|
|
|
|
|
|
File destFile = new File(filePath); |
|
|
|
|
|
file.transferTo(destFile); |
|
|
|
|
|
|
|
|
|
|
|
String fileUrl = "/" + subPath + "/" + datePath + "/" + fileName; |
|
|
|
|
|
String downloadUrl = "/common/download?fileName=" + URLEncoder.encode(fileUrl, "UTF-8"); |
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> data = new HashMap<>(); |
|
|
|
|
|
data.put("fileName", originalFileName); |
|
|
|
|
|
data.put("fileUrl", fileUrl); |
|
|
|
|
|
data.put("downloadUrl", downloadUrl); |
|
|
|
|
|
data.put("filePath", fileUrl); |
|
|
|
|
|
data.put("fileSize", file.getSize()); |
|
|
|
|
|
data.put("uuid", uuid); |
|
|
|
|
|
|
|
|
|
|
|
return AjaxResult.success("上传成功", data); |
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
log.error("文件上传失败", e); |
|
|
|
|
|
return AjaxResult.error("上传失败: " + e.getMessage()); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 查询兽医资质列表(含证书信息) |
|
|
* 查询兽医资质列表(含证书信息) |
|
|
@ -481,43 +425,4 @@ public class VetQualificationController extends BaseController |
|
|
vetQualificationService.manualCheckCertificates(userId); |
|
|
vetQualificationService.manualCheckCertificates(userId); |
|
|
return success("证书检查完成"); |
|
|
return success("证书检查完成"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 下架资质 |
|
|
|
|
|
*/ |
|
|
|
|
|
@PreAuthorize("@ss.hasPermi('vet:qualification:unshelf')") |
|
|
|
|
|
@Log(title = "兽医资质下架", businessType = BusinessType.UPDATE) |
|
|
|
|
|
@PostMapping("/unshelf/{qualificationId}") |
|
|
|
|
|
public AjaxResult unshelf(@PathVariable Long qualificationId, |
|
|
|
|
|
@RequestParam(required = false) String reason) { |
|
|
|
|
|
try { |
|
|
|
|
|
int result = vetQualificationService.unshelfQualification(qualificationId, reason); |
|
|
|
|
|
if (result > 0) { |
|
|
|
|
|
return AjaxResult.success("下架成功"); |
|
|
|
|
|
} else { |
|
|
|
|
|
return AjaxResult.error("下架失败"); |
|
|
|
|
|
} |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
return AjaxResult.error(e.getMessage()); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 上架资质 |
|
|
|
|
|
*/ |
|
|
|
|
|
@PreAuthorize("@ss.hasPermi('vet:qualification:shelf')") |
|
|
|
|
|
@Log(title = "兽医资质上架", businessType = BusinessType.UPDATE) |
|
|
|
|
|
@PostMapping("/shelf/{qualificationId}") |
|
|
|
|
|
public AjaxResult shelf(@PathVariable Long qualificationId) { |
|
|
|
|
|
try { |
|
|
|
|
|
int result = vetQualificationService.shelfQualification(qualificationId); |
|
|
|
|
|
if (result > 0) { |
|
|
|
|
|
return AjaxResult.success("上架成功"); |
|
|
|
|
|
} else { |
|
|
|
|
|
return AjaxResult.error("上架失败"); |
|
|
|
|
|
} |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
return AjaxResult.error(e.getMessage()); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |