package com.flightfeather.grid.web
|
|
import com.flightfeather.grid.service.ClueService
|
import io.swagger.annotations.Api
|
import io.swagger.annotations.ApiOperation
|
import io.swagger.annotations.ApiParam
|
import org.springframework.web.bind.annotation.*
|
import java.net.URLEncoder
|
import javax.servlet.http.HttpServletResponse
|
|
@Api(tags = ["ClueController"], description = "下发线索API接口")
|
@RestController
|
@RequestMapping("/clue")
|
class ClueController(val clueService: ClueService) {
|
|
@ApiOperation("获取下发线索")
|
@GetMapping("/fetch")
|
fun getClue(
|
@ApiParam("起始时间") @RequestParam(required = false) sTime: String?,
|
@ApiParam("结束时间") @RequestParam(required = false) eTime: String?,
|
@ApiParam("页码") @RequestParam(required = false) pageNum: Int?,
|
@ApiParam("单页数据量") @RequestParam(required = false) pageSize: Int?,
|
) = resPack { clueService.getClue(sTime, eTime, pageNum, pageSize) }
|
|
@ApiOperation("从远程数据源拉取下发线索")
|
@GetMapping("/fetch/remote")
|
fun fetchRemoteClue(
|
@ApiParam("下发时间") @RequestParam updateTime: String,
|
) = resPack { clueService.fetchRemoteClue(updateTime) }
|
|
@ApiOperation("从远程数据源获取线索文件")
|
@GetMapping("/fetch/remote/file")
|
fun fetchRemoteClueFile(@ApiParam("线索id") @RequestParam clueId: String, response: HttpServletResponse) {
|
val res = clueService.getClueFile(clueId)
|
val fileName = URLEncoder.encode(res.first, "utf-8")
|
response.apply {
|
setHeader("Content-Disposition", "attachment;filename=${fileName}")
|
setHeader("fileName", fileName)
|
addHeader("Access-Control-Expose-Headers", "fileName")
|
contentType = "application/pdf;charset=UTF-8"
|
setHeader("Pragma", "no-cache")
|
setHeader("Cache-Control", "no-cache")
|
setDateHeader("Expires", 0)
|
}
|
res.second.m.entity.writeTo(response.outputStream)
|
}
|
|
@ApiOperation("推送线索至第三方")
|
@PostMapping("/push")
|
fun pushClue(
|
@ApiParam("线索id") @RequestParam clueId: String,
|
) = resPack { clueService.pushClue(clueId) }
|
}
|