Quellcode durchsuchen

产品评论(不用登陆),页面的一些修改

limin vor 7 Jahren
Ursprung
Commit
82ef044f04

+ 7 - 3
src/main/java/com/goafanti/app/controller/AppOrderController.java

@@ -4,12 +4,15 @@ import java.math.BigDecimal;
 import java.text.ParseException;
 import java.util.ArrayList;
 import java.util.List;
+
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
+
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RestController;
+
 import com.goafanti.comment.bo.CommentInput;
 import com.goafanti.comment.controller.UserCommentController;
 import com.goafanti.comment.service.CommentService;
@@ -296,14 +299,14 @@ public class AppOrderController extends CertifyApiController{
 		if(commentInput.getStar()==null || commentInput.getStar()<0 || commentInput.getStar()>5) {
 			result.getError().add(buildError(ErrorConstants.PARAM_ERROR,"","评分"));return result;
 		}
-		if(StringUtils.isBlank(commentInput.getOrderNo())) {
+		/*if(StringUtils.isBlank(commentInput.getOrderNo())) {
 			result.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"","订单编号"));return result;
-		}
+		}*/
 		if(StringUtils.isBlank(commentInput.getContent()) || commentInput.getContent().length()>512) {
 			result.getError().add(buildError(ErrorConstants.PARAM_ERROR,"","内容限制1-512字符"));return result;
 		}
 		
-			int res=commentService.addNewComment(commentInput,ip);
+		int res=commentService.addNewComment(commentInput,ip);
 		if(res ==-1) {
 			result.getError().add(buildError(ErrorConstants.PARAM_ERROR,"","提交失败"));return result;
 		}
@@ -357,4 +360,5 @@ public class AppOrderController extends CertifyApiController{
 		result.setData(orders);
 		return result;
 	}  
+	
 }

+ 11 - 6
src/main/java/com/goafanti/comment/service/impl/CommentServiceImpl.java

@@ -16,8 +16,6 @@ import com.goafanti.common.dao.JtCommodityCommentMapper;
 import com.goafanti.common.dao.JtConsultOrderMapper;
 import com.goafanti.common.dao.JtOrderMapper;
 import com.goafanti.common.model.JtCommodityComment;
-import com.goafanti.common.model.JtConsultOrder;
-import com.goafanti.common.model.JtOrder;
 import com.goafanti.core.mybatis.BaseMybatisDao;
 import com.goafanti.core.mybatis.page.Pagination;
 import com.goafanti.core.shiro.token.TokenManager;
@@ -37,8 +35,10 @@ public class CommentServiceImpl extends BaseMybatisDao<JtCommodityCommentMapper>
 		String id=UUID.randomUUID().toString();
 		String uid=TokenManager.getUserId();
 //		String uid="1180fa62-7c42-44be-bc41-5583814d69f4";
-		JtOrder jtOrder= new JtOrder(); 
 		
+		//注释掉必须购买才能评价的条件
+		/*
+		JtOrder jtOrder= new JtOrder(); 
 		if (commentInput.getType()==0){
 			jtOrder=jtOrderMapper.selectByPrimaryKey(commentInput.getOrderNo());
 			if(jtOrder==null || jtOrder.getBuyerId()==null || !jtOrder.getBuyerId().equals(uid))return -1;
@@ -46,8 +46,8 @@ public class CommentServiceImpl extends BaseMybatisDao<JtCommodityCommentMapper>
 		if (commentInput.getType()==1){
 			JtConsultOrder jtConsultOrder=jtConsultOrderMapper.selectByPrimaryKey(commentInput.getOrderNo());
 			if(jtConsultOrder==null || jtConsultOrder.getBuyerId()==null || !jtConsultOrder.getBuyerId().equals(uid))return -1;
-		}
-			
+		}*/
+		
 		
 		JtCommodityComment jtCommodityComment=new JtCommodityComment();
 		jtCommodityComment.setCommodityId(commentInput.getCommodityId());
@@ -55,9 +55,14 @@ public class CommentServiceImpl extends BaseMybatisDao<JtCommodityCommentMapper>
 		jtCommodityComment.setCreateTime(new Date());
 		jtCommodityComment.setId(id);
 		jtCommodityComment.setIp(ip);
-		jtCommodityComment.setOrderNo(commentInput.getOrderNo());
 		jtCommodityComment.setStar(commentInput.getStar());
+		
+		//用户id和订单id如果不存在(匿名评论)
+		uid = null == uid ? "" : uid;
+		commentInput.setOrderNo( null == commentInput.getOrderNo()? "" : commentInput.getOrderNo());
+		
 		jtCommodityComment.setUid(uid);
+		jtCommodityComment.setOrderNo(commentInput.getOrderNo());
 		jtCommodityCommentMapper.insert(jtCommodityComment);
 		return 0;
 	}

