Commit 82f7792c by shiwenbo

购砂单位系统和场站系统中使用附件,上传人需要特殊处理

parent 7ff77771
......@@ -42,6 +42,8 @@ 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;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.multipart.MultipartFile;
import com.beecode.bap.attachment.AttachmentConstants.FileCheck;
......@@ -50,8 +52,9 @@ import com.beecode.bap.attachment.common.Utils;
import com.beecode.bap.attachment.exception.AttachmentDataDownLoadException;
import com.beecode.bap.attachment.exception.AttachmentDataUploadException;
import com.beecode.bap.attachment.exception.AttachmentException;
import com.beecode.bap.attachment.internal.CreatorAdapterService;
import com.beecode.bap.attachment.service.AttachmentService;
import com.beecode.inz.basis.pojo.SandUser;
import com.beecode.inz.basis.service.SandUserService;
import com.jiuqi.np.tenant.spring.TenantRuntime;
@RestController
......@@ -72,6 +75,9 @@ public class SandAttachmentController {
@Autowired
private AttachmentService attachmentService;
@Autowired
private SandUserService sandUserService;
@RequestMapping(value = "files", method = RequestMethod.POST)
@Transactional
......@@ -148,7 +154,7 @@ public class SandAttachmentController {
}
attachmentInfo.setFileType(Utils.getFileType(file.getOriginalFilename()));
attachmentInfo.setSize(file.getSize());
UUID currentCreatorId = getCurrentCreatorId();
UUID currentCreatorId = getCurrentSandUserId();
if (currentCreatorId != null) {
attachmentInfo.setCreatorId(currentCreatorId);
}
......@@ -483,15 +489,22 @@ public class SandAttachmentController {
return false;
}
@Autowired
private CreatorAdapterService creatorAdapterService;
// @Autowired
// private CreatorAdapterService creatorAdapterService;
private UUID getCurrentCreatorId() {
return creatorAdapterService.getCurrentCreatorId();
// private UUID getCurrentCreatorId() {
// return creatorAdapterService.getCurrentCreatorId();
// }
private UUID getCurrentSandUserId() {
ServletRequestAttributes attr = (ServletRequestAttributes) RequestContextHolder.currentRequestAttributes();
return (UUID)attr.getRequest().getSession().getAttribute("userId");
}
private String getCreatorName(UUID id) {
return creatorAdapterService.getCreatorName(id);
// return creatorAdapterService.getCreatorName(id);
SandUser user = sandUserService.getById(id);
return user.getTitle();
}
private Map<String, Object> toMap(AttachmentInfo info) {
......
......@@ -42,6 +42,8 @@ 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;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.multipart.MultipartFile;
import com.beecode.bap.attachment.AttachmentConstants.FileCheck;
......@@ -50,8 +52,9 @@ import com.beecode.bap.attachment.common.Utils;
import com.beecode.bap.attachment.exception.AttachmentDataDownLoadException;
import com.beecode.bap.attachment.exception.AttachmentDataUploadException;
import com.beecode.bap.attachment.exception.AttachmentException;
import com.beecode.bap.attachment.internal.CreatorAdapterService;
import com.beecode.bap.attachment.service.AttachmentService;
import com.beecode.inz.basis.pojo.WarehouseUser;
import com.beecode.inz.basis.service.WarehouseUserService;
import com.jiuqi.np.tenant.spring.TenantRuntime;
@RestController
......@@ -72,6 +75,9 @@ public class WarehouseAttachmentController {
@Autowired
private AttachmentService attachmentService;
@Autowired
private WarehouseUserService warehouseUserService;
@RequestMapping(value = "files", method = RequestMethod.POST)
@Transactional
......@@ -148,7 +154,7 @@ public class WarehouseAttachmentController {
}
attachmentInfo.setFileType(Utils.getFileType(file.getOriginalFilename()));
attachmentInfo.setSize(file.getSize());
UUID currentCreatorId = getCurrentCreatorId();
UUID currentCreatorId = getCurrentWarehouseUserId();
if (currentCreatorId != null) {
attachmentInfo.setCreatorId(currentCreatorId);
}
......@@ -483,15 +489,22 @@ public class WarehouseAttachmentController {
return false;
}
@Autowired
private CreatorAdapterService creatorAdapterService;
// @Autowired
// private CreatorAdapterService creatorAdapterService;
private UUID getCurrentCreatorId() {
return creatorAdapterService.getCurrentCreatorId();
// private UUID getCurrentCreatorId() {
// return creatorAdapterService.getCurrentCreatorId();
// }
private UUID getCurrentWarehouseUserId() {
ServletRequestAttributes attr = (ServletRequestAttributes) RequestContextHolder.currentRequestAttributes();
return (UUID)attr.getRequest().getSession().getAttribute("userId");
}
private String getCreatorName(UUID id) {
return creatorAdapterService.getCreatorName(id);
// return creatorAdapterService.getCreatorName(id);
WarehouseUser user = warehouseUserService.getById(id);
return user.getTitle();
}
private Map<String, Object> toMap(AttachmentInfo info) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment