package com.ymwk.icvp.signature.controller; import com.ymwk.icvp.component.PageResult; import com.ymwk.icvp.component.ResponseDTO; import com.ymwk.icvp.signature.entity.Picture; import com.ymwk.icvp.signature.entity.Seal; import com.ymwk.icvp.signature.model.*; import com.ymwk.icvp.signature.service.SealService; import lombok.RequiredArgsConstructor; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; @RestController @RequestMapping("/api/v1/seal") @RequiredArgsConstructor public class SealController { private final SealService sealService; /** * 印章列表(条件查询) */ @PostMapping("/list") public ResponseDTO> list(@RequestBody SealQueryDTO queryDTO) { return sealService.pageSeal(queryDTO); } /** * 印章详情 */ @GetMapping("/detail/{id}") public ResponseDTO detail(@PathVariable Long id) { return sealService.getSealDetail(id); } /** * 生成印章 */ @PostMapping("/create") public ResponseDTO create(@Validated @RequestBody SealCreateDTO createDTO) { return sealService.createSeal(createDTO); } /** * 冻结印章 */ @PostMapping("/freeze/{id}") public ResponseDTO freeze(@PathVariable Long id) { return sealService.freeze(id); } /** * 解冻印章 */ @PostMapping("/unfreeze/{id}") public ResponseDTO unfreeze(@PathVariable Long id) { return sealService.unfreeze(id); } /** * 销毁印章 */ @PostMapping("/destroy/{id}") public ResponseDTO destroy(@PathVariable Long id) { return sealService.destroy(id); } /** * 印章延期 */ @PostMapping("/extend") public ResponseDTO extend(@Validated @RequestBody SealExtendDTO extendDTO) { return sealService.extend(extendDTO); } /** * 绑定/换绑证书 */ @PostMapping("/bindCert") public ResponseDTO bindCert(@Validated @RequestBody SealBindCertDTO bindCertDTO) { return sealService.bindCert(bindCertDTO); } /** * 印章有效性验证 */ @PostMapping("/verify/{id}") public ResponseDTO verify(@PathVariable Long id) { return sealService.verify(id); } /** * 下载印章文件:SM2 返回 ESL,RSA 返回包含印模和证书的 ZIP */ @GetMapping("/download/{id}") public ResponseEntity download(@PathVariable Long id) { ResponseDTO result = sealService.download(id); if (!Integer.valueOf(ResponseDTO.OK_CODE).equals(result.getCode()) || result.getData() == null) { return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(result); } SealDownload download = result.getData(); return ResponseEntity.ok() .header("Content-Disposition", "attachment; filename=\"" + download.getFileName() + "\"") .contentType(MediaType.parseMediaType(download.getContentType())) .body(download.getData()); } }