+ 27 - 0
src/main/java/com/goafanti/common/controller/PublicController.java

@@ -21,7 +21,9 @@ import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.ResponseBody;
 
 import com.goafanti.achievement.service.AchievementService;
+import com.goafanti.comment.bo.CommentInput;
 import com.goafanti.comment.bo.CommentResult;
+import com.goafanti.comment.controller.UserCommentController;
 import com.goafanti.comment.service.CommentService;
 import com.goafanti.common.bo.Result;
 import com.goafanti.common.constant.ErrorConstants;
@@ -688,4 +690,29 @@ public class PublicController extends BaseController {
 		return res;
 	}
 	
+	/**
+	 * 新增评价
+	 */
+	@RequestMapping(value = "/addComment", method = RequestMethod.POST)
+	@ResponseBody
+	public Result addNewComment(HttpServletRequest request,CommentInput commentInput) {
+		Result result=new Result();
+		String ip=UserCommentController.getClientIp(request);
+		if(StringUtils.isBlank(commentInput.getCommodityId())) {
+			result.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"商品id为空","商品id"));return result;
+		}
+		if(commentInput.getStar()==null || commentInput.getStar()<0 || commentInput.getStar()>5) {
+			result.getError().add(buildError(ErrorConstants.PARAM_ERROR,"","评分"));return result;
+		}
+		if(StringUtils.isBlank(commentInput.getContent()) || commentInput.getContent().length()>512) {
+			result.getError().add(buildError(ErrorConstants.PARAM_ERROR,"","内容限制1-512字符"));return result;
+		}
+		int res=commentService.addNewComment(commentInput,ip);
+		if(res ==-1) {
+			result.getError().add(buildError(ErrorConstants.PARAM_ERROR,"","提交失败"));return result;
+		}
+		result.setData(res);
+		return result;
+	}
+	
 }

+ 1 - 1
src/main/webapp/WEB-INF/views/common.html

@@ -333,7 +333,7 @@
 						<a href="http://www.cshtz.gov.cn/" target="_blank">长沙市高新区管委会/</a>
 						<a href="http://www.jxas.ac.cn/" target="_blank">江西省科学院/</a>
 						<a href="http://www.cnic.cn/front/index.html#/cnicSite/home" target="_blank">中科院计算机网络信息中心/</a>
-						<a href="http://kxyjb.csu.edu.cn/" target="_blank">中南大学科学研究部/</a>
+						<!-- <a href="http://kxyjb.csu.edu.cn/" target="_blank">中南大学科学研究部/</a> -->
 						<a href="http://www.cast.org.cn/" target="_blank">中国科协创新创业服务中心/</a>
 						<a href="http://www.hbstd.gov.cn/" target="_blank">湖北省科技厅/</a>
 						<a href="http://www.gdstc.gov.cn/" target="_blank">广东省科技厅/</a>

Datei-Diff unterdrückt, da er zu groß ist
+ 1 - 1
src/main/webapp/WEB-INF/views/portal/service/patenteDetails.html


Datei-Diff unterdrückt, da er zu groß ist
+ 1 - 1
src/main/webapp/WEB-INF/views/portal/service/serviceDetails.html


Datei-Diff unterdrückt, da er zu groß ist
+ 1 - 1
src/main/webapp/WEB-INF/views/portal/service/serviceIndex.html