Procházet zdrojové kódy

评价中商品类型新增

limin před 7 roky
rodič
revize
80ebddae8b

+ 5 - 7
src/main/java/com/goafanti/comment/bo/CommentInput.java

@@ -5,7 +5,7 @@ public class CommentInput {
 	private String content;
 	private Integer star;
 	private String orderNo;
-	private Integer type;//项目 0  顾问、专家 1
+	private Integer commodityType;//0-项目,1-成果,2-需求,3-专家,4-顾问
 public String getCommodityId() {
 	return commodityId;
 }
@@ -30,12 +30,10 @@ public String getOrderNo() {
 public void setOrderNo(String orderNo) {
 	this.orderNo = orderNo;
 }
-
-public Integer getType() {
-	return type;
+public Integer getCommodityType() {
+	return commodityType;
 }
-public void setType(Integer type) {
-	this.type = type;
+public void setCommodityType(Integer commodityType) {
+	this.commodityType = commodityType;
 }
-
 }

+ 4 - 1
src/main/java/com/goafanti/comment/service/impl/CommentServiceImpl.java

@@ -57,6 +57,7 @@ public class CommentServiceImpl extends BaseMybatisDao<JtCommodityCommentMapper>
 		jtCommodityComment.setId(id);
 		jtCommodityComment.setIp(ip);
 		jtCommodityComment.setStar(commentInput.getStar());
+		jtCommodityComment.setCommodityType(commentInput.getCommodityType());
 		
 		//用户id或者订单id如果不存在(匿名评论)
 		if(StringUtils.isBlank(commentInput.getOrderNo())){
@@ -67,7 +68,9 @@ public class CommentServiceImpl extends BaseMybatisDao<JtCommodityCommentMapper>
 			//查看当前ip的游客名称和游客最大名称
 			uid = jtCommodityCommentMapper.getUidByIp(ip);
 			if(StringUtils.isBlank(uid)){
-				int c = Integer.parseInt(jtCommodityCommentMapper.getMaxNameUid()) + 1;
+				uid = jtCommodityCommentMapper.getMaxNameUid();
+				uid = StringUtils.isBlank(uid) ? "0" : uid;//如果是第一个游客
+				int c = Integer.parseInt(uid) + 1;
 				uid = "游客" + String.format("%03d", c);
 			}
 		}

+ 5 - 1
src/main/java/com/goafanti/common/controller/PublicController.java

@@ -701,12 +701,16 @@ public class PublicController extends BaseController {
 		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) {
+		if(null == commentInput.getStar()  || 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;
 		}
+		if(null == commentInput.getCommodityType() || commentInput.getCommodityType()<0 || commentInput.getCommodityType() > 4) {
+			result.getError().add(buildError(ErrorConstants.PARAM_ERROR,"","产品类型"));return result;
+		}
+		
 		int res=commentService.addNewComment(commentInput,ip);
 		if(res ==-1) {
 			result.getError().add(buildError(ErrorConstants.PARAM_ERROR,"","提交失败"));return result;

+ 20 - 5
src/main/java/com/goafanti/common/mapper/JtCommodityCommentMapper.xml

@@ -15,6 +15,7 @@
     <result column="star" jdbcType="INTEGER" property="star" />
     <result column="ip" jdbcType="VARCHAR" property="ip" />
     <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
+    <result column="commodity_type" jdbcType="INTEGER" property="commodityType" />
   </resultMap>
   <sql id="Example_Where_Clause">
     <!--
@@ -90,7 +91,7 @@
       This element is automatically generated by MyBatis Generator, do not modify.
       This element was generated on Thu Jul 19 10:59:39 CST 2018.
     -->
-    id, commodity_id, uid, order_no, content, star, ip, create_time
+    id, commodity_id, uid, order_no, content, star, ip, create_time, commodity_type
   </sql>
   <select id="selectByExample" parameterType="com.goafanti.common.model.JtCommodityCommentExample" resultMap="BaseResultMap">
     <!--
@@ -150,10 +151,10 @@
     -->
     insert into jt_commodity_comment (id, commodity_id, uid, 
       order_no, content, star, 
-      ip, create_time)
+      ip, create_time, commodity_type)
     values (#{id,jdbcType=VARCHAR}, #{commodityId,jdbcType=VARCHAR}, #{uid,jdbcType=VARCHAR}, 
       #{orderNo,jdbcType=VARCHAR}, #{content,jdbcType=VARCHAR}, #{star,jdbcType=INTEGER}, 
-      #{ip,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP})
+      #{ip,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, #{commodityType,jdbcType=INTEGER})
   </insert>
   <insert id="insertSelective" parameterType="com.goafanti.common.model.JtCommodityComment">
     <!--
@@ -187,6 +188,9 @@
       <if test="createTime != null">
         create_time,
       </if>
+      <if test="commodityType != null">
+        commodity_type,
+      </if>
     </trim>
     <trim prefix="values (" suffix=")" suffixOverrides=",">
       <if test="id != null">
@@ -213,6 +217,9 @@
       <if test="createTime != null">
         #{createTime,jdbcType=TIMESTAMP},
       </if>
+      <if test="commodityType != null">
+        #{commodityType,jdbcType=INTEGER},
+      </if>
     </trim>
   </insert>
   <select id="countByExample" parameterType="com.goafanti.common.model.JtCommodityCommentExample" resultType="java.lang.Long">
@@ -258,6 +265,9 @@
       <if test="record.createTime != null">
         create_time = #{record.createTime,jdbcType=TIMESTAMP},
       </if>
+      <if test="record.commodityType != null">
+        commodity_type = #{record.commodityType,jdbcType=INTEGER},
+      </if>
     </set>
     <if test="_parameter != null">
       <include refid="Update_By_Example_Where_Clause" />
@@ -277,7 +287,8 @@
       content = #{record.content,jdbcType=VARCHAR},
       star = #{record.star,jdbcType=INTEGER},
       ip = #{record.ip,jdbcType=VARCHAR},
-      create_time = #{record.createTime,jdbcType=TIMESTAMP}
+      create_time = #{record.createTime,jdbcType=TIMESTAMP},
+      commodity_type = #{record.commodityType,jdbcType=INTEGER}
     <if test="_parameter != null">
       <include refid="Update_By_Example_Where_Clause" />
     </if>
@@ -311,6 +322,9 @@
       <if test="createTime != null">
         create_time = #{createTime,jdbcType=TIMESTAMP},
       </if>
+      <if test="commodityType != null">
+        commodity_type = #{commodityType,jdbcType=INTEGER},
+      </if>
     </set>
     where id = #{id,jdbcType=VARCHAR}
   </update>
@@ -327,7 +341,8 @@
       content = #{content,jdbcType=VARCHAR},
       star = #{star,jdbcType=INTEGER},
       ip = #{ip,jdbcType=VARCHAR},
-      create_time = #{createTime,jdbcType=TIMESTAMP}
+      create_time = #{createTime,jdbcType=TIMESTAMP},
+      commodity_type = #{commodityType,jdbcType=INTEGER}
     where id = #{id,jdbcType=VARCHAR}
   </update>
   <select id="getCommentCount" resultType="java.lang.Integer">

+ 11 - 0
src/main/java/com/goafanti/common/model/JtCommodityComment.java

@@ -188,4 +188,15 @@ public class JtCommodityComment {
 	public void setCreateTime(Date createTime) {
 		this.createTime = createTime;
 	}
+	
+	private Integer commodityType;
+
+	public Integer getCommodityType() {
+		return commodityType;
+	}
+
+	public void setCommodityType(Integer commodityType) {
+		this.commodityType = commodityType;
+	}
+	
 }

+ 1 - 1
src/main/webapp/WEB-INF/views/portal/service/safeguarding.html

@@ -141,7 +141,7 @@
 	</footer>
 	<div th:replace="common::footer(~{::script})">
 		<script type="text/javascript" th:src="${portalHost + '/vendors.js'}"></script>
-		<script type="text/javascript" th:src="${portalHost+'/newMenu/services.js'}"></script>
+		<script type="text/javascript" th:src="${portalHost+'/newMenu/safeguarding.js'}"></script>
 	</div>
 </body>
 </html>