@Test public void testAddShare() throws Exception { shareService.addShare(10000L, 20L, "111", new ArrayList<MultipartFile>()); }
@Override public boolean addShare(Long accountId, Long commId, String desc, List<MultipartFile> imgs) { Share hasShare = shareMapper.selectByCommId(commId); if (null != hasShare) return false; Commodity com = commMapper.selectByKey(commId); if ((com.getShareState() == null ? 0 : com.getShareState()) == 1) return false; Share share = new Share(); share.setCommodityId(commId); share.setIssueDate(new Date().getTime()); share.setParticulars(desc); share.setUserAccountId(accountId); shareMapper.insertByGeneratedKeys(share); for (MultipartFile img : imgs) { ShareImg shareImg = new ShareImg(); String filename = uploadToQiniu(img); String url = qiniuhost + filename; shareImg.setShareId(share.getId()); shareImg.setShareImgUrl(url); shareImgMapper.insert(shareImg); } commMapper.updateShareStateByCommodityId(com.getId(), SHARE_STATE_YET); commodityHistoryMapper.updateShareStateByCommodityId(com.getId(), SHARE_STATE_YET); return true; }
ShareServiceImpl implements IShareService { @Override public boolean addShare(Long accountId, Long commId, String desc, List<MultipartFile> imgs) { Share hasShare = shareMapper.selectByCommId(commId); if (null != hasShare) return false; Commodity com = commMapper.selectByKey(commId); if ((com.getShareState() == null ? 0 : com.getShareState()) == 1) return false; Share share = new Share(); share.setCommodityId(commId); share.setIssueDate(new Date().getTime()); share.setParticulars(desc); share.setUserAccountId(accountId); shareMapper.insertByGeneratedKeys(share); for (MultipartFile img : imgs) { ShareImg shareImg = new ShareImg(); String filename = uploadToQiniu(img); String url = qiniuhost + filename; shareImg.setShareId(share.getId()); shareImg.setShareImgUrl(url); shareImgMapper.insert(shareImg); } commMapper.updateShareStateByCommodityId(com.getId(), SHARE_STATE_YET); commodityHistoryMapper.updateShareStateByCommodityId(com.getId(), SHARE_STATE_YET); return true; } }
ShareServiceImpl implements IShareService { @Override public boolean addShare(Long accountId, Long commId, String desc, List<MultipartFile> imgs) { Share hasShare = shareMapper.selectByCommId(commId); if (null != hasShare) return false; Commodity com = commMapper.selectByKey(commId); if ((com.getShareState() == null ? 0 : com.getShareState()) == 1) return false; Share share = new Share(); share.setCommodityId(commId); share.setIssueDate(new Date().getTime()); share.setParticulars(desc); share.setUserAccountId(accountId); shareMapper.insertByGeneratedKeys(share); for (MultipartFile img : imgs) { ShareImg shareImg = new ShareImg(); String filename = uploadToQiniu(img); String url = qiniuhost + filename; shareImg.setShareId(share.getId()); shareImg.setShareImgUrl(url); shareImgMapper.insert(shareImg); } commMapper.updateShareStateByCommodityId(com.getId(), SHARE_STATE_YET); commodityHistoryMapper.updateShareStateByCommodityId(com.getId(), SHARE_STATE_YET); return true; }  }
ShareServiceImpl implements IShareService { @Override public boolean addShare(Long accountId, Long commId, String desc, List<MultipartFile> imgs) { Share hasShare = shareMapper.selectByCommId(commId); if (null != hasShare) return false; Commodity com = commMapper.selectByKey(commId); if ((com.getShareState() == null ? 0 : com.getShareState()) == 1) return false; Share share = new Share(); share.setCommodityId(commId); share.setIssueDate(new Date().getTime()); share.setParticulars(desc); share.setUserAccountId(accountId); shareMapper.insertByGeneratedKeys(share); for (MultipartFile img : imgs) { ShareImg shareImg = new ShareImg(); String filename = uploadToQiniu(img); String url = qiniuhost + filename; shareImg.setShareId(share.getId()); shareImg.setShareImgUrl(url); shareImgMapper.insert(shareImg); } commMapper.updateShareStateByCommodityId(com.getId(), SHARE_STATE_YET); commodityHistoryMapper.updateShareStateByCommodityId(com.getId(), SHARE_STATE_YET); return true; }  @Override String getUpToken(String suffix); @Override String uploadToQiniu(MultipartFile file); @Override String getUpToken(); @Override boolean isReady(); @Override Share getShare(Long shareId); @Override boolean addShare(Long accountId, Long commId, String desc, List<MultipartFile> imgs); @Override boolean deleteShare(Long shareid); @Override List<Share> selectShare(Long accountid, Long lastshareid, Integer tag); @Override boolean friendsShare(Long account); @Override List<Map<String, Object>> selectByUserAccountId(Long accountId, Long lastCommId); @Override List<Map<String, Object>> selectAll(Long lastCommId); @Override List<Map<String, Object>> selectByCommId(Long commId, Long lastCommId); List<String> imgUrl(Share s); }
ShareServiceImpl implements IShareService { @Override public boolean addShare(Long accountId, Long commId, String desc, List<MultipartFile> imgs) { Share hasShare = shareMapper.selectByCommId(commId); if (null != hasShare) return false; Commodity com = commMapper.selectByKey(commId); if ((com.getShareState() == null ? 0 : com.getShareState()) == 1) return false; Share share = new Share(); share.setCommodityId(commId); share.setIssueDate(new Date().getTime()); share.setParticulars(desc); share.setUserAccountId(accountId); shareMapper.insertByGeneratedKeys(share); for (MultipartFile img : imgs) { ShareImg shareImg = new ShareImg(); String filename = uploadToQiniu(img); String url = qiniuhost + filename; shareImg.setShareId(share.getId()); shareImg.setShareImgUrl(url); shareImgMapper.insert(shareImg); } commMapper.updateShareStateByCommodityId(com.getId(), SHARE_STATE_YET); commodityHistoryMapper.updateShareStateByCommodityId(com.getId(), SHARE_STATE_YET); return true; }  @Override String getUpToken(String suffix); @Override String uploadToQiniu(MultipartFile file); @Override String getUpToken(); @Override boolean isReady(); @Override Share getShare(Long shareId); @Override boolean addShare(Long accountId, Long commId, String desc, List<MultipartFile> imgs); @Override boolean deleteShare(Long shareid); @Override List<Share> selectShare(Long accountid, Long lastshareid, Integer tag); @Override boolean friendsShare(Long account); @Override List<Map<String, Object>> selectByUserAccountId(Long accountId, Long lastCommId); @Override List<Map<String, Object>> selectAll(Long lastCommId); @Override List<Map<String, Object>> selectByCommId(Long commId, Long lastCommId); List<String> imgUrl(Share s);  }