|
|
@@ -2,6 +2,7 @@ package com.goafanti.copyright.controller;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
import javax.validation.Valid;
|
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
@@ -32,7 +33,7 @@ import com.goafanti.core.shiro.token.TokenManager;
|
|
|
@RequestMapping(value = "/techservice/copyright")
|
|
|
public class CopyrightApiController extends CertifyApiController {
|
|
|
@Resource
|
|
|
- private CopyrightInfoService copyrightInfoService;
|
|
|
+ private CopyrightInfoService copyrightInfoService;
|
|
|
|
|
|
@RequestMapping(value = "/apply", method = RequestMethod.POST)
|
|
|
public Result newApply(@Valid InputCopyright inputInfo, BindingResult bindingResult) {
|
|
|
@@ -163,6 +164,38 @@ public class CopyrightApiController extends CertifyApiController {
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
+ @RequestMapping(value = "/download", method = RequestMethod.GET)
|
|
|
+ public Result download(String id, String sign, HttpServletResponse response) {
|
|
|
+ Result res = new Result();
|
|
|
+ if (!checkUserLogin(res)) {
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+ User curUser = TokenManager.getUserToken();
|
|
|
+ if (!checkCertify(res, curUser)) {
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+ if (StringUtils.isEmpty(id)) {
|
|
|
+ res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "软著id"));
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+ CopyrightInfoDetail ci = copyrightInfoService.findByPrimaryKey(id);
|
|
|
+ if (ci == null || !curUser.getId().equals(ci.getUid())) {
|
|
|
+ res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "软著id"));
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+ AttachmentType attachmentType = AttachmentType.getField(sign);
|
|
|
+ if (attachmentType == AttachmentType.COPYRIGHT_APPLY || attachmentType == AttachmentType.COPYRIGHT_AUTH) {
|
|
|
+ if (attachmentType == AttachmentType.COPYRIGHT_APPLY) {
|
|
|
+ downloadFile(response, ci.getApplicationUrlDownloadFileName(), ci.getApplicationUrl());
|
|
|
+ } else if (attachmentType == AttachmentType.COPYRIGHT_AUTH) {
|
|
|
+ downloadFile(response, ci.getCertificateUrlDownloadFileName(), ci.getCertificateUrl());
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "附件标示"));
|
|
|
+ }
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
@RequestMapping(value = "/logs", method = RequestMethod.GET)
|
|
|
public Result logs(String id) {
|
|
|
Result res = new Result();
|