UspihReportController.java 2.47 KB
package com.xkl.controller.uspih;

import com.wordnik.swagger.annotations.ApiImplicitParam;
import com.wordnik.swagger.annotations.ApiImplicitParams;
import com.wordnik.swagger.annotations.ApiOperation;
import com.xkl.authorization.annotation.Authorization;
import com.xkl.authorization.annotation.CurrentAdmin;
import com.xkl.domain.XklAdminEntity;
import com.xkl.model.ResultModel;
import com.xkl.repository.*;
import com.xkl.security.AntiXSS;
import com.xkl.service.IReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;


/**
 * 上传报告及删除报告接口。
 */
@RestController
@RequestMapping("/uspih/report")
public class UspihReportController {

    @Autowired
    private UpSoftVersionRepository upSoftVersionRepository;

    @Autowired
    private IReportService reportService;

    @Autowired
    private ReportRepository reportRepository;

    @Autowired
    private ReportDetailRepository reportDetailRepository;


    @Autowired
    private UserRepository userRepository;

    @Autowired
    private AdminRepository adminRepository;

    @RequestMapping(method = RequestMethod.POST)
    @AntiXSS
    @Authorization
    @ApiOperation(value = "上传并存储报告/Upload and save report")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "authorization", value = "请输入登录返回信息:userId_tokens", required = true, dataType = "string", paramType = "header"),
    })
    public ResponseEntity<ResultModel> save(@CurrentAdmin XklAdminEntity admin, @RequestParam String json_report) {
        // 其中json_report格式为上传软件上传上来的原始report格式。
        return reportService.save(admin, json_report);
    }

    @RequestMapping(method = RequestMethod.DELETE)
    @AntiXSS
    @Authorization
    @ApiOperation(value = "删除报告/Delete report with report id")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "authorization", value = "请输入登录返回信息:userId_tokens", required = true, dataType = "string", paramType = "header"),
    })
    public ResponseEntity<ResultModel> delete(@CurrentAdmin XklAdminEntity admin, @RequestParam long report_id) {
        return reportService.delete(admin, report_id);
    }

}