feiyu02
2024-08-15 196bb14112448857a885e32dc4149e308e00b01a
src/main/kotlin/cn/flightfeather/supervision/lightshare/web/CommitmentController.kt
@@ -1,6 +1,7 @@
package cn.flightfeather.supervision.lightshare.web
import cn.flightfeather.supervision.lightshare.service.CommitmentService
import cn.flightfeather.supervision.lightshare.vo.BaseResponse
import cn.flightfeather.supervision.lightshare.vo.CommitmentVo
import io.swagger.annotations.Api
import io.swagger.annotations.ApiOperation
@@ -8,6 +9,8 @@
import io.swagger.annotations.ApiResponse
import org.springframework.web.bind.annotation.*
import org.springframework.web.multipart.MultipartFile
import org.springframework.web.multipart.MultipartHttpServletRequest
import javax.servlet.http.HttpServletRequest
import javax.servlet.http.HttpServletResponse
/**
@@ -28,6 +31,12 @@
        response: HttpServletResponse
    ) = commitmentService.getLetterOfCommitment(userId, page, perPage, response)
    @ApiOperation(value = "获取用户承诺书模板")
    @GetMapping("/letter/template")
    fun getTemplateOfCommitment(
        @ApiParam(value = "用户id") @RequestParam("userId") userId: String,
    ) = commitmentService.getTemplateOfCommitment(userId)
    @ApiOperation(value = "上传承诺书")
    @PostMapping("/letter/upload")
    fun uploadLetterOfCommitment(
@@ -38,10 +47,14 @@
    @ApiOperation(value = "生成承诺书")
    @PostMapping("/letter/create")
    fun createLetterOfCommitment(
        @ApiParam(value = "用户id") @RequestParam userId: String,
        @ApiParam(value = "承诺书参数") @RequestBody vo: CommitmentVo,
        @ApiParam(value = "承诺书签名") @RequestPart("sign") sign: MultipartFile,
        @ApiParam(value = "承诺书盖章", required = false) @RequestPart("seal") seal: MultipartFile?
    ) = commitmentService.createLetterOfCommitment(userId, vo, sign, seal)
    fun createLetterOfCommitment(request: HttpServletRequest) = if (request is MultipartHttpServletRequest) {
        val sign = request.getFile("sign")
        val seal = request.getFile("seal")
        val userId = request.getParameter("userId")
        val vo = request.getParameter("coVo")
        commitmentService.createLetterOfCommitment(userId, vo, sign, seal)
    } else {
        BaseResponse(false)
    }
}