| | |
| | | @RequestMapping(value = "saveHead") |
| | | public void saveHead(String callback, GoodsEvaluate evaluate, HttpServletRequest request, PrintWriter out) { |
| | | try { |
| | | String id = null; |
| | | if (request instanceof MultipartHttpServletRequest) { |
| | | MultipartHttpServletRequest fileRequest = (MultipartHttpServletRequest) request; |
| | | goodsEvaluateService.saveHead(fileRequest.getFile("portraitFile"), evaluate); |
| | | id = goodsEvaluateService.saveHead(fileRequest.getFile("portraitFile"), evaluate); |
| | | } else { |
| | | goodsEvaluateService.saveHead(null, evaluate); |
| | | id = goodsEvaluateService.saveHead(null, evaluate); |
| | | } |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("保存成功")); |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(id)); |
| | | } catch (GoodsEvaluateException e) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg())); |
| | | } catch (Exception e) { |
| | |
| | | private PinDuoDuoCacheUtil pinDuoDuoCacheUtil; |
| | | |
| | | @Override |
| | | public void saveHead(MultipartFile file, GoodsEvaluate record) throws GoodsEvaluateException { |
| | | public String saveHead(MultipartFile file, GoodsEvaluate record) throws GoodsEvaluateException { |
| | | Integer state = record.getState(); |
| | | if (state == null) { |
| | | state = 0; |
| | |
| | | record.setStartTime(new Date()); |
| | | record.setPublishTime(record.getStartTime()); |
| | | |
| | | if (StringUtil.isNullOrEmpty(record.getId())) { |
| | | record.setId(UUID.randomUUID().toString().replace("-", "")); |
| | | String id = record.getId(); |
| | | if (StringUtil.isNullOrEmpty(id)) { |
| | | id = UUID.randomUUID().toString().replace("-", ""); |
| | | record.setId(id); |
| | | record.setShareNumReal(0); |
| | | record.setCreateTime(new Date()); |
| | | goodsEvaluateDao.save(record); |
| | | } else { |
| | | GoodsEvaluate resultObj = goodsEvaluateDao.getById(record.getId()); |
| | | GoodsEvaluate resultObj = goodsEvaluateDao.getById(id); |
| | | if (resultObj == null) |
| | | throw new GoodsEvaluateException(1, "修改内容已不存在"); |
| | | |
| | |
| | | resultObj.setTitle(tilte); |
| | | goodsEvaluateDao.save(resultObj); |
| | | } |
| | | return id; |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | public interface GoodsEvaluateService { |
| | | |
| | | public void saveHead(MultipartFile file, GoodsEvaluate record) throws GoodsEvaluateException; |
| | | public String saveHead(MultipartFile file, GoodsEvaluate record) throws GoodsEvaluateException; |
| | | |
| | | |
| | | public GoodsEvaluate getById(String id); |