| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- 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<PageResult<Seal>> list(@RequestBody SealQueryDTO queryDTO) {
- return sealService.pageSeal(queryDTO);
- }
- /**
- * 印章详情
- */
- @GetMapping("/detail/{id}")
- public ResponseDTO<Seal> detail(@PathVariable Long id) {
- return sealService.getSealDetail(id);
- }
- /**
- * 生成印章
- */
- @PostMapping("/create")
- public ResponseDTO<Long> create(@Validated @RequestBody SealCreateDTO createDTO) {
- return sealService.createSeal(createDTO);
- }
- /**
- * 冻结印章
- */
- @PostMapping("/freeze/{id}")
- public ResponseDTO<Void> freeze(@PathVariable Long id) {
- return sealService.freeze(id);
- }
- /**
- * 解冻印章
- */
- @PostMapping("/unfreeze/{id}")
- public ResponseDTO<Void> unfreeze(@PathVariable Long id) {
- return sealService.unfreeze(id);
- }
- /**
- * 销毁印章
- */
- @PostMapping("/destroy/{id}")
- public ResponseDTO<Void> destroy(@PathVariable Long id) {
- return sealService.destroy(id);
- }
- /**
- * 印章延期
- */
- @PostMapping("/extend")
- public ResponseDTO<Void> extend(@Validated @RequestBody SealExtendDTO extendDTO) {
- return sealService.extend(extendDTO);
- }
- /**
- * 绑定/换绑证书
- */
- @PostMapping("/bindCert")
- public ResponseDTO<Void> bindCert(@Validated @RequestBody SealBindCertDTO bindCertDTO) {
- return sealService.bindCert(bindCertDTO);
- }
- /**
- * 印章有效性验证
- */
- @PostMapping("/verify/{id}")
- public ResponseDTO<Boolean> verify(@PathVariable Long id) {
- return sealService.verify(id);
- }
- /**
- * 下载印章文件:SM2 返回 ESL,RSA 返回包含印模和证书的 ZIP
- */
- @GetMapping("/download/{id}")
- public ResponseEntity<?> download(@PathVariable Long id) {
- ResponseDTO<SealDownload> 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());
- }
- }
|