| | |
| | | import com.highdatas.srs.util.DbUtils; |
| | | import com.highdatas.srs.util.FileUtils; |
| | | import lombok.extern.java.Log; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.web.bind.annotation.*; |
| | |
| | | @RequestMapping("topicUpload") |
| | | @ResponseBody |
| | | public Result topicUpload(@RequestParam("file") MultipartFile file, HttpServletRequest request){ |
| | | String id = request.getParameter("id"); |
| | | String title = request.getParameter("title"); |
| | | String desp = request.getParameter("desp"); |
| | | String userId = request.getParameter("userId"); |
| | | |
| | | Topic topic = new Topic().setId(DbUtils.getUUID()).setTitle(title).setDesp(desp).setUserId(userId).setCreateTime(new Date()); |
| | | Topic topic; |
| | | if (StringUtils.isEmpty(id)) { |
| | | topic = new Topic().setId(DbUtils.getUUID()).setTitle(title).setDesp(desp).setUserId(userId).setCreateTime(new Date()); |
| | | } else { |
| | | topic = topicService.selectById(id).setTitle(title).setDesp(desp); |
| | | } |
| | | |
| | | String fileName = file.getOriginalFilename(); |
| | | int size = (int) file.getSize(); |
| | |
| | | dest.createNewFile(); |
| | | file.transferTo(dest); //保存文件 |
| | | topic.setAttachment(path); |
| | | topic.insert(); |
| | | topic.insertOrUpdate(); |
| | | return Result.success(CodeMsg.SUCCESS); |
| | | } catch (IllegalStateException e) { |
| | | // TODO Auto-generated catch block |