Sfoglia il codice sorgente

change property `userId` of Coupon to `validUserId`

tubinyan 5 anni fa
parent
commit
870be374e0

+ 1 - 1
sql/courselearning.sql

@@ -324,7 +324,7 @@ CREATE TABLE `coupon` (
   `name` varchar(255) NOT NULL,
   `description` varchar(255) NOT NULL,
   `course_id` int DEFAULT '-1',
-  `user_id` int DEFAULT '-1',
+  `valid_user_id` int DEFAULT '-1',
   `threshold` int DEFAULT '0',
   `discount` double DEFAULT '1.0',
   `cut_down` int DEFAULT '0',

+ 1 - 1
src/main/java/cn/seecoder/courselearning/dto/UserCouponDTO.java

@@ -15,7 +15,7 @@ public class UserCouponDTO {
     private String name;
     private String description;
     private Integer courseId;
-    private Integer userId;
+    private Integer validUserId;
     private double discount;
     private Integer threshold;
     private Integer cutDown;

+ 3 - 2
src/main/java/cn/seecoder/courselearning/po/Coupon.java

@@ -37,8 +37,9 @@ public class Coupon {
 
     /**
      * 如果为-1,表示对所有用户均有效
+     * 当前优惠券对 userId 对应的用户生效
      */
-    private Integer userId;
+    private Integer validUserId;
 
     /**
      * 使用门槛
@@ -80,7 +81,7 @@ public class Coupon {
         this.name = couponVO.getName();
         this.description = couponVO.getDescription();
         this.courseId = couponVO.getCourseId();
-        this.userId = couponVO.getUserId();
+        this.validUserId = couponVO.getValidUserId();
         this.threshold = couponVO.getThreshold();
         this.discount = couponVO.getDiscount();
         this.cutDown = couponVO.getCutDown();

+ 2 - 2
src/main/java/cn/seecoder/courselearning/vo/CouponVO.java

@@ -37,7 +37,7 @@ public class CouponVO {
     /**
      * 如果为-1,表示对所有用户均有效
      */
-    private Integer userId;
+    private Integer validUserId;
 
     /**
      * 满减型 - 使用门槛
@@ -79,7 +79,7 @@ public class CouponVO {
         this.name = coupon.getName();
         this.description = coupon.getDescription();
         this.courseId = coupon.getCourseId();
-        this.userId = coupon.getUserId();
+        this.validUserId = coupon.getValidUserId();
         this.threshold = coupon.getThreshold();
         this.discount = coupon.getDiscount();
         this.cutDown = coupon.getCutDown();

+ 12 - 12
src/main/resources/mapper/CouponMapper.xml

@@ -7,7 +7,7 @@
     <result column="name" jdbcType="VARCHAR" property="name" />
     <result column="description" jdbcType="VARCHAR" property="description" />
     <result column="course_id" jdbcType="INTEGER" property="courseId" />
-    <result column="user_id" jdbcType="INTEGER" property="userId" />
+    <result column="valid_user_id" jdbcType="INTEGER" property="validUserId" />
     <result column="threshold" jdbcType="INTEGER" property="threshold" />
     <result column="discount" jdbcType="DOUBLE" property="discount" />
     <result column="cut_down" jdbcType="INTEGER" property="cutDown" />
@@ -22,12 +22,12 @@
   </delete>
   <insert id="insert" parameterType="cn.seecoder.courselearning.po.Coupon" useGeneratedKeys="true" keyProperty="id">
     insert into coupon (id, type, name, 
-      description, course_id, user_id, 
+      description, course_id, valid_user_id, 
       threshold, discount, cut_down, 
       start_time, end_time, effective, 
       sharable)
     values (#{id,jdbcType=INTEGER}, #{type,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, 
-      #{description,jdbcType=VARCHAR}, #{courseId,jdbcType=INTEGER}, #{userId,jdbcType=INTEGER}, 
+      #{description,jdbcType=VARCHAR}, #{courseId,jdbcType=INTEGER}, #{validUserId,jdbcType=INTEGER}, 
       #{threshold,jdbcType=INTEGER}, #{discount,jdbcType=DOUBLE}, #{cutDown,jdbcType=INTEGER}, 
       #{startTime,jdbcType=TIMESTAMP}, #{endTime,jdbcType=TIMESTAMP}, #{effective,jdbcType=BIT}, 
       #{sharable,jdbcType=BIT})
@@ -38,7 +38,7 @@
       name = #{name,jdbcType=VARCHAR},
       description = #{description,jdbcType=VARCHAR},
       course_id = #{courseId,jdbcType=INTEGER},
-      user_id = #{userId,jdbcType=INTEGER},
+      valid_user_id = #{validUserId,jdbcType=INTEGER},
       threshold = #{threshold,jdbcType=INTEGER},
       discount = #{discount,jdbcType=DOUBLE},
       cut_down = #{cutDown,jdbcType=INTEGER},
@@ -49,32 +49,32 @@
     where id = #{id,jdbcType=INTEGER}
   </update>
   <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
-    select id, type, name, description, course_id, user_id, threshold, discount, cut_down, 
+    select id, type, name, description, course_id, valid_user_id, threshold, discount, cut_down, 
     start_time, end_time, effective, sharable
     from coupon
     where id = #{id,jdbcType=INTEGER}
   </select>
   <select id="selectAll" resultMap="BaseResultMap">
-    select id, type, name, description, course_id, user_id, threshold, discount, cut_down, 
+    select id, type, name, description, course_id, valid_user_id, threshold, discount, cut_down, 
     start_time, end_time, effective, sharable
     from coupon
   </select>
 <!--  <select id="selectAllCourseCoupon" parameterType="java.lang.Integer" resultMap="BaseResultMap">-->
-<!--    select id, type, name, description, course_id, user_id, threshold, discount, cut_down,-->
+<!--    select id, type, name, description, course_id, valid_user_id, threshold, discount, cut_down,-->
 <!--           start_time, end_time, effective, sharable-->
 <!--    from coupon-->
-<!--    where (course_id = -1 or course_id = #{courseId,jdbcType=INTEGER}) and user_id = -1-->
+<!--    where (course_id = -1 or course_id = #{courseId,jdbcType=INTEGER}) and valid_user_id = -1-->
 <!--  </select>-->
   <select id="selectByCourseIdAndUserId" parameterType="java.lang.Integer" resultMap="BaseResultMap">
-    select id, type, name, description, course_id, user_id, threshold, discount, cut_down,
+    select id, type, name, description, course_id, valid_user_id, threshold, discount, cut_down,
            start_time, end_time, effective, sharable
     from coupon
-    where course_id = #{courseId,jdbcType=INTEGER} and user_id = #{userId,jdbcType=INTEGER}
+    where course_id = #{courseId,jdbcType=INTEGER} and valid_user_id = #{validUserId,jdbcType=INTEGER}
   </select>
   <select id="selectByUserId" parameterType="java.lang.Integer" resultMap="BaseResultMap">
-    select id, type, name, description, course_id, user_id, threshold, discount, cut_down,
+    select id, type, name, description, course_id, valid_user_id, threshold, discount, cut_down,
            start_time, end_time, effective, sharable
     from coupon
-    where user_id = #{userId,jdbcType=INTEGER}
+    where valid_user_id = #{validUserId,jdbcType=INTEGER}
   </select>
 </mapper>